1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 18:45:42 -04:00

Update things, finally got netns working

This commit is contained in:
Ryan Voots 2018-05-22 03:32:25 -04:00
parent 0a5546d01f
commit a63bda084b
8 changed files with 87 additions and 30 deletions

37
bin/setup-netns.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
set -e
set -u
ip netns delete perlbot >& /dev/null && echo "Removed old perlbot namespace" || echo "No perlbot namespace yet"
ip link delete perlbot-public type veth >& /dev/null && echo "Removed old perlbot veth device" || echo "No perlbot veth device yet"
ip netns add perlbot
ip link add perlbot-private type veth peer name perlbot-public
ip link set perlbot-private netns perlbot
sleep 1
ip addr add 192.168.196.1/24 dev perlbot-public
ip link set perlbot-public up
ip netns exec perlbot ip link set dev lo up
ip netns exec perlbot ip addr add 192.168.196.2/24 dev perlbot-private
ip netns exec perlbot ip link set perlbot-private up
ip netns exec perlbot ip route add default via 192.168.196.1
iptables -N PERLBOT-FORWARD || iptables -F PERLBOT-FORWARD
iptables -t nat -N PERLBOT-POST || iptables -t nat -F PERLBOT-POST
iptables -A PERLBOT-FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A PERLBOT-FORWARD -i perlbot-public -d 192.168.32.1 -j ACCEPT
iptables -A PERLBOT-FORWARD -i perlbot-public -d 192.168.196.0/24 -j ACCEPT
iptables -A PERLBOT-FORWARD -i perlbot-public -d 192.168.0.0/16 -j REJECT
iptables -A PERLBOT-FORWARD -i perlbot-public -d 10.0.0.0/8 -j REJECT
#iptables -t nat -A PERLBOT-POST -s 192.168.196.0/24 -d 192.168.196.0/24 -j ACCEPT
#iptables -t nat -A PERLBOT-POST -s 192.168.196.0/24 -o perlbot-public -j MASQUERADE
iptables -t filter -D FORWARD -j PERLBOT-FORWARD || echo "No filter chain loaded"
#iptables -t nat -D POSTROUTING -j PERLBOT-POST || echo "No nat chain loaded"
#iptables -t nat -A POSTROUTING -j PERLBOT-POST
iptables -t filter -I FORWARD 1 -j PERLBOT-FORWARD

View file

@ -118,7 +118,7 @@ requires 'Task::Kensho::Logging';
requires 'Task::Kensho::ModuleDev'; requires 'Task::Kensho::ModuleDev';
requires 'Task::Kensho::OOP'; requires 'Task::Kensho::OOP';
#requires 'Task::Kensho::Testing'; #requires 'Task::Kensho::Testing';
requires 'Task::Kensho::XML'; #requires 'Task::Kensho::XML';
requires 'Text::Unidecode'; requires 'Text::Unidecode';
requires 'experimental'; requires 'experimental';
@ -127,3 +127,18 @@ requires 'Math::Calc::Parser';
requires 'ReadonlyX'; requires 'ReadonlyX';
requires 'Const::Fast'; requires 'Const::Fast';
requires 'DateTime::Event::Holiday::US'; requires 'DateTime::Event::Holiday::US';
requires 'App::EvalServerAdvanced::ConstantCalc';
requires 'Crypt::OpenSSL::X509';
requires 'Math::Random::Secure'; # undeclared dep of Data::Random::Flexible
requires 'Data::Random::Flexible';
requires 'Acme::AsciiEmoji';
requires 'PadWalker';
requires 'Encode::Simple';
requires 'PPR';
requires 'Keyword::Simple';
requires 'Unicode::UTF8';
requires 'List::Gather';
requires 'Lingua::EN::Inflexion';
requires 'local::lib';

View file

