🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.free.newsservers
7 messages
7 total messages Started by VPN user Mon, 28 Mar 2016 01:36
What is a quick Linux bash test of a free public newsserver on VPN?
#164154
Author: VPN user
Date: Mon, 28 Mar 2016 01:36
37 lines
1683 bytes
What is a quick Linux bash test of a free public newsserver on VPN?

I often use unreliable VPN configuration files where sometimes
the free public VPN server allows NNTP connections, but sometimes
they do not.

I'd like to write a bash script to test whether the current VPN
server allows a connection to the main free public VPN servers
such as mixmin, netfront, aioe, etc.

I'm not a good script writer, but I can hack stuff out with a
bit of direction. 

Here's what I'm starting with as ideas to test quickly whether
an nntp connection stands a chance with any particular vpn server:

MIXMIN:
$ openssl s_client -connect news.mixmin.net:563
$ echo $?
0

AIOE:
$ telnet nntp.aioe.org nntp >&/dev/null
$ echo $?
0

NETFRONT:
$ telnet freenews.netfront.net 119
$ echo $?
0

MOZILLA:
$ telnet news.mozilla.org 119
$ echo $?
0

Do you suggest any quick Linux bash test of a free public newsserver on VPN?
Re: What is a quick Linux bash test of a free public newsserver on VPN?
#164165
Author: VPN user
Date: Mon, 28 Mar 2016 17:08
99 lines
4205 bytes
Nobody? 
Not even Michael Baeuerle?

I can *manually* test posting using any of a number of news servers:
1. telnet nntp.aioe.org nntp
2. telnet freenews.netfront.net 119 
3. telnet news.mozilla.org 119
4. (more complicated)
   $ openssl s_client -connect news.mixmin.net:563

But I wonder if there is a shortcut test I can script?

Do I need to go through the entire longcut process in bash, or 
is there a shortcut to figure out when posting fails (yet a 
ping works as does a traceroute)?

Here is my multi-step longcut proving when nntp posting works.

1a. Telnet to the newsserver using the nntp port (use either "nntp" or "119"):
$ telnet nntp.aioe.org 119
--------------------------
1b. A successful connection should result in the following message:
Trying 46.165.242.75...
Connected to nntp.aioe.org.
Escape character is '^]'.
200 nntp.aioe.org InterNetNews NNRP server INN 2.5.4 ready (posting ok)
==========================
2a. Run the nntp "post" command:
post
--------------------------
2b. A successful response would be something like the following message:
340 Ok, recommended message-ID <ndblf0$19o6$1@gioia.aioe.org>
==========================
3a. Add required headers, a blank line, the body, & an ending dot:
From: foo@example.com
Newsgroups: alt.test
Subject: This is a test

This is a test
.
--------------------------
3b. A successful post should result in a unique message id:
240 Article received <ndblf0$19o6$1@gioia.aioe.org>
==========================
4a. Quit out of the telnet session:
quit 
--------------------------
4b. A successful message would be the following:
205 Bye!
Connection closed by foreign host.
==========================
5a. Now test a *different* server to see whether that post actually took:
$ telnet freenews.netfront.net nntp
--------------------------
5b. A successful connection should indicate something like the following:
Trying 202.81.252.44...
Connected to freenews.netfront.net.
Escape character is '^]'.
200 freenews.netfront.net InterNetNews NNRP server INN 2.5.4 ready (posting ok)
==========================
6a. Set the news group to the posted newsgroup:
group alt.test
--------------------------
6b. A successful response should look something like this:
211 4552 356765 361317 alt.test
--------------------------
==========================
7a. Ask for the article by the previously saved message id:
article <ndblf0$19o6$1@gioia.aioe.org>
--------------------------
7b. The result should be the article as posted:
220 0 <ndblf0$19o6$1@gioia.aioe.org> article
Path: aioe.org!.POSTED!not-for-mail
From: foo@example.com
Newsgroups: alt.test
Subject: This is a test
Date: Mon, 28 Mar 2016 16:18:21 +0000 (UTC)
Organization: Aioe.org NNTP Server
Lines: 1
Message-ID: <ndblf0$19o6$1@gioia.aioe.org>
NNTP-Posting-Host: C2t50uUupLYInn2uM5C5BQ.user.gioia.aioe.org
X-Complaints-To: abuse@aioe.org
X-Notice: Filtered by postfilter v. 0.8.2
Xref: aioe.org alt.test:361317

