added attach over http/rpc support

This commit is contained in:
Bas van Kervel
2015-06-19 12:32:40 +02:00
committed by Bas van Kervel
parent f202563777
commit ce5c94e471
3 changed files with 134 additions and 6 deletions

View File

@@ -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")