diff --git a/config/rules.yaml b/config/rules.yaml index 2e73028..ceab35a 100644 --- a/config/rules.yaml +++ b/config/rules.yaml @@ -29,6 +29,8 @@ rules: - match: tcp dst port 11211 type: conn_handler target: memcache + - match: tcp dst port 5000 + type: passthrough - match: tcp type: conn_handler target: tcp diff --git a/glutton.go b/glutton.go index e56480f..57ee6d9 100644 --- a/glutton.go +++ b/glutton.go @@ -216,6 +216,10 @@ func (g *Glutton) tcpListen() { } md, err := g.connTable.RegisterConn(conn, rule) + if md.Rule.GetRuleType() == rules.PassThrough { + continue + } + if err != nil { g.Logger.Error("Failed to register connection", producer.ErrAttr(err)) continue diff --git a/rules/rules.go b/rules/rules.go index 0b4d595..c02a00d 100644 --- a/rules/rules.go +++ b/rules/rules.go @@ -18,6 +18,7 @@ type RuleType int const ( UserConnHandler RuleType = iota Drop + PassThrough ) type Config struct { @@ -37,6 +38,10 @@ type Rule struct { matcher *pcap.BPF } +func (r *Rule) GetRuleType() RuleType { + return r.ruleType +} + func (r *Rule) String() string { return fmt.Sprintf("Rule: %s", r.Match) } @@ -62,6 +67,8 @@ func (rule *Rule) init(idx int) error { rule.ruleType = UserConnHandler case "drop": rule.ruleType = Drop + case "passthrough": + rule.ruleType = PassThrough default: return fmt.Errorf("unknown rule type: %s", rule.Type) }