Skip to content

Commit

Permalink
Add * to stand for any protocol for GroupFile
Browse files Browse the repository at this point in the history
  • Loading branch information
lifenjoiner committed Oct 1, 2024
1 parent 57ea20d commit 0ccd4e6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
6 changes: 6 additions & 0 deletions default.config
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ GroupFile
# PROXY 192.168.1.1:8080,192.168.1.1:8081
#
# example.com
#
# # file 4
# # UDP and TCP use the same servers
# PROTOCOL *
# SERVER 1.2.4.8,127.0.0.1
# # PARALLEL default: on, TCP PROXY default: no

# ע�⣺
# 1.����û��ָ���������������������ѡ��һ������������в�ѯ��
Expand Down
6 changes: 6 additions & 0 deletions default.en.config
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ GroupFile
# PROXY 192.168.1.1:8080,192.168.1.1:8081
#
# example.com
#
# # file 4
# # UDP and TCP use the same servers
# PROTOCOL *
# SERVER 1.2.4.8,127.0.0.1
# # PARALLEL default: on, TCP PROXY default: no

# Notes:
# 1.For domains that aren't explicitly specified, a random server group will be chosen.
Expand Down
28 changes: 25 additions & 3 deletions mmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static int Tcp_Init(ModuleMap *ModuleMap, StringListIterator *i)
}

/*
#############################
# UDP
PROTOCOL UDP
SERVER 1.2.4.8,127.0.0.1
Expand Down Expand Up @@ -309,6 +310,10 @@ PROXY 192.168.1.1:8080,192.168.1.1:8081
example.com
#############################
# UDP and TCP use the same servers
PROTOCOL *
SERVER 1.2.4.8,127.0.0.1
*/
static int Modules_InitFromFile(ModuleMap *ModuleMap, StringListIterator *i)
{
Expand All @@ -326,6 +331,10 @@ static int Modules_InitFromFile(ModuleMap *ModuleMap, StringListIterator *i)
const char *Protocol = NULL;
const char *List = NULL;

BOOL UseUDP = FALSE;
BOOL UseTCP = FALSE;
BOOL UseANY = FALSE;

int ret = 0;

FileOri = i->Next(i);
Expand Down Expand Up @@ -458,7 +467,16 @@ static int Modules_InitFromFile(ModuleMap *ModuleMap, StringListIterator *i)
goto EXIT_2;
}

if( strcmp(Protocol, "udp") == 0 )
UseANY = strcmp(Protocol, "*") == 0;
if( UseANY )
{
UseUDP = TRUE;
UseTCP = TRUE;
} else {
UseUDP = strcmp(Protocol, "udp") == 0;
}

if( UseUDP )
{
const char *Services = NULL;
const char *Parallel = "on";
Expand All @@ -472,7 +490,11 @@ static int Modules_InitFromFile(ModuleMap *ModuleMap, StringListIterator *i)
ret = -337;
}

} else if( strcmp(Protocol, "tcp") == 0 )
} else {
UseTCP = strcmp(Protocol, "tcp") == 0;
}

if( UseTCP )
{
const char *Services = NULL;
const char *Parallel = "on";
Expand All @@ -488,7 +510,7 @@ static int Modules_InitFromFile(ModuleMap *ModuleMap, StringListIterator *i)
ret = -233;
}

} else {
} else if( !UseUDP ) {
ERRORMSG("Unknown protocol %s, file \"%s\".\n", Protocol, File);
ret = -281;
}
Expand Down

0 comments on commit 0ccd4e6

Please sign in to comment.