support multiple network interfaces
This commit is contained in:
@ -93,11 +93,6 @@ func ParseChain(cfg *config.ChainConfig) (chain.Chainer, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tr := (&chain.Transport{}).
|
||||
WithConnector(cr).
|
||||
WithDialer(d).
|
||||
WithAddr(v.Addr)
|
||||
|
||||
if v.Bypass == "" {
|
||||
v.Bypass = hop.Bypass
|
||||
}
|
||||
@ -107,15 +102,24 @@ func ParseChain(cfg *config.ChainConfig) (chain.Chainer, error) {
|
||||
if v.Hosts == "" {
|
||||
v.Hosts = hop.Hosts
|
||||
}
|
||||
if v.Interface == "" {
|
||||
v.Interface = hop.Interface
|
||||
}
|
||||
|
||||
tr := (&chain.Transport{}).
|
||||
WithConnector(cr).
|
||||
WithDialer(d).
|
||||
WithAddr(v.Addr).
|
||||
WithInterface(v.Interface)
|
||||
|
||||
node := &chain.Node{
|
||||
Name: v.Name,
|
||||
Addr: v.Addr,
|
||||
Transport: tr,
|
||||
Bypass: registry.BypassRegistry().Get(v.Bypass),
|
||||
Resolver: registry.ResolverRegistry().Get(v.Resolver),
|
||||
Hosts: registry.HostsRegistry().Get(v.Hosts),
|
||||
Marker: &chain.FailMarker{},
|
||||
Transport: tr,
|
||||
}
|
||||
group.AddNode(node)
|
||||
}
|
||||
|
@ -88,14 +88,21 @@ func ParseService(cfg *config.ServiceConfig) (service.Service, error) {
|
||||
if cfg.Handler.Auther != "" {
|
||||
auther = registry.AutherRegistry().Get(cfg.Handler.Auther)
|
||||
}
|
||||
|
||||
router := (&chain.Router{}).
|
||||
WithRetries(cfg.Handler.Retries).
|
||||
// WithTimeout(timeout time.Duration).
|
||||
WithInterface(cfg.Interface).
|
||||
WithChain(registry.ChainRegistry().Get(cfg.Handler.Chain)).
|
||||
WithResolver(registry.ResolverRegistry().Get(cfg.Resolver)).
|
||||
WithHosts(registry.HostsRegistry().Get(cfg.Hosts)).
|
||||
WithLogger(handlerLogger)
|
||||
|
||||
h := registry.HandlerRegistry().Get(cfg.Handler.Type)(
|
||||
handler.RouterOption(router),
|
||||
handler.AutherOption(auther),
|
||||
handler.AuthOption(parseAuth(cfg.Handler.Auth)),
|
||||
handler.RetriesOption(cfg.Handler.Retries),
|
||||
handler.ChainOption(registry.ChainRegistry().Get(cfg.Handler.Chain)),
|
||||
handler.BypassOption(registry.BypassRegistry().Get(cfg.Bypass)),
|
||||
handler.ResolverOption(registry.ResolverRegistry().Get(cfg.Resolver)),
|
||||
handler.HostsOption(registry.HostsRegistry().Get(cfg.Hosts)),
|
||||
handler.TLSConfigOption(tlsConfig),
|
||||
handler.LoggerOption(handlerLogger),
|
||||
)
|
||||
|
Reference in New Issue
Block a user