(_ *config.Map, node config.Node)
| 17 | } |
| 18 | |
| 19 | func ProxyProtocolDirective(_ *config.Map, node config.Node) (interface{}, error) { |
| 20 | p := ProxyProtocol{} |
| 21 | |
| 22 | childM := config.NewMap(nil, node) |
| 23 | var trustList []string |
| 24 | |
| 25 | childM.StringList("trust", false, false, nil, &trustList) |
| 26 | childM.Custom("tls", true, false, nil, tls2.TLSDirective, &p.tlsConfig) |
| 27 | |
| 28 | if _, err := childM.Process(); err != nil { |
| 29 | return nil, err |
| 30 | } |
| 31 | |
| 32 | if len(node.Args) > 0 { |
| 33 | if trustList == nil { |
| 34 | trustList = make([]string, 0) |
| 35 | } |
| 36 | trustList = append(trustList, node.Args...) |
| 37 | } |
| 38 | |
| 39 | for _, trust := range trustList { |
| 40 | if !strings.Contains(trust, "/") { |
| 41 | trust += "/32" |
| 42 | } |
| 43 | _, ipNet, err := net.ParseCIDR(trust) |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | p.trust = append(p.trust, *ipNet) |
| 48 | } |
| 49 | |
| 50 | return &p, nil |
| 51 | } |
| 52 | |
| 53 | func NewListener(inner net.Listener, p *ProxyProtocol, logger *log.Logger) net.Listener { |
| 54 | var listener net.Listener |
nothing calls this directly
no test coverage detected