Add Support for IPV6 and Arbitrary Server Address
Add IPV6 support for Apple Devices Note: Works in GUI not CLI Adds Support for Arbitrary Server Address
This commit is contained in:
parent
cca5999214
commit
2088ae6ede
20 changed files with 276 additions and 56 deletions
|
|
@ -31,7 +31,7 @@ struct BurrowStartRequest: Codable {
|
|||
let no_pi: Bool
|
||||
let tun_excl: Bool
|
||||
let tun_retrieve: Bool
|
||||
let address: String?
|
||||
let address: [String]
|
||||
}
|
||||
struct StartOptions: Codable {
|
||||
let tun: TunOptions
|
||||
|
|
@ -51,7 +51,7 @@ struct BurrowResult<T>: Codable where T: Codable {
|
|||
|
||||
struct ServerConfigData: Codable {
|
||||
struct InternalConfig: Codable {
|
||||
let address: String?
|
||||
let address: [String]
|
||||
let name: String?
|
||||
let mtu: Int32?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
command: BurrowStartRequest(
|
||||
Start: BurrowStartRequest.StartOptions(
|
||||
tun: BurrowStartRequest.TunOptions(
|
||||
name: nil, no_pi: false, tun_excl: false, tun_retrieve: true, address: nil
|
||||
name: nil, no_pi: false, tun_excl: false, tun_retrieve: true, address: []
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -46,12 +46,21 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
|
||||
private func generateTunSettings(from: ServerConfigData) -> NETunnelNetworkSettings? {
|
||||
let cfig = from.ServerConfig
|
||||
guard let addr = cfig.address else {
|
||||
return nil
|
||||
}
|
||||
// Using a makeshift remote tunnel address
|
||||
let nst = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "1.1.1.1")
|
||||
nst.ipv4Settings = NEIPv4Settings(addresses: [addr], subnetMasks: ["255.255.255.0"])
|
||||
var v4Addresses = [String]()
|
||||
var v6Addresses = [String]()
|
||||
for addr in cfig.address {
|
||||
if IPv4Address(addr) != nil {
|
||||
v6Addresses.append(addr)
|
||||
}
|
||||
if IPv6Address(addr) != nil {
|
||||
v4Addresses.append(addr)
|
||||
}
|
||||
}
|
||||
nst.ipv4Settings = NEIPv4Settings(addresses: v4Addresses, subnetMasks: v4Addresses.map { _ in
|
||||
"255.255.255.0"
|
||||
})
|
||||
nst.ipv6Settings = NEIPv6Settings(addresses: v6Addresses, networkPrefixLengths: v6Addresses.map { _ in 64 })
|
||||
logger.log("Initialized ipv4 settings: \(nst.ipv4Settings)")
|
||||
return nst
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue