zan8in / masscan

Masscan is a golang library to run masscan scans, parse scan results.
Apache License 2.0
92 stars 26 forks source link

Why keep structs weirdly? #12

Open rew1nter opened 11 months ago

rew1nter commented 11 months ago

Why do you have ports listed in the masscanresult when you already have it in hosts? :/


    MasscanResult struct {
        Hosts []Hosts `json:"hosts"`
        Ports []Ports `json:"ports"`
    }

    // Hosts  masscan hosts output struct
    Hosts struct {
        IP        string  `json:"ip"`
        Ports     []Ports `json:"ports"`
        Timestamp string  `json:"timestamp"`
    }

    // Ports  masscan ports output struct
    Ports struct {
        Port   int    `json:"port"`
        Proto  string `json:"proto"`
        Status string `json:"status"`
        Reason string `json:"reason"`
        TTL    int    `json:"ttl"`
    }

)

why not just do this?


    MasscanResult struct {
        Hosts []Hosts `json:"hosts"`
    }

    // Hosts  masscan hosts output struct
    Hosts struct {
        IP        string  `json:"ip"`
        Ports     []Ports `json:"ports"`
        Timestamp string  `json:"timestamp"`
    }

    // Ports  masscan ports output struct
    Ports struct {
        Port   int    `json:"port"`
        Proto  string `json:"proto"`
        Status string `json:"status"`
        Reason string `json:"reason"`
        TTL    int    `json:"ttl"`
    }
zan8in commented 11 months ago

Sorry, the code is a bit old, your suggestion is better👏