diff options
author | George Hazan <george.hazan@gmail.com> | 2024-06-13 18:03:26 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-06-13 18:03:26 +0300 |
commit | 3a4d5709c73fa0495138857f7bdb7a49e9e8a80a (patch) | |
tree | d29499ee8454a6c795475a18bf35cd7d09696885 | |
parent | 004f3d1f49c54bc62743a838161ac157ffc37e41 (diff) |
NETLIBBIND to be able to open UDP external ports
-rw-r--r-- | include/m_netlib.h | 1 | ||||
-rw-r--r-- | protocols/Discord/src/voice_client.cpp | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_byte.cpp | 1 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_file.cpp | 1 | ||||
-rw-r--r-- | src/mir_app/src/netlib_bind.cpp | 9 |
5 files changed, 8 insertions, 7 deletions
diff --git a/include/m_netlib.h b/include/m_netlib.h index 5157c118e5..36f48ed67f 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -267,6 +267,7 @@ typedef void (*NETLIBNEWCONNECTIONPROC)(HNETLIBCONN hNewConnection, uint32_t dwR struct NETLIBBIND
{
NETLIBNEWCONNECTIONPROC pfnNewConnection;
+ int iType; // SOCK_STREAM or 0 by default, SOCK_DGRAM, SOCK_RAW
// function to call when there's a new connection. Params are: the
// new connection, IP of remote machine (host byte order)
diff --git a/protocols/Discord/src/voice_client.cpp b/protocols/Discord/src/voice_client.cpp index 29b051799f..1e20a93723 100644 --- a/protocols/Discord/src/voice_client.cpp +++ b/protocols/Discord/src/voice_client.cpp @@ -132,8 +132,9 @@ void CDiscordVoiceCall::processStreams(const JSONNode &d) } NETLIBBIND nlb = {}; - nlb.pfnNewConnection = &GetConnection; + nlb.iType = SOCK_DGRAM; // UDP connection nlb.pExtra = this; + nlb.pfnNewConnection = &GetConnection; m_hBind = Netlib_BindPort(ppro->m_hGatewayNetlibUser, &nlb); if (m_hBind == nullptr) { ppro->debugLogA("UDP port binding failed, exiting"); diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index 7f15a27e42..1cb98c1da1 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -199,7 +199,6 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) NETLIBBIND nlb = {};
nlb.pfnNewConnection = JabberByteSendConnection;
nlb.pExtra = this;
- nlb.wPort = 0; // Use user-specified incoming port ranges, if available
jbt->hConn = Netlib_BindPort(m_hNetlibUser, &nlb);
if (jbt->hConn == nullptr) {
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 2694d49fa4..5366cbd813 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -395,7 +395,6 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) NETLIBBIND nlb = {};
nlb.pfnNewConnection = JabberFileServerConnection;
nlb.pExtra = this;
- nlb.wPort = 0; // Use user-specified incoming port ranges, if available
info.s = (HNETLIBCONN)Netlib_BindPort(m_hNetlibUser, &nlb);
if (info.s == nullptr) {
diff --git a/src/mir_app/src/netlib_bind.cpp b/src/mir_app/src/netlib_bind.cpp index c9cc9f3a0e..49cd9bf829 100644 --- a/src/mir_app/src/netlib_bind.cpp +++ b/src/mir_app/src/netlib_bind.cpp @@ -306,15 +306,16 @@ LBL_Error: /////////////////////////////////////////////////////////////////////////////////////////
-NetlibBoundPort::NetlibBoundPort(HNETLIBUSER _nlu, NETLIBBIND *nlb)
- : handleType(NLH_BOUNDPORT),
+NetlibBoundPort::NetlibBoundPort(HNETLIBUSER _nlu, NETLIBBIND *nlb) :
+ handleType(NLH_BOUNDPORT),
nlu(_nlu)
{
pfnNewConnection = nlb->pfnNewConnection;
pExtra = nlb->pExtra;
- s = socket(PF_INET, SOCK_STREAM, 0);
- s6 = socket(PF_INET6, SOCK_STREAM, 0);
+ int type = (nlb->iType) ? nlb->iType : SOCK_STREAM;
+ s = socket(PF_INET, type, 0);
+ s6 = socket(PF_INET6, type, 0);
}
void NetlibBoundPort::close()
|