iOS 1.0.3 source candidate only; no Apple build or installation acceptance
This commit is contained in:
@@ -27,10 +27,28 @@ final class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
guard let self else { return }
|
||||
do {
|
||||
let resolvedRemoteAddress: String
|
||||
if let providedRemoteAddress, NetworkAddress.isPublicIPv4(providedRemoteAddress) {
|
||||
let runtimeJSON: String
|
||||
if let endpointData = providerConfiguration["internalEndpointJSON"] as? Data {
|
||||
let endpoint = try JSONDecoder().decode(ProxyTransportEndpoint.self, from: endpointData)
|
||||
guard endpoint.address == providedRemoteAddress,
|
||||
ProxyTransportPolicy.authorizedInternalEndpoint(
|
||||
endpoint: endpoint,
|
||||
nodeSlug: providerConfiguration["nodeSlug"] as? String ?? "",
|
||||
configContract: providerConfiguration["configContract"] as? Int,
|
||||
connectionScope: providerConfiguration["connectionScope"] as? String,
|
||||
routeMode: providerConfiguration["routeMode"] as? String ?? "",
|
||||
configJSON: rawJSON
|
||||
) != nil else {
|
||||
throw UCVLError.invalidConfiguration("内部代理入口与授权配置不一致。")
|
||||
}
|
||||
resolvedRemoteAddress = endpoint.address
|
||||
runtimeJSON = try ProxyTransportPolicy.internalConfigJSON(rawJSON: rawJSON, endpoint: endpoint)
|
||||
} else if let providedRemoteAddress, NetworkAddress.isPublicIPv4(providedRemoteAddress) {
|
||||
resolvedRemoteAddress = providedRemoteAddress
|
||||
runtimeJSON = rawJSON
|
||||
} else {
|
||||
resolvedRemoteAddress = try Self.resolveIPv4Address(remoteHost)
|
||||
runtimeJSON = rawJSON
|
||||
}
|
||||
let settings = self.makeNetworkSettings(remoteAddress: resolvedRemoteAddress)
|
||||
self.setTunnelNetworkSettings(settings) { [weak self] error in
|
||||
@@ -50,7 +68,7 @@ final class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
throw UCVLError.invalidConfiguration("路由规则资源缺失。")
|
||||
}
|
||||
let config = try TunnelConfigurationBuilder.makeConfiguration(
|
||||
rawJSON: rawJSON,
|
||||
rawJSON: runtimeJSON,
|
||||
tunnelFileDescriptor: tunnelFD,
|
||||
assetDirectory: geoIP.deletingLastPathComponent().path,
|
||||
resolvedRemoteAddress: resolvedRemoteAddress
|
||||
@@ -142,7 +160,7 @@ final class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
var hints = addrinfo()
|
||||
hints.ai_flags = AI_ADDRCONFIG
|
||||
hints.ai_family = AF_INET
|
||||
hints.ai_socktype = Int32(SOCK_STREAM.rawValue)
|
||||
hints.ai_socktype = SOCK_STREAM
|
||||
hints.ai_protocol = IPPROTO_TCP
|
||||
var results: UnsafeMutablePointer<addrinfo>?
|
||||
let status = host.withCString { getaddrinfo($0, nil, &hints, &results) }
|
||||
|
||||
Reference in New Issue
Block a user