mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
Its only caller is ports_linux.go's ephemeralFirst, so on darwin mise run deadcode listed it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
29 lines
627 B
Go
29 lines
627 B
Go
package platform
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
// ephemeralFirst returns the first port of Linux's ephemeral range
|
|
// (net.ipv4.ip_local_port_range).
|
|
func ephemeralFirst() (int, bool) {
|
|
b, err := os.ReadFile("/proc/sys/net/ipv4/ip_local_port_range")
|
|
if err != nil {
|
|
return 0, false
|
|
}
|
|
return parsePortRangeFirst(string(b))
|
|
}
|
|
|
|
// parsePortRangeFirst reads the first field of Linux's
|
|
// ip_local_port_range ("32768\t60999").
|
|
func parsePortRangeFirst(s string) (int, bool) {
|
|
f := strings.Fields(s)
|
|
if len(f) == 0 {
|
|
return 0, false
|
|
}
|
|
n, err := strconv.Atoi(f[0])
|
|
return n, err == nil && n > 0 && n < 65536
|
|
}
|