in Sources/NIOSSH/Child Channels/ChildChannelStateMachine.swift [390:417]
mutating func sendChannelClose(_ message: SSHMessage.ChannelCloseMessage) throws {
// We can send channel close at any point after the channel is active.
switch self.state {
case .active(channelID: let channelID),
.halfClosedLocal(channelID: let channelID):
precondition(message.recipientChannel == channelID.peerChannelID)
self.state = .closedLocally(channelID: channelID, receivedPeerEOF: false)
case .halfClosedRemote(channelID: let channelID),
.quiescent(channelID: let channelID):
precondition(message.recipientChannel == channelID.peerChannelID)
self.state = .closedLocally(channelID: channelID, receivedPeerEOF: true)
case .closedRemotely(channelID: let channelID, sentEOF: _):
precondition(message.recipientChannel == channelID.peerChannelID)
self.state = .closed(channelID: channelID)
case .idle:
// In the idle state we haven't either sent a channel open or received one. This is not really possible.
preconditionFailure("Somehow received channel EOF for idle channel")
case .requestedLocally, .requestedRemotely:
throw NIOSSHError.protocolViolation(protocolName: "channel", violation: "Sent close before channel was open.")
case .closedLocally, .closed:
throw NIOSSHError.protocolViolation(protocolName: "channel", violation: "Sent close on closed channel.")
}
}