commons-go/model/discovery/DiscoverPort.go

29 lines
619 B
Go
Raw Normal View History

2018-04-26 07:37:59 +00:00
package discovery
2018-04-12 09:38:04 +00:00
2018-04-27 16:02:30 +00:00
type DiscoverPort struct {
2018-04-12 09:38:04 +00:00
FirstScanRange int `json:"firstScanRange,omitempty"`
LastScanRange int `json:"lastScanRange,omitempty"`
ExcludePorts []int `json:"excludePorts,omitempty"`
IncludeTCP bool `json:"includeTCP,omitempty"`
IncludeUDP bool `json:"includeUDP,omitempty"`
2018-04-27 16:02:30 +00:00
DiscoverService *DiscoverService `json:"discoverService,omitempty"`
2018-04-12 09:38:04 +00:00
}
2018-04-27 16:02:30 +00:00
func (dp *DiscoverPort) Contains(port int) bool {
2018-04-12 09:38:04 +00:00
if dp.FirstScanRange > port {
return false
}
if dp.LastScanRange < port {
return false
}
for _, p := range dp.ExcludePorts {
if p == port {
return false
}
}
return true
}