Thread: [pastebot-cvs] pastebot/Server Web.pm,1.7,1.8
Status: Beta
Brought to you by:
rcaputo
From: <to...@us...> - 2002-10-18 02:02:38
|
Update of /cvsroot/pastebot/pastebot/Server In directory usw-pr-cvs1:/tmp/cvs-serv31068/Server Modified Files: Web.pm Log Message: add an option to see if there's a proxy, if the request came through the passthrough proxy, extract the originating IP address from the headers the proxy gives us. Index: Web.pm =================================================================== RCS file: /cvsroot/pastebot/pastebot/Server/Web.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Web.pm 17 Oct 2002 02:51:49 -0000 1.7 --- Web.pm 18 Oct 2002 02:02:30 -0000 1.8 *************** *** 53,58 **** my ( $heap, $socket, $remote_address, $remote_port, ! $my_name, $my_host, $my_port, $my_ifname, $my_isrv, $my_chans ! ) = @_[HEAP, ARG0..ARG8]; # TODO: I think $my_host is obsolete. Maybe it can be removed, and --- 53,59 ---- my ( $heap, $socket, $remote_address, $remote_port, ! $my_name, $my_host, $my_port, $my_ifname, $my_isrv, $my_chans, ! $proxy, ! ) = @_[HEAP, ARG0..ARG9]; # TODO: I think $my_host is obsolete. Maybe it can be removed, and *************** *** 65,68 **** --- 66,70 ---- $heap->{my_isrv} = $my_isrv; $heap->{my_chans} = $my_chans; + $heap->{my_proxy} = $proxy; $heap->{remote_addr} = inet_ntoa($remote_address); *************** *** 141,148 **** $channel =~ tr[\x00-\x1F\x7F][]d; my $error = ""; if (length $channel) { # See if it matches. ! if (is_ignored($heap->{my_isrv}, $channel, $heap->{remote_addr})) { $error = ( "<p><b><font size='+1' color='#800000'>" . --- 143,161 ---- $channel =~ tr[\x00-\x1F\x7F][]d; + my $remote_addr = $heap->{remote_addr}; + if ($heap->{my_proxy} && $remote_addr eq $heap->{my_proxy}) { + # apache sets the X-Forwarded-For header to a list of the + # IP addresses that were forwarded from/to + my $forwarded = $request->headers->header('X-Forwarded-For'); + if ($forwarded) { + ($remote_addr) = split ',', $forwarded; + } + # else must be local + } + my $error = ""; if (length $channel) { # See if it matches. ! if (is_ignored($heap->{my_isrv}, $channel, $remote_addr)) { $error = ( "<p><b><font size='+1' color='#800000'>" . *************** *** 180,184 **** } ! $nick .= " at $heap->{remote_addr}"; # <CanyonMan> how about adding a form field with a "Subject" --- 193,197 ---- } ! $nick .= " at $remote_addr"; # <CanyonMan> how about adding a form field with a "Subject" *************** *** 208,212 **** my $id = store_paste( $nick, $html_summary, $paste, ! $heap->{my_isrv}, $channel, $heap->{remote_addr} ); my $paste_link = "http://$heap->{my_inam}:$heap->{my_port}/$id"; --- 221,225 ---- my $id = store_paste( $nick, $html_summary, $paste, ! $heap->{my_isrv}, $channel, $remote_addr ); my $paste_link = "http://$heap->{my_inam}:$heap->{my_port}/$id"; *************** *** 302,308 **** my @channels = @{$heap->{my_chans}}; @channels = map { "<option value='\#$_'>\#$_" } @channels; - $channels[0] =~ s/\'\>\#/\' selected>\#/; @channels = sort @channels; ! unshift(@channels, "<option value=''>(none)"); # Build content. --- 315,320 ---- my @channels = @{$heap->{my_chans}}; @channels = map { "<option value='\#$_'>\#$_" } @channels; @channels = sort @channels; ! unshift(@channels, "<option value='' selected>(none)"); # Build content. *************** *** 431,435 **** [ @_[ARG0..ARG2], $server, $conf{iface}, $conf{port}, $conf{ifname}, $conf{irc}, ! $ircconf{channel} ], ); --- 443,447 ---- [ @_[ARG0..ARG2], $server, $conf{iface}, $conf{port}, $conf{ifname}, $conf{irc}, ! $ircconf{channel}, $conf{proxy}, ], ); |