mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-12 04:05:53 +02:00
ids-functions.pl: Add function to the the current assigned IP-address of RED.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
@@ -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 = <FILE>;
|
||||
|
||||
# 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;
|
||||
|
||||
Reference in New Issue
Block a user