Quellcode durchsuchen

uuh, initial commit?

Jared Dunbar vor 2 Jahren
Commit
3ffb6d8901
Signiert von: Jared Dunbar <jrddunbr@gmail.com> GPG-Schlüssel-ID: CF202CC859BAC692
4 geänderte Dateien mit 70 neuen und 0 gelöschten Zeilen
  1. 5
    0
      README.md
  2. 20
    0
      client.py
  3. 17
    0
      protocol.md
  4. 28
    0
      server.py

+ 5
- 0
README.md Datei anzeigen

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

+ 20
- 0
client.py Datei anzeigen

@@ -0,0 +1,20 @@
1
+#!/usr/bin/python3
2
+
3
+import platform, socket, json
4
+
5
+def send(ip, port, data):
6
+    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
7
+    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
8
+    sock.connect((ip, port))
9
+    sock.send(json.dumps(data).encode("utf-8"))
10
+    sock.close()
11
+
12
+info = {}
13
+info["osn"] = platform.system()
14
+info["osv"] = platform.release()
15
+
16
+#ip = "128.153.145.211"
17
+ip = "128.153.144.251"
18
+port = 13695
19
+
20
+send(ip, port, info)

+ 17
- 0
protocol.md Datei anzeigen

@@ -0,0 +1,17 @@
1
+# protocol.md
2
+
3
+The ITL protocol runs on UDP `13695`
4
+
5
+## Protocol Syntax
6
+
7
+The syntax is as follows:
8
+
9
+```json
10
+{
11
+  "osn": "name",
12
+  "osv": "version"
13
+}
14
+```
15
+
16
+`osn`: Name of the operating system. Examples: Windows 10, Ubuntu 18.04
17
+`osv`: Version of the operating system. For Windows 10, this is the version (ex, 1803). For Linux systems, this is the kernel version.

+ 28
- 0
server.py Datei anzeigen

@@ -0,0 +1,28 @@
1
+#!/usr/bin/python3
2
+
3
+import socket, json, threading, time
4
+
5
+db = {}
6
+
7
+port = 13695
8
+
9
+server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
10
+server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
11
+server.bind(("0.0.0.0", port))
12
+
13
+def runServer():
14
+    try:
15
+        data, addr = server.recvfrom(1024)
16
+        mdata = json.loads(data.decode("utf-8"))
17
+        db[addr[0]] = {}
18
+        db[addr[0]]["osn"] = mdata["osn"]
19
+        db[addr[0]]["osv"] = mdata["osv"]
20
+    except:
21
+        pass
22
+
23
+serverThread = threading.Thread(target=runServer)
24
+serverThread.start()
25
+
26
+while True:
27
+    print(db)
28
+    time.sleep(10)

Laden…
Abbrechen
Speichern