overflow_discovery/discovery/ipv4/service.go
crusader 40f2ebad23 ing
2017-11-22 19:04:04 +09:00

39 lines
1.0 KiB
Go

package ipv4
import (
"fmt"
"git.loafle.net/overflow/overflow_discovery/api/module/discovery/model"
"github.com/google/gopacket/layers"
)
func ScanService(port *model.Port, ds *model.DiscoveryService, resultChan chan interface{}, errChan chan error, stopChan chan struct{}) {
switch port.PortType {
case model.PortTypeTCP:
if !scanServiceTCP(port, ds, resultChan, errChan, stopChan) {
if dName, ok := layers.TCPPortNames[layers.TCPPort(port.PortNumber)]; ok {
sName := fmt.Sprintf("Not Supported Service. Perhaps %s[%d]", dName, port.PortNumber)
s := &model.Service{
ServiceName: sName,
}
s.Port = port
resultChan <- s
}
}
case model.PortTypeUDP:
if !scanServiceUDP(port, ds, resultChan, errChan, stopChan) {
if dName, ok := layers.UDPPortNames[layers.UDPPort(port.PortNumber)]; ok {
sName := fmt.Sprintf("Not Supported Service. Perhaps %s[%d]", dName, port.PortNumber)
s := &model.Service{
ServiceName: sName,
}
s.Port = port
resultChan <- s
}
}
}
}