Initial import of basic skeleton

This commit is contained in:
Jan Philipp Timme 2019-12-18 14:25:09 +01:00
commit 3868e61f0b
4 changed files with 41 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__

0
README.md Normal file
View File

39
main.py Normal file
View File

@ -0,0 +1,39 @@
import time
import sys
import logging
import Milter
from Milter.utils import parse_addr
# Basic logger that also logs to stdout
# TODO: Improve this a lot.
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
class SuspiciousFrom(Milter.Base):
def __init__(self):
self.id = Milter.uniqueID()
logger.info(f"{self.id} got fired up.")
def header(self, field, value):
logger.info(f"{self.id} Got header: {field} --> {value}")
def main():
milter_socket = "inet:7777@127.0.0.1"
milter_timeout = 60
Milter.factory = SuspiciousFrom
logger.info(f"Starting Milter.")
# This call blocks the main thread.
Milter.runmilter("SuspiciousFromMilter", milter_socket, milter_timeout, rmsock=False)
logger.info(f"Milter finished running.")
if __name__ == "__main__":
logger.debug(f"Hello world!")
main()

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
pymilter==1.0.4