Skip to content

Commit 3e5b77a

Browse files
authored
fix(node): added cli argument --hosturl to register url on zcn (#513)
* fix(node): added cli argument --hosturl to register url on zcn * fix(node): fixed synatx issue
1 parent 4ecc324 commit 3e5b77a

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

code/go/0chain.net/blobber/flags.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var (
2121
httpsPort int
2222
httpsKeyFile string
2323
httpsCertFile string
24+
hostUrl string
2425
)
2526

2627
func init() {
@@ -32,12 +33,14 @@ func init() {
3233
flag.StringVar(&metadataDB, "db_dir", "", "db_dir")
3334
flag.StringVar(&logDir, "log_dir", "", "log_dir")
3435
flag.IntVar(&httpPort, "port", 0, "port")
35-
flag.IntVar(&httpsPort, "https-port", 0, "https-port")
36-
flag.StringVar(&httpsCertFile, "https-cert-file", "", "https-cert-file")
37-
flag.StringVar(&httpsKeyFile, "https-key-file", "", "https-key-file")
36+
flag.IntVar(&httpsPort, "https_port", 0, "https_port")
37+
flag.StringVar(&httpsCertFile, "https_cert_file", "", "https_cert_file")
38+
flag.StringVar(&httpsKeyFile, "https_key_file", "", "https_key_file")
3839
flag.StringVar(&hostname, "hostname", "", "hostname")
3940
flag.StringVar(&configDir, "config_dir", "./config", "config_dir")
4041

42+
flag.StringVar(&hostUrl, "hosturl", "", "register url on blockchain instead of [schema://hostname+port] if it has value")
43+
4144
flag.IntVar(&grpcPort, "grpc_port", 0, "grpc_port")
4245
}
4346

code/go/0chain.net/blobber/node.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ func setupNode() error {
3030
logging.Logger.Info("self identity", zap.Any("id", node.Self.ID))
3131
}
3232

33-
if httpsPort > 0 {
34-
node.Self.SetHostURL("https", hostname, httpsPort)
33+
if len(hostUrl) > 0 {
34+
node.Self.URL = hostUrl
3535
} else {
36-
node.Self.SetHostURL("http", hostname, httpPort)
36+
if httpsPort > 0 {
37+
node.Self.SetHostURL("https", hostname, httpsPort)
38+
} else {
39+
node.Self.SetHostURL("http", hostname, httpPort)
40+
}
3741
}
3842

3943
logging.Logger.Info(" Base URL" + node.Self.GetURLBase())

0 commit comments

Comments
 (0)