ppp-gatekeeper-v0.1.0-201406111015/0000755000000000000000000000000012346026211014505 5ustar rootrootppp-gatekeeper-v0.1.0-201406111015/docs/0000755000000000000000000000000012346026211015435 5ustar rootrootppp-gatekeeper-v0.1.0-201406111015/docs/ppp-gatekeeper.sgml0000644000000000000000000001016712346026211021237 0ustar rootroot manpage.1'. You may view the manual page with: `docbook-to-man manpage.sgml | nroff -man | less'. A typical entry in a Makefile or Makefile.am is: manpage.1: manpage.sgml docbook-to-man $< > $@ The docbook-to-man binary is found in the docbook-to-man package. Please remember that if you create the nroff version in one of the debian/rules file targets (such as build), you will need to include docbook-to-man in your Build-Depends control field. --> Nigel"> Kukard"> 2012-09-08 12:20"> 8"> nkukard@lbsd.net"> PPP-GATEKEEPER"> Debian"> GNU"> GPL"> ]>
&dhemail;
&dhfirstname; &dhsurname; 2010-2012 &dhusername; &dhdate;
&dhucpackage; &dhsection; &dhpackage; PPP Gatekeeper is a daemon that manages PPPOE connections. &dhpackage; DESCRIPTION PPP Gatekeeper is a daemon that manages PPPOE connections and supports various levels of redundancy and failover. OPTIONS These programs follow the usual &gnu; command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. Specify config file to use. Run in foreground, don't daemonize. Show summary of options. SEE ALSO pppd (8). AUTHOR This manual page was written by &author; <&dhemail;>. Permission is granted to copy, distribute and/or modify this document under the terms of the &gnu; General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.
ppp-gatekeeper-v0.1.0-201406111015/TODO0000644000000000000000000000005312346026211015173 0ustar rootroot* Trigger scripts * Poll interface stats ppp-gatekeeper-v0.1.0-201406111015/INSTALL0000644000000000000000000000050712346026211015540 0ustar rootrootDebian: 1. Install ipset & ipset module $ apt-get install ipset ipset-source $ module-assistent auto-install ipset 2. Short circuit ip-up $ cat < /etc/ppp/ip-up.local #!/bin/bash EOF $ chmod 0755 /etc/ppp/ip-up.local 3. For shorewall change these in /etc/shorewall/shorewall.conf IP_FORWARDING=On FORWARD_CLEAR_MARK=No ppp-gatekeeper-v0.1.0-201406111015/ppp-gatekeeper.conf0000644000000000000000000000515412346026211020272 0ustar rootroot# # G L O B A L S E T T I N G S # [global] # Local networks # Comma or whitespace separated localnets=10.0.0.0/24,192.168.0.0/16 # # Default Route Load Balancing # # The default route policy to use when routing over multiple default routes. # The format of this is PRIORITY:POLICY. Where priority would be the priority # specified below in the use_default_route=X setting. Policy is one of the # following values: # rr = round robin # random = random # wrandon = weighted random # atp = auto balance traffic throughput - TODO # # Multiple policies can be specified by separating them with a comma or # whitespace. 7:random,9:rr,1:atp default_route_policy=7:random # # C O N N E C T I O N S E T T I N G S # [connection1] # # PPPOE Settings # # Interface to pppoe over interface=eth2 # PPP unit to use ppp ppp_unit=100 # Username and password username=myuser password=mypass # # DNS # # Use this link as DNS if set # The value is a priority, 1-99, higher is better use_dns=9 # # Explicit Routing # # Routing table # Format: # route [priority 1-99] [weight 1-99] # Eg. # 172.16.0.1/32 # 172.16.1.0/24 40 weight # # Priority defaults to 50 if not specified. routing_table=/etc/ppp/local-routes # Routing table exclusions # Same format as above, weight is not supported. routing_table_exclusions=/etc/ppp/local-routes-excl # # Default Routes # # Use this link as a default route if set. The value format is specified # either as a priority, 1-99 (higher is better), or as a PRIORITY:WEIGHT. # When a WEIGHT is specified this will determine how many times more traffic # will be routed over the interface. Weight defaults to 10 if not specified. use_default_route=7 # # Scripts # # Run this before we think about starting pppd # Paremeters passed: # none #init=/bin/true # Run this when connection is up # Parameters passed: # $link_name $interface $remote_ip $local_ip $dns1 $dns2 #ifup=/bin/true # Run this when connection goes down # Parameters passed: # $link_name $interface $remote_ip $local_ip $dns1 $dns2 #ifdown=/bin/true # Run to bring the interface up, init argument to pppd # Parameters passed: # none #ppp_init=/bin/true # Run to connect the interface, connect argument to pppd # Parameters passed: # none #ppp_connect=/bin/true # Run to disconnect the interface, disconnect argument to pppd # Parameters passed: # none #ppp_disconnect=/bin/true # # Traffic Shaping Options # # If a numeric value is specified, this will be interpreted as the max # link speed in kbit/s. It will be used internally to set various values # to optimize the shaping process # # use_shaping=4096 use_shaping=yes ppp-gatekeeper-v0.1.0-201406111015/contrib/0000755000000000000000000000000012346026211016145 5ustar rootrootppp-gatekeeper-v0.1.0-201406111015/contrib/ppp-gatekeeper.modprobe0000644000000000000000000000011212346026211022601 0ustar rootrootoptions xt_recent ip_list_tot=16384 ip_pkt_list_tot=1 ip_list_hash_size=0 ppp-gatekeeper-v0.1.0-201406111015/contrib/ppp-gatekeeper.dnsmasq0000644000000000000000000000020112346026211022437 0ustar rootroot# Don't forward local domains or local addies domain-needed bogus-priv # Resolver config resolv-file=/etc/ppp/resolv-pppgk.conf ppp-gatekeeper-v0.1.0-201406111015/contrib/start.shorewall0000644000000000000000000000077312346026211021233 0ustar rootroot#!/bin/bash # If no pid file, just exit [ ! -e "/var/run/ppp-gatekeeper/ppp-gatekeeper.pid" ] && exit 0 PPPGK=$(cat /var/run/ppp-gatekeeper/ppp-gatekeeper.pid) if [ -e "/proc/$PPPGK/cmdline" ] then rm -f "/var/run/ppp-gatekeeper/ppp-gatekeeper.ipt" kill -USR2 "$PPPGK" i=1 while [ "$i" -lt 10 ] do if [ -e "/var/run/ppp-gatekeeper/ppp-gatekeeper.ipt" ] then . "/var/run/ppp-gatekeeper/ppp-gatekeeper.ipt" exit 0; fi sleep .5; i=$((i+1)) done fi # vim: ts=4 ppp-gatekeeper-v0.1.0-201406111015/ppp-gatekeeper0000755000000000000000000017312612346026211017356 0ustar rootroot#!/usr/bin/perl # # PPP GateKeeper # Copyright (C) 2008-2014, Linux Based Systems Design # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . use strict; use warnings; use Config::IniFiles; use IO::Pty; use IO::Pipe; use IO::Handle; use IO::Select; use Getopt::Long; use Fcntl qw(F_SETFD); use POSIX qw(WNOHANG setsid); use Data::Dumper; my $VERSION = "0.1.0-201406111015"; # DO NOT CHANGE THESE use constant { TABLE_BASE_ID => 100, # Starting value FWMARK_BASE_ID => 0b0000000000001000, # Increment by this FWMARK_INCREMENT => 0b0000000000001000, # Mask all values we can have FWMARK_MASK_ALL => 0b1111111111111000, # Mask for INTERNAL traffic FWMARK_MASK_INT => 0b0000000000000001, # Mask for EXTERNAL traffic FWMARK_MASK_EXT => 0b0000000000000010, ROUTING_TABLE => 240, ROUTING_TABLE_RULE_PRIORITY => 25000, ROUTING_TABLE_EXCL_DEFAULT_PRIORITY => 25, ROUTING_TABLE_DEFAULT_PRIORITY => 50, ROUTING_TABLE_DEFAULT_WEIGHT => 50, DEFAULT_ROUTE_DEFAULT_WEIGHT => 50, TRAFFIC_HISTORY_SIZE => 300, ROUTE_CACHE_PERIOD => 3600, }; # Constants my $configFile = "/etc/ppp/ppp-gatekeeper.conf"; my $pidFile = "/var/run/ppp-gatekeeper/ppp-gatekeeper.pid"; my $fwStateFile = "/var/run/ppp-gatekeeper/ppp-gatekeeper.ipt"; # Grab options my %optctl = (); GetOptions(\%optctl, 'fg', 'config:s', 'help') or exit 1; print(STDERR "PPP GateKeeper v$VERSION, Copyright (c) 2008-2014 Linux Based Systems Design\n") if (defined($optctl{'fg'}) || defined($optctl{'help'})); # Check if user wants usage if (defined($optctl{'help'})) { displayUsage(); } if (defined($optctl{'config'}) && $optctl{'config'} ne "") { $configFile = $optctl{'config'}; } # Check config file exists if (! -f $configFile) { print(STDERR "ERROR: No configuration file '".$configFile."' found!\n"); exit 1; } # Use config file, ignore case tie my %inifile, 'Config::IniFiles', ( -file => $configFile, -nocase => 1 ) or die "Failed to open config file '".$configFile."': ".join("\n",@Config::IniFiles::errors); # Loop with sections my %config; # special globals my @localNets; my @defaultRoutePolicies; foreach my $section (keys %inifile) { if ($section eq "global") { # Pull in globals we treat specially if (defined($inifile{'global'}->{'localnets'})) { @localNets = split(/[\s,]+/,$inifile{'global'}->{'localnets'}); } if (defined($inifile{'global'}->{'default_route_policy'})) { @defaultRoutePolicies = split(/[\s,]+/,$inifile{'global'}->{'default_route_policy'}); } } else { $config{$section} = $inifile{$section}; } } # Become daemon if we have to if (!defined($optctl{'fg'})) { daemonize(); } logMsg('CONTROLLER',undef,'Initializing'); # Write PID file open(PIDFILE,"> $pidFile") or die "Can't create '$pidFile': $!\n"; print PIDFILE $$; close(PIDFILE); # Make stderr autoflushed STDERR->autoflush(1); # Setup signal handler $SIG{CHLD} = \&REAPER; $SIG{INT} = \&INTERRUPT; $SIG{TERM} = \&INTERRUPT; $SIG{HUP} = \&RELOAD; $SIG{USR1} = \&SIGUSR1; $SIG{USR2} = \&SIGUSR2; # Blank my $globals; $globals->{'default_route'} = {}; $globals->{'dns'} = {}; $globals->{'connections'} = {}; $globals->{'fd_list'} = {}; $globals->{'pid_list'} = {}; $globals->{'routes'} = {}; $globals->{'firewall'} = {}; # Time right now my $now = time(); # Work out interface info my $numIfaces = 0; foreach my $connName (keys %config) { my $id = $numIfaces++; my $connConfig = $config{$connName}; $connConfig->{'id'} = $id; $connConfig->{'name'} = $connName; $globals->{'connections'}->{$connName}->{'status'} = 'down'; $globals->{'connections'}->{$connName}->{'last_state_change'} = $now; $connConfig->{'_internal'} = {}; my $connConfigInternal = $connConfig->{'_internal'}; $connConfigInternal->{'table_id'} = TABLE_BASE_ID + $id; $connConfigInternal->{'fwmark_id'} = FWMARK_BASE_ID + ($id * FWMARK_INCREMENT); # Check some options if (!defined($connConfig->{'type'})) { $connConfig->{'type'} = 'pppoe'; } } # Pull in default route policies foreach my $drp (@defaultRoutePolicies) { my ($tprio,$policy) = split('/:/',$drp); my $prio = sprintf('%02u',$tprio); # Check to make sure the value is valid if ($policy ne "rr" && $policy ne "random" && $policy ne "wrandom") { logMsg('CONTROLLER',undef,"Invalid default route policy '$policy' for '$tprio'\n"); next; } # Set policy $globals->{'default_route'}->{'policies'}->{$prio} = $policy; } # Load localnets runCommand('/usr/sbin/ipset','-N','pppgk-localnets','nethash'); runCommand('/usr/sbin/ipset','-F','pppgk-localnets'); foreach my $net (@localNets) { runCommand('/usr/sbin/ipset','-A','pppgk-localnets',$net); } # Excludes from tracking runCommand('/usr/sbin/ipset','-N','pppgk-trackexcl','nethash'); # If for an odd reason a local route goes outbound, don't track it foreach my $net (@localNets) { runCommand('/usr/sbin/ipset','-A','pppgk-trackexcl',$net); } runCommand('/usr/sbin/ipset','-F','pppgk-trackexcl'); # Add our own routing rule runIPRuleAdd('lookup',ROUTING_TABLE,'prio',ROUTING_TABLE_RULE_PRIORITY); runIPRouteFlushTable(ROUTING_TABLE); # Restore the MARK value for ESTABLISHED connections from internal runIPTablesAddToNew('main', 'mangle','pppgk-preroute-e', '-j','CONNMARK','--restore-mark' ); runIPTablesAddJump('main', 'mangle','PREROUTING','pppgk-preroute-e', '-m','set','--match-set','pppgk-localnets','src', '-m','state','--state','ESTABLISHED,RELATED', ); # This is the main rule which restores the RECENT route MARK value runIPTablesNewChain('main','mangle','pppgk-preroute-int-r'); runIPTablesAddJump('main', 'mangle','PREROUTING','pppgk-preroute-int-r', '-m','state','--state','NEW', '-m','mark','--mark',0, '-m','set','--match-set','pppgk-localnets','src' ); # Restore mark for LOCAL traffic outbound not going to localnets runIPTablesAddToNew('main', 'mangle','pppgk-output-e', '-m','state','--state','ESTABLISHED,RELATED', '-j','CONNMARK','--restore-mark' ); runIPTablesInsertJump('main', 'mangle','OUTPUT',1,'pppgk-output-e', '-m','set','!','--match-set','pppgk-localnets','dst', '-m','state','--state','ESTABLISHED,RELATED', ); # This is the main rule which marks RECENT route MARK values for LOCAL traffic going externally runIPTablesNewChain('main','mangle','pppgk-output-int-nr'); runIPTablesInsertJump('main', 'mangle','OUTPUT',2,'pppgk-output-int-nr', '-m','state','--state','NEW', '-m','mark','--mark',0, '-m','set','!','--match-set','pppgk-localnets','dst' ); # Mark LOCAL traffic outbound and which interface its leaving on runIPTablesNewChain('main','filter','pppgk-output-r'); runIPTablesInsertJump('main', 'filter','OUTPUT',1,'pppgk-output-r', '-m','mark','!','--mark',0, ); # CLAMP all forwarded traffic to max segment size runIPTablesAddToNew('main','mangle','pppgk-forward-clamp', '-p','tcp','--tcp-flags','SYN,RST','SYN', '-j','TCPMSS','--clamp-mss-to-pmtu' ); runIPTablesAddJump('main','mangle','FORWARD','pppgk-forward-clamp'); # Main rule for NEW forwarded traffic from our localnets outbound runIPTablesNewChain('main','mangle','pppgk-forward-int-n'); runIPTablesAddJump('main','mangle', 'FORWARD','pppgk-forward-int-n', '-m','state','--state','NEW', '-m','mark','--mark',0, '-m','set','--match-set','pppgk-localnets','src' ); # Main rule for NEW forwarded traffic from the ppp side inbound runIPTablesNewChain('main','mangle','pppgk-forward-ext-n'); runIPTablesAddJump('main','mangle', 'FORWARD','pppgk-forward-ext-n', '-m','state','--state','NEW', '-m','mark','--mark',0, '-m','set','--match-set','pppgk-localnets','dst' ); # This is the main rule for NEW traffic coming from EXTERNAL inbound runIPTablesNewChain('main','mangle','pppgk-input-ext-n'); runIPTablesAddJump('main', 'mangle','INPUT','pppgk-input-ext-n', '-m','state','--state','NEW', '-m','mark','--mark',0, '-m','set','!','--match-set','pppgk-localnets','src', ); # Save the MARK value to CONNMARK for inbound traffic runIPTablesAddToNew('main', 'mangle','pppgk-input', '-m','mark','!','--mark',0, '-j','CONNMARK','--save-mark' ); runIPTablesAddJump('main','mangle','INPUT','pppgk-input'); # Very last, CONNMARK all traffic with a MARK value runIPTablesAddToNew('main', 'nat','pppgk-postroute', '-m','mark','!','--mark',0, '-j','CONNMARK','--save-mark' ); runIPTablesInsertJump('main','nat','POSTROUTING',1,'pppgk-postroute'); # Watch when we can do something my $select = IO::Select->new(); logMsg('CONTROLLER',undef,"Running, startup may take up to 30s...\n"); # Main loop my $mainExit = 0; while ($mainExit < 5) { my $sleep = 1; # logMsg('CONTROLLER',undef,"About to run select()"); # Can we read data yet? if (my @readyFDs = $select->can_read(1)) { # logMsg('CONTROLLER',undef,"select() can read"); # Loop with ready fd's foreach my $fd (@readyFDs) { my $connName = $globals->{'fd_list'}->{$fd->fileno}; my $connConfig = $config{$connName}; my $connInternal = $globals->{'connections'}->{$connName}->{'_internal'}; # logMsg('MONITOR',$connName,"select() can read fd ".$fd->fileno); # Inititalize buffer $connInternal->{'fd_buffer'} = "" if (!defined($connInternal->{'fd_buffer'})); # Loop while there is data being read my $nread; while ($nread = sysread($fd,$connInternal->{'fd_buffer'},1024,length($connInternal->{'fd_buffer'}))) { last if ($nread < 1024); } # logMsg('CONTROLLER',undef,"sysread() done"); # pipe closed? last if (!defined($nread)); # logMsg('CONTROLLER',undef,"sysread() last done: nread = $nread"); # Split off lines my @lines = split(/\r?\n/,$connInternal->{'fd_buffer'}); # If last bytes are the end of the line, then we have a solid list of # lines, else just save that in buffe for next time if ($connInternal->{'fd_buffer'} =~ /\r?\n$/) { $connInternal->{'fd_buffer'} = ''; } else { $connInternal->{'fd_buffer'} = pop(@lines); } # Output logs if (defined($connConfig->{'logfile'})) { my ($sec,$min,$hour,$day,$mon,$year) = localtime; my $timestamp = sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year+1900, $mon+1, $day, $hour, $min, $sec); # Open logfile and loop with lines open(LOGFILE,'>>',$connConfig->{'logfile'}); foreach my $line (@lines) { print(LOGFILE "$timestamp: $line\n"); } close(LOGFILE); } # Loop through lines we got foreach my $line (@lines) { # logMsg('MONITOR',$connName,"LINE [$line]"); # Got interface name if ($line =~ /^Using interface (\S+)/) { my $iface = $1; # Setup local IP $connInternal->{'interface'} = $iface; logMsg('MONITOR',$connName,'Interface = %s',$iface); # Do we have PID yet? setPPPDPID($connName); # Got local IP } elsif ($line =~ /^local\s+IP\s+address\s+(\S+)/) { my $local_ip = $1; # Setup local IP $connInternal->{'local_ip'} = $local_ip; logMsg('MONITOR',$connName,'Local IP = %s',$local_ip); # Remote IP } elsif ($line =~ /^remote\s+IP\s+address\s+(\S+)/) { my $remote_ip = $1; # Setup remote IP $connInternal->{'remote_ip'} = $remote_ip; logMsg('MONITOR',$connName,'Remote IP = %s',$remote_ip); # Got DNS } elsif ($line =~ /^(\S+)\s+DNS\s+address\s+(\S+)/) { my ($which,$dns) = ($1,$2); # Setup local IP $connInternal->{"dns_$which"} = $dns; logMsg('MONITOR',$connName,'DNS/%s = %s',lc($which),$dns); # Connection is up } elsif ($line =~ /^Script \/etc\/ppp\/ip-up finished/) { connStatus($connName,'up'); # Master exit plan } elsif ($line eq '%%END%%') { logMsg('MONITOR',$connName,"!!!!MASTER EXIT!!!!"); connStatus($connName,'down'); } } } $sleep = 0; } # Sleep if something didn't happen sleep($sleep) if ($sleep); # Check if these processes are still alive? foreach my $pid (keys %{$globals->{'pid_list'}}) { # Clever, lets check if the pid dir exists if ( ! -d "/proc/$pid" ) { my $connName = $globals->{'pid_list'}->{$pid}; logMsg('MONITOR',$connName,'PID %s no longer exists, marking down',$pid); connStatus($connName,'down'); } } # Set now $now = time(); # Look for state changes my %stats; # Connection status stats my @connNames = sort keys %{$globals->{'connections'}}; # Lets loop with the links in alphabetical order foreach my $connName (@connNames) { # Setup some vars we like my $connConfig = $config{$connName}; # The connection my $thisConn = $globals->{'connections'}->{$connName}; my $connInternal = $thisConn->{'_internal'}; # Stats if (defined($stats{$thisConn->{'status'}})) { $stats{$thisConn->{'status'}}++; } else { $stats{$thisConn->{'status'}} = 1; } # We have something to do if (defined($thisConn->{'state_change'})) { # Check what state change it was if ($thisConn->{'state_change'} eq 'up') { logMsg('CONTROLLER',$connName,'Changed state to UP => %s[%s], %s => %s',$connConfig->{'interface'}, $thisConn->{'_internal'}->{'interface'},$thisConn->{'_internal'}->{'local_ip'}, $thisConn->{'_internal'}->{'remote_ip'}); linkUp($connName); } elsif ($thisConn->{'state_change'} eq 'down') { logMsg('CONTROLLER',$connName,'Changed state to DOWN => uptime %0.2fhr',($now - $thisConn->{'_internal'}->{'timestamp'}) / 3600); $select->remove($connInternal->{'fd'}); linkDown($connName); } elsif ($thisConn->{'state_change'} eq 'failed') { logMsg('CONTROLLER',$connName,'Changed state to FAILED'); $select->remove($connInternal->{'fd'}); linkFailed($connName); } # Lock & reset delete($thisConn->{'state_change'}); # If no status updates, print out current state } else { # if ($thisConn->{'status'} eq "up") { # logMsg('CONTROLLER',$connName,'State is %s (%s[%s], %s => %s, %0.2fhr)',uc($thisConn->{'status'}),$connConfig->{'interface'}, # $thisConn->{'_internal'}->{'interface'}, $thisConn->{'_internal'}->{'local_ip'}, $thisConn->{'_internal'}->{'remote_ip'}, # ($now - $thisConn->{'_internal'}->{'timestamp'}) / 3600); # } else { # logMsg('CONTROLLER',$connName,'State is %s',uc($thisConn->{'status'})); # } } # We should be connecting ... if ($mainExit == 0 && $thisConn->{'status'} eq 'down' && ($now - $thisConn->{'last_state_change'}) > 5) { my $pty = forkConnection($connName); $select->add($pty); } } # Update counters if (!$mainExit) { open(DEVSTATS,"< /proc/net/dev"); while (my $line = ) { # Split off counters my (undef,$dev,$bytesIn,$packetsIn,undef,undef,undef,undef,undef,undef,$bytesOut,$packetsOut) = split(/[ \t:]+/,$line); # Find the interface and update foreach my $connName (@connNames) { # Setup some vars we like my $connConfig = $config{$connName}; # The connection my $thisConn = $globals->{'connections'}->{$connName}; my $connInternal = $thisConn->{'_internal'}; # Setup counters if ($thisConn->{'status'} eq "up" && $connInternal->{'interface'} eq $dev) { # Setup counters unshift(@{$connInternal->{'counters'}->{'bytes_in'}},$bytesIn); pop(@{$connInternal->{'counters'}->{'bytes_in'}}) if (@{$connInternal->{'counters'}->{'bytes_in'}} > TRAFFIC_HISTORY_SIZE); unshift(@{$connInternal->{'counters'}->{'bytes_out'}},$bytesIn); pop(@{$connInternal->{'counters'}->{'bytes_out'}}) if (@{$connInternal->{'counters'}->{'bytes_out'}} > TRAFFIC_HISTORY_SIZE); unshift(@{$connInternal->{'counters'}->{'bytes_total'}},$bytesIn+$bytesOut); pop(@{$connInternal->{'counters'}->{'bytes_total'}}) if (@{$connInternal->{'counters'}->{'bytes_total'}} > TRAFFIC_HISTORY_SIZE); unshift(@{$connInternal->{'counters'}->{'packets_in'}},$packetsIn); pop(@{$connInternal->{'counters'}->{'packets_in'}}) if (@{$connInternal->{'counters'}->{'packets_in'}} > TRAFFIC_HISTORY_SIZE); unshift(@{$connInternal->{'counters'}->{'packets_out'}},$packetsIn); pop(@{$connInternal->{'counters'}->{'packets_out'}}) if (@{$connInternal->{'counters'}->{'packets_out'}} > TRAFFIC_HISTORY_SIZE); unshift(@{$connInternal->{'counters'}->{'packets_total'}},$packetsIn+$packetsOut); pop(@{$connInternal->{'counters'}->{'packets_total'}}) if (@{$connInternal->{'counters'}->{'packets_total'}} > TRAFFIC_HISTORY_SIZE); } } } close(DEVSTATS); } # Output some stats my $totalLinks = 0; my $linksNotDown = 0; my $statsLine = ""; foreach my $s (sort keys %stats) { $statsLine .= " $s = ".$stats{$s}; $totalLinks += $stats{$s}; $linksNotDown++ if ($s ne "down"); } $statsLine .= " total = $totalLinks"; # logMsg('CONTROLLER',undef,"STATUS => %s\n",$statsLine); # Exit if we set $mainExit and we have all links down $mainExit++ if ($linksNotDown == 0 && $mainExit); # print(STDERR Dumper($globals)); } logMsg('CONTROLLER',undef,'Waiting for children'); wait(); logMsg('CONTROLLER',undef,'Shutting down'); # Remove iptables rules clearInstanceIPTables('main'); # Remove our main process rules runIPRuleDel('lookup',ROUTING_TABLE,'prio',ROUTING_TABLE_RULE_PRIORITY); runIPRouteFlushTable(ROUTING_TABLE); # Remove ipsets runCommand('/usr/sbin/ipset','-X','pppgk-localnets'); runCommand('/usr/sbin/ipset','-X','pppgk-trackexcl'); # Remove state file unlink($fwStateFile); # Remove PID file unlink($pidFile); logMsg('CONTROLLER',undef,'Exiting'); # Fork connection off to multilink sub forkConnection { my $connName = shift; my $thisConn = $globals->{'connections'}->{$connName}; my $connConfig = $config{$connName}; connStatus($connName,'connecting'); # Grab PTY my $pty = new IO::Pty; # Make happy tty my $tty = $pty->ttyname(); # Fork my $pid = fork(); defined($pid) || die("CONTROLLER($$/$connName): Can't fork: $!"); # This is the parent if ($pid) { # Close slave $pty->close_slave(); $pty->set_raw(); setPID($connName,$pid); setFD($connName,$pty->fileno); return $pty; # This is the child } else { # Setup password pipe pipe(PSLAVE, PMASTER) or die("CHILD($$/$connName): $!"); PMASTER->autoflush(1); sleep(1); print("%%START%%\n"); my $ppid = fork(); defined($ppid) || die("CHILD($$/$connName): Can't fork PASSFD: $!"); # This is the parent if ($ppid) { close(PSLAVE); print(PMASTER $config{$connName}->{'password'}); # pppd wants the other side closed close(PMASTER); # Wait for child waitpid($ppid,0); exit 0; } else { $pty->make_slave_controlling_terminal() || die("PPPD($$/$connName): Failed to make slave controlling terminal: $!"); my $slave = $pty->slave(); close($pty); $slave->set_raw(); # Remap stdout & stdin my $ptyfd = $slave->fileno; close(STDIN); open(STDIN, "<&$ptyfd") || die("PPPD($$/$connName): Failed to remap STDIN on parent to PTY: $!"); close(STDOUT); open(STDOUT, ">&$ptyfd") || die("PPPD($$/$connName): Failed to remap STDOUT on parent to PTY: $!"); close(STDERR); open(STDERR, ">&$ptyfd") || die("PPPD($$/$connName): Failed to remap STDERR on parent to PTY: $!"); # Close slave close($slave); # Password fd pipe, close master close(PMASTER); # If we have a init= option in the config, execute it to bring up the interface before we run ppp if (defined($connConfig->{'init'})) { if (-x $connConfig->{'init'}) { system($connConfig->{'init'}); } else { die("PPPD($$/$connName): init= file is not executable '".$connConfig->{'init'}."'"); } } # Extra args to pass to pppd my @preExtraArgs = (); my @extraArgs = (); # Check the type, pppoe first if ($connConfig->{'type'} eq "pppoe") { push(@preExtraArgs,'local'); push(@preExtraArgs,'plugin','rp-pppoe.so'); # Modem next } elsif ($connConfig->{'type'} eq "modem") { push(@preExtraArgs,'modem'); } else { die("PPPD($$/$connName): Invalid connection type '".$connConfig->{'type'}."'"); } # Check for ppp unit number if (defined($connConfig->{'ppp_unit'})) { push(@extraArgs,'unit',$connConfig->{'ppp_unit'}); } # Check for ppp init script if (defined($connConfig->{'ppp_init'})) { push(@extraArgs,'init', $connConfig->{'ppp_init'}); } # Check for ppp connect script if (defined($connConfig->{'ppp_connect'})) { push(@extraArgs,'connect', $connConfig->{'ppp_connect'}); } # Check for ppp disconnect script if (defined($connConfig->{'ppp_disconnect'})) { push(@extraArgs,'disconnect', $connConfig->{'ppp_disconnect'}); } # Set process name $0 = "pppd - [".$connConfig->{'name'}."] via ".$connConfig->{'interface'}; # DO NOT close this FD on exec fcntl(PSLAVE,F_SETFD,0); system('/usr/sbin/pppd', @preExtraArgs, $connConfig->{'interface'}, 'plugin', 'passwordfd.so', 'passwordfd', PSLAVE->fileno, 'nodetach', 'lcp-echo-failure', 240, 'lcp-echo-interval', 1, 'noipdefault', 'usepeerdns', 'noauth', 'user', $connConfig->{'username'}, 'linkname', $connConfig->{'name'}, 'logfd', 2, @extraArgs, 'debug' ) || print("PPPD($$/$connName): Failed to start pppd: $!%%\n"); print("%%END%%\n"); exit 0; } } } # Debug info sub logMsg { my ($what,$connName,$message,@params) = @_; my ($sec,$min,$hour,$day,$mon,$year) = localtime; my $timestamp = sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year+1900, $mon+1, $day, $hour, $min, $sec); printf(STDERR "[$timestamp] $what($$".($connName ? "/$connName" : "")."): $message\n",@params); } # Change connection status sub connStatus { my ($connName,$status) = @_; # Initialize if not already done my $thisConn = $globals->{'connections'}->{$connName}; # Save previous status my $prevStatus = $thisConn->{'status'}; # Update status $thisConn->{'status'} = $status; # Blew up while connecting if ($prevStatus eq 'connecting' && $status eq 'down') { $thisConn->{'state_change'} = 'failed'; # If connection just came up, awesome } elsif ($prevStatus eq 'connecting' && $status eq 'up') { $thisConn->{'state_change'} = $status; # If connection was up and is now down, we need to down it } elsif ($prevStatus eq 'up' && $status eq 'down') { $thisConn->{'state_change'} = $status; } $thisConn->{'last_state_change'} = time(); } # Link UP function sub linkUp { my $connName = shift; # Internal data my $thisConn = $globals->{'connections'}->{$connName}; my $connInternal = $thisConn->{'_internal'}; my $connConfig = $config{$connName}; my $connConfigInternal = $connConfig->{'_internal'}; # Connection counters $connInternal->{'counters'}->{'bytes_in'} = [ 0 ]; $connInternal->{'counters'}->{'bytes_out'} = [ 0 ]; $connInternal->{'counters'}->{'bytes_total'} = [ 0 ]; $connInternal->{'counters'}->{'packets_in'} = [ 0 ]; $connInternal->{'counters'}->{'packets_out'} = [ 0 ]; $connInternal->{'counters'}->{'packets_total'} = [ 0 ]; # Set timestamp of connection $connInternal->{'timestamp'} = time(); # # BASIC ROUTING # # Setup default route in the table runIPRouteAdd('default','via',$connInternal->{'remote_ip'},'dev',$connInternal->{'interface'},'table', $connConfigInternal->{'table_id'}); # Link local nets to the default route runIPRuleAdd('fwmark',$connConfigInternal->{'fwmark_id'}."/".FWMARK_MASK_ALL,'lookup',$connConfigInternal->{'table_id'}, 'prio',$connConfigInternal->{'fwmark_id'}); # Mark inbound traffic on local interface so we can re-route over it later runIPTablesAddToNew($connName,'mangle','pppgk-input-ext-n-'.$connInternal->{'interface'}, '-j','MARK','--set-mark',$connConfigInternal->{'fwmark_id'} | FWMARK_MASK_EXT ); runIPTablesAddJump($connName,'mangle','pppgk-input-ext-n','pppgk-input-ext-n-'.$connInternal->{'interface'}, '--in-interface',$connInternal->{'interface'} ); # Internal traffic outbound, check recent routing table runIPTablesAddToNew($connName,'mangle','pppgk-preroute-int-r-'.$connInternal->{'interface'}, '-j','MARK','--set-mark',$connConfigInternal->{'fwmark_id'} | FWMARK_MASK_INT ); runIPTablesAddJump($connName,'mangle','pppgk-preroute-int-r','pppgk-preroute-int-r-'.$connInternal->{'interface'}, '-m','recent','--name','pppgk-'.$connInternal->{'interface'},'--rcheck','--rdest','--seconds',ROUTE_CACHE_PERIOD, ); # Internal traffic outbound, set the MARK value we going out on runIPTablesAddToNew($connName,'mangle','pppgk-forward-int-n-'.$connInternal->{'interface'}, '-j','MARK','--set-mark',$connConfigInternal->{'fwmark_id'} | FWMARK_MASK_INT ); runIPTablesAddJump($connName,'mangle','pppgk-forward-int-n','pppgk-forward-int-n-'.$connInternal->{'interface'},,'--out-interface',$connInternal->{'interface'}); # External traffic inbound, mark so we know what interface we came in on runIPTablesAddToNew($connName,'mangle','pppgk-forward-ext-n-'.$connInternal->{'interface'}, '-j','MARK','--set-mark',$connConfigInternal->{'fwmark_id'} | FWMARK_MASK_EXT ); runIPTablesAddJump($connName,'mangle','pppgk-forward-ext-n','pppgk-forward-ext-n-'.$connInternal->{'interface'},'--in-interface',$connInternal->{'interface'}); # New traffic outbound, check and MARK value based on recent route list runIPTablesAddToNew($connName,'mangle','pppgk-output-nr-'.$connInternal->{'interface'}, '-j','MARK','--set-mark',$connConfigInternal->{'fwmark_id'} | FWMARK_MASK_INT ); runIPTablesInsertJump($connName,'mangle','pppgk-output-int-nr',1,'pppgk-output-nr-'.$connInternal->{'interface'}, '-m','recent','--name','pppgk-'.$connInternal->{'interface'},'--rcheck','--rdest','--seconds',ROUTE_CACHE_PERIOD); runIPTablesAddJump($connName,'mangle','pppgk-output-int-nr','pppgk-output-nr-'.$connInternal->{'interface'}, '--out-interface',$connInternal->{'interface'}, '-m','mark','--mark',0 ); # Source NAT based on MARK value runIPTablesAddToNew($connName,'nat','pppgk-postroute-'.$connInternal->{'interface'}, '-j','SNAT','--to',$connInternal->{'local_ip'} ); runIPTablesAddJump($connName,'nat','POSTROUTING','pppgk-postroute-'.$connInternal->{'interface'}, '-m','mark','--mark',$connConfigInternal->{'fwmark_id'}."/".FWMARK_MASK_ALL ); # Update recent route table based on recently seen forwarded traffic runIPTablesAddToNew($connName,'filter','pppgk-forward-'.$connInternal->{'interface'}, '-m','recent','--name','pppgk-'.$connInternal->{'interface'},'--set','--rdest', # Last packet ); runIPTablesInsertJump($connName,'filter','FORWARD',1,'pppgk-forward-'.$connInternal->{'interface'}, '-m','mark','--mark',$connConfigInternal->{'fwmark_id'}."/".FWMARK_MASK_ALL, '-m','mark','--mark',FWMARK_MASK_INT."/".FWMARK_MASK_INT, '-m','set','!','--match-set','pppgk-trackexcl','dst' ); # Update recent route table based on recently seen LOCAL traffic outbound runIPTablesAddToNew($connName,'filter','pppgk-output-r-'.$connInternal->{'interface'}, '-m','recent','--name','pppgk-'.$connInternal->{'interface'},'--set','--rdest', # Last packet seent ); runIPTablesAddJump($connName,'filter','pppgk-output-r','pppgk-output-r-'.$connInternal->{'interface'}, '-m','mark','--mark',$connConfigInternal->{'fwmark_id'}."/".FWMARK_MASK_ALL, '-m','mark','--mark',FWMARK_MASK_INT."/".FWMARK_MASK_INT, '-m','set','!','--match-set','pppgk-trackexcl','dst' ); # # TC # if (defined($connConfig->{'use_shaping'}) && !$mainExit) { # If we have a link speed, use it below my $rateICMP = 64; my $rateDNS = 64; if ($connConfig->{'use_shaping'} =~ /^[0-9]+$/ && (my $linkSpeed = int($connConfig->{'use_shaping'})) > 0) { $rateICMP = $linkSpeed * 0.05; # 5% $rateDNS = $linkSpeed * 0.05; # 5% } # Setup prio with 3 bands of fair queuing runCommand('/sbin/tc','qdisc','add','dev',$connInternal->{'interface'},'root','handle','1:','prio'); runCommand('/sbin/tc','qdisc','add','dev',$connInternal->{'interface'},'parent','1:1','handle','10:','sfq'); runCommand('/sbin/tc','qdisc','add','dev',$connInternal->{'interface'},'parent','1:2','handle','20:','sfq'); runCommand('/sbin/tc','qdisc','add','dev',$connInternal->{'interface'},'parent','1:3','handle','30:','sfq'); # Prioritize ICMP runCommand('/sbin/tc','filter','add','dev',$connInternal->{'interface'},'parent','1:','protocol','ip','prio',1,'u32', 'match','ip','protocol',1,'0xff', 'police','rate',$rateICMP.'kbit','buffer',($rateICMP * 5).'k','continue', 'flowid','1:1' ); # Prioritize ACK runCommand('/sbin/tc','filter','add','dev',$connInternal->{'interface'},'parent','1:','protocol','ip','prio',1,'u32', 'match','ip','protocol','0x6','0xff', 'match','u8','0x05','0x0f','at',0, 'match','u8','0x10','0x0f','at',33, 'match','u16','0x0000','0xffc0','at',2, 'flowid','1:1' ); # Prioritize SYN-ACK runCommand('/sbin/tc','filter','add','dev',$connInternal->{'interface'},'parent','1:','protocol','ip','prio',1,'u32', 'match','ip','protocol','0x6','0xff', 'match','u8','0x05','0x0f','at',0, 'match','u8','0x12','0x0f','at',33, 'match','u16','0x0000','0xffc0','at',2, 'flowid','1:1' ); # Prioritize DNS runCommand('/sbin/tc','filter','add','dev',$connInternal->{'interface'},'parent','1:','protocol','ip','prio',1,'u32', 'match','ip','protocol','0x11','0xff', 'match','ip','dport','53','0xffff', 'police','rate',$rateICMP.'kbit','buffer',($rateICMP * 5).'k','continue', 'flowid','1:1' ); } # # DNS # # If we using this dns, set it up if ($connConfig->{'use_dns'} && !$mainExit) { # Check if we have a primary and secondary if (defined($connInternal->{'dns_primary'}) && defined($connInternal->{'dns_secondary'})) { my $dnsName = sprintf('%02u-%s',$connConfig->{'use_dns'},$connName); my $dns = $globals->{'dns'}; my $previousDNS = $dns->{'current'}; # Setup list $dns->{'list'}->{$dnsName}->{'dns_primary'} = $connInternal->{'dns_primary'}; $dns->{'list'}->{$dnsName}->{'dns_secondary'} = $connInternal->{'dns_secondary'}; # Get highest priority my $highestPrio = (sort keys %{$dns->{'list'}})[-1]; # Are we the highest priority? if ($highestPrio eq $dnsName) { # Do we have a current DNS if (defined($previousDNS)) { # Pull in the current DNS connection info my $dconni = $dns->{'conni_map'}->{$previousDNS}; logMsg('CONTROLLER',$connName,"Activating DNS (previous '%s')",$previousDNS); # If there is already a DNS server, remove its routes runCommand('/sbin/ip','route','del',$dconni->{'dns_primary'},'via',$dconni->{'remote_ip'},'dev', $dconni->{'interface'},'table',ROUTING_TABLE); runCommand('/sbin/ip','route','del',$dconni->{'dns_secondary'},'via',$dconni->{'remote_ip'},'dev', $dconni->{'interface'},'table',ROUTING_TABLE); # Just output some text, we don't need to remove anything if we are the highest priority } else { logMsg('CONTROLLER',$connName,"Activating DNS"); } # Add to exclusion list runCommand('/usr/sbin/ipset','-A','pppgk-trackexcl',$connInternal->{'dns_primary'}."/31"); runCommand('/usr/sbin/ipset','-A','pppgk-trackexcl',$connInternal->{'dns_secondary'}."/31"); # Add DNS routes runIPRouteAdd($connInternal->{'dns_primary'},'via',$connInternal->{'remote_ip'},'dev', $connInternal->{'interface'},'table',ROUTING_TABLE); runIPRouteAdd($connInternal->{'dns_secondary'},'via',$connInternal->{'remote_ip'},'dev', $connInternal->{'interface'},'table',ROUTING_TABLE); # Set ourselves up as the current DNS $dns->{'current'} = $dnsName; # Write out DNS's open(RESOLV,'> /etc/ppp/resolv-pppgk.conf'); printf(RESOLV "nameserver %s\n",$connInternal->{'dns_primary'}); printf(RESOLV "nameserver %s\n",$connInternal->{'dns_secondary'}); close(RESOLV); # If we have resolvconf use it if ( -x "/sbin/resolvconf" ) { logMsg('CONTROLLER',$connName,"Adding DNS to resolvconf"); runCommandForked("/bin/sh","-c","'/sbin/resolvconf -a ".$connInternal->{'interface'}." < /etc/ppp/resolv-pppgk.conf'"); } # If we had a previous DNS, we must blow some stuff away if (defined($previousDNS)) { # Pull in the previous DNS connection info my $dconni = $dns->{'conni_map'}->{$previousDNS}; # Blow the DNS IP's out of the tracking tables & remove DNS cache for them open(XTR,"> /proc/net/xt_recent/pppgk-".$dconni->{'interface'}); runCommand('/sbin/ip','route','flush','cache',$dconni->{'dns_primary'}); printf(XTR "-".$dconni->{'dns_primary'}); runCommand('/sbin/ip','route','flush','cache',$dconni->{'dns_secondary'}); printf(XTR "-".$dconni->{'dns_secondary'}); close(XTR); } } # Add us to the map $dns->{'conni_map'}->{$dnsName} = $connInternal; # Do not have primary AND secondary } else { logMsg('CONTROLLER',$connName,"Cannot use for DNS - MISSING EITHER PRIMARY OR SECONDARY NAMESERVER"); } } # # DEFAULT ROUTE # # If we using this as a default route, set it up if ($connConfig->{'use_default_route'} && !$mainExit) { my ($thisDefaultTPrio,$thisDefaultWeight) = split(':',$connConfig->{'use_default_route'}); my $thisDefaultPrio = sprintf('%02u',$thisDefaultTPrio); my $defaultRoute = $globals->{'default_route'}; # If we don't have a default route weight, just assign it 10 if (!defined($thisDefaultWeight)) { $thisDefaultWeight = DEFAULT_ROUTE_DEFAULT_WEIGHT; } # Setup list $defaultRoute->{'list'}->{$thisDefaultPrio}->{$connName}->{'interface'} = $connInternal->{'interface'}; $defaultRoute->{'list'}->{$thisDefaultPrio}->{$connName}->{'remote_ip'} = $connInternal->{'remote_ip'}; # Get highest priority my $highestPrio = (sort keys %{$defaultRoute->{'list'}})[-1]; # Are we the highest priority? if ($highestPrio eq $thisDefaultPrio) { my $metric = 100 - int($highestPrio); my $defaultRouteStr = join(',',keys %{$defaultRoute->{'list'}->{$thisDefaultPrio}}); # Do we have a current default route if (defined($defaultRoute->{'current'})) { # Is this infact our current route if ($defaultRoute->{'current'} == $thisDefaultPrio) { logMsg('CONTROLLER',$connName,"Activating additional routes for default route priority '%s' => %s", $thisDefaultPrio,$defaultRouteStr); } else { # Work out previous metric my $prevMetric = 100 - int($defaultRoute->{'current'}); logMsg('CONTROLLER',$connName,"Activating default route priority '%s' (previous priority '%s') => %s", $thisDefaultPrio,$defaultRoute->{'current'},$defaultRouteStr); # Remove previous default route runCommand('/sbin/ip','route','del','default','metric',$prevMetric); } # Just output some text, we don't need to remove anything if we are the highest priority } else { logMsg('CONTROLLER',$connName,"Activating new default route priority '%s' => %s",$thisDefaultPrio,$defaultRouteStr); } # Build route list my @rList; # If we have a policy use it if (defined($defaultRoute->{'policies'}) && defined(my $policy = $defaultRoute->{'policies'}->{$thisDefaultPrio})) { push(@rList,'mpath',$policy); } foreach my $routeConnName (keys %{$defaultRoute->{'list'}->{$thisDefaultPrio}}) { my $dconni = $defaultRoute->{'list'}->{$thisDefaultPrio}->{$routeConnName}; push(@rList,'nexthop','via',$dconni->{'remote_ip'},'dev',$dconni->{'interface'},'weight',$thisDefaultWeight); } runCommand('/sbin/ip','route','replace','default','metric',$metric,@rList); # Set ourselves up as the current default route $defaultRoute->{'current'} = $thisDefaultPrio; } } # # ADDITIONAL ROUTES # # If we using this as a default route, set it up if ($connConfig->{'routing_table'} && !$mainExit) { # Global routing table my $routes = $globals->{'routes'}; # List of routing table changes my $routesChanged; if (open(RTABLE,"< ".$connConfig->{'routing_table'})) { # Loop with routes while (my $line = ) { chomp($line); next if ($line =~ /^\s*$/); next if ($line =~ /^\s*#/); my ($route,$prio,$weight) = split(/\s+/,$line); # Default prio to 0 if its not specified if (!defined($prio) || $prio eq "") { $prio = ROUTING_TABLE_DEFAULT_PRIORITY; } if (!defined($weight) || $weight eq "") { $weight = ROUTING_TABLE_DEFAULT_WEIGHT; } my $thisRoutePrio = sprintf('%02u',$prio); $routes->{'list'}->{$route}->{$thisRoutePrio}->{$connName}->{'interface'} = $connInternal->{'interface'}; $routes->{'list'}->{$route}->{$thisRoutePrio}->{$connName}->{'remote_ip'} = $connInternal->{'remote_ip'}; $routes->{'list'}->{$route}->{$thisRoutePrio}->{$connName}->{'weight'} = $weight; $routesChanged->{$route} = $thisRoutePrio; } close(RTABLE); } else { logMsg('CONTROLLER',$connName,"Failed to open routing table '%s': %s",$connConfig->{'routing_table'},$!); } # Loop with route changes foreach my $route (keys %{$routesChanged}) { # Grab prio my $prio = $routesChanged->{$route}; # Create our metric my $metric = 100 - int($prio); # Get highest priority in routing table my $highestPrio = (sort keys %{$routes->{'list'}->{$route}})[-1]; # Does this link change/override the current route? if (!defined($routes->{'current'}->{$route}) || $highestPrio <= $prio) { my @rList; # Process routes foreach my $rConnName (keys %{$routes->{'list'}->{$route}->{$prio}}) { my $rConni = $routes->{'list'}->{$route}->{$prio}->{$rConnName}; push(@rList,'nexthop','via',$rConni->{'remote_ip'},'dev',$rConni->{'interface'},'weight',$rConni->{'weight'}); } # Set current route $routes->{'current'}->{$route} = $prio; # Add route runCommand('/sbin/ip','route','replace','table',ROUTING_TABLE,$route,'metric',$metric,@rList); } } } # Exclusions # nk: should these be above in the if () ? - maybe not, we want to exclude no matter what if ($connConfig->{'routing_table_exclusions'} && !$mainExit) { if (open(RTABLE,"< ".$connConfig->{'routing_table_exclusions'})) { # Loop with routes while (my ($route,$prio) = split(/\s+/,)) { chomp($route); # Skip blanks and comments next if ($route =~ /^\s*$/); next if ($route =~ /^\s*#/); # Set default if not set $prio = (defined($prio) && $prio ne "") ? ( 100 - int($prio) ) : ROUTING_TABLE_EXCL_DEFAULT_PRIORITY; # Add default route runIPRouteAdd('throw',$route,'metric',$prio,'table',ROUTING_TABLE); } close(RTABLE); } else { logMsg('CONTROLLER',$connName,"Failed to open routing table exclusions '%s': %s",$connConfig->{'routing_table'},$!); } } # If we firing up an external command, do it now if ($connConfig->{'ifup'} && !$mainExit) { logMsg('CONTROLLER',$connName,"Running ifup script '".$connConfig->{'ifup'}."'"); runCommandForked($connConfig->{'ifup'},$connName,$connInternal->{'interface'},$connInternal->{'remote_ip'},$connInternal->{'local_ip'}, defined($connInternal->{'primary_dns'}) ? $connInternal->{'primary_dns'} : "", defined($connInternal->{'secondary_dns'}) ? $connInternal->{'primary_dns'} : "" ); } } # Link DOWN function sub linkDown { my $connName = shift; # Internal data my $thisConn = $globals->{'connections'}->{$connName}; my $connInternal = $thisConn->{'_internal'}; my $connConfig = $config{$connName}; my $connConfigInternal = $connConfig->{'_internal'}; logMsg('CONTROLLER',$connName,"Link DOWN"); # # BASIC ROUTING # # Remove routes from table runCommand('/sbin/ip','route','flush','table',$connConfigInternal->{'table_id'}); # Remove routes for local nets runCommand('/sbin/ip','rule','del', 'fwmark',$connConfigInternal->{'fwmark_id'}."/".FWMARK_MASK_ALL, 'lookup',$connConfigInternal->{'table_id'}, 'prio',$connConfigInternal->{'fwmark_id'}); # Remove iptables jumps to us clearInstanceIPTables($connName); # # CONNECTION TRACKING # # Flush everything if (-x '/usr/sbin/conntrack') { runCommandSilent('/usr/sbin/conntrack','-D','--reply-dst',$connInternal->{'local_ip'}); } # # DNS # # Time to process DNS... if ($connConfig->{'use_dns'} && !$mainExit) { my $dnsName = sprintf('%02u-%s',$connConfig->{'use_dns'},$connName); my $dns = $globals->{'dns'}; # Nuke ourselves from the DNS list delete($dns->{'list'}->{$dnsName}); # Check if current DNS is provided by us if (defined($dns->{'current'}) && $dns->{'current'} eq $dnsName) { my $pconni = $dns->{'conni_map'}->{$dnsName}; # Remove old DNS entries from excludes table runCommand('/usr/sbin/ipset','-D','pppgk-trackexcl',$pconni->{'dns_primary'}); runCommand('/usr/sbin/ipset','-D','pppgk-trackexcl',$pconni->{'dns_secondary'}); # Get next highest priority my $highestPrio = (sort keys %{$dns->{'list'}})[-1]; # Is there a next highest priority? if (defined($highestPrio)) { # Pull in highest DNS priorities connection info my $dconni = $dns->{'conni_map'}->{$highestPrio}; logMsg("CONTROLLER",$connName,"De-activating DNS (falling back to '%s')",$highestPrio); # Add new entries to exclusions table runCommand('/usr/sbin/ipset','-A','pppgk-trackexcl',$dconni->{'dns_primary'}."/32"); runCommand('/usr/sbin/ipset','-A','pppgk-trackexcl',$dconni->{'dns_secondary'}."/32"); # Add DNS routes to new DNS runIPRouteAdd($dconni->{'dns_primary'},'via',$dconni->{'remote_ip'},'dev', $dconni->{'interface'},'table',ROUTING_TABLE); runIPRouteAdd($dconni->{'dns_secondary'},'via',$dconni->{'remote_ip'},'dev', $dconni->{'interface'},'table',ROUTING_TABLE); # Set current DNS $dns->{'current'} = $highestPrio; # Write out DNS's open(RESOLV,'> /etc/ppp/resolv-pppgk.conf'); printf(RESOLV "nameserver %s\n",$dconni->{'dns_primary'}); printf(RESOLV "nameserver %s\n",$dconni->{'dns_secondary'}); close(RESOLV); # If we have resolvconf use it if ( -x "/sbin/resolvconf" ) { logMsg('CONTROLLER',$connName,"Updating DNS with resolvconf"); runCommandForked("/bin/sh","-c","'/sbin/resolvconf -d ".$connInternal->{'interface'}."'"); runCommandForked("/bin/sh","-c","'/sbin/resolvconf -a ".$dconni->{'interface'}." < /etc/ppp/resolv-pppgk.conf'"); } # If not OH NOES! } else { logMsg("CONTROLLER",$connName,"De-activating DNS (NO FALLBACK DNS AVAILABLE)"); delete($dns->{'current'}); # Nuke DNS's ? open(RESOLV,'> /etc/ppp/resolv-pppgk.conf'); close(RESOLV); } } # Nuke us from the conni map delete($dns->{'conni_map'}->{$dnsName}); } # # DEFAULT ROUTE # # If we using this as a default route, set it up if ($connConfig->{'use_default_route'} && !$mainExit) { my ($thisDefaultTPrio,$thisDefaultWeight) = split(':',$connConfig->{'use_default_route'}); my $thisDefaultPrio = sprintf('%02u',$thisDefaultTPrio); my $defaultRoute = $globals->{'default_route'}; # If we don't have a default route weight, just assign it 10 if (!defined($thisDefaultWeight)) { $thisDefaultWeight = ROUTING_TABLE_DEFAULT_PRIORITY; } # Nuke ourselves from the default route list delete($defaultRoute->{'list'}->{$thisDefaultPrio}->{$connName}); if ((scalar keys %{$defaultRoute->{'list'}->{$thisDefaultPrio}}) == 0) { delete($defaultRoute->{'list'}->{$thisDefaultPrio}); } # Get highest priority my $highestPrio = (sort keys %{$defaultRoute->{'list'}})[-1]; if (defined($highestPrio)) { my $metric = 100 - int($highestPrio); my $defaultRouteStr = join(',',keys %{$defaultRoute->{'list'}->{$thisDefaultPrio}}); # Is this infact our current route if ($defaultRoute->{'current'} eq $highestPrio) { logMsg('CONTROLLER',$connName,"Deactivating failed routes for default route priority '%s' => %s", $highestPrio,$defaultRouteStr); } else { logMsg('CONTROLLER',$connName,"Activating next default route priority '%s' (previous priority '%s') => %s", $highestPrio,$defaultRoute->{'current'},$defaultRouteStr); } # Build route list my @routes; # If we have a policy use it if (defined($defaultRoute->{'policies'}) && defined(my $policy = $defaultRoute->{'policies'}->{$thisDefaultPrio})) { push(@routes,'mpath',$policy); } foreach my $routeConnName (keys %{$defaultRoute->{'list'}->{$highestPrio}}) { my $dconni = $defaultRoute->{'list'}->{$highestPrio}->{$routeConnName}; push(@routes,'nexthop','via',$dconni->{'remote_ip'},'dev',$dconni->{'interface'},'weight',$thisDefaultWeight); } # Old route should still be here, so remove it runCommand('/sbin/ip','route','replace','default','metric',$metric,@routes); # Set ourselves up as the current default route $defaultRoute->{'current'} = $highestPrio; # If not OH NOES!, if we had a current route, report we don't anymore } elsif (defined($defaultRoute->{'current'})) { my $metric = 100 - int($defaultRoute->{'current'}); logMsg("CONTROLLER",$connName,"De-activating default route '%s' (NO FALLBACK DEFAULT ROUTE AVAILABLE)",$metric); delete($defaultRoute->{'current'}); } } # # ADDITIONAL ROUTES # # If we using this as a default route, set it up if ($connConfig->{'routing_table'} && !$mainExit) { # Global routing table my $routes = $globals->{'routes'}; # List of routing table changes my $routesChanged; # Loop with routes to see if we were in the routing table foreach my $route (keys %{$routes->{'list'}}) { # Loop with priorities foreach my $prio (keys %{$routes->{'list'}->{$route}}) { # Check if this connection is linked to route/prio we're looping with if (defined($routes->{'list'}->{$route}->{$prio}->{$connName})) { # If we're in the routing table... if ($routes->{'current'}->{$route} == $prio) { $routesChanged->{$route} = $prio; delete($routes->{'current'}->{$route}); } # Remove us from the routing table delete($routes->{'list'}->{$route}->{$prio}->{$connName}); if ((keys %{$routes->{'list'}->{$route}->{$prio}}) == 0) { delete($routes->{'list'}->{$route}->{$prio}); } } } } # Loop with route changes foreach my $route (keys %{$routesChanged}) { # Grab prio my $prio = $routesChanged->{$route}; # Create our metric my $metric = 100 - int($prio); # Get highest priority in routing table if ((my $highestPrio = (sort keys %{$routes->{'list'}->{$route}})[-1])) { my @rList; # Process routes foreach my $rConnName (keys %{$routes->{'list'}->{$route}->{$highestPrio}}) { my $rConni = $routes->{'list'}->{$route}->{$highestPrio}->{$rConnName}; push(@rList,'nexthop','via',$rConni->{'remote_ip'},'dev',$rConni->{'interface'},'weight',$rConni->{'weight'}); } # Set current route $routes->{'current'}->{$route} = $prio; # Add route runCommand('/sbin/ip','route','replace','table',ROUTING_TABLE,$route,'metric',$metric,@rList); } } } # If we firing up an external command, do it now if ($connConfig->{'ifdown'}) { runCommand($connConfig->{'ifdown'},$connName,$connInternal->{'interface'},$connInternal->{'remote_ip'},$connInternal->{'local_ip'}, defined($connInternal->{'primary_dns'}) ? $connInternal->{'primary_dns'} : "", defined($connInternal->{'secondary_dns'}) ? $connInternal->{'primary_dns'} : "" ); } # Clear intername info clearPIDFD($connName); } # Link FAILED function sub linkFailed { my $connName = shift; logMsg('CONTROLLER',$connName,"Link FAILED"); clearPIDFD($connName); } # Clear PID and FD info sub clearPIDFD { my $connName = shift; # Internal data my $thisConn = $globals->{'connections'}->{$connName}; my $pidList = $globals->{'pid_list'}; my $fdList = $globals->{'fd_list'}; my $connInternal = $thisConn->{'_internal'}; # Not in use now delete($pidList->{$connInternal->{'pid'}}) if ($connInternal->{'pid'}); delete($fdList->{$connInternal->{'fd'}}) if ($connInternal->{'fd'}); delete($thisConn->{'_internal'}); } # Set pppd pid sub setPPPDPID { my $connName = shift; # Open PIDFILE if (!open(PIDFILE,"< /var/run/ppp-".$connName.".pid")) { logMsg('CONTROLLER',$connName,"Failed to open PIDFILE: $!"); return; } # Pull in PID my $pppdPID = ; close(PIDFILE); # Chomp off anything on the end chomp($pppdPID); # And set the PID for this connection setPID($connName,$pppdPID); logMsg('CONTROLLER',$connName,"Setting pppd pid to $pppdPID"); } # Set PID sub setPID { my ($connName,$pid) = @_; my $thisConn = $globals->{'connections'}->{$connName}; # Remove old pid & fd if (defined($thisConn->{'_internal'}->{'pid'})) { delete($globals->{'pid_list'}->{$thisConn->{'_internal'}->{'pid'}}); } # Setup new values $thisConn->{'_internal'}->{'pid'} = $pid; $globals->{'pid_list'}->{$pid} = $connName; } # Set FD sub setFD { my ($connName,$fd) = @_; my $thisConn = $globals->{'connections'}->{$connName}; # Remove old fd & fd if (defined($thisConn->{'_internal'}->{'fd'})) { delete($globals->{'fd_list'}->{$thisConn->{'_internal'}->{'fd'}}); } # Setup new values $thisConn->{'_internal'}->{'fd'} = $fd; $globals->{'fd_list'}->{$fd} = $connName; } # Child reaper sub REAPER { my $child; # If a second child dies while in the signal handler caused by the # first death, we won't get another signal. So must loop here else # we will leave the unreaped child as a zombie. And the next time # two children die we get another zombie. And so on. while (($child = waitpid(-1,&WNOHANG)) > 0) { # If we are a known child, set status to down if (defined($globals->{'pid_list'}->{$child})) { my $connName = $globals->{'pid_list'}->{$child}; logMsg('CONTROLLER',$connName,'Child %s, exiting with status %s',$child,$?); connStatus($connName,'down'); } } $SIG{CHLD} = \&REAPER; # still loathe sysV } # Child reaper sub INTERRUPT { logMsg('CONTROLLER','INTERRUPT','Preparing for shutdown'); # Set main exit point $mainExit = 1 if (!$mainExit); foreach my $connName (keys %{$globals->{'connections'}}) { my $pid = $globals->{'connections'}->{$connName}->{'_internal'}->{'pid'}; if ($globals->{'connections'}->{$connName}->{'status'} ne 'down' && defined($pid)) { logMsg('CONTROLLER','INTERRUPT',"Signalling '%s' with PID %s to terminate",$connName,$pid); kill(15,$pid); } } logMsg('CONTROLLER','INTERRUPT','Shutdown in progress'); } # Reload config sub RELOAD { logMsg('CONTROLLER','RELOAD','Got reload request!!!'); } # Print out config sub SIGUSR1 { # Look for state changes my %stats; # Connection status stats my @connNames = sort keys %{$globals->{'connections'}}; # Lets loop with the links in alphabetical order foreach my $connName (@connNames) { # Setup some vars we like my $connConfig = $config{$connName}; # The connection my $thisConn = $globals->{'connections'}->{$connName}; my $connInternal = $thisConn->{'_internal'}; # Stats if (defined($stats{$thisConn->{'status'}})) { $stats{$thisConn->{'status'}}++; } else { $stats{$thisConn->{'status'}} = 1; } if ($thisConn->{'status'} eq "up") { logMsg('CONTROLLER','SIGUSR1','%s is %s (pid: %s, %s[%s], %s => %s, uptime %0.2fhr)',$connName,uc($thisConn->{'status'}), $connInternal->{'pid'}, $connConfig->{'interface'}, $thisConn->{'_internal'}->{'interface'}, $thisConn->{'_internal'}->{'local_ip'}, $thisConn->{'_internal'}->{'remote_ip'}, ($now - $thisConn->{'_internal'}->{'timestamp'}) / 3600); } else { logMsg('CONTROLLER','SIGUSR1','%s is %s',$connName,uc($thisConn->{'status'})); } } # Output some stats my $totalLinks = 0; my $linksNotDown = 0; my $statsLine = ""; foreach my $s (sort keys %stats) { $statsLine .= " $s = ".$stats{$s}; $totalLinks += $stats{$s}; $linksNotDown++ if ($s ne "down"); } $statsLine .= " total = $totalLinks"; logMsg('CONTROLLER','SIGUSR1',"STATUS => %s\n",$statsLine); # Output the dns list my @conns = reverse sort keys %{$globals->{'dns'}->{'list'}}; logMsg('CONTROLLER','SIGUSR1',"DNS priority => %s",join(' -> ',@conns)); # Output the default route list @conns = reverse sort keys %{$globals->{'default_route'}->{'list'}}; logMsg('CONTROLLER','SIGUSR1',"Default route priority => %s",join(' -> ',@conns)); } sub SIGUSR2 { # logMsg('CONTROLLER','SIGUSR2',"Current state: ".Dumper($globals)); dumpIPTablesRules(); } # Run a command fork()'d sub runCommandForked { my @args = @_; # Fork of parent to return and child to run command my $pid = fork(); if (!$pid) { runCommand(@args); exit; } } # Run a command silently sub runCommandSilent { return _runCommand({ 'silent' => 1 },@_); } # Run a command with default options sub runCommand { return _runCommand({ 'silent' => 0 },@_); } # Run a command sub _runCommand { my ($options,@args) = @_; my $silent = (defined($options) && defined($options->{'silent'})) ? $options->{'silent'} : 0; # Make pretty string my @cmdString; foreach my $arg (@args) { if ($arg =~ /\s/) { $arg = "'$arg'"; } push(@cmdString,$arg); } my $cmdString = join(' ',@cmdString); # Grab PTY my $pty = new IO::Pty; # Make happy tty my $tty = $pty->ttyname(); # Fork of parent reader, and slave writer my $pid = fork(); if ($pid) { # Close slave $pty->close_slave(); $pty->set_raw(); my $ptyfd = $pty->fileno; # Remap stdout & stdin close(STDIN); open(STDIN, "<&$ptyfd") || die("CMD($$): Failed to remap STDIN on parent to PTY: $!"); close(STDOUT); open(STDOUT, ">&$ptyfd") || die("CMD($$): Failed to remap STDOUT on parent to PTY: $!"); # We're done with pty, close it close($pty); # fire up select my $select = IO::Select->new(); $select->add(\*STDIN); my $buffer = ""; # Loop while we not exiting my $exit; while (!$exit) { sleep(0.5); if ($select->can_read(10)) { # Loop while there is data being read my $nread; while ($nread = sysread(\*STDIN,$buffer,1024,length($buffer))) { last if ($nread < 1024); } # pipe closed? last if (!defined($nread)); } } # Wait for child to exit waitpid($pid,0); # Check buffer length if (length($buffer) > 0 && !$silent) { # If we have something, then output it chomp($buffer); print(STDERR "CMD($$): Output from [$cmdString] was [$buffer]\n"); } } else { $pty->make_slave_controlling_terminal() || die("CMD($$)/CHILD: Failed to make slave controlling terminal: $!"); my $slave = $pty->slave(); close($pty); $slave->set_raw(); # Remap stdout & stdin my $ptyfd = $slave->fileno; close(STDIN); open(STDIN, "<&$ptyfd") || die("CMD($$)/CHILD: Failed to remap STDIN on parent to PTY: $!"); close(STDOUT); open(STDOUT, ">&$ptyfd") || die("CMD($$)/CHILD: Failed to remap STDOUT on parent to PTY: $!"); close(STDERR); open(STDERR, ">&$ptyfd") || die("CMD($$)/CHILD: Failed to remap STDERR on parent to PTY: $!"); # Close slave close($slave); # Execute # print(STDERR "RUNCOMMAND: ",join(' ',@args)); exec(@args); exit; # This is hit if there is errors with exec() } } # # IP Stuff # sub runIPRouteAdd { my (@params) = @_; runCommand('/sbin/ip','route','add',@params); } sub runIPRouteFlushTable { my (@params) = @_; runCommand('/sbin/ip','route','flush','table',@params); } sub runIPRuleAdd { my (@params) = @_; runCommand('/sbin/ip','rule','add',@params); } sub runIPRuleDel { my (@params) = @_; runCommand('/sbin/ip','rule','del',@params); } # # Netfilter Stuff # # Run IPTables and store the command sub runIPTablesNewChain { my ($instance,$table,$chain) = @_; my $firewall = $globals->{'firewall'}; _runIPTables($table,'-N',$chain); $firewall->{'chains'}->{$instance}->{$table}->{$chain} = 1; } sub runIPTablesAdd { my ($instance,$table,$chain,@extra) = @_; my $firewall = $globals->{'firewall'}; _runIPTables($table,'-A',$chain,@extra); push(@{$firewall->{'rules'}->{$instance}->{$table}->{$chain}->{'items'}},\@extra); } sub runIPTablesDelete { my ($instance,$table,$chain,$position) = @_; _runIPTables($table,'-D',$chain,$position); } sub runIPTablesInsert { my ($instance,$table,$chain,$position,@extra) = @_; my $firewall = $globals->{'firewall'}; _runIPTables($table,'-I',$chain,$position,@extra); unshift(@{$firewall->{'irules'}->{$instance}->{$table}->{$chain}->{'items'}},\@extra); } sub runIPTablesAddJump { my ($instance,$table,$chain,$dest,@extra) = @_; my $firewall = $globals->{'firewall'}; _runIPTables($table,'-A',$chain,@extra,'-j',$dest); $firewall->{'jumps'}->{$instance}->{$table}->{$chain}->{$dest} = \@extra; } sub runIPTablesInsertJump { my ($instance,$table,$chain,$position,$dest,@extra) = @_; my $firewall = $globals->{'firewall'}; _runIPTables($table,'-I',$chain,$position,@extra,'-j',$dest); $firewall->{'ijumps'}->{$instance}->{$table}->{$chain}->{$dest} = \@extra; } sub runIPTablesAddToNew { my ($instance,$table,$chain,@extra) = @_; runIPTablesNewChain($instance,$table,$chain); runIPTablesAdd($instance,$table,$chain,@extra); } sub runIPTablesRemoveChain { my ($instance,$table,$chain) = @_; my $firewall = $globals->{'firewall'}; _runIPTables($table,'-F',$chain); _runIPTables($table,'-X',$chain); delete($firewall->{'rules'}->{$instance}->{$table}->{$chain}); delete($firewall->{'irules'}->{$instance}->{$table}->{$chain}); delete($firewall->{'chains'}->{$instance}->{$table}->{$chain}); } sub runIPTablesRemoveJumpChain { my ($instance,$table,$chain,$dest) = @_; runIPTablesRemoveJump($instance,$table,$chain,$dest); runIPTablesRemoveChain($instance,$table,$dest); } sub clearInstanceIPTables { my $instance = shift; my $firewall = $globals->{'firewall'}; # Run through jumps and ijumps, this is a shortcut! foreach my $jump ('jumps','ijumps') { # Find tables we added foreach my $table (keys %{$firewall->{$jump}->{$instance}}) { # Find chains we added jumps to foreach my $chain (keys %{$firewall->{$jump}->{$instance}->{$table}}) { # Find the jumps we added foreach my $dest (keys %{$firewall->{$jump}->{$instance}->{$table}->{$chain}}) { # Blow it away runIPTablesRemoveJumpChain($instance,$table,$chain,$dest); } } } } } # Function to dump the iptables rules that builds the ppp-gatekeeper stuff sub dumpIPTablesRules { my $firewall = $globals->{'firewall'}; logMsg('CONTROLLER','SIGUSR2',"Dumping IPTables rules"); if (!open(IPTR,"> $fwStateFile.lock")) { logMsg('CONTROLLER','SIGUSR2',"ERROR: Failed to open file '$fwStateFile': $!"); return; } # Loop with chains, must add these first foreach my $instance (keys %{$firewall->{'chains'}}) { foreach my $table (keys %{$firewall->{'chains'}->{$instance}}) { foreach my $chain (keys %{$firewall->{'chains'}->{$instance}->{$table}}) { print(IPTR "/sbin/iptables -t '$table' -N '$chain'\n"); } } } # Loop with insert rules, these must be before rules foreach my $instance (keys %{$firewall->{'irules'}}) { foreach my $table (keys %{$firewall->{'irules'}->{$instance}}) { foreach my $chain (keys %{$firewall->{'irules'}->{$instance}->{$table}}) { foreach my $item (@{$firewall->{'irules'}->{$instance}->{$table}->{$chain}->{'items'}}) { print(IPTR "/sbin/iptables -t '$table' -I '$chain' 1 "); foreach my $extra (@{$item}) { printf(IPTR "'$extra' "); } print(IPTR "\n"); } } } } # Loop with normal rules foreach my $instance (keys %{$firewall->{'rules'}}) { foreach my $table (keys %{$firewall->{'rules'}->{$instance}}) { foreach my $chain (keys %{$firewall->{'rules'}->{$instance}->{$table}}) { foreach my $item (@{$firewall->{'rules'}->{$instance}->{$table}->{$chain}->{'items'}}) { print(IPTR "/sbin/iptables -t '$table' -A '$chain' "); foreach my $extra (@{$item}) { printf(IPTR "'$extra' "); } print(IPTR "\n"); } } } } # Loop with insert jumps, these must be before jumps foreach my $instance (keys %{$firewall->{'ijumps'}}) { foreach my $table (keys %{$firewall->{'ijumps'}->{$instance}}) { foreach my $chain (keys %{$firewall->{'ijumps'}->{$instance}->{$table}}) { foreach my $dest (keys %{$firewall->{'ijumps'}->{$instance}->{$table}->{$chain}}) { print(IPTR "/sbin/iptables -t '$table' -I '$chain' 1 "); foreach my $extra (@{$firewall->{'ijumps'}->{$instance}->{$table}->{$chain}->{$dest}}) { printf(IPTR "'$extra' "); } print(IPTR " -j $dest\n"); } } } } # Loop with normal jumps foreach my $instance (keys %{$firewall->{'jumps'}}) { foreach my $table (keys %{$firewall->{'jumps'}->{$instance}}) { foreach my $chain (keys %{$firewall->{'jumps'}->{$instance}->{$table}}) { foreach my $dest (keys %{$firewall->{'jumps'}->{$instance}->{$table}->{$chain}}) { print(IPTR "/sbin/iptables -t '$table' -A '$chain' "); foreach my $extra (@{$firewall->{'jumps'}->{$instance}->{$table}->{$chain}->{$dest}}) { printf(IPTR "'$extra' "); } print(IPTR " -j $dest\n"); } } } } close(IPTR); # Move file into position unlink($fwStateFile); rename("$fwStateFile.lock",$fwStateFile); } # Remove an IPTables jump sub runIPTablesRemoveJump { my ($instance,$table,$chain,$jumpTo) = @_; my $firewall = $globals->{'firewall'}; # Look through iptables chain to see if we can find our jump open(IPT, "/sbin/iptables -t $table -S $chain |"); my $ruleNum = 0; my @found; while (my $line = ) { chomp($line); # Look for last column if ($line =~ /\s+(\S+)\s*$/) { if ($1 eq $jumpTo) { push(@found,$ruleNum); } } $ruleNum++; } close(IPT); # Whack the entry dead (blow them all away) foreach $ruleNum (reverse @found) { runIPTablesDelete($instance,$table,$chain,$ruleNum); } delete($firewall->{'jumps'}->{$instance}->{$table}->{$chain}->{$jumpTo}); delete($firewall->{'ijumps'}->{$instance}->{$table}->{$chain}->{$jumpTo}); } sub _runIPTables { my ($table,@params) = @_; runCommand('/sbin/iptables','-t',$table,@params); } # Become daemon sub daemonize { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '> /var/log/ppp-gatekeeper/stdout.log' or die "Can't open stdout log: $!"; defined(my $pid = fork) or die "Can't fork: $!"; exit if $pid; setsid or die "Can't start a new session: $!"; open STDERR, '> /var/log/ppp-gatekeeper/stderr.log' or die "Can't open stderr log: $!"; } # Display usage sub displayUsage { print(< Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ppp-gatekeeper-v0.1.0-201406111015/AUTHORS0000644000000000000000000000007712346026211015561 0ustar rootrootProject Leader -------------- Nigel Kukard ppp-gatekeeper-v0.1.0-201406111015/debian/0000755000000000000000000000000012346026211015727 5ustar rootrootppp-gatekeeper-v0.1.0-201406111015/debian/watch0000644000000000000000000000037412346026211016764 0ustar rootrootversion=3 opts=pgpsigurlmangle=s/$/.asc/,\ downloadurlmangle=s/\/(v?\d+\.\d+\.\d+.*)$/\/$1\/ppp-gatekeeper-$1.tar.gz/,\ filenamemangle=s/v?(\d+\.\d+\.\d+.*)$/ppp-gatekeeper-$1.tar.gz/ \ http://download.allworldit.org/ppp-gatekeeper/v?(\d+\.\d+\.\d+.*) ppp-gatekeeper-v0.1.0-201406111015/debian/copyright0000644000000000000000000000175512346026211017672 0ustar rootrootFormat: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Source: https://gitlab.devlabs.linuxassist.net/ppp-gatekeeper/ppp-gatekeeper Files: * Copyright: Copyright (C) 2010-2014, Linux Based Systems Design License: GPL-3+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see . . On Debian systems, the complete text of the GNU General Public License version 3 can be found in '/usr/share/common-licenses/GPL-3'. ppp-gatekeeper-v0.1.0-201406111015/debian/control0000644000000000000000000000200012346026211017322 0ustar rootrootSource: ppp-gatekeeper Maintainer: Nigel Kukard Section: contrib/net Priority: optional Standards-Version: 3.9.5 Build-Depends: debhelper (>= 9), docbook-to-man Homepage: http://gitlab.devlabs.linuxassist.net/ppp-gatekeeper/ppp-gatekeeper Vcs-Git: https://gitlab.devlabs.linuxassist.net/ppp-gatekeeper/ppp-gatekeeper.git Vcs-Browser: https://gitlab.devlabs.linuxassist.net/ppp-gatekeeper/ppp-gatekeeper/tree/master Package: ppp-gatekeeper Architecture: all Depends: ${perl:Depends}, ${misc:Depends}, libconfig-inifiles-perl, libio-pty-perl, ppp, iptables, conntrack Suggests: shorewall Description: PPP Gatekeeper manages redundant and failover PPPOE connections PPP Gatekeeper is a daemon that manages PPPOE connections supporting various levels of redundancy and failover. . Traffic can be routed using round-robin and random strategies over links of similar priority. Static IP route lists can also be provided for specific routing purposes. DNS can also be load balanced over multiple links. ppp-gatekeeper-v0.1.0-201406111015/debian/ppp-gatekeeper.logrotate0000644000000000000000000000032012346026211022555 0ustar rootroot/var/log/ppp-gatekeeper/stderr.log { weekly rotate 5 copytruncate compress notifempty missingok } /var/log/ppp-gatekeeper/stdout.log { weekly rotate 5 copytruncate compress notifempty missingok } ppp-gatekeeper-v0.1.0-201406111015/debian/upstream/0000755000000000000000000000000012346026211017567 5ustar rootrootppp-gatekeeper-v0.1.0-201406111015/debian/upstream/signing-key.asc0000644000000000000000000000413512346026211022506 0ustar rootroot-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1 mQENBFL+gX8BCAC5wuUs2HzUKfcfCveczsqeYB6nPK4iXCiVsWBQEPF0mvRSsRuo X7oDsH3fnmT5WR6YgZO4zSjarHBgH19J0uTEwEbWAdcnE04CQZm62/Nd29SqI2ni d237myxXL7wD5TtWP5Pz8iRVtlWPnKdXMYJ5u/OwJcrPsb59W8MonubdQ7XFzvjR A72x+g7BcP/rTZ8fTldzAbA3s4iRru+qqkToT/TyLzYP4aEJIb04CdiHhL2aoZ+e IE228KvWwj9HyGjXQGSNSJT8xmV6Iqrh7GhqbryvC4S4tFLCllJi61MXu4xEE1v7 zht6HJctRHRp3g8Hbi22gkPmbtDH3a06J+ENABEBAAG0R05pZ2VsIEt1a2FyZCAo QWxsV29ybGRJVCBTb2Z0d2FyZSBTaWduaW5nIEtleSkgPHN1cHBvcnRAYWxsd29y bGRpdC5jb20+iQE4BBMBAgAiBQJS/oF/AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIe AQIXgAAKCRBmQ4pbD+xVionoB/sFnA9o0UNP2rgv0dbVbWG68K55EaXb0C/4Js8B EH3vr7jHa+LqaYQMjHSP+ZmO5FgKd9Qf1P8S433Ie0AaJymeLirqUYWKIh4gN8Q6 G1kD6wCzh3EQ/0pWMeFfaI6JwX0cI6D9elnUjBpQtOzpZRrg075kZ4QUX2pob5Gh wjAh1ofDSGPcFOi7bfu9v6/xcWopudEG2vqbNZM09HZ1KCTVnmKK/Mjdax7NQMKV a41u1bzNhmIy9JI2GLVt8M89DNGBSwzC+nXM6EGVtHHXrr0Bg81dT+hfO472CfYD gztcxiK1D4G8+uU7Ou6vMNkXLksjC4hlWOr36ooFy23JYHwviQEcBBABAgAGBQJS /oMMAAoJEIR4oJUcqdAusL4IAKNYi4fCjjBB6ziHC9ZIkFY30Rwjcbl8qqx5Eo91 SU73Jv62oe4GtGoHHiyqAFl5iuLhTVa71xIIPXNsKXAbmq/AyuUzHrc5Xah56WMD sa6NDi29wdKcTh1dwgjs6A//HmyN66x/xyEcAVThFgMKdQE1e7sDbuEPeZ1LJ68p CcRxgFEK9/BLAHrKy1vivHsTyjeHnn5HRsgRBydvGUXQlx0HW7OT6O5NjkFzAePx z0sHQCxMssbP4ayw5lHhg+oAVIcfCR1vH2IruG+xAUQSY4JD6ttfm9NNqVuHmn/t URstSVBcqMXYyfLPkaHQgq4Nr/vIMY4neiI5z+ZLbkOV5Be5AQ0EUv6BfwEIANjk ZEsMzDiqTR7aVMmmalnZqrr9yQxG9n84ocu33qWVpHA4JCPGhVHV5ZqsNH7iCP+O RxSGtCBrd0gksEQtAZyw4vVkF7ZAI8HkWyT7RUloDECk+q0r2lzeLQZjcsJkkDuh pWKL+o8DAcKJ40NTcEEiXmtdwxC2icm8TrNqaGk9ylm6Kkw011CWYja4fkyW/fE/ kNSeA+Mj7dt+oVJkasOnuuXDS4zAZ95quPhLwdOM93ap/HU4SwGOzDBSfTRXwp79 +gr5lDDuzmmDfKa1O535T8M9BhGewwMYODMAyldsSxNQfSuDJ8dhblggt5GcYRpD MgK0YziU8v7pBat2a3sAEQEAAYkBHwQYAQIACQUCUv6BfwIbDAAKCRBmQ4pbD+xV io25B/9Snl0WyYl3cLMqgEJ0mXxVwjdwK9BTJFkrFd8lVCTaR2061RhlzwN5iEXG Hr2YqogaMX7wrJK7p10QioSOfZtQuQwHPceHZKT/qnPJ8ssgZ6lG184quomDf6Kw ICs+Mn0HSh6CVKfU3BLP+j5dN12SnJnGRVPhynBJ1sOaj6vSEvFeQnBKHyyax1f+ opYxDoKDkcPG0/SJ6E37WIyN26Cu5uX2tXyzLV7TCS1ilsTVVP4nGSR8Am3rz/OB Bfn4Yz6e/aD3CbeVJyxTKlbAcSclFshlt0Rv3TVnQXq4yFDFoYCaaSb/bCJ8pCVC o091XhVdO4pes0RYYsltc/NQ/GC9 =TvTK -----END PGP PUBLIC KEY BLOCK----- ppp-gatekeeper-v0.1.0-201406111015/debian/changelog0000644000000000000000000000025512346026211017603 0ustar rootrootppp-gatekeeper (0.1.0~201406111015-1) unstable; urgency=low * Updated to upstream v0.1.0-201406111015 -- Nigel Kukard Wed, 11 Jun 2014 12:16:41 +0200 ppp-gatekeeper-v0.1.0-201406111015/debian/source/0000755000000000000000000000000012346026211017227 5ustar rootrootppp-gatekeeper-v0.1.0-201406111015/debian/source/format0000644000000000000000000000001412346026211020435 0ustar rootroot3.0 (quilt) ppp-gatekeeper-v0.1.0-201406111015/debian/ppp-gatekeeper.manpages0000644000000000000000000000003012346026211022346 0ustar rootrootdebian/ppp-gatekeeper.1 ppp-gatekeeper-v0.1.0-201406111015/debian/ppp-gatekeeper.dirs0000644000000000000000000000004612346026211021523 0ustar rootrootetc/modprobe.d var/log/ppp-gatekeeper ppp-gatekeeper-v0.1.0-201406111015/debian/compat0000644000000000000000000000000212346026211017125 0ustar rootroot9 ppp-gatekeeper-v0.1.0-201406111015/debian/ppp-gatekeeper.init0000644000000000000000000000414212346026211021526 0ustar rootroot#!/bin/sh ### BEGIN INIT INFO # Provides: ppp-gatekeeper # Required-Start: $remote_fs $syslog $network # Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: PPP Gatekeeper # Description: PPP Gatekeeper is a daemon that manages PPPOE connections supporting # various levels of redundancy and failover ### END INIT INFO PATH=/sbin:/bin:/usr/sbin:/usr/bin . /lib/lsb/init-functions set -e DAEMON="/usr/sbin/ppp-gatekeeper" NAME="ppp-gatekeeper" PATH="/sbin:/bin:/usr/sbin:/usr/bin" LOGFILE1="/var/log/ppp-gatekeeper/stdout.log" LOGFILE2="/var/log/ppp-gatekeeper/stderr.log" RUNDIR="/var/run/ppp-gatekeeper" test -x "${DAEMON}" || exit 0 if [ ! -e "${LOGFILE1}" ] then touch "${LOGFILE1}" chmod 0640 "${LOGFILE1}" fi if [ ! -e "${LOGFILE2}" ] then touch "${LOGFILE2}" chmod 0640 "${LOGFILE2}" fi if [ ! -d "${RUNDIR}" ] then mkdir -p --mode=0750 "${RUNDIR}" fi case "${1}" in start) echo -n "Starting ppp-gatekeeper: " start-stop-daemon --start --oknodo --pidfile ${RUNDIR}/ppp-gatekeeper.pid --exec ${DAEMON} echo "${NAME}." ;; stop) echo -n "Stopping ppp-gatekeeper: " start-stop-daemon --stop --retry=TERM/120/KILL/5 --pidfile ${RUNDIR}/ppp-gatekeeper.pid --oknodo rm -f ${RUNDIR}/ppp-gatekeeper.pid echo "${NAME}." ;; restart) echo -n "Stopping ppp-gatekeeper: " start-stop-daemon --stop --retry=TERM/120/KILL/5 --pidfile ${RUNDIR}/ppp-gatekeeper.pid --oknodo rm -f ${RUNDIR}/ppp-gatekeeper.pid echo "${NAME}." echo -n "Starting ppp-gatekeeper: " start-stop-daemon --start --oknodo --pidfile ${RUNDIR}/ppp-gatekeeper.pid --exec ${DAEMON} echo "${NAME}." ;; reload|force-reload) ;; status) PID="$(cat ${RUNDIR}/ppp-gatekeeper.pid 2>/dev/null)" || true if [ ! -f ${RUNDIR}/ppp-gatekeeper.pid ] || [ -z "${PID}" ] then echo "${NAME} is not running" exit 3 fi if ps "${PID}" >/dev/null 2>&1 then echo "${NAME} is running" exit 0 else echo "${NAME} is not running" exit 1 fi ;; *) echo "Usage: /etc/init.d/${NAME} {start|stop|restart|reload|status}" exit 1 ;; esac exit 0 ppp-gatekeeper-v0.1.0-201406111015/debian/rules0000755000000000000000000000155412346026211017014 0ustar rootroot#!/usr/bin/make -f SHELL := /bin/bash %: dh $@ override_dh_install: dh_install install -d -m 0750 debian/ppp-gatekeeper/var/log/ppp-gatekeeper install -D -m 0640 ppp-gatekeeper.conf debian/ppp-gatekeeper/etc/ppp/ppp-gatekeeper.conf mv debian/ppp-gatekeeper/etc/modprobe.d/ppp-gatekeeper.{modprobe,conf} mv debian/ppp-gatekeeper/etc/dnsmasq.d/ppp-gatekeeper.{dnsmasq,conf} mv debian/ppp-gatekeeper/etc/shorewall/start{.shorewall,} chmod +x debian/ppp-gatekeeper/etc/shorewall/start override_dh_installdocs: dh_installdocs AUTHORS TODO override_dh_installinit: dh_installinit --no-start override_dh_auto_build: docbook-to-man docs/ppp-gatekeeper.sgml > debian/ppp-gatekeeper.1 dh_auto_build override_dh_fixperms: dh_fixperms --exclude etc/ppp/ppp-gatekeeper.conf --exclude var/log/ppp-gatekeeper override_dh_clean: rm -f debian/ppp-gatekeeper.1 dh_clean ppp-gatekeeper-v0.1.0-201406111015/debian/ppp-gatekeeper.install0000644000000000000000000000036112346026211022230 0ustar rootroot# Main daemon ppp-gatekeeper usr/sbin # Modprobe for xt_recent contrib/ppp-gatekeeper.modprobe etc/modprobe.d # DNSMasq config file contrib/ppp-gatekeeper.dnsmasq etc/dnsmasq.d # Shorewall start file contrib/start.shorewall etc/shorewall ppp-gatekeeper-v0.1.0-201406111015/debian/ppp-gatekeeper.lintian-overrides0000644000000000000000000000052312346026211024220 0ustar rootroot# This file contains passwords we don't want every user to have access to ppp-gatekeeper: non-standard-file-perm etc/ppp/ppp-gatekeeper.conf 0640 != 0644 # The logs may contain a username and IP routing information which we may not # want users to have access to ppp-gatekeeper: non-standard-dir-perm var/log/ppp-gatekeeper/ 0750 != 0755 ppp-gatekeeper-v0.1.0-201406111015/ChangeLog0000644000000000000000000004155712346026211016273 0ustar rootrootcommit a56c8f9af1c5816801afdc1f31633e36f745c1a4 Author: Nigel Kukard Date: Wed Jun 11 09:51:46 2014 +0000 Fixed description indentation Signed-off-by: Nigel Kukard commit c44e966f87a83293f8b02a8dfb868a5b717a458a Author: Nigel Kukard Date: Wed Jun 11 09:17:54 2014 +0000 Fixed debian watch file to list .gz instead of .xz commit af477b839e8976914f559ede07bfdd663a046e24 Author: Nigel Kukard Date: Tue Jun 10 07:08:05 2014 +0000 Fix permissions of config file and log dir Signed-off-by: Nigel Kukard commit cf67ab5e5be2da58a6f4733210a20552b5733535 Author: Nigel Kukard Date: Mon Jun 9 22:46:43 2014 +0000 Fixed permissions of conf file and log dir Signed-off-by: Nigel Kukard commit d640a8e0cc5d020a43944a55b4ed2d1e6b2a680d Author: Nigel Kukard Date: Mon Jun 9 22:30:13 2014 +0000 Fix race condition in mkdir, slight cleanup Signed-off-by: Nigel Kukard commit 5c7b463dfbe35126bda5e8d31191cab270c557b1 Author: Nigel Kukard Date: Mon Jun 9 22:25:55 2014 +0000 Fixed copyright to reflect GPL-3+ as it should Signed-off-by: Nigel Kukard commit f07c648d170376ad932da808d2cd81ba901a4a6c Author: Nigel Kukard Date: Mon Jun 9 22:25:09 2014 +0000 Fixed wrong license file being included Signed-off-by: Nigel Kukard commit 04ac4e02c9490235f9e43bbe1e7561c11933286a Author: Nigel Kukard Date: Mon Jun 9 22:22:13 2014 +0000 Fixed watch file, ucscan no longer fails Signed-off-by: Nigel Kukard commit f3e045a278e0d89656562a92caea50916e5d5935 Author: Nigel Kukard Date: Mon Jun 9 21:46:46 2014 +0000 Fixed package description Signed-off-by: Nigel Kukard commit b75a167d6dc2851204668a1ebea202d296c66e93 Author: Nigel Kukard Date: Mon Jun 9 11:36:20 2014 +0000 Fix description in initscript commit 5b19b743e98f146a4669082b09d253a996c145f6 Author: Nigel Kukard Date: Mon Jun 9 11:35:54 2014 +0000 Bump debhelper commit 7a68f44e34db598a271e2075b9d01b0d5cf7faa2 Author: Nigel Kukard Date: Mon Jun 9 11:32:31 2014 +0000 Add watch file and signing key commit f03a48a59922ca23eedcf6bd633ef7f181f838b5 Author: Nigel Kukard Date: Mon Jun 9 11:31:46 2014 +0000 Use quilt and not native commit 1cbc135012b0858f723c4607dbca560e9f6ae2b6 Author: Nigel Kukard Date: Mon Jun 9 09:43:05 2014 +0000 Added VCS URLs commit 4bb88cdf3940098d2f95cbde2da3c2207cc4fff0 Author: Nigel Kukard Date: Mon Jun 9 09:31:05 2014 +0000 Make sure we cleanup the stray manpage we create commit 6fe6e291ffcaed275e747f6f922f7251cae01bb6 Author: Nigel Kukard Date: Mon Jun 9 09:02:53 2014 +0000 Add path and source init functions in initscript commit 1d568bd5d4310c190668e51b0fcc84ab34e24018 Author: Nigel Kukard Date: Mon Jun 9 09:02:37 2014 +0000 Bump standards version commit 5ca10ae9fc02e510cb3735ac2322cafebcdb2d66 Author: Nigel Kukard Date: Sun Jun 8 22:48:50 2014 +0000 Fix 2 more lintian errors commit 8938185d2edf6c5d27c63ebd667c1e8d711ffc98 Author: Nigel Kukard Date: Sun Jun 8 22:46:31 2014 +0000 Fixed mv chmod typo commit ce964cc7be623fc7ab67f4bab94f6a1e0cd2801b Author: Nigel Kukard Date: Sun Jun 8 22:41:37 2014 +0000 Fix some lintian errors commit 31f350892a3ee1aa54e940b3c26303f292a6cb32 Author: Nigel Kukard Date: Sun Jun 8 22:41:19 2014 +0000 We can use shell code in rules commit 76e764c9218e9f8f85472a29703519f1bae8c129 Author: Nigel Kukard Date: Sun Jun 8 21:07:30 2014 +0000 Add shell to debian rules commit 2dcbb97d69af64855ed3945fac0c865fda8a9583 Author: Nigel Kukard Date: Sun Jun 8 21:02:51 2014 +0000 Use $(shell ...) in makefile commit aee2b78f9da339e1c2e42f6c666e61f50cb74621 Author: Nigel Kukard Date: Sun Jun 8 20:55:11 2014 +0000 Cleaned up debian packaging commit dd8b1196c515d2ac0af8cb20c97ccda9ba5a9271 Author: Nigel Kukard Date: Sun Mar 9 19:07:05 2014 +0000 Fixed spurious use of indentation, bumped (c) commit 408dea4015b66b931d845cd5bca225648d4d4ec6 Author: Nigel Kukard Date: Thu Dec 19 16:18:39 2013 +0000 Make the RUNDIR when we start up if it not there commit 348f804e55ca5cea53e41f8d96e824e8e8edcb80 Author: Nigel Kukard Date: Mon Jun 24 16:38:57 2013 +0000 Added init= option to execute before pppd commit b547e72b0d78443e68fb88f0ddd37b6e0f049883 Author: Nigel Kukard Date: Thu Jun 20 09:02:42 2013 +0000 Add CIDR mask to DNS server IP's for excl list commit 4bd5da9db29f6b810e4871b3e9cf7264c830fe7c Author: Nigel Kukard Date: Fri May 17 19:09:08 2013 +0000 Don't track local routes outbound commit ff6fb0a452e95d7a0af737c8dda7e6701590d3d2 Author: Nigel Kukard Date: Sat May 11 13:29:56 2013 +0000 Set hash size automatically commit ed41ed4df86de09d97fbc159de84a25ff1ca3d4f Author: Nigel Kukard Date: Sat May 11 13:29:20 2013 +0000 Added config example for ppp_* items commit 2e2fe988c7092b27e40f711d3890c32bdafffe54 Author: Nigel Kukard Date: Sat May 11 13:28:50 2013 +0000 Fixed typo with ppp_init and added config commit 6ad7222666fb9825c50cb9667ca1eb0d98944194 Author: Nigel Kukard Date: Tue May 7 10:58:18 2013 +0000 Fixed exclude list and added ppp connect script Fixed how the tracking exclusion works internally Added support for a ppp connect script commit d9b34ee57e06228530f6aeb8dac09a8e3bc874e4 Author: Nigel Kukard Date: Fri May 3 08:20:33 2013 +0000 Fixed two typos in variable names commit d451ad16508118cb1473627810d58ca734c137b3 Author: Nigel Kukard Date: Wed May 1 09:29:54 2013 +0000 Added tracking exclusion table, fixed typo Added a tracking exclusions ipset to alow for excluding of dest ranges Fixed bug where dns->current should of been used commit 78b0fcf729adf65641993d25823bf9e74d40c8b6 Author: Nigel Kukard Date: Wed May 1 09:03:51 2013 +0000 Flush cache and tracking of DNS on reconnect commit 2d7d27260714131f85ed31ee81844baa04b896e0 Author: Nigel Kukard Date: Sat Apr 27 21:52:19 2013 +0000 Fix missing metric for added routes commit 755e566c9e271463e45a2dab61a046a5c8c9e3c0 Author: Nigel Kukard Date: Mon Feb 18 22:10:16 2013 +0000 Fixed ordering of rules commit b05a616e9289c899183ff14a2cf99524be573962 Author: Nigel Kukard Date: Mon Jan 7 17:07:32 2013 +0000 Updated initscript with kill timeouts commit 4bc6767b6ccac5aaf232ee38e023780d40f5956f Author: Nigel Kukard Date: Mon Jan 7 17:07:12 2013 +0000 Major iptables rules update & support for modems commit e8c7ed95f00ea1eceb5de66a8176f565069ab0b4 Author: Nigel Kukard Date: Fri Nov 2 12:42:25 2012 +0000 Fixed metric not being pulled in for loaded routes Metric was not being pulled in for routes read from the routes file. Fixed. commit cf481ba18649a89ff1f85bb341fc5b38b8005593 Author: Nigel Kukard Date: Thu Sep 27 17:25:39 2012 +0000 Fixed initscript run directory commit ec2b94eb1ab6c85616fb3ad51c989d247e8856aa Author: Nigel Kukard Date: Thu Sep 27 07:51:57 2012 +0000 Mark forwarded & output traffic for tracking commit b52cf1f85b9541641b03ba0cc5f2c5b7c4428178 Author: Nigel Kukard Date: Wed Sep 26 19:07:28 2012 +0000 Major reworking on routing commit 1a68a2e1847e49195f1ecf7f31ef1c49abcbbd2d Author: Nigel Kukard Date: Tue Sep 25 19:33:47 2012 +0000 Added INSTALL file commit 8e2e078ec006475c2621fd3c6f269b857c0a754a Author: Nigel Kukard Date: Tue Sep 25 19:33:27 2012 +0000 Fixed whitespaces commit 496346c77f869cfadf59cac2b0636d1a3124bf6c Author: Nigel Kukard Date: Tue Sep 25 19:30:02 2012 +0000 Make shorewall script executable commit 40fd8e45e32c3a93d0a7efb42a6a2e239d8f17de Author: Nigel Kukard Date: Tue Sep 25 19:27:41 2012 +0000 Added INSTALL file and shorewall as a suggests commit 6c8203eef27fee6539cb3e98730e4075054385c0 Author: Nigel Kukard Date: Tue Sep 25 19:26:48 2012 +0000 Keep more traffic logs, enhance resolvconf Keep 5 mins of traffic logs instead of 5 seconds Enhance the DNS system by using resolvconf if its available commit 6cf2fc27d0b7224db9c8d5e5f3610b8c86647cb5 Author: Nigel Kukard Date: Tue Sep 25 15:53:23 2012 +0000 Fixed some typos commit 6bfa63a79edf9ba9bbfc404406bf1b583320de03 Author: Nigel Kukard Date: Tue Sep 25 15:14:15 2012 +0000 Fixed more paths in debian rules file commit e643ab591f0868eeeb7b6983f5b11f23b6cef3b3 Author: Nigel Kukard Date: Tue Sep 25 15:09:53 2012 +0000 Fixed debian rules bug where path was wrong commit 1c0c9039f53b86522e8f7dac4c4103a9b7179955 Author: Nigel Kukard Date: Tue Sep 25 15:06:25 2012 +0000 Added /etc/modprobe.d, don't stop when installing commit 1ebad6985754ac7aa9005aaf26f54969d517d945 Author: Nigel Kukard Date: Tue Sep 25 14:50:18 2012 +0000 Close to a total overhaul of how we load balance commit 32b736c18d3a3f7bc07cd6b0ea7e79d98e876ef3 Author: Nigel Kukard Date: Tue Sep 25 14:39:33 2012 +0000 Add a /var/run dir for storing state files commit c2d2d7f274e6ec8249bae570d3843cd7b460b6ac Author: Nigel Kukard Date: Tue Sep 25 14:39:10 2012 +0000 We only need one packet timestamp stored commit f1ee5752b0ee17cd8fa474dadb2ef078e1448f6f Author: Nigel Kukard Date: Thu Sep 20 06:45:57 2012 +0000 Added DNSMasq config file commit 0e755568b8dd7a22d6596c1e332c5c14c03fd3c3 Author: Nigel Kukard Date: Thu Sep 20 06:40:45 2012 +0000 Added modprobe config file This allows us to store a large number of xt_recent entries instead of just the standard 100. commit 6ec844d29d7e7a65506276364ee9419dd2e96d40 Author: Nigel Kukard Date: Sat Sep 8 23:31:09 2012 +0200 Don't create pid file in initscript commit d8cb2a35432621d4a935077bba292b272692d1e3 Author: Nigel Kukard Date: Sat Sep 8 23:30:31 2012 +0200 Create a PID file when we run as a daemon commit 8ac160099072dec78964981a3bb4ea5a470b3d05 Author: Nigel Kukard Date: Sat Sep 8 23:15:40 2012 +0200 Start ppp-gatekeeper after reboot, updated init commit dcf0e403d71cd8e56029c439a2d342e2e943297f Author: Nigel Kukard Date: Sat Sep 8 23:02:13 2012 +0200 Fixed naming of pppd to ppp for debian commit a4e0e5aca16451af1b568a419e3937bfd5331084 Author: Nigel Kukard Date: Sat Sep 8 20:55:49 2012 +0000 Added additional requires for debian packaging commit cf81cc69f434fce8d60df3d66dfd8d48a429f471 Author: Nigel Kukard Date: Sat Sep 8 22:32:59 2012 +0200 More initscript fixes commit 77a6e4447ac890cf2105ea6a04974a90375d9d2c Author: Nigel Kukard Date: Sat Sep 8 22:24:52 2012 +0200 Don't start/stop initscript by default commit 46a96a5ddb5902615609a4f2d820835bad4d9643 Author: Nigel Kukard Date: Sat Sep 8 21:59:58 2012 +0200 Revert "Do not automatically start ppp-gatekeeper" This reverts commit dadf22fa562e584263e023b8d745b912c82ca254. commit dadf22fa562e584263e023b8d745b912c82ca254 Author: Nigel Kukard Date: Sat Sep 8 21:45:43 2012 +0200 Do not automatically start ppp-gatekeeper commit c12832abc092a0da789a73052dc21fb682ddd767 Author: Nigel Kukard Date: Sat Sep 8 21:37:59 2012 +0200 Don't create rundir as its /var/run commit aed81857152f31d20c715239143af309648c1ab2 Author: Nigel Kukard Date: Sat Sep 8 19:54:21 2012 +0200 Fixed run dir commit 8021e7bcede7e1f50c379e3a407616a64d2a6172 Author: Nigel Kukard Date: Sat Sep 8 16:41:18 2012 +0200 Fixed manpage path commit 73eb464263462c5b0fa1e465b409913161336acf Author: Nigel Kukard Date: Sat Sep 8 16:39:49 2012 +0200 Added manpages file for debian packaging commit 65703f42a35ea4f24444f603316a5e9ede17e3f7 Author: Nigel Kukard Date: Sat Sep 8 16:37:25 2012 +0200 Fixed manpage formatting problems commit 089e094b56810ee4878046032739619a7b56a932 Author: Nigel Kukard Date: Sat Sep 8 16:31:44 2012 +0200 Added manpage commit c967083dd568b2acea99bf6a06fcdbf146bc7670 Author: Nigel Kukard Date: Sat Sep 8 16:31:21 2012 +0200 Added manpage building make rule commit 26a1f09848ef15702650bb7a74c7bc1e627b5dde Author: Nigel Kukard Date: Sat Sep 8 16:30:56 2012 +0200 Added build depend for docbook-to-man commit aae11d118dbd444ca8d73592aaa1de997ba69552 Author: Nigel Kukard Date: Sat Sep 8 16:30:37 2012 +0200 We don't need a run dir commit 1b2f2fcee5e68f2857fc638d8fd758ddd3a1b99c Author: Nigel Kukard Date: Sat Sep 8 16:29:02 2012 +0200 Changed --daemon to --fg commit 9ac2d14cf91f0a84ef173258d9d8e562de3f642d Author: Nigel Kukard Date: Sat Sep 8 14:57:10 2012 +0200 Added Debian packaging info commit 33d4f8fc37e3cca7b99f9fbfac04f014a426fda3 Author: Nigel Kukard Date: Sat Sep 8 14:57:02 2012 +0200 Removed old config file commit 604cc34e372676cfdbddaa5db0ad76f94010ef94 Author: Nigel Kukard Date: Sat Sep 8 14:55:22 2012 +0200 Fixed up log file paths Changed name of config file commit 0636ec4e08c523e48599af9f5be80727595a5074 Author: Nigel Kukard Date: Sat Sep 8 07:24:07 2012 +0000 Updated copyright commit 860322a9c1ed1b2b6a62dd75f6a3e15c6d87970b Author: Nigel Kukard Date: Sat Sep 8 07:22:17 2012 +0000 Fixed incorrect default route being used Remove old connection tracking information when connection goes down commit 74cb777875ef4fd69d7653a604b1d71d6fee8d18 Author: Nigel Kukard Date: Tue Sep 13 16:58:22 2011 +0000 Updated routing tables and added pid files commit 68fbac417fb6a2ab2d322dac14eea836cfac2c5a Author: Nigel Kukard Date: Mon Apr 4 10:36:28 2011 +0000 Added more debugging info, better timeout support commit 32b81dbe8b3346a9e1784ba1c24f248e851609dd Author: Nigel Kukard Date: Fri Jan 14 01:41:49 2011 +0000 Run ifup scripts in the background This allows us not to hang all other connections if the script is running slow, like a dynamic dns update commit 03afed193f971d41b88ea92793267b6f0a693977 Author: Nigel Kukard Date: Fri Dec 31 19:28:31 2010 +0000 Fixed up formatting of LICENSE file Copied file from gnu.org site commit 3b079609259bc182d919012db0d0357f8cae1935 Author: Nigel Kukard Date: Thu Dec 23 12:58:32 2010 +0000 * Added LICENSE, TODO & AUTHORS files commit 253ff74ea1611ea8e0cd24ba83286e4ea8971b95 Author: Nigel Kukard Date: Sun Nov 28 16:20:45 2010 +0000 * use connConfig, not thisConn for configuration of ifup and ifdown commit 4bb296d6e9e4d2f3b076f7f92007e530f7a0439e Author: Nigel Kukard Date: Sat Nov 27 17:33:13 2010 +0000 * Fixed bug where thisConn was used instead of $connConfig for route exclusion lists commit 7c4a733c7ee6de163b48fba4b8d71f1a6c0c69f0 Author: Nigel Kukard Date: Sat Nov 27 17:28:04 2010 +0000 * More fixups commit 8d6d30a9c123723c749f1d96f8cf3e8bb300df80 Author: Nigel Kukard Date: Fri Nov 26 21:45:48 2010 +0000 * Refactored ppp-gateway not to use shm and developed a better design * Added support for ppp unit number specification commit 98c0d2e7c0a9798523bbe6ede93ed84465071bcd Author: Nigel Kukard Date: Tue Nov 23 06:15:14 2010 +0000 * Fixed up routing priorities * Added ifup and ifdown hooks commit 4f65604eda4def16af5ebd700f303a15233fd681 Author: Nigel Kukard Date: Sat Nov 20 22:01:51 2010 +0000 * Fixed up --help * Removed unused functions commit f29c2ded043e751209baa4b7d1b7768f7c775052 Author: Nigel Kukard Date: Sat Nov 20 21:52:04 2010 +0000 * Initial checkin