Skip to content

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

@gonzochic

Description

@gonzochic

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions