summaryrefslogtreecommitdiff
path: root/toxcore/tox.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r--toxcore/tox.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index d352f672..4b9cff8e 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -815,12 +815,32 @@ uint32_t tox_do_interval(Tox *tox)
815 * return allocated instance of tox on success. 815 * return allocated instance of tox on success.
816 * return 0 if there are problems. 816 * return 0 if there are problems.
817 */ 817 */
818Tox *tox_new(uint8_t ipv6enabled) 818Tox *tox_new(Tox_Options *options)
819{ 819{
820 LOGGER_INIT(LOGGER_OUTPUT_FILE, LOGGER_LEVEL); 820 LOGGER_INIT(LOGGER_OUTPUT_FILE, LOGGER_LEVEL);
821 Messenger_Options options = {0}; 821 Messenger_Options m_options = {0};
822 options.ipv6enabled = ipv6enabled; 822
823 return new_messenger(&options); 823 if (options == NULL) {
824 m_options.ipv6enabled = TOX_ENABLE_IPV6_DEFAULT;
825 } else {
826 m_options.ipv6enabled = options->ipv6enabled;
827 m_options.udp_disabled = options->udp_disabled;
828 m_options.proxy_enabled = options->proxy_enabled;
829
830 if (m_options.proxy_enabled) {
831 ip_init(&m_options.proxy_info.ip_port.ip, m_options.ipv6enabled);
832
833 if (m_options.ipv6enabled)
834 m_options.proxy_info.ip_port.ip.family = AF_UNSPEC;
835
836 if (!addr_resolve_or_parse_ip(options->proxy_address, &m_options.proxy_info.ip_port.ip, NULL))
837 return NULL;
838
839 m_options.proxy_info.ip_port.port = htons(options->proxy_port);
840 }
841 }
842
843 return new_messenger(&m_options);
824} 844}
825 845
826/* Run this before closing shop. 846/* Run this before closing shop.