config: hub.port is optional, allow putting full URL in hub.address field

This commit is contained in:
mappu 2017-11-26 19:54:03 +13:00
parent aacebe5c5f
commit 36f49749ad
2 changed files with 7 additions and 2 deletions

View File

@ -17,7 +17,7 @@ type Config struct {
Hub struct {
Address string `json:"address"`
Port int `json:"port"`
Port int `json:"port,omitempty"`
Tag string `json:"tag"`
}
}

View File

@ -48,8 +48,13 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru
selfUser.ClientTag = this.cfg.Hub.Tag
selfUser.ClientVersion = libnmdc.DEFAULT_CLIENT_VERSION
url := this.cfg.Hub.Address
if this.cfg.Hub.Port == 0 {
url = fmt.Sprintf("%s:%d", this.cfg.Hub.Address, this.cfg.Hub.Port)
}
hco := libnmdc.HubConnectionOptions{
Address: libnmdc.HubAddress(fmt.Sprintf("%s:%d", this.cfg.Hub.Address, this.cfg.Hub.Port)),
Address: libnmdc.HubAddress(url),
Self: selfUser,
NickPassword: Pass,
}