mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Add http-address flag to VC (#2467)
## Issue Addressed #2454 ## Proposed Changes Adds the `--http-address` flag to allow the user to use custom HTTP addresses. This can be helpful for certain Docker setups. Since using custom HTTP addresses is unsafe due to the server being unencrypted, `--unencrypted-http-transport` was also added as a safety flag and must be used in tandem with `--http-address`. This is to ensure the user is aware of the risks associated with using non-local HTTP addresses.
This commit is contained in:
@@ -125,23 +125,36 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.takes_value(false),
|
||||
)
|
||||
/*
|
||||
* Note: there is purposefully no `--http-address` flag provided.
|
||||
* Note: The HTTP server is **not** encrypted (i.e., not HTTPS) and therefore it is
|
||||
* unsafe to publish on a public network.
|
||||
*
|
||||
* The HTTP server is **not** encrypted (i.e., not HTTPS) and therefore it is unsafe to
|
||||
* publish on a public network.
|
||||
*
|
||||
* We restrict the user to `127.0.0.1` and they must provide some other transport-layer
|
||||
* encryption (e.g., SSH tunnels).
|
||||
* If the `--http-address` flag is used, the `--unencrypted-http-transport` flag
|
||||
* must also be used in order to make it clear to the user that this is unsafe.
|
||||
*/
|
||||
.arg(
|
||||
Arg::with_name("http-address")
|
||||
.long("http-address")
|
||||
.value_name("ADDRESS")
|
||||
.help("Set the address for the HTTP address. The HTTP server is not encrypted \
|
||||
and therefore it is unsafe to publish on a public network. When this \
|
||||
flag is used, it additionally requires the explicit use of the \
|
||||
`--unencrypted-http-transport` flag to ensure the user is aware of the \
|
||||
risks involved. For access via the Internet, users should apply \
|
||||
transport-layer security like a HTTPS reverse-proxy or SSH tunnelling.")
|
||||
.requires("unencrypted-http-transport"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("unencrypted-http-transport")
|
||||
.long("unencrypted-http-transport")
|
||||
.help("This is a safety flag to ensure that the user is aware that the http \
|
||||
transport is unencrypted and using a custom HTTP address is unsafe.")
|
||||
.requires("http-address"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("http-port")
|
||||
.long("http-port")
|
||||
.value_name("PORT")
|
||||
.help("Set the listen TCP port for the RESTful HTTP API server. This server does **not** \
|
||||
provide encryption and is completely unsuitable to expose to a public network. \
|
||||
We do not provide a --http-address flag and restrict the user to listening on \
|
||||
127.0.0.1. For access via the Internet, apply a transport-layer security like \
|
||||
a HTTPS reverse-proxy or SSH tunnelling.")
|
||||
.help("Set the listen TCP port for the RESTful HTTP API server.")
|
||||
.default_value("5062")
|
||||
.takes_value(true),
|
||||
)
|
||||
|
||||
@@ -197,6 +197,19 @@ impl Config {
|
||||
config.http_api.enabled = true;
|
||||
}
|
||||
|
||||
if let Some(address) = cli_args.value_of("http-address") {
|
||||
if cli_args.is_present("unencrypted-http-transport") {
|
||||
config.http_api.listen_addr = address
|
||||
.parse::<Ipv4Addr>()
|
||||
.map_err(|_| "http-address is not a valid IPv4 address.")?;
|
||||
} else {
|
||||
return Err(
|
||||
"While using `--http-address`, you must also use `--unencrypted-http-transport`."
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(port) = cli_args.value_of("http-port") {
|
||||
config.http_api.listen_port = port
|
||||
.parse::<u16>()
|
||||
|
||||
Reference in New Issue
Block a user