[#179] resolver: Support wss
connection scheme in NNS.Dial
WebSocket Secure scheme should also lead to using `neoclient.WSClient` by `NNS`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
d51d18d5f3
commit
9c502a9cae
1 changed files with 3 additions and 2 deletions
|
@ -54,7 +54,8 @@ func (x *neoWebSocket) call(contract util.Uint160, method string, prm []smartcon
|
||||||
// Dial connects to the address of the NNS server. If fails, the instance
|
// Dial connects to the address of the NNS server. If fails, the instance
|
||||||
// MUST NOT be used.
|
// MUST NOT be used.
|
||||||
//
|
//
|
||||||
// If URL address scheme is 'ws', then WebSocket protocol is used, otherwise HTTP.
|
// If URL address scheme is 'ws' or 'wss', then WebSocket protocol is used,
|
||||||
|
// otherwise HTTP.
|
||||||
func (n *NNS) Dial(address string) error {
|
func (n *NNS) Dial(address string) error {
|
||||||
// multiSchemeClient unites neoClient and common interface of
|
// multiSchemeClient unites neoClient and common interface of
|
||||||
// neoclient.Client and neoclient.WSClient. Interface is anonymous
|
// neoclient.Client and neoclient.WSClient. Interface is anonymous
|
||||||
|
@ -69,7 +70,7 @@ func (n *NNS) Dial(address string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
uri, err := url.Parse(address)
|
uri, err := url.Parse(address)
|
||||||
if err == nil && uri.Scheme == "ws" {
|
if err == nil && (uri.Scheme == "ws" || uri.Scheme == "wss") {
|
||||||
cWebSocket, err := neoclient.NewWS(context.Background(), address, neoclient.Options{})
|
cWebSocket, err := neoclient.NewWS(context.Background(), address, neoclient.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("create Neo WebSocket client: %w", err)
|
return fmt.Errorf("create Neo WebSocket client: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue