|
@@ -1,4 +1,6 @@
|
|
|
#!/usr/bin/python
|
|
|
+from __future__ import print_function
|
|
|
+import datetime
|
|
|
import socket
|
|
|
import random, string
|
|
|
|
|
@@ -9,16 +11,17 @@ if __name__ == '__main__':
|
|
|
TCP_IP = '::'
|
|
|
TCP_PORT = 1337
|
|
|
BUFFER_SIZE = 1024
|
|
|
-
|
|
|
+
|
|
|
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
|
|
s.bind((TCP_IP, TCP_PORT))
|
|
|
s.listen(1)
|
|
|
while 1:
|
|
|
conn, addr = s.accept()
|
|
|
- print 'Connection address:', addr
|
|
|
- filename = myrandom(10)
|
|
|
- filename +=".txt"
|
|
|
- f = open(filename,'w')
|
|
|
+
|
|
|
+ report_id = myrandom(10)
|
|
|
+ filename = 'reports/' + datetime.date.today().strftime('%Y-%m-%d_') + report_id + '.gz'
|
|
|
+
|
|
|
+ f = open(filename, 'w')
|
|
|
while 1:
|
|
|
data = conn.recv(BUFFER_SIZE)
|
|
|
if not data: break
|
|
@@ -27,7 +30,9 @@ if __name__ == '__main__':
|
|
|
f.write(data) # python will convert \n to os.linesep
|
|
|
f.flush()
|
|
|
f.close()
|
|
|
- conn.send(filename)
|
|
|
+
|
|
|
+ # send reply to reportee
|
|
|
+ conn.send(report_id)
|
|
|
conn.close()
|
|
|
print 'new report:', filename
|
|
|
pass
|