github.com/sandwich-go/boost@v1.3.29/httputil/dns/option.go (about) 1 package dns 2 3 import ( 4 "context" 5 "net" 6 "time" 7 ) 8 9 type OnLookup func(ctx context.Context, host string, cost time.Duration, ipAddrs []net.IPAddr) 10 11 // defaultDialer 默认的拨号器 12 var defaultDialer = &net.Dialer{ 13 Timeout: 30 * time.Second, 14 KeepAlive: 30 * time.Second, 15 } 16 17 //go:generate optiongen --option_with_struct_name=false --new_func=NewOptions --xconf=true --empty_composite_nil=true --usage_tag_name=usage 18 func OptionsOptionDeclareWithDefault() interface{} { 19 return map[string]interface{}{ 20 "TTL": time.Duration(0), // @MethodComment(Cache过期ttl) 21 "Dialer": (Dialer)(defaultDialer), // @MethodComment(拨号器) 22 "Resolver": (Resolver)(net.DefaultResolver), // @MethodComment(解析器) 23 "Policy": Policy(PolicyFirst), // @MethodComment(拨号策略) 24 "LookupTimeout": time.Duration(3 * time.Second), // @MethodComment(搜索超时) 25 "OnLookup": OnLookup(nil), // @MethodComment(当成功搜索) 26 } 27 }