ing
This commit is contained in:
parent
ae5c6f324f
commit
0062a475a4
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
31
crawler/impl/health/cassandra/CassandraHealthCrawler.go
Normal file
31
crawler/impl/health/cassandra/CassandraHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/cassandra/CassandraHealthCrawler_test.go
Normal file
37
crawler/impl/health/cassandra/CassandraHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/dns/DNSHealthCrawler.go
Normal file
31
crawler/impl/health/dns/DNSHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/dns/DNSHealthCrawler_test.go
Normal file
37
crawler/impl/health/dns/DNSHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/ftp/FTPHealthCrawler.go
Normal file
31
crawler/impl/health/ftp/FTPHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/ftp/FTPHealthCrawler_test.go
Normal file
37
crawler/impl/health/ftp/FTPHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/http/HTTPHealthCrawler.go
Normal file
31
crawler/impl/health/http/HTTPHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/http/HTTPHealthCrawler_test.go
Normal file
37
crawler/impl/health/http/HTTPHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/imap/IMAPHealthCrawler.go
Normal file
31
crawler/impl/health/imap/IMAPHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/imap/IMAPHealthCrawler_test.go
Normal file
37
crawler/impl/health/imap/IMAPHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/ldap/LDAPHealthCrawler.go
Normal file
31
crawler/impl/health/ldap/LDAPHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/ldap/LDAPHealthCrawler_test.go
Normal file
37
crawler/impl/health/ldap/LDAPHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/mongodb/MongoDBHealthCrawler.go
Normal file
31
crawler/impl/health/mongodb/MongoDBHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/mongodb/MongoDBHealthCrawler_test.go
Normal file
37
crawler/impl/health/mongodb/MongoDBHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/mysql/MySQLHealthCrawler.go
Normal file
31
crawler/impl/health/mysql/MySQLHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/mysql/MySQLHealthCrawler_test.go
Normal file
37
crawler/impl/health/mysql/MySQLHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/netbios/NetBIOSHealthCrawler.go
Normal file
31
crawler/impl/health/netbios/NetBIOSHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/netbios/NetBIOSHealthCrawler_test.go
Normal file
37
crawler/impl/health/netbios/NetBIOSHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/oracle/OracleHealthCrawler.go
Normal file
31
crawler/impl/health/oracle/OracleHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/oracle/OracleHealthCrawler_test.go
Normal file
37
crawler/impl/health/oracle/OracleHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/pop/POPHealthCrawler.go
Normal file
31
crawler/impl/health/pop/POPHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/pop/POPHealthCrawler_test.go
Normal file
37
crawler/impl/health/pop/POPHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/postgresql/PostgreSQLHealthCrawler.go
Normal file
31
crawler/impl/health/postgresql/PostgreSQLHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
}
|
31
crawler/impl/health/redis/RedisHealthCrawler.go
Normal file
31
crawler/impl/health/redis/RedisHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/redis/RedisHealthCrawler_test.go
Normal file
37
crawler/impl/health/redis/RedisHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/rmi/RMIHealthCrawler.go
Normal file
31
crawler/impl/health/rmi/RMIHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/rmi/RMIHealthCrawler_test.go
Normal file
37
crawler/impl/health/rmi/RMIHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/smb/SMBHealthCrawler.go
Normal file
31
crawler/impl/health/smb/SMBHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/smb/SMBHealthCrawler_test.go
Normal file
37
crawler/impl/health/smb/SMBHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/smtp/SMTPHealthCrawler.go
Normal file
31
crawler/impl/health/smtp/SMTPHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/smtp/SMTPHealthCrawler_test.go
Normal file
37
crawler/impl/health/smtp/SMTPHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/snmp/v2/SNMPHealthCrawler.go
Normal file
31
crawler/impl/health/snmp/v2/SNMPHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/snmp/v2/SNMPHealthCrawler_test.go
Normal file
37
crawler/impl/health/snmp/v2/SNMPHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/snmp/v3/SNMPHealthCrawler.go
Normal file
31
crawler/impl/health/snmp/v3/SNMPHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/snmp/v3/SNMPHealthCrawler_test.go
Normal file
37
crawler/impl/health/snmp/v3/SNMPHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
32
crawler/impl/health/sqlserver/SQLServerHealthCrawler.go
Normal file
32
crawler/impl/health/sqlserver/SQLServerHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/sqlserver/SQLServerHealthCrawler_test.go
Normal file
37
crawler/impl/health/sqlserver/SQLServerHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
31
crawler/impl/health/ssh/SSHHealthCrawler.go
Normal file
31
crawler/impl/health/ssh/SSHHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/ssh/SSHHealthCrawler_test.go
Normal file
37
crawler/impl/health/ssh/SSHHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
32
crawler/impl/health/telnet/TelnetHealthCrawler.go
Normal file
32
crawler/impl/health/telnet/TelnetHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/telnet/TelnetHealthCrawler_test.go
Normal file
37
crawler/impl/health/telnet/TelnetHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
32
crawler/impl/health/wmi/WMIHealthCrawler.go
Normal file
32
crawler/impl/health/wmi/WMIHealthCrawler.go
Normal file
|
@ -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
|
||||
}
|
37
crawler/impl/health/wmi/WMIHealthCrawler_test.go
Normal file
37
crawler/impl/health/wmi/WMIHealthCrawler_test.go
Normal file
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user