servicematcher : http-relative matchers
This commit is contained in:
parent
1dcb5f8438
commit
69f9095a71
|
@ -32,7 +32,7 @@ var (
|
||||||
h = &omd.Host{
|
h = &omd.Host{
|
||||||
Zone: z,
|
Zone: z,
|
||||||
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||||
Address: "192.168.1.229",
|
Address: "127.0.0.1",
|
||||||
Mac: "50:E5:49:46:93:28",
|
Mac: "50:E5:49:46:93:28",
|
||||||
}
|
}
|
||||||
dp = &omd.DiscoverPort{
|
dp = &omd.DiscoverPort{
|
||||||
|
@ -47,7 +47,7 @@ var (
|
||||||
p = &omd.Port{
|
p = &omd.Port{
|
||||||
Host: h,
|
Host: h,
|
||||||
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
|
||||||
PortNumber: json.Number(strconv.Itoa(80)),
|
PortNumber: json.Number(strconv.Itoa(21)),
|
||||||
DiscoveredDate: omu.NowPtr(),
|
DiscoveredDate: omu.NowPtr(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,16 @@ LOOP:
|
||||||
s = hadlePrePacket(info, sc, conn, osm.NewPacket(buf, rn))
|
s = hadlePrePacket(info, sc, conn, osm.NewPacket(buf, rn))
|
||||||
} else {
|
} else {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
s = hadlePostPacket(info, sc)
|
s = hadlePostPacket(info, sc, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != s {
|
if nil != s {
|
||||||
|
if s.Key == "HTTP" {
|
||||||
|
hsm := matcher.GetHTTPSubMatchers()
|
||||||
|
if ss := hadlePostPacket(info, sc, hsm); ss != nil {
|
||||||
|
s = ss
|
||||||
|
}
|
||||||
|
}
|
||||||
break LOOP
|
break LOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,11 +165,15 @@ LOOP:
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func hadlePostPacket(info osm.MatchInfo, sc serviceConnector) *omd.Service {
|
func hadlePostPacket(info osm.MatchInfo, sc serviceConnector, limitedMatchers []osm.Matcher) *omd.Service {
|
||||||
defer func() {
|
defer func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ms := matcher.GetTCPMatchers(false)
|
ms := matcher.GetTCPMatchers(false)
|
||||||
|
if limitedMatchers != nil {
|
||||||
|
ms = limitedMatchers
|
||||||
|
}
|
||||||
|
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
var s *omd.Service
|
var s *omd.Service
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ var (
|
||||||
|
|
||||||
TCPPrePacketMatchers []osm.Matcher
|
TCPPrePacketMatchers []osm.Matcher
|
||||||
TCPNotPrePacketMatchers []osm.Matcher
|
TCPNotPrePacketMatchers []osm.Matcher
|
||||||
|
|
||||||
|
HTTPSubMatchers []osm.Matcher
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -36,13 +38,16 @@ func init() {
|
||||||
addTCPMatcher(ftp.NewMatcher())
|
addTCPMatcher(ftp.NewMatcher())
|
||||||
addTCPMatcher(http.NewMatcher())
|
addTCPMatcher(http.NewMatcher())
|
||||||
addTCPMatcher(lpd.NewMatcher())
|
addTCPMatcher(lpd.NewMatcher())
|
||||||
addTCPMatcher(elasticsearch.NewMatcher())
|
|
||||||
addTCPMatcher(telnet.NewMatcher())
|
addTCPMatcher(telnet.NewMatcher())
|
||||||
addTCPMatcher(nbss.NewMatcher())
|
addTCPMatcher(nbss.NewMatcher())
|
||||||
addTCPMatcher(ldap.NewMatcher())
|
addTCPMatcher(ldap.NewMatcher())
|
||||||
addTCPMatcher(mysql.NewMatcher())
|
addTCPMatcher(mysql.NewMatcher())
|
||||||
|
|
||||||
// UDP
|
// UDP
|
||||||
|
// addUDPMatcher(dns.NewMatcher())
|
||||||
|
|
||||||
|
// HTTP-relative
|
||||||
|
addHTTPSubMatcher(elasticsearch.NewMatcher())
|
||||||
}
|
}
|
||||||
|
|
||||||
func addTCPMatcher(m osm.Matcher) {
|
func addTCPMatcher(m osm.Matcher) {
|
||||||
|
@ -60,6 +65,10 @@ func addUDPMatcher(m osm.UDPMatcher) {
|
||||||
UDPMatchers = append(UDPMatchers, m)
|
UDPMatchers = append(UDPMatchers, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addHTTPSubMatcher(m osm.Matcher) {
|
||||||
|
HTTPSubMatchers = append(HTTPSubMatchers, m)
|
||||||
|
}
|
||||||
|
|
||||||
func GetTCPMatchers(isPrePacket bool) []osm.Matcher {
|
func GetTCPMatchers(isPrePacket bool) []osm.Matcher {
|
||||||
if isPrePacket {
|
if isPrePacket {
|
||||||
return TCPPrePacketMatchers
|
return TCPPrePacketMatchers
|
||||||
|
@ -72,6 +81,10 @@ func GetUDPMatchers() []osm.UDPMatcher {
|
||||||
return UDPMatchers
|
return UDPMatchers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetHTTPSubMatchers() []osm.Matcher {
|
||||||
|
return HTTPSubMatchers
|
||||||
|
}
|
||||||
|
|
||||||
func GetMatcherByKey(key string) osm.Matcher {
|
func GetMatcherByKey(key string) osm.Matcher {
|
||||||
for _, m := range AllMatchers {
|
for _, m := range AllMatchers {
|
||||||
if m.Key() == key {
|
if m.Key() == key {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user