mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
LoxiLB UI: select virtual ip from red0 interface
since we added loxilb ip management to add ip on red0 interface, we can select the virtual ip from red0 interface. Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
@@ -1306,6 +1306,22 @@ sub grab_address_from_file($) {
|
||||
return;
|
||||
}
|
||||
|
||||
sub get_ipaddresses_from_interface($) {
|
||||
my ($interface) = @_;
|
||||
my @ip_addresses;
|
||||
|
||||
my $output = `ip addr show $interface 2>/dev/null`;
|
||||
|
||||
# Check if the command was successful
|
||||
if ($? == 0) {
|
||||
# Extract IP addresses using regex
|
||||
while ($output =~ /inet (\d+\.\d+\.\d+\.\d+)/g) {
|
||||
push @ip_addresses, $1;
|
||||
}
|
||||
}
|
||||
return @ip_addresses;
|
||||
}
|
||||
|
||||
# Function to get all configured and enabled nameservers.
|
||||
sub get_nameservers () {
|
||||
my %settings;
|
||||
|
||||
@@ -288,6 +288,7 @@ my @PROTOCOLS = ("tcp", "udp");
|
||||
my @ALGO = ("rr", "hash", "priority", "persist", "lc");
|
||||
my @MODE = ("default", "onearm", "fullnat", "dsr");
|
||||
my @MONITOR = ("on", "off");
|
||||
my @VIP = &General::get_ipaddresses_from_interface("red0");
|
||||
|
||||
#Edited line number (KEY1) passed until cleared by 'save' or 'remove' or 'new sort order'
|
||||
print <<END;
|
||||
@@ -297,9 +298,26 @@ print <<END;
|
||||
<tr>
|
||||
<td class='base'>$Lang::tr{'loxilb lb name'}: </td>
|
||||
<td><input type='text' name='NAME' value='$settings{'NAME'}' size='25'/></td>
|
||||
</tr><tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='base'>$Lang::tr{'loxilb lb extip'}: </td>
|
||||
<td><input type='text' name='EXTIP' value='$settings{'EXTIP'}' size='25'/></td>
|
||||
<td>
|
||||
<select name='EXTIP' id='extip' style="width: 95px;">
|
||||
END
|
||||
|
||||
foreach (@VIP) {
|
||||
print "<option value=\"$_\"";
|
||||
if ($_ eq $settings{'EXTIP'}) {
|
||||
print " selected=\"selected\"";
|
||||
}
|
||||
print ">$_</option>";
|
||||
}
|
||||
|
||||
print <<END;
|
||||
|
||||
</select>
|
||||
</td>
|
||||
|
||||
<td class='base'>$Lang::tr{'enabled'}</td>
|
||||
<td><input type='checkbox' name='EN' $checked{'EN'}{'on'} /></td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user