File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -37,19 +37,16 @@ type Scanner struct {
3737}
3838
3939func (s * Scanner ) Run () {
40+ str := s .addr
4041 addr := net .ParseIP (s .addr )
41- if addr == nil {
42- fmt .Println ("Invalid address format" )
43- return
44- }
45- str := addr .String ()
46- if addr .To4 () == nil {
47- str = "[" + str + "]"
42+ if addr != nil && addr .To4 () == nil {
43+ str = "[" + addr .String () + "]"
4844 }
4945 conn , err := net .DialTimeout ("tcp" , str + ":" + s .port , s .timeout )
5046 if err != nil {
5147 fmt .Println ("Dial failed: " , err )
5248 } else {
49+ addr = conn .RemoteAddr ().(* net.TCPAddr ).IP
5350 line := "" + conn .RemoteAddr ().String () + " \t "
5451 conn .SetDeadline (time .Now ().Add (s .timeout ))
5552 c := tls .Client (conn , & tls.Config {
@@ -70,6 +67,10 @@ func (s *Scanner) Run() {
7067 }
7168 }
7269
70+ if addr == nil {
71+ fmt .Println ("Invalid address format" )
72+ return
73+ }
7374 s .mu .Lock ()
7475 s .high = addr
7576 s .low = addr
You can’t perform that action at this time.
0 commit comments