test
This commit is contained in:
parent
508fac7b8a
commit
9ad03d5303
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -47,7 +47,7 @@
|
|||
"socket/web",
|
||||
"socket/web/client"
|
||||
]
|
||||
revision = "20a63b3de6efdc0942bfb4be21ddc64e2b76f59d"
|
||||
revision = "cbe8e30db48a21b33650c5ed7e7d8bbf4784c9d4"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -111,7 +111,7 @@
|
|||
"model/sensorconfig",
|
||||
"service/probe"
|
||||
]
|
||||
revision = "7e2ff26648aefbafaee2ca28c1a958332ae4c6f9"
|
||||
revision = "54725b74e13a501d7a13a76a82c294769729748d"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
|
|
@ -5,47 +5,44 @@ import (
|
|||
"encoding/base64"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
type SocketHeahthCrawler struct {
|
||||
type SocketHealthCrawler struct {
|
||||
crawler.Crawler
|
||||
m cnsm.Matcher
|
||||
}
|
||||
|
||||
func (s *SocketHeahthCrawler) SetMatcher(m cnsm.Matcher) {
|
||||
func (s *SocketHealthCrawler) SetMatcher(m cnsm.Matcher) {
|
||||
s.m = m
|
||||
}
|
||||
|
||||
func (s *SocketHeahthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Conn, error) {
|
||||
connection := config.Target.Connection
|
||||
|
||||
metaIPType := connection.MetaIPType
|
||||
func (s *SocketHealthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Conn, error) {
|
||||
connection := config.Connection
|
||||
metaIPTypeKey := connection.MetaIPTypeKey
|
||||
ip := connection.IP
|
||||
port := connection.Port
|
||||
metaPortType := connection.MetaPortType
|
||||
metaCryptoType := connection.MetaCryptoType
|
||||
metaPortTypeKey := connection.MetaPortTypeKey
|
||||
metaCryptoTypeKey := connection.MetaCryptoTypeKey
|
||||
|
||||
addr := fmt.Sprintf("%s:%s", ip, port)
|
||||
|
||||
network := ""
|
||||
switch ocmm.ToMetaIPTypeEnum(metaIPType) {
|
||||
case ocmm.MetaIPTypeEnumV6:
|
||||
switch ocmm.ToMetaPortTypeEnum(metaPortType) {
|
||||
case ocmm.MetaPortTypeEnumUDP:
|
||||
switch metaIPTypeKey {
|
||||
case "V6":
|
||||
switch metaPortTypeKey {
|
||||
case "UDP":
|
||||
network = "udp6"
|
||||
default:
|
||||
network = "tcp6"
|
||||
}
|
||||
default:
|
||||
switch ocmm.ToMetaPortTypeEnum(metaPortType) {
|
||||
case ocmm.MetaPortTypeEnumUDP:
|
||||
switch metaPortTypeKey {
|
||||
case "UDP":
|
||||
network = "udp"
|
||||
default:
|
||||
network = "tcp"
|
||||
|
@ -57,7 +54,7 @@ func (s *SocketHeahthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Con
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if ocmm.ToMetaCryptoTypeEnum(metaCryptoType) == ocmm.MetaCryptoTypeEnumTLS {
|
||||
if metaCryptoTypeKey == "TLS" {
|
||||
cfg := &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
ServerName: ip,
|
||||
|
@ -74,11 +71,9 @@ func (s *SocketHeahthCrawler) getConnection(config *ocmsc.SensorConfig) (net.Con
|
|||
return conn, nil
|
||||
}
|
||||
|
||||
func (s *SocketHeahthCrawler) CheckHeahth(config *ocmsc.SensorConfig) (result map[string]string, err error) {
|
||||
func (s *SocketHealthCrawler) CheckHealth(config *ocmsc.SensorConfig) (result map[string]string, err error) {
|
||||
result = make(map[string]string, 0)
|
||||
|
||||
result["StartTime"] = time.Now().String()
|
||||
|
||||
conn, cErr := s.getConnection(config)
|
||||
if cErr != nil {
|
||||
result["Error"] = cErr.Error()
|
||||
|
@ -87,7 +82,7 @@ func (s *SocketHeahthCrawler) CheckHeahth(config *ocmsc.SensorConfig) (result ma
|
|||
}
|
||||
defer conn.Close()
|
||||
|
||||
connection := config.Target.Connection
|
||||
connection := config.Connection
|
||||
port, _ := cuej.NumberToInt(connection.Port)
|
||||
info := cnsm.NewMatchInfo(connection.IP, port)
|
||||
|
||||
|
@ -143,8 +138,6 @@ func (s *SocketHeahthCrawler) CheckHeahth(config *ocmsc.SensorConfig) (result ma
|
|||
}
|
||||
}
|
||||
|
||||
result["EndTime"] = time.Now().String()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type ActiveDirectoryHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *ActiveDirectoryHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *ActiveDirectoryHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *ActiveDirectoryHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type CassandraHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *CassandraHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *CassandraHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *CassandraHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type DNSHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *DNSHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *DNSHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *DNSHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type FTPHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *FTPHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *FTPHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *FTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type HTTPHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *HTTPHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *HTTPHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *HTTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type IMAPHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *IMAPHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *IMAPHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *IMAPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type LDAPHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *LDAPHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *LDAPHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *LDAPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type MongoDBHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *MongoDBHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *MongoDBHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *MongoDBHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type MySQLHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *MySQLHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *MySQLHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *MySQLHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type NetBIOSHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *NetBIOSHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *NetBIOSHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *NetBIOSHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type OracleHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *OracleHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *OracleHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *OracleHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type POPHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *POPHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *POPHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *POPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type PostgreSQLHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *PostgreSQLHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *PostgreSQLHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *PostgreSQLHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type RedisHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *RedisHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *RedisHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *RedisHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type RMIHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *RMIHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *RMIHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *RMIHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type SMBHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *SMBHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *SMBHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *SMBHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type SMTPHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *SMTPHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *SMTPHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *SMTPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type SNMPHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *SNMPHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *SNMPHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *SNMPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type SNMPHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *SNMPHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *SNMPHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *SNMPHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type SQLServerHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *SQLServerHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *SQLServerHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *SQLServerHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type SSHHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *SSHHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *SSHHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *SSHHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type TelnetHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *TelnetHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *TelnetHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *TelnetHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type WMIHealthCrawler struct {
|
||||
health.SocketHeahthCrawler
|
||||
health.SocketHealthCrawler
|
||||
}
|
||||
|
||||
func (c *WMIHealthCrawler) Key() string {
|
||||
|
@ -24,7 +24,7 @@ func (c *WMIHealthCrawler) Auth(auth map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func (c *WMIHealthCrawler) Get(config *ocmsc.SensorConfig) (map[string]string, error) {
|
||||
rss, err := c.CheckHeahth(config)
|
||||
rss, err := c.CheckHealth(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user