Co-authored-by: boxjan <i@boxjan.li>
This commit is contained in:
parent
98288bc3ca
commit
af745bd97d
1 changed files with 4 additions and 4 deletions
|
@ -29,12 +29,12 @@ func IsIPV6(ip _net.IP) bool {
|
||||||
|
|
||||||
// IsPortAvailable checks if a TCP port is available or not
|
// IsPortAvailable checks if a TCP port is available or not
|
||||||
func IsPortAvailable(p int) bool {
|
func IsPortAvailable(p int) bool {
|
||||||
conn, err := _net.Dial("tcp", fmt.Sprintf(":%v", p))
|
ln, err := _net.Listen("tcp", fmt.Sprintf(":%v", p))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer ln.Close()
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsIPv6Enabled checks if IPV6 is enabled or not and we have
|
// IsIPv6Enabled checks if IPV6 is enabled or not and we have
|
||||||
|
|
Loading…
Reference in a new issue