예제 #1
0
def main(servers, proxyPorts, uiPort, launchUI):
    """Runs the proxy forever or until a 'KILL' command is received or
    someone hits Ctrl+Break."""
    _createProxies(servers, proxyPorts)
    httpServer = UserInterfaceServer(uiPort)
    proxyUI = ProxyUserInterface(state, _recreateState)
    httpServer.register(proxyUI)
    Dibbler.run(launchBrowser=launchUI)
예제 #2
0
def main(servers, proxyPorts, uiPort, launchUI):
    """Runs the proxy forever or until a 'KILL' command is received or
    someone hits Ctrl+Break."""
    _createProxies(servers, proxyPorts)
    httpServer = UserInterfaceServer(uiPort)
    proxyUI = ProxyUserInterface(state, _recreateState)
    httpServer.register(proxyUI)
    Dibbler.run(launchBrowser=launchUI)
예제 #3
0
 def runUIAndProxy():
     httpServer = UserInterfaceServer(8881)
     proxyUI = ProxyUserInterface(state, _recreateState)
     httpServer.register(proxyUI)
     BayesProxyListener('localhost', 8110, ('', 8111))
     state.bayes.learn(tokenizer.tokenize(spam1), True)
     state.bayes.learn(tokenizer.tokenize(good1), False)
     proxyReady.set()
     Dibbler.run()
예제 #4
0
 def runUIAndProxy():
     httpServer = UserInterfaceServer(8881)
     proxyUI = ProxyUserInterface(state, _recreateState)
     httpServer.register(proxyUI)
     BayesProxyListener('localhost', 8110, ('', 8111))
     state.bayes.learn(tokenizer.tokenize(spam1), True)
     state.bayes.learn(tokenizer.tokenize(good1), False)
     proxyReady.set()
     Dibbler.run()
예제 #5
0
 def main(state):

    """Runs the core server forever or until a 'KILL' command is received or
    someone hits Ctrl+Break."""

    http_server = UserInterfaceServer(state.ui_port)

    http_server.register(CoreUserInterface(state))

    Dibbler.run(launchBrowser=state.launch_ui)
예제 #6
0
파일: sb_pop3dnd.py 프로젝트: Xodarap/Eipi
def setup():
    # Setup state, app, boxes, trainers and account
    state.createWorkers()
    proxyListeners = []
    app = Application("SpambayesIMAPServer")

    spam_box = SpambayesMailbox("Spam", 0, options["Storage",
                                                   "spam_cache"])
    unsure_box = SpambayesMailbox("Unsure", 1, options["Storage",
                                                       "unknown_cache"])
    ham_train_box = SpambayesMailbox("TrainAsHam", 2,
                                     options["Storage", "ham_cache"])
    inbox = SpambayesInbox(3)

    spam_trainer = Trainer(spam_box, True)
    ham_trainer = Trainer(ham_train_box, False)
    spam_box.addListener(spam_trainer)
    ham_train_box.addListener(ham_trainer)

    user_account = SpambayesAccount(options["imapserver", "username"],
                                    ham_train_box, spam_box, unsure_box,
                                    inbox)

    # add IMAP4 server
    f = OneParameterFactory()
    f.protocol = SpambayesIMAPServer
    f.parameter = user_account
    state.imap_port = options["imapserver", "port"]
    app.listenTCP(state.imap_port, f)

    # add POP3 proxy
    for (server, serverPort), proxyPort in zip(state.servers,
                                               state.proxyPorts):
        listener = MyBayesProxyListener(server, serverPort, proxyPort,
                                        spam_box, unsure_box)
        proxyListeners.append(listener)
    state.buildServerStrings()

    # add web interface
    httpServer = UserInterfaceServer(state.uiPort)
    serverUI = ServerUserInterface(state, _recreateState)
    httpServer.register(serverUI)

    return app
예제 #7
0
def main(state):
    """Runs the core server forever or until a 'KILL' command is received or
    someone hits Ctrl+Break."""
    http_server = UserInterfaceServer(state.ui_port)
    http_server.register(CoreUserInterface(state))
    Dibbler.run(launchBrowser=state.launch_ui)
예제 #8
0
             imaps.append(None)
         else:
             imaps.append(IMAPSession(server, imapDebug, doExpunge))
     def close_db():
         message_db.store()
         message_db.close()
         message.Message().message_info_db.store()
         message.Message().message_info_db.close()
         message.Message.message_info_db = None
         classifier.store()
         classifier.close()
     def change_db():
         classifier = storage.open_storage(*storage.database_type(opts))
         message.Message.message_info_db = message_db
         imap_filter = IMAPFilter(classifier, message_db)
     httpServer = UserInterfaceServer(options["html_ui", "port"])
     pwds = [ x[2] for x in servers_data ]
     httpServer.register(IMAPUserInterface(classifier, imaps, pwds,
                                           IMAPSession, stats=stats,
                                           close_db=close_db,
                                           change_db=change_db))
     launchBrowser = launchUI or options["html_ui", "launch_browser"]
     if sleepTime:
         thread.start_new_thread(Dibbler.run, (),
                                 {"launchBrowser":launchBrowser})
     else:
         Dibbler.run(launchBrowser=launchBrowser)
 if doClassify or doTrain:
     imaps = []
     for server, username, password in servers_data:
         imaps.append(((server, imapDebug, doExpunge),
예제 #9
0
    if server.find(':') > -1:
        server, port = server.split(':', 1)
        port = int(port)
    else:
        if options["imap", "use_ssl"]:
            port = 993
        else:
            port = 143

    imap_filter = IMAPFilter(classifier)

    # Web interface
    if not (doClassify or doTrain):
        if server != "":
            imap = IMAPSession(server, port, imapDebug, doExpunge)
        httpServer = UserInterfaceServer(options["html_ui", "port"])
        httpServer.register(IMAPUserInterface(classifier, imap, pwd,
                                              IMAPSession))
        Dibbler.run(launchBrowser=launchUI or options["html_ui",
                                                      "launch_browser"])
    else:
        while True:
            imap = IMAPSession(server, port, imapDebug, doExpunge)
            imap.login(username, pwd)

            if doTrain:
                if options["globals", "verbose"]:
                    print "Training"
                imap_filter.Train()
            if doClassify:
                if options["globals", "verbose"]: