package matcher import ( osm "git.loafle.net/overflow/service_matcher-go" "git.loafle.net/overflow/service_matcher-go/activedirectory" "git.loafle.net/overflow/service_matcher-go/cassandra" "git.loafle.net/overflow/service_matcher-go/echo" "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/imap" "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/oracle" "git.loafle.net/overflow/service_matcher-go/pop" "git.loafle.net/overflow/service_matcher-go/postgresql" "git.loafle.net/overflow/service_matcher-go/redis" "git.loafle.net/overflow/service_matcher-go/rmi" "git.loafle.net/overflow/service_matcher-go/smb" "git.loafle.net/overflow/service_matcher-go/sqlserver" "git.loafle.net/overflow/service_matcher-go/ssh" "git.loafle.net/overflow/service_matcher-go/telnet" "git.loafle.net/overflow/service_matcher-go/wmi" ) var ( AllMatchers []osm.Matcher TCPMatchers []osm.Matcher UDPMatchers []osm.UDPMatcher TCPPrePacketMatchers []osm.Matcher TCPNotPrePacketMatchers []osm.Matcher HTTPSubMatchers []osm.Matcher ) func init() { //TCP addTCPMatcher(activedirectory.NewMatcher()) addTCPMatcher(cassandra.NewMatcher()) addTCPMatcher(echo.NewMatcher()) addTCPMatcher(ftp.NewMatcher()) addTCPMatcher(http.NewMatcher()) addTCPMatcher(imap.NewMatcher()) addTCPMatcher(ldap.NewMatcher()) addTCPMatcher(lpd.NewMatcher()) addTCPMatcher(mongodb.NewMatcher()) addTCPMatcher(mysql.NewMatcher()) addTCPMatcher(nbss.NewMatcher()) addTCPMatcher(oracle.NewMatcher()) addTCPMatcher(pop.NewMatcher()) addTCPMatcher(postgresql.NewMatcher()) addTCPMatcher(redis.NewMatcher()) addTCPMatcher(rmi.NewMatcher()) addTCPMatcher(smb.NewMatcher()) addTCPMatcher(sqlserver.NewMatcher()) addTCPMatcher(ssh.NewMatcher()) addTCPMatcher(telnet.NewMatcher()) addTCPMatcher(wmi.NewMatcher()) // UDP // addUDPMatcher(dns.NewMatcher()) // HTTP-relative addHTTPSubMatcher(elasticsearch.NewMatcher()) } 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 addHTTPSubMatcher(m osm.Matcher) { HTTPSubMatchers = append(HTTPSubMatchers, m) } func GetTCPMatchers(isPrePacket bool) []osm.Matcher { if isPrePacket { return TCPPrePacketMatchers } return TCPNotPrePacketMatchers } func GetUDPMatchers() []osm.UDPMatcher { return UDPMatchers } func GetHTTPSubMatchers() []osm.Matcher { return HTTPSubMatchers } func GetMatcherByKey(matchCtx *osm.MatchCtx, key string) osm.Matcher { for _, m := range AllMatchers { if m.Key(matchCtx) == key { return m } } return nil }