Beispiel #1
0
void info_cmd(sock_t fd, char *options, unsigned int nb_options)
{
	char msg[BUFSIZE] = {0, };
	char *msg2 = NULL;
	
	snprintf(msg, BUFSIZE,
		 "Infos:\n"
		 "- Listening interface: %s/%s\n"
		 "- Supported IP version: %s\n"
		 "- Logging to %s\n"
		 "- Running/Max threads: %d/%d\n"
		 "- SSL private key: %s\n"
		 "- SSL certificate: %s\n"
		 "- Proxy: %s [%s]\n"
		 "- Plugins directory: %s\n"
		 , 
		 cfg->iface, cfg->port,
		 (cfg->ip_version==AF_INET)? "IPv4": (cfg->ip_version==AF_INET6)?"IPv6": "ANY",
		 (cfg->logfile)?cfg->logfile:"stdout",
		 get_active_threads_size(), cfg->nb_threads,
		 cfg->keyfile,
		 cfg->certfile,
		 cfg->proxy.host ? cfg->proxy.host : "None",
		 cfg->proxy.host ? cfg->proxy.port : "direct",
		 cfg->plugins_path  
		);

	proxenet_write(fd, (void*)msg, strlen(msg));
	
	if (proxenet_plugin_list_size()) {
		msg2 = proxenet_build_plugins_list();
		proxenet_write(fd, (void*)msg2, strlen(msg2));
		proxenet_xfree(msg2);

	} else {
		proxenet_write(fd, (void*)"No plugin loaded\n", 17);
	}
	
	return;
}
Beispiel #2
0
void proxenet_print_plugins_list(int fd)
{
	char *list_str;
	int list_len;

	list_len = 2048;
	list_str = (char*)alloca(list_len);
	memset(list_str, 0, list_len);

	if (!proxenet_build_plugins_list(list_str, &list_len)) {
		xlog(LOG_ERROR, "%s\n", "Failed to build plugins list string");
		return;
	}

	if (fd<0)
		xlog(LOG_INFO, "%s", list_str);
	else {
		proxenet_write(fd, list_str, list_len);
		proxenet_write(fd, "\n", 1);
	}

        return;
}
Beispiel #3
0
void plugin_cmd(sock_t fd, char *options, unsigned int nb_options)
{
	char msg[BUFSIZE] = {0, };
	char *ptr, *plist_str;
	int n, res;
	
	ptr = strtok(options, " \n");
	if (!ptr){
		n = snprintf(msg, BUFSIZE, "Invalid action\nSyntax\n plugin [list]|[toggle <num>]\n");
		proxenet_write(fd, (void*)msg, n);
		return;
	}

	if (strcmp(ptr, "list") == 0) {
		plist_str = proxenet_build_plugins_list();
		proxenet_write(fd, (void*)plist_str, strlen(plist_str));
		proxenet_xfree(plist_str);
		return;
		
	} else if (strcmp(ptr, "toggle") == 0) {
		ptr = strtok(NULL, " \n");
		if (!ptr)
			return;

		n = atoi(ptr);
		if (0 < n && n <= proxenet_plugin_list_size() ) {
			res = proxenet_toggle_plugin(n);
			n = snprintf(msg, BUFSIZE, "Plugin %d is now %sACTIVE\n", n, res?"":"IN");
			proxenet_write(fd, (void*)msg, n);
			return;
		}
	}
	
	n = snprintf(msg, BUFSIZE, "Invalid action\nSyntax\n plugin [list]|[toggle <num>]\n");
	proxenet_write(fd, (void*)msg, n);
	return;
}