~ubuntu-branches/ubuntu/trusty/juju-core/trusty-proposed

« back to all changes in this revision

Viewing changes to src/code.google.com/p/go.crypto/ssh/tcpip.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-29 11:40:20 UTC
  • mfrom: (23.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140129114020-ejieitm8smtt5vln
Tags: 1.17.1-0ubuntu2
d/tests/local-provider: Don't fail tests if ~/.juju is present as its
created by the juju version command. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
        return c.ListenTCP(laddr)
28
28
}
29
29
 
30
 
// RFC 4254 7.1
31
 
type channelForwardMsg struct {
32
 
        Message   string
33
 
        WantReply bool
34
 
        raddr     string
35
 
        rport     uint32
36
 
}
37
 
 
38
30
// Automatic port allocation is broken with OpenSSH before 6.0. See
39
31
// also https://bugzilla.mindrot.org/show_bug.cgi?id=2017.  In
40
32
// particular, OpenSSH 5.9 sends a channelOpenMsg with port number 0,
83
75
        return nil, fmt.Errorf("ssh: listen on random port failed after %d tries: %v", tries, err)
84
76
}
85
77
 
 
78
// RFC 4254 7.1
 
79
type channelForwardMsg struct {
 
80
        Message   string
 
81
        WantReply bool
 
82
        raddr     string
 
83
        rport     uint32
 
84
}
 
85
 
86
86
// ListenTCP requests the remote peer open a listening socket
87
87
// on laddr. Incoming connections will be available by calling
88
88
// Accept on the returned net.Listener.
232
232
}
233
233
 
234
234
// Dial initiates a connection to the addr from the remote host.
235
 
// addr is resolved using net.ResolveTCPAddr before connection.
236
 
// This could allow an observer to observe the DNS name of the
237
 
// remote host. Consider using ssh.DialTCP to avoid this.
 
235
// The resulting connection has a zero LocalAddr() and RemoteAddr().
238
236
func (c *ClientConn) Dial(n, addr string) (net.Conn, error) {
239
 
        raddr, err := net.ResolveTCPAddr(n, addr)
240
 
        if err != nil {
241
 
                return nil, err
242
 
        }
243
 
        return c.DialTCP(n, nil, raddr)
 
237
        // Parse the address into host and numeric port.
 
238
        host, portString, err := net.SplitHostPort(addr)
 
239
        if err != nil {
 
240
                return nil, err
 
241
        }
 
242
        port, err := strconv.ParseUint(portString, 10, 16)
 
243
        if err != nil {
 
244
                return nil, err
 
245
        }
 
246
        // Use a zero address for local and remote address.
 
247
        zeroAddr := &net.TCPAddr{
 
248
                IP:   net.IPv4zero,
 
249
                Port: 0,
 
250
        }
 
251
        ch, err := c.dial(net.IPv4zero.String(), 0, host, int(port))
 
252
        if err != nil {
 
253
                return nil, err
 
254
        }
 
255
        return &tcpChanConn{
 
256
                tcpChan: ch,
 
257
                laddr:   zeroAddr,
 
258
                raddr:   zeroAddr,
 
259
        }, nil
244
260
}
245
261
 
246
262
// DialTCP connects to the remote address raddr on the network net,
277
293
}
278
294
 
279
295
// dial opens a direct-tcpip connection to the remote server. laddr and raddr are passed as
280
 
// strings and are expected to be resolveable at the remote end.
 
296
// strings and are expected to be resolvable at the remote end.
281
297
func (c *ClientConn) dial(laddr string, lport int, raddr string, rport int) (*tcpChan, error) {
282
298
        ch := c.newChan(c.transport)
283
 
        if err := c.writePacket(marshal(msgChannelOpen, channelOpenDirectMsg{
 
299
        if err := c.transport.writePacket(marshal(msgChannelOpen, channelOpenDirectMsg{
284
300
                ChanType:      "direct-tcpip",
285
301
                PeersId:       ch.localId,
286
 
                PeersWindow:   1 << 14,
287
 
                MaxPacketSize: 1 << 15, // RFC 4253 6.1
 
302
                PeersWindow:   channelWindowSize,
 
303
                MaxPacketSize: channelMaxPacketSize,
288
304
                raddr:         raddr,
289
305
                rport:         uint32(rport),
290
306
                laddr:         laddr,