Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
Fix SOCKS5 proxy when client makes requests with IP address
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuhaow committed Sep 13, 2016
1 parent f11d052 commit 25f5e8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
I will do my best to guarantee that this project adheres to [Semantic Versioning](http://semver.org/) after 1.0.0, but please do read change log before updating.

## [0.5.2]
## Fixed
- SOCKS5 proxy correctly handles connections with IP address.

## [0.5.1]
## Added
- Now one can initailize a `Port` by an integer directly.
Expand Down
4 changes: 2 additions & 2 deletions src/Socket/ProxySocket/SOCKS5ProxySocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public class SOCKS5ProxySocket: ProxySocket {
case SocketTag.SOCKS5.ConnectIPv4:
var address = [Int8](count: Int(INET_ADDRSTRLEN), repeatedValue: 0)
inet_ntop(AF_INET, data.bytes, &address, socklen_t(INET_ADDRSTRLEN))
destinationHost = NSString(bytes: &address, length: Int(INET_ADDRSTRLEN), encoding: NSUTF8StringEncoding)! as String
destinationHost = NSString(CString: &address, encoding: NSUTF8StringEncoding)! as String
socket.readDataToLength(2, withTag: SocketTag.SOCKS5.ConnectPort)
case SocketTag.SOCKS5.ConnectIPv6:
var address = [Int8](count: Int(INET6_ADDRSTRLEN), repeatedValue: 0)
inet_ntop(AF_INET, data.bytes, &address, socklen_t(INET6_ADDRSTRLEN))
destinationHost = NSString(bytes: &address, length: Int(INET6_ADDRSTRLEN), encoding: NSUTF8StringEncoding)! as String
destinationHost = NSString(CString: &address, encoding: NSUTF8StringEncoding)! as String
socket.readDataToLength(2, withTag: SocketTag.SOCKS5.ConnectPort)
case SocketTag.SOCKS5.ConnectDomainLength:
let length: UInt8 = UnsafePointer<UInt8>(data.bytes).memory
Expand Down

0 comments on commit 25f5e8f

Please sign in to comment.