Add ability to peer via socks4a (works for tor)
This commit is contained in:
parent
66c05e9f1f
commit
7d6b551cb4
@ -86,6 +86,72 @@ function nntp_open($nserver=0,$nport=0) {
|
|||||||
return $ns;
|
return $ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nntp2_open($nserver=0,$nport=0) {
|
||||||
|
global $text_error,$CONFIG;
|
||||||
|
// echo "<br>NNTP OPEN<br>";
|
||||||
|
$authorize=((isset($CONFIG['remote_auth_user'])) && (isset($CONFIG['remote_auth_pass'])) &&
|
||||||
|
($CONFIG['remote_auth_user'] != ""));
|
||||||
|
if ($nserver==0) $nserver=$CONFIG['remote_server'];
|
||||||
|
if ($nport==0) $nport=$CONFIG['remote_port'];
|
||||||
|
if($CONFIG['remote_ssl']) {
|
||||||
|
$ns=@fsockopen('ssl://'.$nserver.":".$nport);
|
||||||
|
} else {
|
||||||
|
if($CONFIG['socks_host'] !== '') {
|
||||||
|
$ns=fsocks4asockopen($CONFIG['socks_host'], $CONFIG['socks_port'], $nserver, $nport);
|
||||||
|
} else {
|
||||||
|
$ns=@fsockopen('tcp://'.$nserver.":".$nport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// $ns=@fsockopen($nserver,$nport);
|
||||||
|
$weg=line_read($ns); // kill the first line
|
||||||
|
if (substr($weg,0,2) != "20") {
|
||||||
|
echo "<p>".$text_error["error:"].$weg."</p>";
|
||||||
|
fclose($ns);
|
||||||
|
$ns=false;
|
||||||
|
} else {
|
||||||
|
if ($ns != false) {
|
||||||
|
fputs($ns,"MODE reader\r\n");
|
||||||
|
$weg=line_read($ns); // and once more
|
||||||
|
if ((substr($weg,0,2) != "20") &&
|
||||||
|
((!$authorize) || ((substr($weg,0,3) != "480") && ($authorize)))) {
|
||||||
|
echo "<p>".$text_error["error:"].$weg."</p>";
|
||||||
|
fclose($ns);
|
||||||
|
$ns=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((isset($CONFIG['remote_auth_user'])) && (isset($CONFIG['remote_auth_pass'])) &&
|
||||||
|
($CONFIG['remote_auth_user'] != "")) {
|
||||||
|
fputs($ns,"AUTHINFO USER ".$CONFIG['remote_auth_user']."\r\n");
|
||||||
|
$weg=line_read($ns);
|
||||||
|
fputs($ns,"AUTHINFO PASS ".$CONFIG['remote_auth_pass']."\r\n");
|
||||||
|
$weg=line_read($ns);
|
||||||
|
/* Only check auth if reading and posting same server */
|
||||||
|
if (substr($weg,0,3) != "281" && !(isset($post_server)) && ($post_server!="")) {
|
||||||
|
echo "<p>".$text_error["error:"]."</p>";
|
||||||
|
echo "<p>".$text_error["auth_error"]."</p>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($ns==false) echo "<p>".$text_error["connection_failed"]."</p>";
|
||||||
|
return $ns;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fsocks4asockopen($proxyHostname, $proxyPort, $targetHostname, $targetPort)
|
||||||
|
{
|
||||||
|
$sock = fsockopen($proxyHostname, $proxyPort);
|
||||||
|
if($sock === false)
|
||||||
|
return false;
|
||||||
|
fwrite($sock, pack("CCnCCCCC", 0x04, 0x01, $targetPort, 0x00, 0x00, 0x00, 0x01, 0x00).$targetHostname.pack("C", 0x00));
|
||||||
|
$response = fread($sock, 16);
|
||||||
|
$values = unpack("xnull/Cret/nport/Nip", $response);
|
||||||
|
if($values["ret"] == 0x5a) return $sock;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fclose(sock);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close a NNTP connection
|
* Close a NNTP connection
|
||||||
*
|
*
|
||||||
@ -1279,7 +1345,6 @@ function np_get_db_article($article, $group, $makearray=1, $dbh=null) {
|
|||||||
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." DEBUG: fetched: ".$article." from ".$group, FILE_APPEND);
|
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." DEBUG: fetched: ".$article." from ".$group, FILE_APPEND);
|
||||||
if($makearray == 1) {
|
if($makearray == 1) {
|
||||||
$thisarticle = preg_split("/\r\n|\n|\r/", trim($msg2));
|
$thisarticle = preg_split("/\r\n|\n|\r/", trim($msg2));
|
||||||
array_pop($thisarticle);
|
|
||||||
return $thisarticle;
|
return $thisarticle;
|
||||||
} else {
|
} else {
|
||||||
return trim($msg2);
|
return trim($msg2);
|
||||||
|
@ -3,6 +3,8 @@ return [
|
|||||||
'remote_server' => 'news.example.com',
|
'remote_server' => 'news.example.com',
|
||||||
'remote_port' => '119',
|
'remote_port' => '119',
|
||||||
'remote_ssl' => '',
|
'remote_ssl' => '',
|
||||||
|
'socks_host' => '',
|
||||||
|
'socks_port' => '',
|
||||||
'remote_auth_user' => 'username',
|
'remote_auth_user' => 'username',
|
||||||
'remote_auth_pass' => 'password',
|
'remote_auth_pass' => 'password',
|
||||||
'enable_nntp' => '1',
|
'enable_nntp' => '1',
|
||||||
|
@ -91,50 +91,4 @@ function post_articles($ns, $spooldir) {
|
|||||||
}
|
}
|
||||||
return "Messages sent\r\n";
|
return "Messages sent\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function nntp2_open($nserver=0,$nport=0) {
|
|
||||||
global $text_error,$CONFIG;
|
|
||||||
// echo "<br>NNTP OPEN<br>";
|
|
||||||
$authorize=((isset($CONFIG['remote_auth_user'])) && (isset($CONFIG['remote_auth_pass'])) &&
|
|
||||||
($CONFIG['remote_auth_user'] != ""));
|
|
||||||
if ($nserver==0) $nserver=$CONFIG['remote_server'];
|
|
||||||
if ($nport==0) $nport=$CONFIG['remote_port'];
|
|
||||||
if($CONFIG['remote_ssl']) {
|
|
||||||
$ns=@fsockopen('ssl://'.$nserver.":".$nport);
|
|
||||||
} else {
|
|
||||||
$ns=@fsockopen('tcp://'.$nserver.":".$nport);
|
|
||||||
}
|
|
||||||
// $ns=@fsockopen($nserver,$nport);
|
|
||||||
$weg=line_read($ns); // kill the first line
|
|
||||||
if (substr($weg,0,2) != "20") {
|
|
||||||
echo "<p>".$text_error["error:"].$weg."</p>";
|
|
||||||
fclose($ns);
|
|
||||||
$ns=false;
|
|
||||||
} else {
|
|
||||||
if ($ns != false) {
|
|
||||||
fputs($ns,"MODE reader\r\n");
|
|
||||||
$weg=line_read($ns); // and once more
|
|
||||||
if ((substr($weg,0,2) != "20") &&
|
|
||||||
((!$authorize) || ((substr($weg,0,3) != "480") && ($authorize)))) {
|
|
||||||
echo "<p>".$text_error["error:"].$weg."</p>";
|
|
||||||
fclose($ns);
|
|
||||||
$ns=false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((isset($CONFIG['remote_auth_user'])) && (isset($CONFIG['remote_auth_pass'])) &&
|
|
||||||
($CONFIG['remote_auth_user'] != "")) {
|
|
||||||
fputs($ns,"AUTHINFO USER ".$CONFIG['remote_auth_user']."\r\n");
|
|
||||||
$weg=line_read($ns);
|
|
||||||
fputs($ns,"AUTHINFO PASS ".$CONFIG['remote_auth_pass']."\r\n");
|
|
||||||
$weg=line_read($ns);
|
|
||||||
/* Only check auth if reading and posting same server */
|
|
||||||
if (substr($weg,0,3) != "281" && !(isset($post_server)) && ($post_server!="")) {
|
|
||||||
echo "<p>".$text_error["error:"]."</p>";
|
|
||||||
echo "<p>".$text_error["auth_error"]."</p>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($ns==false) echo "<p>".$text_error["connection_failed"]."</p>";
|
|
||||||
return $ns;
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
@ -11,6 +11,8 @@ return [
|
|||||||
'remote_ssl' => 'Enable if connecting to remote server using ssl (1=true, blank=false)',
|
'remote_ssl' => 'Enable if connecting to remote server using ssl (1=true, blank=false)',
|
||||||
'remote_auth_user' => 'Username to authenticate to remote server',
|
'remote_auth_user' => 'Username to authenticate to remote server',
|
||||||
'remote_auth_pass' => 'Password to authenticate to remote server',
|
'remote_auth_pass' => 'Password to authenticate to remote server',
|
||||||
|
'socks_host' => 'ip address of your socks4a server (use this for tor)',
|
||||||
|
'socks_port' => 'port for your socks4a server',
|
||||||
|
|
||||||
# LOCAL server configuration
|
# LOCAL server configuration
|
||||||
'enable_nntp' => 'Enable local nntp server (1=true, blank=false)',
|
'enable_nntp' => 'Enable local nntp server (1=true, blank=false)',
|
||||||
|
@ -417,52 +417,6 @@ function create_spool_groups($in_groups, $out_groups) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nntp2_open($nserver=0,$nport=0) {
|
|
||||||
global $text_error,$CONFIG;
|
|
||||||
// echo "<br>NNTP OPEN<br>";
|
|
||||||
$authorize=((isset($CONFIG['remote_auth_user'])) && (isset($CONFIG['remote_auth_pass'])) &&
|
|
||||||
($CONFIG['remote_auth_user'] != ""));
|
|
||||||
if ($nserver==0) $nserver=$CONFIG['remote_server'];
|
|
||||||
if ($nport==0) $nport=$CONFIG['remote_port'];
|
|
||||||
if($CONFIG['remote_ssl']) {
|
|
||||||
$ns=@fsockopen('ssl://'.$nserver.":".$nport);
|
|
||||||
} else {
|
|
||||||
$ns=@fsockopen('tcp://'.$nserver.":".$nport);
|
|
||||||
}
|
|
||||||
// $ns=@fsockopen($nserver,$nport);
|
|
||||||
$weg=line_read($ns); // kill the first line
|
|
||||||
if (substr($weg,0,2) != "20") {
|
|
||||||
echo "<p>".$text_error["error:"].$weg."</p>";
|
|
||||||
fclose($ns);
|
|
||||||
$ns=false;
|
|
||||||
} else {
|
|
||||||
if ($ns != false) {
|
|
||||||
fputs($ns,"MODE reader\r\n");
|
|
||||||
$weg=line_read($ns); // and once more
|
|
||||||
if ((substr($weg,0,2) != "20") &&
|
|
||||||
((!$authorize) || ((substr($weg,0,3) != "480") && ($authorize)))) {
|
|
||||||
echo "<p>".$text_error["error:"].$weg."</p>";
|
|
||||||
fclose($ns);
|
|
||||||
$ns=false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((isset($CONFIG['remote_auth_user'])) && (isset($CONFIG['remote_auth_pass'])) &&
|
|
||||||
($CONFIG['remote_auth_user'] != "")) {
|
|
||||||
fputs($ns,"AUTHINFO USER ".$CONFIG['remote_auth_user']."\r\n");
|
|
||||||
$weg=line_read($ns);
|
|
||||||
fputs($ns,"AUTHINFO PASS ".$CONFIG['remote_auth_pass']."\r\n");
|
|
||||||
$weg=line_read($ns);
|
|
||||||
/* Only check auth if reading and posting same server */
|
|
||||||
if (substr($weg,0,3) != "281" && !(isset($post_server)) && ($post_server!="")) {
|
|
||||||
echo "<p>".$text_error["error:"]."</p>";
|
|
||||||
echo "<p>".$text_error["auth_error"]."</p>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($ns==false) echo "<p>".$text_error["connection_failed"]."</p>";
|
|
||||||
return $ns;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_high_watermark($group) {
|
function get_high_watermark($group) {
|
||||||
global $local_groupfile;
|
global $local_groupfile;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user