allow setting advertise address

This commit is contained in:
Asim Aslam
2019-09-18 18:56:02 +01:00
parent cdbab3df66
commit 05e62a2b95
2 changed files with 17 additions and 2 deletions

View File

@@ -86,11 +86,17 @@ func newNetwork(opts ...Option) Network {
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 := server.NewServer(
server.Id(options.Id),
server.Address(options.Id),
server.Advertise(options.Address),
server.Advertise(address),
server.Name(options.Name),
server.Transport(tunTransport),
)
@@ -108,7 +114,7 @@ func newNetwork(opts ...Option) Network {
network := &network{
node: &node{
id: options.Id,
address: options.Address,
address: address,
peers: make(map[string]*node),
},
options: options,