diff --git a/default.config b/default.config index db7979f..55dd6d3 100755 --- a/default.config +++ b/default.config @@ -107,6 +107,7 @@ GroupFile # 服务器组文件的写法: # # file 1 +# ; comment too # # UDP # PROTOCOL UDP # SERVER 1.2.4.8,127.0.0.1 @@ -114,7 +115,7 @@ GroupFile # # LIST domainlist.txt # -# example.com +# example.com # comment # # # file 2 # # TCP @@ -137,10 +138,10 @@ GroupFile # 注意: # 1.对于没有指定服务器的域名,会随机选择一个服务器组进行查询。 # 2.如果某域名匹配多个服务器组,则选择的顺序如下: -# (1) 优先选择不含通配符的匹配项,如果仍然有多条匹配,则选择匹配度最高的那个, -# 如果匹配度相同的情况下仍然有多条匹配,则选择最后一个。 +# (1) 优先选择不含通配符的匹配项,如果有多条匹配,则选择匹配度最高的那个, +# 如果匹配度相同的情况下有多条匹配,则选择最后一个。 # (例如 `ipv6.microsoft.com' 比 `microsoft.com' 对于域名 `teredo.ipv6.microsoft.com' 的匹配度更高) -# (2) 然后选择包含通配符的匹配项,如果有多条匹配,则选择第一个; +# (2) 然后选择包含通配符的匹配项,如果有多条匹配,则随机选择一个; # 组合示例: # 一、以 microsoft.com 或 office.com 结尾的域名通过 UDP 服务器 1.2.4.8 查询,其它域名通过 TCP 服务器 8.8.4.4 查询: @@ -156,7 +157,7 @@ GroupFile # BlockIP ,,..... # 阻挡含有以下 IP 地址(支持 IPv4 和 IPv6 地址)的 DNS 数据包 (since 6.0.0) # IPv6 地址不用加方括号 -BlockIP 243.185.187.39,46.82.174.68,37.61.54.158,93.46.8.89,59.24.3.173,203.98.7.65,8.7.198.45,78.16.49.15,159.106.121.75 +BlockIP # IPSubstituting ,,..... # 替换 DNS 数据包中的 IP 地址(只支持 IPv4 地址) (since 5.0.1) diff --git a/default.en.config b/default.en.config index 4c2f5d9..7d3fd96 100755 --- a/default.en.config +++ b/default.en.config @@ -133,6 +133,7 @@ GroupFile # GroupFile syntax: # # file 1 +# ; comment too # # UDP # PROTOCOL UDP # SERVER 1.2.4.8,127.0.0.1 @@ -140,7 +141,7 @@ GroupFile # # LIST domainlist.txt # -# example.com +# example.com # comment # # # file 2 # # TCP @@ -164,12 +165,12 @@ GroupFile # 1.For domains that aren't explicitly specified, a random server group will be chosen. # 2.For domains specified to more than one server groups, the order of seletion is as follows: # (1) The matched item without any wildcards. -# If there are still more than one, choose the most matchable one +# If there are more than one, choose the most matchable one # (e.g. `ipv6.microsoft.com' is more matchable than `microsoft.com' # when matching with `teredo.ipv6.microsoft.com'). # If there are more than one most matchable items, choose the last one. # (2) The matched item with wildcards. -# If there are more than one, the first is chosen. +# If there are more than one, a random one is chosen. # # Other Examples: # 1. Forward quieries to domains tailed with microsoft.com or office.com to 1.2.4.8 over UDP, @@ -186,7 +187,7 @@ GroupFile # BlockIP ,,..... # Ignore DNS responses from servers with these IPs (since 6.0.0) # An IPv6 address should NOT be square-bracket-rounded -BlockIP 243.185.187.39,46.82.174.68,37.61.54.158,93.46.8.89,59.24.3.173,203.98.7.65,8.7.198.45,78.16.49.15,159.106.121.75 +BlockIP # IPSubstituting ,,..... # Replace an IP with another in every response from servers(only IPv4 supported) (since 5.0.1) diff --git a/main.c b/main.c index 67fedef..337b4e5 100755 --- a/main.c +++ b/main.c @@ -86,9 +86,6 @@ static int EnvironmentInit(void) /* UDPGroup 1.2.4.8,114.114.114.114 * on */ ConfigAddAlias(&ConfigInfo, "ServerGroup", "UDPGroup", "UDP", NULL); - TmpTypeDescriptor.boolean = FALSE; - ConfigAddOption(&ConfigInfo, "EnableUDPtoTCP", STRATEGY_DEFAULT, TYPE_BOOLEAN, TmpTypeDescriptor); - /* TCPGroup 1.2.4.8,114.114.114.114 example.com 192.168.50.5:8080, 192.168.50.6:8080*/ /* TCPGroup 1.2.4.8,114.114.114.114 * no*/ ConfigAddAlias(&ConfigInfo, "ServerGroup", "TCPGroup", "TCP", NULL); @@ -96,6 +93,9 @@ static int EnvironmentInit(void) /* TLSGroup getdnsapi.net:853:185.49.141.38|foxZRnIh9gZpWnl+zEiKa0EJ2rdCGroMWm02gaxSc9S= example.com */ ConfigAddAlias(&ConfigInfo, "ServerGroup", "TLSGroup", "TLS", NULL); + TmpTypeDescriptor.boolean = FALSE; + ConfigAddOption(&ConfigInfo, "EnableUDPtoTCP", STRATEGY_DEFAULT, TYPE_BOOLEAN, TmpTypeDescriptor); + TmpTypeDescriptor.str = NULL; ConfigAddOption(&ConfigInfo, "BlockIP", STRATEGY_APPEND, TYPE_STRING, TmpTypeDescriptor); diff --git a/mmgr.c b/mmgr.c index 97baa3a..1b484b5 100755 --- a/mmgr.c +++ b/mmgr.c @@ -37,6 +37,12 @@ static ModuleMap *CurModuleMap = NULL; static RWLock ModulesLock = {NULL}; static ConfigFileInfo *CurrConfigInfo = NULL; +static void DomainList_Tidy(StringList *DomainList) +{ + DomainList->TrimAll(DomainList, "\t ."); + DomainList->LowercaseAll(DomainList); +} + static int MappingAModule(ModuleMap *ModuleMap, ModuleInterface *Stored, StringList *DomainList @@ -45,9 +51,6 @@ static int MappingAModule(ModuleMap *ModuleMap, StringListIterator i; const char *OneDomain; - DomainList->TrimAll(DomainList, "\t ."); - DomainList->LowercaseAll(DomainList); - if( StringListIterator_Init(&i, DomainList) != 0 ) { return -46; @@ -159,6 +162,8 @@ static int Udp_Init(ModuleMap *ModuleMap, StringListIterator *i) return -148; } + DomainList_Tidy(&DomainList); + if( Udp_Init_Core(ModuleMap, Services, &DomainList, Parallel) != 0 ) { return -153; @@ -240,6 +245,8 @@ static int Tcp_Init(ModuleMap *ModuleMap, StringListIterator *i) return -148; } + DomainList_Tidy(&DomainList); + if( Tcp_Init_Core(ModuleMap, Services, &DomainList, Proxies) != 0 ) { return -233; @@ -420,6 +427,8 @@ static int Modules_InitFromFile(ModuleMap *ModuleMap, StringListIterator *i) } } + DomainList_Tidy(&Domains); + if( Domains.Count(&Domains) == 0 ) { ret = 0;