aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/ftpserver.pl11
-rw-r--r--tests/server/sockfilt.c21
2 files changed, 26 insertions, 6 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index e32c019bd..a5b474f5c 100644
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -623,6 +623,7 @@ sub PASV_command {
sub PORT_command {
my ($arg, $cmd) = @_;
my $port;
+ my $addr;
# We always ignore the given IP and use localhost.
@@ -633,6 +634,7 @@ sub PORT_command {
return 0;
}
$port = ($5<<8)+$6;
+ $addr = "$1.$2.$3.$4";
}
# EPRT |2|::1|49706|
elsif(($cmd eq "EPRT") && ($grok_eprt)) {
@@ -642,6 +644,7 @@ sub PORT_command {
}
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";
@@ -653,10 +656,12 @@ sub PORT_command {
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;
diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c
index b4e1c07f0..2cca0b37b 100644
--- a/tests/server/sockfilt.c
+++ b/tests/server/sockfilt.c
@@ -522,6 +522,7 @@ int main(int argc, char *argv[])
int error;
int arg=1;
enum sockmode mode = PASSIVE_LISTEN; /* default */
+ const char *addr = NULL;
while(argc>arg) {
if(!strcmp("--version", argv[arg])) {
@@ -571,6 +572,14 @@ int main(int argc, char *argv[])
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"
@@ -578,7 +587,9 @@ int main(int argc, char *argv[])
" --pidfile [file]\n"
" --ipv4\n"
" --ipv6\n"
- " --port [port]");
+ " --port [port]\n"
+ " --connect [port]\n"
+ " --addr [address]");
return 0;
}
}
@@ -615,7 +626,9 @@ int main(int argc, char *argv[])
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
@@ -624,7 +637,9 @@ int main(int argc, char *argv[])
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));
}