X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fcurl-de-brisk.phh;h=a78b3fcf50c7031a0d21caa0f449891fcbf1fb9c;hb=456b5daac0243fe5d6d8bbe6ea5fe434f876c66a;hp=8dd8889551bef16b6c121df35a6ede8cb08267c1;hpb=7a68ca3ff3bbc47a1cff8b71448bc473c7a95b33;p=curl-de-sac.git diff --git a/web/Obj/curl-de-brisk.phh b/web/Obj/curl-de-brisk.phh index 8dd8889..a78b3fc 100755 --- a/web/Obj/curl-de-brisk.phh +++ b/web/Obj/curl-de-brisk.phh @@ -5,6 +5,51 @@ require_once($G_base . 'Obj/curl-de-sac.phh'); define('TOR_CHK_URL', 'http://localhost/curl-de-sac/test/tor_mock.ppp'); define('PROXY_CHK_URL', 'http://localhost/curl-de-sac/test/proxy_mock.ppp'); +/* + * Operational Brisk stuff + */ +function brisk_cds_reload($brisk) +{ + if ($brisk->cds != NULL) { + $brisk->cds->cmd_cls_deregister_all(); + unset($brisk->cds); + $brisk->cds = NULL; + } + // create cds + $brisk->cds = new Curl_de_sac(); + + // create tor_chk_cls and proxy_chk_cls + $tor_chk_cls = new Tor_chk_cmd_cls(); + $proxy_chk_cls = new Proxy_chk_cmd_cls(); + + // registrer tor_chk_cls and proxy_chk_cls + printf("MAIN: Register 'tor_chk_cls'\n"); + if (($brisk->cds->cmd_cls_register($tor_chk_cls)) == FALSE) { + fprintf(STDERR, "MAIN: 'tor_chk_cls' registration failed\n"); + return (FALSE); + } + printf("MAIN: Register 'proxy_chk_cls'\n"); + if (($brisk->cds->cmd_cls_register($proxy_chk_cls)) == FALSE) { + fprintf(STDERR, "MAIN: 'proxy_chk_cls' registration failed\n"); + return (FALSE); + } + + return (TRUE); +} + +function brisk_cds_execute($brisk, $ghost, $real_idx, $sess, $ip, $authenticate, $header) +{ + if ($brisk->cds->execute("tor_chk", $brisk, $ghost, $sess, $ip, $authenticate != FALSE, $header) == FALSE) { + log_main("cds_execute failed"); + } + if ($brisk->cds->execute("proxy_chk", $brisk, $ghost, $sess, $ip, $authenticate != FALSE, $header) == FALSE) { + log_main("cds_execute failed"); + } +} + +/* + * CDS commands stuff + */ class Tor_chk_cmd extends CDS_cmd { var $ctx; var $user_idx; @@ -84,14 +129,32 @@ class Tor_chk_cmd_cls extends CDS_cmd_cls { ; } - $cmd->ctx->tor_chk_postprocess($cmd->user_idx, $cmd->user_sess, $cmd->conn_ip, $cmd->is_auth, $is_tor); + tor_chk_postprocess($cmd->ctx, $cmd->user_idx, $cmd->user_sess, $cmd->conn_ip, $cmd->is_auth, $is_tor); return TRUE; } function timeout($cmd) { - printf("'tor_chk' timeout function reached\n"); + tor_chk_timeout_cb($cmd->ctx, $cmd->user_idx, $cmd->user_sess, $cmd->conn_ip, $cmd->is_auth); + } +} + +class Proxy_chk_cmd extends CDS_cmd { + var $ctx; + var $user_idx; + var $user_sess; + var $conn_ip; + var $is_auth; + + function Proxy_chk_cmd($cmd_cls, $ch, $ctx, $user_idx, $user_sess, $conn_ip, $is_auth) + { + parent::__construct($cmd_cls, $ch); + $this->ctx = $ctx; + $this->user_idx = $user_idx; + $this->user_sess = $user_sess; + $this->conn_ip = $conn_ip; + $this->is_auth = $is_auth; } } @@ -127,7 +190,7 @@ class Proxy_chk_cmd_cls extends CDS_cmd_cls { foreach($this->scan_headers as $key){ //proxy detected? lets log... - if($headers[$key]) { + if(array_key_exists($key, $headers)) { // we already are behind a PROXY, this are our headers if ($key == 'X-Proxy-ID') { if ($headers[$key] == '860705422') @@ -142,7 +205,7 @@ class Proxy_chk_cmd_cls extends CDS_cmd_cls { continue; } - $ctx->proxy_chk_postprocess($user_idx, $user_sess, $conn_ip, $is_auth, TRUE); + proxy_chk_postprocess($ctx, $user_idx, $user_sess, $conn_ip, $is_auth, TRUE); return TRUE; } } @@ -192,15 +255,39 @@ class Proxy_chk_cmd_cls extends CDS_cmd_cls { ; } - $cmd->ctx->proxy_chk_postprocess($cmd->user_idx, $cmd->user_sess, $cmd->conn_ip, $cmd->is_auth, $is_proxy); + proxy_chk_postprocess($cmd->ctx, $cmd->user_idx, $cmd->user_sess, $cmd->conn_ip, $cmd->is_auth, $is_proxy); return TRUE; } function timeout($cmd) { - printf("'proxy_chk' timeout function reached\n"); + proxy_chk_timeout_cb($cmd->ctx, $cmd->user_idx, $cmd->user_sess, $cmd->conn_ip, $cmd->is_auth); } } +function tor_chk_postprocess($brisk, $user_idx, $user_sess, $conn_ip, $is_auth, $is_tor) +{ + log_cds(sprintf("tor: 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 tor_chk_timeout_cb($brisk, $user_idx, $user_sess, $conn_ip, $is_auth) +{ + log_cds(sprintf("tor: user_idx: %d, user_sess: %s, conn_ip: %s, is_auth: %s", + $user_idx, $user_sess, $conn_ip, ($is_auth ? "YES" : "NO"))); +} + +function proxy_chk_postprocess($brisk, $user_idx, $user_sess, $conn_ip, $is_auth, $is_proxy) +{ + log_cds(sprintf("proxy: user_idx: %d, user_sess: %s, conn_ip: %s, is_auth: %s, is_proxy: %s", + $user_idx, $user_sess, $conn_ip, ($is_auth ? "YES" : "NO"), ($is_proxy ? "YES" : "NO"))); +} + +function proxy_chk_timeout_cb($brisk, $user_idx, $user_sess, $conn_ip, $is_auth) +{ + log_cds(sprintf("proxy timeout: user_idx: %d, user_sess: %s, conn_ip: %s, is_auth: %s", + $user_idx, $user_sess, $conn_ip, ($is_auth ? "YES" : "NO"))); +} + ?>