OLD | NEW |
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/rand" | 8 "crypto/rand" |
9 "encoding/binary" | 9 "encoding/binary" |
10 "errors" | 10 "errors" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 c.forwardList.closeAll() | 189 c.forwardList.closeAll() |
190 }() | 190 }() |
191 | 191 |
192 for { | 192 for { |
193 packet, err := c.readPacket() | 193 packet, err := c.readPacket() |
194 if err != nil { | 194 if err != nil { |
195 break | 195 break |
196 } | 196 } |
197 // TODO(dfc) A note on blocking channel use. | 197 // TODO(dfc) A note on blocking channel use. |
198 // The msg, data and dataExt channels of a clientChan can | 198 // The msg, data and dataExt channels of a clientChan can |
199 » » // cause this loop to block indefinately if the consumer does | 199 » » // cause this loop to block indefinitely if the consumer does |
200 // not service them. | 200 // not service them. |
201 switch packet[0] { | 201 switch packet[0] { |
202 case msgChannelData: | 202 case msgChannelData: |
203 if len(packet) < 9 { | 203 if len(packet) < 9 { |
204 // malformed data packet | 204 // malformed data packet |
205 return | 205 return |
206 } | 206 } |
207 remoteId := binary.BigEndian.Uint32(packet[1:5]) | 207 remoteId := binary.BigEndian.Uint32(packet[1:5]) |
208 length := binary.BigEndian.Uint32(packet[5:9]) | 208 length := binary.BigEndian.Uint32(packet[5:9]) |
209 packet = packet[9:] | 209 packet = packet[9:] |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 if !ok { | 336 if !ok { |
337 // invalid request | 337 // invalid request |
338 c.sendConnectionFailed(msg.PeersId) | 338 c.sendConnectionFailed(msg.PeersId) |
339 return | 339 return |
340 } | 340 } |
341 | 341 |
342 l, ok := c.forwardList.lookup(*laddr) | 342 l, ok := c.forwardList.lookup(*laddr) |
343 if !ok { | 343 if !ok { |
344 // TODO: print on a more structured log. | 344 // TODO: print on a more structured log. |
345 fmt.Println("could not find forward list entry for", lad
dr) | 345 fmt.Println("could not find forward list entry for", lad
dr) |
346 » » » // Section 7.2, implementations MUST reject suprious inc
oming | 346 » » » // Section 7.2, implementations MUST reject spurious inc
oming |
347 // connections. | 347 // connections. |
348 c.sendConnectionFailed(msg.PeersId) | 348 c.sendConnectionFailed(msg.PeersId) |
349 return | 349 return |
350 } | 350 } |
351 raddr, rest, ok := parseTCPAddr(rest) | 351 raddr, rest, ok := parseTCPAddr(rest) |
352 if !ok { | 352 if !ok { |
353 // invalid request | 353 // invalid request |
354 c.sendConnectionFailed(msg.PeersId) | 354 c.sendConnectionFailed(msg.PeersId) |
355 return | 355 return |
356 } | 356 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 defer c.Unlock() | 521 defer c.Unlock() |
522 | 522 |
523 for _, ch := range c.chans { | 523 for _, ch := range c.chans { |
524 if ch == nil { | 524 if ch == nil { |
525 continue | 525 continue |
526 } | 526 } |
527 ch.Close() | 527 ch.Close() |
528 close(ch.msg) | 528 close(ch.msg) |
529 } | 529 } |
530 } | 530 } |
OLD | NEW |