aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorRalph Caraveo III <deckarep@gmail.com>2018-07-16 15:54:19 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-07-16 15:54:19 +0800
commit5d30be412b0f9181cb007c8893ee583ee4319116 (patch)
tree4593b259665d22c552cc869f08317305119a99e0 /rpc
parenteb7f901289dce3f9fe3341da8c0b938ea839f79d (diff)
downloaddexon-5d30be412b0f9181cb007c8893ee583ee4319116.tar.gz
dexon-5d30be412b0f9181cb007c8893ee583ee4319116.tar.zst
dexon-5d30be412b0f9181cb007c8893ee583ee4319116.zip
all: switch out defunct set library to different one (#16873)
* keystore, ethash, eth, miner, rpc, whisperv6: tech debt with now defunct set. * whisperv5: swap out gopkg.in/fatih/set.v0 with supported set
Diffstat (limited to 'rpc')
-rw-r--r--rpc/server.go4
-rw-r--r--rpc/types.go4
-rw-r--r--rpc/websocket.go10
3 files changed, 9 insertions, 9 deletions
diff --git a/rpc/server.go b/rpc/server.go
index 8925419fe..90ffadd25 100644
--- a/rpc/server.go
+++ b/rpc/server.go
@@ -25,8 +25,8 @@ import (
"sync"
"sync/atomic"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/log"
- "gopkg.in/fatih/set.v0"
)
const MetadataApi = "rpc"
@@ -46,7 +46,7 @@ const (
func NewServer() *Server {
server := &Server{
services: make(serviceRegistry),
- codecs: set.New(),
+ codecs: mapset.NewSet(),
run: 1,
}
diff --git a/rpc/types.go b/rpc/types.go
index f2375604e..4252c3602 100644
--- a/rpc/types.go
+++ b/rpc/types.go
@@ -23,8 +23,8 @@ import (
"strings"
"sync"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/common/hexutil"
- "gopkg.in/fatih/set.v0"
)
// API describes the set of methods offered over the RPC interface
@@ -73,7 +73,7 @@ type Server struct {
run int32
codecsMu sync.Mutex
- codecs *set.Set
+ codecs mapset.Set
}
// rpcRequest represents a raw incoming RPC request
diff --git a/rpc/websocket.go b/rpc/websocket.go
index a6e1cec28..e7a86ddae 100644
--- a/rpc/websocket.go
+++ b/rpc/websocket.go
@@ -29,9 +29,9 @@ import (
"strings"
"time"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/log"
"golang.org/x/net/websocket"
- "gopkg.in/fatih/set.v0"
)
// websocketJSONCodec is a custom JSON codec with payload size enforcement and
@@ -84,7 +84,7 @@ func NewWSServer(allowedOrigins []string, srv *Server) *http.Server {
// websocket upgrade process. When a '*' is specified as an allowed origins all
// connections are accepted.
func wsHandshakeValidator(allowedOrigins []string) func(*websocket.Config, *http.Request) error {
- origins := set.New()
+ origins := mapset.NewSet()
allowAllOrigins := false
for _, origin := range allowedOrigins {
@@ -97,18 +97,18 @@ func wsHandshakeValidator(allowedOrigins []string) func(*websocket.Config, *http
}
// allow localhost if no allowedOrigins are specified.
- if len(origins.List()) == 0 {
+ if len(origins.ToSlice()) == 0 {
origins.Add("http://localhost")
if hostname, err := os.Hostname(); err == nil {
origins.Add("http://" + strings.ToLower(hostname))
}
}
- log.Debug(fmt.Sprintf("Allowed origin(s) for WS RPC interface %v\n", origins.List()))
+ log.Debug(fmt.Sprintf("Allowed origin(s) for WS RPC interface %v\n", origins.ToSlice()))
f := func(cfg *websocket.Config, req *http.Request) error {
origin := strings.ToLower(req.Header.Get("Origin"))
- if allowAllOrigins || origins.Has(origin) {
+ if allowAllOrigins || origins.Contains(origin) {
return nil
}
log.Warn(fmt.Sprintf("origin '%s' not allowed on WS-RPC interface\n", origin))