Add support to sync via http proxy

This commit is contained in:
Retro_Guy 2021-02-04 20:01:58 -07:00
parent 71e4c638aa
commit c5f6f41612
4 changed files with 30 additions and 3 deletions

View File

@ -98,11 +98,15 @@ function nntp2_open($nserver=0,$nport=0) {
} else {
if(isset($CONFIG['socks_host']) && $CONFIG['socks_host'] !== '') {
$ns=fsocks4asockopen($CONFIG['socks_host'], $CONFIG['socks_port'], $nserver, $nport);
} elseif(isset($CONFIG['http_host']) && $CONFIG['http_host'] !== '') {
$ns=fhttpsockopen($CONFIG['http_host'], $CONFIG['http_port'], $nserver, $nport);
} else {
$ns=@fsockopen('tcp://'.$nserver.":".$nport);
}
}
// $ns=@fsockopen($nserver,$nport);
if(isset($CONFIG['http_host']) && $CONFIG['http_host'] !== '') {
fputs($ns, "MODE reader\r\n");
}
$weg=line_read($ns); // kill the first line
if (substr($weg,0,2) != "20") {
echo "<p>".$text_error["error:"].$weg."</p>";
@ -147,11 +151,27 @@ function fsocks4asockopen($proxyHostname, $proxyPort, $targetHostname, $targetPo
if($values["ret"] == 0x5a) return $sock;
else
{
fclose(sock);
fclose($sock);
return false;
}
}
function fhttpsockopen($proxyHostname, $proxyPort, $targetHostname, $targetPort)
{
$sock = fsockopen($proxyHostname, $proxyPort);
if($sock === false)
return false;
fwrite($sock, 'CONNECT '.$targetHostname.':'.$targetPort.' HTTP/1.0');
fwrite($sock, "\r\n");
fwrite($sock, "\r\n");
$weg=line_read($sock);
while (substr($weg,0,2) != "20") {
echo $weg."\r\n";
$weg=line_read($sock);
}
return $sock;
}
/*
* Close a NNTP connection
*

View File

@ -5,6 +5,8 @@ return [
'remote_ssl' => '',
'socks_host' => '',
'socks_port' => '',
'http_host' => '',
'http_port' => '',
'remote_auth_user' => 'username',
'remote_auth_pass' => 'password',
'enable_nntp' => '1',

View File

@ -13,6 +13,8 @@ return [
'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',
'http_host' => 'ip address of your http proxy server (use this for i2p or create client tunnel)',
'http_port' => 'port for your http proxy server',
# LOCAL server configuration
'enable_nntp' => 'Enable local nntp server (1=true, blank=false)',

View File

@ -138,7 +138,6 @@ function get_articles($ns, $group) {
$banned_names = file("/etc/rslight/banned_names.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$nocem_check="@@NCM";
# Check if group exists. Open it if it does
fputs($ns, "group ".$group."\r\n");
$response = line_read($ns);
@ -223,6 +222,10 @@ function get_articles($ns, $group) {
if (strcmp(substr($response,0,3),"220") != 0) {
echo "\n".$response."\n";
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Unexpected response to ARTICLE command: ".$response, FILE_APPEND);
if(trim($response) == '') {
fclose($ns);
break;
}
$article++;
continue;
}