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

Commit

Permalink
Fixed a very edge case where inet_ntoa does not support multi-thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuhaow committed Sep 14, 2016
1 parent 7817099 commit 3a5795e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 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.4]
## Fixed
- Fixed a very edge case where `inet_ntoa` does not support multi-thread.

## [0.5.3]
## Fixed
- SOCKS5 proxy now can correctly process IPv6 requests. Thx yarshure.
Expand Down
7 changes: 4 additions & 3 deletions src/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ public struct Utils {
return ""
}

let remoteAddr = UnsafeMutablePointer<in_addr>(remoteHostEnt.memory.h_addr_list[0]).memory
let remoteAddr = UnsafeMutablePointer<Void>(remoteHostEnt.memory.h_addr_list[0])

let addr = inet_ntoa(remoteAddr)
return NSString(UTF8String: addr)! as String
var output = [Int8](count: Int(INET6_ADDRSTRLEN), repeatedValue: 0)
inet_ntop(AF_INET, remoteAddr, &output, socklen_t(INET6_ADDRSTRLEN))
return NSString(UTF8String: output)! as String
}
}

Expand Down

0 comments on commit 3a5795e

Please sign in to comment.