From: Stefan Schantl Date: Thu, 31 Jan 2019 08:41:35 +0000 (+0100) Subject: ids-functions.pl: Add function to the the current assigned IP-address of RED. X-Git-Tag: v2.23-core131~117^2~79 X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=commitdiff_plain;h=de8e1e5b6ce6c8d82dc8e67c92af338206252dc2 ids-functions.pl: Add function to the the current assigned IP-address of RED. Signed-off-by: Stefan Schantl --- diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl index a7c1585228..1f782b5c15 100644 --- a/config/cfgroot/ids-functions.pl +++ b/config/cfgroot/ids-functions.pl @@ -901,5 +901,36 @@ sub get_aliases() { return @aliases; } +# +## Function to grab the current assigned IP-address on red. +# +sub get_red_address() { + # File, which contains the current IP-address of the red interface. + my $file = "${General::swroot}/red/local-ipaddress"; + + # Check if the file exists. + if (-e $file) { + # Open the given file. + open(FILE, "$file") or die "Could not open $file."; + + # Obtain the address from the first line of the file. + my $address = ; + + # Close filehandle + close(FILE); + + # Remove newlines. + chomp $address; + + # Check if the grabbed address is valid. + if (&General::validip($address)) { + # Return the address. + return $address; + } + } + + # Return nothing. + return; +} 1;