From 215c3b0f8ba4a6b754936b0ebcbd5cb9a30c7e46 Mon Sep 17 00:00:00 2001 From: aunsane Date: Mon, 18 Dec 2017 15:17:26 +0300 Subject: Tox: added 2 new options - UDP hole-punching - local network peer discovery --- protocols/Tox/src/resource.h | 3 ++- protocols/Tox/src/tox_core.cpp | 3 +++ protocols/Tox/src/tox_options.cpp | 13 ++++++++++++- protocols/Tox/src/tox_options.h | 4 ++++ 4 files changed, 21 insertions(+), 2 deletions(-) (limited to 'protocols/Tox/src') diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h index a036587e91..b5f13e9d32 100644 --- a/protocols/Tox/src/resource.h +++ b/protocols/Tox/src/resource.h @@ -27,8 +27,9 @@ #define IDC_ENABLE_IPV6 1008 #define IDC_PROFILE_EXPORT 1009 #define IDC_DNS_ID 1010 +#define IDC_ENABLE_HOLEPUNCHING 1010 #define IDC_PROFILE_NEW 1011 -#define IDC_SAVEPERMANENT 1012 +#define IDC_ENABLE_LOCALDISCOVERY 1012 #define IDC_PROFILE_IMPORT 1013 #define IDC_SAVEPERMANENTLY 1014 #define IDC_NODESLIST 1015 diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index 735bcd0f3f..de977b090f 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -10,7 +10,10 @@ Tox_Options* CToxProto::GetToxOptions() } options->udp_enabled = getBool("EnableUDP", 1); + if (options->udp_enabled && getBool("EnableUDPHolePunching", 1)) + options->hole_punching_enabled = true; options->ipv6_enabled = getBool("EnableIPv6", 0); + options->local_discovery_enabled = getBool("EnableLocalDiscovery", 0); if (m_hNetlibUser != nullptr) { NETLIBUSERSETTINGS nlus = { sizeof(nlus) }; diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index bf4aeea940..cdd12f7089 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -6,7 +6,8 @@ CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog) m_profileCreate(this, IDC_PROFILE_NEW), m_profileImport(this, IDC_PROFILE_IMPORT), m_profileExport(this, IDC_PROFILE_EXPORT), m_nickname(this, IDC_NAME), m_password(this, IDC_PASSWORD), m_group(this, IDC_GROUP), - m_enableUdp(this, IDC_ENABLE_UDP), m_enableIPv6(this, IDC_ENABLE_IPV6), + m_enableUdp(this, IDC_ENABLE_UDP), m_enableUdpHolePunching(this, IDC_ENABLE_HOLEPUNCHING), + m_enableIPv6(this, IDC_ENABLE_IPV6), m_enableLocalDiscovery(this, IDC_ENABLE_LOCALDISCOVERY), m_maxConnectRetries(this, IDC_MAXCONNECTRETRIES), m_maxConnectRetriesSpin(this, IDC_MAXCONNECTRETRIESSPIN), m_maxReconnectRetries(this, IDC_MAXRECONNECTRETRIES), m_maxReconnectRetriesSpin(this, IDC_MAXRECONNECTRETRIESSPIN) { @@ -15,13 +16,18 @@ CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog) CreateLink(m_password, "Password", L""); CreateLink(m_group, TOX_SETTINGS_GROUP, L"Tox"); CreateLink(m_enableUdp, "EnableUDP", DBVT_BYTE, TRUE); + CreateLink(m_enableUdpHolePunching, "EnableUDPHolePunching", DBVT_BYTE, TRUE); CreateLink(m_enableIPv6, "EnableIPv6", DBVT_BYTE, FALSE); + CreateLink(m_enableLocalDiscovery, "EnableLocalDiscovery", DBVT_BYTE, FALSE); if (idDialog == IDD_OPTIONS_MAIN) { CreateLink(m_maxConnectRetries, "MaxConnectRetries", DBVT_BYTE, TOX_MAX_CONNECT_RETRIES); CreateLink(m_maxReconnectRetries, "MaxReconnectRetries", DBVT_BYTE, TOX_MAX_RECONNECT_RETRIES); } + m_enableUdp.OnChange = Callback(this, &CToxOptionsMain::EnableUdp_OnClick); + m_enableUdpHolePunching.Enable(m_enableUdp.GetState()); + m_toxAddressCopy.OnClick = Callback(this, &CToxOptionsMain::ToxAddressCopy_OnClick); m_profileCreate.OnClick = Callback(this, &CToxOptionsMain::ProfileCreate_OnClick); m_profileImport.OnClick = Callback(this, &CToxOptionsMain::ProfileImport_OnClick); @@ -54,6 +60,11 @@ void CToxOptionsMain::OnInitDialog() m_maxReconnectRetriesSpin.SetPosition(m_proto->getByte("MaxReconnectRetries", TOX_MAX_RECONNECT_RETRIES)); } +void CToxOptionsMain::EnableUdp_OnClick(CCtrlBase*) +{ + m_enableUdpHolePunching.Enable(m_enableUdp.GetState()); +} + void CToxOptionsMain::ToxAddressCopy_OnClick(CCtrlButton*) { char *toxAddress = m_toxAddress.GetTextA(); diff --git a/protocols/Tox/src/tox_options.h b/protocols/Tox/src/tox_options.h index f134e3d554..011aaf6b76 100644 --- a/protocols/Tox/src/tox_options.h +++ b/protocols/Tox/src/tox_options.h @@ -17,7 +17,9 @@ private: CCtrlEdit m_group; CCtrlCheck m_enableUdp; + CCtrlCheck m_enableUdpHolePunching; CCtrlCheck m_enableIPv6; + CCtrlCheck m_enableLocalDiscovery; CCtrlEdit m_maxConnectRetries; CCtrlSpin m_maxConnectRetriesSpin; @@ -27,6 +29,8 @@ private: protected: void OnInitDialog(); + void EnableUdp_OnClick(CCtrlBase*); + void ToxAddressCopy_OnClick(CCtrlButton*); void ProfileCreate_OnClick(CCtrlButton*); void ProfileImport_OnClick(CCtrlButton*); -- cgit v1.2.3