Skip to content

Commit

Permalink
default options(servr.test.0.0.0.0 = TRUE), i.e., test the availabili…
Browse files Browse the repository at this point in the history
…ty of a port on both 127.0.0.1 and 0.0.0.0 by default
  • Loading branch information
yihui committed Nov 16, 2021
1 parent f319a7e commit 3e4da98
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: servr
Type: Package
Title: A Simple HTTP Server to Serve Static Files or Dynamic Documents
Version: 0.23.2
Version: 0.23.3
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Carson", "Sievert", role = "ctb"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CHANGES IN servr VERSION 0.24

- When searching for an available random port via `servr::random_port()` on the host `127.0.0.1`, the availability of the port is also tested on `0.0.0.0` by default. This is to avoid the situation where a port has been used on `0.0.0.0` but **httpuv** still thinks it is available on `127.0.0.1`. If you want to skip this additional testing, you may set `options(servr.test.0.0.0.0 = FALSE)`.

# CHANGES IN servr VERSION 0.23

Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ random_port = function(port = 4321L, host = getOption('servr.host', '127.0.0.1')
# when the same port is tested on 127.0.0.1, which might be a bug of httpuv;
# so we provide an option to test the availability of a port on 0.0.0.0 when
# we intend to serve a site on 127.0.0.1
test0 = host == '127.0.0.1' && getOption('servr.test.0.0.0.0', FALSE)
test0 = host == '127.0.0.1' && getOption('servr.test.0.0.0.0', TRUE)
for (p in ports) if (port_available(p, host) && (!test0 || port_available(p, '0.0.0.0'))) {
port = p
break
Expand Down

0 comments on commit 3e4da98

Please sign in to comment.