Skip to content

Commit 31f679c

Browse files
author
wintrmvte
committed
+ PortscanSingleTimeout() because any change of arguments within PortscanSingle() will break backwards compatibility
1 parent 6e3cec1 commit 31f679c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

net.go

+8
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ func PortscanSingle(target string, port int) bool {
239239
return len(opened_ports) != 0
240240
}
241241

242+
// PortscanSingleTimeout checks if a specific port is open in a given target.
243+
// Connection timeout as well as no. of threads can be adjusted
244+
func PortscanSingleTimeout(target string, port, timeout, threads int) bool {
245+
ps := portscanner.NewPortScanner(target, time.Duration(timeout)*time.Second, threads)
246+
opened_ports := ps.GetOpenedPort(port-1, port+1)
247+
return len(opened_ports) != 0
248+
}
249+
242250
// Returns true if host is alive
243251
func Ping(target string) bool {
244252
open_counter := 0

0 commit comments

Comments
 (0)