]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
authorArne Fitzenreiter <arne_f@ipfire.org>
Sun, 12 Jan 2014 18:05:54 +0000 (19:05 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sun, 12 Jan 2014 18:05:54 +0000 (19:05 +0100)
html/cgi-bin/index.cgi
html/cgi-bin/ovpnmain.cgi
src/misc-progs/openvpnctrl.c

index b3a262994b8b6e56dc327bb38af034b6b064a848..d6115bdb00c5b2297abc04e20313298186a7a790 100644 (file)
@@ -404,7 +404,7 @@ END
 
                                my $display;
                                my $display_colour = $Header::colourred;
-                               if ( $tustate[1] eq 'CONNECTED') {
+                               if (($tustate[1] eq 'CONNECTED') || ($tustate[1] eq 'WAIT')) {
                                        $display_colour = $Header::colourgreen;
                                        $display = $Lang::tr{'capsopen'};
                                } else {
index 75b6c75f10c9cb6a8389067db9d6dc7dd889965d..b075cc54d9bac8d92fc292e061a5d500024f47d2 100644 (file)
@@ -4941,7 +4941,7 @@ END
 #EXITING       -- A graceful exit is in progress.
 ####
 
-               if ( $tustate[1] eq 'CONNECTED') {
+               if (($tustate[1] eq 'CONNECTED') || ($tustate[1] eq 'WAIT')) {
                        $col1="bgcolor='${Header::colourgreen}'";
                        $active = "<b><font color='#FFFFFF'>$Lang::tr{'capsopen'}</font></b>";
                }else {
index 2af537272b209fa73c5ff0355d9464946aa5dde9..272db0faade2dc3abb79687ad1d077c7308b4175 100644 (file)
@@ -168,6 +168,29 @@ int readPidFile(const char *pidfile) {
        return pid;
 }
 
+int readExternalAddress(char* address) {
+       FILE *fp = fopen("/var/ipfire/red/local-ipaddress", "r");
+       if (!fp)
+               goto ERROR;
+
+       int r = fscanf(fp, "%s", address);
+       fclose(fp);
+
+       if (r < 0)
+               goto ERROR;
+
+       /* In case the read IP address is not valid, we empty
+        * the content of address and return non-zero. */
+       if (!VALID_IP(address))
+               goto ERROR;
+
+       return 0;
+
+ERROR:
+       address = NULL;
+       return 1;
+}
+
 void ovpnInit(void) {
        // Read OpenVPN configuration
        kv = initkeyvalues();
@@ -482,10 +505,18 @@ int startNet2Net(char *name) {
        // Make sure all firewall rules are up to date.
        setFirewallRules();
 
+       // Get the external IP address.
+       char address[STRING_SIZE] = "";
+       int r = readExternalAddress(address);
+       if (r) {
+               fprintf(stderr, "Could not read the external address\n");
+               exit(1);
+       }
+
        char command[STRING_SIZE];
        snprintf(command, STRING_SIZE-1, "/sbin/modprobe tun");
        executeCommand(command);
-       snprintf(command, STRING_SIZE-1, "/usr/sbin/openvpn --config %s", configfile);
+       snprintf(command, STRING_SIZE-1, "/usr/sbin/openvpn --local %s --config %s", address, configfile);
        executeCommand(command);
 
        return 0;