netscan icon indicating copy to clipboard operation
netscan copied to clipboard

Returned Address Sets always contains ip *.*.*.255

Open gonzochic opened this issue 6 years ago • 2 comments

Hi, if you run Scan() the result will always contain the number of open ips on the specific port but always the same IP (e.g. 10.0.1.255 or 192.168.1.255).

This is caused because you dereference a variable inside a GO Routine which was referenced inside a Range Loop.

func (s *Scanner) Scan() []AddressSet {
	...
         // here you get a reference to the specific id
	for _, ip := range s.ips {

and then

                                                
                                                 // here you use the referenced IP which is at this time the last item of the range loop
						results = append(results, AddressSet{
							IP:       copyIP(ip),
							Port:     port,
							Protocol: proto,
						})
					

To fix that, you need to copy the id first into a variable and pass it into the go routine (as you did with address).

gonzochic avatar Feb 03 '19 09:02 gonzochic

The current Scan() is unusable right now. I was thinking that something was wrong on my network. Thanks for the PR!

gabstv avatar May 10 '19 18:05 gabstv

@jessfraz can you merge #7. Afterwards we can close.

gonzochic avatar May 21 '19 07:05 gonzochic