allow setting advertise address
This commit is contained in:
parent
cdbab3df66
commit
05e62a2b95
@ -86,11 +86,17 @@ func newNetwork(opts ...Option) Network {
|
|||||||
tun.WithTunnel(options.Tunnel),
|
tun.WithTunnel(options.Tunnel),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// set the address to advertise
|
||||||
|
address := options.Address
|
||||||
|
if len(options.Advertise) > 0 {
|
||||||
|
address = options.Advertise
|
||||||
|
}
|
||||||
|
|
||||||
// server is network server
|
// server is network server
|
||||||
server := server.NewServer(
|
server := server.NewServer(
|
||||||
server.Id(options.Id),
|
server.Id(options.Id),
|
||||||
server.Address(options.Id),
|
server.Address(options.Id),
|
||||||
server.Advertise(options.Address),
|
server.Advertise(address),
|
||||||
server.Name(options.Name),
|
server.Name(options.Name),
|
||||||
server.Transport(tunTransport),
|
server.Transport(tunTransport),
|
||||||
)
|
)
|
||||||
@ -108,7 +114,7 @@ func newNetwork(opts ...Option) Network {
|
|||||||
network := &network{
|
network := &network{
|
||||||
node: &node{
|
node: &node{
|
||||||
id: options.Id,
|
id: options.Id,
|
||||||
address: options.Address,
|
address: address,
|
||||||
peers: make(map[string]*node),
|
peers: make(map[string]*node),
|
||||||
},
|
},
|
||||||
options: options,
|
options: options,
|
||||||
|
@ -20,6 +20,8 @@ type Options struct {
|
|||||||
Name string
|
Name string
|
||||||
// Address to bind to
|
// Address to bind to
|
||||||
Address string
|
Address string
|
||||||
|
// Advertise sets the address to advertise
|
||||||
|
Advertise string
|
||||||
// Nodes is a list of seed nodes
|
// Nodes is a list of seed nodes
|
||||||
Nodes []string
|
Nodes []string
|
||||||
// Tunnel is network tunnel
|
// Tunnel is network tunnel
|
||||||
@ -53,6 +55,13 @@ func Address(a string) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Advertise sets the address to advertise
|
||||||
|
func Advertise(a string) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.Advertise = a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Nodes is a list of seed nodes used along
|
// Nodes is a list of seed nodes used along
|
||||||
// with resolved node
|
// with resolved node
|
||||||
func Nodes(n ...string) Option {
|
func Nodes(n ...string) Option {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user