From: Michael Tremer Date: Wed, 27 Jul 2011 16:40:12 +0000 (+0200) Subject: openvpnctrl: Add option to start all n2n connections at once. X-Git-Tag: v2.9-core53~29^2~3^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fopenvpn-n2n;p=ipfire-2.x.git openvpnctrl: Add option to start all n2n connections at once. --- diff --git a/src/misc-progs/openvpnctrl.c b/src/misc-progs/openvpnctrl.c index 758800da16..163386b43a 100644 --- a/src/misc-progs/openvpnctrl.c +++ b/src/misc-progs/openvpnctrl.c @@ -25,7 +25,7 @@ char enableorange[STRING_SIZE] = "off"; char OVPNRED[STRING_SIZE] = "OVPN"; char OVPNBLUE[STRING_SIZE] = "OVPN_BLUE_"; char OVPNORANGE[STRING_SIZE] = "OVPN_ORANGE_"; -char WRAPPERVERSION[STRING_SIZE] = "ipfire-2.1.2"; +char WRAPPERVERSION[STRING_SIZE] = "ipfire-2.2.0"; struct connection_struct { char name[STRING_SIZE]; @@ -60,6 +60,12 @@ void usage(void) printf(" kills/stops OpenVPN\n"); printf(" -r --restart\n"); printf(" restarts OpenVPN (implicitly creates chains and firewall rules)\n"); + printf(" -sn2n --start-net-2-net\n"); + printf(" starts all net2net connections\n"); + printf(" you may pass a connection name to the switch to only start a specific one\n"); + printf(" -kn2n --kill-net-2-net\n"); + printf(" kills all net2net connections\n"); + printf(" you may pass a connection name to the switch to only start a specific one\n"); printf(" -d --display\n"); printf(" displays OpenVPN status to syslog\n"); printf(" -fwr --firewall-rules\n"); @@ -482,6 +488,28 @@ void killNet2Net(char *name) { exit(0); } +void startAllNet2Net() { + connection *conn = getConnections(); + + while(conn) { + startNet2Net(conn->name); + conn = conn->next; + } + + exit(0); +} + +void killAllNet2Net() { + connection *conn = getConnections(); + + while(conn) { + killNet2Net(conn->name); + conn = conn->next; + } + + exit(0); +} + void displayopenvpn(void) { char command[STRING_SIZE]; @@ -533,6 +561,14 @@ int main(int argc, char *argv[]) { startDaemon(); return 0; } + else if( (strcmp(argv[1], "-sn2n") == 0) || (strcmp(argv[1], "--start-net-2-net") == 0) ) { + startAllNet2Net(); + return 0; + } + else if( (strcmp(argv[1], "-kn2n") == 0) || (strcmp(argv[1], "--kill-net-2-net") == 0) ) { + killAllNet2Net(); + return 0; + } else if( (strcmp(argv[1], "-sdo") == 0) || (strcmp(argv[1], "--start-daemon-only") == 0) ) { startDaemon(); return 0;