Added some RabbitMQ amendments.
This commit is contained in:
parent
20a2a2be26
commit
46d895d900
2 changed files with 14 additions and 2 deletions
|
@ -88,6 +88,12 @@ class rabbitMQClient:
|
|||
manager.insertURLLog(result[0], result[1], result[2], result[4], result[5])
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
|
||||
if result[3] == 'ipBlock':
|
||||
|
||||
result[2] = datetime.datetime.fromisoformat(result[2])
|
||||
manager = logsManager(config.sqlServer, config.sqlDatabase, config.sqlUsername, config.sqlPassword)
|
||||
manager.insertIPBlock(result[0], result[1], result[4], result[5], result[6], result[2], config.ipinfoAPIToken)
|
||||
|
||||
context = ssl.create_default_context(
|
||||
cafile=self.ca)
|
||||
context.verify_mode = ssl.CERT_REQUIRED
|
||||
|
|
|
@ -10,7 +10,6 @@ def main():
|
|||
print("Usage: python script.py <blockedIPAddress> <jail> <live>")
|
||||
sys.exit(1)
|
||||
|
||||
manager = logsManager(config.sqlServer, config.sqlDatabase, config.sqlUsername, config.sqlPassword)
|
||||
hostname = socket.gethostname()
|
||||
ipAddress = socket.gethostbyname(hostname)
|
||||
blockedIPAddress = sys.argv[1]
|
||||
|
@ -21,7 +20,14 @@ def main():
|
|||
|
||||
print(hostname, ipAddress, blockedIPAddress, jail, live, logTime, token)
|
||||
|
||||
manager.insertIPBlock(hostname, ipAddress, blockedIPAddress, jail, live, logTime, token)
|
||||
if not config.loggingMode == 'none' and not config.loggingMode == 'rabbitmq':
|
||||
|
||||
manager = logsManager(config.sqlServer, config.sqlDatabase, config.sqlUsername, config.sqlPassword)
|
||||
manager.insertIPBlock(hostname, ipAddress, blockedIPAddress, jail, live, logTime, token)
|
||||
|
||||
if config.loggingMode == 'rabbitmq':
|
||||
|
||||
rabbitmq.publish(hostname + '|' + socket.gethostbyname(socket.gethostname()) + '|' + str(logTime) + '|' + 'ipBlock' + '|' + str(blockedIPAddress) + '|' + str(jail) + '|' str(live)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue