Skip to content

Commit ae9173a

Browse files
committed
Exclude C oracle targets on Windows.
1 parent 1556d1d commit ae9173a

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

Sources/SwiftMTH/TelnetSession.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,14 @@ public final class TelnetSession {
343343

344344
// MARK: - Output
345345

346+
/// Send output data to the client, compressing via MCCP2 if active.
347+
/// Host applications must route all socket output through this method
348+
/// once MCCP2 negotiation completes, otherwise clients receive
349+
/// uncompressed data after the MCCP2 start marker.
350+
public func sendOutput(_ data: [UInt8]) {
351+
write(data)
352+
}
353+
346354
private func write(_ data: [UInt8]) {
347355
#if canImport(CZlib)
348356
if let mccp2 = mccp2 {

Tests/MTHTests/TelnetSessionTests.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,30 @@ private func makeSession() -> (TelnetSession, FakeDelegate) {
619619
#expect(d.writtenChunks.count == chunks1)
620620
}
621621

622+
// MARK: - sendOutput (Public Output API)
623+
624+
@Test func sendOutputPassthroughWithoutMCCP2() {
625+
let (s, d) = makeSession()
626+
let data: [UInt8] = Array("Hello, World!\r\n".utf8)
627+
s.sendOutput(data)
628+
#expect(d.allWrittenBytes == data)
629+
}
630+
631+
@Test func sendOutputCompressesWithMCCP2() {
632+
let (s, d) = makeSession()
633+
_ = s.processInput([IAC, DO, MCCP2])
634+
d.writtenChunks.removeAll()
635+
636+
let data: [UInt8] = Array("Hello, World!\r\n".utf8)
637+
s.sendOutput(data)
638+
639+
#expect(!d.writtenChunks.isEmpty)
640+
// Compressed output should differ from the raw input
641+
let compressed = d.allWrittenBytes
642+
#expect(compressed != data)
643+
#expect(!compressed.isEmpty)
644+
}
645+
622646
// MARK: - MCCP3 (Input Decompression)
623647

624648
@Test func sbMccp3InitializesInflate() {

0 commit comments

Comments
 (0)