mirror of
https://github.com/apple/swift-nio-extras.git
synced 2025-05-16 09:52:28 +08:00
Implement a SOCKSv5 client according to RFC 1928. Server implementation will be added in another PR to keep sizes down. https://datatracker.ietf.org/doc/html/rfc1928 A few meaningful changes: Add all relevant types used across SOCKS clients and servers Add a state machine used to manage a connection from a clients side Add a channel handler that should be added at the very start of a channel pipeline
34 lines
1.1 KiB
Swift
34 lines
1.1 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2021 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import NIO
|
|
@testable import NIOSOCKS
|
|
import XCTest
|
|
|
|
public class ServerResponseTests: XCTestCase {
|
|
}
|
|
|
|
// MARK: - ServeResponse
|
|
extension ServerResponseTests {
|
|
|
|
func testServerResponseReadFromByteBuffer() {
|
|
var buffer = ByteBuffer(bytes: [0x05, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x00, 0x50])
|
|
XCTAssertEqual(buffer.readableBytes, 10)
|
|
XCTAssertNoThrow(XCTAssertEqual(try buffer.readServerResponse(),
|
|
.init(reply: .succeeded, boundAddress: .address(try! .init(ipAddress: "1.2.3.4", port: 80)))))
|
|
XCTAssertEqual(buffer.readableBytes, 0)
|
|
}
|
|
|
|
}
|