(ctx context.Context, state *Request)
| 7 | ) |
| 8 | |
| 9 | func DefaultEnv(ctx context.Context, state *Request) map[string]any { |
| 10 | return map[string]any{ |
| 11 | "incidr": func(ipStr, cidrStr string) (bool, error) { |
| 12 | ip := net.ParseIP(ipStr) |
| 13 | if ip == nil { |
| 14 | return false, errors.New("first argument is not an IP address") |
| 15 | } |
| 16 | _, cidr, err := net.ParseCIDR(cidrStr) |
| 17 | if err != nil { |
| 18 | return false, err |
| 19 | } |
| 20 | return cidr.Contains(ip), nil |
| 21 | }, |
| 22 | "metadata": func(label string) string { |
| 23 | return "" |
| 24 | }, |
| 25 | "type": state.Type, |
| 26 | "name": state.Name, |
| 27 | "class": state.Class, |
| 28 | "proto": state.Proto, |
| 29 | "size": state.Len, |
| 30 | "client_ip": state.IP, |
| 31 | "port": state.Port, |
| 32 | "id": func() int { return int(state.Req.Id) }, |
| 33 | "opcode": func() int { return state.Req.Opcode }, |
| 34 | "do": state.Do, |
| 35 | "bufsize": state.Size, |
| 36 | "server_ip": state.LocalIP, |
| 37 | "server_port": state.LocalPort, |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | type Request struct { |
| 42 | Req *Msg |
searching dependent graphs…