chore(identify) move private func to bottom of file
Brian Tiger Chow committed
Sep 13, 2014 at 01:34 UTC
1386205f7ad6f645f7cb78a33dc03cd4916b3813
1 file changed
+24
-24
identify/identify.go
+24
-24
@@ -31,30 +31,6 @@ var SupportedHashes = "SHA256,SHA512,SHA1"
31
// ErrUnsupportedKeyType is returned when a private key cast/type switch fails.
32
var ErrUnsupportedKeyType = errors.New("unsupported key type")
33
34
-func genRandHello(self *peer.Peer) (*Hello, error) {
35
- hello := new(Hello)
36
-
37
- // Generate and send Hello packet.
38
- // Hello = (rand, PublicKey, Supported)
39
- nonce := make([]byte, 16)
40
- _, err := rand.Read(nonce)
41
- if err != nil {
42
- return nil, err
43
- }
44
-
45
- myPubKey, err := self.PubKey.Bytes()
46
- if err != nil {
47
- return nil, err
48
- }
49
-
50
- hello.Rand = nonce
51
- hello.Pubkey = myPubKey
52
- hello.Exchanges = &SupportedExchanges
53
- hello.Ciphers = &SupportedCiphers
54
- hello.Hashes = &SupportedHashes
55
- return hello, nil
56
-}
57
-
34
// Performs initial communication with this peer to share node ID's and
35
// initiate communication. (secureIn, secureOut, error)
36
func Handshake(self, remote *peer.Peer, in <-chan []byte, out chan<- []byte) (<-chan []byte, chan<- []byte, error) {
@@ -322,3 +298,27 @@ func selectBest(myPrefs, theirPrefs string) (string, error) {
298
299
return "", errors.New("No algorithms in common!")
300
}
301
+
302
+func genRandHello(self *peer.Peer) (*Hello, error) {
303
+ hello := new(Hello)
304
+
305
+ // Generate and send Hello packet.
306
+ // Hello = (rand, PublicKey, Supported)
307
+ nonce := make([]byte, 16)
308
+ _, err := rand.Read(nonce)
309
+ if err != nil {
310
+ return nil, err
311
+ }
312
+
313
+ myPubKey, err := self.PubKey.Bytes()
314
+ if err != nil {
315
+ return nil, err
316
+ }
317
+
318
+ hello.Rand = nonce
319
+ hello.Pubkey = myPubKey
320
+ hello.Exchanges = &SupportedExchanges
321
+ hello.Ciphers = &SupportedCiphers
322
+ hello.Hashes = &SupportedHashes
323
+ return hello, nil
324
+}