Skip to content

Instantly share code, notes, and snippets.

@kalebo
Last active August 29, 2015 14:20
Show Gist options
  • Save kalebo/65dd711b714635828fdf to your computer and use it in GitHub Desktop.
Save kalebo/65dd711b714635828fdf to your computer and use it in GitHub Desktop.
Dynamic IP Tracker
#!/usr/bin/python
# To add an an entry from a remote machine (NAME at LOCATION):
# $ echo "LOCATION::NAME" | telnet YOURSERVER 45667
import socket
from datetime import datetime
HOST = ""
PORT = 45667
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(5)
while True:
conn, addr = s.accept()
hostid = conn.recv(1024).rstrip()
print "%s (%s) --> %s" % (hostid,datetime.now().strftime("%Y-%m-%dT%H:%M"),addr[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment