config: hub.port is optional, allow putting full URL in hub.address field
This commit is contained in:
parent
aacebe5c5f
commit
36f49749ad
@ -17,7 +17,7 @@ type Config struct {
|
|||||||
|
|
||||||
Hub struct {
|
Hub struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port,omitempty"`
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
main.go
7
main.go
@ -48,8 +48,13 @@ func (this *App) HubWorker(Nick, Pass string, so socketio.Socket, done chan stru
|
|||||||
selfUser.ClientTag = this.cfg.Hub.Tag
|
selfUser.ClientTag = this.cfg.Hub.Tag
|
||||||
selfUser.ClientVersion = libnmdc.DEFAULT_CLIENT_VERSION
|
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{
|
hco := libnmdc.HubConnectionOptions{
|
||||||
Address: libnmdc.HubAddress(fmt.Sprintf("%s:%d", this.cfg.Hub.Address, this.cfg.Hub.Port)),
|
Address: libnmdc.HubAddress(url),
|
||||||
Self: selfUser,
|
Self: selfUser,
|
||||||
NickPassword: Pass,
|
NickPassword: Pass,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user