2011-07-28 Dario Rodriguez <dario.rodriguez@artica.es>
* pandora_windows_service.h, pandora_windows_service.cc: Added proxy mode feature. * bin/PandoraAgent.exe: Created new compiled version with proxy mode feature. * bin/pandora_agent.conf: Added new parameters to configure proxy mode. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4646 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c2bdee86f1
commit
5420de75b4
|
@ -1,3 +1,11 @@
|
|||
2011-07-28 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||
|
||||
* pandora_windows_service.h, pandora_windows_service.cc: Added proxy
|
||||
mode feature.
|
||||
* bin/PandoraAgent.exe: Created new compiled version with proxy mode
|
||||
feature.
|
||||
* bin/pandora_agent.conf: Added new parameters to configure proxy mode.
|
||||
|
||||
2011-07-28 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* bin/util/tentacle_server.exe: Tentacle server executable to use it
|
||||
|
|
Binary file not shown.
|
@ -64,6 +64,15 @@ server_port 41121
|
|||
# Set XML encoding (ISO-8859-1 by default).
|
||||
#encoding ISO-8859-1
|
||||
|
||||
# If set to 1 start Drone Agent's Proxy Mode
|
||||
# proxy_mode 1
|
||||
|
||||
# Max number of simmultaneus connection for proxy (by default 10)
|
||||
# proxy_max_connection 10
|
||||
|
||||
# Proxy timeout (by default 1s)
|
||||
# proxy_timeout 1
|
||||
|
||||
# Enable or disable XML buffer.
|
||||
xml_buffer 0
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <pandora_agent_conf.h>
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Pandora;
|
||||
|
@ -81,6 +82,10 @@ Pandora_Windows_Service::setValues (const char * svc_name,
|
|||
* Destroys a Pandora_Windows_Service object.
|
||||
*/
|
||||
Pandora_Windows_Service::~Pandora_Windows_Service () {
|
||||
|
||||
if(conf->getValue("proxy_mode") != "") {
|
||||
killTentacleProxy();
|
||||
}
|
||||
|
||||
if (this->conf != NULL) {
|
||||
delete this->conf;
|
||||
|
@ -206,6 +211,7 @@ Pandora_Windows_Service::pandora_init () {
|
|||
string conf_file, interval, debug, transfer_interval, util_dir, path, env;
|
||||
string udp_server_enabled, udp_server_port, udp_server_addr, udp_server_auth_addr;
|
||||
string name_agent, name;
|
||||
string proxy_mode, server_ip;
|
||||
int pos, num;
|
||||
|
||||
setPandoraDebug (true);
|
||||
|
@ -262,6 +268,13 @@ Pandora_Windows_Service::pandora_init () {
|
|||
|
||||
srand ((unsigned) time (0));
|
||||
this->setSleepTime (this->interval);
|
||||
|
||||
/*Check if proxy mode is set*/
|
||||
proxy_mode = conf->getValue ("proxy_mode");
|
||||
|
||||
if (proxy_mode != "") {
|
||||
lauchTentacleProxy();
|
||||
}
|
||||
|
||||
pandoraLog ("Pandora agent started");
|
||||
|
||||
|
@ -276,6 +289,70 @@ Pandora_Windows_Service::pandora_init () {
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
Pandora_Windows_Service::killTentacleProxy() {
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFO si;
|
||||
string kill_cmd;
|
||||
|
||||
kill_cmd = "taskkill.exe /F /IM tentacle_server.exe";
|
||||
|
||||
ZeroMemory (&si, sizeof (si));
|
||||
ZeroMemory (&pi, sizeof (pi));
|
||||
if (CreateProcess (NULL , (CHAR *)kill_cmd.c_str (), NULL, NULL, FALSE,
|
||||
CREATE_NO_WINDOW, NULL, NULL, &si, &pi) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
Pandora_Windows_Service::lauchTentacleProxy() {
|
||||
string server_ip, server_port, proxy_max_connections, proxy_timeout;
|
||||
string proxy_cmd;
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFO si;
|
||||
|
||||
/*Check if server proxy is localhost*/
|
||||
server_ip = conf->getValue("server_ip");
|
||||
|
||||
if (server_ip != "localhost") {
|
||||
proxy_max_connections = conf->getValue("proxy_max_connection");
|
||||
|
||||
if (proxy_max_connections == "") {
|
||||
proxy_max_connections = "10";
|
||||
}
|
||||
|
||||
proxy_timeout = conf->getValue("proxy_timeout");
|
||||
|
||||
if (proxy_timeout == "") {
|
||||
proxy_timeout = "1";
|
||||
}
|
||||
|
||||
server_port = conf->getValue("server_port");
|
||||
|
||||
if (server_port == "") {
|
||||
server_port = "41121";
|
||||
}
|
||||
|
||||
proxy_cmd = "tentacle_server.exe -b " + server_ip + " -g " + server_port + " -c " + proxy_max_connections + " -t " + proxy_timeout + "-d";
|
||||
|
||||
pandoraLog("Proxy mode enabled");
|
||||
|
||||
ZeroMemory (&si, sizeof (si));
|
||||
ZeroMemory (&pi, sizeof (pi));
|
||||
if (CreateProcess (NULL , (CHAR *)proxy_cmd.c_str (), NULL, NULL, FALSE,
|
||||
CREATE_NO_WINDOW, NULL, NULL, &si, &pi) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
} else {
|
||||
pandoraLog ("[error] You can not proxy to localhost");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
string
|
||||
Pandora_Windows_Service::getXmlHeader () {
|
||||
char timestamp[20];
|
||||
|
|
|
@ -80,6 +80,8 @@ namespace Pandora {
|
|||
void pandora_run_broker (string config);
|
||||
int count_broker_agents();
|
||||
void check_broker_agents(string *all_conf);
|
||||
int lauchTentacleProxy();
|
||||
int killTentacleProxy();
|
||||
|
||||
Pandora_Windows_Service ();
|
||||
|
||||
|
|
Loading…
Reference in New Issue