Просмотр исходного кода

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
z3APA3A 10 лет назад
Родитель
Сommit
347d7736c7
1 измененных файлов с 45 добавлено и 7 удалено
  1. 45 7
      src/plugins/SSLPlugin/ssl_plugin.c

+ 45 - 7
src/plugins/SSLPlugin/ssl_plugin.c

@@ -325,6 +325,47 @@ static struct filter ssl_filter = {
 	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
 __declspec(dllexport)
@@ -333,15 +374,9 @@ __declspec(dllexport)
  int ssl_plugin (struct pluginlink * pluginlink, 
 					 int argc, char** argv){
 	pl = pluginlink;
-	if(argc > 1) {
-		if(cert_path && *cert_path) free(cert_path);
-		cert_path = strdup(argv[1]);
-	}
 	if(!ssl_loaded){
 		ssl_loaded = 1;
 		pthread_mutex_init(&ssl_mutex, NULL);
-		ssl_filter.next = pl->conf->filters;
-		pl->conf->filters = &ssl_filter;
 		memcpy(&sso, pl->so, sizeof(struct sockfuncs));
 		pl->so->_send = ssl_send;
 		pl->so->_recv = ssl_recv;
@@ -349,10 +384,13 @@ __declspec(dllexport)
 		pl->so->_recvfrom = ssl_recvfrom;
 		pl->so->_closesocket = ssl_closesocket;
 		pl->so->_poll = ssl_poll;
+		ssl_commandhandlers[2].next = pl->commandhandlers->next;
+		pl->commandhandlers->next = ssl_commandhandlers;
 	}
-	else{
+	else {
 		ssl_release();
 	}
+
 	ssl_init();
 	tcppmfunc = (PROXYFUNC)pl->findbyname("tcppm");	
 	if(!tcppmfunc){return 13;}