diff options
Diffstat (limited to 'whitelist.py')
-rw-r--r-- | whitelist.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/whitelist.py b/whitelist.py index cd0906c..7eb111e 100644 --- a/whitelist.py +++ b/whitelist.py @@ -13,8 +13,10 @@ whitelist manage a list of trusted user. """ import logging +# logging.basicConfig(level=logging.DEBUG) import sys import time + import wlp @@ -29,7 +31,7 @@ class whitelist(object): DENY = 0 ACCEPT = 1 - def __init__(self, wlfile='wl.pyg', logfile='pyg.log'): + def __init__(self, wlfile, logfile='pyg.log'): self.logger = logging.getLogger(__name__) self.logger.setLevel(logging.INFO) log_fh = logging.FileHandler(logfile) @@ -49,12 +51,12 @@ class whitelist(object): def checkfrom(self, fromhead): """have you permission to be here, sir?""" - for owner in self.wl.keys(): + for owner in self.wl: # here colon after 'From' IS required, because binary module wl # expects it. # TODO: when switching to the python lexxing, remove this # limitation. - if fromhead[:-1].find(self.wl[owner]['From:']) >= 0: + if fromhead.find(self.wl[owner]['From:']) >= 0: return owner else: return None @@ -77,25 +79,25 @@ class whitelist(object): self.logger.info('at %s (%s)', ltime, tzone) if owner is not None: - self.logger.info('\tWLOwner: ' + owner + '') - self.logger.info('\tFrom: ' + heads.get('From', 'NOT PRESENT')) - self.logger.info('\tSubject: ' + heads.get('Subject', 'NOT PRESENT')) - self.logger.info('\tSender: ' + heads.get('Sender', 'NOT PRESENT')) - self.logger.info('\tDate: ' + heads.get('Date', 'NOT PRESENT')) + self.logger.debug('\tWLOwner: ' + owner + '') + self.logger.debug('\tFrom: ' + heads.get('From', 'NOT PRESENT')) + self.logger.debug('\tSubject: ' + heads.get('Subject', 'NOT PRESENT')) + self.logger.debug('\tSender: ' + heads.get('Sender', 'NOT PRESENT')) + self.logger.debug('\tDate: ' + heads.get('Date', 'NOT PRESENT')) # some client create Message-Id other Message-ID. if 'Message-ID' in heads: - self.logger.info('\tMessage-ID: ' + heads.get('Message-ID')) + self.logger.debug('\tMessage-ID: ' + heads.get('Message-ID')) else: - self.logger.info('\tMessage-Id: ' + heads.get('Message-Id', - 'NOT PRESENT')) + self.logger.debug('\tMessage-Id: ' + heads.get('Message-Id', + 'NOT PRESENT')) # X-Newsgroups: and To: are present if user is trusted, else # Newsgroup: exists since no changes on nntp headers are done. if 'X-Newsgroups' in heads: - self.logger.info('\tTo: ' + heads.get('To', 'NOT PRESENT')) - self.logger.info('\tX-Newsgroups: ' + heads.get('X-Newsgroups', - 'NOT PRESENT')) + self.logger.debug('\tTo: ' + heads.get('To', 'NOT PRESENT')) + self.logger.debug('\tX-Newsgroups: ' + heads.get('X-Newsgroups', + 'NOT PRESENT')) else: - self.logger.info('\tNewsgroups: ' + - heads.get('Newsgroups', 'NOT PRESENT')) + self.logger.debug('\tNewsgroups: ' + + heads.get('Newsgroups', 'NOT PRESENT')) |