mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
add -crypto option to switch encryption on by a flag
This commit is contained in:
parent
2f00e5cad1
commit
7f12ac702f
6 changed files with 21 additions and 10 deletions
|
|
@ -65,6 +65,7 @@ var (
|
||||||
SHH bool
|
SHH bool
|
||||||
Dial bool
|
Dial bool
|
||||||
PrintVersion bool
|
PrintVersion bool
|
||||||
|
Encryption bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// flags specific to cli client
|
// flags specific to cli client
|
||||||
|
|
@ -115,6 +116,7 @@ func Init() {
|
||||||
flag.BoolVar(&ShowGenesis, "genesis", false, "Dump the genesis block")
|
flag.BoolVar(&ShowGenesis, "genesis", false, "Dump the genesis block")
|
||||||
flag.StringVar(&ImportChain, "chain", "", "Imports given chain")
|
flag.StringVar(&ImportChain, "chain", "", "Imports given chain")
|
||||||
|
|
||||||
|
flag.BoolVar(&Encryption, "crypto", false, "whether to use encryption (experimental, temporary)")
|
||||||
flag.BoolVar(&Dump, "dump", false, "output the ethereum state in JSON format. Sub args [number, hash]")
|
flag.BoolVar(&Dump, "dump", false, "output the ethereum state in JSON format. Sub args [number, hash]")
|
||||||
flag.StringVar(&DumpHash, "hash", "", "specify arg in hex")
|
flag.StringVar(&DumpHash, "hash", "", "specify arg in hex")
|
||||||
flag.IntVar(&DumpNumber, "number", -1, "specify arg in number")
|
flag.IntVar(&DumpNumber, "number", -1, "specify arg in number")
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ func main() {
|
||||||
KeyRing: KeyRing,
|
KeyRing: KeyRing,
|
||||||
Shh: SHH,
|
Shh: SHH,
|
||||||
Dial: Dial,
|
Dial: Dial,
|
||||||
|
Encryption: Encryption,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,9 @@ type Config struct {
|
||||||
NATType string
|
NATType string
|
||||||
PMPGateway string
|
PMPGateway string
|
||||||
|
|
||||||
Shh bool
|
Shh bool
|
||||||
Dial bool
|
Dial bool
|
||||||
|
Encryption bool
|
||||||
|
|
||||||
KeyManager *crypto.KeyManager
|
KeyManager *crypto.KeyManager
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +108,7 @@ func New(config *Config) (*Ethereum, error) {
|
||||||
keyManager.Init(config.KeyRing, 0, false)
|
keyManager.Init(config.KeyRing, 0, false)
|
||||||
|
|
||||||
// Create a new client id for this instance. This will help identifying the node on the network
|
// Create a new client id for this instance. This will help identifying the node on the network
|
||||||
clientId := p2p.NewSimpleClientIdentity(config.Name, config.Version, config.Identifier, keyManager.PublicKey())
|
clientId := p2p.NewSimpleClientIdentity(config.Name, config.Version, config.Identifier, keyManager.PrivateKey(), keyManager.PublicKey())
|
||||||
|
|
||||||
saveProtocolVersion(db)
|
saveProtocolVersion(db)
|
||||||
//ethutil.Config.Db = db
|
//ethutil.Config.Db = db
|
||||||
|
|
@ -143,12 +144,13 @@ func New(config *Config) (*Ethereum, error) {
|
||||||
fmt.Println(nat)
|
fmt.Println(nat)
|
||||||
|
|
||||||
eth.net = &p2p.Server{
|
eth.net = &p2p.Server{
|
||||||
Identity: clientId,
|
Identity: clientId,
|
||||||
MaxPeers: config.MaxPeers,
|
MaxPeers: config.MaxPeers,
|
||||||
Protocols: protocols,
|
Protocols: protocols,
|
||||||
Blacklist: eth.blacklist,
|
Blacklist: eth.blacklist,
|
||||||
NAT: p2p.UPNP(),
|
NAT: p2p.UPNP(),
|
||||||
NoDial: !config.Dial,
|
NoDial: !config.Dial,
|
||||||
|
Encryption: config.Encryption,
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(config.Port) > 0 {
|
if len(config.Port) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ func runEthProtocol(txPool txPool, chainManager chainManager, blockPool blockPoo
|
||||||
blockPool: blockPool,
|
blockPool: blockPool,
|
||||||
rw: rw,
|
rw: rw,
|
||||||
peer: peer,
|
peer: peer,
|
||||||
id: fmt.Sprintf("%x", peer.Identity().Pubkey()[:8]),
|
id: fmt.Sprintf("%x", peer.PublicKey()[:8]),
|
||||||
}
|
}
|
||||||
err = self.handleStatus()
|
err = self.handleStatus()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,9 @@ func newServerPeer(server *Server, conn net.Conn, dialAddr *peerAddr) *Peer {
|
||||||
p.otherPeers = server.Peers
|
p.otherPeers = server.Peers
|
||||||
p.pubkeyHook = server.verifyPeer
|
p.pubkeyHook = server.verifyPeer
|
||||||
p.runBaseProtocol = true
|
p.runBaseProtocol = true
|
||||||
|
if server.Encryption {
|
||||||
|
p.CryptoType = EthCrypto
|
||||||
|
}
|
||||||
|
|
||||||
// laddr can be updated concurrently by NAT traversal.
|
// laddr can be updated concurrently by NAT traversal.
|
||||||
// newServerPeer must be called with the server lock held.
|
// newServerPeer must be called with the server lock held.
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,9 @@ type Server struct {
|
||||||
// If NoDial is true, the server will not dial any peers.
|
// If NoDial is true, the server will not dial any peers.
|
||||||
NoDial bool
|
NoDial bool
|
||||||
|
|
||||||
|
// whether or not use encryption
|
||||||
|
Encryption bool
|
||||||
|
|
||||||
// Hook for testing. This is useful because we can inhibit
|
// Hook for testing. This is useful because we can inhibit
|
||||||
// the whole protocol stack.
|
// the whole protocol stack.
|
||||||
newPeerFunc peerFunc
|
newPeerFunc peerFunc
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue