From 36f49749ad7bbdcd4fa7eb95b3f0b31e335da776 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 26 Nov 2017 19:54:03 +1300 Subject: [PATCH] config: hub.port is optional, allow putting full URL in hub.address field --- Config.go | 2 +- main.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Config.go b/Config.go index 86d1ee0..0cdb1fb 100644 --- a/Config.go +++ b/Config.go @@ -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"` } } diff --git a/main.go b/main.go index ef228b5..87f7eb3 100644 --- a/main.go +++ b/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.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, }