MCPcopy Index your code
hub / github.com/foxcpp/maddy / ProxyProtocolDirective

Function ProxyProtocolDirective

internal/proxy_protocol/proxy_protocol.go:19–51  ·  view source on GitHub ↗
(_ *config.Map, node config.Node)

Source from the content-addressed store, hash-verified

17}
18
19func 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
53func NewListener(inner net.Listener, p *ProxyProtocol, logger *log.Logger) net.Listener {
54 var listener net.Listener

Callers

nothing calls this directly

Calls 4

StringListMethod · 0.95
CustomMethod · 0.95
ProcessMethod · 0.95
NewMapFunction · 0.92

Tested by

no test coverage detected