Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #48 and logging #71

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions laikamilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,21 @@ def close(self):
try:
self.client.close()
except:
self.logger.writeLog(syslog.LOG_ERR, self.uuid+" ERROR attempting to close ZMQ context")
#If client is not connected check your laikamilter config
if self.client == None:
self.logger.writeLog(syslog.LOG_ERR, "ERROR cannot close non-connected client in ZMQ context")
else:
self.logger.writeLog(syslog.LOG_ERR, "ERROR attempting to close ZMQ context")


#public function to get flags from si-scan
def zmqGetFlagswithRetry(self, numRetries, milterContext):
sendResponse = self._zmqGetFlags(numRetries, milterContext)
if sendResponse == -1:
self.logger.writeLog(syslog.LOG_ERR, \
"ERROR Laikamilter could not connect to laikad servers:"\
+ str(milterContext.milterConfig.servers)
)


def _getNextScanServer(self):
Expand Down Expand Up @@ -628,15 +637,15 @@ def _zmqGetFlags(self, numRetries, milterContext):
def _zmqSendBuffer(self, milterContext,numRetries, REQUEST_TIMEOUT,SERVER_ENDPOINT):
gotResponseFromScanner=-1
self.client = Client(SERVER_ENDPOINT)

log = milterContext.uuid+" Sending "+ str(milterContext.qid)+" to "+ SERVER_ENDPOINT
self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log)))
myhostname = socket.gethostname()
externalObject = ExternalObject(
buffer=milterContext.fileBuffer,
externalVars=ExternalVars(
filename=milterContext.archiveFileName,
source=milterContext.milterConfig.milterName+"-"+str(myhostname[:myhostname.index(".")]),
source=milterContext.milterConfig.milterName+"-"+ \
(str(myhostname[:myhostname.index(".")]) if "." in myhostname else str(myhostname)),
ephID=milterContext.qid,
uniqID=milterContext.messageID
),
Expand Down