From 7bccbb21239ca3cecf2914e9b307ab1e1b1aa46e Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 18 Sep 2014 08:21:38 +0200 Subject: [PATCH] function log_cds added --- web/Obj/brisk.phh | 46 +++++++++++++++++++++++++++++++++++++++ web/Obj/sac-a-push.phh | 1 + web/index.php | 2 +- web/spush/brisk-spush.php | 14 ++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 391f0a8..881e9a3 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -79,6 +79,7 @@ define('DBG_LMOP', 0x0800); define('DBG_TRAC', 0x1000); define('DBG_SHME', 0x2000); define('DBG_ENGI', 0x4000); +define('DBG_CDS', 0x8000); // NOTE: BRISK DEBUG must be a numerical constant, not the result of operations on symbols define('BRISK_DEBUG', 0x0800); @@ -1000,10 +1001,24 @@ class Brisk var $delay_mgr; + var $cds; + public static $sess_cur; function Brisk() { + // create cds + $this->cds = new Curl_de_sac(); + + // create tor_chk_cls + $tor_chk_cls = new tor_chk_cmd_cls(); + + // registrer tor_chk_cls + printf("MAIN: Register 'tor_chk_cls'\n"); + if (($this->cds->cmd_cls_register($tor_chk_cls)) == FALSE) { + fprintf(STDERR, "MAIN: 'tor_chk_cls' registration failed\n"); + exit(1); + } } // constructor @@ -2354,6 +2369,10 @@ class Brisk log_main(sprintf("TROVATO LIBERO A [%d] sess [%s] name [%s] count [%d] name [%s] code [%s]", $idx, $sess, $name_new, count($this->user),$this->user[$real_idx]->name, $this->user[$real_idx]->code)); $ret = $this->user[$real_idx]; + if ($this->cds->execute("tor_chk", $this, $real_idx, $sess, $ip) == FALSE) { + log_main("cds_execute failed"); + } + return ($ret); } @@ -2707,6 +2726,33 @@ function log_mop($step, $log) } +function log_cds($log) +{ + GLOBAL $PHP_SELF; + + if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_CDS) == 0) + return; + + $sess = Brisk::sess_cur_get(); + if (isset($sess) == FALSE) + $ssess = "XXXX"; + else + $ssess = $sess; + + if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_CDS) == 0) + return; + + if ((BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_TRAC) + $btrace = btrace_line(debug_backtrace()); + else + $btrace = ""; + if (($fp = @fopen(LEGAL_PATH."/cds.log", 'a')) != FALSE) { + fwrite($fp, sprintf("CDS: [%f] [%s] [%s]\n", gettimeofday(TRUE), $log, $btrace)); + fclose($fp); + } +} + + function log_only2($log) { GLOBAL $PHP_SELF; diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 3f4f6c8..4e88985 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -931,6 +931,7 @@ class Sac_a_push { } // if (isset($this->s2u[$id]... } // foreach ($this->socks... printf("\n"); + $this->app->cds->process(); } // while (... } // function run(... diff --git a/web/index.php b/web/index.php index c53bc95..70e1ddd 100644 --- a/web/index.php +++ b/web/index.php @@ -356,13 +356,13 @@ function index_main(&$brisk, $transp_type, &$header_out, $remote_addr_full, $get } } + $banned = FALSE; if ($ACTION == "login" && isset($name)) { log_main("pre garbage_manager DUE"); if (isset($pass_private) == FALSE || $pass_private == "") { $pass_private = FALSE; - $banned = FALSE; if ($brisk->ban_check($remote_addr)) { // TODO: find a way to add a nonblocking sleep(5) here $banned = TRUE; diff --git a/web/spush/brisk-spush.php b/web/spush/brisk-spush.php index cbbce76..7b1ddc0 100755 --- a/web/spush/brisk-spush.php +++ b/web/spush/brisk-spush.php @@ -32,6 +32,7 @@ require_once($G_base."Obj/brisk.phh"); require_once($G_base."Obj/auth.phh"); require_once($G_base."Obj/zlibstream.phh"); require_once($G_base."Obj/mail.phh"); +require_once($G_base."Obj/curl-de-brisk.phh"); // require_once("../Obj/proxyscan.phh"); require_once($G_base."index.php"); require_once($G_base."index_wr.php"); @@ -44,6 +45,19 @@ function main($argv) { GLOBAL $G_ban_list, $G_black_list; + // create cds + $cds = new Curl_de_sac(); + + // create tor_chk_cls + $tor_chk_cls = new tor_chk_cmd_cls(); + + // registrer tor_chk_cls + printf("MAIN: Register 'tor_chk_cls'\n"); + if (($cds->cmd_cls_register($tor_chk_cls)) == FALSE) { + fprintf(STDERR, "MAIN: 'tor_chk_cls' registration failed\n"); + exit(1); + } + pid_save(); do { if (($brisk = Brisk::create(LEGAL_PATH."/brisk-crystal.data", $G_ban_list, $G_black_list)) == FALSE) { -- 2.17.1