mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-24 02:55:40 +08:00
ssl_plugin: configuration commands added
plugin /path_to/SslPlugin.dll ssl_plugin ssl_certpath /path_to/certificates/ ssl_strip proxy -p3128 ssl_nostrip proxy -p3129
This commit is contained in:
parent
d9271bfec8
commit
347d7736c7
@ -325,6 +325,47 @@ static struct filter ssl_filter = {
|
|||||||
ssl_filter_close
|
ssl_filter_close
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int strip = 0;
|
||||||
|
|
||||||
|
static int h_strip(int argc, unsigned char **argv){
|
||||||
|
if((strip&1)) return 1;
|
||||||
|
if(strip) usleep(100*SLEEPTIME);
|
||||||
|
ssl_filter.next = pl->conf->filters;
|
||||||
|
pl->conf->filters = &ssl_filter;
|
||||||
|
strip++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int h_nostrip(int argc, unsigned char **argv){
|
||||||
|
struct filter * sf;
|
||||||
|
if(!(strip&1)) return 1;
|
||||||
|
if(strip) usleep(100*SLEEPTIME);
|
||||||
|
if(pl->conf->filters == &ssl_filter) pl->conf->filters = ssl_filter.next;
|
||||||
|
else for(sf = pl->conf->filters; sf && sf->next; sf=sf->next){
|
||||||
|
if(sf->next == &ssl_filter) {
|
||||||
|
sf->next = ssl_filter.next;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strip++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int h_certpath(int argc, unsigned char **argv){
|
||||||
|
size_t len;
|
||||||
|
len = strlen(argv[1]);
|
||||||
|
if(!len || (argv[1][len - 1] != '/' && argv[1][len - 1] != '\\')) return 1;
|
||||||
|
if(cert_path && *cert_path) free(cert_path);
|
||||||
|
cert_path = strdup(argv[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct commands ssl_commandhandlers[] = {
|
||||||
|
{ssl_commandhandlers+1, "ssl_strip", h_strip, 1, 1},
|
||||||
|
{ssl_commandhandlers+2, "ssl_nostrip", h_nostrip, 1, 1},
|
||||||
|
{NULL, "ssl_certpath", h_certpath, 2, 2},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
__declspec(dllexport)
|
__declspec(dllexport)
|
||||||
@ -333,15 +374,9 @@ __declspec(dllexport)
|
|||||||
int ssl_plugin (struct pluginlink * pluginlink,
|
int ssl_plugin (struct pluginlink * pluginlink,
|
||||||
int argc, char** argv){
|
int argc, char** argv){
|
||||||
pl = pluginlink;
|
pl = pluginlink;
|
||||||
if(argc > 1) {
|
|
||||||
if(cert_path && *cert_path) free(cert_path);
|
|
||||||
cert_path = strdup(argv[1]);
|
|
||||||
}
|
|
||||||
if(!ssl_loaded){
|
if(!ssl_loaded){
|
||||||
ssl_loaded = 1;
|
ssl_loaded = 1;
|
||||||
pthread_mutex_init(&ssl_mutex, NULL);
|
pthread_mutex_init(&ssl_mutex, NULL);
|
||||||
ssl_filter.next = pl->conf->filters;
|
|
||||||
pl->conf->filters = &ssl_filter;
|
|
||||||
memcpy(&sso, pl->so, sizeof(struct sockfuncs));
|
memcpy(&sso, pl->so, sizeof(struct sockfuncs));
|
||||||
pl->so->_send = ssl_send;
|
pl->so->_send = ssl_send;
|
||||||
pl->so->_recv = ssl_recv;
|
pl->so->_recv = ssl_recv;
|
||||||
@ -349,10 +384,13 @@ __declspec(dllexport)
|
|||||||
pl->so->_recvfrom = ssl_recvfrom;
|
pl->so->_recvfrom = ssl_recvfrom;
|
||||||
pl->so->_closesocket = ssl_closesocket;
|
pl->so->_closesocket = ssl_closesocket;
|
||||||
pl->so->_poll = ssl_poll;
|
pl->so->_poll = ssl_poll;
|
||||||
|
ssl_commandhandlers[2].next = pl->commandhandlers->next;
|
||||||
|
pl->commandhandlers->next = ssl_commandhandlers;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
ssl_release();
|
ssl_release();
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl_init();
|
ssl_init();
|
||||||
tcppmfunc = (PROXYFUNC)pl->findbyname("tcppm");
|
tcppmfunc = (PROXYFUNC)pl->findbyname("tcppm");
|
||||||
if(!tcppmfunc){return 13;}
|
if(!tcppmfunc){return 13;}
|
||||||
|
Loading…
Reference in New Issue
Block a user