domain-set: support punycode.

This commit is contained in:
Nick Peng
2023-12-06 22:56:48 +08:00
parent 11d92a67a1
commit 9554b3debe
7 changed files with 461 additions and 6 deletions

View File

@@ -17,6 +17,7 @@
*/
#include "dns_conf.h"
#include "idna.h"
#include "list.h"
#include "rbtree.h"
#include "tlog.h"
@@ -308,8 +309,14 @@ static int _get_domain(char *value, char *domain, int max_domain_size, char **pt
goto errout;
}
memcpy(domain, begin, len);
domain[len] = '\0';
size_t domain_len = max_domain_size;
domain_len = utf8_to_punycode(begin, len, domain, domain_len);
if (domain_len <= 0) {
tlog(TLOG_ERROR, "domain name %s invalid", value);
goto errout;
}
domain[domain_len] = '\0';
if (ptr_after_domain) {
*ptr_after_domain = end + 1;