~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/golang.org/x/crypto/ssh/mux.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
 
132
132
func (m *mux) sendMessage(msg interface{}) error {
133
133
        p := Marshal(msg)
 
134
        if debugMux {
 
135
                log.Printf("send global(%d): %#v", m.chanList.offset, msg)
 
136
        }
134
137
        return m.conn.writePacket(p)
135
138
}
136
139
 
175
178
        return m.sendMessage(globalRequestFailureMsg{Data: data})
176
179
}
177
180
 
178
 
// TODO(hanwen): Disconnect is a transport layer message. We should
179
 
// probably send and receive Disconnect somewhere in the transport
180
 
// code.
181
 
 
182
 
// Disconnect sends a disconnect message.
183
 
func (m *mux) Disconnect(reason uint32, message string) error {
184
 
        return m.sendMessage(disconnectMsg{
185
 
                Reason:  reason,
186
 
                Message: message,
187
 
        })
188
 
}
189
 
 
190
181
func (m *mux) Close() error {
191
182
        return m.conn.Close()
192
183
}
236
227
        }
237
228
 
238
229
        switch packet[0] {
239
 
        case msgNewKeys:
240
 
                // Ignore notification of key change.
241
 
                return nil
242
 
        case msgDisconnect:
243
 
                return m.handleDisconnect(packet)
244
230
        case msgChannelOpen:
245
231
                return m.handleChannelOpen(packet)
246
232
        case msgGlobalRequest, msgRequestSuccess, msgRequestFailure:
260
246
        return ch.handlePacket(packet)
261
247
}
262
248
 
263
 
func (m *mux) handleDisconnect(packet []byte) error {
264
 
        var d disconnectMsg
265
 
        if err := Unmarshal(packet, &d); err != nil {
266
 
                return err
267
 
        }
268
 
 
269
 
        if debugMux {
270
 
                log.Printf("caught disconnect: %v", d)
271
 
        }
272
 
        return &d
273
 
}
274
 
 
275
249
func (m *mux) handleGlobalPacket(packet []byte) error {
276
250
        msg, err := decode(packet)
277
251
        if err != nil {