Fix the problem that linked list inversion does not take effect.
This commit is contained in:
parent
890afe93c8
commit
5e3b8d0194
13
CProxy.conf
13
CProxy.conf
@ -8,7 +8,7 @@ global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
http_ip="2001:19f0:4401:2f:5400:3ff:fec4:e376";
|
http_ip="174.137.54.215";
|
||||||
http_port=129;
|
http_port=129;
|
||||||
http_del="Host,";
|
http_del="Host,";
|
||||||
http_first="[M] [U] [V]\r\nHost: [H]\r\n";
|
http_first="[M] [U] [V]\r\nHost: [H]\r\n";
|
||||||
@ -21,13 +21,16 @@ http {
|
|||||||
}
|
}
|
||||||
|
|
||||||
https {
|
https {
|
||||||
https_ip="2001:19f0:4401:2f:5400:3ff:fec4:e376";
|
https_ip="174.137.54.215";
|
||||||
https_port=129;
|
https_port=129;
|
||||||
https_del="Host,host,x-online-host";
|
https_del="Host,host,x-online-host";
|
||||||
https_first="[M] [U] [V]\r\nHost: [host]\r\n";
|
https_first="[M] [U] [V]\r\nHost: [host]\r\n";
|
||||||
strrep="Windows NT 10.0" -> "Linux";
|
|
||||||
strrep="Linux" -> "aixiao.me";
|
strrep="Windows NT 10.0" -> "aaaaaaaaaaaaaaaaaaa";
|
||||||
strrep="aixiao.me" -> "AIXIAO.ME";
|
strrep="aaaaaaaaaaaaaaaaaaa" -> "bbbbbbbbbbbbbbbb";
|
||||||
|
strrep="bbbbbbbbbbbbbbbb" -> "cccccccccccccccccc";
|
||||||
|
strrep="cccccccccccccccccc" -> "ddddddddddddddddddddddd";
|
||||||
|
|
||||||
regrep="Host*.+?" -> "host: [host]:443";
|
regrep="Host*.+?" -> "host: [host]:443";
|
||||||
regrep="host*.+?" -> "Host: [H]";
|
regrep="host*.+?" -> "Host: [H]";
|
||||||
regrep="host*.+?" -> "Host: [host]";
|
regrep="host*.+?" -> "Host: [host]";
|
||||||
|
@ -17,7 +17,6 @@ http {
|
|||||||
strrep="aixiao.me" -> "AIXIAO.ME";
|
strrep="aixiao.me" -> "AIXIAO.ME";
|
||||||
regrep="Accept-Encoding*.+?" -> "Accept-Encoding: GZIP, deflate";
|
regrep="Accept-Encoding*.+?" -> "Accept-Encoding: GZIP, deflate";
|
||||||
regrep="Connection*.+?" -> "Connection: KEEP-alive";
|
regrep="Connection*.+?" -> "Connection: KEEP-alive";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
https {
|
https {
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
## Help Information
|
## Help Information
|
||||||
|
|
||||||
CProxy proxy server
|
C Proxy Server
|
||||||
Author: aixiao@aixiao.me
|
Author: AIXIAO@AIXIAO.ME
|
||||||
Usage: [-?h] [-s signal] [-c filename]
|
Usage: [-?h] [-s signal] [-c filename]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
@ -544,6 +544,7 @@ static char *delete_head(char *head, const char *needle, int string)
|
|||||||
static char *conf_handle_strrep(char *str, int str_len, tcp *temp)
|
static char *conf_handle_strrep(char *str, int str_len, tcp *temp)
|
||||||
{
|
{
|
||||||
tcp *p = temp;
|
tcp *p = temp;
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
if (p->strrep) {
|
if (p->strrep) {
|
||||||
str = replace(str, &str_len, p->strrep_s, p->strrep_s_len, p->strrep_t, p->strrep_t_len);
|
str = replace(str, &str_len, p->strrep_s, p->strrep_s_len, p->strrep_t, p->strrep_t_len);
|
||||||
@ -613,7 +614,10 @@ char *request_head(conn_t * in, conf * configure)
|
|||||||
splice_head(incomplete_head, "\n", configure->https_first);
|
splice_head(incomplete_head, "\n", configure->https_first);
|
||||||
incomplete_head_len = strlen(incomplete_head); // 更新HTTPS HEADER长度
|
incomplete_head_len = strlen(incomplete_head); // 更新HTTPS HEADER长度
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
incomplete_head = conf_handle_strrep(incomplete_head, incomplete_head_len, https_head_strrep);
|
incomplete_head = conf_handle_strrep(incomplete_head, incomplete_head_len, https_head_strrep);
|
||||||
|
|
||||||
incomplete_head_len = strlen(incomplete_head) + 1; // 更新HTTPS HEADER长度
|
incomplete_head_len = strlen(incomplete_head) + 1; // 更新HTTPS HEADER长度
|
||||||
incomplete_head = conf_handle_regrep(incomplete_head, incomplete_head_len, https_head_regrep);
|
incomplete_head = conf_handle_regrep(incomplete_head, incomplete_head_len, https_head_regrep);
|
||||||
|
|
||||||
|
12
httpudp.c
12
httpudp.c
@ -71,12 +71,16 @@ static int createRspFd(info_t * client)
|
|||||||
setsockopt(client->responseClientFd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
|
setsockopt(client->responseClientFd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
|
||||||
setsockopt(client->responseClientFd, SOL_IP, IP_TRANSPARENT, &opt, sizeof(opt));
|
setsockopt(client->responseClientFd, SOL_IP, IP_TRANSPARENT, &opt, sizeof(opt));
|
||||||
//切换root伪装源目标地址
|
//切换root伪装源目标地址
|
||||||
seteuid(0);
|
if (-1 == seteuid(0))
|
||||||
setegid(0);
|
perror("seteuid");
|
||||||
|
if (-1 == setegid(0))
|
||||||
|
perror("setegid");
|
||||||
bind(client->responseClientFd, (struct sockaddr *)&client->toaddr, sizeof(struct sockaddr_in));
|
bind(client->responseClientFd, (struct sockaddr *)&client->toaddr, sizeof(struct sockaddr_in));
|
||||||
//切换回用户设置的uid
|
//切换回用户设置的uid
|
||||||
setegid(global.uid);
|
if (-1 == setegid(global.uid))
|
||||||
seteuid(global.uid);
|
perror("setegid");
|
||||||
|
if (-1 == seteuid(global.uid))
|
||||||
|
perror("seteuid");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
53
main.c
53
main.c
@ -29,7 +29,6 @@ int epollfd, server_sock, server_sock6, local_port, process;
|
|||||||
conn_t cts[MAX_CONNECTION];
|
conn_t cts[MAX_CONNECTION];
|
||||||
char local_host[CACHE_SIZE];
|
char local_host[CACHE_SIZE];
|
||||||
|
|
||||||
|
|
||||||
int create_server_socket(int port)
|
int create_server_socket(int port)
|
||||||
{
|
{
|
||||||
int server_sock;
|
int server_sock;
|
||||||
@ -270,8 +269,7 @@ int process_signal(int signal, char *process_name)
|
|||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
if (signal == SERVER_TYPE_STATUS)
|
if (signal == SERVER_TYPE_STATUS) ;
|
||||||
;
|
|
||||||
else if (signal == SERVICE_TYPE_STATUS_NOT_PRINT)
|
else if (signal == SERVICE_TYPE_STATUS_NOT_PRINT)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -444,8 +442,6 @@ void thread_loop(conf * configure)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _main(int argc, char *argv[])
|
void _main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
@ -459,29 +455,6 @@ void _main(int argc, char *argv[])
|
|||||||
memset(configure, 0, sizeof(struct CONF));
|
memset(configure, 0, sizeof(struct CONF));
|
||||||
read_conf(inifile, configure);
|
read_conf(inifile, configure);
|
||||||
|
|
||||||
// 反转链表,使读取的配置正序
|
|
||||||
http_head_strrep = local_reverse(http_head_strrep);
|
|
||||||
http_head_regrep = local_reverse(http_head_regrep);
|
|
||||||
|
|
||||||
https_head_strrep = local_reverse(https_head_strrep);
|
|
||||||
https_head_regrep = local_reverse(https_head_regrep);
|
|
||||||
|
|
||||||
/*
|
|
||||||
print_tcp(https_head_strrep);
|
|
||||||
print_tcp(https_head_regrep);
|
|
||||||
free_tcp(&https_head_strrep);
|
|
||||||
free_tcp(&https_head_regrep);
|
|
||||||
|
|
||||||
print_tcp(http_head_strrep);
|
|
||||||
print_tcp(http_head_regrep);
|
|
||||||
free_tcp(&http_head_strrep);
|
|
||||||
free_tcp(&http_head_regrep);
|
|
||||||
|
|
||||||
free_conf(configure);
|
|
||||||
free(configure);
|
|
||||||
exit(0);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
sslEncodeCode = 0; // 默认SSL不转码
|
sslEncodeCode = 0; // 默认SSL不转码
|
||||||
if (configure->sslencoding > 0) // 如果配置文件有sslencoding值,优先使用配置文件读取的值
|
if (configure->sslencoding > 0) // 如果配置文件有sslencoding值,优先使用配置文件读取的值
|
||||||
@ -568,9 +541,31 @@ void _main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
server_ini(); // 守护进程
|
server_ini(); // 守护进程
|
||||||
|
|
||||||
|
// 反转链表,使读取的配置正序
|
||||||
|
http_head_strrep = local_reverse(http_head_strrep);
|
||||||
|
http_head_regrep = local_reverse(http_head_regrep);
|
||||||
|
|
||||||
|
https_head_strrep = local_reverse(https_head_strrep);
|
||||||
|
https_head_regrep = local_reverse(https_head_regrep);
|
||||||
|
|
||||||
|
/*
|
||||||
|
print_tcp(https_head_strrep);
|
||||||
|
print_tcp(https_head_regrep);
|
||||||
|
free_tcp(&https_head_strrep);
|
||||||
|
free_tcp(&https_head_regrep);
|
||||||
|
|
||||||
|
print_tcp(http_head_strrep);
|
||||||
|
print_tcp(http_head_regrep);
|
||||||
|
free_tcp(&http_head_strrep);
|
||||||
|
free_tcp(&http_head_regrep);
|
||||||
|
|
||||||
|
free_conf(configure);
|
||||||
|
free(configure);
|
||||||
|
exit(0);
|
||||||
|
*/
|
||||||
|
|
||||||
rt.rlim_max = rt.rlim_cur = MAX_CONNECTION * 2; // 设置每个进程允许打开的最大文件数
|
rt.rlim_max = rt.rlim_cur = MAX_CONNECTION * 2; // 设置每个进程允许打开的最大文件数
|
||||||
if (setrlimit(RLIMIT_NOFILE, &rt) == -1)
|
if (setrlimit(RLIMIT_NOFILE, &rt) == -1)
|
||||||
perror("setrlimit");
|
perror("setrlimit");
|
||||||
|
Loading…
Reference in New Issue
Block a user