83 lines
2.1 KiB
Go
83 lines
2.1 KiB
Go
package matcher
|
|
|
|
import (
|
|
osm "git.loafle.net/overflow/service_matcher-go"
|
|
"git.loafle.net/overflow/service_matcher-go/elasticsearch"
|
|
"git.loafle.net/overflow/service_matcher-go/ftp"
|
|
"git.loafle.net/overflow/service_matcher-go/http"
|
|
"git.loafle.net/overflow/service_matcher-go/ldap"
|
|
"git.loafle.net/overflow/service_matcher-go/lpd"
|
|
"git.loafle.net/overflow/service_matcher-go/mongodb"
|
|
"git.loafle.net/overflow/service_matcher-go/mysql"
|
|
"git.loafle.net/overflow/service_matcher-go/nbss"
|
|
"git.loafle.net/overflow/service_matcher-go/postgresql"
|
|
"git.loafle.net/overflow/service_matcher-go/redis"
|
|
"git.loafle.net/overflow/service_matcher-go/ssh"
|
|
"git.loafle.net/overflow/service_matcher-go/telnet"
|
|
)
|
|
|
|
var (
|
|
AllMatchers []osm.Matcher
|
|
|
|
TCPMatchers []osm.Matcher
|
|
UDPMatchers []osm.UDPMatcher
|
|
|
|
TCPPrePacketMatchers []osm.Matcher
|
|
TCPNotPrePacketMatchers []osm.Matcher
|
|
)
|
|
|
|
func init() {
|
|
//TCP
|
|
addTCPMatcher(ssh.NewMatcher())
|
|
addTCPMatcher(mongodb.NewMatcher())
|
|
addTCPMatcher(mysql.NewMatcher())
|
|
addTCPMatcher(redis.NewMatcher())
|
|
addTCPMatcher(postgresql.NewMatcher())
|
|
addTCPMatcher(ftp.NewMatcher())
|
|
addTCPMatcher(http.NewMatcher())
|
|
addTCPMatcher(lpd.NewMatcher())
|
|
addTCPMatcher(elasticsearch.NewMatcher())
|
|
addTCPMatcher(telnet.NewMatcher())
|
|
addTCPMatcher(nbss.NewMatcher())
|
|
addTCPMatcher(ldap.NewMatcher())
|
|
addTCPMatcher(mysql.NewMatcher())
|
|
|
|
// UDP
|
|
}
|
|
|
|
func addTCPMatcher(m osm.Matcher) {
|
|
AllMatchers = append(AllMatchers, m)
|
|
TCPMatchers = append(TCPMatchers, m)
|
|
if m.IsPrePacket() {
|
|
TCPPrePacketMatchers = append(TCPPrePacketMatchers, m)
|
|
} else {
|
|
TCPNotPrePacketMatchers = append(TCPNotPrePacketMatchers, m)
|
|
}
|
|
}
|
|
|
|
func addUDPMatcher(m osm.UDPMatcher) {
|
|
AllMatchers = append(AllMatchers, m)
|
|
UDPMatchers = append(UDPMatchers, m)
|
|
}
|
|
|
|
func GetTCPMatchers(isPrePacket bool) []osm.Matcher {
|
|
if isPrePacket {
|
|
return TCPPrePacketMatchers
|
|
}
|
|
|
|
return TCPNotPrePacketMatchers
|
|
}
|
|
|
|
func GetUDPMatchers() []osm.UDPMatcher {
|
|
return UDPMatchers
|
|
}
|
|
|
|
func GetMatcherByKey(key string) osm.Matcher {
|
|
for _, m := range AllMatchers {
|
|
if m.Key() == key {
|
|
return m
|
|
}
|
|
}
|
|
return nil
|
|
}
|