-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpn2.py
32 lines (24 loc) · 820 Bytes
/
vpn2.py
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
#!/usr/bin/python3 # This is server.py file
import socket
# create a socket object
serversocket = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
# get local machine name
host = socket.gethostname()
port = 53
# bind to the port
print(host)
serversocket.bind((host, port))
# queue up to 5 requests
serversocket.listen(5)
try:
while True:
clientsocket,addr = serversocket.accept()
msg = clientsocket.recv(1024)
print(msg)
clientsocket.close()
except KeyboardInterrupt:
print("interrupt")
finally:
# clean up
serversocket.close()