326 |
<label>LABEL_SERV_BADCOUNTRIES_STATUS</label> |
<label>LABEL_SERV_BADCOUNTRIES_STATUS</label> |
327 |
</field> |
</field> |
328 |
|
|
|
diff -Nur smeserver-xt_geoip-1.0.1.old/root/etc/e-smith/web/panels/manager/cgi-bin/xt_geoip smeserver-xt_geoip-1.0.1/root/etc/e-smith/web/panels/manager/cgi-bin/xt_geoip |
|
|
--- smeserver-xt_geoip-1.0.1.old/root/etc/e-smith/web/panels/manager/cgi-bin/xt_geoip 2019-07-23 03:16:53.279411436 +0200 |
|
|
+++ smeserver-xt_geoip-1.0.1/root/etc/e-smith/web/panels/manager/cgi-bin/xt_geoip 2019-07-23 02:18:09.000000000 +0200 |
|
|
@@ -81,7 +81,7 @@ |
|
|
<field |
|
|
type="literal" |
|
|
id="badcountries" |
|
|
- value="get_badcountries()"> |
|
|
+ value="get_badcountries(1)"> |
|
|
<label>LABEL_BADCOUNTRIES_STATUS</label> |
|
|
</field> |
|
|
|
|
|
@@ -102,7 +102,6 @@ |
|
|
<field type="literal" id="service_label" value=""> |
|
|
<description>SERVICE_DESCRIPTION</description> |
|
|
</field> |
|
|
- |
|
|
<subroutine src="print_custom_button('PER_SERVICE_GEOIP', 'Service', '')"/> |
|
|
|
|
|
<field type="literal" id="stats_label" value=""> |
|
|
@@ -128,10 +127,20 @@ |
|
|
<description>DESC_GEOIP</description> |
|
|
</field> |
|
|
|
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="masq_reverse" |
|
|
+ options="'enabled' => '!=', 'disabled' => '=='" |
|
|
+ value="get_reverse('masq','XTGeoipRev')"> |
|
|
+ <label>LABEL_REVERSE_MATCH</label> |
|
|
+ <description>DESC_REVERSE_MATCH</description> |
|
|
+ </field> |
|
|
+ |
|
|
<field |
|
|
type="text" |
|
|
id="masq_badcountries" |
|
|
size="64" |
|
|
+ value="get_badcountries(0)" |
|
|
validation="must_exist()"> |
|
|
<label>LABEL_BADCOUNTRIES</label> |
|
|
<description>DESC_BADCOUNTRIES</description> |
|
|
@@ -140,9 +149,18 @@ |
|
|
<field |
|
|
type="literal" |
|
|
id="badcountries" |
|
|
- value="get_badcountries()"> |
|
|
+ value="get_badcountries(1)"> |
|
|
<label>LABEL_BADCOUNTRIES_STATUS</label> |
|
|
</field> |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="masq_others" |
|
|
+ options="'enabled' => 'enabled', 'disabled' => 'disabled'" |
|
|
+ value="get_reverse('masq','XTGeoipOther')"> |
|
|
+ <label>LABEL_OTHERS</label> |
|
|
+ <description>DESC_OTHERS</description> |
|
|
+ </field> |
|
|
|
|
|
<field |
|
|
type="select" |
|
|
@@ -163,7 +181,7 @@ |
|
|
<field |
|
|
type="literal" |
|
|
id="badcountries" |
|
|
- value="get_badcountries()"> |
|
|
+ value="get_badcountries(1)"> |
|
|
<label>LABEL_BADCOUNTRIES_STATUS</label> |
|
|
</field> |
|
|
<subroutine src="print_service_table()" /> |
|
|
@@ -187,14 +205,24 @@ |
|
|
<field |
|
|
type="literal" |
|
|
id="badcountries" |
|
|
- value="get_badcountries()"> |
|
|
+ value="get_badcountries(1)"> |
|
|
<label>LABEL_BADCOUNTRIES_STATUS</label> |
|
|
</field> |
|
|
|
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="masq_srv_reverse" |
|
|
+ options="'enabled' => '!=', 'disabled' => '=='" |
|
|
+ value="get_reverse('','XTGeoipRev')"> |
|
|
+ <label>LABEL_REVERSE_MATCH</label> |
|
|
+ <description>DESC_REVERSE_MATCH</description> |
|
|
+ </field> |
|
|
+ |
|
|
<field |
|
|
type="text" |
|
|
id="masq_srv_badcountries" |
|
|
size="64" |
|
|
+ value="get_srv_badcountries(0)" |
|
|
validation="srv_must_exist()"> |
|
|
<label>LABEL_BADCOUNTRIES</label> |
|
|
<description>DESC_BADCOUNTRIES</description> |
|
|
@@ -203,7 +231,7 @@ |
|
|
<field |
|
|
type="literal" |
|
|
id="srv_badcountries" |
|
|
- value="get_srv_badcountries()"> |
|
|
+ value="get_srv_badcountries(1)"> |
|
|
<label>LABEL_SERV_BADCOUNTRIES_STATUS</label> |
|
|
</field> |
|
|
|
|
|
diff -Nur smeserver-xt_geoip-1.0.1.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm smeserver-xt_geoip-1.0.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm |
|
|
--- smeserver-xt_geoip-1.0.1.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm 2019-07-23 03:16:53.284411435 +0200 |
|
|
+++ smeserver-xt_geoip-1.0.1/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/xt_geoip.pm 2019-07-23 02:49:15.000000000 +0200 |
|
|
@@ -23,6 +23,7 @@ |
|
|
get_value |
|
|
get_badcountries |
|
|
get_geoip |
|
|
+ get_reverse |
|
|
print_service_table |
|
|
get_stat_geoip |
|
|
print_custom_button |
|
|
@@ -139,7 +140,12 @@ |
|
|
|
|
|
sub get_badcountries |
|
|
{ |
|
|
- return $db->get_prop("masq", "BadCountries"); |
|
|
+ my $self = shift; |
|
|
+ my $full = shift; |
|
|
+ my $badc=$db->get_prop("masq", "BadCountries")||""; |
|
|
+ return $badc unless $full ; |
|
|
+ my $rev = (($db->get_prop("masq", "XTGeoipRev")||"disabled") eq "enabled") ? "!=" : "=="; |
|
|
+ return "$rev $badc "; |
|
|
} |
|
|
|
|
|
=head2 get_geoip |
|
|
@@ -152,6 +158,20 @@ |
|
|
return $db->get_prop("masq", "GeoIP") || 'disabled'; |
|
|
} |
|
|
|
|
|
+=head2 get_reverse |
|
|
+ |
|
|
+method to retrieve the value of geoip for the form |
|
|
+=cut |
|
|
+ |
|
|
+sub get_reverse |
|
|
+{ |
|
|
+ my $fm = shift; |
|
|
+ my $item = shift; |
|
|
+ my $prop = shift; |
|
|
+ $item = ($item eq 'masq') ? $item : $fm->cgi->param('name'); |
|
|
+ return $db->get_prop("$item", "$prop") || "disabled"; |
|
|
+} |
|
|
+ |
|
|
=head2 get_stat_geoip |
|
|
|
|
|
method to retrieve the status of geoip for the form |
|
|
@@ -189,15 +209,23 @@ |
|
|
|
|
|
my $mq_bc = get_badcountries(); |
|
|
my $mq_gp = get_geoip(); |
|
|
- my $n_mq_bc = $q->param("masq_badcountries") || $mq_bc; |
|
|
+ my $masq = $db->get('masq') || "disabled"; |
|
|
+ my $mq_rv = $masq->prop('XTGeoipRev') || 'disabled'; |
|
|
+ my $mq_ot = $masq->prop('XTGeoipOther') || 'disabled'; |
|
|
+ |
|
|
+ my $n_mq_bc = $q->param("masq_badcountries"); |
|
|
my $n_mq_gp = $q->param("masq_geoip") || $mq_gp; |
|
|
my $n_upd_gp = $q->param("update_geoip") || ''; |
|
|
- |
|
|
- if (($n_mq_bc eq $mq_bc) && ($n_mq_gp eq $mq_gp) && ($n_upd_gp eq 'NO')) { |
|
|
+ my $n_mq_rv = $q->param("masq_reverse") || $mq_rv ; |
|
|
+ my $n_mq_ot = $q->param("masq_others") || $mq_ot ; |
|
|
+ |
|
|
+ if (($n_mq_bc eq $mq_bc) && ($n_mq_gp eq $mq_gp) && ($n_upd_gp eq 'NO') && ($n_mq_rv eq $mq_rv) && ($n_mq_ot eq $mq_ot)) { |
|
|
return $self->success("NO_CHANGE") |
|
|
} |
|
|
$db->set_prop("masq", "BadCountries", $n_mq_bc); |
|
|
$db->set_prop("masq", "GeoIP", $n_mq_gp); |
|
|
+ $db->set_prop("masq", "XTGeoipRev", $n_mq_rv); |
|
|
+ $db->set_prop("masq", "XTGeoipOther", $n_mq_ot); |
|
|
|
|
|
my $eventloc = "xt_geoip-modify"; |
|
|
$eventloc = "xt_geoip-update" if $n_upd_gp eq 'YES'; |
|
|
@@ -293,9 +321,13 @@ |
|
|
|
|
|
sub get_srv_badcountries |
|
|
{ |
|
|
- my ($self) = @_; |
|
|
+ my $self = shift; |
|
|
my $name = $self->cgi->param('name'); |
|
|
- return $db->get_prop($name, "BadCountries"); |
|
|
+ my $full = shift; |
|
|
+ my $badc=$db->get_prop($name, "BadCountries")||""; |
|
|
+ return $badc unless $full ; |
|
|
+ my $rev = (($db->get_prop($name, "XTGeoipRev")||"disabled") eq "enabled") ? "!=" : "=="; |
|
|
+ return "$rev $badc "; |
|
|
} |
|
|
|
|
|
sub print_service_table { |
|
|
@@ -338,6 +370,7 @@ |
|
|
my $status = $i->prop('status'); |
|
|
my $access = $i->prop('access'); |
|
|
my $servBC = $i->prop('BadCountries') || ' '; |
|
|
+ my $servRev = (( $i->prop('XTGeoipRev')|| 'disabled') eq 'disabled' )? '==': '!='; |
|
|
|
|
|
my $params = $self->build_serv_cgi_params($servname, $i->props()); |
|
|
|
|
|
@@ -352,13 +385,15 @@ |
|
|
. ' '; |
|
|
|
|
|
my $color = 'red'; |
|
|
- if ($status eq 'disabled' || $access ne 'public') { $color = 'green'; } |
|
|
+ my $deco= "none"; |
|
|
+ if ($servRev eq '!=' ) { $color = 'green'; } |
|
|
+ if ($status eq 'disabled' || $access ne 'public') { $color = 'grey'; $deco= "line-through"; } |
|
|
print $q->Tr ( |
|
|
esmith::cgi::genSmallCell($q, $servname,"normal"), |
|
|
esmith::cgi::genSmallCell($q, $port,"normal"), |
|
|
- esmith::cgi::genSmallCell($q, $status,"header"), |
|
|
- esmith::cgi::genSmallCell($q, $access,"header"), |
|
|
- esmith::cgi::genSmallCell($q, "<font color='$color'>" . $servBC . "</font>","header"), |
|
|
+ esmith::cgi::genSmallCell($q, $status,"normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $access,"normal"), |
|
|
+ esmith::cgi::genSmallCell($q, "<font color='$color' style='text-decoration: $deco'>" . "$servRev $servBC" . "</font>","normal"), |
|
|
esmith::cgi::genSmallCell($q, $actionModify,"normal"), |
|
|
esmith::cgi::genSmallCell($q, $actionRemove,"normal")); |
|
|
} |
|
|
@@ -386,7 +421,8 @@ |
|
|
if (my $serv = $db->get($name)) { |
|
|
my $servBC = $serv->prop('BadCountries') || ''; |
|
|
if ($servBC ne '') { |
|
|
- $db->set_prop($name, "BadCountries", ''); |
|
|
+ my $tps = $db->set_prop_and_delete($name, "BadCountries"); |
|
|
+ $tps = $db->get_prop_and_delete($name, "XTGeoipRev"); |
|
|
# Untaint $name before use in system() |
|
|
# $name =~ /(.+)/; $name = $1; |
|
|
if (system ("/sbin/e-smith/signal-event", "xt_geoip-service") == 0) |
|
|
@@ -410,14 +446,17 @@ |
|
|
my $name = $self->cgi->param('name'); |
|
|
if (my $serv = $db->get($name)) { |
|
|
my $servBC = $serv->prop('BadCountries') || ''; |
|
|
+ my $servRev = $serv->prop('XTGeoipRev') || 'disabled'; |
|
|
|
|
|
my $q = $self->{'cgi'}; |
|
|
- my $n_servBC = $q->param("masq_srv_badcountries") || $servBC; |
|
|
- |
|
|
- if ($n_servBC eq $servBC) { |
|
|
+ my $n_servBC = $q->param("masq_srv_badcountries"); |
|
|
+ my $n_servRev = $q->param("masq_srv_reverse") || $servRev; |
|
|
+ |
|
|
+ if ($n_servBC eq $servBC && $n_servRev eq $servRev ) { |
|
|
return $self->success("NO_CHANGE") |
|
|
} |
|
|
$db->set_prop($name, "BadCountries", $n_servBC); |
|
|
+ $db->set_prop($name, "XTGeoipRev", $n_servRev); |
|
|
|
|
|
if (system ( "/sbin/e-smith/signal-event", "xt_geoip-service" ) == 0 ) |
|
|
{ |
|