forked from cerc-io/plugeth
ethstats: work around weird URL scheme parsing issues
This commit is contained in:
parent
1cf2ee4597
commit
db93641941
@ -23,10 +23,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
@ -128,7 +128,7 @@ func (s *Service) loop() {
|
|||||||
path := fmt.Sprintf("%s/api", s.host)
|
path := fmt.Sprintf("%s/api", s.host)
|
||||||
urls := []string{path}
|
urls := []string{path}
|
||||||
|
|
||||||
if parsed, err := url.Parse(path); err == nil && !parsed.IsAbs() {
|
if !strings.Contains(path, "://") { // url.Parse and url.IsAbs is unsuitable (https://github.com/golang/go/issues/19779)
|
||||||
urls = []string{"wss://" + path, "ws://" + path}
|
urls = []string{"wss://" + path, "ws://" + path}
|
||||||
}
|
}
|
||||||
// Establish a websocket connection to the server on any supported URL
|
// Establish a websocket connection to the server on any supported URL
|
||||||
|
Loading…
Reference in New Issue
Block a user