monutil/reportIPBlock.py

28 lines
803 B
Python
Raw Normal View History

def main():
import socket
import config
import datetime
from log import logsManager
import sys
if len(sys.argv) != 4:
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]
jail = sys.argv[2]
live = int(sys.argv[3])
logTime = datetime.datetime.now()
token = config.ipinfoAPIToken
print(hostname, ipAddress, blockedIPAddress, jail, live, logTime, token)
manager.insertIPBlock(hostname, ipAddress, blockedIPAddress, jail, live, logTime, token)
if __name__ == "__main__":
main()