package compiler // Global-compiled long-tail: blrules, conntrack, secmarks (rendered on enforcing // devices), and vars (substitution variables, rendered on every device). type RenderedBlrule struct { Priority int `yaml:"priority,omitempty" json:"priority,omitempty"` Action string `yaml:"action" json:"action"` Source string `yaml:"source,omitempty" json:"source,omitempty"` Dest string `yaml:"dest,omitempty" json:"dest,omitempty"` Proto string `yaml:"proto,omitempty" json:"proto,omitempty"` DPort []string `yaml:"dport,omitempty" json:"dport,omitempty"` SPort []string `yaml:"sport,omitempty" json:"sport,omitempty"` Log string `yaml:"log,omitempty" json:"log,omitempty"` Comment string `yaml:"comment,omitempty" json:"comment,omitempty"` } type RenderedConntrack struct { Action string `yaml:"action" json:"action"` Source string `yaml:"source,omitempty" json:"source,omitempty"` Dest string `yaml:"dest,omitempty" json:"dest,omitempty"` Proto string `yaml:"proto,omitempty" json:"proto,omitempty"` DPort []string `yaml:"dport,omitempty" json:"dport,omitempty"` SPort []string `yaml:"sport,omitempty" json:"sport,omitempty"` Chain string `yaml:"chain,omitempty" json:"chain,omitempty"` Helper string `yaml:"helper,omitempty" json:"helper,omitempty"` User string `yaml:"user,omitempty" json:"user,omitempty"` Comment string `yaml:"comment,omitempty" json:"comment,omitempty"` } type RenderedSecmark struct { Secmark string `yaml:"secmark" json:"secmark"` Chain string `yaml:"chain" json:"chain"` Source string `yaml:"source,omitempty" json:"source,omitempty"` Dest string `yaml:"dest,omitempty" json:"dest,omitempty"` Proto string `yaml:"proto,omitempty" json:"proto,omitempty"` DPort []string `yaml:"dport,omitempty" json:"dport,omitempty"` SPort []string `yaml:"sport,omitempty" json:"sport,omitempty"` Comment string `yaml:"comment,omitempty" json:"comment,omitempty"` } // renderGlobal2 renders the global-compiled sections. blrules/conntrack/secmarks // only apply on enforcing devices; vars are always emitted. func renderGlobal2(in Input, out *RenderedConfig) { if len(in.Vars) > 0 { out.Vars = make(map[string]string, len(in.Vars)) for _, v := range in.Vars { out.Vars[v.Key] = v.Value } } if !out.Enforcing { return } for _, b := range in.Blrules { out.Blrules = append(out.Blrules, RenderedBlrule{ Priority: b.Priority, Action: b.Action, Source: b.Source, Dest: b.Dest, Proto: b.Proto, DPort: b.DPort, SPort: b.SPort, Log: b.Log, Comment: b.Comment, }) } for _, c := range in.Conntrack { out.Conntrack = append(out.Conntrack, RenderedConntrack{ Action: c.Action, Source: c.Source, Dest: c.Dest, Proto: c.Proto, DPort: c.DPort, SPort: c.SPort, Chain: c.Chain, Helper: c.Helper, User: c.User, Comment: c.Comment, }) } for _, s := range in.Secmarks { out.Secmarks = append(out.Secmarks, RenderedSecmark{ Secmark: s.Secmark, Chain: s.Chain, Source: s.Source, Dest: s.Dest, Proto: s.Proto, DPort: s.DPort, SPort: s.SPort, Comment: s.Comment, }) } }