Skip to content

Commit

Permalink
Merge pull request #21 from qualified/change-default-address
Browse files Browse the repository at this point in the history
Change the default address to 0.0.0.0
  • Loading branch information
kazk authored Jun 15, 2021
2 parents 3b45dfb + 1889da8 commit 7dd19f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Examples:
lsp-ws-proxy -l 8888 -- langserver --stdio
Options:
-l, --listen address or localhost's port to listen on (default: 9999)
-l, --listen address or port to listen on (default: 0.0.0.0:9999)
-t, --timeout inactivity timeout in seconds
-s, --sync write text document to disk on save
-r, --remap remap relative uri (source://)
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ Examples:
lsp-ws-proxy -l 8888 -- langserver --stdio
*/
struct Options {
/// address or localhost's port to listen on (default: 9999)
/// address or port to listen on (default: 0.0.0.0:9999)
#[argh(
option,
short = 'l',
default = "String::from(\"127.0.0.1:9999\")",
default = "String::from(\"0.0.0.0:9999\")",
from_str_fn(parse_listen)
)]
listen: String,
Expand Down Expand Up @@ -149,9 +149,9 @@ async fn maybe_write_text_document(msg: &lsp::Message) -> Result<(), std::io::Er
}

fn parse_listen(value: &str) -> Result<String, String> {
// If a number is given, treat it as a localhost's port number
// Allow specifying only a port number.
if value.chars().all(|c| c.is_ascii_digit()) {
return Ok(format!("127.0.0.1:{}", value));
return Ok(format!("0.0.0.0:{}", value));
}

match value.parse::<SocketAddr>() {
Expand Down

0 comments on commit 7dd19f9

Please sign in to comment.