Skip to content

Instantly share code, notes, and snippets.

@NghiaTranUIT
Created March 15, 2021 13:20
Show Gist options
  • Save NghiaTranUIT/b2e234fcb47f77d1e53f926953da7fb7 to your computer and use it in GitHub Desktop.
Save NghiaTranUIT/b2e234fcb47f77d1e53f926953da7fb7 to your computer and use it in GitHub Desktop.
private func newPacketTunnelSettings(proxyHost: String, proxyPort: Int) -> NEPacketTunnelNetworkSettings {
let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
/* proxy settings */
let proxySettings = NEProxySettings()
proxySettings.httpServer = NEProxyServer(
address: proxyHost,
port: proxyPort
)
proxySettings.httpsServer = NEProxyServer(
address: proxyHost,
port: proxyPort
)
proxySettings.autoProxyConfigurationEnabled = false
proxySettings.httpEnabled = true
proxySettings.httpsEnabled = true
proxySettings.matchDomains = [""]
settings.proxySettings = proxySettings
/* ipv4 settings */
let ipv4Settings = NEIPv4Settings(addresses: ["192.169.89.1"], subnetMasks: ["255.255.255.0"])
settings.ipv4Settings = ipv4Settings
/* MTU */
settings.mtu = 1500
// DNS
let dnsSettings = NEDNSSettings(servers: ["8.8.8.8", "1.1.1.1"])
dnsSettings.matchDomains = [""]
dnsSettings.matchDomainsNoSearch = false
settings.dnsSettings = dnsSettings
return settings
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment