diff options
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 5b7a7f61..359708ee 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1807,6 +1807,27 @@ Messenger *new_messenger(Messenger_Options *options, unsigned int *error) | |||
1807 | return NULL; | 1807 | return NULL; |
1808 | } | 1808 | } |
1809 | 1809 | ||
1810 | if (options->tcp_server_port) { | ||
1811 | m->tcp_server = new_TCP_server(options->ipv6enabled, 1, &options->tcp_server_port, m->dht->self_public_key, | ||
1812 | m->dht->self_secret_key, m->onion); | ||
1813 | |||
1814 | if (m->tcp_server == NULL) { | ||
1815 | kill_friend_connections(m->fr_c); | ||
1816 | kill_onion(m->onion); | ||
1817 | kill_onion_announce(m->onion_a); | ||
1818 | kill_onion_client(m->onion_c); | ||
1819 | kill_DHT(m->dht); | ||
1820 | kill_net_crypto(m->net_crypto); | ||
1821 | kill_networking(m->net); | ||
1822 | free(m); | ||
1823 | |||
1824 | if (error) | ||
1825 | *error = MESSENGER_ERROR_TCP_SERVER; | ||
1826 | |||
1827 | return NULL; | ||
1828 | } | ||
1829 | } | ||
1830 | |||
1810 | m->options = *options; | 1831 | m->options = *options; |
1811 | friendreq_init(&(m->fr), m->fr_c); | 1832 | friendreq_init(&(m->fr), m->fr_c); |
1812 | set_nospam(&(m->fr), random_int()); | 1833 | set_nospam(&(m->fr), random_int()); |
@@ -1826,6 +1847,10 @@ void kill_messenger(Messenger *m) | |||
1826 | 1847 | ||
1827 | uint32_t i; | 1848 | uint32_t i; |
1828 | 1849 | ||
1850 | if (m->tcp_server) { | ||
1851 | kill_TCP_server(m->tcp_server); | ||
1852 | } | ||
1853 | |||
1829 | kill_friend_connections(m->fr_c); | 1854 | kill_friend_connections(m->fr_c); |
1830 | kill_onion(m->onion); | 1855 | kill_onion(m->onion); |
1831 | kill_onion_announce(m->onion_a); | 1856 | kill_onion_announce(m->onion_a); |
@@ -2270,6 +2295,10 @@ void do_messenger(Messenger *m) | |||
2270 | do_DHT(m->dht); | 2295 | do_DHT(m->dht); |
2271 | } | 2296 | } |
2272 | 2297 | ||
2298 | if (m->tcp_server) { | ||
2299 | do_TCP_server(m->tcp_server); | ||
2300 | } | ||
2301 | |||
2273 | do_net_crypto(m->net_crypto); | 2302 | do_net_crypto(m->net_crypto); |
2274 | do_onion_client(m->onion_c); | 2303 | do_onion_client(m->onion_c); |
2275 | do_friend_connections(m->fr_c); | 2304 | do_friend_connections(m->fr_c); |