gosh/interceptor/net.go

18 lines
276 B
Go

package interceptor
import (
"fmt"
"net"
)
type NetModule struct{}
func (n *NetModule) IsPortOpen(host string, port int) bool {
conn, err := net.Dial("tcp", net.JoinHostPort(host, fmt.Sprintf("%d", port)))
if err != nil {
return false
}
conn.Close()
return true
}