nexus: OpenVPN: Instead of creating / using a configfile, use the new
dynamic service argument support so we don't need one :) Signed-off-by: San Mehat <san@google.com> nexus: fix property max
This commit is contained in:
parent
a61755e5fc
commit
2fd9c5897a
2 changed files with 8 additions and 21 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
#include "OpenVpnController.h"
|
#include "OpenVpnController.h"
|
||||||
|
|
||||||
#define DAEMON_PROP_NAME "vpn.openvpn.status"
|
#define DAEMON_PROP_NAME "vpn.openvpn.status"
|
||||||
|
|
||||||
#define DAEMON_CONFIG_FILE "/data/misc/openvpn/openvpn.conf"
|
#define DAEMON_CONFIG_FILE "/data/misc/openvpn/openvpn.conf"
|
||||||
|
|
||||||
OpenVpnController::OpenVpnController() :
|
OpenVpnController::OpenVpnController() :
|
||||||
|
|
@ -46,13 +47,16 @@ int OpenVpnController::stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenVpnController::enable() {
|
int OpenVpnController::enable() {
|
||||||
|
char svc[PROPERTY_VALUE_MAX];
|
||||||
if (validateConfig()) {
|
char tmp[64];
|
||||||
LOGE("Error validating configuration file");
|
|
||||||
|
if (!getProperty("vpn.gateway", tmp, sizeof(tmp))) {
|
||||||
|
LOGE("Error reading property 'vpn.gateway' (%s)", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
snprintf(svc, sizeof(svc), "openvpn:--remote %s 1194", tmp);
|
||||||
|
|
||||||
if (mServiceManager->start("openvpn"))
|
if (mServiceManager->start(svc))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -64,15 +68,3 @@ int OpenVpnController::disable() {
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenVpnController::validateConfig() {
|
|
||||||
unlink(DAEMON_CONFIG_FILE);
|
|
||||||
|
|
||||||
FILE *fp = fopen(DAEMON_CONFIG_FILE, "w");
|
|
||||||
if (!fp)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
fprintf(fp, "remote %s 1194\n", inet_ntoa(getVpnGateway()));
|
|
||||||
fclose(fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,6 @@ public:
|
||||||
int stop();
|
int stop();
|
||||||
int enable();
|
int enable();
|
||||||
int disable();
|
int disable();
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
private:
|
|
||||||
int validateConfig();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue