Removed useless parameter from new_TCP_server()

This commit is contained in:
irungentoo 2015-06-28 22:14:54 -04:00
parent b8362a6726
commit 50e0802a62
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
6 changed files with 11 additions and 13 deletions

View File

@ -32,7 +32,7 @@ START_TEST(test_basic)
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key); crypto_box_keypair(self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_public_key, self_secret_key, NULL); TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server");
ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports"); ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports");
@ -214,7 +214,7 @@ START_TEST(test_some)
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key); crypto_box_keypair(self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_public_key, self_secret_key, NULL); TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server");
ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports"); ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports");
@ -380,7 +380,7 @@ START_TEST(test_client)
uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(self_public_key, self_secret_key); crypto_box_keypair(self_public_key, self_secret_key);
TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_public_key, self_secret_key, NULL); TCP_Server *tcp_s = new_TCP_server(1, NUM_PORTS, ports, self_secret_key, NULL);
ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server"); ck_assert_msg(tcp_s != NULL, "Failed to create TCP relay server");
ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports"); ck_assert_msg(tcp_s->num_listening_socks == NUM_PORTS, "Failed to bind to all ports");

View File

@ -141,7 +141,7 @@ int main(int argc, char *argv[])
#ifdef TCP_RELAY_ENABLED #ifdef TCP_RELAY_ENABLED
#define NUM_PORTS 3 #define NUM_PORTS 3
uint16_t ports[NUM_PORTS] = {443, 3389, PORT}; uint16_t ports[NUM_PORTS] = {443, 3389, PORT};
TCP_Server *tcp_s = new_TCP_server(ipv6enabled, NUM_PORTS, ports, dht->self_public_key, dht->self_secret_key, onion); TCP_Server *tcp_s = new_TCP_server(ipv6enabled, NUM_PORTS, ports, dht->self_secret_key, onion);
if (tcp_s == NULL) { if (tcp_s == NULL) {
printf("TCP server failed to initialize.\n"); printf("TCP server failed to initialize.\n");

View File

@ -624,8 +624,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
tcp_server = new_TCP_server(enable_ipv6, tcp_relay_port_count, tcp_relay_ports, dht->self_public_key, tcp_server = new_TCP_server(enable_ipv6, tcp_relay_port_count, tcp_relay_ports, dht->self_secret_key, onion);
dht->self_secret_key, onion);
// tcp_relay_port_count != 0 at this point // tcp_relay_port_count != 0 at this point
free(tcp_relay_ports); free(tcp_relay_ports);

View File

@ -1813,8 +1813,7 @@ Messenger *new_messenger(Messenger_Options *options, unsigned int *error)
} }
if (options->tcp_server_port) { if (options->tcp_server_port) {
m->tcp_server = new_TCP_server(options->ipv6enabled, 1, &options->tcp_server_port, m->dht->self_public_key, m->tcp_server = new_TCP_server(options->ipv6enabled, 1, &options->tcp_server_port, m->dht->self_secret_key, m->onion);
m->dht->self_secret_key, m->onion);
if (m->tcp_server == NULL) { if (m->tcp_server == NULL) {
kill_friend_connections(m->fr_c); kill_friend_connections(m->fr_c);

View File

@ -939,8 +939,8 @@ static sock_t new_listening_TCP_socket(int family, uint16_t port)
return sock; return sock;
} }
TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uint16_t *ports, const uint8_t *public_key, TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uint16_t *ports, const uint8_t *secret_key,
const uint8_t *secret_key, Onion *onion) Onion *onion)
{ {
if (num_sockets == 0 || ports == NULL) if (num_sockets == 0 || ports == NULL)
return NULL; return NULL;
@ -1015,8 +1015,8 @@ TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uin
set_callback_handle_recv_1(onion, &handle_onion_recv_1, temp); set_callback_handle_recv_1(onion, &handle_onion_recv_1, temp);
} }
memcpy(temp->public_key, public_key, crypto_box_PUBLICKEYBYTES);
memcpy(temp->secret_key, secret_key, crypto_box_SECRETKEYBYTES); memcpy(temp->secret_key, secret_key, crypto_box_SECRETKEYBYTES);
crypto_scalarmult_curve25519_base(temp->public_key, temp->secret_key);
bs_list_init(&temp->accepted_key_list, crypto_box_PUBLICKEYBYTES, 8); bs_list_init(&temp->accepted_key_list, crypto_box_PUBLICKEYBYTES, 8);

View File

@ -143,8 +143,8 @@ typedef struct {
/* Create new TCP server instance. /* Create new TCP server instance.
*/ */
TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uint16_t *ports, const uint8_t *public_key, TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, const uint16_t *ports, const uint8_t *secret_key,
const uint8_t *secret_key, Onion *onion); Onion *onion);
/* Run the TCP_server /* Run the TCP_server
*/ */