Backwards-compatible handling of Engine URLs that don't include a specified protocol
This commit is contained in:
parent
2ee15a38ed
commit
3a35809a02
|
@ -126,6 +126,15 @@ proc parseCmdArg*(T: type EngineApiUrlConfigValue, input: string): T
|
||||||
jwtSecretFile: jwtSecretFile,
|
jwtSecretFile: jwtSecretFile,
|
||||||
roles: roles)
|
roles: roles)
|
||||||
|
|
||||||
|
proc fixupWeb3Urls*(web3Url: var string) =
|
||||||
|
var normalizedUrl = toLowerAscii(web3Url)
|
||||||
|
if not (normalizedUrl.startsWith("https://") or
|
||||||
|
normalizedUrl.startsWith("http://") or
|
||||||
|
normalizedUrl.startsWith("wss://") or
|
||||||
|
normalizedUrl.startsWith("ws://")):
|
||||||
|
warn "The Web3 URL does not specify a protocol. Assuming a WebSocket server", web3Url
|
||||||
|
web3Url = "ws://" & web3Url
|
||||||
|
|
||||||
proc toFinalUrl*(confValue: EngineApiUrlConfigValue,
|
proc toFinalUrl*(confValue: EngineApiUrlConfigValue,
|
||||||
confJwtSecret: Option[seq[byte]]): Result[EngineApiUrl, cstring] =
|
confJwtSecret: Option[seq[byte]]): Result[EngineApiUrl, cstring] =
|
||||||
if confValue.jwtSecret.isSome and confValue.jwtSecretFile.isSome:
|
if confValue.jwtSecret.isSome and confValue.jwtSecretFile.isSome:
|
||||||
|
@ -138,8 +147,11 @@ proc toFinalUrl*(confValue: EngineApiUrlConfigValue,
|
||||||
else:
|
else:
|
||||||
confJwtSecret
|
confJwtSecret
|
||||||
|
|
||||||
|
var url = confValue.url
|
||||||
|
fixupWeb3Urls(url)
|
||||||
|
|
||||||
ok EngineApiUrl.init(
|
ok EngineApiUrl.init(
|
||||||
url = confValue.url,
|
url = url,
|
||||||
jwtSecret = jwtSecret,
|
jwtSecret = jwtSecret,
|
||||||
roles = confValue.roles.get(defaultEngineApiRoles))
|
roles = confValue.roles.get(defaultEngineApiRoles))
|
||||||
|
|
||||||
|
@ -163,12 +175,3 @@ proc toFinalEngineApiUrls*(elUrls: seq[EngineApiUrlConfigValue],
|
||||||
fatal "Invalid EL configuration", err = error
|
fatal "Invalid EL configuration", err = error
|
||||||
quit 1
|
quit 1
|
||||||
result.add engineApiUrl
|
result.add engineApiUrl
|
||||||
|
|
||||||
proc fixupWeb3Urls*(web3Url: var string) =
|
|
||||||
var normalizedUrl = toLowerAscii(web3Url)
|
|
||||||
if not (normalizedUrl.startsWith("https://") or
|
|
||||||
normalizedUrl.startsWith("http://") or
|
|
||||||
normalizedUrl.startsWith("wss://") or
|
|
||||||
normalizedUrl.startsWith("ws://")):
|
|
||||||
warn "The Web3 URL does not specify a protocol. Assuming a WebSocket server", web3Url
|
|
||||||
web3Url = "ws://" & web3Url
|
|
||||||
|
|
Loading…
Reference in New Issue