package server import ( "encoding/json" "housecarl/internal/trace" ) // otherTables lists the tables in an `nft -j list ruleset` other than // Housecarl's ("inet main"). // inputFilters lists the tables other than Housecarl's with a filter // chain on the input hook: what filters the machine in shadow mode. func inputFilters(data []byte) []string { var doc struct { Nftables []map[string]json.RawMessage `json:"nftables"` } out := []string{} if json.Unmarshal(data, &doc) != nil { return out } for _, item := range doc.Nftables { raw, ok := item["chain"] if !ok { continue } var c struct{ Family, Table, Type, Hook string } if json.Unmarshal(raw, &c) == nil && c.Type == "filter" && c.Hook == "input" && !(c.Family == "inet" && (c.Table == "housecarl" || c.Table == trace.Table)) { out = append(out, c.Family+" "+c.Table) } } return out } func otherTables(data []byte) []string { var doc struct { Nftables []map[string]json.RawMessage `json:"nftables"` } out := []string{} if json.Unmarshal(data, &doc) != nil { return out } for _, item := range doc.Nftables { raw, ok := item["table"] if !ok { continue } var t struct{ Family, Name string } if json.Unmarshal(raw, &t) == nil && !(t.Family == "inet" && (t.Name == "housecarl" || t.Name == trace.Table)) { out = append(out, t.Family+" "+t.Name) } } return out }