@ -17,6 +17,9 @@ server "*" {
plugin "eval" {addressed: false; } plugin "eval" {addressed: false; }
plugin "deparse" {addressed: false; } plugin "deparse" {addressed: false; }
} }
channel "#perl6" {
plugin "eval" {addressed: false; }
}
channel "#perl-help" { channel "#perl-help" {
plugin "eval" {addressed: false; } plugin "eval" {addressed: false; }
plugin "deparse" {addressed: false; } plugin "deparse" {addressed: false; }

View file

@ -50,7 +50,7 @@ sub _start {
# TODO setup TCP server. # TODO setup TCP server.
$self->{server} = POE::Component::Server::TCP->new( $self->{server} = POE::Component::Server::TCP->new(
Port => 1784, Port => 1784,
Address =>'127.0.0.1', Address =>'192.168.196.2',
ClientFilter => "POE::Filter::Line", ClientFilter => "POE::Filter::Line",
ClientInput => \&receive_paste, ClientInput => \&receive_paste,
); );

View file

@ -276,6 +276,9 @@ sub handle {
my ($self, $said, $pm) = @_; my ($self, $said, $pm) = @_;
my $conf = $self->get_conf_for_channel($pm, $said->{server}, $said->{channel}); my $conf = $self->get_conf_for_channel($pm, $said->{server}, $said->{channel});
$said->{body} =~ s/^\s*(what|who|where|how|when|why)\s+($COPULA_RE)\s+(?<fact>.*?)\??\s*$/$+{fact}/i;
my $prefix = $conf->{prefix_command}; my $prefix = $conf->{prefix_command};
return unless $prefix; return unless $prefix;

View file

@ -1,4 +1,3 @@
use Net::INET6Glue::INET_is_INET6;
use LWP::UserAgent; use LWP::UserAgent;
use HTML::TreeBuilder::XPath; use HTML::TreeBuilder::XPath;
@ -21,6 +20,7 @@ sub {
my $ua = LWP::UserAgent->new( agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36" ); my $ua = LWP::UserAgent->new( agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36" );
my $url; my $url;
if( $said->{body} =~ s{(https?://\S+)\s*}{} ) { if( $said->{body} =~ s{(https?://\S+)\s*}{} ) {
$url = $1; $url = $1;
} }
@ -32,7 +32,6 @@ sub {
return; return;
} }
my $resp = $ua->get( $url ); my $resp = $ua->get( $url );
if( not $resp ) { if( not $resp ) {

View file

@ -109,7 +109,7 @@ sub command {
} elsif ($command eq 'banuser') { } elsif ($command eq 'banuser') {
my $paste = $args[0]; my $paste = $args[0];
if (my ($id) = ($paste =~ m{^(?:(?:https?://(?:[a-z\.]+)?perlbot.pl/p(?:astebin)?/([^/]{6,})/?)|([^/]+))$}g)) { if (my ($id) = ($paste =~ m{^(?:(?:https?://(?:[a-z\.]+)?(?:perlbot\.pl|perl\.bot)/p(?:astebin)?/([^/]{6,})/?)|([^/]+))$}g)) {
my $response = $self->ban_user_paste($env, $id, $who, $where); my $response = $self->ban_user_paste($env, $id, $who, $where);
return ("handled", $response); return ("handled", $response);
} else { } else {

View file

@ -36,9 +36,7 @@ sub make_pastebin {
} }
} }
my @versions = ('', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.6t 5.8 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.26t all));
my @versions = ('', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.8 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 all));
sub new { sub new {
my( $class ) = @_; my( $class ) = @_;
@ -205,7 +203,9 @@ sub command {
if (rand() < $special{$holiday}{prob}) { if (rand() < $special{$holiday}{prob}) {
my $char = $special{$holiday}{chars}[rand()*@{$special{$holiday}{chars}}]; my $char = $special{$holiday}{chars}[rand()*@{$special{$holiday}{chars}}];
$resultstr .= " ".$char; unless ($said->{nested}) { # if we're called in compose don't do this
$resultstr .= " ".$char; # disabled until i make it magic-erer
}
} }
} }