This commit is contained in:
crusader
2018-06-13 20:22:23 +09:00
parent 163a6a92d2
commit 6b10353dd0
2 changed files with 33 additions and 13 deletions

View File

@@ -9,6 +9,7 @@ import (
cnsm "git.loafle.net/commons/service_matcher-go"
cuej "git.loafle.net/commons/util-go/encoding/json"
ocmm "git.loafle.net/overflow/commons-go/model/meta"
ocmsc "git.loafle.net/overflow/commons-go/model/sensorconfig"
"git.loafle.net/overflow/crawler-go"
)
@@ -25,19 +26,38 @@ func (s *SocketHeahthCrawler) SetMatcher(m cnsm.Matcher) {
func (s *SocketHeahthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Conn, error) {
connection := config.Target.Connection
metaIPType := connection.MetaIPType
ip := connection.IP
port := connection.Port
portType := connection.PortType
ssl := connection.SSL
metaPortType := connection.MetaPortType
metaCryptoType := connection.MetaCryptoType
addr := fmt.Sprintf("%s:%s", ip, port)
conn, err := net.Dial(portType.String(), addr)
network := ""
switch ocmm.ToMetaIPTypeEnum(metaIPType) {
case ocmm.MetaIPTypeEnumV6:
switch ocmm.ToMetaPortTypeEnum(metaPortType) {
case ocmm.MetaPortTypeEnumUDP:
network = "udp6"
default:
network = "tcp6"
}
default:
switch ocmm.ToMetaPortTypeEnum(metaPortType) {
case ocmm.MetaPortTypeEnumUDP:
network = "udp"
default:
network = "tcp"
}
}
conn, err := net.Dial(network, addr)
if err != nil {
return nil, err
}
if ssl {
if ocmm.ToMetaCryptoTypeEnum(metaCryptoType) == ocmm.MetaCryptoTypeEnumTLS {
cfg := &tls.Config{
InsecureSkipVerify: true,
ServerName: ip,