⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pop3proxy.java

📁 StandBayeMail
💻 JAVA
字号:
/** * <p>Title: StandBayeMail </p> * <p>Description: A bayesian spam filter</p> * <p>Copyright: Copyright (c) 2004 by Luca M. Viola</p> * <p>Company: 3AM.it</p> * @author Luca M. Viola <luca@3am.it> * @version 1.0  This program is free software; you can redistribute it and/or  modify it under the terms of the GNU General Public License  as published by the Free Software Foundation; either version 2  of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  This proxy was partly adapted from the original work  Copyright (C) 2003 by Morten Teinum  http://home.chello.no/~forever/morten/pop3_proxy/index.html. */package pop3proxy;import java.io.*;import java.net.*;import java.util.*;import StandBayeMail.*;public class Pop3Proxy implements ServerMapper, Logger{/*  // Uncomment these lines to compile with gcj  // static references to these classes ensure that the linker will include them    private static Class c1 = gnu.java.locale.Calendar.class;    private static Class c2 = java.util.GregorianCalendar.class;    private static Class c3 = gnu.gcj.convert.Input_ASCII.class;    private static Class c4 = gnu.gcj.convert.Input_UTF8.class;    private static Class c5 = gnu.gcj.convert.Input_8859_1.class;    private static Class c6 = gnu.java.locale.LocaleInformation.class;    private static Class c7 = gnu.gcj.convert.Output_ASCII.class;*/  protected long lastModified = -1;  protected java.util.Properties users = new java.util.Properties();  private ServerSocket server;  private static String currentWDir=".";  private StandBayeMail sd;  public static String getCurrentWDir()  {    return currentWDir;  }  public static void main(String args[])  {    if( args.length>0 )      if( args[0]!=null )        currentWDir=args[0];    int port = SocketWrapper.POP3_PORT;    try    {      if (args.length > 1)      {        port = Integer.parseInt(args[1]);      }    }    catch (Exception e)    {      e.printStackTrace();    }    new Pop3Proxy(port);  }  public Pop3Proxy(int port)  {    sd=new StandBayeMail();    //Preloads the databases of good words and spam words    Statistics st = sd.calculateSpamicity(getCurrentWDir()+File.separator+"goodlist.sps",                                          getCurrentWDir()+File.separator+"spamlist.sps", "");    log(Logger.PROXY, "StandBayeMail Copyright (C) by Luca M. Viola (luca@3am.it)");    log(Logger.PROXY, "Version "+StandBayeMail.version+" [build "+StandBayeMail.buildno+","+StandBayeMail.buildtime+"]");    log(Logger.PROXY, "");    log(Logger.PROXY, "StandBayeMail comes with ABSOLUTELY NO WARRANTY.");    log(Logger.PROXY, "This is free software, and you are welcome to redistribute it");    log(Logger.PROXY, "under certain conditions. To get more details read the GNU");    log(Logger.PROXY, "General Public License in the file LICENSE.txt included");    log(Logger.PROXY, "with this distribution or http://www.gnu.org/licenses/gpl.txt");    log(Logger.PROXY, "");    log(Logger.PROXY, "StandBayeMail Proxy Server started [" + (new Date())+"]");    try    {      server = new ServerSocket(port);      log(Logger.PROXY, "Bound on " + server.toString());      while (true)      {        try        {          new Pop3Protocol(server.accept(), this, this,sd);        }        catch (Exception se)        {          if (se instanceof SocketException)          {            String message = se.getMessage();            if (message.indexOf("socket closed") != -1)            {              log(Logger.PROXY, "Proxy Server shut down.");              System.exit(0);            }          }        }      }    }    catch (Exception e)    {      e.printStackTrace();    }  }  public synchronized String getServer(String userName)  {    checkConfigFile();    return users.getProperty(userName);  }  protected synchronized void checkConfigFile()  {    File configFile = new File(getCurrentWDir()+File.separator+"StandBayeMail.config");    if (!configFile.exists())      log(Logger.PROXY, "config file not found.");    if (lastModified == configFile.lastModified()) return;    try    {      java.util.Properties newUserSet = new java.util.Properties();      FileInputStream fis = new FileInputStream(configFile);      newUserSet.load(fis);      users = newUserSet;      lastModified = configFile.lastModified();    }    catch (Exception e)    {      e.printStackTrace();    }  }  public synchronized void log(int from, String line)  {    if( line.startsWith("PASS") ) line="PASS ********";    System.out.println(Logger.descr[from] + " " + line);    System.out.flush();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -