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
91130ea3
Commit
91130ea3
authored
Jul 15, 2016
by
Nick Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/bootnode: Add support for outputting a node's ID on the command line
parent
f970610c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
main.go
cmd/bootnode/main.go
+16
-12
No files found.
cmd/bootnode/main.go
View file @
91130ea3
...
...
@@ -20,6 +20,7 @@ package main
import
(
"crypto/ecdsa"
"flag"
"fmt"
"os"
"github.com/ethereum/go-ethereum/cmd/utils"
...
...
@@ -32,7 +33,8 @@ import (
func
main
()
{
var
(
listenAddr
=
flag
.
String
(
"addr"
,
":30301"
,
"listen address"
)
genKey
=
flag
.
String
(
"genkey"
,
""
,
"generate a node key and quit"
)
genKey
=
flag
.
String
(
"genkey"
,
""
,
"generate a node key"
)
writeAddr
=
flag
.
Bool
(
"writeaddress"
,
false
,
"write out the node's pubkey hash and quit"
)
nodeKeyFile
=
flag
.
String
(
"nodekey"
,
""
,
"private key filename"
)
nodeKeyHex
=
flag
.
String
(
"nodekeyhex"
,
""
,
"private key as hex (for testing)"
)
natdesc
=
flag
.
String
(
"nat"
,
"none"
,
"port mapping mechanism (any|none|upnp|pmp|extip:<IP>)"
)
...
...
@@ -45,22 +47,19 @@ func main() {
glog
.
SetToStderr
(
true
)
flag
.
Parse
()
if
*
genKey
!=
""
{
key
,
err
:=
crypto
.
GenerateKey
()
if
err
!=
nil
{
utils
.
Fatalf
(
"could not generate key: %v"
,
err
)
}
if
err
:=
crypto
.
SaveECDSA
(
*
genKey
,
key
);
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
os
.
Exit
(
0
)
}
natm
,
err
:=
nat
.
Parse
(
*
natdesc
)
if
err
!=
nil
{
utils
.
Fatalf
(
"-nat: %v"
,
err
)
}
switch
{
case
*
genKey
!=
""
:
nodeKey
,
err
=
crypto
.
GenerateKey
()
if
err
!=
nil
{
utils
.
Fatalf
(
"could not generate key: %v"
,
err
)
}
if
err
=
crypto
.
SaveECDSA
(
*
genKey
,
nodeKey
);
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
case
*
nodeKeyFile
==
""
&&
*
nodeKeyHex
==
""
:
utils
.
Fatalf
(
"Use -nodekey or -nodekeyhex to specify a private key"
)
case
*
nodeKeyFile
!=
""
&&
*
nodeKeyHex
!=
""
:
...
...
@@ -75,6 +74,11 @@ func main() {
}
}
if
*
writeAddr
{
fmt
.
Printf
(
"%v
\n
"
,
discover
.
PubkeyID
(
&
nodeKey
.
PublicKey
))
os
.
Exit
(
0
)
}
if
_
,
err
:=
discover
.
ListenUDP
(
nodeKey
,
*
listenAddr
,
natm
,
""
);
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
...
...
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