sub PORT_command {
my ($arg, $cmd) = @_;
my $port;
+ my $addr;
# We always ignore the given IP and use localhost.
return 0;
}
$port = ($5<<8)+$6;
+ $addr = "$1.$2.$3.$4";
}
# EPRT |2|::1|49706|
elsif(($cmd eq "EPRT") && ($grok_eprt)) {
}
sendcontrol "200 Thanks for dropping by. We contact you later\r\n";
$port = $3;
+ $addr = $2;
}
else {
sendcontrol "500 we don't like $cmd now\r\n";
return 1;
}
- # We fire up a new sockfilt to do the data tranfer for us.
+ # We fire up a new sockfilt to do the data transfer for us.
# FIX: make it use IPv6 if need be
- $slavepid = open2(\*DREAD, \*DWRITE,
- "./server/sockfilt --connect $port --logfile log/sockdata$ftpdnum$ext.log --pidfile .sockdata$ftpdnum$ext.pid $ipv6");
+ my $filtcmd="./server/sockfilt --connect $port --addr $addr --logfile log/sockdata$ftpdnum$ext.log --pidfile .sockdata$ftpdnum$ext.pid $ipv6";
+ $slavepid = open2(\*DREAD, \*DWRITE, $filtcmd);
+
+ print STDERR "$filtcmd\n" if($verbose);
print DWRITE "PING\n";
my $pong;
int error;
int arg=1;
enum sockmode mode = PASSIVE_LISTEN; /* default */
+ const char *addr = NULL;
while(argc>arg) {
if(!strcmp("--version", argv[arg])) {
arg++;
}
}
+ else if(!strcmp("--addr", argv[arg])) {
+ /* Set an IP address to use with --connect; otherwise use localhost */
+ arg++;
+ if(argc>arg) {
+ addr = argv[arg];
+ arg++;
+ }
+ }
else {
puts("Usage: sockfilt [option]\n"
" --version\n"
" --pidfile [file]\n"
" --ipv4\n"
" --ipv6\n"
- " --port [port]");
+ " --port [port]\n"
+ " --connect [port]\n"
+ " --addr [address]");
return 0;
}
}
me.sin_family = AF_INET;
me.sin_port = htons(connectport);
me.sin_addr.s_addr = INADDR_ANY;
- Curl_inet_pton(AF_INET, "127.0.0.1", &me.sin_addr);
+ if (!addr)
+ addr = "127.0.0.1";
+ Curl_inet_pton(AF_INET, addr, &me.sin_addr);
rc = connect(sock, (struct sockaddr *) &me, sizeof(me));
#ifdef ENABLE_IPV6
memset(&me6, 0, sizeof(me6));
me6.sin6_family = AF_INET6;
me6.sin6_port = htons(connectport);
- Curl_inet_pton(AF_INET6, "::1", &me6.sin6_addr);
+ if (!addr)
+ addr = "::1";
+ Curl_inet_pton(AF_INET6, addr, &me6.sin6_addr);
rc = connect(sock, (struct sockaddr *) &me6, sizeof(me6));
}