feat: 完成 M2 mosh(LAN + tsnet 端到端验证)
- mosh(blinksh/ios C++)+protobuf-lite 交叉编译为 MoshCore.xcframework (CommonCrypto 后端、含 arm64 模拟器 slice;绕 autotools 用 CMake 直编 + 手写 config.h) - tsnet 桥新增 UDP relay(StartMoshRelay:loopback↔tsnet.Dial 逐包搬运) - MoshSession(pipe↔FILE*/pthread/SIGWINCH)+ MoshConnectScanner(TXCore,+4 单测=39) - SSHTerminalModel 编排:SSH 引导 mosh-server→解析 MOSH CONNECT→relay→mosh 接管 - LAN 直连 + mosh-over-tsnet 均端到端验证通过,R1(tsnet UDP 数据报语义) 证伪 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
37
packages/TXCore/Tests/TXCoreTests/MoshConnectTests.swift
Normal file
37
packages/TXCore/Tests/TXCoreTests/MoshConnectTests.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
import XCTest
|
||||
@testable import TXCore
|
||||
|
||||
final class MoshConnectTests: XCTestCase {
|
||||
func testParseBasic() {
|
||||
let info = MoshConnectScanner.parse("MOSH CONNECT 60001 gPFm3s8bkfMGrun5QI0Xdw")
|
||||
XCTAssertEqual(info, MoshConnectInfo(port: 60001, key: "gPFm3s8bkfMGrun5QI0Xdw"))
|
||||
}
|
||||
|
||||
func testParseAmidNoise() {
|
||||
let out = """
|
||||
user@host:~$ mosh-server new -s -c 256\r
|
||||
\r
|
||||
MOSH CONNECT 60022 AbCd1234+/xyzKEY0000==\r
|
||||
\r
|
||||
mosh-server (mosh 1.4.0)\r
|
||||
"""
|
||||
let info = MoshConnectScanner.parse(out)
|
||||
XCTAssertEqual(info?.port, 60022)
|
||||
XCTAssertEqual(info?.key, "AbCd1234+/xyzKEY0000==")
|
||||
}
|
||||
|
||||
func testNoMatch() {
|
||||
XCTAssertNil(MoshConnectScanner.parse("bash: mosh-server: command not found"))
|
||||
XCTAssertNil(MoshConnectScanner.parse("MOSH CONNECT notaport keyhere"))
|
||||
}
|
||||
|
||||
func testStreamingAcrossFeeds() {
|
||||
let s = MoshConnectScanner()
|
||||
XCTAssertNil(s.feed("prompt$ mosh-server new\r\nMOSH CON"))
|
||||
XCTAssertNil(s.result)
|
||||
let info = s.feed("NECT 60007 KeyAcrossBoundary123\r\n")
|
||||
XCTAssertEqual(info, MoshConnectInfo(port: 60007, key: "KeyAcrossBoundary123"))
|
||||
// 幂等:后续 feed 不改变结果。
|
||||
XCTAssertEqual(s.feed("MOSH CONNECT 61000 other"), MoshConnectInfo(port: 60007, key: "KeyAcrossBoundary123"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user