From 6df412401c09b333feabdffd5e7af5f0682d89f6 Mon Sep 17 00:00:00 2001 From: Vincent Li Date: Sat, 1 Jun 2024 21:09:54 +0000 Subject: [PATCH] loxilb UI: add backend monitor option Signed-off-by: Vincent Li --- html/cgi-bin/loxilbconfig.cgi | 43 +++++++++++++++++++++++++++++++---- langs/en/cgi-bin/en.pl | 1 + langs/zh/cgi-bin/zh.pl | 1 + 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/html/cgi-bin/loxilbconfig.cgi b/html/cgi-bin/loxilbconfig.cgi index b5628cf1a..a365e8edd 100644 --- a/html/cgi-bin/loxilbconfig.cgi +++ b/html/cgi-bin/loxilbconfig.cgi @@ -54,7 +54,8 @@ $settings{'SEL'} = ''; $settings{'MODE'} = ''; $settings{'ENDPOINTS'} = ''; $settings{'EPORT'} = ''; -my @nosaved=('EN','NAME','EXTIP','PORT','PROTO','SEL','MODE','ENDPOINTS','EPORT'); # List here ALL setting2 fields. Mandatory +$settings{'MONITOR'} = ''; +my @nosaved=('EN','NAME','EXTIP','PORT','PROTO','SEL','MODE','ENDPOINTS','EPORT','MONITOR'); # List here ALL setting2 fields. Mandatory $settings{'ACTION'} = ''; # add/edit/remove $settings{'KEY1'} = ''; # point record for ACTION @@ -147,6 +148,7 @@ if ($settings{'ACTION'} eq $Lang::tr{'add'}) { $temp[6] ='' unless defined $temp[5]; # not always populated $temp[7] ='' unless defined $temp[6]; # not always populated $temp[8] ='' unless defined $temp[7]; # not always populated + $temp[9] ='' unless defined $temp[8]; # not always populated #Same ip already used? if($temp[1] eq $settings{'NAME'} && $settings{'KEY1'} eq ''){ $errormessage = $Lang::tr{'ccd err loxilbconfigeexist'}; @@ -156,10 +158,10 @@ if ($settings{'ACTION'} eq $Lang::tr{'add'}) { unless ($errormessage) { if ($settings{'KEY1'} eq '') { #add or edit ? - unshift (@current, "$settings{'EN'},$settings{'NAME'},$settings{'EXTIP'},$settings{'PORT'},$settings{'PROTO'},$settings{'SEL'},$settings{'MODE'},$settings{'ENDPOINTS'},$settings{'EPORT'}\n"); + unshift (@current, "$settings{'EN'},$settings{'NAME'},$settings{'EXTIP'},$settings{'PORT'},$settings{'PROTO'},$settings{'SEL'},$settings{'MODE'},$settings{'ENDPOINTS'},$settings{'EPORT'},$settings{'MONITOR'}\n"); &General::log($Lang::tr{'loxilb lb config added'}); } else { - @current[$settings{'KEY1'}] = "$settings{'EN'},$settings{'NAME'},$settings{'EXTIP'},$settings{'PORT'},$settings{'PROTO'},$settings{'SEL'},$settings{'MODE'},$settings{'ENDPOINTS'},$settings{'EPORT'}\n"; + @current[$settings{'KEY1'}] = "$settings{'EN'},$settings{'NAME'},$settings{'EXTIP'},$settings{'PORT'},$settings{'PROTO'},$settings{'SEL'},$settings{'MODE'},$settings{'ENDPOINTS'},$settings{'EPORT'},$settings{'MONITOR'}\n"; $settings{'KEY1'} = ''; # End edit mode &General::log($Lang::tr{'loxilb lb config changed'}); } @@ -189,6 +191,7 @@ if ($settings{'ACTION'} eq $Lang::tr{'edit'}) { $settings{'MODE'}=$temp[6]; $settings{'ENDPOINTS'}=$temp[7]; $settings{'EPORT'}=$temp[8]; + $settings{'MONITOR'}=$temp[9]; if ($settings{'EN'} eq 'on') { &CreateLB(%settings); } @@ -208,6 +211,7 @@ if ($settings{'ACTION'} eq $Lang::tr{'remove'}) { $settings{'MODE'}=$temp[6]; $settings{'ENDPOINTS'}=$temp[7]; $settings{'EPORT'}=$temp[8]; + $settings{'MONITOR'}=$temp[9]; &DeleteLB(%settings); splice (@current,$settings{'KEY1'},1); # Delete line @@ -252,6 +256,7 @@ if ($settings{'ACTION'} eq '' ) { # First launch from GUI $settings{'MODE'} = ''; $settings{'ENDPOINTS'} = ''; $settings{'EPORT'} = ''; + $settings{'MONITOR'} = ''; } &Header::openpage($Lang::tr{'loxilb lb config entries'}, 1, ''); @@ -279,6 +284,7 @@ if ($settings{'KEY1'} ne '') { my @PROTOCOLS = ("tcp", "udp"); my @ALGO = ("rr", "hash", "priority", "persist", "lc"); my @MODE = ("default", "onearm", "fullnat", "dsr"); +my @MONITOR = ("on", "off"); #Edited line number (KEY1) passed until cleared by 'save' or 'remove' or 'new sort order' print <$Lang::tr{'loxilb lb eport'}:  + + $Lang::tr{'loxilb lb monitor'}:  + + @@ -553,7 +583,7 @@ sub SortDataFile # Each SORTABLE field must have is pair. # Other data fields (non sortable) can be grouped in one - my @record = ('KEY',$key++,'EN',$temp[0],'NAME',$temp[1],'EXTIP',$temp[2],'PORT',$temp[3],'PROTO',$temp[4],'SEL',$temp[5],'MODE',$temp[6],'ENDPOINTS',$temp[7],'EPORT',$temp[8]); + my @record = ('KEY',$key++,'EN',$temp[0],'NAME',$temp[1],'EXTIP',$temp[2],'PORT',$temp[3],'PROTO',$temp[4],'SEL',$temp[5],'MODE',$temp[6],'ENDPOINTS',$temp[7],'EPORT',$temp[8],'MONITOR',$temp[9]); my $record = {}; # create a reference to empty hash %{$record} = @record; # populate that hash with @record $entries{$record->{KEY}} = $record; # add this to a hash of hashes @@ -563,7 +593,7 @@ sub SortDataFile # Each field value is printed , with the newline ! Don't forget separator and order of them. foreach my $entry (sort fixedleasesort keys %entries) { - print FILE "$entries{$entry}->{EN},$entries{$entry}->{NAME},$entries{$entry}->{EXTIP},$entries{$entry}->{PORT},$entries{$entry}->{PROTO},$entries{$entry}->{SEL},$entries{$entry}->{MODE},$entries{$entry}->{ENDPOINTS},$entries{$entry}->{EPORT}\n"; + print FILE "$entries{$entry}->{EN},$entries{$entry}->{NAME},$entries{$entry}->{EXTIP},$entries{$entry}->{PORT},$entries{$entry}->{PROTO},$entries{$entry}->{SEL},$entries{$entry}->{MODE},$entries{$entry}->{ENDPOINTS},$entries{$entry}->{EPORT},$entries{$entry}->{MONITOR}\n"; } close(FILE); @@ -605,6 +635,9 @@ sub CreateLB { push(@loxicmd_options, "$mode"); } push(@loxicmd_options, "$endpoints"); + if ($settings{'MONITOR'} eq 'on') { + push(@loxicmd_options, "--monitor"); + } &General::system($command, @loxicmd_options); } diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index bcea0daa8..89d5c8d5c 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -2470,6 +2470,7 @@ 'loxilb lb mode' => 'MODE', 'loxilb lb endpoints' => 'ENDPOINTS', 'loxilb lb eport' => 'EPORT', +'loxilb lb monitor' => 'MONITOR', 'status' => 'Status', 'status information' => 'Status information', 'status ovpn' => 'OpenVPN', diff --git a/langs/zh/cgi-bin/zh.pl b/langs/zh/cgi-bin/zh.pl index 53608a3f1..12444d859 100644 --- a/langs/zh/cgi-bin/zh.pl +++ b/langs/zh/cgi-bin/zh.pl @@ -2437,6 +2437,7 @@ 'loxilb lb mode' => '模式', 'loxilb lb endpoints' => '后端服务器', 'loxilb lb eport' => '前端端口', +'loxilb lb monitor' => '后端服务监控', 'status' => '状态', 'status information' => '状态信息', 'status ovpn' => 'OpenVPN',