Skip to content

Commit

Permalink
closes #18
Browse files Browse the repository at this point in the history
  • Loading branch information
leesoh committed May 2, 2022
1 parent 76f0676 commit ac34f05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
3 changes: 3 additions & 0 deletions internal/result/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func (r *Result) hostPrinter(h *Host) {
}

func (r *Result) portPrinter(h *Host) {
if h.allPortsClosed() {
return
}
writer := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
fmt.Fprintln(writer, "PORT\tSERVICE\tPRODUCT\tVERSION")
for k, v := range h.TCPPorts {
Expand Down
19 changes: 3 additions & 16 deletions internal/result/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,19 @@ func (h *Host) addOrUpdatePort(k int, p *Port, proto string) {
return
}
h.TCPPorts[k].Update(p)
//h.mergePorts(k, p)
}
if proto == "udp" {
if _, hasPort := h.UDPPorts[k]; !hasPort {
h.UDPPorts[k] = p
return
}
h.UDPPorts[k].Update(p)
//h.mergePorts(k, p)
}
}

//func (h *Host) mergePorts(k int, p *Port) {
// if h.TCPPorts[k].Name == "" && p.Name != "" {
// h.TCPPorts[k].Name = p.Name
// }
// if h.TCPPorts[k].Product == "" && p.Product != "" {
// h.TCPPorts[k].Product = p.Product
// }
// if h.TCPPorts[k].Version == "" && p.Version != "" {
// h.TCPPorts[k].Version = p.Version
// }
// if h.TCPPorts[k].ExtraInfo == "" && p.ExtraInfo != "" {
// h.TCPPorts[k].ExtraInfo = p.ExtraInfo
// }
//}
func (h *Host) allPortsClosed() bool {
return len(h.TCPPorts) == 0 && len(h.UDPPorts) == 0
}

func (h *Host) GetName() string {
if h.Name != "" {
Expand Down

0 comments on commit ac34f05

Please sign in to comment.