From d4764f181cb113dd46372d709be33762a9ccd345 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 21 Jan 2007 23:09:34 +0000 Subject: [PATCH] add support for standalone operation darcs-hash:20070121230934-5007d-2f6872706b1bbb9512dd739418046439dc18b09e.gz --- src/org/ibex/mail/Main.java | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/org/ibex/mail/Main.java b/src/org/ibex/mail/Main.java index d8d7562..e4971ed 100644 --- a/src/org/ibex/mail/Main.java +++ b/src/org/ibex/mail/Main.java @@ -17,12 +17,45 @@ import org.ibex.jetty.*; public class Main implements Listener { + public static void main(String[] s) throws Exception { + new Main().main(); + } + + public void main() throws Exception { + ServerSocket sock143 = new ServerSocket(143); + ServerSocket sock119 = new ServerSocket(119); + ServerSocket sock25 = new ServerSocket(25); + new Acceptor(sock143).start(); + new Acceptor(sock119).start(); + new Acceptor(sock25).start(); + } + + private class Acceptor extends Thread { + private ServerSocket ss; + public Acceptor(ServerSocket ss) { this.ss = ss; } + public void run() { + try { + while(true) { + final Socket s = ss.accept(); + try { + new Thread() { + public void run() { + try { + accept(new Connection(s, "megacz.com")); + } catch (Exception e) { Log.error(Main.class, e); } + } + }.start(); + } catch (Exception e) { Log.error(Main.class, e); } + } + } catch (Exception e) { Log.error(Main.class, e); } + } + } + public boolean accept(Connection conn) { try { if (conn.getLocalPort() == 143) new IMAP.Listener(auth).handleRequest(conn); - else if (conn.getLocalPort() == 25) new SMTP.Server().handleRequest(conn); - else if (conn.getLocalPort() == 8080) new SMTP.Server().handleRequest(conn); else if (conn.getLocalPort() == 119) new NNTP.Listener(auth).handleRequest(conn); + else if (conn.getLocalPort() == 25) new SMTP.Server().handleRequest(conn); //else if (conn.getLocalPort() == 110) new POP3.Listener(auth).handleRequest(conn); //else if (conn.getLocalPort() == 8099) GMail.handleRequest(conn); else return false; -- 1.7.10.4