1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 type recordingProxy struct {
18 func (r *recordingProxy) Dial(network, addr string) (net.Conn, error) {
19 r.addrs = append(r.addrs, addr)
20 return nil, errors.New("recordingProxy")
23 func TestPerHost(t *testing.T) {
24 var def, bypass recordingProxy
25 perHost := NewPerHost(&def, &bypass)
26 perHost.AddFromString("localhost,*.zone,127.0.0.1,10.0.0.1/8,1000::/16")
28 expectedDef := []string{
33 expectedBypass := []string{
42 for _, addr := range expectedDef {
43 perHost.Dial("tcp", addr)
45 for _, addr := range expectedBypass {
46 perHost.Dial("tcp", addr)
49 if !reflect.DeepEqual(expectedDef, def.addrs) {
50 t.Errorf("Hosts which went to the default proxy didn't match. Got %v, want %v", def.addrs, expectedDef)
52 if !reflect.DeepEqual(expectedBypass, bypass.addrs) {
53 t.Errorf("Hosts which went to the bypass proxy didn't match. Got %v, want %v", bypass.addrs, expectedBypass)