5 Commits

Author SHA1 Message Date
14aa2d8fda * Tue Oct 28 2025 Jean-Philippe Pialasse <jpp@koozali.org> 1.3.1-31.sme
- Update the references in Createlinks to smeserver-*-update [SME: 13249]
  thanks to Zsolt Vasarhelyi
2025-10-28 14:21:08 -04:00
a570a47f5a Update the references in Createlinks to smeserver-*-update SME: 13249 2025-10-28 16:03:35 +02:00
John Crisp
daa56b9cc5 xt_geoip 1.3.1-30.sme Fix syntax in masq template for [SME: 12445] 2025-10-22 13:46:41 +02:00
John Crisp
39a0598d79 xt_geoip 1.3.1-29.sme updated filenames 2025-10-22 11:59:00 +02:00
John Crisp
3caa8642cb Fix for XT_geoip 2025-10-22 11:57:56 +02:00
16 changed files with 1372 additions and 822 deletions

View File

@@ -7,7 +7,7 @@ use esmith::Build::CreateLinks qw(:all);
#--------------------------------------------------
# links to add
panel_link("xt_geoip","manager");
panel_link("xtgeoip","manager");
# templates to expand
for my $event (qw(xt_geoip-modify xt_geoip-update xt_geoip-service
@@ -37,7 +37,7 @@ for my $event (qw(xt_geoip-update bootstrap-console-save
{
event_link("smeserver-xt_geoip-download-action", $event, "10");
}
for my $event (qw(bootstrap-console-save e-smith-packetfilter-update
for my $event (qw(bootstrap-console-save smeserver-packetfilter-update
smeserver-xt_geoip-update remoteaccess-update))
{
event_link("xt_geoip_kmod", $event, "15");

View File

@@ -12,7 +12,7 @@
my $locBC;
# to allow reload without locking just after initial install
$OUT .=<<'EOF';
$OUT .= <<'EOF';
iptables -n --list XTGeoIP >/dev/null 2>&1
test=$?
if [[ $test -eq 1 ]] ; then
@@ -26,63 +26,72 @@
EOF
# Find the current XTGeoIP_$$ chain, and create a new one.
$OUT .=<<'EOF';
$OUT .= <<'EOF';
OLD_XTGeoIP=$(get_safe_id XTGeoIP filter find)
NEW_XTGeoIP=$(get_safe_id XTGeoIP filter new)
/sbin/iptables --new-chain $NEW_XTGeoIP
EOF
if ( $GP eq 'enabled' )
{
if (-s $PATH_MODULE || -s $PATH2_MODULE || -s $PATH3_MODULE)
{
if ($GP eq 'enabled') {
if (-s $PATH_MODULE || -s $PATH2_MODULE || -s $PATH3_MODULE) {
# do not block Localhost(s)
$OUT .= " /sbin/iptables -A \$NEW_XTGeoIP -s 127.0.0.0/24 -j RETURN\n";
# do not block LAN
my $locals = "@locals";
if (@locals)
{
if (@locals) {
# Make a new local_chk chain and add any networks found in networks db
foreach my $local (@locals)
{
foreach my $local (@locals) {
# If the network is a remote vpn subnet, restrict it to the ipsec0
# interface.
my ($net, $msk) = split /\//, $local;
my $netrec = $nets->get($net);
die "Can't find network $net in networks db!\n" unless $netrec;
$OUT .= " /sbin/iptables -A \$NEW_XTGeoIP -s $local";
if (($netrec->prop('remoteVPNSubnet') || 'no') eq 'yes')
{
if (($netrec->prop('remoteVPNSubnet') || 'no') eq 'yes') {
$OUT .= " --in-interface ipsec0";
}
$OUT .= " -j RETURN\n";
} ## end foreach my $local (@locals)
} ## end if (@locals)
# [SME: 12445] do not block Remote authorized access
# TO DO : allow pin point per service eg this UK ip/network even if UK is filtered
if (($masq{XTAcceptValidRemoteHosts} || 'enabled') eq 'enabled') {
foreach (split /[,;]/, (${'httpd-admin'}{'ValidFrom'} || '')) {
my ($ip, $bits) = Net::IPv4Addr::ipv4_parse("$_");
$OUT .= " /sbin/iptables -A \$NEW_XTGeoIP -s $ip/$bits -j RETURN\n" unless "$ip" eq '0.0.0.0';
}
}
} ## end if (($masq{XTAcceptValidRemoteHosts...}))
my @services = split(/,/, $masq{'XtServices'});
foreach my $servName (@services)
{
foreach my $servName (@services) {
$port = ${$servName}{'TCPPort'} || '';
my $servStatus = ${$servName}{'status'} || 'disabled';
my $servAccess = ${$servName}{'access'} || 'private';
my $locBC = ${$servName}{'BadCountries'} || '';
my $reverse = ( ( ${$servName}{'XTGeoipRev'} || 'disabled' ) eq "enabled" )? "!": "";
my $reverse = ((${$servName}{'XTGeoipRev'} || 'disabled') eq "enabled") ? "!" : "";
if ($port ne '' and $servStatus eq 'enabled' and $servAccess eq 'public' and $locBC ne '') {
push @locPorts, $port;
my $multi = ( $port =~ /[,:]/ )? "-m multiport --dports" : "--dport";
my $multi = ($port =~ /[,:]/) ? "-m multiport --dports" : "--dport";
$OUT .= " /sbin/iptables -A \$NEW_XTGeoIP -m geoip $reverse --src-cc $locBC -p tcp $multi $port -j NFLOG --nflog-prefix \"GeoIP BAN: $servName\"\n";
$OUT .= " /sbin/iptables -A \$NEW_XTGeoIP -m geoip $reverse --src-cc $locBC -p tcp $multi $port -j DROP\n";
}
}
} ## end if ($port ne '' and $servStatus...)
} ## end foreach my $servName (@services)
# block for all or other ports should move there
if ($BC ne '') {
my $reverse = ( ( $masq{'XTGeoipRev'} || 'disabled' ) eq "enabled" )? "!": "";
my $others = ( ( $masq{'XTGeoipOther'} || 'disabled') eq "enabled") ? 1 : 0;
my $reverse = (($masq{'XTGeoipRev'} || 'disabled') eq "enabled") ? "!" : "";
my $others = (($masq{'XTGeoipOther'} || 'disabled') eq "enabled") ? 1 : 0;
@locPorts = () unless $others;
if (@locPorts != 0) {
my $LocPorts = join ',', @locPorts;
$OUT .= " /sbin/iptables -A \$NEW_XTGeoIP -p tcp -m geoip -m multiport ! --dports $LocPorts $reverse --src-cc $BC -j NFLOG --nflog-prefix \"GeoIP BAN: OTHER\"\n";
@@ -91,21 +100,17 @@ EOF
$OUT .= " /sbin/iptables -A \$NEW_XTGeoIP -p tcp -m geoip $reverse --src-cc $BC -j NFLOG --nflog-prefix \"GeoIP BAN: ALL\"\n";
$OUT .= " /sbin/iptables -A \$NEW_XTGeoIP -p tcp -m geoip $reverse --src-cc $BC -j DROP\n";
}
}
$OUT .= " /sbin/iptables --append \$NEW_XTGeoIP" .
" -j RETURN\n";
} ## end if ($BC ne '')
$OUT .= " /sbin/iptables --append \$NEW_XTGeoIP" . " -j RETURN\n";
## end of add
}
}
} ## end if (-s $PATH_MODULE ||...)
} ## end if ($GP eq 'enabled')
# Having created a new XTGeoIP chain, activate it and destroy the old.
$OUT .=<<'EOF';
$OUT .= <<'EOF';
/sbin/iptables --replace XTGeoIP 1 \
--jump $NEW_XTGeoIP
/sbin/iptables --flush $OLD_XTGeoIP
/sbin/iptables --delete-chain $OLD_XTGeoIP
EOF
}

View File

@@ -1,494 +0,0 @@
package SrvMngr::Controller::Xt_geoip;
#----------------------------------------------------------------------
# heading : Network
# description : GeoIP IP filtering
# navigation : 6000 610
# name : xt_geoip, method : get, url : /xt_geoip, ctlact : Xt_geoip#main
# name : xt_geoipd, method : post, url : /xt_geoip, ctlact : Xt_geoip#do_display
# name : xt_geoipc, method : get, url : /xt_geoipb, ctlact : Xt_geoip#do_display
# name : xt_geoipu, method : post, url : /xt_geoipb, ctlact : Xt_geoip#do_action
#
# routes : end
#----------------------------------------------------------------------
use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
use POSIX qw(strftime);
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw( theme_list init_session );
# our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my ($cdb);
sub main {
my $c = shift;
$c->app->log->info($c->log_req);
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $title = $c->render_to_string(inline => ($c->l('xtg_FORM_TITLE')));
my %xtg_datas = ();
$xtg_datas{'choice'} = '';
$c->stash(title => $title, xtg_datas => \%xtg_datas);
$c->render('xt_geoip');
} ## end sub main
sub do_display {
my $c = shift;
$c->app->log->info($c->log_req);
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $title = $c->render_to_string(inline => ($c->l('xtg_FORM_TITLE')));
my $choice = $c->param('Choice');
my $result;
my %xtg_datas = ();
$xtg_datas{'choice'} = $choice;
if ($choice eq 'LCOD') {
$result = $c->generateCodes();
# $c->stash( title => $title, modul => $result, xtg_datas => \%xtg_datas );
# return $c->render('xt_geoip_lst');
} ## end if ($choice eq 'LCOD')
if ($choice eq 'LF2B') {
$result = $c->generateStats('f2b');
# $result = $c->render_to_string(inline => generateStats($c, 'f2b'));
# $c->stash( title => $title, modul => $result, xtg_datas => \%xtg_datas );
# return $c->render('xt_geoip_lst');
} ## end if ($choice eq 'LF2B')
if ($choice eq 'LSSH') {
$result = $c->generateStats('ssh');
# $result = $c->render_to_string(inline => generateStats($c, 'ssh'));
# $c->stash( title => $title, modul => $result, xtg_datas => \%xtg_datas );
# return $c->render('xt_geoip_lst');
} ## end if ($choice eq 'LSSH')
if ($choice eq 'LIPT') {
$result = $c->generateStats('ipt');
# $c->stash( title => $title, modul => $result, xtg_datas => \%xtg_datas );
# return $c->render('xt_geoip_lst');
} ## end if ($choice eq 'LIPT')
if ($choice eq 'LSRV') {
# $c->stash( title => $title, xtg_datas => \%xtg_datas );
# return $c->render('xt_geoip_lsrv');
} ## end if ($choice eq 'LSRV')
if ($choice eq 'UPDT') {
# $c->stash( title => $title, xtg_datas => \%xtg_datas );
# return $c->render('xt_geoip_updt');
} ## end if ($choice eq 'UPDT')
if ($choice eq 'UPDS') {
$xtg_datas{name} = $c->param('Name');
# $c->stash( title => $title, xtg_datas => \%xtg_datas );
# return $c->render('xt_geoip_upds');
} ## end if ($choice eq 'UPDS')
if ($choice eq 'REMS') {
$xtg_datas{name} = $c->param('Name');
# $c->stash( title => $title, xtg_datas => \%xtg_datas );
# return $c->render('xt_geoip_rems');
} ## end if ($choice eq 'REMS')
$c->stash(title => $title, modul => $result, xtg_datas => \%xtg_datas);
return $c->render('xt_geoip_lst') if ($choice ~~ [ 'LCOD', 'LF2B', 'LSSH', 'LIPT' ]);
return $c->render('xt_geoip' . '_' . lc($choice)) if ($choice ~~ [ 'UPDT', 'UPDS', 'REMS', 'LSRV' ]);
$c->redirect_to('/xt_geoip');
} ## end sub do_display
sub do_action {
my $c = shift;
$c->app->log->info($c->log_req);
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $rt = $c->current_route;
my $title = $c->render_to_string(inline => ($c->l('xtg_FORM_TITLE')));
my %xtg_datas = ();
my $choice = $c->param('Choice');
$xtg_datas{'choice'} = $choice;
my ($res, $result) = '';
if ($choice eq 'LSRV') {
#$result .= 'Blocked for testing ! Avoid updates for now ';
$res = '';
if (!$result) {
$res = $c->do_otherServices();
$result .= $res unless $res eq 'OK';
if (!$result) {
$result = $c->l('xtg_SERVICE_SUCCESS');
}
} ## end if (!$result)
} ## end if ($choice eq 'LSRV')
if ($choice eq 'UPDT') {
$res = $c->must_exist();
$result .= $res unless $res eq 'OK';
#$result .= 'Blocked for testing ! Avoid updates for now ';
$res = '';
if (!$result) {
$res = $c->change_settings();
$result .= $res unless $res eq 'OK';
if (!$result) {
$result = $c->l('xtg_SUCCESS');
}
} ## end if (!$result)
} ## end if ($choice eq 'UPDT')
if ($choice eq 'REMS') {
#$result .= 'Blocked for testing ! Avoid updates for now ';
my $name = $c->param('Name');
$xtg_datas{name} = $name;
$res = '';
if (!$result) {
$res = $c->remove_serv();
$result .= $res unless $res eq 'OK';
if (!$result) {
$result = $c->l('xtg_SUCCESSFULLY_DELETED_SERVICE');
}
} ## end if (!$result)
} ## end if ($choice eq 'REMS')
if ($choice eq 'UPDS') {
#$result .= 'Blocked for testing ! Avoid updates for now ';
my $name = $c->param('Name');
$xtg_datas{name} = $name;
$res = '';
if (!$result) {
$res = $c->modify_serv();
$result .= $res unless $res eq 'OK';
if (!$result) {
$result = $c->l('xtg_SERVICE_SUCCESS');
}
} ## end if (!$result)
} ## end if ($choice eq 'UPDS')
# common parts
if ($res ne 'OK') {
$c->stash(error => $result);
$c->stash(title => $title, xtg_datas => \%xtg_datas);
return $c->render('xt_geoip' . '_' . lc($choice));
}
my $message = "xt_geoip updates $choice DONE";
$c->app->log->info($message);
$c->flash(success => $result);
## $c->flash( error => 'No changes applied !!' );
#return to 'xt_geoip' route !!!
$c->redirect_to('/xt_geoip');
} ## end sub do_action
sub get_badcountries {
my $c = shift;
my $full = shift;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $badc = $cdb->get_prop("masq", "BadCountries") || "";
return $badc unless $full;
my $rev = (($cdb->get_prop("masq", "XTGeoipRev") || "disabled") eq "enabled") ? "!=" : "==";
return "$rev $badc ";
} ## end sub get_badcountries
sub get_geoip {
return $cdb->get_prop("masq", "GeoIP") || 'disabled';
}
sub get_reverse {
my $c = shift;
my $item = shift;
my $prop = shift;
$item = ($item eq 'masq') ? $item : $c->param('Name');
return $cdb->get_prop("$item", "$prop") || "disabled";
} ## end sub get_reverse
sub get_stat_geoip {
my $c = shift;
if (system("/bin/test -f /lib/modules/`/bin/uname -r`/weak-updates/xtables-addons/xt_geoip.ko") != 0) {
return $c->l('xtg_ERROR_MISSING_MODULE');
} elsif (system("/sbin/lsmod | grep 'xt_geoip' > /dev/null") != 0) {
return $c->l('xtg_ERROR_UNLOADED_MODULE');
} elsif (get_geoip() eq 'enabled' && system("/sbin/iptables -L -n | grep 'XTGeoIP' > /dev/null") != 0) {
return $c->l('xtg_ERROR_FILTER_CHAIN_MISSING');
} else {
return '';
}
} ## end sub get_stat_geoip
sub get_stat_license_key {
my $c = shift;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
if (($cdb->get_prop('geoip', 'status') || 'disabled') eq 'enabled') {
if (($cdb->get_prop('geoip', 'LicenseKey') || '') ne '') {
return '';
}
} ## end if (($cdb->get_prop('geoip'...)))
return $c->l('xtg_ERROR_LICENSE_KEY');
} ## end sub get_stat_license_key
sub get_date_update {
#my $file = "/usr/share/xt_geoip/LE/A1.iv4";
my $file = "/usr/share/xt_geoip/A1.iv4";
my $filetime = (-e $file) ? (stat($file))[9] : 0;
return strftime("%Y/%m/%d %H:%M", localtime($filetime)) || '';
} ## end sub get_date_update
sub get_srv_name {
my ($c) = @_;
return $c->param('Name');
}
sub get_services_table {
my $c = shift;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $choice = shift || 'sel';
my @services;
my @serv_rec;
if ($choice ne 'all') {
@services = split(/,/, $cdb->get_prop("masq", "XtServices"));
for (@services) {
my $rec = $cdb->get($_);
push @serv_rec, $rec if ($rec && $rec->prop('TCPPort'));
}
} else {
for ($cdb->get_all_by_prop(type => 'service')) {
push @serv_rec, $_ if ($_->prop('TCPPort'));
}
} ## end else [ if ($choice ne 'all') ]
return \@serv_rec;
} ## end sub get_services_table
sub get_srv_badcountries {
my ($c, $name, $full) = @_;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $badc = $cdb->get_prop($name, "BadCountries") || "";
return $badc unless $full;
my $rev = (($cdb->get_prop($name, "XTGeoipRev") || "disabled") eq "enabled") ? "!=" : "==";
return "$rev $badc ";
} ## end sub get_srv_badcountries
#Subroutine to list statistics
sub generateStats {
my $c = shift;
my $stats_type = shift;
my $out = '';
# Untaint $name before use in system()
$stats_type =~ /(.+)/;
$stats_type = $1;
if ($stats_type ne "ipt" and $stats_type ne "ssh" and $stats_type ne "f2b") {
$out .= sprintf("<h3>%s %s </h3>", $c->l('xtg_INVALID_STATS_TYPE'), $stats_type);
return $out;
}
# my $now_string = $c->gen_locale_date_string();
my $file = "/var/lib/xt_geoip/extA_" . $stats_type . "_country.lst";
my $filetime = (-e $file) ? (stat($file))[9] : 0;
my $date_string = strftime("%Y/%m/%d %H:%M", localtime($filetime)) || '';
$out .= sprintf("<h3>%s %s %s</h3>", $c->l('xtg_STATS_GENERATED'), $stats_type, $date_string);
open(Xt_GEOIPSTATS, $file);
$out .= sprintf "<pre>";
while (<Xt_GEOIPSTATS>) {
$out .= sprintf("%s", $_);
}
close Xt_GEOIPSTATS;
$out .= sprintf "</pre>";
$out .= sprintf("<h3>%s</h3>", $c->l('xtg_END_OF_STATS'));
return $out;
} ## end sub generateStats
#Subroutine to list countries codes
sub generateCodes {
my $c = shift;
my $out = '';
# my $now_string = $c->gen_locale_date_string();
my $file = "/usr/share/xt_geoip/geoip_countries_list.txt";
unless (-e $file) {
$out .= "<br>" . $c->l('xtg_INVALID_CODES_LIST');
return $out;
}
my $filetime = (-e $file) ? (stat($file))[9] : 0;
my $date_string = strftime("%Y/%m/%d %H:%M", localtime($filetime)) || '';
$out .= sprintf("<h3>%s %s </h3>", $c->l('xtg_COUNTRY_LIST'), $date_string);
open(Xt_GEOIPCODES, $file);
$out .= sprintf "<pre>";
while (<Xt_GEOIPCODES>) {
$out .= sprintf("%s", $_);
}
close Xt_GEOIPCODES;
$out .= sprintf "</pre>";
$out .= sprintf("<h3>%s</h3>", $c->l('xtg_END_OF_CODES'));
return $out;
} ## end sub generateCodes
#Subroutine to list other services codes
sub otherServices {
my ($c, $choice) = @_;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my %serv_ok = map { $_ => 1 } split(/,/, $cdb->get_prop("masq", "XtServices"));
# unless $choice eq 'all';
my @serv_others = ();
for ($cdb->get_all_by_prop(type => 'service')) {
next unless $_->prop('TCPPort');
# if ( $_->prop('TCPPort')) {
# push @serv_others, $_->key unless exists( $serv_ok{$_->key});
push @serv_others, $_->key unless $choice eq 'sel' and not exists($serv_ok{ $_->key });
# }
} ## end for ($cdb->get_all_by_prop...)
return \@serv_others;
} ## end sub otherServices
#Subroutine to update list services codes
sub do_otherServices {
my $c = shift;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $serv1 = ($cdb->get_prop("masq", "XtServices")) || '';
my $serv2 = join(',', @{ $c->every_param('Selectedservices') });
$cdb->set_prop("masq", "XtServices", $serv2) if ($serv1 ne $serv2);
return 'OK';
} ## end sub do_otherServices
sub change_settings {
my $c = shift;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $mq_bc = get_badcountries();
my $mq_gp = get_geoip();
my $masq = $cdb->get('masq') || "disabled";
my $mq_rv = $masq->prop('XTGeoipRev') || 'disabled';
my $mq_ot = $masq->prop('XTGeoipOther') || 'disabled';
my $n_mq_bc = $c->param("Masq_badcountries");
my $n_mq_gp = $c->param("Masq_geoip") || $mq_gp;
my $n_upd_gp = $c->param("Update_geoip") || '';
my $n_mq_rv = $c->param("Masq_reverse") || $mq_rv;
my $n_mq_ot = $c->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 'OK';
} ## end if (($n_mq_bc eq $mq_bc...))
$cdb->set_prop("masq", "BadCountries", $n_mq_bc);
$cdb->set_prop("masq", "GeoIP", $n_mq_gp);
$cdb->set_prop("masq", "XTGeoipRev", $n_mq_rv);
$cdb->set_prop("masq", "XTGeoipOther", $n_mq_ot);
my $eventloc = "xt_geoip-modify";
$eventloc = "xt_geoip-update" if $n_upd_gp eq 'YES';
unless (system("/sbin/e-smith/signal-event", $eventloc) == 0) {
return $c->l("xtg_ERROR_UPDATING");
}
return 'OK';
} ## end sub change_settings
=head2 valid_badcountries
subroutine to validate countries.
=cut
sub must_exist {
my $c = shift;
my $listerr = "";
my @mq_bcs = split /[,:]/, $c->param("Masq_badcountries");
if (@mq_bcs) {
my $ctr = @mq_bcs;
return $c->l('xtg_ERROR_COUNTRY_MAX', $ctr) if ($ctr > 50);
foreach my $bcs (@mq_bcs) {
#my $file = "/usr/share/xt_geoip/LE/" . $bcs . ".iv4";
my $file = "/usr/share/xt_geoip/" . $bcs . ".iv4";
if (!-f $file) { $listerr .= $bcs . ","; }
}
return $c->l('xtg_ERROR_COUNTRY_NOT_EXIST', $listerr) if $listerr;
} ## end if (@mq_bcs)
return 'OK';
} ## end sub must_exist
sub remove_serv {
my ($c) = @_;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $name = $c->param('Name');
# Untaint $name before use in system()
$name =~ /(.+)/;
$name = $1;
if (my $serv = $cdb->get($name)) {
my $servBC = $serv->prop('BadCountries') || '';
if ($servBC ne '') {
my $tps = $cdb->get_prop_and_delete($name, "BadCountries");
$tps = $cdb->get_prop_and_delete($name, "XTGeoipRev");
unless (system("/sbin/e-smith/signal-event", "xt_geoip-service") == 0) {
return $c->l("xtg_ERROR_WHILE_DELETING_SERVICE") . ' ' . $name;
}
return 'OK';
} ## end if ($servBC ne '')
} else {
return $c->l('xtg_CANT_FIND_SERV');
}
} ## end sub remove_serv
sub modify_serv {
my ($c) = @_;
our $cdb = esmith::ConfigDB::UTF8->open() or die "Couldn't open ConfigDB::UTF8\n";
my $name = $c->param('Name');
# Untaint $name before use in system()
$name =~ /(.+)/;
$name = $1;
if (my $serv = $cdb->get($name)) {
my $servBC = $serv->prop('BadCountries') || '';
my $servRev = $serv->prop('XTGeoipRev') || 'disabled';
my $n_servBC = $c->param("Masq_srv_badcountries");
my $n_servRev = $c->param("Masq_srv_reverse") || $servRev;
if ($n_servBC eq $servBC && $n_servRev eq $servRev) {
return 'OK';
}
$cdb->set_prop($name, "BadCountries", $n_servBC);
$cdb->set_prop($name, "XTGeoipRev", $n_servRev);
unless (system("/sbin/e-smith/signal-event", "xt_geoip-service") == 0) {
return $c->l("xtg_ERROR_UPDATING") . ' ' . $name;
}
return 'OK';
} else {
return $c->l('xtg_CANT_FIND_SERV');
}
} ## end sub modify_serv
1;

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
<HR class='sme-copyrightbar'>
%= form_for '/xt_geoip' => (method => 'POST') => begin
%= form_for '/xtgeoip' => (method => 'POST') => begin
%= $c->render_to_string(inline => l('xtg_COUNTRY_LIST_DESCRIPTION'));
%= submit_button l 'xtg_CNTRY_LIST', class => 'action'
@@ -11,4 +11,4 @@
% end
</div>
<!-- button_to l('xtg_CNTRY_LIST') => "/xt_geoip" => (class => 'action') -->
<!-- button_to l('xtg_CNTRY_LIST') => "/xgteoip" => (class => 'action') -->

View File

@@ -2,7 +2,7 @@
<HR class='sme-copyrightbar'>
%= form_for '/xt_geoip' => (method => 'POST') => begin
%= form_for '/xtgeoip' => (method => 'POST') => begin
<h2>
%= l('xtg_SERVICE_DESCRIPTION')
@@ -45,8 +45,8 @@
%= t td => (class => 'sme-border') => $sv->prop('access')
%= t td => (class => 'sme-border') => $c->render_to_string(inline => $BC)
% my $actionModify = "<a href='xt_geoipb?Choice=UPDS&Name=" . $sv->key . "'>" . l('MODIFY') . "</a>";
% my $actionRemove = "<a href='xt_geoipb?Choice=REMS&Name=" . $sv->key . "'>" . l('REMOVE') . "</a>";
% my $actionModify = "<a href='xtgeoipb?Choice=UPDS&Name=" . $sv->key . "'>" . l('MODIFY') . "</a>";
% my $actionRemove = "<a href='xtgeoipb?Choice=REMS&Name=" . $sv->key . "'>" . l('REMOVE') . "</a>";
<td class='sme-border'><%= $c->render_to_string(inline => $actionModify) %></td>
<td class='sme-border'><%= $c->render_to_string(inline => $actionRemove) %></td>

View File

@@ -4,7 +4,7 @@
%= $c->render_to_string(inline => l('xtg_STATS_DESCRIPTION'));
</h3>
%= form_for '/xt_geoip' => (method => 'POST') => begin
%= form_for '/xtgeoip' => (method => 'POST') => begin
%= $c->render_to_string(inline => l('xtg_IPT_LIST_DESCRIPTION'));
%= submit_button l 'xtg_IPT_LIST', class => 'action'
@@ -12,7 +12,7 @@
% end
%= form_for '/xt_geoip' => (method => 'POST') => begin
%= form_for '/xtgeoip' => (method => 'POST') => begin
%= $c->render_to_string(inline => l('xtg_SSH_LIST_DESCRIPTION'));
@@ -21,7 +21,7 @@
% end
%= form_for '/xt_geoip' => (method => 'POST') => begin
%= form_for '/xtgeoip' => (method => 'POST') => begin
%= $c->render_to_string(inline => l('xtg_F2B_LIST_DESCRIPTION'));

View File

@@ -1,4 +1,4 @@
% layout 'default', title => "Smanager - xt_geoip";
% layout 'default', title => "Smanager - xtgeoip";
% content_for 'module' => begin
@@ -23,7 +23,7 @@
%= $c->render_to_string(inline => l('xtg_XT_GEOIP_STATUS_DESCRIPTION'));
<br>
%= form_for '/xt_geoip' => (method => 'POST') => begin
%= form_for '/xtgeoip' => (method => 'POST') => begin
<p><span class=label>
%=l 'xtg_LABEL_GEOIP_STATUS'

View File

@@ -1,4 +1,4 @@
% layout 'default', title => "Smanager - xt_geoip";
% layout 'default', title => "Smanager - xtgeoip";
% content_for 'module' => begin
@@ -23,7 +23,7 @@
%= $c->render_to_string(inline => l('xtg_DESC_AVAILABLE_SERVICES'));
<br>
%= form_for '/xt_geoipb' => (method => 'POST') => begin
%= form_for '/xtgeoipb' => (method => 'POST') => begin
<p><span class=label>
%=l 'xtg_LABEL_AVAILABLE_SERVICES'

View File

@@ -1,4 +1,4 @@
% layout 'default', title => "Smanager - xt_geoip - List";
% layout 'default', title => "Smanager - xtgeoip - List";
% content_for 'module' => begin
@@ -19,7 +19,7 @@
<h1><%= $title %></h1>
%= form_for '/xt_geoip' => (method => 'GET') => begin
%= form_for '/xtgeoip' => (method => 'GET') => begin
<br>
%= $c->render_to_string(inline => stash 'modul');

View File

@@ -1,4 +1,4 @@
% layout 'default', title => "Smanager - xt_geoip";
% layout 'default', title => "Smanager - xtgeoip";
% content_for 'module' => begin
@@ -25,7 +25,7 @@
%= $c->render_to_string(inline => l('xtg_REMOVE_DESC'));
%= form_for '/xt_geoipb' => (method => 'POST') => begin
%= form_for '/xtgeoipb' => (method => 'POST') => begin
<p><span class=label>
%=l 'xtg_LABEL_SERVICE'

View File

@@ -1,4 +1,4 @@
% layout 'default', title => "Smanager - xt_geoip";
% layout 'default', title => "Smanager - xtgeoip";
% content_for 'module' => begin
@@ -25,7 +25,7 @@
%= $c->render_to_string(inline => l('xtg_ADD_DESC'));
%= form_for '/xt_geoipb' => (method => 'POST') => begin
%= form_for '/xtgeoipb' => (method => 'POST') => begin
<p><span class=label>
%=l 'xtg_LABEL_SERVICE'

View File

@@ -1,4 +1,4 @@
% layout 'default', title => "Smanager - xt_geoip";
% layout 'default', title => "Smanager - xtgeoip";
% content_for 'module' => begin
@@ -19,7 +19,7 @@
<h1><%= $title %></h1>
%= form_for '/xt_geoipb' => (method => 'POST') => begin
%= form_for '/xtgeoipb' => (method => 'POST') => begin
<p>
%=l 'xtg_DESC_GEOIP'

View File

@@ -1,6 +1,6 @@
%define name smeserver-xt_geoip
%define version 1.3.1
%define release 28
%define release 31
Summary: smserver rpm to setup database, update and configuration for xt_geoip module with a panel.
Name: %{name}
@@ -78,6 +78,19 @@ rm -rf %{name}-%{version}
%changelog
* Tue Oct 28 2025 Jean-Philippe Pialasse <jpp@koozali.org> 1.3.1-31.sme
- Update the references in Createlinks to smeserver-*-update [SME: 13249]
thanks to Zsolt Vasarhelyi
* Wed Oct 22 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 1.3.1-30.sme
- Fix error in patch for [SME: 12445]
- Tidy template
* Tue Oct 21 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 1.3.1-29.sme
- Fix SmartMatch errors [SME: 13240]
- Fix panel errors [SME: 13173]
- Do not block remote access authorized [SME: 12445]
* Tue Oct 07 2025 Brian Read <brianr@koozali.org> 1.3.1-28.sme
- Add UTF8 and avoid potential DB caching problems [SME: 13209]