X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=fe6d4848815e1992983c5345fbc1c2115330faae;hb=c3f60752d7261a4769734cc9ddbf9e7fe0a073a4;hp=391f0a8ed5e78bd430aba8de69555760b82363e1;hpb=93d7a6690daa9a9138277a8d83edb766fb2bab8a;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 391f0a8..fe6d484 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,13 @@ class Brisk var $delay_mgr; + var $cds; + public static $sess_cur; function Brisk() { + $this->cds = NULL; } // constructor @@ -1013,7 +1017,7 @@ class Brisk fprintf(STDERR, "ROOM FROM FILE\n"); rename($crystal_filename, $crystal_filename.".old"); - $brisk->reload($ban_list, $black_list); + $brisk->reload(TRUE, $ban_list, $black_list); return($brisk); } @@ -1030,11 +1034,6 @@ class Brisk $thiz->ban_list = NULL; $thiz->black_list = NULL; - fprintf(STDERR, "PRE IPCLASS_UPDATE (%d, %d)\n", count($ban_list), count($black_list)); - $thiz->ipclass_update('ban_list', $ban_list); - $thiz->ipclass_update('black_list', $black_list); - fprintf(STDERR, "POST IPCLASS_UPDATE %d %d\n", count($thiz->ban_list), count($thiz->black_list)); - for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { $thiz->user[$i] = User::create($thiz, $i, "", ""); } @@ -1049,9 +1048,17 @@ class Brisk static::$sess_cur = FALSE; + $thiz->reload(TRUE, $ban_list, $black_list); + return ($thiz); } + function tor_chk_postprocess($user_idx, $user_sess, $conn_ip, $is_auth, $is_tor) + { + log_cds(sprintf("user_idx: %d, user_sess: %s, conn_ip: %s, is_auth: %s, is_tor: %s", + $user_idx, $user_sess, $conn_ip, ($is_auth ? "YES" : "NO"), ($is_tor ? "YES" : "NO"))); + } + function ipclass_update($ip_out_s, $ip_in) { fprintf(STDERR, "N_IN: %d\n", count($ip_in)); @@ -1073,15 +1080,35 @@ class Brisk } } - function reload($ban_list, $black_list) + function reload($is_first, $ban_list, $black_list) { fprintf(STDERR, "RELOAD STUFF (%d)(%d)\n", count($ban_list), count($black_list)); + if ($this->cds != NULL) { + $this->cds->cmd_cls_deregister_all(); + unset($this->cds); + $this->cds = NULL; + } + // 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); + } + $this->ipclass_update("ban_list", $ban_list); $this->ipclass_update("black_list", $black_list); - $this->banned_kickoff(); - $this->garbage_manager(TRUE); + if (!$is_first) { + $this->banned_kickoff(); + $this->garbage_manager(TRUE); + } } function banned_kickoff() @@ -2255,6 +2282,10 @@ class Brisk } $idx = $ghost; + if ($this->cds->execute("tor_chk", $this, $ghost, $sess, $ip, $authenticate != FALSE) == FALSE) { + log_main("cds_execute failed"); + } + return ($this->user[$ghost]); } else if ($idx != -1 && $i == MAX_PLAYERS) { @@ -2354,6 +2385,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, $authenticate != FALSE) == FALSE) { + log_main("cds_execute failed"); + } + return ($ret); } @@ -2707,6 +2742,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;