diff --git a/README.md b/README.md index e78bb1e..4cf0c04 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Usage: [-?hdsc] [-s signal] [-c filename] Options: - -h : help information - -d : daemon - -s signal : send signal to a master process: stop - -c filename : set configuration file (default: conf/cproxy.ini) + -?,-h : help information + -d : daemon + -s signal : send signal to a master process: stop + -c filename : set configuration file (default: conf/cproxy.ini) - May 7 2019 18:48:10 Compile、link. \ No newline at end of file + May 7 2019 18:48:10 Compile、link. diff --git a/conf.c b/conf.c index cf00967..10dd7e0 100644 --- a/conf.c +++ b/conf.c @@ -212,5 +212,5 @@ void free_conf(conf *p) free(p->https_regrep); free(p->https_regrep_aim); free(p->https_regrep_obj); - } + diff --git a/conf.h b/conf.h index 5a59a52..05ac947 100644 --- a/conf.h +++ b/conf.h @@ -4,6 +4,7 @@ #include "iniparser.h" #include "cproxy.h" #include + char *strncpy_(char *dest, const char *src, size_t n); void read_conf(char *file, conf *p); void free_conf(conf *p); diff --git a/conf/cproxy.ini b/conf/cproxy.ini index c767782..507c7e9 100644 --- a/conf/cproxy.ini +++ b/conf/cproxy.ini @@ -8,7 +8,6 @@ http_port=80; http_del="x-online-host,X-Online-Host,host,Host"; http_first="[M] [U] [V]\r\n.aixiao.me\rx-online-host: [host]\r\nhost: iread.wo.cn\r\n"; strrep = "Mi MIX 2->Linux"; -;regrep = "host*.+?->host: iread.wo.cn"; [https] https_ip=10.0.0.172; @@ -17,3 +16,4 @@ https_del=",Host"; https_first="[M] iread.wo.cn//https://[host]:[port]#iread.wo.cn [V]\r\nhost: iread.wo.cn:443\r\n"; strrep = "Mi MIX 2->Linux"; regrep = "Host*.+?->Host: iread.wo.cn:443"; + diff --git a/conf/cproxy.ini.explain b/conf/cproxy.ini.explain index 7c9226a..9c7df31 100644 --- a/conf/cproxy.ini.explain +++ b/conf/cproxy.ini.explain @@ -1,5 +1,5 @@ 模块: [server], [http], [https] -[server]模块: +[server]模块 PORT 端口 PID_FILE pid文件 @@ -10,8 +10,9 @@ PID_FILE pid文件 [host] 原请求host [port] 原请求端口 -关键字strrep替换字符串指令 +关键字strrep替换字符串指令. strrep = "Mi MIX 2->Linux"; 以"->"为分界符,"Mi MIX 2"字符串替换为"Linux"字符串. -关键字regrep正则匹配替换字符串 +关键字regrep正则匹配替换字符串. regrep = "Host*.+?->Host: iread.wo.cn:443"; 以"->"为分界符,匹配到的内容"Host*.+?"替换为"Host: iread.wo.cn:443"字符串. + diff --git a/cproxy.c b/cproxy.c index 7b90b5b..b6e6c5a 100644 --- a/cproxy.c +++ b/cproxy.c @@ -328,6 +328,7 @@ int _main(int argc, char *argv[]) exit(0); break; case 'c': + free_conf(configure); // 如果指定-c参数就释放上次分配的内存 inifile=optarg; read_conf(inifile, configure); break; @@ -351,3 +352,4 @@ int main(int argc, char *argv[]) { return _main(argc, argv); } + diff --git a/cproxy.h b/cproxy.h index 6868f05..46cb38b 100644 --- a/cproxy.h +++ b/cproxy.h @@ -103,3 +103,4 @@ void rewrite_header(); char help_information(void); #endif + diff --git a/cproxy_help.c b/cproxy_help.c index ac2291c..121d94c 100644 --- a/cproxy_help.c +++ b/cproxy_help.c @@ -15,10 +15,10 @@ char help_information(void) static const char *s_help[] = { "", "Options:", - " -h : help information", - " -d : daemon", - " -s signal : send signal to a master process: stop", - " -c filename : set configuration file (default: conf/cproxy.ini)", + " -?,-h : help information", + " -d : daemon", + " -s signal : send signal to a master process: stop", + " -c filename : set configuration file (default: conf/cproxy.ini)", "", 0 }; diff --git a/cproxy_help.h b/cproxy_help.h index db3e7ca..a0880c1 100644 --- a/cproxy_help.h +++ b/cproxy_help.h @@ -4,6 +4,7 @@ #include #include "cproxy.h" #define BUILD(fmt...) do { fprintf(stderr,"%s %s ",__DATE__,__TIME__); fprintf(stderr, ##fmt); } while(0) + char help_information(void); #endif diff --git a/cproxy_request.c b/cproxy_request.c index 4a90e16..70c2bdd 100644 --- a/cproxy_request.c +++ b/cproxy_request.c @@ -490,7 +490,6 @@ int replacement_http_head(char *header_buffer, char *remote_host, int *remote_po char *M = malloc(l + 1); if (M) { strncpy_(M, HTTPS_HEAD, l); - //printf("%s", M); } else { free(M); return 0; @@ -587,3 +586,4 @@ int replacement_http_head(char *header_buffer, char *remote_host, int *remote_po free(header_buffer_backup); return 1; } + diff --git a/cproxy_request.h b/cproxy_request.h index 2c1cf44..2811ea9 100644 --- a/cproxy_request.h +++ b/cproxy_request.h @@ -6,6 +6,7 @@ #include #include #include "cproxy.h" + void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen); char *replace(char *replace_memory, int *replace_memory_len, const char *src, const int src_len, const char *dest, const int dest_len); void del_chr(char *s, char ch); diff --git a/log/cproxy.pid b/log/cproxy.pid index 0863c8e..c2a7542 100644 --- a/log/cproxy.pid +++ b/log/cproxy.pid @@ -1 +1 @@ -22338 \ No newline at end of file +8604 \ No newline at end of file