Commit 5a381fad by Michael Pastushkov

working version!! udp

parent 40b88a5c
...@@ -147,11 +147,11 @@ int encode(unsigned char* buf, int len) { ...@@ -147,11 +147,11 @@ int encode(unsigned char* buf, int len) {
update_cipher(); update_cipher();
for (i=0; i<len; i++) for (i=0; i<len; i++)
buf[i] = cipher[buf[i]]; buf[i] = cipher[buf[i]];
// if (options.log) { if (options.log) {
// printf("\r%-50s", " "); printf("\r%-50s", " ");
// printf("\r%s encode %i bytes ", get_current_timestamp(), len); printf("\r%s encode %i bytes ", get_current_timestamp(), len);
// fflush(stdout); fflush(stdout);
// } }
return 0; return 0;
} }
...@@ -168,11 +168,11 @@ int decode(unsigned char* buf, int len) { ...@@ -168,11 +168,11 @@ int decode(unsigned char* buf, int len) {
} }
} }
} }
// if (options.log) { if (options.log) {
// printf("\r%-50s", " "); printf("\r%-50s", " ");
// printf("\r%s decode %i bytes ", get_current_timestamp(), len); printf("\r%s decode %i bytes ", get_current_timestamp(), len);
// fflush(stdout); fflush(stdout);
// } }
return 0; return 0;
} }
...@@ -369,17 +369,18 @@ int use(void) ...@@ -369,17 +369,18 @@ int use(void)
count_recv = recvfrom(rc.client_socket, buffer, sizeof(buffer), MSG_PEEK, (struct sockaddr *)&client_addr, &addr_len); count_recv = recvfrom(rc.client_socket, buffer, sizeof(buffer), MSG_PEEK, (struct sockaddr *)&client_addr, &addr_len);
if (count_recv < 0) { if (count_recv < 0) {
perror("use() - PEEK"); perror("use() - PEEK");
return 1;
} }
if (rc.my_addr.sin_port == 0) { if (rc.my_addr.sin_port == 0) {
rc.my_addr.sin_addr.s_addr = client_addr.sin_addr.s_addr; rc.my_addr.sin_addr.s_addr = client_addr.sin_addr.s_addr;
rc.my_addr.sin_port = client_addr.sin_port; rc.my_addr.sin_port = client_addr.sin_port;
if (options.log > 1) if (options.log)
printf("my address %s:%d\tpid: %d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port), getpid()); printf("my address %s:%d\tpid: %d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port), getpid());
} else { } else {
if (!compare_clients(rc.my_addr, client_addr)) { if (!compare_clients(rc.my_addr, client_addr)) {
if (options.log > 1) if (options.log > 2)
printf("ignore %s:%d\tpid: %d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port), getpid()); printf("ignore %s:%d\tpid: %d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port), getpid());
continue; // not our business continue;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment