ing
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user