本文整理汇总了Python中Milter类的典型用法代码示例。如果您正苦于以下问题:Python Milter类的具体用法?Python Milter怎么用?Python Milter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Milter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: macromilterSUT
def macromilterSUT(request):
macromilter.LOG_DIR = 'test_output/'
macromilter.MATCHED_FILE_LOG_DIR = 'test_output/matched_files/'
macromilter.initialize_async_process_queues(20)
macromilter.cleanup_queues()
Milter.factory = macromilter.MacroMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags)
Milter.factory._ctx = TestBase()
sut = macromilter.MacroMilter()
sut.messageToParse = StringIO.StringIO()
def tear_down():
# clear queues
macromilter.cleanup_queues()
macromilter.WhiteList = ()
request.addfinalizer(tear_down)
return sut
示例2: main
def main():
# Run as a specific user
if run_as_user != None:
run_as_uid = getpwnam(run_as_user).pw_uid
run_as_gid = getpwnam(run_as_user).pw_gid
print "%s running as %s (uid=%s,gid=%s)" % (time.strftime('%Y%b%d %H:%M:%S'), run_as_user, run_as_uid, run_as_gid)
# always set gid first, because once we've set uid, we can't set gid anymore
os.setgid(run_as_gid)
os.setuid(run_as_uid)
# Log startup
print "%s milter startup" % time.strftime('%Y%b%d %H:%M:%S')
sys.stdout.flush()
# Handle log printing in the background
bt = Thread(target=background)
bt.start()
# Register to have the Milter factory create instances of your class:
Milter.factory = MilterSysUser
#Milter.set_flags(Milter.ADDHDRS) # we only need to add a header
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
Milter.runmilter("pythonfilter", socketname, timeout)
# Wait for logger to complete
logq.put(None)
bt.join()
print "%s milter shutdown" % time.strftime('%Y%b%d %H:%M:%S')
示例3: run
def run(self):
utils.log_to_syslog()
logger.info('DSPAM Milter startup (v{})'.format(VERSION))
self.configure()
utils.daemonize(self.pidfile)
Milter.factory = DspamMilter
Milter.runmilter('DspamMilter', self.socket, self.timeout)
logger.info('DSPAM Milter shutdown (v{})'.format(VERSION))
logging.shutdown()
示例4: main
def main():
bt = Thread()
bt.start()
timeout = 60
# Register with Milter factory
Milter.factory = pgpMilter
# we don't modify mails, so no flags
Milter.set_flags(0)
Milter.runmilter("pgpmilter",socket,timeout)
bt.join()
示例5: main
def main():
socketname = "/var/run/nomixsock"
timeout = 600
# Register to have the Milter factory create instances of your class:
Milter.factory = NoMixMilter
print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'))
sys.stdout.flush()
Milter.runmilter("nomixfilter",socketname,timeout)
logq.put(None)
bt.join()
print("%s nomix milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
示例6: main
def main():
bt = Thread(target=background)
bt.start()
socketname = "/var/run/pagure/paguresock"
timeout = 600
# Register to have the Milter factory create instances of your class:
Milter.factory = PagureMilter
print "%s pagure milter startup" % time.strftime("%Y%b%d %H:%M:%S")
sys.stdout.flush()
Milter.runmilter("paguremilter", socketname, timeout)
logq.put(None)
bt.join()
print "%s pagure milter shutdown" % time.strftime("%Y%b%d %H:%M:%S")
示例7: main
def main():
parser = OptionParser()
parser.add_option('-s', '--socket', dest='socket', help='Socket to listen (e.g. inet:[email protected])')
parser.add_option('-t', '--timeout', type='int', dest='timeout', default='10', help='MTA timeout (default is 10 sec)')
(options, args) = parser.parse_args()
if not options.socket:
parser.print_help()
sys.exit(0)
Milter.factory = TuMilter
print "%s TuMilter startup" % time.strftime('%Y %b %d %H:%M:%S')
sys.stdout.flush()
Milter.runmilter("tumilter",options.socket,options.timeout)
示例8: main
def main():
os.umask(007)
Milter.set_flags( Milter.QUARANTINE
+ Milter.CHGHDRS
+ Milter.DELRCPT
+ Milter.ADDRCPT
+ Milter.CHGFROM)
config = getConfig()
def instantiate():
return DMARCMilter(config)
Milter.factory = instantiate
Milter.runmilter("dmarc_milter", config.socket, config.timeout)
示例9: __init__
def __init__(self): # A new instance with each new connection.
self.id = Milter.uniqueID() # Integer incremented with each call.
self.messageToParse = None
self.level = 0
self.headercount = 0
self.attachment_contains_macro = False
self.size = 0
示例10: __init__
def __init__(self):
self.tempname = None
self.mailfrom = None
self.fp = None
self.bodysize = 0
self.id = Milter.uniqueID()
self.user = None
示例11: envrcpt
def envrcpt(self, to, *str):
rcptinfo = to,Milter.dictfromlist(str)
self.R.append(rcptinfo)
self.log("to: ", parse_addr(to)[0])
a = 23
b = 42
addr = parse_addr(to)[0]
euser = addr[0:2]
ecsum = addr[2:4]
eitext = addr[4:]
edomain = parse_addr(to)[1]
genitext = ''.join((euser, eitext, edomain))
gencsum = hashlib.sha512(genitext.encode('utf-8')).hexdigest()
posa = int(a)-1
posb = int(b)-1
csuma = gencsum[posa:(posa+1)]
csumb = gencsum[posb:(posb+1)]
self.log(addr, euser, ecsum, eitext, edomain, genitext, gencsum, posa, posb, csuma, csumb)
if(ecsum != "".join((csuma,csumb))):
self.log("Computer sagt nein.")
return Milter.REJECT
self.log("Computer sagt ja.")
return Milter.CONTINUE
示例12: main
def main():
bt = Thread(target=background)
bt.start()
socketname = "/home/stuart/pythonsock"
timeout = 600
# Register to have the Milter factory create instances of your class:
Milter.factory = myMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'))
sys.stdout.flush()
Milter.runmilter("pythonfilter",socketname,timeout)
logq.put(None)
bt.join()
print("%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
示例13: __init__
def __init__(self, conf=None): # A new instance with each new connection.
self.id = Milter.uniqueID()
if conf is not None:
assert isinstance(conf, config.Config)
self.conf = conf
else:
self.conf = config.Config()
self.gpgm_gpg = gnupg.GPG(gnupghome=self.conf.gnupghome)
示例14: main
def main():
bt = Thread(target=background)
bt.start()
socketname = "/home/stuart/pythonsock"
timeout = 600
Milter.factory = myMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags)
print "%s milter startup" % time.strftime('%Y%b%d %H:%M:%S')
sys.stdout.flush()
Milter.runmilter("pythonfilter",socketname,timeout)
logq.put(None)
bt.join()
print "%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S')
示例15: __init__
def __init__(self):
"""
Create a new milter instance.
"""
self.id = Milter.uniqueID()
self.message = ''
self.recipients = []
self.dspam = None