require_once("$DOCUMENT_ROOT/Etc/".BRISK_CONF);
require_once("${G_base}Obj/ipclass.phh");
-require_once("${G_base}Obj/provider_proxy.phh");
$mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi',
'en' => 'back standing' ),
var $ban_list; // ban list (authized allowed)
var $black_list; // black list (anti-dos, noone allowed)
var $cloud_smasher; // list of cloud ip ranges to be rejected
- var $provider_proxy; // list of provider/browser that offer proxy service
var $ghost_sess;
var $delay_mgr;
fprintf(STDERR, "ROOM FROM FILE\n");
rename($crystal_filename, $crystal_filename.".old");
- $brisk->reload(TRUE, $ban_list, $black_list, $cloud_smasher, $prov_proxy);
+ $brisk->reload(TRUE, $ban_list, $black_list, $cloud_smasher);
return($brisk);
}
$thiz->ban_list = IpClass::create();
$thiz->black_list = IpClass::create();
$thiz->cloud_smasher = IpClass::create();
- $thiz->provider_proxy = ProviderProxy::create();
$thiz->ghost_sess = new GhostSess();
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
static::$sess_cur = FALSE;
- $thiz->reload(TRUE, $ban_list, $black_list, $cloud_smasher, $prov_proxy);
+ $thiz->reload(TRUE, $ban_list, $black_list, $cloud_smasher);
return ($thiz);
}
- function reload($is_first, $ban_list, $black_list, $cloud_smasher, $prov_proxy)
+ function reload($is_first, $ban_list, $black_list, $cloud_smasher)
{
- fprintf(STDERR, "RELOAD STUFF (%d)(%d)(%d)(%d)\n",
- count($ban_list), count($black_list), count($cloud_smasher), count($prov_proxy));
+ fprintf(STDERR, "RELOAD STUFF (%d)(%d)(%d)\n",
+ count($ban_list), count($black_list), count($cloud_smasher));
if (defined('CURL_DE_SAC_VERS')) {
if (brisk_cds_reload($this) == FALSE) {
$this->ban_list->update($ban_list);
$this->black_list->update($black_list);
$this->cloud_smasher->update($cloud_smasher);
- $this->provider_proxy->update($prov_proxy);
if (!$is_first) {
$this->banned_kickoff();
return ($this->cloud_smasher->check($ip_str));
}
- function pproxy_realip($header, $ip_str)
- {
- return ($this->provider_proxy->realip($header, $ip_str));
- }
-
function users_cleanup()
{
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
function request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie)
{
- GLOBAL $G_ban_list, $G_black_list, $G_cloud_smasher, $G_provider_proxy;
+ GLOBAL $G_ban_list, $G_black_list, $G_cloud_smasher;
printf("NEW_SOCKET (root): %d PATH [%s]\n", intval($new_socket), $path);
- // $remote_addr = addrtoipv4($addr);
- $remote_addr = $this->pproxy_realip($header, addrtoipv4($addr));
- fprintf(STDERR, "\n\n\n PRE_BLACK [%s]\n\n\n", $remote_addr);
- if ($this->black_check($remote_addr)) {
+ fprintf(STDERR, "\n\n\n PRE_BLACK [%s]\n\n\n", $addr);
+ if ($this->black_check($addr)) {
// TODO: waiting async 5 sec before close
fprintf(STDERR, "\n\n\n BLACK CHECK\n\n\n");
return (FALSE);
}
if ($path != "" && $path != "index.php") {
- if ($this->cloud_check($remote_addr)) {
+ if ($this->cloud_check($addr)) {
// TODO: waiting async 5 sec before close
return (FALSE);
}
static $fixed_fd = 3;
static $cnt_master = NULL;
static $cnt_slave = NULL;
+
+ var $provider_proxy; // list of provider/browser that offer proxy service
var $file_socket;
var $unix_socket;
static function create(&$app, $sockname, $debug, $blocking_mode, $argv)
{
+ GLOBAL $G_provider_proxy;
+
$thiz = new Sac_a_push();
$thiz->app = $app;
+
+ $thiz->provider_proxy = ProviderProxy::create();
+
$thiz->file_socket = $sockname;
$thiz->unix_socket = "unix://$sockname";
$thiz->direct_socket = "unix://${sockname}2";
}
$thiz->main_loop = FALSE;
+ $thiz->reload(TRUE, $G_provider_proxy);
return ($thiz);
}
== FALSE) {
fprintf(STDERR, "TODO: fix wrong header management\n");
}
- $addr = stream_socket_get_name($new_socket, TRUE);
+ $addr_full = stream_socket_get_name($new_socket, TRUE);
+ // FOR TEST $header['X-Forwarded-For'] = '154.155.22.33';
+ $addr = $this->pproxy_realip($header, addrtoipv4($addr_full));
+
printf("PATH: [%s]\n", $path);
if ($method == "POST" && $rest > 0) {
if (isset($header['Expect']) && $header['Expect'] == '100-continue') {
$line = trim($buf);
if ($line == "reload") {
require("$DOCUMENT_ROOT/Etc/".BRISK_CONF);
+ $this->reload(FALSE, $G_provider_proxy);
$this->app->reload(FALSE, $G_ban_list, $G_black_list,
- $G_cloud_smasher, $G_provider_proxy);
+ $G_cloud_smasher);
global_dump();
}
else if ($line == "shutdown" || $line == "sd") {
} // while (...
} // function run(...
+ function pproxy_realip($header, $ip_str)
+ {
+ return ($this->provider_proxy->realip($header, $ip_str));
+ }
+
+ function reload($is_first, $prov_proxy)
+ {
+ fprintf(STDERR, "SAP RELOAD STUFF (%d)\n", count($prov_proxy));
+
+ $this->provider_proxy->update($prov_proxy);
+ }
+
function direct_command($cmdstr)
{
GLOBAL $G_alarm_passwd;