forked from mhco0/PyCRP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
39 lines (25 loc) · 864 Bytes
/
client.py
File metadata and controls
39 lines (25 loc) · 864 Bytes
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
import dns
import sys
import socket
import library
def get_ip_from_dns(addrDomain = "crp.server.teste", dns_address = ('192.168.0.23', 8080)):
print("pegando ip do server")
data = "FIND " + addrDomain
udpSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
print('sending {!r}'.format(data))
udpSocket.sendto(str(data).encode(),dns_address)
data, _ = udpSocket.recvfrom(1024)
finally:
print('closing socket')
udpSocket.close()
return data.decode()
def main():
assert len(sys.argv) == 2
server_ip = get_ip_from_dns(dns_address=('172.20.4.159',8080))
print("server ip: ", server_ip)
server_adress = (server_ip, 9090)
library.Library(server_adress, sys.argv[1].lower())
library.mainloop()
if __name__ == "__main__":
main()