Skip to content

Commit

Permalink
Added network config url to config
Browse files Browse the repository at this point in the history
  • Loading branch information
xssnick committed Feb 24, 2023
1 parent 5ca0723 commit 113821b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ import (
)

type Config struct {
ProxyPass string `json:"proxy_pass"`
PrivateKey []byte `json:"private_key"`
ExternalIP string `json:"external_ip"`
ListenIP string `json:"listen_ip"`
Port uint16 `json:"port"`
ProxyPass string `json:"proxy_pass"`
PrivateKey []byte `json:"private_key"`
ExternalIP string `json:"external_ip"`
ListenIP string `json:"listen_ip"`
NetworkConfigURL string `json:"network_config_url"`
Port uint16 `json:"port"`
}

var FlagDomain = flag.String("domain", "", "domain to configure")
Expand Down Expand Up @@ -67,7 +68,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

netCfg, err := liteclient.GetConfigFromUrl(ctx, "https://ton-blockchain.github.io/global.config.json")
netCfg, err := liteclient.GetConfigFromUrl(ctx, cfg.NetworkConfigURL)
if err != nil {
panic("failed to load network config: " + err.Error())
}
Expand Down Expand Up @@ -161,6 +162,7 @@ func loadConfig() (*Config, error) {
return nil, err
}
cfg.PrivateKey = srvKey.Seed()
cfg.NetworkConfigURL = "https://ton-blockchain.github.io/global.config.json"

cfg.ExternalIP, err = getPublicIP()
if err != nil {
Expand Down Expand Up @@ -191,6 +193,11 @@ func loadConfig() (*Config, error) {
return nil, err
}

// backwards compatibility with old configs
if cfg.NetworkConfigURL == "" {
cfg.NetworkConfigURL = "https://ton-blockchain.github.io/global.config.json"
}

return &cfg, nil
}

Expand Down

0 comments on commit 113821b

Please sign in to comment.