From: Matteo Nastasi (mop) Date: Sun, 1 Feb 2015 14:14:12 +0000 (+0100) Subject: provider_proxy management added X-Git-Tag: v4.18.0~2 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=28be75bdd1253bb56c8bef5476f59be63013eb71;p=brisk.git provider_proxy management added --- diff --git a/web/Obj/brisk.conf-templ.pho b/web/Obj/brisk.conf-templ.pho index 92fe8ee..6854d6a 100644 --- a/web/Obj/brisk.conf-templ.pho +++ b/web/Obj/brisk.conf-templ.pho @@ -1,4 +1,11 @@ black_list->check($ip_str)); } - function pproxy_realip($ip_str) + function pproxy_realip($header, $ip_str) { - return ($this->provider_proxy->realip($ip_str)); + return ($this->provider_proxy->realip($header, $ip_str)); } function users_cleanup() @@ -2613,16 +2614,16 @@ class Brisk function request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie) { - GLOBAL $G_ban_list, $G_black_list; + GLOBAL $G_ban_list, $G_black_list, $G_provider_proxy; printf("NEW_SOCKET (root): %d PATH [%s]\n", intval($new_socket), $path); // $remote_addr = addrtoipv4($addr); - $remote_addr = $this->pproxy_realip(addrtoipv4($addr)); + $remote_addr = $this->pproxy_realip($header, addrtoipv4($addr)); fprintf(STDERR, "\n\n\n PRE_BLACK_CHECK \n\n\n"); if ($this->black_check($remote_addr)) { // TODO: waiting async 5 sec before close - fprintf(STDERR, "\n\n\n BLACK_CHECK \n\n\n"); + fprintf(STDERR, "\n\n\n BLACK CHECK\n\n\n"); return (FALSE); } diff --git a/web/Obj/provider_proxy.phh b/web/Obj/provider_proxy.phh index 7542802..eb4b12e 100644 --- a/web/Obj/provider_proxy.phh +++ b/web/Obj/provider_proxy.phh @@ -24,24 +24,6 @@ require_once("${G_base}Obj/ipclass.phh"); -$G_pproxy = array( "samosa" => array("headitem" => "X-Forwarded-For", - "ipclass" => array("107.178.33.0/24", - "107.178.34.0/24", - "107.178.35.0/24", - "107.178.37.0/24", - "107.178.38.0/24", - "107.178.39.0/24", - "107.178.41.0/24", - "107.178.42.0/24", - "107.178.43.0/24", - "107.178.45.0/24", - "107.178.46.0/24", - "107.178.47.0/24", - "206.173.221.0/24") ), - "mytest" => array("headitem" => "X-Forwarded-For", - "ipclass" => array("192.168.2.3/24") ) - ); - class ProviderProxyItem { var $name; @@ -79,8 +61,9 @@ class ProviderProxy function clean() { if ($this->pp != NULL) { - foreach ($this->pp as $pp_name) { - unset($this->pp[$pp_name]); + foreach ($this->pp as $pp_key => $pp_value) { + fprintf(STDERR, "PHP PPN: %s\n", $pp_key); + unset($this->pp[$pp_key]); } unset($this->pp); $this->pp = NULL; @@ -92,19 +75,19 @@ class ProviderProxy $this->clean(); $this->pp = array(); - foreach ($pproxy as $pp_name => $pp_descr) { - $this->pp[$pp_name] = new ProviderProxyItem($pp_name, $pp_descr); + foreach ($pproxy as $pp_key => $pp_value) { + $this->pp[$pp_key] = new ProviderProxyItem($pp_key, $pp_value); } } - function realip($headers, $ip) + function realip($header, $ip) { if ($this->pp != NULL) { foreach ($this->pp as $pp_name => $pp_item) { - if ($pp_item->match($ip)) { - if (isset($headers[$pp_item->headitem])) { - fprintf(STDERR, "Match public proxy [%s]\n", $pp_name); - return ($headers[$pp_item->headitem]); + if ($pp_item->ipclass->check($ip)) { + if (isset($header[$pp_item->headitem])) { + fprintf(STDERR, "Match public proxy [%s][%s]\n", $pp_name, $header[$pp_item->headitem]); + return ($header[$pp_item->headitem]); } } } diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index d9ee5ad..fdf5541 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -623,7 +623,8 @@ class Sac_a_push { { GLOBAL $DOCUMENT_ROOT, $HTTP_HOST; - GLOBAL $G_alarm_passwd, $G_ban_list, $G_black_list, $G_btrace_pref_sub, $G_dbauth; + GLOBAL $G_alarm_passwd, $G_ban_list, $G_black_list, $G_provider_proxy; + GLOBAL $G_btrace_pref_sub, $G_dbauth; GLOBAL $G_dbpfx, $G_donors_all, $G_donors_cur, $G_is_local, $G_lang; GLOBAL $G_poll_entries, $G_poll_name, $G_poll_title, $G_proxy_white_list; GLOBAL $G_room_roadmap, $G_shutdown; @@ -799,7 +800,8 @@ class Sac_a_push { $line = trim($buf); if ($line == "reload") { require("$DOCUMENT_ROOT/Etc/".BRISK_CONF); - $this->app->reload(FALSE, $G_ban_list, $G_black_list); + $this->app->reload(FALSE, $G_ban_list, $G_black_list, + $G_provider_proxy); global_dump(); } else if ($line == "shutdown" || $line == "sd") { diff --git a/web/brisk.css b/web/brisk.css index 0539984..d886215 100644 --- a/web/brisk.css +++ b/web/brisk.css @@ -263,3 +263,7 @@ span.au1 { span.au2 { background-color: #bafcba; } + +div.bye_msg { + font-weigth: bold; +} \ No newline at end of file diff --git a/web/index.php b/web/index.php index 9486808..c2c4be1 100644 --- a/web/index.php +++ b/web/index.php @@ -27,14 +27,16 @@ require_once("Obj/brisk.phh"); require_once("Obj/auth.phh"); require_once("Obj/proxyscan.phh"); -$mlang_room = array( 'userpasserr' => array('it' => 'Utente e/o password errati.', - 'en' => 'Wrong user and/or password.'), - 'userpassmust' => array('it' => 'Il nickname deve contenere almeno una lettera o una cifra.', - 'en' => 'The nickname have to contain at least one letter or one number.'), +$mlang_room = array( 'userpassuse' => array('it' => 'Il tuo nickname è già in uso.', + 'en' => 'Your nickname is already in use.'), 'userpassend' => array('it' => 'Spiacenti, non ci sono più posti liberi. Riprova più tardi.', 'en' => 'We are sorry, there aren\'t free place. Try again later.'), - 'userpassuse' => array('it' => 'Il tuo nickname è già in uso.', - 'en' => 'Your nickname is already in use.'), + 'userpassmust' => array('it' => 'Il nickname deve contenere almeno una lettera o una cifra.', + 'en' => 'The nickname have to contain at least one letter or one number.'), + 'userpasserr' => array('it' => 'Utente e/o password errati.', + 'en' => 'Wrong user and/or password.'), + 'userpassban' => array('it' => 'Il tuo indirizzo IP è stato bannato perché precedentemente utilizzato da qualche molestatore.', + 'en' => 'Your IP address is banned because trolling activity was detected from it.'), 'standing' => array('it' => 'Giocatori in piedi', 'en' => 'Standing players'), 'headline' => array('it' => 'briscola chiamata in salsa ajax', @@ -53,6 +55,9 @@ $mlang_room = array( 'userpasserr' => array('it' => 'Utente e/o password errati 'en' => 'EN L\' accesso attraverso sistemi di anonimizzazione non è consentito.'), 'reas_anot' => array('it' => 'La tua sessione è stata assegnata ad un altro browser.', 'en' => 'EN La tua sessione è stata assegnata ad un altro browser.'), + 'reas_cloud' => array('it' => 'La connessione dai computer di una cloud non è ammessa.', + 'en' => 'Connection from cloud computers is not allowed.'), + 'btn_enter' => array('it' => 'entra', 'en' => 'enter'), 'passwarn' => array('it' => 'Se non hai ancora una password, lascia il campo in bianco ed entra.', @@ -342,6 +347,7 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f $standup = ""; $ACTION = "login"; $last_msg = ""; + $banned = FALSE; if (isset($BRISK_SHOWHTML) == FALSE) { $is_table = FALSE; @@ -391,9 +397,7 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f } } } - - $banned = FALSE; - if ($ACTION == "login" && isset($name)) { + if (!$banned && $ACTION == "login" && isset($name)) { log_main("pre garbage_manager DUE"); if (isset($pass_private) == FALSE || $pass_private == "") { @@ -402,7 +406,7 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f if ($brisk->ban_check($remote_addr)) { // TODO: find a way to add a nonblocking sleep(5) here $banned = TRUE; - $idx = -1; + $idx = -4; } } @@ -432,15 +436,24 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f } } else { + fprintf(STDERR, "POST CHECK QUI\n"); /* Login Rendering */ - if ($idx == -3) + switch($idx) { + case -4: + $sfx = 'ban'; + break; + case -3: $sfx = 'err'; - else if ($idx == -2) + break; + case -2: $sfx = 'must'; - else if ($idx == -1) + break; + case -1: $sfx = 'end'; - else + break; + default: $sfx = 'use'; + } $body .= '
'.$mlang_room['userpass'.$sfx][$G_lang].'
'; } diff --git a/web/room.css b/web/room.css index 73cb799..d3af1ab 100644 --- a/web/room.css +++ b/web/room.css @@ -456,3 +456,4 @@ img.tickbut { cursor: pointer; margin-top:4px; } + diff --git a/web/spush/brisk-spush.php b/web/spush/brisk-spush.php index 76db91f..3a43b19 100755 --- a/web/spush/brisk-spush.php +++ b/web/spush/brisk-spush.php @@ -42,11 +42,11 @@ require_once($G_base."briskin5/index_wr.php"); function main($argv) { - GLOBAL $G_ban_list, $G_black_list, $G_prov_proxy; + GLOBAL $G_ban_list, $G_black_list, $G_provider_proxy; pid_save(); do { - if (($brisk = Brisk::create(LEGAL_PATH."/brisk-crystal.data", $G_ban_list, $G_black_list, $G_prov_proxy)) == FALSE) { + if (($brisk = Brisk::create(LEGAL_PATH."/brisk-crystal.data", $G_ban_list, $G_black_list, $G_provider_proxy)) == FALSE) { log_crit("Brisk::create failed"); $ret = 1; break;