From 511c2d2c91825f56f5727f38de2b7c4c5137fc48 Mon Sep 17 00:00:00 2001 From: Fabrixxm Date: Tue, 23 Jun 2015 17:36:26 +0200 Subject: [PATCH] rino: settings in admin, choose lowest common on notify --- include/items.php | 9 +++------ mod/admin.php | 13 +++++++++++-- mod/dfrn_notify.php | 20 ++++++++++++++------ view/templates/admin_site.tpl | 1 + 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/include/items.php b/include/items.php index 2feab3ea18..a13abf2865 100644 --- a/include/items.php +++ b/include/items.php @@ -1987,12 +1987,8 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $rino = get_config('system','rino_encrypt'); - - if(! $rino) { - $rino = 0; - } else { - $rino = 2; - } + $rino = intval($rino); + @@ -2104,6 +2100,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if($page) $postvars['page'] = $page; + if($rino>0 && $rino_remote_version>0 && (! $dissolve)) { logger('rino version: '. $rino_remote_version); diff --git a/mod/admin.php b/mod/admin.php index 78735262c2..fbbd6ffe4e 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -379,7 +379,9 @@ function admin_page_site_post(&$a){ $proxy_disabled = ((x($_POST,'proxy_disabled')) ? True : False); $old_pager = ((x($_POST,'old_pager')) ? True : False); $only_tag_search = ((x($_POST,'only_tag_search')) ? True : False); - + $rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0); + + if($ssl_policy != intval(get_config('system','ssl_policy'))) { if($ssl_policy == SSL_POLICY_FULL) { q("update `contact` set @@ -432,6 +434,7 @@ function admin_page_site_post(&$a){ set_config('system','suppress_tags',$suppress_tags); set_config('system','shortcut_icon',$shortcut_icon); set_config('system','touch_icon',$touch_icon); + if ($banner==""){ // don't know why, but del_config doesn't work... q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", @@ -515,6 +518,9 @@ function admin_page_site_post(&$a){ set_config('system','old_pager', $old_pager); set_config('system','only_tag_search', $only_tag_search); + set_config('system','rino_encrypt', $rino); + + info( t('Site settings updated.') . EOL); goaway($a->get_baseurl(true) . '/admin/site' ); return; // NOTREACHED @@ -695,7 +701,10 @@ function admin_page_site(&$a) { '$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")), '$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), "Change base url for this server. Sends relocate message to all DFRN contacts of all users."), - '$form_security_token' => get_form_security_token("admin_site") + + '$rino' => array('rino', t("RINO Encription"), intval(get_config('system','rino_encrypt')), t("Encription layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")), + + '$form_security_token' => get_form_security_token("admin_site") )); diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index c8b7438c19..874f17c772 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -134,6 +134,14 @@ function dfrn_notify_post(&$a) { if(strlen($key)) { + + // if local rino is lower than remote rino, abort: should not happen! + // but only for $remote_rino > 1, because old code did't send rino version + if ($rino_remote_version > 1 && $rino < $rino_remote) { + logger("rino version '$rino_remote' is lower than supported '$rino'"); + xml_status(0,"rino version '$rino_remote' is lower than supported '$rino'"); + } + $rawkey = hex2bin(trim($key)); logger('rino: md5 raw key: ' . md5($rawkey)); $final_key = ''; @@ -208,6 +216,7 @@ function dfrn_notify_content(&$a) { $dfrn_id = notags(trim($_GET['dfrn_id'])); $dfrn_version = (float) $_GET['dfrn_version']; + $rino_remote = ((x($_GET,'rino')) ? intval($_GET['rino']) : 0); $type = ""; $last_update = ""; @@ -288,12 +297,11 @@ function dfrn_notify_content(&$a) { $rino = get_config('system','rino_encrypt'); - - if(! $rino){ - $rino = 0; - } else { - $rino = 2; - } + $rino = intval($rino); + + // if requested rino is lower than enabled local rino, lower local rino version + // if requested rino is higher than enabled local rino, reply with local rino + if ($rino_remote < $rino) $rino = $rino_remote; if((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) { $perm = 'rw'; diff --git a/view/templates/admin_site.tpl b/view/templates/admin_site.tpl index bcaed585c2..34c590b2ea 100644 --- a/view/templates/admin_site.tpl +++ b/view/templates/admin_site.tpl @@ -99,6 +99,7 @@

{{$advanced}}

+ {{include file="field_select.tpl" field=$rino}} {{include file="field_checkbox.tpl" field=$no_utf}} {{include file="field_checkbox.tpl" field=$verifyssl}} {{include file="field_input.tpl" field=$proxy}} -- 2.39.2