Clean up eols in xover output and add 'open_clients' config option

This commit is contained in:
Retro_Guy 2021-01-21 20:56:24 -07:00
parent e790a1295b
commit aef9df41a8
4 changed files with 13 additions and 7 deletions

View File

@ -42,6 +42,7 @@ return [
'expire_days' => '0',
'pathhost' => 'unconfigured',
'article_database' => '1',
'open_clients' => ''
'thissitekey' => '<site_key>'
];
?>

View File

@ -19,10 +19,8 @@
if(($ok_group[0] == ':') || (trim($ok_group) == "")) {
continue;
}
if(strpos($ok_group, "\t") == false) {
$ok_group=preg_replace('/ /', "\t", $ok_group, 1);
}
fputs($fp1, $ok_group);
$ok_group = preg_split("/( |\t)/", trim($ok_group), 2);
fputs($fp1, $ok_group[0]."\r\n");
}
}
}

View File

@ -16,6 +16,11 @@
$cryptoSetup = stream_socket_enable_crypto($msgsock, TRUE, STREAM_CRYPTO_METHOD_TLSv1_0_SERVER | STREAM_CRYPTO_METHOD_TLSv1_1_SERVER | STREAM_CRYPTO_METHOD_TLSv1_2_SERVER);
}
stream_set_timeout($msgsock, 300);
$client = stream_socket_get_name($msgsock, 1);
$client_ip = explode(':', $client);
if(strpos($CONFIG['open_clients'], $client_ip[0]) !== false) {
$auth_ok = 1;
}
/* Send instructions. */
$msg = "200 Rocksolid Light NNTP Server ready (no posting)\r\n";
fwrite($msgsock, $msg, strlen($msg));
@ -35,7 +40,7 @@ set_time_limit(0);
if(stripos($buf, 'AUTHINFO PASS') !== false) {
file_put_contents($logfile, "\n".format_log_date()." AUTHINFO PASS (hidden)", FILE_APPEND);
} else {
file_put_contents($logfile, "\n".format_log_date()." ".$buf, FILE_APPEND);
file_put_contents($logfile, "\n".format_log_date()." ".$client." ".$buf, FILE_APPEND);
}
$command = explode(' ', $buf);
$command[0] = strtolower($command[0]);
@ -563,7 +568,8 @@ function get_xover($articles, $msgsock) {
$article=preg_split("/[\s,]+/", $overviewline);
for($i=$first; $i<=$last; $i++) {
if($article[0] === strval($i)) {
fwrite($msgsock, $overviewline."\r\n", strlen($overviewline));
$overviewline = trim($overviewline)."\r\n";
fwrite($msgsock, $overviewline, strlen($overviewline));
}
}
}
@ -934,7 +940,7 @@ function get_list($mode) {
$name = preg_split("/( |\t)/", $findgroup, 2);
if($name[0][0] === ':')
continue;
$ok_article = get_article_list($nntp_group);
$ok_article = get_article_list($findgroup);
sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
$first = $ok_article[0];

View File

@ -57,6 +57,7 @@ return [
'nocem_groups' => 'The list of groups to monitor for nocem messages (space separated)',
# Misc
'open_clients' => 'Space separated list of ip addresses of clients allowed to post without authenticating',
'article_database' => 'Enable storing articles in database files (1=database, blank=tradspool)',
'expire_days' => 'Posts should be expired after how many days (zero for never)',
'pathhost' => 'The pathhost to use in your XRef header. (maybe a one word name for your site)',