RE: IP Filtering Patch
"Metzger, Michael" <[email protected]> Thu, 20 Feb 2003 11:48:16 -0600
| Newsgroups | gmane.music.equipment.slimp3.dev |
|---|---|
| Message-ID | <[email protected]> |
------_=_NextPart_000_01C2D908.3F27BD90 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Ok, this patch applies to CVS as of this morning (02/20/03) and implements the following: - Option to allow/disallow local IP addresses to connect (127.0.0.1, any local IP, etc) (enabled by default) - Removal of 127.0.0.1 from always being listed in allowed IPs - Text cleanup based on new option Mike -----Original Message----- From: Metzger, Michael [mailto:[email protected]] Sent: Thursday, February 20, 2003 11:14 AM To: '[email protected]' Subject: RE: [slimp3-dev] IP Filtering Patch Working on it as we speak. To suit everyone, I've added an additional option of "Allow Local IPs" to either implicitly allow every IP aliased on the system, or block them. If you block them, you can still explicitly define certain sources. Should hopefully have something soon, but my job keeps getting in the way... ;) Mike -----Original Message----- From: dean blackketter [mailto:[email protected]] Sent: Thursday, February 20, 2003 11:12 AM To: [email protected] Subject: Re: [slimp3-dev] IP Filtering Patch Fair enough. By default the local machine addresses should be allowed. The current CVS tree always adds 127.0.0.1, even if you delete it AND blocks connections from the local machine even if 127.0.0.1 is allowed (as they appear to come in on the adaptor's address.) Patches, anyone? -dean On Thursday, February 20, 2003, at 07:28 AM, Karl Auer wrote: > On Thu, 20 Feb 2003 07:53:22 -0800 > dean blackketter <[email protected]> wrote: >> I think that the local host (and all it's aliases) should always be >> allowed and shouldn't even appear. > > Heavens, no! On a Unix machine, who's to say all the users are trusted? > > Please leave this settable, or at least only open in conjunction with > active password protection. > > Regards, K. > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Karl Auer (kauer-Va/[email protected]) +41-43-2660706 (h) > http://www.biplane.com.au/~kauer/ +41- 1-6327531 (w) > > ------------------------ Yahoo! Groups Sponsor > ---------------------~--> > Get 128 Bit SSL Encryption! > http://us.click.yahoo.com/FpY02D/vN2EAA/xGHJAA/rIp0lB/TM > --------------------------------------------------------------------- > ~-> > > To unsubscribe from this group, send an email to: > [email protected] > > > > Your use of Yahoo! Groups is subject to > http://docs.yahoo.com/info/terms/ > > To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/FpY02D/vN2EAA/xGHJAA/rIp0lB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: [email protected] Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ ------_=_NextPart_000_01C2D908.3F27BD90 Content-Type: application/octet-stream; name="ipfilter-022003.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ipfilter-022003.diff" ? Playlists ? ipfilter-022003.diff Index: strings.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/slimp3/slimp3/server/strings.txt,v retrieving revision 1.158 diff -u -p -B -r1.158 strings.txt --- strings.txt 20 Feb 2003 06:56:07 -0000 1.158 +++ strings.txt 20 Feb 2003 17:36:26 -0000 @@ -1921,8 +1921,20 @@ SETUP_ALLOWEDHOSTS EN IP addresses allowed to make incoming connections =20 SETUP_FILTERRULE_DESC - EN If you have turned on blocking you can enter the addresses that = you'd like to allow to connect to the SLIMP3 server.<br><br>This field = accepts a list of specific IP addresses, * style wildcards, and IP = address ranges in a comma separated list. For = example:<BR><BR><B>10.1.2.2</B> will allow only 10.1.2.2 to = connect<BR><BR><B>10.1.2.*</B> will allow anything with an IP address = that be the 10.1.2.x addresses.<BR><BR><B>10.1.2.2-50</B> will allow IP = addresses in the range 10.1.2.2 - 10.1.2.50 to connect.<BR><BR>Finally, = multiple entries can be combined with commas, like this = <B>10.1.2.2,172.16.1.*,192.168.1-255.*</B><BR><BR>Note: 127.0.0.1 is = always added to the list to allow the computer running the SLIMP3 = server to connect. + EN If you have turned on blocking you can enter the addresses that = you'd like to allow to connect to the SLIMP3 server.<br><br>This field = accepts a list of specific IP addresses, * style wildcards, and IP = address ranges in a comma separated list. For = example:<BR><BR><B>10.1.2.2</B> will allow only 10.1.2.2 to = connect<BR><BR><B>10.1.2.*</B> will allow anything with an IP address = that be the 10.1.2.x addresses.<BR><BR><B>10.1.2.2-50</B> will allow IP = addresses in the range 10.1.2.2 - 10.1.2.50 to connect.<BR><BR>Finally, = multiple entries can be combined with commas, like this = <B>10.1.2.2,172.16.1.*,192.168.1-255.*</B><BR><BR> =20 +SETUP_ALLOWLOCAL_HEAD + EN Allow Local IP Connections +=09 +SETUP_ALLOWLOCAL_DESC + EN Allow IP addresses assigned to SliMP3 server to connect implicitly = to the HTTP or CLI interfaces.<BR>This includes the loopback address = and any locally assigned IP addresses.<BR> +=09 +SETUP_ALLOWLOCAL + EN Allow +=09 +SETUP_NO_ALLOWLOCAL + EN Do not Allow +=09 #miscellaneous setup strings SETUP_NEW_VALUE DE Neuer Wert f=FCr Index: lib/SliMP3/HTTP.pm =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/slimp3/slimp3/server/lib/SliMP3/HTTP.pm,v retrieving revision 1.227 diff -u -p -B -r1.227 HTTP.pm --- lib/SliMP3/HTTP.pm 20 Feb 2003 06:56:07 -0000 1.227 +++ lib/SliMP3/HTTP.pm 20 Feb 2003 17:36:30 -0000 @@ -94,10 +94,27 @@ my %streamingFiles; =20 my $mdnsIDslimp3; my $mdnsIDhttp; +my @hostaddr; + # initialize the http server sub init { + my $host =3D gethost(hostname() || 'localhost'); + if ( @{$host->addr_list} > 1 )=20 + {=20 + my $i; + for my $addr ( @{$host->addr_list} ) { + push @hostaddr, inet_ntoa($addr); + }=20 + } else { + push @hostaddr, inet_ntoa($host->addr); + }=20 +=09 idle(); }=09 + +sub hostaddr { + return \@hostaddr; +} =20 sub openport { my ($listenerport, $listeneraddr) =3D @_; Index: lib/SliMP3/Misc.pm =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/slimp3/slimp3/server/lib/SliMP3/Misc.pm,v retrieving revision 1.142 diff -u -p -B -r1.142 Misc.pm --- lib/SliMP3/Misc.pm 20 Feb 2003 06:56:07 -0000 1.142 +++ lib/SliMP3/Misc.pm 20 Feb 2003 17:36:30 -0000 @@ -493,6 +493,15 @@ sub delimitThousands { sub isAllowedHost { my $host =3D shift; my @rules =3D split /\,/, SliMP3::Prefs::get('allowedHosts'); + if (SliMP3::Prefs::get('allowLocalhost')) + { + foreach my $addr (@{SliMP3::HTTP::hostaddr()}) + { + push @rules, $addr; + } + push @rules, '127.0.0.1'; + } +=09 foreach my $item (@rules) { if ($item eq $host) Index: lib/SliMP3/Prefs.pm =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/slimp3/slimp3/server/lib/SliMP3/Prefs.pm,v retrieving revision 1.95 diff -u -p -B -r1.95 Prefs.pm --- lib/SliMP3/Prefs.pm 20 Feb 2003 06:56:07 -0000 1.95 +++ lib/SliMP3/Prefs.pm 20 Feb 2003 17:36:30 -0000 @@ -41,8 +41,9 @@ my %DEFAULT =3D ( ,"authorize" =3D> 0 # No authorization by default ,"username" =3D> '' ,"password" =3D> '' - ,"filterHosts" =3D> 0 # use 0 for false, 1 for true - ,"allowedHosts" =3D> "127.0.0.1" + ,"filterHosts" =3D> 0 # No filtering by default + ,"allowLocalhost" =3D> 1 # Allow local IP addresses to connect + ,"allowedHosts" =3D> "" ,"tcpReadMax" =3D> 2 ,"tcpWriteMax" =3D> 2 ,"tcpConnectMax" =3D> 3 Index: lib/SliMP3/Setup.pm =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/slimp3/slimp3/server/lib/SliMP3/Setup.pm,v retrieving revision 1.84 diff -u -p -B -r1.84 Setup.pm --- lib/SliMP3/Setup.pm 20 Feb 2003 06:56:07 -0000 1.84 +++ lib/SliMP3/Setup.pm 20 Feb 2003 17:36:32 -0000 @@ -946,7 +946,7 @@ sub initSetupConfig { ,'GroupOrder' =3D> ['Default'] ,'Groups' =3D> { 'Default' =3D> { - 'PrefOrder' =3D> = ['authorize','username','password','filterHosts', 'allowedHosts'] + 'PrefOrder' =3D> = ['authorize','username','password','filterHosts', 'allowLocalhost', = 'allowedHosts'] } } ,'Prefs' =3D> { @@ -977,6 +977,15 @@ sub initSetupConfig { ,'1' =3D> string('SETUP_IPFILTER') } } + ,'allowLocalhost' =3D> { + 'validate' =3D> \&validateTrueFalse + ,'PrefHead' =3D> string('SETUP_ALLOWLOCAL_HEAD') + ,'PrefDesc' =3D> string('SETUP_ALLOWLOCAL_DESC') + ,'options' =3D> { + '0' =3D> string('SETUP_NO_ALLOWLOCAL') + ,'1' =3D> string('SETUP_ALLOWLOCAL') + } + } ,'allowedHosts' =3D> { 'validate' =3D> \&validateAllowedHosts ,'PrefHead' =3D> string('SETUP_FILTERRULE_HEAD') @@ -2042,11 +2051,7 @@ sub validateAllowedHosts { $val =3D~ s/\s+//g; if (!defined($val)) { return undef; - } elsif ($val eq '') { - return "127.0.0.1"; - } elsif ($val !~ /127\.0\.0\.1/) { - $val =3D "127.0.0.1," . $val; - } else { + } else { return $val; } } ------_=_NextPart_000_01C2D908.3F27BD90--