home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.madoka.org
/
2014.12.ftp.madoka.org.tar
/
ftp.madoka.org
/
pub
/
plum
/
2.x
/
plum2_32_1.lzh
/
module
/
ctcp
/
dcc
/
nat.plm
< prev
next >
Wrap
Text File
|
1999-02-20
|
4KB
|
131 lines
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><!-- $_ if 0; # -*- perl -*-
# $Id: nat.plm,v 2.4 1998/12/24 04:24:15 hasegawa Exp $
# copyright (c)1998 Yoshinori Hasegawa <hasegawa@madoka.org>
package ctcp_dcc_nat;
$_ = 'ctcp_dcc_nat';
sub cpcs_dcc {
local($clientno, $prefix, $cmd, @params) = @_;
local($userno, @args, $ip, $from, $to, $peer, $host, $adrs);
$userno = $'userno[$clientno];
@args = split(/\s+/, $params[1]);
$ip = &parse_ip($args[2]);
foreach $map (&'property($userno, 'mapping')) {
($from, $to) = split(/\s+/, $map);
next unless $to;
next unless &parse_ip($from) == $ip;
$args[2] = &parse_ip($to);
$params[1] = join(' ', @args);
return ($prefix, $cmd, @params);
}
if (&check_private($userno, $ip)) {
$peer = (&'peername($clientno))[1];
if (&check_private($userno, $peer)) {
$host = (split(/\@/, &'user($'server[$clientno]), 2))[1];
$adrs = &parse_ip($host);
if ($adrs) {
$args[2] = $adrs;
}
} else {
$args[2] = $peer;
}
$params[1] = join(' ', @args);
}
return ($prefix, $cmd, @params);
}
sub check_private {
local($userno, $ip) = @_;
local($start, $end);
foreach $private (&'property($userno, 'private')) {
($start, $end) = split(/\s+/, $private);
next unless $end;
next unless $ip >= &parse_ip($start);
next unless $ip <= &parse_ip($end);
return 1;
}
return 0;
}
sub parse_ip {
local($ip) = @_;
local(@addr);
if ($ip =~ /^\d+$/) {
return $ip;
} elsif ($ip =~ /^[\d\.]+$/) {
@addr = split(/\./, $ip);
return unpack('N', pack('C4', @addr, 0, 0, 0));
} else {
return unpack('N', (gethostbyname($ip))[4] || "\0\0\0\0");
}
return 0 unless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B$r%0%m!<%P%k(BIP$B$KJQ49$7$F(B
$BAw?.@h$NAj<j$KAw$j$^$9!#(B
</DD>
<DT> ctcp.dcc.nat.private* $B@hF,%"%I%l%9(B $B=*N;%"%I%l%9(B
</DT>
<DD> $B%W%i%$%Y!<%H$J(BIP$B%"%I%l%9$NHO0O$r;XDj$7$^$9!#(B
$BAw$m$&$H$9$k(BDCC$B$,$3$NHO0OFb$N$b$N$+$i$G$"$l$P!"(B
IP$B%"%I%l%9$rJQ49$7$^$9!#(B
</DD>
</DL>
<HR><H3>$B@_DjNc(B</H3>
<PRE>
+ ctcp/dcc/nat.plm
ctcp.dcc.nat.mapping: 192.168.1.1 133.6.108.1
ctcp.dcc.nat.mapping: 192.168.1.2 133.6.108.2
</PRE>
$B!V(B192.168.1.1$B!W$+$iAw$i$l$F$-$?(BDCC$B$r!V(B133.6.108.1$B!W$+$iAw$C$?$h$&$K(B
$B8+$;$+$1$FAw?.@h$NAj<j$KAw$j$^$9!#$^$?!V(B192.168.1.2$B!W$+$iAw$i$l$F$-$?(B
DCC$B$r!V(B133.6.108.2$B!W$+$iAw$i$l$F$-$?$h$&$K8+$;$+$1$^$9!#(B
<PRE>
+ ctcp/dcc/nat.plm
ctcp.dcc.nat.private: 192.168.0.0 192.168.255.255
</PRE>
$B!V(B192.168.0.0$B!W$+$i!V(B192.168.255.255$B!W$N4V$+$iAw$i$l$F$-$?(BDCC$B$r(B
$B%0%m!<%P%k$J(BIP$B%"%I%l%9$KJQ49$7$FAw?.@h$NAj<j$KAw$j$^$9!#(B
</BODY></HTML>