Contact: fumanchu@aminus.org

Log in as guest/misc to create tickets

Changeset 38

Show
Ignore:
Timestamp:
02/07/06 13:06:46
Author:
fumanchu
Message:

It's aliiiiive!!!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • vmpro_pager.py

    r34 r38  
    1616import asyncore 
    1717import smtpd 
     18import threading 
    1819 
    1920import win32serviceutil 
     
    2324 
    2425 
     26class win32log: 
     27     
     28    def write(self, msg): 
     29        servicemanager.LogInfoMsg('%s (%s): %s' 
     30                                  % (SMTPProxyService._svc_name_, 
     31                                     SMTPProxyService._svc_display_name_, 
     32                                     msg)) 
     33     
     34    def flush(self): pass 
     35win32log = win32log() 
     36 
     37##smtpd.DEBUGSTREAM = win32log 
     38 
     39 
     40class VoicemailProProxy(smtpd.PureProxy): 
     41    def process_message(self, peer, mailfrom, rcpttos, data): 
     42        # Fixup the mailfrom; 
     43        # Exim requires that it contain a domain, but it's coming through as "Voicemail2". 
     44        refused = self._deliver("vemergency@amor.org", rcpttos, data) 
     45         
     46        # TBD: what to do with refused addresses? 
     47        win32log.write("Delivery results: %s" % repr(refused)) 
     48        return refused 
     49 
     50 
    2551class SMTPProxyService(win32serviceutil.ServiceFramework): 
    2652     
    27     _svc_name_ = "Voicemail Pro Email Fixup
    28     _svc_display_name_ = "Voicemail Pro Email Fixup service/proxy
     53    _svc_name_ = "vmpro_pager
     54    _svc_display_name_ = "Voicemail Pro Email Fixup
    2955     
    3056    def __init__(self, args): 
     
    3359        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) 
    3460        # create our proxy instance 
    35         self.proxy = smtpd.PureProxy(("localhost", 25), ("192.168.0.6", 25)) 
     61        self.proxy = VoicemailProProxy(("localhost", 25), ("192.168.0.6", 25)) 
    3662     
    3763    def SvcDoRun(self): 
     
    6591 
    6692if __name__ == '__main__': 
    67     win32serviceutil.HandleCommandLine(SMTPProxyService) 
     93    import sys 
     94    if sys.argv[1:] == ['test']: 
     95        p = VoicemailProProxy(("localhost", 25), ("192.168.0.6", 25)) 
     96        try: 
     97            asyncore.loop() 
     98        except KeyboardInterrupt: 
     99            p.close() 
     100    else: 
     101        win32serviceutil.HandleCommandLine(SMTPProxyService)