summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/rect.py44
-rw-r--r--testing/toxic/dhtstatus.c4
2 files changed, 2 insertions, 46 deletions
diff --git a/testing/rect.py b/testing/rect.py
deleted file mode 100644
index 05f0abc4..00000000
--- a/testing/rect.py
+++ /dev/null
@@ -1,44 +0,0 @@
1#basic python UDP script
2#for testing only
3import socket
4import random
5
6UDP_IP = "127.0.0.1"
7UDP_PORT = 5004
8
9sock = socket.socket(socket.AF_INET, # Internet
10 socket.SOCK_DGRAM) # UDP
11sock.bind((UDP_IP, UDP_PORT))
12
13#our client_id
14client_id = str(''.join(random.choice("abcdefghijklmnopqrstuvwxyz") for x in range(32)))
15
16print client_id
17a = 1;
18#send ping request to our DHT on localhost.
19sock.sendto("0012345678".decode("hex") + client_id, ('127.0.0.1', 33445))
20
21#print all packets received and respond to ping requests properly
22while True:
23 data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
24 print "received message:", data.encode('hex'), " From:", addr
25 #if we receive a ping request.
26 print data[0].encode('hex')
27 if data[0] == "00".decode('hex'):
28 print "Sending ping resp"
29 sock.sendto("01".decode('hex') + data[1:5] + client_id, addr)
30
31 #if we receive a get_nodes request.
32 if data[0] == "02".decode('hex'):
33 print "Sending getn resp"
34 #send send nodes packet with a couple 127.0.0.1 ips and ports.
35 #127.0.0.1:5000, 127.0.0.1:5001, 127.0.0.1:5002
36 sock.sendto("03".decode('hex') + data[1:5] + client_id + ("HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH" + "7F00000113880000".decode('hex') + "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH" + "7F00000113890000".decode('hex') + "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH" + "7F000001138A0000".decode('hex')), addr)
37
38 if data[0] == "10".decode('hex'):
39 print "Sending handshake resp"
40 sock.sendto("10".decode('hex') + data[1:5] + client_id[:4], addr)
41 if data[0] == "11".decode('hex'):
42 print "Sending SYNC resp"
43 a+=1
44 sock.sendto("11".decode('hex') + chr(a) + data[1:9], addr)
diff --git a/testing/toxic/dhtstatus.c b/testing/toxic/dhtstatus.c
index 66268900..e026a173 100644
--- a/testing/toxic/dhtstatus.c
+++ b/testing/toxic/dhtstatus.c
@@ -43,13 +43,13 @@ static void dhtstatus_onDraw(ToxWindow *self)
43 uint32_t i, j; 43 uint32_t i, j;
44 ipbuf ipbuf; 44 ipbuf ipbuf;
45 wprintw(self->window,"\n%llu ______________________ CLOSE LIST ________________________ ___ IP ADDR ___ _PRT_ LST PNG ____ SELF ____ _PRT_ LST\n\n", now); 45 wprintw(self->window,"\n%llu ______________________ CLOSE LIST ________________________ ___ IP ADDR ___ _PRT_ LST PNG ____ SELF ____ _PRT_ LST\n\n", now);
46 for(i = 0; i < CLIENT_ID_SIZE; i++) { 46 for(i = 0; i < 32; i++) { /*Number of nodes in closelist*/
47 Client_data * client = close_clientlist + i; 47 Client_data * client = close_clientlist + i;
48 if (i == num_selected) wattron(self->window, COLOR_PAIR(3)); 48 if (i == num_selected) wattron(self->window, COLOR_PAIR(3));
49 wprintw(self->window,"[%02i] ", i); 49 wprintw(self->window,"[%02i] ", i);
50 uint16_t port = ntohs(client->ip_port.port); 50 uint16_t port = ntohs(client->ip_port.port);
51 if(port) { 51 if(port) {
52 for(j = 0; j < 32; j++) 52 for(j = 0; j < CLIENT_ID_SIZE; j++)
53 wprintw(self->window, "%02hhx", client->client_id[j]); 53 wprintw(self->window, "%02hhx", client->client_id[j]);
54 54
55 printip(ipbuf, client->ip_port.ip); 55 printip(ipbuf, client->ip_port.ip);