This is a test
.
==========================
8a. Quit out of the telnet session:
quit
--------------------------
8b. The response should be successful:
205 Bye!
Connection closed by foreign host.
==========================

Given that the longcut works, is there a clever shortcut that 
I can insert into a bash script that will test and report 
whether nntp posting is currently working?
Re: What is a quick Linux bash test of a free public newsserver on VPN?
#164185
Author: VPN user
Date: Wed, 30 Mar 2016 00:45
50 lines
2504 bytes
VPN user wrote in message ndboei$tur$2@news.mixmin.net

> Nobody? 
> Not even Michael Baeuerle?
> 
> I can *manually* test posting using any of a number of news servers:
> 1. telnet nntp.aioe.org nntp
> 2. telnet freenews.netfront.net 119 
> 3. telnet news.mozilla.org 119
> 4. (more complicated)
>    $ openssl s_client -connect news.mixmin.net:563

There are many ways to solve the problem, but, not being much of a coder, 
I solved the problem with a bash shell script and with a tcl expect script.

Here is the except TCL script.
(BTW, what do people use for filename extensions for "expect" scripts?)

#!/usr/bin/expect
# Test if NNTP posting is allowed by a given news server for the current VPN connection.
# Use Model: $ vpnnntp.tcl nntp.aioe.org 119
# Output: A message will state whether posting is allowed, or not.

# Abort if the process takes more than 10 seconds.
# WIP: Need to test if this actually works as I haven't seen it happen yet.
set timeout 10

# Obtain the newsserver & NNTP port from the command line:
set _server [lindex $argv 0]
set _port [lindex $argv 1]
send_user "...Connecting to ${_server}:${_port}\n"

# Report whether the newsserver allows NNTP posting for this VPN connection.
spawn telnet $_server $_port
send_user "...Checking for connection-refused or for posting-ok condition...\n"
expect {
   "200 nntp.aioe.org InterNetNews NNRP server INN 2.5.4 ready (posting ok)"
   {
     send_user "...Good: Posting is allowed by ${_server}:${_port}\n"
     send "quit\r"
   }

   "Connection refused"
   {
     send_user "...Oops: Connections are refused by ${_server}:${_port}\n"
   }

 }

expect eof
SOLVED: What is a quick Linux bash test of a free public newsserver on VPN?
#164186
Author: VPN user
Date: Wed, 30 Mar 2016 00:47
98 lines
3771 bytes
> Here is the except TCL script.
> (BTW, what do people use for filename extensions for "expect" scripts?)
> 
> #!/usr/bin/expect
> # Test if NNTP posting is allowed by a given news server for the current VPN connection.
> # Use Model: $ vpnnntp.tcl nntp.aioe.org 119
> # Output: A message will state whether posting is allowed, or not.
> 
> # Abort if the process takes more than 10 seconds.
> # WIP: Need to test if this actually works as I haven't seen it happen yet.
> set timeout 10
> 
> # Obtain the newsserver & NNTP port from the command line:
> set _server [lindex $argv 0]
> set _port [lindex $argv 1]
> send_user "...Connecting to ${_server}:${_port}\n"
> 
> # Report whether the newsserver allows NNTP posting for this VPN connection.
> spawn telnet $_server $_port
> send_user "...Checking for connection-refused or for posting-ok condition...\n"
> expect {
>    "200 nntp.aioe.org InterNetNews NNRP server INN 2.5.4 ready (posting ok)"
>    {
>      send_user "...Good: Posting is allowed by ${_server}:${_port}\n"
>      send "quit\r"
>    }
> 
>    "Connection refused"
>    {
>      send_user "...Oops: Connections are refused by ${_server}:${_port}\n"
>    }
> 
>  }
> 
> expect eof

Above is the vpnnntp.tcl script which solves the original question.
Below is the bash vpnnntp.sh script which solves the original question.

Improvements are always welcome.

#!/bin/bash
# vpnnntp.sh will test whether nntp posting is ok given the current vpn server

# Free error checking:
set -u

# Output storage:
_outFile=/tmp/nntp.out

# If openvpn is not currently running, then exit.
openvpnPID=$(pgrep openvpn)
  if [ $? -ne 0 ]; then
    echo "Oops: Openvpn is not running."
    exit 1
  fi

