Release configuration file memory
This commit is contained in:
parent
94f16b1f11
commit
3538b77afc
@ -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.
|
2
conf.c
2
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);
|
||||
|
||||
}
|
||||
|
||||
|
1
conf.h
1
conf.h
@ -4,6 +4,7 @@
|
||||
#include "iniparser.h"
|
||||
#include "cproxy.h"
|
||||
#include <unistd.h>
|
||||
|
||||
char *strncpy_(char *dest, const char *src, size_t n);
|
||||
void read_conf(char *file, conf *p);
|
||||
void free_conf(conf *p);
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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"字符串.
|
||||
|
||||
|
2
cproxy.c
2
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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#include "cproxy.h"
|
||||
#define BUILD(fmt...) do { fprintf(stderr,"%s %s ",__DATE__,__TIME__); fprintf(stderr, ##fmt); } while(0)
|
||||
|
||||
char help_information(void);
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <regex.h>
|
||||
#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);
|
||||
|
@ -1 +1 @@
|
||||
22338
|
||||
8604
|
Loading…
Reference in New Issue
Block a user