INNER CODE UNIT · Go
newIPTablesRules
uswitch/kiam · cmd/kiam/iptables.go:35
func newIPTablesRules(host string, kiamPort int, hostInterface string) *rules {
return &rules{host: host, kiamPort: kiamPort, hostInterface: hostInterface}
}
func (r *rules) Add() error {
ipt, err := iptables.New()
if err != nil {
return err
}
return ipt.AppendUnique("nat", "PREROUTING", r.ruleSpec()...)
}
func (r *rules) ruleSpec() []string {
rules := []string{
"-p", "tcp",
"-d", metadataAddress,
"--dport", "80",