(tt *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestProxyProtocolTrustedSource(tt *testing.T) { |
| 73 | tt.Parallel() |
| 74 | t := tests.NewT(tt) |
| 75 | t.DNS(map[string]mockdns.Zone{ |
| 76 | "one.maddy.test.": { |
| 77 | TXT: []string{"v=spf1 ip4:127.0.0.17 -all"}, |
| 78 | }, |
| 79 | }) |
| 80 | t.Port("smtp") |
| 81 | t.Config(` |
| 82 | smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} { |
| 83 | hostname mx.maddy.test |
| 84 | tls off |
| 85 | |
| 86 | proxy_protocol { |
| 87 | trust ` + tests.DefaultSourceIP.String() + ` ::1/128 |
| 88 | tls off |
| 89 | } |
| 90 | |
| 91 | defer_sender_reject no |
| 92 | |
| 93 | check { |
| 94 | spf { |
| 95 | enforce_early yes |
| 96 | fail_action reject |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | deliver_to dummy |
| 101 | } |
| 102 | `) |
| 103 | t.Run(1) |
| 104 | defer t.Close() |
| 105 | |
| 106 | conn := t.Conn("smtp") |
| 107 | defer conn.Close() |
| 108 | conn.Writeln(fmt.Sprintf("PROXY TCP4 127.0.0.17 %s 12345 %d", tests.DefaultSourceIP.String(), t.Port("smtp"))) |
| 109 | conn.SMTPNegotation("localhost", nil, nil) |
| 110 | conn.Writeln("MAIL FROM:<testing@one.maddy.test>") |
| 111 | conn.ExpectPattern("250 *") |
| 112 | conn.Writeln("QUIT") |
| 113 | conn.ExpectPattern("221 *") |
| 114 | } |
| 115 | |
| 116 | func TestProxyProtocolUntrustedSource(tt *testing.T) { |
| 117 | tt.Parallel() |
nothing calls this directly
no test coverage detected