🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #211314

Re: StartTLS with Mercury/32

#211314
From: madmax
Date: Fri, 13 Oct 2006 05:01
155 lines
6035 bytes
-----BEGIN PGP SIGNED MESSAGE-----

On Thu, 12 Oct 2006, George Orwell <nobody@mixmaster.it> wrote:
>>can you run Java on your machine, Runaway? Would any other remop be
>>interested in a program to monitor Mercury and restart as needed? I could
>>write that when I have time, as a way to contribute to the cause here. Let
>>me know if anybody's interested.
>>
>>
>>
>>.
>
>We are interested.  Please code at your convienience.


Thanks for the feedback. Here's the base logic, for anybody that is
familiar with compiling Java. I tried to make it as simple as possible to
use. Feedback is appreciated.

This brings up the question of how to distribute this code? If I publish
the source, anyone can compile it but a person would need to have some
familiarity with doing that. Maybe some trusted person(s) could provide the
executable *.class file, or maybe crypto hashes can be used by others to
verify any class file that I publish, against the source code. 

Paste into a file named MadMonitor.java
then run                               javac MadMonitor.java
to compile
then                                      java MadMonitor
c:\mercury\mercury.exe 25 30                       to execute

=========================

/**    MadMonitor  by madmax@none.non
        todo: 
        determine failure condition: does a Mercury instance in TLS failure
condition
        1) give a 502 reply to the STARTTLS command?
            or
        2) accept the STARTTLS command but fail to negotiate TLS?        
        
        also, check if the target port (normally 25) is occupied before
starting Mercury
        
*/        
        

import java.io.*;
import java.net.*;

public class MadMonitor {

    private Runtime rt;
    private Process proc;
    private String exe;
    private int port, interval;
    
    public static void main(String[] args) {
        if (args.length != 3) {
            System.err.println("Usage: java Madmonitor executable port
interval_seconds");
            System.err.println("e.g.: java Madmonitor
c:\\mercury\\mercury.exe 25 30");
        } else {
            new MadMonitor(args[0], args[1], args[2]).begin();    
        }
    }
    
    // class constructor
    public MadMonitor(String exe, String port, String seconds) {
        this.exe = exe;
        this.port = Integer.parseInt(port);
        interval = Integer.parseInt(seconds) * 1000;
        System.out.println("Polling interval is " + seconds + " seconds.");
        rt = Runtime.getRuntime();
    }
        
    private void begin() {
        startProc();
        boolean flag = true;
        while (flag) {
            try {
                Thread.sleep(interval);
                
                Socket sock = new Socket("127.0.0.1", port);
                
                BufferedReader br = new BufferedReader
                    (new InputStreamReader(sock.getInputStream()));
                PrintWriter pw = new PrintWriter
                    (new OutputStreamWriter(sock.getOutputStream()), true);

                String s;
                s = br.readLine(); // get greeting
                System.out.println(s);

                pw.println("STARTTLS");
                s = br.readLine(); // get reply
                System.out.println(s);
                
                br.close();
                pw.close();
                sock.close();
                
                if (s.startsWith("5")) {
                    endProc();
                    startProc();    
                }
                
            } catch (InterruptedException ie) {
                System.out.println(ie);
            } catch (UnknownHostException uhe) {
                System.err.println(uhe);
            } catch (IOException ioe) {
                System.err.println(ioe);
            }
        }
        endProc();
    }    
            
    private void endProc() {    
        proc.destroy();
        try {    
            proc.waitFor();
            System.out.print("Process destroyed. Exit value>" +
proc.exitValue());
            System.out.println("   [Expected value=1]");
        } catch (InterruptedException ie) {
            System.err.println(ie);
        }
    }
    
    private void startProc() {    
        try {
            proc = rt.exec(exe);
            System.out.println("MadMonitor started");
        } catch (IOException ioe) {
            System.out.println(ioe);    
        }
    }    

}





-----BEGIN PGP SIGNATURE-----
Version: N/A

iQA/AwUBRS8UtIc8LUQoEaFFEQKOGwCbBphuKzFm0lBN+32LTjq5dgDATaYAoP7+
FUGokG7ztWUpr7+Ep/uADUIQ
=gunD
-----END PGP SIGNATURE-----

Technical Details
Message-ID: <TQ7OBTC739003.0008449074@anonymous.poster>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!feeder.news-service.com!feeder1.cambrium.nl!feed.tweaknews.nl!news.wiretrip.org!news.dizum.com!sewer-output!mail2news
References: <eg291q$uq6$1@bananasplit.info> <B9218YR538996.0247453704@twistycreek.com> <eg4qq7$esi$1@bananasplit.info> <M6M4Z55Z39001.7462268519@twistycreek.com> <a2832c115199fd6978e73d38bc0cfebe@mixmaster.it>

Show Full Headers
Complete Article Headers
Message-ID: <TQ7OBTC739003.0008449074@anonymous.poster>
Subject: Re: StartTLS with Mercury/32
Date: Fri, 13 Oct 2006 05:01:13 +0000
From: madmax <madmax@none.non>
References: <eg291q$uq6$1@bananasplit.info> <B9218YR538996.0247453704@twistycreek.com> <eg4qq7$esi$1@bananasplit.info> <M6M4Z55Z39001.7462268519@twistycreek.com> <a2832c115199fd6978e73d38bc0cfebe@mixmaster.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!feeder.news-service.com!feeder1.cambrium.nl!feed.tweaknews.nl!news.wiretrip.org!news.dizum.com!sewer-output!mail2news
Newsgroups: alt.privacy.anon-server
X-Remailer-Contact: Anonymous Mailer <DingoAdmin@DingoRemailer.com>
X-Spam-Processed: dingoremailer.com, Fri, 13 Oct 2006 00:01:17 -0500
 (not processed: recipient mail2news@dizum.com in exclude file)
X-Return-Path: dingobounce@dingoremailer.com
X-MDaemon-Deliver-To: mail2news@dizum.com
Mail-To-News-Contact: abuse@dizum.com
Organization: mail2news@dizum.com
Lines: 155