added attach over http/rpc support
This commit is contained in:
committed by
Bas van Kervel
parent
f202563777
commit
ce5c94e471
@@ -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")
|
||||
|
Reference in New Issue
Block a user