Title: | Get the Same, Personal, Free 'TCP' Port over and over |
---|---|
Description: | An R implementation of the cross-platform, language-independent "port4me" algorithm (<https://github.com/HenrikBengtsson/port4me>), which (1) finds a free Transmission Control Protocol ('TCP') port in [1024,65535] that the user can open, (2) is designed to work in multi-user environments, (3), gives different users, different ports, (4) gives the user the same port over time with high probability, (5) gives different ports for different software tools, and (6) requires no configuration. |
Authors: | Henrik Bengtsson [aut, cre, cph] , Jeroen Ooms [ctb] (C code for testing availability of TCP ports, <https://orcid.org/0000-0002-4035-0289>) |
Maintainer: | Henrik Bengtsson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.7.1 |
Built: | 2024-10-31 22:08:49 UTC |
Source: | https://github.com/HenrikBengtsson/port4me |
Gets a Personalized TCP Port that can be Opened by the User
port4me( tool = NULL, user = NULL, prepend = NULL, include = NULL, exclude = NULL, skip = NULL, list = NULL, test = NULL, max_tries = 65535L, must_work = TRUE )
port4me( tool = NULL, user = NULL, prepend = NULL, include = NULL, exclude = NULL, skip = NULL, list = NULL, test = NULL, max_tries = 65535L, must_work = TRUE )
tool |
(optional) The name of the software tool for which a port should be generated. |
user |
(optional) The name of the user.
Defaults to |
prepend |
(optional) An integer vector of ports to always consider. |
include |
(optional) An integer vector of possible ports to return.
Defaults to |
exclude |
(optional) An integer vector of ports to exclude. |
skip |
(optional) Number of non-excluded ports to skip.
Defaults to |
list |
(optional) Number of ports to list. |
test |
(optional) A port to check whether it can be opened or not. |
max_tries |
Maximum number of ports checked, before giving up.
Defaults to |
must_work |
If TRUE, then an error is produced if no port could
be found. If FALSE, then |
A port, or a vector of ports.
If test
is given, then TRUE is if the port can be opened, otherwise FALSE.
The default values of the arguments can be controlled via environment variables. See port4me.settings for details.
port <- port4me() print(port) port <- port4me(tool = "rstudio") print(port) port <- port4me("rstudio") ## short for the above print(port) ports <- port4me(tool = "rstudio", list = 5L) print(ports) avail <- port4me(test = 4321) print(avail)
port <- port4me() print(port) port <- port4me(tool = "rstudio") print(port) port <- port4me("rstudio") ## short for the above print(port) ports <- port4me(tool = "rstudio", list = 5L) print(ports) avail <- port4me(test = 4321) print(avail)
Below are the environment variables that are used by the port4me
package and packages enhancing it.
WARNING: Note that the names and the default values of these settings
may change in future versions of the package. Please use with care
until further notice.
PORT4ME_EXCLUDE
:Controls the default value for argument exclude
of port4me()
.
Ports and port sequences should be separated by commas.
Port sequences should be specified as a start and end port separated
by a hyphen.
Example: PORT4ME_EXCLUDE=4444,5000-5999,8080
.
(Default: empty)
PORT4ME_INCLUDE
:Controls the default value for argument include
of port4me()
.
The format should be the same as for PORT4ME_INCLUDE
.
(Default: empty)
PORT4ME_PREPEND
:Controls the default value for argument prepend
of port4me()
.
The format should be the same as for PORT4ME_INCLUDE
.
(Default: empty)
PORT4ME_SKIP
:Controls the default value for argument skip
of port4me()
.
(Default: 0
)
PORT4ME_TOOL
:Controls the default value for argument tool
of port4me()
.
(Default: empty)
PORT4ME_USER
:Controls the default value for argument user
of port4me()
.
(Default: Sys.info()[["user"]])
)
PORT4ME_EXCLUDE_SITE
, PORT4ME_INCLUDE_SITE
,
PORT4ME_PREPEND_SITE
:Additional sets of ports to be excluded, included, and prepended. These are typically set for all users ("site wide") by a systems administrator or similar. (Default: empty)
PORT4ME_EXCLUDE_UNSAFE
:Additional sets of ports to be excluded that are considered unsafe
to open in a web browser.
Special token "{chrome}"
expands to the value of environment
variable PORT4ME_EXCLUDE_UNSAFE_CHROME
.
Special token "{firefox}"
expands to the value of environment
variable PORT4ME_EXCLUDE_UNSAFE_FIREFOX
.
The default is to exclude the ports that Chrome and Firefox blocks.
(Default: "{chrome},{firefox}"
)
PORT4ME_EXCLUDE_UNSAFE_CHROME
:The set of ports that the Chrome web browser considers unsafe and therefore blocks. (Default: ports blocked by Chrome)
PORT4ME_EXCLUDE_UNSAFE_FIREFOX
:The set of ports that the Firefox web browser considers unsafe and therefore blocks. (Default: ports blocked by Firefox)
PORT4ME_DEBUG
:If true
, extensive debug messages are generated.
(Default: false
)
Environment variables can be configured for R, by setting them in
your personal ~/.Renviron
file, e.g.
PORT4ME_EXCLUDE=4848,8080
For more information, see the Startup help page.
Sys.setenv(PORT4ME_EXCLUDE = "4444,5000-5999,8080") port4me()
Sys.setenv(PORT4ME_EXCLUDE = "4444,5000-5999,8080") port4me()