Skip to content

Commit

Permalink
Merge pull request #46 from orlandos-nl/feature/fix-exec-sftp
Browse files Browse the repository at this point in the history
Fix using Exec side-by-side with SFTP
  • Loading branch information
Joannis authored Oct 1, 2023
2 parents c0f4eea + 8615374 commit f12b31f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
15 changes: 2 additions & 13 deletions Sources/Citadel/Exec/ExecHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum SSHServerError: Error {

final class ExecHandler: ChannelDuplexHandler {
typealias InboundIn = SSHChannelData
typealias InboundOut = ByteBuffer
typealias InboundOut = SSHChannelData
typealias OutboundIn = SSHChannelData
typealias OutboundOut = SSHChannelData

Expand Down Expand Up @@ -92,18 +92,7 @@ final class ExecHandler: ChannelDuplexHandler {
}

func channelRead(context: ChannelHandlerContext, data: NIOAny) {
let data = self.unwrapInboundIn(data)

guard case .byteBuffer(let bytes) = data.data else {
fatalError("Unexpected read type")
}

guard case .channel = data.type else {
context.fireErrorCaught(SSHServerError.invalidDataType)
return
}

context.fireChannelRead(self.wrapInboundOut(bytes))
context.fireChannelRead(data)
}

func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?) {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Citadel/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ final class SubsystemHandler: ChannelDuplexHandler {
func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?) {
context.write(data, promise: promise)
}

deinit {
configured.fail(CitadelError.channelCreationFailed)
}
}

final class CitadelServerDelegate {
Expand Down

0 comments on commit f12b31f

Please sign in to comment.