Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
900e124b
Commit
900e124b
authored
Feb 09, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd, common, node, rpc: rework naming convention to canonical one
parent
7486904b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
115 additions
and
115 deletions
+115
-115
js_test.go
cmd/geth/js_test.go
+2
-2
main.go
cmd/geth/main.go
+3
-3
monitorcmd.go
cmd/geth/monitorcmd.go
+1
-1
usage.go
cmd/geth/usage.go
+1
-1
main.go
cmd/gethrpctest/main.go
+7
-7
client.go
cmd/utils/client.go
+1
-1
flags.go
cmd/utils/flags.go
+26
-26
defaults.go
common/defaults.go
+5
-5
config.go
node/config.go
+50
-50
config_test.go
node/config_test.go
+3
-3
node.go
node/node.go
+12
-12
node_test.go
node/node_test.go
+2
-2
server.go
rpc/server.go
+2
-2
No files found.
cmd/geth/js_test.go
View file @
900e124b
...
...
@@ -96,7 +96,7 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *nod
t
.
Fatal
(
err
)
}
// Create a networkless protocol stack
stack
,
err
:=
node
.
New
(
&
node
.
Config
{
PrivateKey
:
testNodeKey
,
Name
:
"test"
,
NoDiscovery
:
true
,
I
pc
Path
:
fmt
.
Sprintf
(
"geth-test-%d.ipc"
,
rand
.
Int63
())})
stack
,
err
:=
node
.
New
(
&
node
.
Config
{
PrivateKey
:
testNodeKey
,
Name
:
"test"
,
NoDiscovery
:
true
,
I
PC
Path
:
fmt
.
Sprintf
(
"geth-test-%d.ipc"
,
rand
.
Int63
())})
if
err
!=
nil
{
t
.
Fatalf
(
"failed to create node: %v"
,
err
)
}
...
...
@@ -142,7 +142,7 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *nod
stack
.
Service
(
&
ethereum
)
assetPath
:=
filepath
.
Join
(
os
.
Getenv
(
"GOPATH"
),
"src"
,
"github.com"
,
"ethereum"
,
"go-ethereum"
,
"cmd"
,
"mist"
,
"assets"
,
"ext"
)
client
,
err
:=
utils
.
NewRemoteRPCClientFromString
(
"ipc:"
+
stack
.
I
pc
Endpoint
())
client
,
err
:=
utils
.
NewRemoteRPCClientFromString
(
"ipc:"
+
stack
.
I
PC
Endpoint
())
if
err
!=
nil
{
t
.
Fatalf
(
"failed to attach to node: %v"
,
err
)
}
...
...
cmd/geth/main.go
View file @
900e124b
...
...
@@ -312,7 +312,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
WSListenAddrFlag
,
utils
.
WSPortFlag
,
utils
.
WSApiFlag
,
utils
.
WS
CORSDomain
Flag
,
utils
.
WS
AllowedDomains
Flag
,
utils
.
IPCDisabledFlag
,
utils
.
IPCApiFlag
,
utils
.
IPCPathFlag
,
...
...
@@ -425,7 +425,7 @@ func console(ctx *cli.Context) {
startNode
(
ctx
,
node
)
// Attach to the newly started node, and either execute script or become interactive
client
,
err
:=
utils
.
NewRemoteRPCClientFromString
(
"ipc:"
+
node
.
I
pc
Endpoint
())
client
,
err
:=
utils
.
NewRemoteRPCClientFromString
(
"ipc:"
+
node
.
I
PC
Endpoint
())
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to attach to the inproc geth: %v"
,
err
)
}
...
...
@@ -451,7 +451,7 @@ func execScripts(ctx *cli.Context) {
startNode
(
ctx
,
node
)
// Attach to the newly started node and execute the given scripts
client
,
err
:=
utils
.
NewRemoteRPCClientFromString
(
"ipc:"
+
node
.
I
pc
Endpoint
())
client
,
err
:=
utils
.
NewRemoteRPCClientFromString
(
"ipc:"
+
node
.
I
PC
Endpoint
())
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to attach to the inproc geth: %v"
,
err
)
}
...
...
cmd/geth/monitorcmd.go
View file @
900e124b
...
...
@@ -36,7 +36,7 @@ import (
var
(
monitorCommandAttachFlag
=
cli
.
StringFlag
{
Name
:
"attach"
,
Value
:
"ipc:"
+
node
.
DefaultI
pc
Endpoint
(),
Value
:
"ipc:"
+
node
.
DefaultI
PC
Endpoint
(),
Usage
:
"API endpoint to attach to"
,
}
monitorCommandRowsFlag
=
cli
.
IntFlag
{
...
...
cmd/geth/usage.go
View file @
900e124b
...
...
@@ -93,7 +93,7 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
WSListenAddrFlag
,
utils
.
WSPortFlag
,
utils
.
WSApiFlag
,
utils
.
WS
CORSDomain
Flag
,
utils
.
WS
AllowedDomains
Flag
,
utils
.
IPCDisabledFlag
,
utils
.
IPCApiFlag
,
utils
.
IPCPathFlag
,
...
...
cmd/gethrpctest/main.go
View file @
900e124b
...
...
@@ -93,13 +93,13 @@ func main() {
func
MakeSystemNode
(
keydir
string
,
privkey
string
,
test
*
tests
.
BlockTest
)
(
*
node
.
Node
,
error
)
{
// Create a networkless protocol stack
stack
,
err
:=
node
.
New
(
&
node
.
Config
{
I
pcPath
:
node
.
DefaultIpc
Endpoint
(),
H
ttpHost
:
common
.
DefaultHttp
Host
,
H
ttpPort
:
common
.
DefaultHttp
Port
,
H
ttp
Modules
:
[]
string
{
"admin"
,
"db"
,
"eth"
,
"debug"
,
"miner"
,
"net"
,
"shh"
,
"txpool"
,
"personal"
,
"web3"
},
W
sHost
:
common
.
DefaultWs
Host
,
W
sPort
:
common
.
DefaultWs
Port
,
W
s
Modules
:
[]
string
{
"admin"
,
"db"
,
"eth"
,
"debug"
,
"miner"
,
"net"
,
"shh"
,
"txpool"
,
"personal"
,
"web3"
},
I
PCPath
:
node
.
DefaultIPC
Endpoint
(),
H
TTPHost
:
common
.
DefaultHTTP
Host
,
H
TTPPort
:
common
.
DefaultHTTP
Port
,
H
TTP
Modules
:
[]
string
{
"admin"
,
"db"
,
"eth"
,
"debug"
,
"miner"
,
"net"
,
"shh"
,
"txpool"
,
"personal"
,
"web3"
},
W
SHost
:
common
.
DefaultWS
Host
,
W
SPort
:
common
.
DefaultWS
Port
,
W
S
Modules
:
[]
string
{
"admin"
,
"db"
,
"eth"
,
"debug"
,
"miner"
,
"net"
,
"shh"
,
"txpool"
,
"personal"
,
"web3"
},
NoDiscovery
:
true
,
})
if
err
!=
nil
{
...
...
cmd/utils/client.go
View file @
900e124b
...
...
@@ -33,7 +33,7 @@ func NewRemoteRPCClient(ctx *cli.Context) (rpc.Client, error) {
return
NewRemoteRPCClientFromString
(
endpoint
)
}
// use IPC by default
return
rpc
.
NewIPCClient
(
node
.
DefaultI
pc
Endpoint
())
return
rpc
.
NewIPCClient
(
node
.
DefaultI
PC
Endpoint
())
}
// NewRemoteRPCClientFromString returns a RPC client which connects to the given
...
...
cmd/utils/flags.go
View file @
900e124b
...
...
@@ -232,12 +232,12 @@ var (
RPCListenAddrFlag
=
cli
.
StringFlag
{
Name
:
"rpcaddr"
,
Usage
:
"HTTP-RPC server listening interface"
,
Value
:
common
.
DefaultH
ttp
Host
,
Value
:
common
.
DefaultH
TTP
Host
,
}
RPCPortFlag
=
cli
.
IntFlag
{
Name
:
"rpcport"
,
Usage
:
"HTTP-RPC server listening port"
,
Value
:
common
.
DefaultH
ttp
Port
,
Value
:
common
.
DefaultH
TTP
Port
,
}
RPCCORSDomainFlag
=
cli
.
StringFlag
{
Name
:
"rpccorsdomain"
,
...
...
@@ -247,7 +247,7 @@ var (
RPCApiFlag
=
cli
.
StringFlag
{
Name
:
"rpcapi"
,
Usage
:
"API's offered over the HTTP-RPC interface"
,
Value
:
rpc
.
DefaultH
ttpRpc
Apis
,
Value
:
rpc
.
DefaultH
TTP
Apis
,
}
IPCDisabledFlag
=
cli
.
BoolFlag
{
Name
:
"ipcdisable"
,
...
...
@@ -256,12 +256,12 @@ var (
IPCApiFlag
=
cli
.
StringFlag
{
Name
:
"ipcapi"
,
Usage
:
"API's offered over the IPC-RPC interface"
,
Value
:
rpc
.
DefaultI
pc
Apis
,
Value
:
rpc
.
DefaultI
PC
Apis
,
}
IPCPathFlag
=
DirectoryFlag
{
Name
:
"ipcpath"
,
Usage
:
"Filename for IPC socket/pipe within the datadir (explicit paths escape it)"
,
Value
:
DirectoryString
{
common
.
DefaultI
pc
Socket
},
Value
:
DirectoryString
{
common
.
DefaultI
PC
Socket
},
}
WSEnabledFlag
=
cli
.
BoolFlag
{
Name
:
"ws"
,
...
...
@@ -270,21 +270,21 @@ var (
WSListenAddrFlag
=
cli
.
StringFlag
{
Name
:
"wsaddr"
,
Usage
:
"WS-RPC server listening interface"
,
Value
:
common
.
DefaultW
s
Host
,
Value
:
common
.
DefaultW
S
Host
,
}
WSPortFlag
=
cli
.
IntFlag
{
Name
:
"wsport"
,
Usage
:
"WS-RPC server listening port"
,
Value
:
common
.
DefaultW
s
Port
,
Value
:
common
.
DefaultW
S
Port
,
}
WSApiFlag
=
cli
.
StringFlag
{
Name
:
"wsapi"
,
Usage
:
"API's offered over the WS-RPC interface"
,
Value
:
rpc
.
DefaultH
ttpRpc
Apis
,
Value
:
rpc
.
DefaultH
TTP
Apis
,
}
WS
CORSDomain
Flag
=
cli
.
StringFlag
{
Name
:
"ws
corsdomain
"
,
Usage
:
"Domains from which to accept websockets requests"
,
WS
AllowedDomains
Flag
=
cli
.
StringFlag
{
Name
:
"ws
domains
"
,
Usage
:
"Domains from which to accept websockets requests
(can be spoofed)
"
,
Value
:
""
,
}
ExecFlag
=
cli
.
StringFlag
{
...
...
@@ -393,9 +393,9 @@ func MustMakeDataDir(ctx *cli.Context) string {
return
""
}
// MakeI
pc
Path creates an IPC path configuration from the set command line flags,
// MakeI
PC
Path creates an IPC path configuration from the set command line flags,
// returning an empty string if IPC was explicitly disabled, or the set path.
func
MakeI
pc
Path
(
ctx
*
cli
.
Context
)
string
{
func
MakeI
PC
Path
(
ctx
*
cli
.
Context
)
string
{
if
ctx
.
GlobalBool
(
IPCDisabledFlag
.
Name
)
{
return
""
}
...
...
@@ -481,18 +481,18 @@ func MakeNAT(ctx *cli.Context) nat.Interface {
return
natif
}
// MakeH
ttp
RpcHost creates the HTTP RPC listener interface string from the set
// MakeH
TTP
RpcHost creates the HTTP RPC listener interface string from the set
// command line flags, returning empty if the HTTP endpoint is disabled.
func
MakeH
ttp
RpcHost
(
ctx
*
cli
.
Context
)
string
{
func
MakeH
TTP
RpcHost
(
ctx
*
cli
.
Context
)
string
{
if
!
ctx
.
GlobalBool
(
RPCEnabledFlag
.
Name
)
{
return
""
}
return
ctx
.
GlobalString
(
RPCListenAddrFlag
.
Name
)
}
// MakeW
s
RpcHost creates the WebSocket RPC listener interface string from the set
// MakeW
S
RpcHost creates the WebSocket RPC listener interface string from the set
// command line flags, returning empty if the HTTP endpoint is disabled.
func
MakeW
s
RpcHost
(
ctx
*
cli
.
Context
)
string
{
func
MakeW
S
RpcHost
(
ctx
*
cli
.
Context
)
string
{
if
!
ctx
.
GlobalBool
(
WSEnabledFlag
.
Name
)
{
return
""
}
...
...
@@ -616,15 +616,15 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.
NAT
:
MakeNAT
(
ctx
),
MaxPeers
:
ctx
.
GlobalInt
(
MaxPeersFlag
.
Name
),
MaxPendingPeers
:
ctx
.
GlobalInt
(
MaxPendingPeersFlag
.
Name
),
I
pcPath
:
MakeIpc
Path
(
ctx
),
H
ttpHost
:
MakeHttp
RpcHost
(
ctx
),
H
ttp
Port
:
ctx
.
GlobalInt
(
RPCPortFlag
.
Name
),
H
ttp
Cors
:
ctx
.
GlobalString
(
RPCCORSDomainFlag
.
Name
),
H
ttp
Modules
:
strings
.
Split
(
ctx
.
GlobalString
(
RPCApiFlag
.
Name
),
","
),
W
sHost
:
MakeWs
RpcHost
(
ctx
),
W
s
Port
:
ctx
.
GlobalInt
(
WSPortFlag
.
Name
),
W
sCors
:
ctx
.
GlobalString
(
WSCORSDomain
Flag
.
Name
),
W
s
Modules
:
strings
.
Split
(
ctx
.
GlobalString
(
WSApiFlag
.
Name
),
","
),
I
PCPath
:
MakeIPC
Path
(
ctx
),
H
TTPHost
:
MakeHTTP
RpcHost
(
ctx
),
H
TTP
Port
:
ctx
.
GlobalInt
(
RPCPortFlag
.
Name
),
H
TTP
Cors
:
ctx
.
GlobalString
(
RPCCORSDomainFlag
.
Name
),
H
TTP
Modules
:
strings
.
Split
(
ctx
.
GlobalString
(
RPCApiFlag
.
Name
),
","
),
W
SHost
:
MakeWS
RpcHost
(
ctx
),
W
S
Port
:
ctx
.
GlobalInt
(
WSPortFlag
.
Name
),
W
SDomains
:
ctx
.
GlobalString
(
WSAllowedDomains
Flag
.
Name
),
W
S
Modules
:
strings
.
Split
(
ctx
.
GlobalString
(
WSApiFlag
.
Name
),
","
),
}
// Configure the Ethereum service
accman
:=
MakeAccountManager
(
ctx
)
...
...
common/defaults.go
View file @
900e124b
...
...
@@ -22,11 +22,11 @@ import (
)
const
(
DefaultI
pc
Socket
=
"geth.ipc"
// Default (relative) name of the IPC RPC socket
DefaultH
ttp
Host
=
"localhost"
// Default host interface for the HTTP RPC server
DefaultH
ttp
Port
=
8545
// Default TCP port for the HTTP RPC server
DefaultW
s
Host
=
"localhost"
// Default host interface for the websocket RPC server
DefaultW
s
Port
=
8546
// Default TCP port for the websocket RPC server
DefaultI
PC
Socket
=
"geth.ipc"
// Default (relative) name of the IPC RPC socket
DefaultH
TTP
Host
=
"localhost"
// Default host interface for the HTTP RPC server
DefaultH
TTP
Port
=
8545
// Default TCP port for the HTTP RPC server
DefaultW
S
Host
=
"localhost"
// Default host interface for the websocket RPC server
DefaultW
S
Port
=
8546
// Default TCP port for the websocket RPC server
)
// DefaultDataDir is the default data directory to use for the databases and other
...
...
node/config.go
View file @
900e124b
...
...
@@ -53,11 +53,11 @@ type Config struct {
// in memory.
DataDir
string
// I
pc
Path is the requested location to place the IPC endpoint. If the path is
// I
PC
Path is the requested location to place the IPC endpoint. If the path is
// a simple file name, it is placed inside the data directory (or on the root
// pipe path on Windows), whereas if it's a resolvable path name (absolute or
// relative), then that specific path is enforced. An empty path disables IPC.
I
pc
Path
string
I
PC
Path
string
// This field should be a valid secp256k1 private key that will be used for both
// remote peer identification as well as network traffic encryption. If no key
...
...
@@ -99,104 +99,104 @@ type Config struct {
// Zero defaults to preset values.
MaxPendingPeers
int
// H
ttp
Host is the host interface on which to start the HTTP RPC server. If this
// H
TTP
Host is the host interface on which to start the HTTP RPC server. If this
// field is empty, no HTTP API endpoint will be started.
H
ttp
Host
string
H
TTP
Host
string
// H
ttp
Port is the TCP port number on which to start the HTTP RPC server. The
// H
TTP
Port is the TCP port number on which to start the HTTP RPC server. The
// default zero value is/ valid and will pick a port number randomly (useful
// for ephemeral nodes).
H
ttp
Port
int
H
TTP
Port
int
// H
ttp
Cors is the Cross-Origin Resource Sharing header to send to requesting
// H
TTP
Cors is the Cross-Origin Resource Sharing header to send to requesting
// clients. Please be aware that CORS is a browser enforced security, it's fully
// useless for custom HTTP clients.
H
ttp
Cors
string
H
TTP
Cors
string
// H
ttp
Modules is a list of API modules to expose via the HTTP RPC interface.
// H
TTP
Modules is a list of API modules to expose via the HTTP RPC interface.
// If the module list is empty, all RPC API endpoints designated public will be
// exposed.
H
ttp
Modules
[]
string
H
TTP
Modules
[]
string
// W
s
Host is the host interface on which to start the websocket RPC server. If
// W
S
Host is the host interface on which to start the websocket RPC server. If
// this field is empty, no websocket API endpoint will be started.
W
s
Host
string
W
S
Host
string
// W
s
Port is the TCP port number on which to start the websocket RPC server. The
// W
S
Port is the TCP port number on which to start the websocket RPC server. The
// default zero value is/ valid and will pick a port number randomly (useful for
// ephemeral nodes).
W
s
Port
int
W
S
Port
int
// W
sCors is the Cross-Origin Resource Sharing header to send to requesting clients.
//
Please be aware that CORS is a browser enforced security, it's fully useless
//
for custom websocket clients
.
W
sCor
s
string
// W
SDomains is the list of domain to accept websocket requests from. Please be
//
aware that the server can only act upon the HTTP request the client sends and
//
cannot verify the validity of the request header
.
W
SDomain
s
string
// W
s
Modules is a list of API modules to expose via the websocket RPC interface.
// W
S
Modules is a list of API modules to expose via the websocket RPC interface.
// If the module list is empty, all RPC API endpoints designated public will be
// exposed.
W
s
Modules
[]
string
W
S
Modules
[]
string
}
// I
pc
Endpoint resolves an IPC endpoint based on a configured value, taking into
// I
PC
Endpoint resolves an IPC endpoint based on a configured value, taking into
// account the set data folders as well as the designated platform we're currently
// running on.
func
(
c
*
Config
)
I
pc
Endpoint
()
string
{
func
(
c
*
Config
)
I
PC
Endpoint
()
string
{
// Short circuit if IPC has not been enabled
if
c
.
I
pc
Path
==
""
{
if
c
.
I
PC
Path
==
""
{
return
""
}
// On windows we can only use plain top-level pipes
if
runtime
.
GOOS
==
"windows"
{
if
strings
.
HasPrefix
(
c
.
I
pc
Path
,
`\\.\pipe\`
)
{
return
c
.
I
pc
Path
if
strings
.
HasPrefix
(
c
.
I
PC
Path
,
`\\.\pipe\`
)
{
return
c
.
I
PC
Path
}
return
`\\.\pipe\`
+
c
.
I
pc
Path
return
`\\.\pipe\`
+
c
.
I
PC
Path
}
// Resolve names into the data directory full paths otherwise
if
filepath
.
Base
(
c
.
I
pcPath
)
==
c
.
Ipc
Path
{
if
filepath
.
Base
(
c
.
I
PCPath
)
==
c
.
IPC
Path
{
if
c
.
DataDir
==
""
{
return
filepath
.
Join
(
os
.
TempDir
(),
c
.
I
pc
Path
)
return
filepath
.
Join
(
os
.
TempDir
(),
c
.
I
PC
Path
)
}
return
filepath
.
Join
(
c
.
DataDir
,
c
.
I
pc
Path
)
return
filepath
.
Join
(
c
.
DataDir
,
c
.
I
PC
Path
)
}
return
c
.
I
pc
Path
return
c
.
I
PC
Path
}
// DefaultI
pc
Endpoint returns the IPC path used by default.
func
DefaultI
pc
Endpoint
()
string
{
config
:=
&
Config
{
DataDir
:
common
.
DefaultDataDir
(),
I
pcPath
:
common
.
DefaultIpc
Socket
}
return
config
.
I
pc
Endpoint
()
// DefaultI
PC
Endpoint returns the IPC path used by default.
func
DefaultI
PC
Endpoint
()
string
{
config
:=
&
Config
{
DataDir
:
common
.
DefaultDataDir
(),
I
PCPath
:
common
.
DefaultIPC
Socket
}
return
config
.
I
PC
Endpoint
()
}
// H
ttp
Endpoint resolves an HTTP endpoint based on the configured host interface
// H
TTP
Endpoint resolves an HTTP endpoint based on the configured host interface
// and port parameters.
func
(
c
*
Config
)
H
ttp
Endpoint
()
string
{
if
c
.
H
ttp
Host
==
""
{
func
(
c
*
Config
)
H
TTP
Endpoint
()
string
{
if
c
.
H
TTP
Host
==
""
{
return
""
}
return
fmt
.
Sprintf
(
"%s:%d"
,
c
.
H
ttpHost
,
c
.
Http
Port
)
return
fmt
.
Sprintf
(
"%s:%d"
,
c
.
H
TTPHost
,
c
.
HTTP
Port
)
}
// DefaultH
ttp
Endpoint returns the HTTP endpoint used by default.
func
DefaultH
ttp
Endpoint
()
string
{
config
:=
&
Config
{
H
ttpHost
:
common
.
DefaultHttpHost
,
HttpPort
:
common
.
DefaultHttp
Port
}
return
config
.
H
ttp
Endpoint
()
// DefaultH
TTP
Endpoint returns the HTTP endpoint used by default.
func
DefaultH
TTP
Endpoint
()
string
{
config
:=
&
Config
{
H
TTPHost
:
common
.
DefaultHTTPHost
,
HTTPPort
:
common
.
DefaultHTTP
Port
}
return
config
.
H
TTP
Endpoint
()
}
// W
s
Endpoint resolves an websocket endpoint based on the configured host interface
// W
S
Endpoint resolves an websocket endpoint based on the configured host interface
// and port parameters.
func
(
c
*
Config
)
W
s
Endpoint
()
string
{
if
c
.
W
s
Host
==
""
{
func
(
c
*
Config
)
W
S
Endpoint
()
string
{
if
c
.
W
S
Host
==
""
{
return
""
}
return
fmt
.
Sprintf
(
"%s:%d"
,
c
.
W
sHost
,
c
.
Ws
Port
)
return
fmt
.
Sprintf
(
"%s:%d"
,
c
.
W
SHost
,
c
.
WS
Port
)
}
// DefaultW
s
Endpoint returns the websocket endpoint used by default.
func
DefaultW
s
Endpoint
()
string
{
config
:=
&
Config
{
W
sHost
:
common
.
DefaultWsHost
,
WsPort
:
common
.
DefaultWs
Port
}
return
config
.
W
s
Endpoint
()
// DefaultW
S
Endpoint returns the websocket endpoint used by default.
func
DefaultW
S
Endpoint
()
string
{
config
:=
&
Config
{
W
SHost
:
common
.
DefaultWSHost
,
WSPort
:
common
.
DefaultWS
Port
}
return
config
.
W
S
Endpoint
()
}
// NodeKey retrieves the currently configured private key of the node, checking
...
...
node/config_test.go
View file @
900e124b
...
...
@@ -63,10 +63,10 @@ func TestDatadirCreation(t *testing.T) {
// Tests that IPC paths are correctly resolved to valid endpoints of different
// platforms.
func
TestI
pc
PathResolution
(
t
*
testing
.
T
)
{
func
TestI
PC
PathResolution
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
DataDir
string
I
pc
Path
string
I
PC
Path
string
Windows
bool
Endpoint
string
}{
...
...
@@ -85,7 +85,7 @@ func TestIpcPathResolution(t *testing.T) {
for
i
,
test
:=
range
tests
{
// Only run when platform/test match
if
(
runtime
.
GOOS
==
"windows"
)
==
test
.
Windows
{
if
endpoint
:=
(
&
Config
{
DataDir
:
test
.
DataDir
,
I
pcPath
:
test
.
IpcPath
})
.
Ipc
Endpoint
();
endpoint
!=
test
.
Endpoint
{
if
endpoint
:=
(
&
Config
{
DataDir
:
test
.
DataDir
,
I
PCPath
:
test
.
IPCPath
})
.
IPC
Endpoint
();
endpoint
!=
test
.
Endpoint
{
t
.
Errorf
(
"test %d: IPC endpoint mismatch: have %s, want %s"
,
i
,
endpoint
,
test
.
Endpoint
)
}
}
...
...
node/node.go
View file @
900e124b
...
...
@@ -68,7 +68,7 @@ type Node struct {
wsEndpoint
string
// Websocket endpoint (interface + port) to listen at (empty = websocket disabled)
wsWhitelist
[]
string
// Websocket RPC modules to allow through this endpoint
ws
Cors
string
// Websocket RPC Cross-Origin Resource Sharing header
ws
Domains
string
// Websocket RPC allowed origin domains
wsListener
net
.
Listener
// Websocket RPC listener socket to server API requests
wsHandler
*
rpc
.
Server
// Websocket RPC request handler to process the API requests
...
...
@@ -107,13 +107,13 @@ func New(conf *Config) (*Node, error) {
MaxPendingPeers
:
conf
.
MaxPendingPeers
,
},
serviceFuncs
:
[]
ServiceConstructor
{},
ipcEndpoint
:
conf
.
I
pc
Endpoint
(),
httpEndpoint
:
conf
.
H
ttp
Endpoint
(),
httpWhitelist
:
conf
.
H
ttp
Modules
,
httpCors
:
conf
.
H
ttp
Cors
,
wsEndpoint
:
conf
.
W
s
Endpoint
(),
wsWhitelist
:
conf
.
W
s
Modules
,
ws
Cors
:
conf
.
WsCor
s
,
ipcEndpoint
:
conf
.
I
PC
Endpoint
(),
httpEndpoint
:
conf
.
H
TTP
Endpoint
(),
httpWhitelist
:
conf
.
H
TTP
Modules
,
httpCors
:
conf
.
H
TTP
Cors
,
wsEndpoint
:
conf
.
W
S
Endpoint
(),
wsWhitelist
:
conf
.
W
S
Modules
,
ws
Domains
:
conf
.
WSDomain
s
,
eventmux
:
new
(
event
.
TypeMux
),
},
nil
}
...
...
@@ -224,7 +224,7 @@ func (n *Node) startRPC(services map[reflect.Type]Service) error {
n
.
stopIPC
()
return
err
}
if
err
:=
n
.
startWS
(
n
.
wsEndpoint
,
apis
,
n
.
wsWhitelist
,
n
.
ws
Cor
s
);
err
!=
nil
{
if
err
:=
n
.
startWS
(
n
.
wsEndpoint
,
apis
,
n
.
wsWhitelist
,
n
.
ws
Domain
s
);
err
!=
nil
{
n
.
stopHTTP
()
n
.
stopIPC
()
return
err
...
...
@@ -388,7 +388,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, cors s
n
.
wsEndpoint
=
endpoint
n
.
wsListener
=
listener
n
.
wsHandler
=
handler
n
.
ws
Cor
s
=
cors
n
.
ws
Domain
s
=
cors
return
nil
}
...
...
@@ -501,8 +501,8 @@ func (n *Node) DataDir() string {
return
n
.
datadir
}
// I
pc
Endpoint retrieves the current IPC endpoint used by the protocol stack.
func
(
n
*
Node
)
I
pc
Endpoint
()
string
{
// I
PC
Endpoint retrieves the current IPC endpoint used by the protocol stack.
func
(
n
*
Node
)
I
PC
Endpoint
()
string
{
return
n
.
ipcEndpoint
}
...
...
node/node_test.go
View file @
900e124b
...
...
@@ -37,7 +37,7 @@ var (
func
testNodeConfig
()
*
Config
{
return
&
Config
{
I
pc
Path
:
fmt
.
Sprintf
(
"test-%d.ipc"
,
rand
.
Int63
()),
I
PC
Path
:
fmt
.
Sprintf
(
"test-%d.ipc"
,
rand
.
Int63
()),
PrivateKey
:
testNodeKey
,
Name
:
"test node"
,
}
...
...
@@ -541,7 +541,7 @@ func TestAPIGather(t *testing.T) {
defer
stack
.
Stop
()
// Connect to the RPC server and verify the various registered endpoints
ipcClient
,
err
:=
rpc
.
NewIPCClient
(
stack
.
I
pc
Endpoint
())
ipcClient
,
err
:=
rpc
.
NewIPCClient
(
stack
.
I
PC
Endpoint
())
if
err
!=
nil
{
t
.
Fatalf
(
"failed to connect to the IPC API server: %v"
,
err
)
}
...
...
rpc/server.go
View file @
900e124b
...
...
@@ -33,8 +33,8 @@ import (
const
(
stopPendingRequestTimeout
=
3
*
time
.
Second
// give pending requests stopPendingRequestTimeout the time to finish when the server is stopped
DefaultI
pcApis
=
"admin,eth,debug,miner,net,shh,txpool,personal,web3"
DefaultH
ttpRpc
Apis
=
"eth,net,web3"
DefaultI
PCApis
=
"admin,eth,debug,miner,net,shh,txpool,personal,web3"
DefaultH
TTP
Apis
=
"eth,net,web3"
)
// NewServer will create a new server instance with no registered handlers.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment