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;