iOS开发大神总结

iOS 使用socks5代理服务器

2018-09-04  本文已影响115人  redexpress

iOS 使用socks5代理服务器需要配置URLSessionConfiguration,如下:

let dict: [String:Any] = [kCFStreamPropertySOCKSProxyPort as String: 9180,  kCFStreamPropertySOCKSProxyHost as String: "127.0.0.1"]
let configuration = URLSessionConfiguration.ephemeral
configuration.connectionProxyDictionary = dict
let session = URLSession(configuration: configuration)
let task = session.dataTask(with: URL(string: "http://httpbin.org/get")!){
    data, response, error in print(response ?? "")
}
task.resume()
上一篇下一篇

猜你喜欢

热点阅读