mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-28 11:43:25 +02:00
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
This commit is contained in:
@@ -404,7 +404,7 @@ END
|
|||||||
|
|
||||||
my $display;
|
my $display;
|
||||||
my $display_colour = $Header::colourred;
|
my $display_colour = $Header::colourred;
|
||||||
if ( $tustate[1] eq 'CONNECTED') {
|
if (($tustate[1] eq 'CONNECTED') || ($tustate[1] eq 'WAIT')) {
|
||||||
$display_colour = $Header::colourgreen;
|
$display_colour = $Header::colourgreen;
|
||||||
$display = $Lang::tr{'capsopen'};
|
$display = $Lang::tr{'capsopen'};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4941,7 +4941,7 @@ END
|
|||||||
#EXITING -- A graceful exit is in progress.
|
#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}'";
|
$col1="bgcolor='${Header::colourgreen}'";
|
||||||
$active = "<b><font color='#FFFFFF'>$Lang::tr{'capsopen'}</font></b>";
|
$active = "<b><font color='#FFFFFF'>$Lang::tr{'capsopen'}</font></b>";
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -168,6 +168,29 @@ int readPidFile(const char *pidfile) {
|
|||||||
return pid;
|
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) {
|
void ovpnInit(void) {
|
||||||
// Read OpenVPN configuration
|
// Read OpenVPN configuration
|
||||||
kv = initkeyvalues();
|
kv = initkeyvalues();
|
||||||
@@ -482,10 +505,18 @@ int startNet2Net(char *name) {
|
|||||||
// Make sure all firewall rules are up to date.
|
// Make sure all firewall rules are up to date.
|
||||||
setFirewallRules();
|
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];
|
char command[STRING_SIZE];
|
||||||
snprintf(command, STRING_SIZE-1, "/sbin/modprobe tun");
|
snprintf(command, STRING_SIZE-1, "/sbin/modprobe tun");
|
||||||
executeCommand(command);
|
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);
|
executeCommand(command);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user