Commit 35b3db25 authored by Mikio Hara's avatar Mikio Hara

net: add lookup IP hook for testing

This change adds testHookLookIP to enable to inject DNS name to IP
address mappings for Happ{y,yish,ier} Eyeballs dial testing.

Change-Id: I8ac04a594e1e2bd77909528df0552889914a7790
Reviewed-on: https://go-review.googlesource.com/8399Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent bec4481d
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
var testHookLookupIP = func(fn func(string) ([]IPAddr, error), host string) ([]IPAddr, error) { return fn(host) }
......@@ -46,7 +46,7 @@ var lookupGroup singleflight
// is always owned by the caller.
func lookupIPMerge(host string) (addrs []IPAddr, err error) {
addrsi, err, shared := lookupGroup.Do(host, func() (interface{}, error) {
return lookupIP(host)
return testHookLookupIP(lookupIP, host)
})
return lookupIPReturn(addrsi, err, shared)
}
......@@ -84,7 +84,7 @@ func lookupIPDeadline(host string, deadline time.Time) (addrs []IPAddr, err erro
defer t.Stop()
ch := lookupGroup.DoChan(host, func() (interface{}, error) {
return lookupIP(host)
return testHookLookupIP(lookupIP, host)
})
select {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment