From 904db593df914d2932d9c2f018b00987052461d7 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Mon, 27 Jan 2014 12:01:53 +0100 Subject: add a temporary logger command at remote server side --- mod/post.php | 1 + 1 file changed, 1 insertion(+) (limited to 'mod') diff --git a/mod/post.php b/mod/post.php index 965ba09a3..d01f61a5c 100644 --- a/mod/post.php +++ b/mod/post.php @@ -490,6 +490,7 @@ function post_post(&$a) { // Useful to get a health check on a remote site. // This will let us know if any important communication details // that we may have stored are no longer valid, regardless of xchan details. + logger('POST: got ping send pong now back: ' . z_root() , LOGGER_DEBUG ); $ret['success'] = true; $ret['site'] = array(); -- cgit v1.2.3 From aa285b83c1c8f674be8f200d4feae6299eafc436 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Tue, 28 Jan 2014 10:58:31 +0100 Subject: to make visible what I try, ping still won't work, but I'm confused about get_channel --- mod/admin.php | 8 +++++++- mod/post.php | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 950c7e5ce..e59f15c74 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -468,6 +468,7 @@ function admin_page_site(&$a) { } function admin_page_hubloc_post(&$a){ check_form_security_token_redirectOnErr('/admin/hubloc', 'admin_hubloc'); + require_once('include/zot.php'); //prepare for ping @@ -477,7 +478,12 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; - logger('hubloc_url : ' . $hublocurl , LOGGER_DEBUG); + logger('ping hubloc_url : ' . $hublocurl , LOGGER_DEBUG); + logger('ping get_channel : ' . print_r($a->get_channel(),true), LOGGER_DEBUG); + $m = zot_build_packet($a->get_channel(),'ping'); + $r = zot_zot($hubloc_url,$m); + logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); + } //if ( $_POST'' == "check" ) { diff --git a/mod/post.php b/mod/post.php index d01f61a5c..cce183e46 100644 --- a/mod/post.php +++ b/mod/post.php @@ -9,6 +9,8 @@ require_once('include/zot.php'); function post_init(&$a) { + logger('POST inside',LOGGER_DEBUG); + logger('POST given parameter: ' . print_r($_REQUEST,true), LOGGER_DEBUG); // Most access to this endpoint is via the post method. // Here we will pick out the magic auth params which arrive -- cgit v1.2.3 From ef97a454bbccbd9f7e0e63180c365ed3227fe42c Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Wed, 29 Jan 2014 15:45:35 +0100 Subject: ping gives us now a reply. But the reply doesnt contains useful data, requires still some investigations --- mod/admin.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index e59f15c74..1a284c42f 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -478,23 +478,25 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; - logger('ping hubloc_url : ' . $hublocurl , LOGGER_DEBUG); - logger('ping get_channel : ' . print_r($a->get_channel(),true), LOGGER_DEBUG); + + //perform ping $m = zot_build_packet($a->get_channel(),'ping'); + logger('ping message : ' . print_r($m,true), LOGGER_DEBUG); $r = zot_zot($hubloc_url,$m); logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); + + //unfotunatly zping wont work, I guess return format is not correct + //require_once('mod/zping.php'); + //$r = zping_content($hublocurl); + //logger('zping answer: ' . $r, LOGGER_DEBUG); + + //handle results and set the hubloc flags in db to make results visible - } - - //if ( $_POST'' == "check" ) { - // //todo - //} + //in case of repair store new pub key for tested hubloc (all channel with this hubloc) in db + //after repair set hubloc flags to 0 - //perform ping - //handle results and set the hubloc flags in db to make results visible + } - //in case of repair store new pub key for tested hubloc (all channel with this hubloc) in db - //after repair set hubloc flags to 0 goaway($a->get_baseurl(true) . '/admin/hubloc' ); return; -- cgit v1.2.3 From 0a2b2a139080b41c10bbc7fc0f3b24129f2c3c38 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Thu, 30 Jan 2014 10:39:09 +0100 Subject: attempt with fix URL for testing works --- mod/admin.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 1a284c42f..360eddd2a 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -9,7 +9,7 @@ * @param App $a */ function admin_post(&$a){ - + logger('admin_post', LOGGER_DEBUG); if(!is_site_admin()) { return; @@ -74,6 +74,7 @@ function admin_post(&$a){ */ function admin_content(&$a) { + logger('admin_content', LOGGER_DEBUG); if(!is_site_admin()) { return login(false); } @@ -478,11 +479,13 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; + $hublocurl = "http://fred-dev.michameer.dyndns.org/post"; //perform ping $m = zot_build_packet($a->get_channel(),'ping'); logger('ping message : ' . print_r($m,true), LOGGER_DEBUG); - $r = zot_zot($hubloc_url,$m); + logger('ping _REQUEST ' . print_r($_REQUEST,true), LOGGER_DEBUG); + $r = zot_zot($hublocurl,$m); logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); //unfotunatly zping wont work, I guess return format is not correct -- cgit v1.2.3 From c5ac5544cb02aa3194c5cab2b3ab736a2e19e6eb Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Thu, 30 Jan 2014 11:04:20 +0100 Subject: clean up logger commands. Placed apostrophs at the end from some comments to keep the syntax highlighting in vi working --- mod/admin.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 360eddd2a..12b847b03 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -479,12 +479,9 @@ function admin_page_hubloc_post(&$a){ intval($hublocid) ); $hublocurl = $arrhublocurl[0]['hubloc_url'] . '/post'; - $hublocurl = "http://fred-dev.michameer.dyndns.org/post"; //perform ping $m = zot_build_packet($a->get_channel(),'ping'); - logger('ping message : ' . print_r($m,true), LOGGER_DEBUG); - logger('ping _REQUEST ' . print_r($_REQUEST,true), LOGGER_DEBUG); $r = zot_zot($hublocurl,$m); logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); -- cgit v1.2.3 From c0f02d774a0af0f0959a7690dadb30586ee0b6b1 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Thu, 30 Jan 2014 20:41:40 +0100 Subject: started analysis of ping response and clean up more logger --- mod/admin.php | 13 +++++++++++-- mod/post.php | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 12b847b03..76decae09 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -483,14 +483,23 @@ function admin_page_hubloc_post(&$a){ //perform ping $m = zot_build_packet($a->get_channel(),'ping'); $r = zot_zot($hublocurl,$m); - logger('ping answer: ' . print_r($r,true), LOGGER_DEBUG); + //handle results and set the hubloc flags in db to make results visible + $r2 = $r[body]; + $r3 = $r2[success]; + if ( $r3[success] == True ){ + //set HUBLOC_OFFLINE to 0 + logger(' success = true ',LOGGER_DEBUG); + } else { + //set HUBLOC_OFFLINE to 1 + logger(' success = false ', LOGGER_DEBUG); + + } //unfotunatly zping wont work, I guess return format is not correct //require_once('mod/zping.php'); //$r = zping_content($hublocurl); //logger('zping answer: ' . $r, LOGGER_DEBUG); - //handle results and set the hubloc flags in db to make results visible //in case of repair store new pub key for tested hubloc (all channel with this hubloc) in db //after repair set hubloc flags to 0 diff --git a/mod/post.php b/mod/post.php index cce183e46..cb0dc8302 100644 --- a/mod/post.php +++ b/mod/post.php @@ -9,8 +9,6 @@ require_once('include/zot.php'); function post_init(&$a) { - logger('POST inside',LOGGER_DEBUG); - logger('POST given parameter: ' . print_r($_REQUEST,true), LOGGER_DEBUG); // Most access to this endpoint is via the post method. // Here we will pick out the magic auth params which arrive @@ -257,6 +255,11 @@ function post_init(&$a) { $a->set_groups(init_groups_visitor($_SESSION['visitor_id'])); info(sprintf( t('Welcome %s. Remote authentication successful.'),$x[0]['xchan_name'])); logger('mod_zot: auth success from ' . $x[0]['xchan_addr']); + q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ", + intval(HUBLOC_WORKS), + intval($x[0]['hubloc_id']) + ); + } else { if($test) { @@ -447,14 +450,12 @@ function post_init(&$a) { function post_post(&$a) { - logger('mod_zot: ' . print_r($_REQUEST,true), LOGGER_DEBUG); $encrypted_packet = false; $ret = array('success' => false); $data = json_decode($_REQUEST['data'],true); - logger('mod_zot: data: ' . print_r($data,true), LOGGER_DATA); /** * Many message packets will arrive encrypted. The existence of an 'iv' element @@ -483,7 +484,6 @@ function post_post(&$a) { $data = array('type' => 'bogus'); } - logger('mod_zot: decoded data: ' . print_r($data,true), LOGGER_DATA); $msgtype = ((array_key_exists('type',$data)) ? $data['type'] : ''); -- cgit v1.2.3