|
|
|
@ -59,31 +59,31 @@ var ( |
|
|
|
|
|
|
|
|
|
//constants for environment variables
|
|
|
|
|
const ( |
|
|
|
|
SWARM_ENV_CHEQUEBOOK_ADDR = "SWARM_CHEQUEBOOK_ADDR" |
|
|
|
|
SWARM_ENV_ACCOUNT = "SWARM_ACCOUNT" |
|
|
|
|
SWARM_ENV_LISTEN_ADDR = "SWARM_LISTEN_ADDR" |
|
|
|
|
SWARM_ENV_PORT = "SWARM_PORT" |
|
|
|
|
SWARM_ENV_NETWORK_ID = "SWARM_NETWORK_ID" |
|
|
|
|
SWARM_ENV_SWAP_ENABLE = "SWARM_SWAP_ENABLE" |
|
|
|
|
SWARM_ENV_SWAP_API = "SWARM_SWAP_API" |
|
|
|
|
SWARM_ENV_SYNC_DISABLE = "SWARM_SYNC_DISABLE" |
|
|
|
|
SWARM_ENV_SYNC_UPDATE_DELAY = "SWARM_ENV_SYNC_UPDATE_DELAY" |
|
|
|
|
SWARM_ENV_MAX_STREAM_PEER_SERVERS = "SWARM_ENV_MAX_STREAM_PEER_SERVERS" |
|
|
|
|
SWARM_ENV_LIGHT_NODE_ENABLE = "SWARM_LIGHT_NODE_ENABLE" |
|
|
|
|
SWARM_ENV_DELIVERY_SKIP_CHECK = "SWARM_DELIVERY_SKIP_CHECK" |
|
|
|
|
SWARM_ENV_ENS_API = "SWARM_ENS_API" |
|
|
|
|
SWARM_ENV_ENS_ADDR = "SWARM_ENS_ADDR" |
|
|
|
|
SWARM_ENV_CORS = "SWARM_CORS" |
|
|
|
|
SWARM_ENV_BOOTNODES = "SWARM_BOOTNODES" |
|
|
|
|
SWARM_ENV_PSS_ENABLE = "SWARM_PSS_ENABLE" |
|
|
|
|
SWARM_ENV_STORE_PATH = "SWARM_STORE_PATH" |
|
|
|
|
SWARM_ENV_STORE_CAPACITY = "SWARM_STORE_CAPACITY" |
|
|
|
|
SWARM_ENV_STORE_CACHE_CAPACITY = "SWARM_STORE_CACHE_CAPACITY" |
|
|
|
|
SWARM_ENV_BOOTNODE_MODE = "SWARM_BOOTNODE_MODE" |
|
|
|
|
SWARM_ACCESS_PASSWORD = "SWARM_ACCESS_PASSWORD" |
|
|
|
|
SWARM_AUTO_DEFAULTPATH = "SWARM_AUTO_DEFAULTPATH" |
|
|
|
|
SWARM_GLOBALSTORE_API = "SWARM_GLOBALSTORE_API" |
|
|
|
|
GETH_ENV_DATADIR = "GETH_DATADIR" |
|
|
|
|
SwarmEnvChequebookAddr = "SWARM_CHEQUEBOOK_ADDR" |
|
|
|
|
SwarmEnvAccount = "SWARM_ACCOUNT" |
|
|
|
|
SwarmEnvListenAddr = "SWARM_LISTEN_ADDR" |
|
|
|
|
SwarmEnvPort = "SWARM_PORT" |
|
|
|
|
SwarmEnvNetworkID = "SWARM_NETWORK_ID" |
|
|
|
|
SwarmEnvSwapEnable = "SWARM_SWAP_ENABLE" |
|
|
|
|
SwarmEnvSwapAPI = "SWARM_SWAP_API" |
|
|
|
|
SwarmEnvSyncDisable = "SWARM_SYNC_DISABLE" |
|
|
|
|
SwarmEnvSyncUpdateDelay = "SWARM_ENV_SYNC_UPDATE_DELAY" |
|
|
|
|
SwarmEnvMaxStreamPeerServers = "SWARM_ENV_MAX_STREAM_PEER_SERVERS" |
|
|
|
|
SwarmEnvLightNodeEnable = "SWARM_LIGHT_NODE_ENABLE" |
|
|
|
|
SwarmEnvDeliverySkipCheck = "SWARM_DELIVERY_SKIP_CHECK" |
|
|
|
|
SwarmEnvENSAPI = "SWARM_ENS_API" |
|
|
|
|
SwarmEnvENSAddr = "SWARM_ENS_ADDR" |
|
|
|
|
SwarmEnvCORS = "SWARM_CORS" |
|
|
|
|
SwarmEnvBootnodes = "SWARM_BOOTNODES" |
|
|
|
|
SwarmEnvPSSEnable = "SWARM_PSS_ENABLE" |
|
|
|
|
SwarmEnvStorePath = "SWARM_STORE_PATH" |
|
|
|
|
SwarmEnvStoreCapacity = "SWARM_STORE_CAPACITY" |
|
|
|
|
SwarmEnvStoreCacheCapacity = "SWARM_STORE_CACHE_CAPACITY" |
|
|
|
|
SwarmEnvBootnodeMode = "SWARM_BOOTNODE_MODE" |
|
|
|
|
SwarmAccessPassword = "SWARM_ACCESS_PASSWORD" |
|
|
|
|
SwarmAutoDefaultPath = "SWARM_AUTO_DEFAULTPATH" |
|
|
|
|
SwarmGlobalstoreAPI = "SWARM_GLOBALSTORE_API" |
|
|
|
|
GethEnvDataDir = "GETH_DATADIR" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// These settings ensure that TOML keys use the same names as Go struct fields.
|
|
|
|
@ -227,7 +227,7 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con |
|
|
|
|
|
|
|
|
|
currentConfig.SwapAPI = ctx.GlobalString(SwarmSwapAPIFlag.Name) |
|
|
|
|
if currentConfig.SwapEnabled && currentConfig.SwapAPI == "" { |
|
|
|
|
utils.Fatalf(SWARM_ERR_SWAP_SET_NO_API) |
|
|
|
|
utils.Fatalf(SwarmErrSwapSetNoAPI) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ctx.GlobalIsSet(EnsAPIFlag.Name) { |
|
|
|
@ -274,113 +274,113 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con |
|
|
|
|
// envVarsOverride overrides the current config with whatver is provided in environment variables
|
|
|
|
|
// most values are not allowed a zero value (empty string), if not otherwise noted
|
|
|
|
|
func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) { |
|
|
|
|
if keyid := os.Getenv(SWARM_ENV_ACCOUNT); keyid != "" { |
|
|
|
|
if keyid := os.Getenv(SwarmEnvAccount); keyid != "" { |
|
|
|
|
currentConfig.BzzAccount = keyid |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if chbookaddr := os.Getenv(SWARM_ENV_CHEQUEBOOK_ADDR); chbookaddr != "" { |
|
|
|
|
if chbookaddr := os.Getenv(SwarmEnvChequebookAddr); chbookaddr != "" { |
|
|
|
|
currentConfig.Contract = common.HexToAddress(chbookaddr) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if networkid := os.Getenv(SWARM_ENV_NETWORK_ID); networkid != "" { |
|
|
|
|
if networkid := os.Getenv(SwarmEnvNetworkID); networkid != "" { |
|
|
|
|
id, err := strconv.ParseUint(networkid, 10, 64) |
|
|
|
|
if err != nil { |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_NETWORK_ID, err) |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvNetworkID, err) |
|
|
|
|
} |
|
|
|
|
if id != 0 { |
|
|
|
|
currentConfig.NetworkID = id |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if datadir := os.Getenv(GETH_ENV_DATADIR); datadir != "" { |
|
|
|
|
if datadir := os.Getenv(GethEnvDataDir); datadir != "" { |
|
|
|
|
currentConfig.Path = expandPath(datadir) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bzzport := os.Getenv(SWARM_ENV_PORT) |
|
|
|
|
bzzport := os.Getenv(SwarmEnvPort) |
|
|
|
|
if len(bzzport) > 0 { |
|
|
|
|
currentConfig.Port = bzzport |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if bzzaddr := os.Getenv(SWARM_ENV_LISTEN_ADDR); bzzaddr != "" { |
|
|
|
|
if bzzaddr := os.Getenv(SwarmEnvListenAddr); bzzaddr != "" { |
|
|
|
|
currentConfig.ListenAddr = bzzaddr |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if swapenable := os.Getenv(SWARM_ENV_SWAP_ENABLE); swapenable != "" { |
|
|
|
|
if swapenable := os.Getenv(SwarmEnvSwapEnable); swapenable != "" { |
|
|
|
|
swap, err := strconv.ParseBool(swapenable) |
|
|
|
|
if err != nil { |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SWAP_ENABLE, err) |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSwapEnable, err) |
|
|
|
|
} |
|
|
|
|
currentConfig.SwapEnabled = swap |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if syncdisable := os.Getenv(SWARM_ENV_SYNC_DISABLE); syncdisable != "" { |
|
|
|
|
if syncdisable := os.Getenv(SwarmEnvSyncDisable); syncdisable != "" { |
|
|
|
|
sync, err := strconv.ParseBool(syncdisable) |
|
|
|
|
if err != nil { |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SYNC_DISABLE, err) |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSyncDisable, err) |
|
|
|
|
} |
|
|
|
|
currentConfig.SyncEnabled = !sync |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if v := os.Getenv(SWARM_ENV_DELIVERY_SKIP_CHECK); v != "" { |
|
|
|
|
if v := os.Getenv(SwarmEnvDeliverySkipCheck); v != "" { |
|
|
|
|
skipCheck, err := strconv.ParseBool(v) |
|
|
|
|
if err != nil { |
|
|
|
|
currentConfig.DeliverySkipCheck = skipCheck |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if v := os.Getenv(SWARM_ENV_SYNC_UPDATE_DELAY); v != "" { |
|
|
|
|
if v := os.Getenv(SwarmEnvSyncUpdateDelay); v != "" { |
|
|
|
|
d, err := time.ParseDuration(v) |
|
|
|
|
if err != nil { |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SYNC_UPDATE_DELAY, err) |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSyncUpdateDelay, err) |
|
|
|
|
} |
|
|
|
|
currentConfig.SyncUpdateDelay = d |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if max := os.Getenv(SWARM_ENV_MAX_STREAM_PEER_SERVERS); max != "" { |
|
|
|
|
if max := os.Getenv(SwarmEnvMaxStreamPeerServers); max != "" { |
|
|
|
|
m, err := strconv.Atoi(max) |
|
|
|
|
if err != nil { |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_MAX_STREAM_PEER_SERVERS, err) |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvMaxStreamPeerServers, err) |
|
|
|
|
} |
|
|
|
|
currentConfig.MaxStreamPeerServers = m |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if lne := os.Getenv(SWARM_ENV_LIGHT_NODE_ENABLE); lne != "" { |
|
|
|
|
if lne := os.Getenv(SwarmEnvLightNodeEnable); lne != "" { |
|
|
|
|
lightnode, err := strconv.ParseBool(lne) |
|
|
|
|
if err != nil { |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_LIGHT_NODE_ENABLE, err) |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvLightNodeEnable, err) |
|
|
|
|
} |
|
|
|
|
currentConfig.LightNodeEnabled = lightnode |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if swapapi := os.Getenv(SWARM_ENV_SWAP_API); swapapi != "" { |
|
|
|
|
if swapapi := os.Getenv(SwarmEnvSwapAPI); swapapi != "" { |
|
|
|
|
currentConfig.SwapAPI = swapapi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if currentConfig.SwapEnabled && currentConfig.SwapAPI == "" { |
|
|
|
|
utils.Fatalf(SWARM_ERR_SWAP_SET_NO_API) |
|
|
|
|
utils.Fatalf(SwarmErrSwapSetNoAPI) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ensapi := os.Getenv(SWARM_ENV_ENS_API); ensapi != "" { |
|
|
|
|
if ensapi := os.Getenv(SwarmEnvENSAPI); ensapi != "" { |
|
|
|
|
currentConfig.EnsAPIs = strings.Split(ensapi, ",") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ensaddr := os.Getenv(SWARM_ENV_ENS_ADDR); ensaddr != "" { |
|
|
|
|
if ensaddr := os.Getenv(SwarmEnvENSAddr); ensaddr != "" { |
|
|
|
|
currentConfig.EnsRoot = common.HexToAddress(ensaddr) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if cors := os.Getenv(SWARM_ENV_CORS); cors != "" { |
|
|
|
|
if cors := os.Getenv(SwarmEnvCORS); cors != "" { |
|
|
|
|
currentConfig.Cors = cors |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if bm := os.Getenv(SWARM_ENV_BOOTNODE_MODE); bm != "" { |
|
|
|
|
if bm := os.Getenv(SwarmEnvBootnodeMode); bm != "" { |
|
|
|
|
bootnodeMode, err := strconv.ParseBool(bm) |
|
|
|
|
if err != nil { |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_BOOTNODE_MODE, err) |
|
|
|
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvBootnodeMode, err) |
|
|
|
|
} |
|
|
|
|
currentConfig.BootnodeMode = bootnodeMode |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if api := os.Getenv(SWARM_GLOBALSTORE_API); api != "" { |
|
|
|
|
if api := os.Getenv(SwarmGlobalstoreAPI); api != "" { |
|
|
|
|
currentConfig.GlobalStoreAPI = api |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|