p2p: avoid calling os.Getenv for every handshake

This commit is contained in:
Felix Lange 2016-02-19 01:18:31 +01:00
parent 151cf5359a
commit 9860e75cb4

View file

@ -262,6 +262,8 @@ func (h *encHandshake) staticSharedSecret(prv *ecdsa.PrivateKey) ([]byte, error)
return ecies.ImportECDSA(prv).GenerateShared(h.remotePub, sskLen, sskLen) return ecies.ImportECDSA(prv).GenerateShared(h.remotePub, sskLen, sskLen)
} }
var configSendEIP = os.Getenv("RLPX_EIP8") != ""
// initiatorEncHandshake negotiates a session token on conn. // initiatorEncHandshake negotiates a session token on conn.
// it should be called on the dialing side of the connection. // it should be called on the dialing side of the connection.
// //
@ -273,7 +275,7 @@ func initiatorEncHandshake(conn io.ReadWriter, prv *ecdsa.PrivateKey, remoteID d
return s, err return s, err
} }
var authPacket []byte var authPacket []byte
if os.Getenv("RLPX_EIP8") != "" { if configSendEIP {
authPacket, err = sealEIP8(authMsg, h) authPacket, err = sealEIP8(authMsg, h)
} else { } else {
authPacket, err = authMsg.sealPlain(h) authPacket, err = authMsg.sealPlain(h)