TSG-7832: 支持非标端口8443,支持配置文件配置支持识别的端口QUIC_PORT_LIST=443;8443;
This commit is contained in:
@@ -127,30 +127,47 @@ int is_iquic(enum _QUIC_VERSION quic_version)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int check_port(unsigned short port)
|
||||||
|
{
|
||||||
|
int i=0;
|
||||||
|
for(i=0; i< g_quic_param.quic_port_num; i++)
|
||||||
|
{
|
||||||
|
if(g_quic_param.quic_port_list[i]==port)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int is_quic_port(struct streaminfo *pstream)
|
int is_quic_port(struct streaminfo *pstream)
|
||||||
{
|
{
|
||||||
|
unsigned short source=0, dest=0;
|
||||||
|
|
||||||
switch(pstream->addr.addrtype)
|
switch(pstream->addr.addrtype)
|
||||||
{
|
{
|
||||||
case ADDR_TYPE_IPV4:
|
case ADDR_TYPE_IPV4:
|
||||||
case __ADDR_TYPE_IP_PAIR_V4:
|
case __ADDR_TYPE_IP_PAIR_V4:
|
||||||
if(ntohs(pstream->addr.ipv4->source)!=443 && ntohs(pstream->addr.ipv4->dest)!=443)
|
source=(unsigned short)ntohs(pstream->addr.ipv4->source);
|
||||||
{
|
dest=(unsigned short)ntohs(pstream->addr.ipv4->dest);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ADDR_TYPE_IPV6:
|
case ADDR_TYPE_IPV6:
|
||||||
case __ADDR_TYPE_IP_PAIR_V6:
|
case __ADDR_TYPE_IP_PAIR_V6:
|
||||||
if(ntohs(pstream->addr.ipv6->source)!=443 && ntohs(pstream->addr.ipv6->dest)!=443)
|
source=(unsigned short)ntohs(pstream->addr.ipv6->source);
|
||||||
{
|
dest=(unsigned short)ntohs(pstream->addr.ipv6->dest);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
if(check_port(source) || check_port(dest))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_value(unsigned char *payload, int *offset, int len)
|
static int get_value(unsigned char *payload, int *offset, int len)
|
||||||
|
|||||||
@@ -41,6 +41,71 @@ static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
|
|||||||
|
|
||||||
const char QUIC_VERSION_20200603=0;
|
const char QUIC_VERSION_20200603=0;
|
||||||
|
|
||||||
|
static int parse_quic_port(char *port_list, unsigned short *quic_port, int quic_port_num)
|
||||||
|
{
|
||||||
|
int i=0,ret=0;
|
||||||
|
int port_num=0;
|
||||||
|
int range_len=0,used_len=0;
|
||||||
|
char buf[256]={0};
|
||||||
|
unsigned short s_port=0,e_port=0;
|
||||||
|
char *begin=NULL,*end=NULL,*pchr=NULL;
|
||||||
|
|
||||||
|
if(port_list==NULL)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
begin=port_list;
|
||||||
|
end=NULL;
|
||||||
|
range_len=strlen(port_list);
|
||||||
|
|
||||||
|
while(range_len>used_len)
|
||||||
|
{
|
||||||
|
end=index(begin, ';');
|
||||||
|
if(end==NULL)
|
||||||
|
{
|
||||||
|
end=begin+range_len-used_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(end==begin)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
strncpy(buf, begin, end-begin);
|
||||||
|
used_len+=end-begin+1;
|
||||||
|
if(range_len>used_len)
|
||||||
|
{
|
||||||
|
begin=end+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pchr=strchr(buf, '-');
|
||||||
|
if(pchr == NULL)
|
||||||
|
{
|
||||||
|
s_port=(unsigned short)atoi(buf);
|
||||||
|
e_port=s_port;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret=sscanf(buf, "%hu-%hu", &s_port, &e_port);
|
||||||
|
if(ret!=2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=s_port; i<=e_port && port_num<quic_port_num; i++)
|
||||||
|
{
|
||||||
|
quic_port[port_num++]=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return port_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int quic_init_stream(void **pme, int thread_seq)
|
int quic_init_stream(void **pme, int thread_seq)
|
||||||
{
|
{
|
||||||
struct _quic_context *_context=(struct _quic_context *)dictator_malloc(thread_seq, sizeof(struct _quic_context));
|
struct _quic_context *_context=(struct _quic_context *)dictator_malloc(thread_seq, sizeof(struct _quic_context));
|
||||||
@@ -110,7 +175,7 @@ extern "C" int QUIC_INIT(void)
|
|||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
FILE *fp=NULL;
|
FILE *fp=NULL;
|
||||||
char buf[2048]={0};
|
char buff[2048]={0};
|
||||||
int region_id=0;
|
int region_id=0;
|
||||||
char region_name[REGION_NAME_LEN]={0};
|
char region_name[REGION_NAME_LEN]={0};
|
||||||
|
|
||||||
@@ -121,6 +186,9 @@ extern "C" int QUIC_INIT(void)
|
|||||||
|
|
||||||
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "DUMP_PCAKET_SWITCH", &g_quic_param.dump_packet_switch, 0);
|
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "DUMP_PCAKET_SWITCH", &g_quic_param.dump_packet_switch, 0);
|
||||||
|
|
||||||
|
MESA_load_profile_string_def(g_quic_proto_conffile, "QUIC", "QUIC_PORT_LIST", buff, sizeof(buff), "443;8443;");
|
||||||
|
g_quic_param.quic_port_num=parse_quic_port(buff, g_quic_param.quic_port_list, SUPPORT_QUIC_PORT_NUM);
|
||||||
|
|
||||||
g_quic_param.logger=MESA_create_runtime_log_handle(g_quic_param.log_path, g_quic_param.level);
|
g_quic_param.logger=MESA_create_runtime_log_handle(g_quic_param.log_path, g_quic_param.level);
|
||||||
if(g_quic_param.logger==NULL)
|
if(g_quic_param.logger==NULL)
|
||||||
{
|
{
|
||||||
@@ -130,19 +198,19 @@ extern "C" int QUIC_INIT(void)
|
|||||||
|
|
||||||
if(((fp = fopen(g_quic_regionname_conffile, "r"))!=NULL))
|
if(((fp = fopen(g_quic_regionname_conffile, "r"))!=NULL))
|
||||||
{
|
{
|
||||||
while(fgets(buf, sizeof(buf), fp))
|
while(fgets(buff, sizeof(buff), fp))
|
||||||
{
|
{
|
||||||
ret = sscanf(buf, "%d\t%s", ®ion_id, region_name);
|
ret = sscanf(buff, "%d\t%s", ®ion_id, region_name);
|
||||||
if(2>ret)
|
if(2>ret)
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Read error, Please check %s, region_line: %s", g_quic_regionname_conffile, buf);
|
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Read error, Please check %s, region_line: %s", g_quic_regionname_conffile, buff);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(region_id>MAX_REGION_NUM)
|
if(region_id>MAX_REGION_NUM)
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Read error, Please check %s, bigger than MAX_REGION_NUM, region_line: %s", g_quic_regionname_conffile, buf);
|
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Read error, Please check %s, bigger than MAX_REGION_NUM, region_line: %s", g_quic_regionname_conffile, buff);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#define TRUE 0x01
|
#define TRUE 0x01
|
||||||
#define MAYBE 0x02
|
#define MAYBE 0x02
|
||||||
|
|
||||||
|
#define SUPPORT_QUIC_PORT_NUM 128
|
||||||
|
|
||||||
#define QUIC_HALF_CLOSE 0x01
|
#define QUIC_HALF_CLOSE 0x01
|
||||||
#define QUIC_WHOLE_CLOSE 0x02
|
#define QUIC_WHOLE_CLOSE 0x02
|
||||||
@@ -25,7 +26,9 @@ struct _quic_param_t
|
|||||||
unsigned long long quic_region_cnt;
|
unsigned long long quic_region_cnt;
|
||||||
unsigned short quic_plugid;
|
unsigned short quic_plugid;
|
||||||
int level;
|
int level;
|
||||||
|
int quic_port_num;
|
||||||
int dump_packet_switch;
|
int dump_packet_switch;
|
||||||
|
unsigned short quic_port_list[SUPPORT_QUIC_PORT_NUM];
|
||||||
char quic_conf_regionname[MAX_REGION_NUM][REGION_NAME_LEN];
|
char quic_conf_regionname[MAX_REGION_NUM][REGION_NAME_LEN];
|
||||||
char log_path[128];
|
char log_path[128];
|
||||||
void *logger;
|
void *logger;
|
||||||
|
|||||||
@@ -54,3 +54,4 @@ add_test(NAME GQUIC_50_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/
|
|||||||
add_test(NAME MVFST_01_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/01/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/01/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
|
add_test(NAME MVFST_01_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/01/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/01/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
|
||||||
add_test(NAME MVFST_02_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/02/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/02/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
|
add_test(NAME MVFST_02_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/02/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/02/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
|
||||||
add_test(NAME TQUIC_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/tquic/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/tquic/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
|
add_test(NAME TQUIC_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/tquic/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/tquic/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
|
||||||
|
add_test(NAME IQUIC_PORT_8443_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/port-8443/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/port-8443/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
|
||||||
|
|||||||
Binary file not shown.
6
test/pcap/port-8443/quic_result.json
Normal file
6
test/pcap/port-8443/quic_result.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[{
|
||||||
|
"Tuple4": "192.168.50.49.58445>45.77.96.66.8443",
|
||||||
|
"VERSION": "IETF QUIC 29",
|
||||||
|
"SNI": "quic.tech",
|
||||||
|
"name": "QUIC_RESULT_1"
|
||||||
|
}]
|
||||||
Reference in New Issue
Block a user