From aef9df41a838976b3485f41f694cb210f398f8a4 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Thu, 21 Jan 2021 20:56:24 -0700 Subject: [PATCH] Clean up eols in xover output and add 'open_clients' config option --- Rocksolid_Light/rslight/rslight.inc.php | 1 + Rocksolid_Light/rslight/scripts/cron.php | 6 ++---- Rocksolid_Light/rslight/scripts/rslight-lib.php | 12 +++++++++--- Rocksolid_Light/rslight/scripts/setuphelper.php | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Rocksolid_Light/rslight/rslight.inc.php b/Rocksolid_Light/rslight/rslight.inc.php index c0e421b..df906fa 100644 --- a/Rocksolid_Light/rslight/rslight.inc.php +++ b/Rocksolid_Light/rslight/rslight.inc.php @@ -42,6 +42,7 @@ return [ 'expire_days' => '0', 'pathhost' => 'unconfigured', 'article_database' => '1', + 'open_clients' => '' 'thissitekey' => '' ]; ?> diff --git a/Rocksolid_Light/rslight/scripts/cron.php b/Rocksolid_Light/rslight/scripts/cron.php index 0ff3cdf..dc84d1d 100755 --- a/Rocksolid_Light/rslight/scripts/cron.php +++ b/Rocksolid_Light/rslight/scripts/cron.php @@ -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"); } } } diff --git a/Rocksolid_Light/rslight/scripts/rslight-lib.php b/Rocksolid_Light/rslight/scripts/rslight-lib.php index be3008d..8b3d572 100755 --- a/Rocksolid_Light/rslight/scripts/rslight-lib.php +++ b/Rocksolid_Light/rslight/scripts/rslight-lib.php @@ -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]; diff --git a/Rocksolid_Light/rslight/scripts/setuphelper.php b/Rocksolid_Light/rslight/scripts/setuphelper.php index fbafb5e..f226ef2 100644 --- a/Rocksolid_Light/rslight/scripts/setuphelper.php +++ b/Rocksolid_Light/rslight/scripts/setuphelper.php @@ -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)',