summaryrefslogtreecommitdiff
path: root/tcpproxy_test.go
diff options
context:
space:
mode:
authorNathan Johnson <[email protected]>2018-06-07 17:11:22 -0500
committerBrad Fitzpatrick <[email protected]>2018-06-07 15:11:22 -0700
commitdbc151467a20b4513174bb3d6b1283e9419eb0f9 (patch)
tree3ee70fb558b3c4ec256dbb030eb069699dd40c84 /tcpproxy_test.go
parent2b928d9b07d782cc1a94736979d012792810658f (diff)
Adding the HostName field to the Conn struct (#18)
Changing the internal-only match interface to return any parsed hostnames. It can be useful for implementers of Target to be able to inspect the already-parsed SNI header (in the case of TLS) or host header (in the case of http) to know what host was asked for by the client in order to make additional routing decisions. This can be used by transparent reverse proxies where the destination is not known in advance.
Diffstat (limited to 'tcpproxy_test.go')
-rw-r--r--tcpproxy_test.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/tcpproxy_test.go b/tcpproxy_test.go
index 682214d..83729e3 100644
--- a/tcpproxy_test.go
+++ b/tcpproxy_test.go
@@ -72,10 +72,14 @@ func TestMatchHTTPHost(t *testing.T) {
t.Run(name, func(t *testing.T) {
br := bufio.NewReader(tt.r)
r := httpHostMatch{equals(tt.host), noopTarget{}}
- got := r.match(br) != nil
+ m, name := r.match(br)
+ got := m != nil
if got != tt.want {
t.Fatalf("match = %v; want %v", got, tt.want)
}
+ if tt.want && name != tt.host {
+ t.Fatalf("host = %s; want %s", name, tt.host)
+ }
get := make([]byte, 3)
if _, err := io.ReadFull(br, get); err != nil {
t.Fatal(err)