iOS 17+ પર NWConnection SOCKS5 પ્રોક્સી ગોઠવો
NWConnection બનાવતા પહેલાં iOS 17 SOCKSv5 ProxyConfiguration ને NWParameters.PrivacyContext સાથે જોડો.
iOS 17 અને ત્યારપછીના વર્ઝનમાં Network.framework ગોપનીયતા સંદર્ભ દ્વારા SOCKSv5 પ્રોક્સી લાગુ કરી શકે છે. કનેક્શન બનાવતા પહેલાં તે સંદર્ભને પરિમાણો સાથે જોડો:
import Network
@available(iOS 17.0, *)
func makeConnection() -> NWConnection {
let parameters = NWParameters.tls
let context = NWParameters.PrivacyContext(description: "Service route")
let endpoint = NWEndpoint.hostPort(
host: "proxy.example", port: 1080)
context.proxyConfigurations = [
ProxyConfiguration(socksv5Proxy: endpoint)
]
parameters.setPrivacyContext(context)
return NWConnection(
host: "service.example", port: 443, using: parameters)
}
ફંક્શન શરૂ ન થયેલું TLS કનેક્શન પરત કરે છે. એપ્લિકેશનનું સ્થિતિ સંચાલન સ્થાપિત કરો, તેને ઇચ્છિત કતારમાં શરૂ કરો અને પછી તેના સામાન્ય મોકલવા અને મેળવવાના માર્ગ દ્વારા એપ્લિકેશન પ્રોટોકોલની આપલે કરો.
proxy.example:1080 એ SOCKS શ્રોતા છે. મંજૂર જાહેર સેવા કનેક્શન માટે SOCKS5 પ્રોક્સી યાદી યજમાન અને પોર્ટના ઉમેદવારો પૂરા પાડે છે. service.example:443 ગંતવ્ય રહે છે. ગોપનીયતા સંદર્ભ તેની પ્રોક્સી ગોઠવણીઓ તે સંદર્ભ સાથે જોડાયેલા કનેક્શન પર લાગુ કરે છે; બીજા પરિમાણો સાથે અસંબંધિત કનેક્શન બનાવવાથી આ સેટઅપ વારસામાં મળતું નથી.
આ Network.framework નું કનેક્શન ઇન્ટરફેસ છે. URLSession પ્રોક્સી ઓવરરાઇડ અથવા WKWebView ડેટા-સ્ટોર સેટિંગ તે અલગ ઉપભોક્તાઓને ગોઠવે છે. NWConnection પર બનેલા WebSocket માટે, એપ્લિકેશને યોગ્ય WebSocket પ્રોટોકોલ વિકલ્પો પણ પૂરા પાડવા જોઈએ.