Browse Source

Do not attempt to serve on "well-known" ports (#824)

index-subcmd
Jochen Kupperschmidt Vincent Prouillet 5 years ago
parent
commit
b3bc8a8896
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      components/utils/src/net.rs

+ 3
- 1
components/utils/src/net.rs View File

@@ -1,7 +1,9 @@
use std::net::TcpListener;

pub fn get_available_port(avoid: u16) -> Option<u16> {
(1000..9000).find(|port| *port != avoid && port_is_available(*port))
// Start after "well-known" ports (0–1023) as they require superuser
// privileges on UNIX-like operating systems.
(1024..9000).find(|port| *port != avoid && port_is_available(*port))
}

pub fn port_is_available(port: u16) -> bool {


Loading…
Cancel
Save