LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package ssh | 5 package ssh |
6 | 6 |
7 import ( | 7 import ( |
8 "crypto" | 8 "crypto" |
9 "errors" | |
10 "fmt" | 9 "fmt" |
11 "net" | 10 "net" |
12 "sync" | 11 "sync" |
13 | 12 |
14 _ "crypto/sha1" | 13 _ "crypto/sha1" |
15 _ "crypto/sha256" | 14 _ "crypto/sha256" |
16 _ "crypto/sha512" | 15 _ "crypto/sha512" |
17 ) | 16 ) |
18 | 17 |
19 // These are string constants in the SSH protocol. | 18 // These are string constants in the SSH protocol. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 result.rCompression, ok = findCommonAlgorithm(clientKexInit.CompressionS
erverClient, serverKexInit.CompressionServerClient) | 143 result.rCompression, ok = findCommonAlgorithm(clientKexInit.CompressionS
erverClient, serverKexInit.CompressionServerClient) |
145 if !ok { | 144 if !ok { |
146 return | 145 return |
147 } | 146 } |
148 | 147 |
149 return result | 148 return result |
150 } | 149 } |
151 | 150 |
152 // Cryptographic configuration common to both ServerConfig and ClientConfig. | 151 // Cryptographic configuration common to both ServerConfig and ClientConfig. |
153 type CryptoConfig struct { | 152 type CryptoConfig struct { |
154 » // The maximum amount of data sent or received after which a | 153 » // The maximum number of bytes sent or received after which a |
155 // new key is negotiated. | 154 // new key is negotiated. |
156 RekeyThreshold uint64 | 155 RekeyThreshold uint64 |
157 | 156 |
158 // The allowed key exchanges algorithms. If unspecified then a | 157 // The allowed key exchanges algorithms. If unspecified then a |
159 // default set of algorithms is used. | 158 // default set of algorithms is used. |
160 KeyExchanges []string | 159 KeyExchanges []string |
161 | 160 |
162 // The allowed cipher algorithms. If unspecified then DefaultCipherOrder
is | 161 // The allowed cipher algorithms. If unspecified then DefaultCipherOrder
is |
163 // used. | 162 // used. |
164 Ciphers []string | 163 Ciphers []string |
165 | 164 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 w.Wait() | 349 w.Wait() |
351 } | 350 } |
352 if w.win < win { | 351 if w.win < win { |
353 win = w.win | 352 win = w.win |
354 } | 353 } |
355 w.win -= win | 354 w.win -= win |
356 w.L.Unlock() | 355 w.L.Unlock() |
357 return win | 356 return win |
358 } | 357 } |
359 | 358 |
360 // sshConn provides net.Conn metadata, but but disallows direct reads | 359 type netConnMethods interface { |
361 // and writes. | 360 » Close() error |
| 361 » RemoteAddr() net.Addr |
| 362 » LocalAddr() net.Addr |
| 363 } |
| 364 |
| 365 // sshconn provides net.Conn metadata, but disallows direct reads and |
| 366 // writes. |
362 type sshConn struct { | 367 type sshConn struct { |
363 » net.Conn | 368 » netConnMethods |
364 } | 369 » conn net.Conn |
365 | 370 } |
366 func (c *sshConn) Write([]byte) (int, error) { | |
367 » return 0, errors.New("open a channel to write to an SSH connection") | |
368 } | |
369 | |
370 func (c *sshConn) Read([]byte) (int, error) { | |
371 » return 0, errors.New("open a channel to read from an SSH connection") | |
372 } | |
LEFT | RIGHT |