Skip to content

Commit

Permalink
Resurface the list of allowedIPs to make it configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Feb 13, 2024
1 parent 66f4b14 commit e3af7f6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 1 addition & 4 deletions ios/PacketTunnel/WireGuardAdapter/WgAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ private extension TunnelAdapterConfiguration {
if let peer {
var peerConfig = PeerConfiguration(publicKey: peer.publicKey)
peerConfig.endpoint = peer.endpoint.wgEndpoint
peerConfig.allowedIPs = [
IPAddressRange(from: "0.0.0.0/0")!,
IPAddressRange(from: "::/0")!,
]
peerConfig.allowedIPs = allowedIPs
peers.append(peerConfig)
}

Expand Down
4 changes: 3 additions & 1 deletion ios/PacketTunnelCore/Actor/ConfigurationBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ struct ConfigurationBuilder {
var interfaceAddresses: [IPAddressRange]
var dns: SelectedDNSServers?
var endpoint: MullvadEndpoint?
var allowedIPs: [IPAddressRange]

func makeConfiguration() throws -> TunnelAdapterConfiguration {
return TunnelAdapterConfiguration(
privateKey: privateKey,
interfaceAddresses: interfaceAddresses,
dns: dnsServers,
peer: try peer
peer: try peer,
allowedIPs: allowedIPs
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ extension PacketTunnelActor {
do {
let configurationBuilder = ConfigurationBuilder(
privateKey: PrivateKey(),
interfaceAddresses: []
interfaceAddresses: [],
allowedIPs: []
)
var config = try configurationBuilder.makeConfiguration()
config.dns = [IPv4Address.loopback]
Expand Down
6 changes: 5 additions & 1 deletion ios/PacketTunnelCore/Actor/PacketTunnelActor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ extension PacketTunnelActor {
privateKey: activeKey,
interfaceAddresses: settings.interfaceAddresses,
dns: settings.dnsServers,
endpoint: connectionState.connectedEndpoint
endpoint: connectionState.connectedEndpoint,
allowedIPs: [
IPAddressRange(from: "0.0.0.0/0")!,
IPAddressRange(from: "::/0")!,
]
)

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public struct TunnelAdapterConfiguration {
public var interfaceAddresses: [IPAddressRange]
public var dns: [IPAddress]
public var peer: TunnelPeer?
public var allowedIPs: [IPAddressRange]
}

/// Struct describing a single peer.
Expand Down

0 comments on commit e3af7f6

Please sign in to comment.