# If the total number of arguments is 0, then use the default nntp server & nntp port.
# e.g., nntp.aioe.org:119
  if [ $# -eq 0 ]; then
    _nntpServer=nntp.aioe.org
    _nntpPort=119
 fi

# If the total number of arguments is 1, then use that nntp server & the default nntp port.
  if [ $# -eq 1 ]; then
    _nntpServer=$1
    _nntpPort=119
 fi

# If the total number of arguments is 2, then use that nntp server & that nntp port.
  if [ $# -eq 2 ]; then
    _nntpServer=$1
    _nntpPort=$2
 fi

# If the total number of arguments is greater than 2, then consider that an error.
  if [ $# -gt 2 ]; then
    echo "Oops: Too many arguments; maximum of 2"
    exit 1
 fi

# Attempt to connect to the given nntp server:
(
sleep 1
echo "quit";
) | telnet $_nntpServer $_nntpPort | tee $_outFile

# Test if the nntp server allows posting from the current openvpn IP address:
grep "posting ok" $_outFile 
if [ "$?" = "0" ]; then
  echo "Posting is ok because the exit return status was true = 0" # output on standard out
else
  echo "Posting is not ok because the exit return status was false = 1" 1>&2 # output on standard error
fi

exit 0
## End ##
Re: SOLVED: What is a quick Linux bash test of a free public newsserver on VPN?
#164187
Author: VPN user
Date: Wed, 30 Mar 2016 13:56
108 lines
4085 bytes
VPN user wrote in message ndf7na$29b$10@news.mixmin.net

>> Here is the except Bash script.

BTW, for some reason, the "logic" fails but I can't for the life of
me see why it failed.

Here is a run I just made using the script below, which took less than
30 seconds between the first run and the fourth.

Do you know *why* the script fails the first 3 times, yet doing it
manually works the 4th time?

In all four cases, the script runs the *exact* same command!

Run 1:
$ vpnusenet.sh
  Trying 46.165.242.75...
  Connected to nntp.aioe.org.
  Escape character is '^]'.
  Connection closed by foreign host.
  Posting is not ok because the exit return status was false = 1

Run 2: 
$ vpnusenet.sh nntp.aioe.org
  Trying 46.165.242.75...
  Connected to nntp.aioe.org.
  Escape character is '^]'.
  Connection closed by foreign host.
  Posting is not ok because the exit return status was false = 1

Run 3:
$ vpnusenet.sh nntp.aioe.org 119
  Trying 46.165.242.75...
  Connected to nntp.aioe.org.
  Escape character is '^]'.
  Connection closed by foreign host.
  Posting is not ok because the exit return status was false = 1

Run 4:
$ telnet nntp.aioe.org 119
  Trying 46.165.242.75...
  Connected to nntp.aioe.org.
  Escape character is '^]'.
  200 nntp.aioe.org InterNetNews NNRP server INN 2.5.4 ready (posting ok)
quit
  205 Bye!
  Connection closed by foreign host.

Here is the bash script for your tests:
#!/bin/bash
# vpnusenet.sh will test whether nntp posting is ok given the current vpn server
# USE: $ vpnusenet.sh (will use the default newssserver nntp.aioe.org & default port 119)
# USE: $ vpnusenet.sh freenews.netfront.net (will use the given newsserver & default to the port 119)
# USE: $ vpnusenet.sh news.mozilla.org 119 (will use the given newsserver & the stated port)

# Free error checking:
set -u

# Output storage:
_outFile=/tmp/nntp.out

# Default newsserver and port:
_nntpServer=nntp.aioe.org
_nntpPort=119

# If openvpn is not currently running, then exit.
openvpnPID=$(pgrep openvpn)
  if [ $? -ne 0 ]; then
    echo "Oops: Openvpn is not running."
    exit 1
  fi

# If the total number of arguments is 1, then use that nntp server & the default nntp port.
# e.g., news.mixmin.net:119, freenews.netfront.net:119, news.mozilla.org:119, etc.
  if [ $# -eq 1 ]; then
    _nntpServer=$1
 fi

# If the total number of arguments is 2, then use that nntp server & that nntp port.
# e.g., nntp.aioe.org:443, nntp.aioe.org:563, news.mixmin.net:563, etc.
  if [ $# -eq 2 ]; then
    _nntpServer=$1
    _nntpPort=$2
 fi

# If the total number of arguments is greater than 2, then consider that an error.
  if [ $# -gt 2 ]; then
    echo "Oops: Too many arguments; maximum of 2"
    exit 1
 fi

# Attempt to connect to the given nntp server:
(
sleep 1
echo "quit";
) | telnet $_nntpServer $_nntpPort | tee $_outFile

# Test if the nntp server allows posting from the current openvpn IP address:
grep "posting ok" $_outFile 
if [ "$?" = "0" ]; then
  echo "Posting is ok because the exit return status was true = 0" # output on standard out
else
  echo "Posting is not ok because the exit return status was false = 1" 1>&2 # output on standard error
fi

exit 0
## End ##
Re: SOLVED: What is a quick Linux bash test of a free public newsserver on VPN?
#164191
Author: VPN user
Date: Thu, 31 Mar 2016 15:00
52 lines
2637 bytes
Here's a more robust script which actually posts a message, 
and then checks if that message was posted.

#!/usr/bin/expect -f
# Test nntp connection using "vpnexpect nntp.aioe.org 119".
# See also: autoexpect telnet nntp.aioe.org 119, where you can interact & read results easily.
# See also: Expect home page at http://expect.sourceforge.net
set timeout 10
set _ip [lindex $argv 0]
set _port [lindex $argv 1]
send_user "Connecting to ${_ip}:${_port} now\n"
# interact
spawn telnet $_ip $_port
sleep 1
send_user "Checking for connection-refused or for posting-ok condition...\n"
expect {
   "200 nntp.aioe.org InterNetNews NNRP server INN 2.5.4 ready (posting ok)"
   {
         send_user "Posting is ok, so trying a test post...\n"
         send "post\r"
         send "From: foo@example.com\r"
         send "Newsgroups: alt.test\r"
         send "Subject: This is my test post\r"
         send "\r"
         send "This is my test post\r"
         send ".\r"
         # 240 Article received <ndevt2$s8d$1@gioia.aioe.org>
         # expect -re "^240 Article received \<\.*\>$"
         expect -re "\<\.*\>"
         # send_user "The expect_out buffer 2 is: $expect_out(buffer)\n"
         # send_user "The expect_out string 2 is: $expect_out(0,string)\n"
         set _id [lindex $expect_out(0,string)\n]
         send_user "The message-id string is: $_id\n"
         send "group alt.test\r"
         expect "alt.test"
         send "article $_id\r"
         expect "Organization: Aioe.org NNTP Server"
         send_user "Sleeping for 5 seconds.\n"
         sleep 5
         send "quit\r";
         expect "205 Bye!"
   }
 
   "Connection refused"
   {
     send_user "Oops: The connection was refused to ${_ip}:${_port}"
     exit
   }
 
 }

expect eof
Re: SOLVED: What is a quick Linux bash test of a free public newsserver on VPN?
#164192
Author: VPN user
Date: Thu, 31 Mar 2016 15:00
49 lines
2319 bytes
This is an improved checking script.

#!/usr/bin/expect
#********************************************************************
#*
#*    Test if NNTP posting is allowed by a given news server
#*    for the current VPN connection within 10 seconds.
#*
#* Usage:    vpnusenet.exp server port
#*
#* Example:  vpnusenet.exp nntp.aioe.org 119
#*
#* Output: news server will state whether posting is allowed or
#*          otherwise, you will get any telnet failure messages.
#*
#* Return code:
#*         $? = 0 upon success
#*         $? = 1 upon failure
#*
#********************************************************************

set timeout 10

     #********************************************************
     # Obtain the newsserver & NNTP port from the command line
     #*********************************************************

set _server [lindex $argv 0]
set _port [lindex $argv 1]
# send_user "...Connecting to ${_server}:${_port}\n"
   puts "\n\n...Connecting to ${_server}:${_port}\n"

     #**************************************************
     # Report whether the newsserver allows NNTP posting
     #**************************************************

puts "\n\nChecking for connection-refused or for posting-ok condition...\n"

spawn telnet $_server $_port
expect {
  "posting ok" { send "quit\r" ; exit 0 }
  }

  puts "\n\nTest Failure: \n\r"
  exit 1

expect eof

#********* end testvpnusenet.exp ***************************
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads