Skip to content

Implement SOCKS proxy functionality #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5a49c2c
Basic socks functionality
Davidde94 Jun 16, 2021
b45f4d9
Remove auth field
Davidde94 Jun 16, 2021
8e1232a
Remove test addresses
Davidde94 Jun 16, 2021
974677f
Working tests
Davidde94 Jun 16, 2021
122f650
Update packages
Davidde94 Jun 16, 2021
f1598be
Merge branch 'main' into de/socks-client
Davidde94 Jun 16, 2021
481e1b1
Rename to MockSOCKSServer
Davidde94 Jun 17, 2021
064edcb
Code review cleanup
Davidde94 Jun 17, 2021
210c4d7
Cleanup public authorization
Davidde94 Jun 17, 2021
18c7103
Throw error on auth data
Davidde94 Jun 17, 2021
323eefd
Add missing socks server test
Davidde94 Jun 17, 2021
c273847
Fabians test cleanup
Davidde94 Jun 17, 2021
3c0e120
Remove redundant auth complete write
Davidde94 Jun 17, 2021
ba629a4
Add test for speaking to wrong server type
Davidde94 Jun 17, 2021
e4c1b52
Add misbehaving server test
Davidde94 Jun 17, 2021
d718299
Guard against multiple requests
Davidde94 Jun 17, 2021
eee59e3
Soundness
Davidde94 Jun 17, 2021
112d5b1
Soundness
Davidde94 Jun 17, 2021
976fe2e
Update Sources/AsyncHTTPClient/HTTPClientProxyHandler.swift
Davidde94 Jun 17, 2021
ea04cfa
Support bogus addresses
Davidde94 Jun 17, 2021
ddc009a
Merge branch 'de/socks-client' of github.com:Davidde94/async-http-cli…
Davidde94 Jun 17, 2021
221420f
Swift format
Davidde94 Jun 17, 2021
91a1636
Soundness
Davidde94 Jun 17, 2021
15e5334
Address PR comments
Davidde94 Jun 18, 2021
c61184e
Cory PR nits
Davidde94 Jun 18, 2021
97c6b7f
Soundness
Davidde94 Jun 18, 2021
dd405af
Fabian nit
Davidde94 Jun 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Soundness
  • Loading branch information
Davidde94 committed Jun 18, 2021
commit 97c6b7f9e1a37d2033e618d1d41a7d27eb6837cd
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.29.0"),
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.13.0"),
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.9.0"),
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.9.1"),
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.5.1"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
],
Expand Down
4 changes: 2 additions & 2 deletions Sources/AsyncHTTPClient/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ extension NIOClientTCPBootstrap {
switch proxy.type {
case .http:
try channel.pipeline.syncAddHTTPProxyHandler(host: host,
port: port,
authorization: proxy.authorization)
port: port,
authorization: proxy.authorization)
case .socks:
try channel.pipeline.syncAddSOCKSProxyHandler(host: host, port: port)
}
Expand Down
6 changes: 2 additions & 4 deletions Tests/AsyncHTTPClientTests/HTTPClient+SOCKSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
//===----------------------------------------------------------------------===//

/* NOT @testable */ import AsyncHTTPClient // Tests that need @testable go into HTTPClientInternalTests.swift
import Logging
import NIO
import NIOSOCKS
import XCTest
import Logging

class HTTPClientSOCKSTests: XCTestCase {

typealias Request = HTTPClient.Request

var clientGroup: EventLoopGroup!
Expand Down Expand Up @@ -72,7 +71,7 @@ class HTTPClientSOCKSTests: XCTestCase {
XCTAssertNotNil(self.backgroundLogStore)
self.backgroundLogStore = nil
}

func testProxySOCKS() throws {
let socksBin = try MockSOCKSServer(expectedURL: "/socks/test", expectedResponse: "it works!")
let localClient = HTTPClient(eventLoopGroupProvider: .shared(self.clientGroup),
Expand Down Expand Up @@ -135,5 +134,4 @@ class HTTPClientSOCKSTests: XCTestCase {
// the server will send a bogus message in response to the clients request
XCTAssertThrowsError(try localClient.get(url: "http://localhost/socks/test").wait())
}

}