mirror of
https://github.com/henrypp/simplewall.git
synced 2026-10-21 10:40:27 -05:00
removed _app_parsehostaddress_wsa
This commit is contained in:
2 files changed
+83
-83
No files matched your search
+82
-82
@@ -2373,86 +2373,86 @@ rstring _app_parsehostaddress_dns (LPCWSTR hostname, USHORT port)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rstring _app_parsehostaddress_wsa (LPCWSTR hostname, USHORT port)
|
||||
{
|
||||
if (_r_str_isempty (hostname) || !app.ConfigGet (L"IsEnableWsaResolver", false).AsBool ())
|
||||
return nullptr;
|
||||
|
||||
// initialize winsock (required by getnameinfo)
|
||||
WSADATA wsaData = {0};
|
||||
INT rc = WSAStartup (WINSOCK_VERSION, &wsaData);
|
||||
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
app.LogError (L"WSAStartup", rc, nullptr, 0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rstring result;
|
||||
|
||||
ADDRINFOEXW hints = {0};
|
||||
ADDRINFOEXW * ppQueryResultsSet = nullptr;
|
||||
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
LPGUID lpNspid = nullptr;
|
||||
rc = GetAddrInfoEx (hostname, L"domain", NS_DNS, lpNspid, &hints, &ppQueryResultsSet, nullptr, nullptr, nullptr, nullptr);
|
||||
|
||||
if (rc != ERROR_SUCCESS || !ppQueryResultsSet)
|
||||
{
|
||||
app.LogError (L"GetAddrInfoEx", rc, hostname, 0);
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto current = ppQueryResultsSet; current != nullptr; current = current->ai_next)
|
||||
{
|
||||
WCHAR printableIP[INET6_ADDRSTRLEN] = {0};
|
||||
|
||||
if (current->ai_family == AF_INET)
|
||||
{
|
||||
struct sockaddr_in* sock_in4 = (struct sockaddr_in*)current->ai_addr;
|
||||
PIN_ADDR addr4 = &(sock_in4->sin_addr);
|
||||
|
||||
if (IN4_IS_ADDR_UNSPECIFIED (addr4))
|
||||
continue;
|
||||
|
||||
InetNtop (current->ai_family, addr4, printableIP, _countof (printableIP));
|
||||
}
|
||||
else if (current->ai_family == AF_INET6)
|
||||
{
|
||||
struct sockaddr_in6* sock_in6 = (struct sockaddr_in6*)current->ai_addr;
|
||||
PIN6_ADDR addr6 = &(sock_in6->sin6_addr);
|
||||
|
||||
if (IN6_IS_ADDR_UNSPECIFIED (addr6))
|
||||
continue;
|
||||
|
||||
InetNtop (current->ai_family, addr6, printableIP, _countof (printableIP));
|
||||
}
|
||||
|
||||
if (_r_str_isempty (printableIP))
|
||||
continue;
|
||||
|
||||
result.Append (printableIP);
|
||||
|
||||
if (port)
|
||||
result.AppendFormat (L":%d", port);
|
||||
|
||||
result.Append (DIVIDER_RULE);
|
||||
}
|
||||
|
||||
_r_str_trim (result, DIVIDER_RULE);
|
||||
}
|
||||
|
||||
FreeAddrInfoEx (ppQueryResultsSet);
|
||||
|
||||
WSACleanup ();
|
||||
|
||||
return result;
|
||||
}
|
||||
//
|
||||
//rstring _app_parsehostaddress_wsa (LPCWSTR hostname, USHORT port)
|
||||
//{
|
||||
// if (_r_str_isempty (hostname) || !app.ConfigGet (L"IsEnableWsaResolver", false).AsBool ())
|
||||
// return nullptr;
|
||||
//
|
||||
// // initialize winsock (required by getnameinfo)
|
||||
// WSADATA wsaData = {0};
|
||||
// INT rc = WSAStartup (WINSOCK_VERSION, &wsaData);
|
||||
//
|
||||
// if (rc != ERROR_SUCCESS)
|
||||
// {
|
||||
// app.LogError (L"WSAStartup", rc, nullptr, 0);
|
||||
// return nullptr;
|
||||
// }
|
||||
//
|
||||
// rstring result;
|
||||
//
|
||||
// ADDRINFOEXW hints = {0};
|
||||
// ADDRINFOEXW * ppQueryResultsSet = nullptr;
|
||||
//
|
||||
// hints.ai_family = AF_UNSPEC;
|
||||
// hints.ai_socktype = SOCK_STREAM;
|
||||
// hints.ai_protocol = IPPROTO_TCP;
|
||||
//
|
||||
// LPGUID lpNspid = nullptr;
|
||||
// rc = GetAddrInfoEx (hostname, L"domain", NS_DNS, lpNspid, &hints, &ppQueryResultsSet, nullptr, nullptr, nullptr, nullptr);
|
||||
//
|
||||
// if (rc != ERROR_SUCCESS || !ppQueryResultsSet)
|
||||
// {
|
||||
// app.LogError (L"GetAddrInfoEx", rc, hostname, 0);
|
||||
// return nullptr;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// for (auto current = ppQueryResultsSet; current != nullptr; current = current->ai_next)
|
||||
// {
|
||||
// WCHAR printableIP[INET6_ADDRSTRLEN] = {0};
|
||||
//
|
||||
// if (current->ai_family == AF_INET)
|
||||
// {
|
||||
// struct sockaddr_in* sock_in4 = (struct sockaddr_in*)current->ai_addr;
|
||||
// PIN_ADDR addr4 = &(sock_in4->sin_addr);
|
||||
//
|
||||
// if (IN4_IS_ADDR_UNSPECIFIED (addr4))
|
||||
// continue;
|
||||
//
|
||||
// InetNtop (current->ai_family, addr4, printableIP, _countof (printableIP));
|
||||
// }
|
||||
// else if (current->ai_family == AF_INET6)
|
||||
// {
|
||||
// struct sockaddr_in6* sock_in6 = (struct sockaddr_in6*)current->ai_addr;
|
||||
// PIN6_ADDR addr6 = &(sock_in6->sin6_addr);
|
||||
//
|
||||
// if (IN6_IS_ADDR_UNSPECIFIED (addr6))
|
||||
// continue;
|
||||
//
|
||||
// InetNtop (current->ai_family, addr6, printableIP, _countof (printableIP));
|
||||
// }
|
||||
//
|
||||
// if (_r_str_isempty (printableIP))
|
||||
// continue;
|
||||
//
|
||||
// result.Append (printableIP);
|
||||
//
|
||||
// if (port)
|
||||
// result.AppendFormat (L":%d", port);
|
||||
//
|
||||
// result.Append (DIVIDER_RULE);
|
||||
// }
|
||||
//
|
||||
// _r_str_trim (result, DIVIDER_RULE);
|
||||
// }
|
||||
//
|
||||
// FreeAddrInfoEx (ppQueryResultsSet);
|
||||
//
|
||||
// WSACleanup ();
|
||||
//
|
||||
// return result;
|
||||
//}
|
||||
|
||||
bool _app_parsenetworkstring (LPCWSTR network_string, NET_ADDRESS_FORMAT * format_ptr, PUSHORT port_ptr, FWP_V4_ADDR_AND_MASK* paddr4, FWP_V6_ADDR_AND_MASK* paddr6, LPWSTR paddr_dns, size_t dns_length)
|
||||
{
|
||||
@@ -2526,8 +2526,8 @@ bool _app_parsenetworkstring (LPCWSTR network_string, NET_ADDRESS_FORMAT * forma
|
||||
|
||||
rstring host = _app_parsehostaddress_dns (ni.NamedAddress.Address, port);
|
||||
|
||||
if (host.IsEmpty ())
|
||||
host = _app_parsehostaddress_wsa (ni.NamedAddress.Address, port);
|
||||
//if (host.IsEmpty ())
|
||||
// host = _app_parsehostaddress_wsa (ni.NamedAddress.Address, port);
|
||||
|
||||
if (host.IsEmpty ())
|
||||
{
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ bool _app_item_get (EnumDataType type, size_t app_hash, rstring* display_name, r
|
||||
void _app_refreshstatus (HWND hwnd, INT listview_id = INVALID_INT);
|
||||
|
||||
rstring _app_parsehostaddress_dns (LPCWSTR hostname, USHORT port);
|
||||
rstring _app_parsehostaddress_wsa (LPCWSTR hostname, USHORT port);
|
||||
//rstring _app_parsehostaddress_wsa (LPCWSTR hostname, USHORT port);
|
||||
|
||||
bool _app_parsenetworkstring (LPCWSTR network_string, NET_ADDRESS_FORMAT* format_ptr, PUSHORT port_ptr, FWP_V4_ADDR_AND_MASK* paddr4, FWP_V6_ADDR_AND_MASK* paddr6, LPWSTR paddr_dns, size_t dns_length);
|
||||
bool _app_parserulestring (rstring rule, PITEM_ADDRESS ptr_addr);
|
||||
|
||||
Reference in new issue
Block a user