实现Ping和TCP端口扫描功能

This commit is contained in:
2026-07-17 19:00:47 +08:00
parent 4a2086c6f1
commit c858e8e311
6 changed files with 516 additions and 23 deletions
+17
View File
@@ -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
}