Release configuration file memory
This commit is contained in:
parent
94f16b1f11
commit
3538b77afc
@ -18,7 +18,7 @@
|
|||||||
Usage: [-?hdsc] [-s signal] [-c filename]
|
Usage: [-?hdsc] [-s signal] [-c filename]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h : help information
|
-?,-h : help information
|
||||||
-d : daemon
|
-d : daemon
|
||||||
-s signal : send signal to a master process: stop
|
-s signal : send signal to a master process: stop
|
||||||
-c filename : set configuration file (default: conf/cproxy.ini)
|
-c filename : set configuration file (default: conf/cproxy.ini)
|
||||||
|
2
conf.c
2
conf.c
@ -212,5 +212,5 @@ void free_conf(conf *p)
|
|||||||
free(p->https_regrep);
|
free(p->https_regrep);
|
||||||
free(p->https_regrep_aim);
|
free(p->https_regrep_aim);
|
||||||
free(p->https_regrep_obj);
|
free(p->https_regrep_obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
conf.h
1
conf.h
@ -4,6 +4,7 @@
|
|||||||
#include "iniparser.h"
|
#include "iniparser.h"
|
||||||
#include "cproxy.h"
|
#include "cproxy.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
char *strncpy_(char *dest, const char *src, size_t n);
|
char *strncpy_(char *dest, const char *src, size_t n);
|
||||||
void read_conf(char *file, conf *p);
|
void read_conf(char *file, conf *p);
|
||||||
void free_conf(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_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";
|
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";
|
strrep = "Mi MIX 2->Linux";
|
||||||
;regrep = "host*.+?->host: iread.wo.cn";
|
|
||||||
|
|
||||||
[https]
|
[https]
|
||||||
https_ip=10.0.0.172;
|
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";
|
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";
|
strrep = "Mi MIX 2->Linux";
|
||||||
regrep = "Host*.+?->Host: iread.wo.cn:443";
|
regrep = "Host*.+?->Host: iread.wo.cn:443";
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
模块: [server], [http], [https]
|
模块: [server], [http], [https]
|
||||||
[server]模块:
|
[server]模块
|
||||||
PORT 端口
|
PORT 端口
|
||||||
PID_FILE pid文件
|
PID_FILE pid文件
|
||||||
|
|
||||||
@ -10,8 +10,9 @@ PID_FILE pid文件
|
|||||||
[host] 原请求host
|
[host] 原请求host
|
||||||
[port] 原请求端口
|
[port] 原请求端口
|
||||||
|
|
||||||
关键字strrep替换字符串指令
|
关键字strrep替换字符串指令.
|
||||||
strrep = "Mi MIX 2->Linux"; 以"->"为分界符,"Mi MIX 2"字符串替换为"Linux"字符串.
|
strrep = "Mi MIX 2->Linux"; 以"->"为分界符,"Mi MIX 2"字符串替换为"Linux"字符串.
|
||||||
|
|
||||||
关键字regrep正则匹配替换字符串
|
关键字regrep正则匹配替换字符串.
|
||||||
regrep = "Host*.+?->Host: iread.wo.cn:443"; 以"->"为分界符,匹配到的内容"Host*.+?"替换为"Host: iread.wo.cn:443"字符串.
|
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);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
free_conf(configure); // 如果指定-c参数就释放上次分配的内存
|
||||||
inifile=optarg;
|
inifile=optarg;
|
||||||
read_conf(inifile, configure);
|
read_conf(inifile, configure);
|
||||||
break;
|
break;
|
||||||
@ -351,3 +352,4 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
return _main(argc, argv);
|
return _main(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
cproxy.h
1
cproxy.h
@ -103,3 +103,4 @@ void rewrite_header();
|
|||||||
char help_information(void);
|
char help_information(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ char help_information(void)
|
|||||||
static const char *s_help[] = {
|
static const char *s_help[] = {
|
||||||
"",
|
"",
|
||||||
"Options:",
|
"Options:",
|
||||||
" -h : help information",
|
" -?,-h : help information",
|
||||||
" -d : daemon",
|
" -d : daemon",
|
||||||
" -s signal : send signal to a master process: stop",
|
" -s signal : send signal to a master process: stop",
|
||||||
" -c filename : set configuration file (default: conf/cproxy.ini)",
|
" -c filename : set configuration file (default: conf/cproxy.ini)",
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "cproxy.h"
|
#include "cproxy.h"
|
||||||
#define BUILD(fmt...) do { fprintf(stderr,"%s %s ",__DATE__,__TIME__); fprintf(stderr, ##fmt); } while(0)
|
#define BUILD(fmt...) do { fprintf(stderr,"%s %s ",__DATE__,__TIME__); fprintf(stderr, ##fmt); } while(0)
|
||||||
|
|
||||||
char help_information(void);
|
char help_information(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -490,7 +490,6 @@ int replacement_http_head(char *header_buffer, char *remote_host, int *remote_po
|
|||||||
char *M = malloc(l + 1);
|
char *M = malloc(l + 1);
|
||||||
if (M) {
|
if (M) {
|
||||||
strncpy_(M, HTTPS_HEAD, l);
|
strncpy_(M, HTTPS_HEAD, l);
|
||||||
//printf("%s", M);
|
|
||||||
} else {
|
} else {
|
||||||
free(M);
|
free(M);
|
||||||
return 0;
|
return 0;
|
||||||
@ -587,3 +586,4 @@ int replacement_http_head(char *header_buffer, char *remote_host, int *remote_po
|
|||||||
free(header_buffer_backup);
|
free(header_buffer_backup);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include "cproxy.h"
|
#include "cproxy.h"
|
||||||
|
|
||||||
void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen);
|
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);
|
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);
|
void del_chr(char *s, char ch);
|
||||||
|
@ -1 +1 @@
|
|||||||
22338
|
8604
|
Loading…
Reference in New Issue
Block a user