diff options
| author | Nagi5Yeq <wu@x-nagi.com> | 2021-02-04 23:21:41 +0800 |
|---|---|---|
| committer | Nagi5Yeq <wu@x-nagi.com> | 2021-02-04 23:21:41 +0800 |
| commit | 31d9d4dbed319a3c1a0a493c1e48ed7d20621762 (patch) | |
| tree | 1f57dc9567bce95cad774287551d54e6b417a175 /src/SocketCore.cc | |
| parent | b3066738d1705f84979cd3477b567ea4201e2296 (diff) | |
add ipv6 address in http announce
Diffstat (limited to 'src/SocketCore.cc')
| -rw-r--r-- | src/SocketCore.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/SocketCore.cc b/src/SocketCore.cc index e235f512..8907eb4f 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -1570,6 +1570,9 @@ bool verifyHostname(const std::string& hostname, namespace { bool ipv4AddrConfigured = true; bool ipv6AddrConfigured = true; + +bool hasGlobalIpv6Addr = false; +char globalIpv6Addr[NI_MAXHOST]; } // namespace #ifdef __MINGW32__ @@ -1694,6 +1697,11 @@ void checkAddrconfig() !IN6_IS_ADDR_LINKLOCAL(&ad.in6.sin6_addr)) { ipv6AddrConfigured = true; found = true; + if (!hasGlobalIpv6Addr && + inetNtop(AF_INET6, &ad.in6.sin6_addr, globalIpv6Addr, + sizeof(globalIpv6Addr) == 0)) { + hasGlobalIpv6Addr = true; + } } break; } @@ -1723,6 +1731,14 @@ bool getIPv4AddrConfigured() { return ipv4AddrConfigured; } bool getIPv6AddrConfigured() { return ipv6AddrConfigured; } +const char* getGlobalIpv6Addr() +{ + if (hasGlobalIpv6Addr == true) { + return globalIpv6Addr; + } + return nullptr; +} + } // namespace net } // namespace aria2 |
