Browse Source

uuh, initial commit?

master
Jared Dunbar 3 years ago
commit
3ffb6d8901
Signed by: jared GPG Key ID: CF202CC859BAC692
  1. 5
      README.md
  2. 20
      client.py
  3. 17
      protocol.md
  4. 28
      server.py

5
README.md

@ -0,0 +1,5 @@
# itl-tracker
The ITL tracker application tracks ITL utilization.
The ITL machines report back to the main itl server what operating system they are in and other information.

20
client.py

@ -0,0 +1,20 @@
#!/usr/bin/python3
import platform, socket, json
def send(ip, port, data):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.connect((ip, port))
sock.send(json.dumps(data).encode("utf-8"))
sock.close()
info = {}
info["osn"] = platform.system()
info["osv"] = platform.release()
#ip = "128.153.145.211"
ip = "128.153.144.251"
port = 13695
send(ip, port, info)

17
protocol.md

@ -0,0 +1,17 @@
# protocol.md
The ITL protocol runs on UDP `13695`
## Protocol Syntax
The syntax is as follows:
```json
{
"osn": "name",
"osv": "version"
}
```
`osn`: Name of the operating system. Examples: Windows 10, Ubuntu 18.04
`osv`: Version of the operating system. For Windows 10, this is the version (ex, 1803). For Linux systems, this is the kernel version.

28
server.py

@ -0,0 +1,28 @@
#!/usr/bin/python3
import socket, json, threading, time
db = {}
port = 13695
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(("0.0.0.0", port))
def runServer():
try:
data, addr = server.recvfrom(1024)
mdata = json.loads(data.decode("utf-8"))
db[addr[0]] = {}
db[addr[0]]["osn"] = mdata["osn"]
db[addr[0]]["osv"] = mdata["osv"]
except:
pass
serverThread = threading.Thread(target=runServer)
serverThread.start()
while True:
print(db)
time.sleep(10)
Loading…
Cancel
Save