mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-21 12:04:56 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1b4b4347c5 | ||
![]() |
2f37af43c5 | ||
![]() |
56e5970c64 | ||
![]() |
2b76b68c65 | ||
![]() |
d2eeac4c32 |
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
HEAD
|
HEAD
|
||||||
====
|
====
|
||||||
|
Enhancements:
|
||||||
|
- support for Linux up to 4.15
|
||||||
|
|
||||||
|
|
||||||
v2.14 (2017-11-22)
|
v2.14 (2017-11-22)
|
||||||
|
@@ -93,4 +93,8 @@ static inline struct net *par_net(const struct xt_action_param *par)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NF_CT_ASSERT
|
||||||
|
# define NF_CT_ASSERT(x) WARN_ON(!(x))
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _XTABLES_COMPAT_H */
|
#endif /* _XTABLES_COMPAT_H */
|
||||||
|
@@ -357,11 +357,18 @@ has_logged_during_this_minute(const struct peer *peer)
|
|||||||
*
|
*
|
||||||
* @r: rule
|
* @r: rule
|
||||||
*/
|
*/
|
||||||
static void
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
|
||||||
peer_gc(unsigned long r)
|
static void peer_gc(struct timer_list *tl)
|
||||||
|
#else
|
||||||
|
static void peer_gc(unsigned long r)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
|
||||||
|
struct xt_pknock_rule *rule = from_timer(rule, tl, timer);
|
||||||
|
#else
|
||||||
struct xt_pknock_rule *rule = (struct xt_pknock_rule *)r;
|
struct xt_pknock_rule *rule = (struct xt_pknock_rule *)r;
|
||||||
|
#endif
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
struct list_head *pos, *n;
|
struct list_head *pos, *n;
|
||||||
|
|
||||||
@@ -469,9 +476,13 @@ add_rule(struct xt_pknock_mtinfo *info)
|
|||||||
if (rule->peer_head == NULL)
|
if (rule->peer_head == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
|
||||||
|
timer_setup(&rule->timer, peer_gc, 0);
|
||||||
|
#else
|
||||||
init_timer(&rule->timer);
|
init_timer(&rule->timer);
|
||||||
rule->timer.function = peer_gc;
|
rule->timer.function = peer_gc;
|
||||||
rule->timer.data = (unsigned long)rule;
|
rule->timer.data = (unsigned long)rule;
|
||||||
|
#endif
|
||||||
|
|
||||||
rule->status_proc = proc_create_data(info->rule_name, 0, pde,
|
rule->status_proc = proc_create_data(info->rule_name, 0, pde,
|
||||||
&pknock_proc_ops, rule);
|
&pknock_proc_ops, rule);
|
||||||
|
@@ -8,23 +8,45 @@ use IO::Handle;
|
|||||||
use Text::CSV_XS; # or trade for Text::CSV
|
use Text::CSV_XS; # or trade for Text::CSV
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
my $le32 = pack("V", 0x10000000);
|
||||||
|
my $be32 = pack("N", 0x10000000);
|
||||||
|
my $u32 = undef;
|
||||||
|
|
||||||
|
sub wantBE { return !$u32 || $u32 eq $be32; }
|
||||||
|
sub wantLE { return !$u32 || $u32 eq $le32; }
|
||||||
|
|
||||||
my $csv = Text::CSV_XS->new({
|
my $csv = Text::CSV_XS->new({
|
||||||
allow_whitespace => 1,
|
allow_whitespace => 1,
|
||||||
binary => 1,
|
binary => 1,
|
||||||
eol => $/,
|
eol => $/,
|
||||||
}); # or Text::CSV
|
}); # or Text::CSV
|
||||||
my $target_dir = ".";
|
my $target_dir = ".";
|
||||||
|
my $native_only = 0;
|
||||||
|
|
||||||
&Getopt::Long::Configure(qw(bundling));
|
&Getopt::Long::Configure(qw(bundling));
|
||||||
&GetOptions(
|
&GetOptions(
|
||||||
"D=s" => \$target_dir,
|
"D=s" => \$target_dir,
|
||||||
|
"n" => \$native_only,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!-d $target_dir) {
|
if (!-d $target_dir) {
|
||||||
print STDERR "Target directory $target_dir does not exist.\n";
|
print STDERR "Target directory $target_dir does not exist.\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
foreach (qw(LE BE)) {
|
my @dbs = qw(LE BE);
|
||||||
|
if ($native_only) {
|
||||||
|
$u32 = pack("L", 0x10000000);
|
||||||
|
if ($u32 eq $le32) {
|
||||||
|
@dbs = qw(LE);
|
||||||
|
} elsif ($u32 eq $be32) {
|
||||||
|
@dbs = qw(BE);
|
||||||
|
} else {
|
||||||
|
print STDERRR "Cannot determine endianness.\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (@dbs) {
|
||||||
my $dir = "$target_dir/$_";
|
my $dir = "$target_dir/$_";
|
||||||
if (!-e $dir && !mkdir($dir)) {
|
if (!-e $dir && !mkdir($dir)) {
|
||||||
print STDERR "Could not mkdir $dir: $!\n";
|
print STDERR "Could not mkdir $dir: $!\n";
|
||||||
@@ -80,43 +102,55 @@ sub dump_one
|
|||||||
scalar(@{$country->{pool_v6}}),
|
scalar(@{$country->{pool_v6}}),
|
||||||
$iso_code, $country->{name};
|
$iso_code, $country->{name};
|
||||||
|
|
||||||
$file = "$target_dir/LE/".uc($iso_code).".iv6";
|
if (wantLE) {
|
||||||
if (!open($fh_le, "> $file")) {
|
$file = "$target_dir/LE/".uc($iso_code).".iv6";
|
||||||
print STDERR "Error opening $file: $!\n";
|
if (!open($fh_le, "> $file")) {
|
||||||
exit 1;
|
print STDERR "Error opening $file: $!\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
foreach my $range (@{$country->{pool_v6}}) {
|
||||||
|
print $fh_le &ip6_swap($range->[0]), &ip6_swap($range->[1]);
|
||||||
|
}
|
||||||
|
close $fh_le;
|
||||||
}
|
}
|
||||||
$file = "$target_dir/BE/".uc($iso_code).".iv6";
|
if (wantBE) {
|
||||||
if (!open($fh_be, "> $file")) {
|
$file = "$target_dir/BE/".uc($iso_code).".iv6";
|
||||||
print STDERR "Error opening $file: $!\n";
|
if (!open($fh_be, "> $file")) {
|
||||||
exit 1;
|
print STDERR "Error opening $file: $!\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
foreach my $range (@{$country->{pool_v6}}) {
|
||||||
|
print $fh_be $range->[0], $range->[1];
|
||||||
|
}
|
||||||
|
close $fh_be;
|
||||||
}
|
}
|
||||||
foreach my $range (@{$country->{pool_v6}}) {
|
|
||||||
print $fh_be $range->[0], $range->[1];
|
|
||||||
print $fh_le &ip6_swap($range->[0]), &ip6_swap($range->[1]);
|
|
||||||
}
|
|
||||||
close $fh_le;
|
|
||||||
close $fh_be;
|
|
||||||
|
|
||||||
printf "%5u IPv4 ranges for %s %s\n",
|
printf "%5u IPv4 ranges for %s %s\n",
|
||||||
scalar(@{$country->{pool_v4}}),
|
scalar(@{$country->{pool_v4}}),
|
||||||
$iso_code, $country->{name};
|
$iso_code, $country->{name};
|
||||||
|
|
||||||
$file = "$target_dir/LE/".uc($iso_code).".iv4";
|
if (wantLE) {
|
||||||
if (!open($fh_le, "> $file")) {
|
$file = "$target_dir/LE/".uc($iso_code).".iv4";
|
||||||
print STDERR "Error opening $file: $!\n";
|
if (!open($fh_le, "> $file")) {
|
||||||
exit 1;
|
print STDERR "Error opening $file: $!\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
foreach my $range (@{$country->{pool_v4}}) {
|
||||||
|
print $fh_le pack("VV", $range->[0], $range->[1]);
|
||||||
|
}
|
||||||
|
close $fh_le;
|
||||||
}
|
}
|
||||||
$file = "$target_dir/BE/".uc($iso_code).".iv4";
|
if (wantBE) {
|
||||||
if (!open($fh_be, "> $file")) {
|
$file = "$target_dir/BE/".uc($iso_code).".iv4";
|
||||||
print STDERR "Error opening $file: $!\n";
|
if (!open($fh_be, "> $file")) {
|
||||||
exit 1;
|
print STDERR "Error opening $file: $!\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
foreach my $range (@{$country->{pool_v4}}) {
|
||||||
|
print $fh_be pack("NN", $range->[0], $range->[1]);
|
||||||
|
}
|
||||||
|
close $fh_be;
|
||||||
}
|
}
|
||||||
foreach my $range (@{$country->{pool_v4}}) {
|
|
||||||
print $fh_le pack("VV", $range->[0], $range->[1]);
|
|
||||||
print $fh_be pack("NN", $range->[0], $range->[1]);
|
|
||||||
}
|
|
||||||
close $fh_le;
|
|
||||||
close $fh_be;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ip6_pack
|
sub ip6_pack
|
||||||
|
Reference in New Issue
Block a user