实现Ping和TCP端口扫描功能
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TCPProbe(ip string, port int, timeout time.Duration) bool {
|
||||
addr := net.JoinHostPort(ip, strconv.Itoa(port))
|
||||
conn, err := net.DialTimeout("tcp", addr, timeout)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
conn.Close()
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user