diff --git a/crawler/impl/health/SocketHeahthCrawler.go b/crawler/impl/health/SocketHeahthCrawler.go index 399bbd9..7ea62d1 100644 --- a/crawler/impl/health/SocketHeahthCrawler.go +++ b/crawler/impl/health/SocketHeahthCrawler.go @@ -22,7 +22,6 @@ func (s *SocketHeahthCrawler) SetMatcher(m cnsm.Matcher) { } func (s *SocketHeahthCrawler) getConnection(config *configM.Config) (net.Conn, error) { - connection := config.Target.Connection ip := connection.IP @@ -32,27 +31,26 @@ func (s *SocketHeahthCrawler) getConnection(config *configM.Config) (net.Conn, e addr := fmt.Sprintf("%s:%s", ip, port) - if ssl == false { - conn, err := net.Dial(portType, addr) - if err != nil { - return nil, err - } - return conn, nil - } else { - conn, err := tls.Dial( - portType, - addr, - &tls.Config{ - InsecureSkipVerify: true, - ServerName: ip, - ClientAuth: tls.RequestClientCert, - }, - ) - if err != nil { - return nil, err - } - return conn, nil + conn, err := net.Dial(portType, addr) + if err != nil { + return nil, err } + + if ssl { + cfg := &tls.Config{ + InsecureSkipVerify: true, + ServerName: ip, + ClientAuth: tls.RequestClientCert, + } + tlsConn := tls.Client(conn, cfg) + if err := tlsConn.Handshake(); err != nil { + return nil, err + } + + conn = tlsConn + } + + return conn, nil } func (s *SocketHeahthCrawler) CheckHeahth(config *configM.Config) (result map[string]string, err error) { diff --git a/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler.go b/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler.go index a9d3e32..b79df66 100644 --- a/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler.go +++ b/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler.go @@ -11,13 +11,12 @@ type ActiveDirectoryHealthCrawler struct { health.SocketHeahthCrawler } -func (r *ActiveDirectoryHealthCrawler) Name() string { +func (c *ActiveDirectoryHealthCrawler) Name() string { return "ACTIVEDIRECTORY_HEALTH_CRAWLER" } -func (r *ActiveDirectoryHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { - - rss, err := r.CheckHeahth(config) +func (c *ActiveDirectoryHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) if err != nil { return nil, err } diff --git a/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler_test.go b/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler_test.go index 860d11d..37aa2be 100644 --- a/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler_test.go +++ b/crawler/impl/health/activedirectory/ActiveDirectoryHealthCrawler_test.go @@ -2,68 +2,36 @@ package activedirectory import ( "encoding/json" - "log" "testing" - "time" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" ) func setConfig() crawler.Crawler { - r := NewCrawler().* + c := NewCrawler().(*ActiveDirectoryHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.1", + Port: json.Number(389), + PortType: "tcp", + SSL: false, + } - m := make(map[string]interface{}, 0) + c.PutConfig("c", config) - m["ip"] = "192.168.1.1" - m["port"] = "389" - m["portType"] = "tcp" - m["ssl"] = false - - r.PutConfig("ad", m) - - return r + return c } func TestMatch(t *testing.T) { // test config - r := setConfig() + c := setConfig() - out := param.Output{} - r.Get("ad", &out) + rss, err := c.Get("c") - var check bool - json.Unmarshal(out.Data, &check) - - assert.Equal(t, true, check) -} - -func start() { - r := setConfig() - - of_rpc.AddDelegate("ad", r) - err := of_rpc.StartJSONRPC() - if err != nil { - log.Fatal(err) - } -} - -func TestRPC(t *testing.T) { - go start() - time.Sleep(2 * time.Second) - - in := param.Input{ - Name: "ad", - Id: "ad", - } - - result, err := client.InvokeJSONRPCGet("50000", in) - - if err != nil { - t.Fatal(err) - } - - var check bool - json.Unmarshal(result.Data, &check) - assert.Equal(t, true, check) + assert.Nil(t, err) + assert.NotNil(t, rss) } diff --git a/crawler/impl/health/cassandra/CassandraHealthCrawler.go b/crawler/impl/health/cassandra/CassandraHealthCrawler.go new file mode 100644 index 0000000..dae2845 --- /dev/null +++ b/crawler/impl/health/cassandra/CassandraHealthCrawler.go @@ -0,0 +1,31 @@ +package cassandra + +import ( + cnsmc "git.loafle.net/commons_go/network_service_matcher/cassandra" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type CassandraHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *CassandraHealthCrawler) Name() string { + return "CASSANDRA_HEALTH_CRAWLER" +} + +func (c *CassandraHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &CassandraHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmc.NewMatcher()) + return c +} diff --git a/crawler/impl/health/cassandra/CassandraHealthCrawler_test.go b/crawler/impl/health/cassandra/CassandraHealthCrawler_test.go new file mode 100644 index 0000000..88ec770 --- /dev/null +++ b/crawler/impl/health/cassandra/CassandraHealthCrawler_test.go @@ -0,0 +1,37 @@ +package cassandra + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*CassandraHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.104", + Port: json.Number(9042), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/dns/DNSHealthCrawler.go b/crawler/impl/health/dns/DNSHealthCrawler.go new file mode 100644 index 0000000..3bcf5c8 --- /dev/null +++ b/crawler/impl/health/dns/DNSHealthCrawler.go @@ -0,0 +1,31 @@ +package dns + +import ( + cnsmd "git.loafle.net/commons_go/network_service_matcher/dns" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type DNSHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *DNSHealthCrawler) Name() string { + return "DNS_HEALTH_CRAWLER" +} + +func (c *DNSHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &DNSHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmd.NewMatcher()) + return c +} diff --git a/crawler/impl/health/dns/DNSHealthCrawler_test.go b/crawler/impl/health/dns/DNSHealthCrawler_test.go new file mode 100644 index 0000000..7ab2993 --- /dev/null +++ b/crawler/impl/health/dns/DNSHealthCrawler_test.go @@ -0,0 +1,37 @@ +package dns + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*DNSHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(53), + PortType: "udp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/ftp/FTPHealthCrawler.go b/crawler/impl/health/ftp/FTPHealthCrawler.go new file mode 100644 index 0000000..215f76b --- /dev/null +++ b/crawler/impl/health/ftp/FTPHealthCrawler.go @@ -0,0 +1,31 @@ +package ftp + +import ( + cnsmf "git.loafle.net/commons_go/network_service_matcher/ftp" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type FTPHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *FTPHealthCrawler) Name() string { + return "FTP_HEALTH_CRAWLER" +} + +func (c *FTPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &FTPHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmf.NewMatcher()) + return c +} diff --git a/crawler/impl/health/ftp/FTPHealthCrawler_test.go b/crawler/impl/health/ftp/FTPHealthCrawler_test.go new file mode 100644 index 0000000..d7a7888 --- /dev/null +++ b/crawler/impl/health/ftp/FTPHealthCrawler_test.go @@ -0,0 +1,37 @@ +package ftp + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*FTPHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(21), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/http/HTTPHealthCrawler.go b/crawler/impl/health/http/HTTPHealthCrawler.go new file mode 100644 index 0000000..2814339 --- /dev/null +++ b/crawler/impl/health/http/HTTPHealthCrawler.go @@ -0,0 +1,31 @@ +package http + +import ( + cnsmh "git.loafle.net/commons_go/network_service_matcher/http" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type HTTPHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *HTTPHealthCrawler) Name() string { + return "HTTP_HEALTH_CRAWLER" +} + +func (c *HTTPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &HTTPHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmh.NewMatcher()) + return c +} diff --git a/crawler/impl/health/http/HTTPHealthCrawler_test.go b/crawler/impl/health/http/HTTPHealthCrawler_test.go new file mode 100644 index 0000000..198b5ef --- /dev/null +++ b/crawler/impl/health/http/HTTPHealthCrawler_test.go @@ -0,0 +1,37 @@ +package http + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*HTTPHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.105", + Port: json.Number(80), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/imap/IMAPHealthCrawler.go b/crawler/impl/health/imap/IMAPHealthCrawler.go new file mode 100644 index 0000000..9e6bcd7 --- /dev/null +++ b/crawler/impl/health/imap/IMAPHealthCrawler.go @@ -0,0 +1,31 @@ +package imap + +import ( + cnsmi "git.loafle.net/commons_go/network_service_matcher/imap" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type IMAPHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *IMAPHealthCrawler) Name() string { + return "IMAP_HEALTH_CRAWLER" +} + +func (c *IMAPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &IMAPHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmi.NewMatcher()) + return c +} diff --git a/crawler/impl/health/imap/IMAPHealthCrawler_test.go b/crawler/impl/health/imap/IMAPHealthCrawler_test.go new file mode 100644 index 0000000..57408d7 --- /dev/null +++ b/crawler/impl/health/imap/IMAPHealthCrawler_test.go @@ -0,0 +1,37 @@ +package imap + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*IMAPHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(993), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/ldap/LDAPHealthCrawler.go b/crawler/impl/health/ldap/LDAPHealthCrawler.go new file mode 100644 index 0000000..ad4267d --- /dev/null +++ b/crawler/impl/health/ldap/LDAPHealthCrawler.go @@ -0,0 +1,31 @@ +package ldap + +import ( + cnsml "git.loafle.net/commons_go/network_service_matcher/ldap" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type LDAPHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *LDAPHealthCrawler) Name() string { + return "LDAP_HEALTH_CRAWLER" +} + +func (c *LDAPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &LDAPHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsml.NewMatcher()) + return c +} diff --git a/crawler/impl/health/ldap/LDAPHealthCrawler_test.go b/crawler/impl/health/ldap/LDAPHealthCrawler_test.go new file mode 100644 index 0000000..6d66abf --- /dev/null +++ b/crawler/impl/health/ldap/LDAPHealthCrawler_test.go @@ -0,0 +1,37 @@ +package ldap + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*LDAPHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(389), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/mongodb/MongoDBHealthCrawler.go b/crawler/impl/health/mongodb/MongoDBHealthCrawler.go new file mode 100644 index 0000000..82d8d99 --- /dev/null +++ b/crawler/impl/health/mongodb/MongoDBHealthCrawler.go @@ -0,0 +1,31 @@ +package mongodb + +import ( + cnsmm "git.loafle.net/commons_go/network_service_matcher/mongodb" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type MongoDBHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *MongoDBHealthCrawler) Name() string { + return "MONGODB_HEALTH_CRAWLER" +} + +func (c *MongoDBHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &MongoDBHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmm.NewMatcher()) + return c +} diff --git a/crawler/impl/health/mongodb/MongoDBHealthCrawler_test.go b/crawler/impl/health/mongodb/MongoDBHealthCrawler_test.go new file mode 100644 index 0000000..f4009c5 --- /dev/null +++ b/crawler/impl/health/mongodb/MongoDBHealthCrawler_test.go @@ -0,0 +1,37 @@ +package mongodb + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*MongoDBHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.104", + Port: json.Number(27017), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/mysql/MySQLHealthCrawler.go b/crawler/impl/health/mysql/MySQLHealthCrawler.go new file mode 100644 index 0000000..d21bf4b --- /dev/null +++ b/crawler/impl/health/mysql/MySQLHealthCrawler.go @@ -0,0 +1,31 @@ +package mysql + +import ( + cnsmm "git.loafle.net/commons_go/network_service_matcher/mysql" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type MySQLHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *MySQLHealthCrawler) Name() string { + return "MYSQL_HEALTH_CRAWLER" +} + +func (c *MySQLHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &MySQLHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmm.NewMatcher()) + return c +} diff --git a/crawler/impl/health/mysql/MySQLHealthCrawler_test.go b/crawler/impl/health/mysql/MySQLHealthCrawler_test.go new file mode 100644 index 0000000..d33c843 --- /dev/null +++ b/crawler/impl/health/mysql/MySQLHealthCrawler_test.go @@ -0,0 +1,37 @@ +package mysql + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*MySQLHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.103", + Port: json.Number(3306), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/netbios/NetBIOSHealthCrawler.go b/crawler/impl/health/netbios/NetBIOSHealthCrawler.go new file mode 100644 index 0000000..4678917 --- /dev/null +++ b/crawler/impl/health/netbios/NetBIOSHealthCrawler.go @@ -0,0 +1,31 @@ +package netbios + +import ( + cnsmn "git.loafle.net/commons_go/network_service_matcher/netbios" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type NetBIOSHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *NetBIOSHealthCrawler) Name() string { + return "NETBIOS_HEALTH_CRAWLER" +} + +func (c *NetBIOSHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &NetBIOSHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmn.NewMatcher()) + return c +} diff --git a/crawler/impl/health/netbios/NetBIOSHealthCrawler_test.go b/crawler/impl/health/netbios/NetBIOSHealthCrawler_test.go new file mode 100644 index 0000000..437dc1c --- /dev/null +++ b/crawler/impl/health/netbios/NetBIOSHealthCrawler_test.go @@ -0,0 +1,37 @@ +package netbios + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*NetBIOSHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.106", + Port: json.Number(139), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/oracle/OracleHealthCrawler.go b/crawler/impl/health/oracle/OracleHealthCrawler.go new file mode 100644 index 0000000..545f27f --- /dev/null +++ b/crawler/impl/health/oracle/OracleHealthCrawler.go @@ -0,0 +1,31 @@ +package oracle + +import ( + cnsmo "git.loafle.net/commons_go/network_service_matcher/oracle" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type OracleHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *OracleHealthCrawler) Name() string { + return "ORACLE_HEALTH_CRAWLER" +} + +func (c *OracleHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &OracleHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmo.NewMatcher()) + return c +} diff --git a/crawler/impl/health/oracle/OracleHealthCrawler_test.go b/crawler/impl/health/oracle/OracleHealthCrawler_test.go new file mode 100644 index 0000000..5ec6b26 --- /dev/null +++ b/crawler/impl/health/oracle/OracleHealthCrawler_test.go @@ -0,0 +1,37 @@ +package oracle + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*OracleHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.30", + Port: json.Number(1521), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/pop/POPHealthCrawler.go b/crawler/impl/health/pop/POPHealthCrawler.go new file mode 100644 index 0000000..875b105 --- /dev/null +++ b/crawler/impl/health/pop/POPHealthCrawler.go @@ -0,0 +1,31 @@ +package pop + +import ( + cnsmp "git.loafle.net/commons_go/network_service_matcher/pop" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type POPHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *POPHealthCrawler) Name() string { + return "POP_HEALTH_CRAWLER" +} + +func (c *POPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &POPHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmp.NewMatcher()) + return c +} diff --git a/crawler/impl/health/pop/POPHealthCrawler_test.go b/crawler/impl/health/pop/POPHealthCrawler_test.go new file mode 100644 index 0000000..5ba8b6b --- /dev/null +++ b/crawler/impl/health/pop/POPHealthCrawler_test.go @@ -0,0 +1,37 @@ +package pop + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*POPHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(110), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/postgresql/PostgreSQLHealthCrawler.go b/crawler/impl/health/postgresql/PostgreSQLHealthCrawler.go new file mode 100644 index 0000000..8b82eb5 --- /dev/null +++ b/crawler/impl/health/postgresql/PostgreSQLHealthCrawler.go @@ -0,0 +1,31 @@ +package postgresql + +import ( + cnsmp "git.loafle.net/commons_go/network_service_matcher/postgresql" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type PostgreSQLHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *PostgreSQLHealthCrawler) Name() string { + return "POSTGRESQL_HEALTH_CRAWLER" +} + +func (c *PostgreSQLHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &PostgreSQLHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmp.NewMatcher()) + return c +} diff --git a/crawler/impl/health/postgresql/PostgreSQLHealthCrawler_test.go b/crawler/impl/health/postgresql/PostgreSQLHealthCrawler_test.go new file mode 100644 index 0000000..18f5980 --- /dev/null +++ b/crawler/impl/health/postgresql/PostgreSQLHealthCrawler_test.go @@ -0,0 +1,37 @@ +package postgresql + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*PostgreSQLHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.107", + Port: json.Number(5432), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/redis/RedisHealthCrawler.go b/crawler/impl/health/redis/RedisHealthCrawler.go new file mode 100644 index 0000000..1271886 --- /dev/null +++ b/crawler/impl/health/redis/RedisHealthCrawler.go @@ -0,0 +1,31 @@ +package redis + +import ( + cnsmr "git.loafle.net/commons_go/network_service_matcher/redis" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type RedisHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *RedisHealthCrawler) Name() string { + return "REDIS_HEALTH_CRAWLER" +} + +func (c *RedisHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &RedisHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmr.NewMatcher()) + return c +} diff --git a/crawler/impl/health/redis/RedisHealthCrawler_test.go b/crawler/impl/health/redis/RedisHealthCrawler_test.go new file mode 100644 index 0000000..d5f41cc --- /dev/null +++ b/crawler/impl/health/redis/RedisHealthCrawler_test.go @@ -0,0 +1,37 @@ +package redis + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*RedisHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.104", + Port: json.Number(6379), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/rmi/RMIHealthCrawler.go b/crawler/impl/health/rmi/RMIHealthCrawler.go new file mode 100644 index 0000000..32791a6 --- /dev/null +++ b/crawler/impl/health/rmi/RMIHealthCrawler.go @@ -0,0 +1,31 @@ +package rmi + +import ( + cnsmr "git.loafle.net/commons_go/network_service_matcher/rmi" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type RMIHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *RMIHealthCrawler) Name() string { + return "RMI_HEALTH_CRAWLER" +} + +func (c *RMIHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &RMIHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmr.NewMatcher()) + return c +} diff --git a/crawler/impl/health/rmi/RMIHealthCrawler_test.go b/crawler/impl/health/rmi/RMIHealthCrawler_test.go new file mode 100644 index 0000000..a3f6ed7 --- /dev/null +++ b/crawler/impl/health/rmi/RMIHealthCrawler_test.go @@ -0,0 +1,37 @@ +package rmi + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*RMIHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.103", + Port: json.Number(9840), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/smb/SMBHealthCrawler.go b/crawler/impl/health/smb/SMBHealthCrawler.go new file mode 100644 index 0000000..17d7b8f --- /dev/null +++ b/crawler/impl/health/smb/SMBHealthCrawler.go @@ -0,0 +1,31 @@ +package smb + +import ( + cnsms "git.loafle.net/commons_go/network_service_matcher/smb" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type SMBHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *SMBHealthCrawler) Name() string { + return "SMB_HEALTH_CRAWLER" +} + +func (c *SMBHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &SMBHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsms.NewMatcher()) + return c +} diff --git a/crawler/impl/health/smb/SMBHealthCrawler_test.go b/crawler/impl/health/smb/SMBHealthCrawler_test.go new file mode 100644 index 0000000..8490f73 --- /dev/null +++ b/crawler/impl/health/smb/SMBHealthCrawler_test.go @@ -0,0 +1,37 @@ +package smb + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*SMBHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.106", + Port: json.Number(445), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/smtp/SMTPHealthCrawler.go b/crawler/impl/health/smtp/SMTPHealthCrawler.go new file mode 100644 index 0000000..d9f6608 --- /dev/null +++ b/crawler/impl/health/smtp/SMTPHealthCrawler.go @@ -0,0 +1,31 @@ +package smtp + +import ( + cnsms "git.loafle.net/commons_go/network_service_matcher/smtp" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type SMTPHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *SMTPHealthCrawler) Name() string { + return "SMTP_HEALTH_CRAWLER" +} + +func (c *SMTPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &SMTPHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsms.NewMatcher()) + return c +} diff --git a/crawler/impl/health/smtp/SMTPHealthCrawler_test.go b/crawler/impl/health/smtp/SMTPHealthCrawler_test.go new file mode 100644 index 0000000..384cbee --- /dev/null +++ b/crawler/impl/health/smtp/SMTPHealthCrawler_test.go @@ -0,0 +1,37 @@ +package smtp + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*SMTPHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(25), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/snmp/v2/SNMPHealthCrawler.go b/crawler/impl/health/snmp/v2/SNMPHealthCrawler.go new file mode 100644 index 0000000..63bd5a7 --- /dev/null +++ b/crawler/impl/health/snmp/v2/SNMPHealthCrawler.go @@ -0,0 +1,31 @@ +package v2 + +import ( + cnsms "git.loafle.net/commons_go/network_service_matcher/snmp/v2" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type SNMPHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *SNMPHealthCrawler) Name() string { + return "SNMPV2C_HEALTH_CRAWLER" +} + +func (c *SNMPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &SNMPHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsms.NewMatcher()) + return c +} diff --git a/crawler/impl/health/snmp/v2/SNMPHealthCrawler_test.go b/crawler/impl/health/snmp/v2/SNMPHealthCrawler_test.go new file mode 100644 index 0000000..0db3787 --- /dev/null +++ b/crawler/impl/health/snmp/v2/SNMPHealthCrawler_test.go @@ -0,0 +1,37 @@ +package v2 + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*SNMPHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(161), + PortType: "udp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/snmp/v3/SNMPHealthCrawler.go b/crawler/impl/health/snmp/v3/SNMPHealthCrawler.go new file mode 100644 index 0000000..ae380a8 --- /dev/null +++ b/crawler/impl/health/snmp/v3/SNMPHealthCrawler.go @@ -0,0 +1,31 @@ +package v3 + +import ( + cnsms "git.loafle.net/commons_go/network_service_matcher/snmp/v3" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type SNMPHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *SNMPHealthCrawler) Name() string { + return "SNMPV3_HEALTH_CRAWLER" +} + +func (c *SNMPHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &SNMPHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsms.NewMatcher()) + return c +} diff --git a/crawler/impl/health/snmp/v3/SNMPHealthCrawler_test.go b/crawler/impl/health/snmp/v3/SNMPHealthCrawler_test.go new file mode 100644 index 0000000..945b07f --- /dev/null +++ b/crawler/impl/health/snmp/v3/SNMPHealthCrawler_test.go @@ -0,0 +1,37 @@ +package v3 + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*SNMPHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.254", + Port: json.Number(161), + PortType: "udp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/sqlserver/SQLServerHealthCrawler.go b/crawler/impl/health/sqlserver/SQLServerHealthCrawler.go new file mode 100644 index 0000000..e6cb51e --- /dev/null +++ b/crawler/impl/health/sqlserver/SQLServerHealthCrawler.go @@ -0,0 +1,32 @@ +package sqlserver + + +import ( + cnsms "git.loafle.net/commons_go/network_service_matcher/sqlserver" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type SQLServerHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *SQLServerHealthCrawler) Name() string { + return "SQLSERVER_HEALTH_CRAWLER" +} + +func (c *SQLServerHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &SQLServerHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsms.NewMatcher()) + return c +} diff --git a/crawler/impl/health/sqlserver/SQLServerHealthCrawler_test.go b/crawler/impl/health/sqlserver/SQLServerHealthCrawler_test.go new file mode 100644 index 0000000..cd4cb13 --- /dev/null +++ b/crawler/impl/health/sqlserver/SQLServerHealthCrawler_test.go @@ -0,0 +1,37 @@ +package sqlserver + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*SQLServerHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.106", + Port: json.Number(1433), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/ssh/SSHHealthCrawler.go b/crawler/impl/health/ssh/SSHHealthCrawler.go new file mode 100644 index 0000000..539638f --- /dev/null +++ b/crawler/impl/health/ssh/SSHHealthCrawler.go @@ -0,0 +1,31 @@ +package ssh + +import ( + cnsms "git.loafle.net/commons_go/network_service_matcher/ssh" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type SSHHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *SSHHealthCrawler) Name() string { + return "SSH_HEALTH_CRAWLER" +} + +func (c *SSHHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &SSHHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsms.NewMatcher()) + return c +} diff --git a/crawler/impl/health/ssh/SSHHealthCrawler_test.go b/crawler/impl/health/ssh/SSHHealthCrawler_test.go new file mode 100644 index 0000000..1d3be38 --- /dev/null +++ b/crawler/impl/health/ssh/SSHHealthCrawler_test.go @@ -0,0 +1,37 @@ +package ssh + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*SSHHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(22), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/telnet/TelnetHealthCrawler.go b/crawler/impl/health/telnet/TelnetHealthCrawler.go new file mode 100644 index 0000000..f86f840 --- /dev/null +++ b/crawler/impl/health/telnet/TelnetHealthCrawler.go @@ -0,0 +1,32 @@ +package telnet + + +import ( + cnsmt "git.loafle.net/commons_go/network_service_matcher/telnet" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type TelnetHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *TelnetHealthCrawler) Name() string { + return "TELNET_HEALTH_CRAWLER" +} + +func (c *TelnetHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &TelnetHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmt.NewMatcher()) + return c +} diff --git a/crawler/impl/health/telnet/TelnetHealthCrawler_test.go b/crawler/impl/health/telnet/TelnetHealthCrawler_test.go new file mode 100644 index 0000000..58f0bba --- /dev/null +++ b/crawler/impl/health/telnet/TelnetHealthCrawler_test.go @@ -0,0 +1,37 @@ +package telnet + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*TelnetHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.215", + Port: json.Number(23), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +} diff --git a/crawler/impl/health/wmi/WMIHealthCrawler.go b/crawler/impl/health/wmi/WMIHealthCrawler.go new file mode 100644 index 0000000..a4b71c3 --- /dev/null +++ b/crawler/impl/health/wmi/WMIHealthCrawler.go @@ -0,0 +1,32 @@ +package wmi + + +import ( + cnsmw "git.loafle.net/commons_go/network_service_matcher/wmi" + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "git.loafle.net/overflow/overflow_probe_container_network/crawler/impl/health" +) + +type WMIHealthCrawler struct { + health.SocketHeahthCrawler +} + +func (c *WMIHealthCrawler) Name() string { + return "WMI_HEALTH_CRAWLER" +} + +func (c *WMIHealthCrawler) InternalGet(config *configM.Config) (map[string]string, error) { + rss, err := c.CheckHeahth(config) + if err != nil { + return nil, err + } + return rss, nil +} + +func NewCrawler() crawler.Crawler { + c := &WMIHealthCrawler{} + c.Internal = c + c.SetMatcher(cnsmw.NewMatcher()) + return c +} diff --git a/crawler/impl/health/wmi/WMIHealthCrawler_test.go b/crawler/impl/health/wmi/WMIHealthCrawler_test.go new file mode 100644 index 0000000..223c34f --- /dev/null +++ b/crawler/impl/health/wmi/WMIHealthCrawler_test.go @@ -0,0 +1,37 @@ +package wmi + +import ( + "encoding/json" + "testing" + + configM "git.loafle.net/overflow/overflow_commons_go/modules/config/model" + "git.loafle.net/overflow/overflow_probe_container_network/crawler" + "github.com/stretchr/testify/assert" +) + +func setConfig() crawler.Crawler { + + c := NewCrawler().(*WMIHealthCrawler) + config := &configM.Config{} + config.Target = &configM.Target{} + config.Target.Connection = &configM.Connection{ + IP: "192.168.1.1", + Port: json.Number(135), + PortType: "tcp", + SSL: false, + } + + c.PutConfig("c", config) + + return c +} + +func TestMatch(t *testing.T) { + // test config + c := setConfig() + + rss, err := c.Get("c") + + assert.Nil(t, err) + assert.NotNil(t, rss) +}