• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修订版2fd9c5897aba37847879033dd1cffd345ced93fc (tree)
时间2009-05-21 09:16:00
作者San Mehat <san@goog...>
CommiterSan Mehat

Log Message

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

更改概述

差异

--- a/nexus/OpenVpnController.cpp
+++ b/nexus/OpenVpnController.cpp
@@ -26,6 +26,7 @@
2626 #include "OpenVpnController.h"
2727
2828 #define DAEMON_PROP_NAME "vpn.openvpn.status"
29+
2930 #define DAEMON_CONFIG_FILE "/data/misc/openvpn/openvpn.conf"
3031
3132 OpenVpnController::OpenVpnController() :
@@ -46,13 +47,16 @@ int OpenVpnController::stop() {
4647 }
4748
4849 int OpenVpnController::enable() {
49-
50- if (validateConfig()) {
51- LOGE("Error validating configuration file");
50+ char svc[PROPERTY_VALUE_MAX];
51+ char tmp[64];
52+
53+ if (!getProperty("vpn.gateway", tmp, sizeof(tmp))) {
54+ LOGE("Error reading property 'vpn.gateway' (%s)", strerror(errno));
5255 return -1;
5356 }
57+ snprintf(svc, sizeof(svc), "openvpn:--remote %s 1194", tmp);
5458
55- if (mServiceManager->start("openvpn"))
59+ if (mServiceManager->start(svc))
5660 return -1;
5761
5862 return 0;
@@ -64,15 +68,3 @@ int OpenVpnController::disable() {
6468 return -1;
6569 return 0;
6670 }
67-
68-int OpenVpnController::validateConfig() {
69- unlink(DAEMON_CONFIG_FILE);
70-
71- FILE *fp = fopen(DAEMON_CONFIG_FILE, "w");
72- if (!fp)
73- return -1;
74-
75- fprintf(fp, "remote %s 1194\n", inet_ntoa(getVpnGateway()));
76- fclose(fp);
77- return 0;
78-}
--- a/nexus/OpenVpnController.h
+++ b/nexus/OpenVpnController.h
@@ -33,11 +33,6 @@ public:
3333 int stop();
3434 int enable();
3535 int disable();
36-
37-protected:
38-
39-private:
40- int validateConfig();
4136 };
4237
4338 #endif