[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 227/264: tests: run the SOCKS test server on a dynamic port numb
From: |
gnunet |
Subject: |
[gnurl] 227/264: tests: run the SOCKS test server on a dynamic port number |
Date: |
Thu, 30 Apr 2020 16:08:50 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit bcd9813588e971212f139d614a77215f1602e066
Author: Daniel Stenberg <address@hidden>
AuthorDate: Sun Apr 19 23:45:15 2020 +0200
tests: run the SOCKS test server on a dynamic port number
Closes #5266
---
tests/runtests.pl | 13 +++++++------
tests/server/socksd.c | 20 ++++++++++++++------
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 9857076fb..cd22cd3f7 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -2277,7 +2277,6 @@ sub runmqttserver {
sub runsocksserver {
my ($id, $verbose, $ipv6) = @_;
my $ip=$HOSTIP;
- my $port = $SOCKSPORT;
my $proto = 'socks';
my $ipvnum = 4;
my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1;
@@ -2290,6 +2289,7 @@ sub runsocksserver {
$server = servername_id($proto, $ipvnum, $idnum);
$pidfile = $serverpidfile{$server};
+ my $portfile = $serverportfile{$server};
# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
@@ -2308,8 +2308,9 @@ sub runsocksserver {
# start our socks server, get commands from the FTP cmd file
my $cmd="server/socksd".exe_ext('SRV').
- " --port $port ".
+ " --port 0 ".
" --pidfile $pidfile".
+ " --portfile $portfile".
" --backend $HOSTIP".
" --config $FTPDCMD";
my ($sockspid, $pid2) = startnew($cmd, $pidfile, 30, 0);
@@ -2322,11 +2323,13 @@ sub runsocksserver {
return (0,0);
}
+ my $port = pidfromfile($portfile);
+
if($verbose) {
logmsg "RUN: $srvrname server is now running PID $pid2\n";
}
- return ($pid2, $sockspid);
+ return ($pid2, $sockspid, $port);
}
#######################################################################
@@ -3159,7 +3162,6 @@ sub checksystem {
logmsg sprintf("RTSP-IPv6/%d ", $RTSP6PORT);
}
logmsg sprintf("\n* SSH/%d ", $SSHPORT);
- logmsg sprintf("SOCKS/%d ", $SOCKSPORT);
if($httptlssrv) {
logmsg sprintf("HTTPTLS/%d ", $HTTPTLSPORT);
if($has_ipv6) {
@@ -4883,7 +4885,7 @@ sub startservers {
}
elsif($what eq "socks4" || $what eq "socks5" ) {
if(!$run{'socks'}) {
- ($pid, $pid2) = runsocksserver("", $verbose);
+ ($pid, $pid2, $SOCKSPORT) = runsocksserver("", $verbose);
if($pid <= 0) {
return "failed starting socks server";
}
@@ -5442,7 +5444,6 @@ $minport = $base; # original base port number
$HTTPSPORT = $base++; # HTTPS (stunnel) server port
$FTPSPORT = $base++; # FTPS (stunnel) server port
$SSHPORT = $base++; # SSH (SCP/SFTP) port
-$SOCKSPORT = $base++; # SOCKS port
$RTSPPORT = $base++; # RTSP server port
$RTSP6PORT = $base++; # RTSP IPv6 server port
$HTTPTLSPORT = $base++; # HTTP TLS (non-stunnel) server port
diff --git a/tests/server/socksd.c b/tests/server/socksd.c
index 813eca665..e6e9c12b0 100644
--- a/tests/server/socksd.c
+++ b/tests/server/socksd.c
@@ -883,6 +883,7 @@ int main(int argc, char *argv[])
curl_socket_t msgsock = CURL_SOCKET_BAD;
int wrotepidfile = 0;
const char *pidname = ".socksd.pid";
+ const char *portfile = NULL;
bool juggle_again;
int error;
int arg = 1;
@@ -903,6 +904,11 @@ int main(int argc, char *argv[])
if(argc>arg)
pidname = argv[arg++];
}
+ else if(!strcmp("--portfile", argv[arg])) {
+ arg++;
+ if(argc>arg)
+ portfile = argv[arg++];
+ }
else if(!strcmp("--config", argv[arg])) {
arg++;
if(argc>arg)
@@ -943,12 +949,6 @@ int main(int argc, char *argv[])
if(argc>arg) {
char *endptr;
unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- if((endptr != argv[arg] + strlen(argv[arg])) ||
- ((ulnum != 0UL) && ((ulnum < 1025UL) || (ulnum > 65535UL)))) {
- fprintf(stderr, "socksd: invalid --port argument (%s)\n",
- argv[arg]);
- return 0;
- }
port = curlx_ultous(ulnum);
arg++;
}
@@ -961,6 +961,7 @@ int main(int argc, char *argv[])
" --version\n"
" --logfile [file]\n"
" --pidfile [file]\n"
+ " --portfile [file]\n"
" --ipv4\n"
" --ipv6\n"
" --bindonly\n"
@@ -1013,6 +1014,13 @@ int main(int argc, char *argv[])
goto socks5_cleanup;
}
+ if(portfile) {
+ wrotepidfile = write_portfile(portfile, port);
+ if(!wrotepidfile) {
+ goto socks5_cleanup;
+ }
+ }
+
do {
juggle_again = incoming(sock);
} while(juggle_again);
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 98/264: SECURITY.md: minor rephrase, (continued)
- [gnurl] 98/264: SECURITY.md: minor rephrase, gnunet, 2020/04/30
- [gnurl] 125/264: appveyor: turn disabled tests into ignored result tests, gnunet, 2020/04/30
- [gnurl] 130/264: lib: never define CURL_CA_BUNDLE with a getenv, gnunet, 2020/04/30
- [gnurl] 127/264: appveyor: sort builds by type and add two new variants, gnunet, 2020/04/30
- [gnurl] 134/264: RELEASE-NOTES: synced, gnunet, 2020/04/30
- [gnurl] 103/264: memdebug: don't log free(NULL), gnunet, 2020/04/30
- [gnurl] 138/264: cleanup: correct copyright year range on a few files, gnunet, 2020/04/30
- [gnurl] 131/264: TODO: Option to make -Z merge lined based outputs on stdout, gnunet, 2020/04/30
- [gnurl] 104/264: build: fixed build for systems with select() in unistd.h, gnunet, 2020/04/30
- [gnurl] 226/264: multi-ssl: reset the SSL backend on `Curl_global_cleanup()`, gnunet, 2020/04/30
- [gnurl] 227/264: tests: run the SOCKS test server on a dynamic port number,
gnunet <=
- [gnurl] 223/264: runtests: always put test number in servercmd file, gnunet, 2020/04/30
- [gnurl] 205/264: tests: make 2006-2010 handle different port number lengths, gnunet, 2020/04/30
- [gnurl] 235/264: mqtt: make NOSTATE get within the debug name array, gnunet, 2020/04/30
- [gnurl] 233/264: tests: add %NOLISTENPORT and use it, gnunet, 2020/04/30
- [gnurl] 234/264: tests: run the RTSP test server on a dynamic port number, gnunet, 2020/04/30
- [gnurl] 232/264: mqtt: remove code with no purpose, gnunet, 2020/04/30
- [gnurl] 231/264: mqtt: fix Curl_read() error handling while reading remaining length, gnunet, 2020/04/30
- [gnurl] 247/264: tests/git: ignore mqttd and port files, gnunet, 2020/04/30
- [gnurl] 248/264: docs: fix two typos, gnunet, 2020/04/30
- [gnurl] 240/264: version: skip idn2_check_version() check and add precaution, gnunet, 2020/04/30