diff options
Diffstat (limited to 'rpc/comms/comms.go')
-rw-r--r-- | rpc/comms/comms.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rpc/comms/comms.go b/rpc/comms/comms.go index 7aa94b1ea..29ad11b3c 100644 --- a/rpc/comms/comms.go +++ b/rpc/comms/comms.go @@ -7,6 +7,8 @@ import ( "fmt" "strings" + "strconv" + "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/rpc/api" @@ -82,7 +84,28 @@ func ClientFromEndpoint(endpoint string, c codec.Codec) (EthereumClient, error) } if strings.HasPrefix(endpoint, "rpc:") { + parts := strings.Split(endpoint, ":") + addr := "http://localhost" + port := uint(8545) + if len(parts) >= 3 { + addr = parts[1] + ":" + parts[2] + } + + if len(parts) >= 4 { + p, err := strconv.Atoi(parts[3]) + + if err != nil { + return nil, err + } + port = uint(p) + } + + cfg := HttpConfig{ + ListenAddress: addr, + ListenPort: port, + } + return NewHttpClient(cfg, codec.JSON), nil } return nil, fmt.Errorf("Invalid endpoint") |