mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-12-27 02:29:52 +03:00
Improve NAT-T hint string handling
This commit is contained in:
parent
f6edb5e165
commit
68dc4e23d8
@ -6649,6 +6649,7 @@ void CmEditAccountDlgUpdate(HWND hWnd, CM_ACCOUNT *a)
|
||||
// Host name
|
||||
GetTxtA(hWnd, E_HOSTNAME, a->ClientOption->Hostname, sizeof(a->ClientOption->Hostname));
|
||||
Trim(a->ClientOption->Hostname);
|
||||
a->ClientOption->HintStr[0] = 0;
|
||||
|
||||
if (InStr(a->ClientOption->Hostname, "/tcp"))
|
||||
{
|
||||
@ -7091,10 +7092,17 @@ void CmEditAccountDlgInit(HWND hWnd, CM_ACCOUNT *a)
|
||||
SetText(hWnd, E_ACCOUNT_NAME, a->ClientOption->AccountName);
|
||||
|
||||
// Host name
|
||||
SetTextA(hWnd, E_HOSTNAME, a->ClientOption->Hostname);
|
||||
StrCpy(a->old_server_name, sizeof(a->old_server_name), a->ClientOption->Hostname);
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), a->ClientOption->Hostname);
|
||||
if (IsEmptyStr(a->ClientOption->HintStr) == false)
|
||||
{
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), a->ClientOption->HintStr);
|
||||
}
|
||||
SetTextA(hWnd, E_HOSTNAME, hostname);
|
||||
StrCpy(a->old_server_name, sizeof(a->old_server_name), hostname);
|
||||
|
||||
if (InStr(a->ClientOption->Hostname, "/tcp"))
|
||||
if (InStr(hostname, "/tcp"))
|
||||
{
|
||||
Check(hWnd, R_DISABLE_NATT, true);
|
||||
}
|
||||
|
@ -4315,6 +4315,13 @@ void InRpcClientOption(CLIENT_OPTION *c, PACK *p)
|
||||
|
||||
PackGetUniStr(p, "AccountName", c->AccountName, sizeof(c->AccountName));
|
||||
PackGetStr(p, "Hostname", c->Hostname, sizeof(c->Hostname));
|
||||
// Extract hint string from hostname
|
||||
UINT i = SearchStrEx(c->Hostname, "/", 0, false);
|
||||
if (i != INFINITE)
|
||||
{
|
||||
StrCpy(c->HintStr, sizeof(c->HintStr), c->Hostname + i + 1);
|
||||
c->Hostname[i] = 0;
|
||||
}
|
||||
c->Port = PackGetInt(p, "Port");
|
||||
c->PortUDP = PackGetInt(p, "PortUDP");
|
||||
c->ProxyType = PackGetInt(p, "ProxyType");
|
||||
@ -4352,7 +4359,20 @@ void OutRpcClientOption(PACK *p, CLIENT_OPTION *c)
|
||||
}
|
||||
|
||||
PackAddUniStr(p, "AccountName", c->AccountName);
|
||||
PackAddStr(p, "Hostname", c->Hostname);
|
||||
// Append hint string to hostname
|
||||
if (IsEmptyStr(c->HintStr))
|
||||
{
|
||||
// No hint
|
||||
PackAddStr(p, "Hostname", c->Hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), c->Hostname);
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), c->HintStr);
|
||||
PackAddStr(p, "Hostname", hostname);
|
||||
}
|
||||
PackAddStr(p, "ProxyName", c->ProxyName);
|
||||
PackAddStr(p, "ProxyUsername", c->ProxyUsername);
|
||||
PackAddStr(p, "ProxyPassword", c->ProxyPassword);
|
||||
@ -7030,6 +7050,12 @@ bool CtEnumAccount(CLIENT *c, RPC_CLIENT_ENUM_ACCOUNT *e)
|
||||
|
||||
// Server name
|
||||
StrCpy(item->ServerName, sizeof(item->ServerName), a->ClientOption->Hostname);
|
||||
// Append hint string to hostname
|
||||
if (IsEmptyStr(a->ClientOption->HintStr) == false)
|
||||
{
|
||||
StrCat(item->ServerName, sizeof(item->ServerName), "/");
|
||||
StrCat(item->ServerName, sizeof(item->ServerName), a->ClientOption->HintStr);
|
||||
}
|
||||
|
||||
// Proxy type
|
||||
item->ProxyType = a->ClientOption->ProxyType;
|
||||
@ -9222,6 +9248,13 @@ CLIENT_OPTION *CiLoadClientOption(FOLDER *f)
|
||||
|
||||
CfgGetUniStr(f, "AccountName", o->AccountName, sizeof(o->AccountName));
|
||||
CfgGetStr(f, "Hostname", o->Hostname, sizeof(o->Hostname));
|
||||
// Extract hint string from hostname
|
||||
UINT i = SearchStrEx(o->Hostname, "/", 0, false);
|
||||
if (i != INFINITE)
|
||||
{
|
||||
StrCpy(o->HintStr, sizeof(o->HintStr), o->Hostname + i + 1);
|
||||
o->Hostname[i] = 0;
|
||||
}
|
||||
o->Port = CfgGetInt(f, "Port");
|
||||
o->PortUDP = CfgGetInt(f, "PortUDP");
|
||||
o->ProxyType = CfgGetInt(f, "ProxyType");
|
||||
@ -9764,7 +9797,20 @@ void CiWriteClientOption(FOLDER *f, CLIENT_OPTION *o)
|
||||
}
|
||||
|
||||
CfgAddUniStr(f, "AccountName", o->AccountName);
|
||||
CfgAddStr(f, "Hostname", o->Hostname);
|
||||
// Append hint string to hostname
|
||||
if (IsEmptyStr(o->HintStr))
|
||||
{
|
||||
// No hint
|
||||
CfgAddStr(f, "Hostname", o->Hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), o->Hostname);
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), o->HintStr);
|
||||
CfgAddStr(f, "Hostname", hostname);
|
||||
}
|
||||
CfgAddInt(f, "Port", o->Port);
|
||||
CfgAddInt(f, "PortUDP", o->PortUDP);
|
||||
CfgAddInt(f, "ProxyType", o->ProxyType);
|
||||
|
@ -4333,6 +4333,7 @@ UINT PcAccountSet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
// Success
|
||||
t.ClientOption->Port = port;
|
||||
StrCpy(t.ClientOption->Hostname, sizeof(t.ClientOption->Hostname), host);
|
||||
t.ClientOption->HintStr[0] = 0;
|
||||
StrCpy(t.ClientOption->HubName, sizeof(t.ClientOption->HubName), GetParamStr(o, "HUB"));
|
||||
|
||||
Zero(&c, sizeof(c));
|
||||
@ -4400,7 +4401,18 @@ UINT PcAccountGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
CtInsert(ct, _UU("CMD_ACCOUNT_COLUMN_NAME"), t.ClientOption->AccountName);
|
||||
|
||||
// Host name of the destination VPN Server
|
||||
StrToUni(tmp, sizeof(tmp), t.ClientOption->Hostname);
|
||||
if (IsEmptyStr(t.ClientOption->HintStr))
|
||||
{
|
||||
StrToUni(tmp, sizeof(tmp), t.ClientOption->Hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), t.ClientOption->Hostname);
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), t.ClientOption->HintStr);
|
||||
StrToUni(tmp, sizeof(tmp), hostname);
|
||||
}
|
||||
CtInsert(ct, _UU("CMD_ACCOUNT_COLUMN_HOSTNAME"), tmp);
|
||||
|
||||
// The port number to connect to VPN Server
|
||||
@ -13117,6 +13129,7 @@ UINT PsCascadeSet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
|
||||
t.ClientOption->Port = port;
|
||||
StrCpy(t.ClientOption->Hostname, sizeof(t.ClientOption->Hostname), host);
|
||||
t.ClientOption->HintStr[0] = 0;
|
||||
StrCpy(t.ClientOption->HubName, sizeof(t.ClientOption->HubName), GetParamStr(o, "HUB"));
|
||||
|
||||
Free(host);
|
||||
@ -13223,7 +13236,18 @@ UINT PsCascadeGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
|
||||
CtInsert(ct, _UU("CMD_ACCOUNT_COLUMN_NAME"), t.ClientOption->AccountName);
|
||||
|
||||
// Host name of the destination VPN Server
|
||||
StrToUni(tmp, sizeof(tmp), t.ClientOption->Hostname);
|
||||
if (IsEmptyStr(t.ClientOption->HintStr))
|
||||
{
|
||||
StrToUni(tmp, sizeof(tmp), t.ClientOption->Hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), t.ClientOption->Hostname);
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), t.ClientOption->HintStr);
|
||||
StrToUni(tmp, sizeof(tmp), hostname);
|
||||
}
|
||||
CtInsert(ct, _UU("CMD_ACCOUNT_COLUMN_HOSTNAME"), tmp);
|
||||
|
||||
// The port number to connect to VPN Server
|
||||
@ -24273,6 +24297,12 @@ UINT PsConnect(CONSOLE *c, char *host, UINT port, char *hub, char *adminhub, wch
|
||||
Zero(&o, sizeof(o));
|
||||
UniStrCpy(o.AccountName, sizeof(o.AccountName), L"VPNCMD");
|
||||
StrCpy(o.Hostname, sizeof(o.Hostname), host);
|
||||
UINT i = SearchStrEx(o.Hostname, "/", 0, false);
|
||||
if (i != INFINITE)
|
||||
{
|
||||
StrCpy(o.HintStr, sizeof(o.HintStr), o.Hostname + i + 1);
|
||||
o.Hostname[i] = 0;
|
||||
}
|
||||
o.Port = port;
|
||||
o.ProxyType = PROXY_DIRECT;
|
||||
|
||||
@ -24331,7 +24361,7 @@ UINT PsConnect(CONSOLE *c, char *host, UINT port, char *hub, char *adminhub, wch
|
||||
PS *ps;
|
||||
|
||||
// Success
|
||||
ps = NewPs(c, rpc, host, port, hub, adminhub, cmdline);
|
||||
ps = NewPs(c, rpc, o.Hostname, port, hub, adminhub, cmdline);
|
||||
PsMain(ps);
|
||||
retcode = ps->LastError;
|
||||
FreePs(ps);
|
||||
|
@ -105,6 +105,7 @@ struct CLIENT_OPTION
|
||||
char pad12[3];
|
||||
UCHAR HostUniqueKey[SHA1_SIZE]; // Host unique key
|
||||
char CustomHttpHeader[HTTP_CUSTOM_HEADER_MAX_SIZE]; // Custom HTTP proxy header
|
||||
char HintStr[MAX_HOST_NAME_LEN + 1]; // Hint string for NAT-T
|
||||
};
|
||||
|
||||
// Client authentication data
|
||||
|
@ -6306,9 +6306,9 @@ SOCK *ClientConnectGetSocket(CONNECTION *c, bool additional_connect)
|
||||
{
|
||||
// If additional_connect == false, enable trying to NAT-T connection
|
||||
// If additional_connect == true, follow the IsRUDPSession setting in this session
|
||||
sock = TcpIpConnectEx(hostname, c->ServerPort,
|
||||
sock = TcpIpConnectEx2(hostname, c->ServerPort,
|
||||
(bool *)cancel_flag, c->hWndForUI, &nat_t_err, (additional_connect ? (!sess->IsRUDPSession) : false),
|
||||
true, &resolved_ip);
|
||||
true, o->HintStr, &resolved_ip);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -6444,23 +6444,31 @@ UINT ProxyCodeToCedar(UINT code)
|
||||
|
||||
// TCP connection function
|
||||
SOCK *TcpConnectEx3(char *hostname, UINT port, UINT timeout, bool *cancel_flag, void *hWnd, bool no_nat_t, UINT *nat_t_error_code, bool try_start_ssl, IP *ret_ip)
|
||||
{
|
||||
return TcpConnectEx4(hostname, port, timeout, cancel_flag, hWnd, no_nat_t, nat_t_error_code, try_start_ssl, NULL, ret_ip);
|
||||
}
|
||||
SOCK *TcpConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, void *hWnd, bool no_nat_t, UINT *nat_t_error_code, bool try_start_ssl, char *hint_str, IP *ret_ip)
|
||||
{
|
||||
#ifdef OS_WIN32
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
#endif // OS_WIN32
|
||||
return ConnectEx4(hostname, port, timeout, cancel_flag, (no_nat_t ? NULL : VPN_RUDP_SVC_NAME), nat_t_error_code, try_start_ssl, true, ret_ip);
|
||||
return ConnectEx5(hostname, port, timeout, cancel_flag, (no_nat_t ? NULL : VPN_RUDP_SVC_NAME), nat_t_error_code, try_start_ssl, true, hint_str, ret_ip);
|
||||
#ifdef OS_WIN32
|
||||
}
|
||||
else
|
||||
{
|
||||
return WinConnectEx3((HWND)hWnd, hostname, port, timeout, 0, NULL, NULL, nat_t_error_code, (no_nat_t ? NULL : VPN_RUDP_SVC_NAME), try_start_ssl);
|
||||
return WinConnectEx4((HWND)hWnd, hostname, port, timeout, 0, NULL, NULL, nat_t_error_code, (no_nat_t ? NULL : VPN_RUDP_SVC_NAME), try_start_ssl, hint_str);
|
||||
}
|
||||
#endif // OS_WIN32
|
||||
}
|
||||
|
||||
// Connect with TCP/IP
|
||||
SOCK *TcpIpConnectEx(char *hostname, UINT port, bool *cancel_flag, void *hWnd, UINT *nat_t_error_code, bool no_nat_t, bool try_start_ssl, IP *ret_ip)
|
||||
{
|
||||
return TcpIpConnectEx2(hostname, port, cancel_flag, hWnd, nat_t_error_code, no_nat_t, try_start_ssl, NULL, ret_ip);
|
||||
}
|
||||
SOCK *TcpIpConnectEx2(char *hostname, UINT port, bool *cancel_flag, void *hWnd, UINT *nat_t_error_code, bool no_nat_t, bool try_start_ssl, char *hint_str, IP *ret_ip)
|
||||
{
|
||||
SOCK *s = NULL;
|
||||
UINT dummy_int = 0;
|
||||
@ -6475,7 +6483,7 @@ SOCK *TcpIpConnectEx(char *hostname, UINT port, bool *cancel_flag, void *hWnd, U
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = TcpConnectEx3(hostname, port, 0, cancel_flag, hWnd, no_nat_t, nat_t_error_code, try_start_ssl, ret_ip);
|
||||
s = TcpConnectEx4(hostname, port, 0, cancel_flag, hWnd, no_nat_t, nat_t_error_code, try_start_ssl, hint_str, ret_ip);
|
||||
if (s == NULL)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -114,6 +114,7 @@ bool ServerAccept(CONNECTION *c);
|
||||
bool ClientConnect(CONNECTION *c);
|
||||
SOCK *ClientConnectToServer(CONNECTION *c);
|
||||
SOCK *TcpIpConnectEx(char *hostname, UINT port, bool *cancel_flag, void *hWnd, UINT *nat_t_error_code, bool no_nat_t, bool try_start_ssl, IP *ret_ip);
|
||||
SOCK *TcpIpConnectEx2(char *hostname, UINT port, bool *cancel_flag, void *hWnd, UINT *nat_t_error_code, bool no_nat_t, bool try_start_ssl, char *hint_str, IP *ret_ip);
|
||||
bool ClientUploadSignature(SOCK *s);
|
||||
bool ClientDownloadHello(CONNECTION *c, SOCK *s);
|
||||
bool ServerDownloadSignature(CONNECTION *c, char **error_detail_str);
|
||||
@ -121,6 +122,7 @@ bool ServerUploadHello(CONNECTION *c);
|
||||
bool ClientUploadAuth(CONNECTION *c);
|
||||
SOCK *ClientConnectGetSocket(CONNECTION *c, bool additional_connect);
|
||||
SOCK *TcpConnectEx3(char *hostname, UINT port, UINT timeout, bool *cancel_flag, void *hWnd, bool no_nat_t, UINT *nat_t_error_code, bool try_start_ssl, IP *ret_ip);
|
||||
SOCK *TcpConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, void *hWnd, bool no_nat_t, UINT *nat_t_error_code, bool try_start_ssl, char *hint_str, IP *ret_ip);
|
||||
|
||||
UINT ProxyCodeToCedar(UINT code);
|
||||
|
||||
|
@ -19360,7 +19360,14 @@ void SmEditSettingDlgInit(HWND hWnd, SM_EDIT_SETTING *p)
|
||||
SetText(hWnd, E_ACCOUNT_NAME, s->Title);
|
||||
|
||||
// Host name
|
||||
SetTextA(hWnd, E_HOSTNAME, s->ClientOption.Hostname);
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), s->ClientOption.Hostname);
|
||||
if (IsEmptyStr(s->ClientOption.HintStr) == false)
|
||||
{
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), s->ClientOption.HintStr);
|
||||
}
|
||||
SetTextA(hWnd, E_HOSTNAME, hostname);
|
||||
|
||||
// Port number
|
||||
CbSetHeight(hWnd, C_PORT, 18);
|
||||
@ -19450,6 +19457,16 @@ void SmEditSettingDlgUpdate(HWND hWnd, SM_EDIT_SETTING *p)
|
||||
|
||||
GetTxtA(hWnd, E_HOSTNAME, tmp, sizeof(tmp));
|
||||
Trim(tmp);
|
||||
UINT i = SearchStrEx(tmp, "/", 0, false);
|
||||
if (i != INFINITE)
|
||||
{
|
||||
StrCpy(s->ClientOption.HintStr, sizeof(s->ClientOption.HintStr), tmp + i + 1);
|
||||
tmp[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s->ClientOption.HintStr[0] = 0;
|
||||
}
|
||||
|
||||
if (StrCmpi(tmp, s->ClientOption.Hostname) != 0)
|
||||
{
|
||||
@ -20211,6 +20228,13 @@ void SmLoadSettingList()
|
||||
|
||||
if (s != NULL)
|
||||
{
|
||||
// Migrate from old settings that mixed hint string with hostname
|
||||
UINT i = SearchStrEx(s->ClientOption.Hostname, "/", 0, false);
|
||||
if (i != INFINITE)
|
||||
{
|
||||
StrCpy(s->ClientOption.HintStr, sizeof(s->ClientOption.HintStr), s->ClientOption.Hostname + i + 1);
|
||||
s->ClientOption.Hostname[i] = 0;
|
||||
}
|
||||
Add(sm->SettingList, s);
|
||||
}
|
||||
FreeBuf(b);
|
||||
@ -20273,6 +20297,7 @@ void SmInitDefaultSettingList()
|
||||
Sha0(s->HashedPassword, "", 0);
|
||||
UniStrCpy(s->ClientOption.AccountName, sizeof(s->ClientOption.AccountName), s->Title);
|
||||
StrCpy(s->ClientOption.Hostname, sizeof(s->ClientOption.Hostname), "localhost");
|
||||
s->ClientOption.HintStr[0] = 0;
|
||||
s->ClientOption.Port = GC_DEFAULT_PORT;
|
||||
|
||||
Add(sm->SettingList, s);
|
||||
@ -20362,7 +20387,14 @@ void SmRefreshSettingEx(HWND hWnd, wchar_t *select_name)
|
||||
UniFormat(tmp, sizeof(tmp), _UU("SM_MODE_HUB"), s->HubName);
|
||||
}
|
||||
|
||||
StrToUni(tmp2, sizeof(tmp2), s->ClientOption.Hostname);
|
||||
char hostname[MAX_SIZE];
|
||||
StrCpy(hostname, sizeof(hostname), s->ClientOption.Hostname);
|
||||
if (IsEmptyStr(s->ClientOption.HintStr) == false)
|
||||
{
|
||||
StrCat(hostname, sizeof(hostname), "/");
|
||||
StrCat(hostname, sizeof(hostname), s->ClientOption.HintStr);
|
||||
}
|
||||
StrToUni(tmp2, sizeof(tmp2), hostname);
|
||||
|
||||
LvInsertAdd(b,
|
||||
(s->ServerAdminMode ? ICO_SERVER_ONLINE : ICO_HUB),
|
||||
@ -20781,6 +20813,12 @@ void SmParseCommandLine()
|
||||
|
||||
UniStrCpy(o->AccountName, sizeof(o->AccountName), s->Title);
|
||||
StrCpy(o->Hostname, sizeof(o->Hostname), host);
|
||||
UINT i = SearchStrEx(o->Hostname, "/", 0, false);
|
||||
if (i != INFINITE)
|
||||
{
|
||||
StrCpy(o->HintStr, sizeof(o->HintStr), o->Hostname + i + 1);
|
||||
o->Hostname[i] = 0;
|
||||
}
|
||||
o->Port = port;
|
||||
o->ProxyType = PROXY_DIRECT;
|
||||
StrCpy(o->DeviceName, sizeof(o->DeviceName), "DUMMY");
|
||||
|
@ -41,7 +41,7 @@ typedef struct SETTING
|
||||
char HubName[MAX_HUBNAME_LEN + 1]; // HUB name
|
||||
UCHAR HashedPassword[SHA1_SIZE]; // Password
|
||||
CLIENT_OPTION ClientOption; // Client Option
|
||||
UCHAR Reserved[10240 - sizeof(UINT) * 8 - SHA1_SIZE - HTTP_CUSTOM_HEADER_MAX_SIZE]; // Reserved area
|
||||
UCHAR Reserved[10240 - sizeof(UINT) * 8 - SHA1_SIZE - HTTP_CUSTOM_HEADER_MAX_SIZE - MAX_HOST_NAME_LEN - 1]; // Reserved area
|
||||
} SETTING;
|
||||
|
||||
// Structure declaration
|
||||
|
@ -1329,7 +1329,7 @@ void WinConnectDlgThread(THREAD *thread, void *param)
|
||||
nat_t_svc_name = d->nat_t_svc_name;
|
||||
}
|
||||
|
||||
s = ConnectEx3(d->hostname, d->port, d->timeout, &d->cancel, nat_t_svc_name, &nat_t_error_code, d->try_start_ssl, false);
|
||||
s = ConnectEx5(d->hostname, d->port, d->timeout, &d->cancel, nat_t_svc_name, &nat_t_error_code, d->try_start_ssl, false, d->hint_str, NULL);
|
||||
|
||||
d->ret_sock = s;
|
||||
d->nat_t_error_code = nat_t_error_code;
|
||||
@ -1398,6 +1398,10 @@ UINT WinConnectDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *
|
||||
|
||||
// TCP connection with showing the UI
|
||||
SOCK *WinConnectEx3(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_id, wchar_t *caption, wchar_t *info, UINT *nat_t_error_code, char *nat_t_svc_name, bool try_start_ssl)
|
||||
{
|
||||
return WinConnectEx4(hWnd, server, port, timeout, icon_id, caption, info, nat_t_error_code, nat_t_svc_name, try_start_ssl, NULL);
|
||||
}
|
||||
SOCK *WinConnectEx4(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_id, wchar_t *caption, wchar_t *info, UINT *nat_t_error_code, char *nat_t_svc_name, bool try_start_ssl, char *hint_str)
|
||||
{
|
||||
wchar_t tmp[MAX_SIZE];
|
||||
wchar_t tmp2[MAX_SIZE];
|
||||
@ -1440,6 +1444,7 @@ SOCK *WinConnectEx3(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_
|
||||
d.timeout = timeout;
|
||||
d.hostname = server;
|
||||
d.port = port;
|
||||
d.hint_str = hint_str;
|
||||
StrCpy(d.nat_t_svc_name, sizeof(d.nat_t_svc_name), nat_t_svc_name);
|
||||
|
||||
Dialog(hWnd, D_CONNECT, WinConnectDlgProc, &d);
|
||||
|
@ -331,6 +331,7 @@ typedef struct WINCONNECT_DLG_DATA
|
||||
char nat_t_svc_name[MAX_SIZE];
|
||||
UINT nat_t_error_code;
|
||||
bool try_start_ssl;
|
||||
char *hint_str;
|
||||
} WINCONNECT_DLG_DATA;
|
||||
|
||||
HBITMAP ResizeBitmap(HBITMAP hSrc, UINT src_x, UINT src_y, UINT dst_x, UINT dst_y);
|
||||
@ -694,6 +695,7 @@ HFONT GetMeiryoFontEx(UINT font_size);
|
||||
HFONT GetMeiryoFontEx2(UINT font_size, bool bold);
|
||||
bool ShowWindowsNetworkConnectionDialog();
|
||||
SOCK *WinConnectEx3(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_id, wchar_t *caption, wchar_t *info, UINT *nat_t_error_code, char *nat_t_svc_name, bool try_start_ssl);
|
||||
SOCK *WinConnectEx4(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_id, wchar_t *caption, wchar_t *info, UINT *nat_t_error_code, char *nat_t_svc_name, bool try_start_ssl, char *hint_str);
|
||||
UINT WinConnectDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param);
|
||||
void WinConnectDlgThread(THREAD *thread, void *param);
|
||||
void NicInfo(UI_NICINFO *info);
|
||||
|
@ -13979,7 +13979,7 @@ void ConnectThreadForIPv4(THREAD *thread, void *param)
|
||||
Zero(&p4, sizeof(p4));
|
||||
|
||||
// p1: TCP
|
||||
StrCpy(p1.Hostname, sizeof(p1.Hostname), p->Hostname_Original);
|
||||
StrCpy(p1.Hostname, sizeof(p1.Hostname), p->Hostname);
|
||||
Copy(&p1.Ip, ip, sizeof(IP));
|
||||
p1.Port = p->Port;
|
||||
p1.Timeout = p->Timeout;
|
||||
@ -13989,7 +13989,7 @@ void ConnectThreadForIPv4(THREAD *thread, void *param)
|
||||
p1.CancelLock = NewLock();
|
||||
|
||||
// p2: NAT-T
|
||||
StrCpy(p2.Hostname, sizeof(p2.Hostname), p->Hostname_Original);
|
||||
StrCpy(p2.Hostname, sizeof(p2.Hostname), p->Hostname);
|
||||
Copy(&p2.Ip, ip, sizeof(IP));
|
||||
p2.Port = p->Port;
|
||||
p2.Timeout = p->Timeout;
|
||||
@ -14002,7 +14002,7 @@ void ConnectThreadForIPv4(THREAD *thread, void *param)
|
||||
p2.Delay = 30; // Delay by 30ms
|
||||
|
||||
// p3: over ICMP
|
||||
StrCpy(p3.Hostname, sizeof(p3.Hostname), p->Hostname_Original);
|
||||
StrCpy(p3.Hostname, sizeof(p3.Hostname), p->Hostname);
|
||||
Copy(&p3.Ip, ip, sizeof(IP));
|
||||
p3.Port = p->Port;
|
||||
p3.Timeout = p->Timeout;
|
||||
@ -14013,7 +14013,7 @@ void ConnectThreadForIPv4(THREAD *thread, void *param)
|
||||
p3.Delay = 200; // Delay by 200ms
|
||||
|
||||
// p4: over DNS
|
||||
StrCpy(p4.Hostname, sizeof(p4.Hostname), p->Hostname_Original);
|
||||
StrCpy(p4.Hostname, sizeof(p4.Hostname), p->Hostname);
|
||||
Copy(&p4.Ip, ip, sizeof(IP));
|
||||
p4.Port = p->Port;
|
||||
p4.Timeout = p->Timeout;
|
||||
@ -14221,7 +14221,7 @@ void ConnectThreadForIPv4(THREAD *thread, void *param)
|
||||
|
||||
if (s != INVALID_SOCKET)
|
||||
{
|
||||
p->Sock = CreateTCPSock(s, false, ¤t_ip, p->No_Get_Hostname, p->Hostname_Original);
|
||||
p->Sock = CreateTCPSock(s, false, ¤t_ip, p->No_Get_Hostname, p->Hostname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -14308,7 +14308,7 @@ void ConnectThreadForIPv6(THREAD *thread, void *param)
|
||||
|
||||
if (s != INVALID_SOCKET)
|
||||
{
|
||||
p->Sock = CreateTCPSock(s, true, ¤t_ip, p->No_Get_Hostname, p->Hostname_Original);
|
||||
p->Sock = CreateTCPSock(s, true, ¤t_ip, p->No_Get_Hostname, p->Hostname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -14410,11 +14410,13 @@ SOCK *ConnectEx3(char *hostname, UINT port, UINT timeout, bool *cancel_flag, cha
|
||||
return ConnectEx4(hostname, port, timeout, cancel_flag, nat_t_svc_name, nat_t_error_code, try_start_ssl, no_get_hostname, NULL);
|
||||
}
|
||||
SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, char *nat_t_svc_name, UINT *nat_t_error_code, bool try_start_ssl, bool no_get_hostname, IP *ret_ip)
|
||||
{
|
||||
return ConnectEx5(hostname, port, timeout, cancel_flag, nat_t_svc_name, nat_t_error_code, try_start_ssl, no_get_hostname, NULL, ret_ip);
|
||||
}
|
||||
SOCK *ConnectEx5(char *hostname, UINT port, UINT timeout, bool *cancel_flag, char *nat_t_svc_name, UINT *nat_t_error_code, bool try_start_ssl, bool no_get_hostname, char *hint_str, IP *ret_ip)
|
||||
{
|
||||
bool dummy = false;
|
||||
bool use_natt = false;
|
||||
char hostname_original[MAX_SIZE];
|
||||
char hint_str[MAX_SIZE];
|
||||
bool force_use_natt = false;
|
||||
UINT dummy_int = 0;
|
||||
IP dummy_ret_ip;
|
||||
@ -14442,33 +14444,15 @@ SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, cha
|
||||
ret_ip = &dummy_ret_ip;
|
||||
}
|
||||
|
||||
Zero(hint_str, sizeof(hint_str));
|
||||
StrCpy(hostname_original, sizeof(hostname_original), hostname);
|
||||
|
||||
use_natt = (IsEmptyStr(nat_t_svc_name) ? false : true);
|
||||
|
||||
if (use_natt)
|
||||
{
|
||||
// In case of using NAT-T, split host name if the '/' is included in the host name
|
||||
UINT i = SearchStrEx(hostname, "/", 0, false);
|
||||
|
||||
if (i == INFINITE)
|
||||
if (IsEmptyStr(hint_str) == false)
|
||||
{
|
||||
// Not included
|
||||
StrCpy(hostname_original, sizeof(hostname_original), hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Included
|
||||
StrCpy(hostname_original, sizeof(hostname_original), hostname);
|
||||
hostname_original[i] = 0;
|
||||
|
||||
// Force to use the NAT-T
|
||||
force_use_natt = true;
|
||||
|
||||
// Copy the hint string
|
||||
StrCpy(hint_str, sizeof(hint_str), hostname + i + 1);
|
||||
|
||||
if (StrCmpi(hint_str, "tcp") == 0 || StrCmpi(hint_str, "disable") == 0
|
||||
|| StrCmpi(hint_str, "disabled") == 0
|
||||
|| StrCmpi(hint_str, "no") == 0 || StrCmpi(hint_str, "none") == 0)
|
||||
@ -14479,10 +14463,6 @@ SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, cha
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StrCpy(hostname_original, sizeof(hostname_original), hostname);
|
||||
}
|
||||
|
||||
LIST *iplist_v6 = NULL;
|
||||
LIST *iplist_v4 = NULL;
|
||||
@ -14506,7 +14486,7 @@ SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, cha
|
||||
else
|
||||
{
|
||||
// Forward resolution
|
||||
if (DnsResolveEx(&iplist_v6, &iplist_v4, hostname_original, 0, cancel_flag) == false)
|
||||
if (DnsResolveEx(&iplist_v6, &iplist_v4, hostname, 0, cancel_flag) == false)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -14532,7 +14512,6 @@ SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, cha
|
||||
p6.Port = port;
|
||||
p6.Timeout = timeout;
|
||||
StrCpy(p6.Hostname, sizeof(p6.Hostname), hostname);
|
||||
StrCpy(p6.Hostname_Original, sizeof(p6.Hostname_Original), hostname_original);
|
||||
p6.No_Get_Hostname = no_get_hostname;
|
||||
p6.CancelFlag = &cancel_flag2;
|
||||
p6.NoDelayFlag = &no_delay_flag;
|
||||
@ -14551,7 +14530,6 @@ SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, cha
|
||||
p4.Port = port;
|
||||
p4.Timeout = timeout;
|
||||
StrCpy(p4.Hostname, sizeof(p4.Hostname), hostname);
|
||||
StrCpy(p4.Hostname_Original, sizeof(p4.Hostname_Original), hostname_original);
|
||||
StrCpy(p4.HintStr, sizeof(p4.HintStr), hint_str);
|
||||
p4.No_Get_Hostname = no_get_hostname;
|
||||
p4.CancelFlag = &cancel_flag2;
|
||||
|
@ -802,7 +802,6 @@ struct CONNECT_SERIAL_PARAM
|
||||
UINT Port;
|
||||
UINT Timeout;
|
||||
char Hostname[MAX_SIZE];
|
||||
char Hostname_Original[MAX_SIZE];
|
||||
char HintStr[MAX_SIZE];
|
||||
bool No_Get_Hostname;
|
||||
bool *CancelFlag;
|
||||
@ -1085,6 +1084,7 @@ SOCK *ConnectEx(char *hostname, UINT port, UINT timeout);
|
||||
SOCK *ConnectEx2(char *hostname, UINT port, UINT timeout, bool *cancel_flag);
|
||||
SOCK *ConnectEx3(char *hostname, UINT port, UINT timeout, bool *cancel_flag, char *nat_t_svc_name, UINT *nat_t_error_code, bool try_start_ssl, bool no_get_hostname);
|
||||
SOCK *ConnectEx4(char *hostname, UINT port, UINT timeout, bool *cancel_flag, char *nat_t_svc_name, UINT *nat_t_error_code, bool try_start_ssl, bool no_get_hostname, IP *ret_ip);
|
||||
SOCK *ConnectEx5(char *hostname, UINT port, UINT timeout, bool *cancel_flag, char *nat_t_svc_name, UINT *nat_t_error_code, bool try_start_ssl, bool no_get_hostname, char *hint_str, IP *ret_ip);
|
||||
SOCKET ConnectTimeoutIPv4(IP *ip, UINT port, UINT timeout, bool *cancel_flag);
|
||||
bool SetSocketBufferSize(SOCKET s, bool send, UINT size);
|
||||
UINT SetSocketBufferSizeWithBestEffort(SOCKET s, bool send, UINT size);
|
||||
|
Loading…
Reference in New Issue
Block a user