@ -97,14 +97,9 @@ var (
Name : "sync" ,
Name : "sync" ,
Usage : "Swarm Syncing enabled (default true)" ,
Usage : "Swarm Syncing enabled (default true)" ,
}
}
EnsEndpointsFlag = cli . StringSliceFlag {
EnsAPIFlag = cli . StringSliceFlag {
Name : "ens-endpoint" ,
Usage : "ENS API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url" ,
}
EnsAPIFlag = cli . StringFlag {
Name : "ens-api" ,
Name : "ens-api" ,
Usage : "URL of the Ethereum API provider to use for ENS record lookups" ,
Usage : "ENS API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url" ,
Value : node . DefaultIPCEndpoint ( "geth" ) ,
}
}
EnsAddrFlag = cli . StringFlag {
EnsAddrFlag = cli . StringFlag {
Name : "ens-addr" ,
Name : "ens-addr" ,
@ -323,7 +318,6 @@ DEPRECATED: use 'swarm db clean'.
utils . PasswordFileFlag ,
utils . PasswordFileFlag ,
// bzzd-specific flags
// bzzd-specific flags
CorsStringFlag ,
CorsStringFlag ,
EnsEndpointsFlag ,
EnsAPIFlag ,
EnsAPIFlag ,
EnsAddrFlag ,
EnsAddrFlag ,
SwarmConfigPathFlag ,
SwarmConfigPathFlag ,
@ -445,8 +439,7 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
utils . Fatalf ( "SWAP is enabled but --swap-api is not set" )
utils . Fatalf ( "SWAP is enabled but --swap-api is not set" )
}
}
ensEndpoints := ctx . GlobalStringSlice ( EnsEndpointsFlag . Name )
ensAPIs := ctx . GlobalStringSlice ( EnsAPIFlag . Name )
ensapi := ctx . GlobalString ( EnsAPIFlag . Name )
ensAddr := ctx . GlobalString ( EnsAddrFlag . Name )
ensAddr := ctx . GlobalString ( EnsAddrFlag . Name )
cors := ctx . GlobalString ( CorsStringFlag . Name )
cors := ctx . GlobalString ( CorsStringFlag . Name )
@ -462,21 +455,40 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
}
}
ensClientConfigs := [ ] swarm . ENSClientConfig { }
ensClientConfigs := [ ] swarm . ENSClientConfig { }
if ensapi != "" {
switch len ( ensAPIs ) {
case 0 :
ensClientConfigs = append ( ensClientConfigs , swarm . ENSClientConfig {
ensClientConfigs = append ( ensClientConfigs , swarm . ENSClientConfig {
Endpoint : ensap i ,
Endpoint : nod e. DefaultIPCEndpo int ( "geth" ) ,
ContractAddress : ensAddr ,
ContractAddress : ensAddr ,
} )
} )
}
case 1 :
if ensEndpoints != nil {
// Check if only one --ens-api is specified in order to use --ens-addr value
for _ , s := range ensEndpoints {
// to preserve the backward compatibility with single --ens-api flag.
// Multiple
c := parseFlagEnsAPI ( ensAPIs [ 0 ] )
if ensAddr != "" {
// If contract address is specified in both cases, check for conflict.
if c . ContractAddress != "" && ensAddr != c . ContractAddress {
utils . Fatalf ( "--ens-addr flag in conflict with --ens-api flag contract address" )
}
c . ContractAddress = ensAddr
}
ensClientConfigs = append ( ensClientConfigs , c )
default :
// Backward compatibility with single --ens-api flag and --ens-addr is preserved.
// Check for case where multiple --ens-api flags are set with --ens-addr where
// the specified contract address is not clear to which api belongs.
if ensAddr != "" {
utils . Fatalf ( "--ens-addr flag can not be used with multiple --ens-api flags" )
}
for _ , s := range ensAPIs {
if s != "" {
if s != "" {
ensClientConfigs = append ( ensClientConfigs , parseFlagEnsEndpoint ( s ) )
ensClientConfigs = append ( ensClientConfigs , parseFlagEnsAPI ( s ) )
}
}
}
}
}
}
if len ( ensClientConfigs ) == 0 {
if len ( ensClientConfigs ) == 0 {
log . Warn ( "No ENS, please specify non-empty --ens-api or --ens-endpoint to use domain name resolution" )
log . Warn ( "No ENS, please specify non-empty --ens-api to use domain name resolution" )
}
}
return swarm . NewSwarm ( ctx , swapClient , ensClientConfigs , bzzconfig , swapEnabled , syncEnabled , cors )
return swarm . NewSwarm ( ctx , swapClient , ensClientConfigs , bzzconfig , swapEnabled , syncEnabled , cors )
@ -486,7 +498,7 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
}
}
}
}
func parseFlagEnsEndpoint ( s string ) swarm . ENSClientConfig {
func parseFlagEnsAPI ( s string ) swarm . ENSClientConfig {
isAllLetterString := func ( s string ) bool {
isAllLetterString := func ( s string ) bool {
for _ , r := range s {
for _ , r := range s {
if ! unicode . IsLetter ( r ) {
if ! unicode . IsLetter ( r ) {