- After loading from DB rn_address is in form: [x:x:x:x:x:x:x:x]:nnnn, getaddrinfo function expect ipv6 in node argument without square brackets, otherwise, the argument is interpreted as FQDN.
... | ... |
@@ -1829,6 +1829,7 @@ static int build_rtpp_socks(int lmode, int rtest) { |
1829 | 1829 |
rtpe_reload_lock_get(rtpp_list->rset_lock); |
1830 | 1830 |
for (pnode=rtpp_list->rn_first; pnode!=0; pnode = pnode->rn_next) { |
1831 | 1831 |
char *hostname; |
1832 |
+ char *hp; |
|
1832 | 1833 |
|
1833 | 1834 |
if (pnode->rn_umode == 0) { |
1834 | 1835 |
rtpp_socks[pnode->idx] = -1; |
... | ... |
@@ -1860,11 +1861,23 @@ static int build_rtpp_socks(int lmode, int rtest) { |
1860 | 1861 |
if (cp == NULL || *cp == '\0') |
1861 | 1862 |
cp = CPORT; |
1862 | 1863 |
|
1864 |
+ if(pnode->rn_umode == 6) { |
|
1865 |
+ hp = strrchr(hostname, ']'); |
|
1866 |
+ if(hp != NULL) |
|
1867 |
+ *hp = '\0'; |
|
1868 |
+ |
|
1869 |
+ hp = hostname; |
|
1870 |
+ if(*hp == '[') |
|
1871 |
+ hp++; |
|
1872 |
+ } else { |
|
1873 |
+ hp = hostname; |
|
1874 |
+ } |
|
1875 |
+ |
|
1863 | 1876 |
memset(&hints, 0, sizeof(hints)); |
1864 | 1877 |
hints.ai_flags = 0; |
1865 | 1878 |
hints.ai_family = (pnode->rn_umode == 6) ? AF_INET6 : AF_INET; |
1866 | 1879 |
hints.ai_socktype = SOCK_DGRAM; |
1867 |
- if ((n = getaddrinfo(hostname, cp, &hints, &res)) != 0) { |
|
1880 |
+ if ((n = getaddrinfo(hp, cp, &hints, &res)) != 0) { |
|
1868 | 1881 |
LM_ERR("%s\n", gai_strerror(n)); |
1869 | 1882 |
pkg_free(hostname); |
1870 | 1883 |
rtpp_socks[pnode->idx] = -1; |