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

Commit

Permalink
Fix that SOCKS adapter sends IP bytes in wrong order
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuhaow committed Jun 22, 2017
1 parent 7cf22ea commit 26e7d04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
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.12.0

### Fixed
- Fix that the SOCKS adapter will send IP bytes in wrong order.

## 0.11.0

### Changed
Expand Down
6 changes: 4 additions & 2 deletions src/Socket/AdapterSocket/SOCKS5Adapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ public class SOCKS5Adapter: AdapterSocket {
var response: [UInt8]
if session.isIPv4() {
response = [0x05, 0x01, 0x00, 0x01]
response += Utils.IP.IPv4ToBytes(session.host)!
let address = IPAddress(fromString: session.host)!
response += [UInt8](address.dataInNetworkOrder)
} else if session.isIPv6() {
response = [0x05, 0x01, 0x00, 0x04]
response += Utils.IP.IPv6ToBytes(session.host)!
let address = IPAddress(fromString: session.host)!
response += [UInt8](address.dataInNetworkOrder)
} else {
response = [0x05, 0x01, 0x00, 0x03]
response.append(UInt8(session.host.utf8.count))
Expand Down

0 comments on commit 26e7d04

Please sign in to comment.