diff --git a/NetworkSocket.cpp b/NetworkSocket.cpp index 4071b7c..3f7f02e 100644 --- a/NetworkSocket.cpp +++ b/NetworkSocket.cpp @@ -292,7 +292,7 @@ void NetworkSocketTCPObfuscated::Receive(NetworkPacket *packet){ } if(packetLen>packet->length){ - LOGW("packet too big to fit into buffer (%u vs %u)", packetLen, packet->length); + LOGW("packet too big to fit into buffer (%u vs %u)", (unsigned int)packetLen, (unsigned int)packet->length); packet->length=0; return; } diff --git a/NetworkSocket.h b/NetworkSocket.h index e66015f..6c89d74 100644 --- a/NetworkSocket.h +++ b/NetworkSocket.h @@ -28,6 +28,7 @@ namespace tgvoip { virtual std::string ToString()=0; bool operator==(const NetworkAddress& other); bool operator!=(const NetworkAddress& other); + virtual ~NetworkAddress()=default; }; class IPv4Address : public NetworkAddress{ diff --git a/logging.h b/logging.h index b777756..cbe811b 100644 --- a/logging.h +++ b/logging.h @@ -16,10 +16,6 @@ void tgvoip_log_file_printf(char level, const char* msg, ...); void tgvoip_log_file_write_header(); -#if !defined(snprintf) && defined(_WIN32) && defined(__cplusplus_winrt) -#define snprintf _snprintf -#endif - #if defined(__ANDROID__) #include @@ -48,6 +44,10 @@ void tgvoip_log_file_write_header(); #include #include +#if !defined(snprintf) && defined(_WIN32) && defined(__cplusplus_winrt) +#define snprintf _snprintf +#endif + #define _TGVOIP_W32_LOG_PRINT(verb, msg, ...){ char __log_buf[1024]; snprintf(__log_buf, 1024, "%c/tgvoip: " msg "\n", verb, ##__VA_ARGS__); OutputDebugStringA(__log_buf); tgvoip_log_file_printf((char)verb, msg, __VA_ARGS__);} #define LOGV(msg, ...) _TGVOIP_W32_LOG_PRINT('V', msg, ##__VA_ARGS__) diff --git a/os/windows/CXWrapper.cpp b/os/windows/CXWrapper.cpp index 424623b..5f71f3b 100644 --- a/os/windows/CXWrapper.cpp +++ b/os/windows/CXWrapper.cpp @@ -149,15 +149,27 @@ void VoIPControllerWrapper::SetConfig(double initTimeout, double recvTimeout, Da config.enableAEC=enableAEC; config.enableAGC=enableAGC; config.enableNS=enableNS; - if(logFilePath!=nullptr){ + if(logFilePath!=nullptr&&!logFilePath->IsEmpty()){ WideCharToMultiByte(CP_UTF8, 0, logFilePath->Data(), -1, config.logFilePath, sizeof(config.logFilePath), NULL, NULL); } - if(statsDumpFilePath!=nullptr){ + if(statsDumpFilePath!=nullptr&&!statsDumpFilePath->IsEmpty()){ WideCharToMultiByte(CP_UTF8, 0, statsDumpFilePath->Data(), -1, config.statsDumpFilePath, sizeof(config.statsDumpFilePath), NULL, NULL); } controller->SetConfig(&config); } +void VoIPControllerWrapper::SetProxy(ProxyProtocol protocol, Platform::String^ address, uint16_t port, Platform::String^ username, Platform::String^ password){ + char _address[2000]; + char _username[256]; + char _password[256]; + + WideCharToMultiByte(CP_UTF8, 0, address->Data(), -1, _address, sizeof(_address), NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, username->Data(), -1, _username, sizeof(_username), NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, password->Data(), -1, _password, sizeof(_password), NULL, NULL); + + controller->SetProxy((int)protocol, _address, port, _username, _password); +} + void VoIPControllerWrapper::UpdateServerConfig(Platform::String^ json){ JsonObject^ jconfig=JsonValue::Parse(json)->GetObject(); std::map config; diff --git a/os/windows/CXWrapper.h b/os/windows/CXWrapper.h index 4d36c8a..d00d5fb 100644 --- a/os/windows/CXWrapper.h +++ b/os/windows/CXWrapper.h @@ -53,6 +53,11 @@ namespace libtgvoip{ Always }; + public enum class ProxyProtocol{ + None=0, + SOCKS5 + }; + public interface class IStateCallback{ void OnCallStateChanged(CallState newState); }; @@ -69,6 +74,7 @@ namespace libtgvoip{ void SetMicMute(bool mute); void SetEncryptionKey(const Platform::Array^ key, bool isOutgoing); void SetConfig(double initTimeout, double recvTimeout, DataSavingMode dataSavingMode, bool enableAEC, bool enableNS, bool enableAGC, Platform::String^ logFilePath, Platform::String^ statsDumpFilePath); + void SetProxy(ProxyProtocol protocol, Platform::String^ address, uint16_t port, Platform::String^ username, Platform::String^ password); Platform::String^ GetDebugString(); Platform::String^ GetDebugLog(); Error GetLastError();