Skip to content

Commit 5ad25c0

Browse files
committed
Changed for eduVPN
- fix building on Xcode 16. See: WireGuard/wireguard-apple#33 - support ProxyGuard using the forked wireguard-go as a submodule - fix split tunnel DNS search domains, see: https://lists.zx2c4.com/pipermail/wireguard/2021-July/006927.html from eduvpn/apple#524 - Update Go modules
1 parent 2fec12a commit 5ad25c0

25 files changed

+100
-725
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "Sources/WireGuardKitGo/wireguard-go"]
2+
path = Sources/WireGuardKitGo/wireguard-go
3+
url = https://codeberg.org/eduVPN/wireguard-go

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ This project contains an application for iOS and for macOS, as well as many comp
44

55
## Building
66

7-
- Clone this repo:
7+
- Clone this repo and its submodule:
88

99
```
10-
$ git clone https://git.zx2c4.com/wireguard-apple
10+
$ git clone --recursive https://git.zx2c4.com/wireguard-apple
1111
$ cd wireguard-apple
1212
```
1313

Sources/Shared/Model/TunnelConfiguration+WgQuickConfig.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extension TunnelConfiguration {
2727
case peerHasInvalidPreSharedKey(String)
2828
case peerHasInvalidAllowedIP(String)
2929
case peerHasInvalidEndpoint(String)
30+
case peerHasInvalidProxyEndpoint(String)
3031
case peerHasInvalidPersistentKeepAlive(String)
3132
case peerHasInvalidTransferBytes(String)
3233
case peerHasInvalidLastHandshakeTime(String)
@@ -72,7 +73,7 @@ extension TunnelConfiguration {
7273
attributes[key] = value
7374
}
7475
let interfaceSectionKeys: Set<String> = ["privatekey", "listenport", "address", "dns", "mtu"]
75-
let peerSectionKeys: Set<String> = ["publickey", "presharedkey", "allowedips", "endpoint", "persistentkeepalive"]
76+
let peerSectionKeys: Set<String> = ["publickey", "presharedkey", "allowedips", "endpoint", "proxyendpoint", "persistentkeepalive"]
7677
if parserState == .inInterfaceSection {
7778
guard interfaceSectionKeys.contains(key) else {
7879
throw ParseError.interfaceHasUnrecognizedKey(keyWithCase)
@@ -156,6 +157,9 @@ extension TunnelConfiguration {
156157
if let endpoint = peer.endpoint {
157158
output.append("Endpoint = \(endpoint.stringRepresentation)\n")
158159
}
160+
if let proxyEndpoint = peer.proxyEndpoint {
161+
output.append("ProxyEndpoint = \(proxyEndpoint.absoluteString)\n")
162+
}
159163
if let persistentKeepAlive = peer.persistentKeepAlive {
160164
output.append("PersistentKeepalive = \(persistentKeepAlive)\n")
161165
}
@@ -240,6 +244,12 @@ extension TunnelConfiguration {
240244
}
241245
peer.endpoint = endpoint
242246
}
247+
if let proxyEndpointString = attributes["proxyendpoint"] {
248+
guard let proxyEndpoint = URL(string: proxyEndpointString) else {
249+
throw ParseError.peerHasInvalidProxyEndpoint(proxyEndpointString)
250+
}
251+
peer.proxyEndpoint = URL(string: proxyEndpointString)
252+
}
243253
if let persistentKeepAliveString = attributes["persistentkeepalive"] {
244254
guard let persistentKeepAlive = UInt16(persistentKeepAliveString) else {
245255
throw ParseError.peerHasInvalidPersistentKeepAlive(persistentKeepAliveString)

Sources/WireGuardApp/Base.lproj/Localizable.strings

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"tunnelPeerPublicKey" = "Public key";
9090
"tunnelPeerPreSharedKey" = "Preshared key";
9191
"tunnelPeerEndpoint" = "Endpoint";
92+
"tunnelPeerProxyEndpoint" = "Proxy Endpoint";
9293
"tunnelPeerPersistentKeepalive" = "Persistent keepalive";
9394
"tunnelPeerAllowedIPs" = "Allowed IPs";
9495
"tunnelPeerRxBytes" = "Data received";
@@ -187,6 +188,7 @@
187188
"alertInvalidPeerMessagePreSharedKeyInvalid" = "Peer’s preshared key must be a 32-byte key in base64 encoding";
188189
"alertInvalidPeerMessageAllowedIPsInvalid" = "Peer’s allowed IPs must be a list of comma-separated IP addresses, optionally in CIDR notation";
189190
"alertInvalidPeerMessageEndpointInvalid" = "Peer’s endpoint must be of the form ‘host:port’ or ‘[host]:port’";
191+
"alertInvalidPeerMessageProxyEndpointInvalid" = "Peer’s proxy endpoint must be a valid URL";
190192
"alertInvalidPeerMessagePersistentKeepaliveInvalid" = "Peer’s persistent keepalive must be between 0 to 65535, or unspecified";
191193
"alertInvalidPeerMessagePublicKeyDuplicated" = "Two or more peers cannot have the same public key";
192194

@@ -395,10 +397,11 @@
395397
"macAlertPreSharedKeyInvalid" = "Preshared key is invalid";
396398
"macAlertAllowedIPInvalid (%@)" = "Allowed IP ‘%@’ is invalid";
397399
"macAlertEndpointInvalid (%@)" = "Endpoint ‘%@’ is invalid";
400+
"macAlertProxyEndpointInvalid (%@)" = "Proxy Endpoint ‘%@’ is invalid";
398401
"macAlertPersistentKeepliveInvalid (%@)" = "Persistent keepalive value ‘%@’ is invalid";
399402

400403
"macAlertUnrecognizedPeerKey (%@)" = "Peer contains unrecognized key ‘%@’";
401-
"macAlertInfoUnrecognizedPeerKey" = "Valid keys are: ‘PublicKey’, ‘PresharedKey’, ‘AllowedIPs’, ‘Endpoint’ and ‘PersistentKeepalive’";
404+
"macAlertInfoUnrecognizedPeerKey" = "Valid keys are: ‘PublicKey’, ‘PresharedKey’, ‘AllowedIPs’, ‘Endpoint’, 'ProxyEndpoint' and ‘PersistentKeepalive’";
402405

403406
"macAlertMultipleEntriesForKey (%@)" = "There should be only one entry per section for key ‘%@’";
404407

Sources/WireGuardApp/Tunnel/TunnelConfiguration+UapiConfig.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ extension TunnelConfiguration {
140140
}
141141
peer.endpoint = endpoint
142142
}
143+
if let proxyEndpointString = attributes["proxy_endpoint"] {
144+
guard let proxyEndpoint = URL(string: proxyEndpointString) else {
145+
throw ParseError.peerHasInvalidProxyEndpoint(proxyEndpointString)
146+
}
147+
peer.proxyEndpoint = proxyEndpoint
148+
}
143149
if let persistentKeepAliveString = attributes["persistent_keepalive_interval"] {
144150
guard let persistentKeepAlive = UInt16(persistentKeepAliveString) else {
145151
throw ParseError.peerHasInvalidPersistentKeepAlive(persistentKeepAliveString)

Sources/WireGuardApp/UI/TunnelViewModel.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class TunnelViewModel {
4141
case publicKey
4242
case preSharedKey
4343
case endpoint
44+
case proxyEndpoint
4445
case persistentKeepAlive
4546
case allowedIPs
4647
case rxBytes
@@ -54,6 +55,7 @@ class TunnelViewModel {
5455
case .publicKey: return tr("tunnelPeerPublicKey")
5556
case .preSharedKey: return tr("tunnelPeerPreSharedKey")
5657
case .endpoint: return tr("tunnelPeerEndpoint")
58+
case .proxyEndpoint: return tr("tunnelPeerProxyEndpoint")
5759
case .persistentKeepAlive: return tr("tunnelPeerPersistentKeepalive")
5860
case .allowedIPs: return tr("tunnelPeerAllowedIPs")
5961
case .rxBytes: return tr("tunnelPeerRxBytes")
@@ -314,6 +316,9 @@ class TunnelViewModel {
314316
if let endpoint = config.endpoint {
315317
scratchpad[.endpoint] = endpoint.stringRepresentation
316318
}
319+
if let proxyEndpoint = config.proxyEndpoint {
320+
scratchpad[.proxyEndpoint] = proxyEndpoint.absoluteString
321+
}
317322
if let persistentKeepAlive = config.persistentKeepAlive {
318323
scratchpad[.persistentKeepAlive] = String(persistentKeepAlive)
319324
}
@@ -372,6 +377,14 @@ class TunnelViewModel {
372377
errorMessages.append(tr("alertInvalidPeerMessageEndpointInvalid"))
373378
}
374379
}
380+
if let proxyEndpointString = scratchpad[.proxyEndpoint] {
381+
if let proxyEndpoint = URL(string: proxyEndpointString) {
382+
config.proxyEndpoint = proxyEndpoint
383+
} else {
384+
fieldsWithError.insert(.proxyEndpoint)
385+
errorMessages.append(tr("alertInvalidPeerMessageProxyEndpointInvalid"))
386+
}
387+
}
375388
if let persistentKeepAliveString = scratchpad[.persistentKeepAlive] {
376389
if let persistentKeepAlive = UInt16(persistentKeepAliveString) {
377390
config.persistentKeepAlive = persistentKeepAlive

Sources/WireGuardApp/UI/iOS/ViewController/TunnelDetailTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TunnelDetailTableViewController: UITableViewController {
1919
]
2020

2121
static let peerFields: [TunnelViewModel.PeerField] = [
22-
.publicKey, .preSharedKey, .endpoint,
22+
.publicKey, .preSharedKey, .endpoint, .proxyEndpoint,
2323
.allowedIPs, .persistentKeepAlive,
2424
.rxBytes, .txBytes, .lastHandshakeTime
2525
]

Sources/WireGuardApp/UI/iOS/ViewController/TunnelEditTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ extension TunnelEditTableViewController {
356356
case .publicKey:
357357
cell.placeholderText = tr("tunnelEditPlaceholderTextRequired")
358358
cell.keyboardType = .default
359-
case .preSharedKey, .endpoint:
359+
case .preSharedKey, .endpoint, .proxyEndpoint:
360360
cell.placeholderText = tr("tunnelEditPlaceholderTextOptional")
361361
cell.keyboardType = .default
362362
case .allowedIPs:

Sources/WireGuardApp/UI/macOS/ParseError+WireGuardAppError.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ extension TunnelConfiguration.ParseError: WireGuardAppError {
3939
return (tr(format: "macAlertAllowedIPInvalid (%@)", value), tr("alertInvalidPeerMessageAllowedIPsInvalid"))
4040
case .peerHasInvalidEndpoint(let value):
4141
return (tr(format: "macAlertEndpointInvalid (%@)", value), tr("alertInvalidPeerMessageEndpointInvalid"))
42+
case .peerHasInvalidProxyEndpoint(let value):
43+
return (tr(format: "macAlertProxyEndpointInvalid (%@)", value), tr("alertInvalidPeerMessageProxyEndpointInvalid"))
4244
case .peerHasInvalidPersistentKeepAlive(let value):
4345
return (tr(format: "macAlertPersistentKeepliveInvalid (%@)", value), tr("alertInvalidPeerMessagePersistentKeepaliveInvalid"))
4446
case .peerHasUnrecognizedKey(let value):

Sources/WireGuardApp/UI/macOS/View/ConfTextColorTheme.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct ConfTextAquaColorTheme: ConfTextColorTheme {
1616
HighlightPublicKey.rawValue: NSColor(hex: "#643820"), // Preprocessor directives in Xcode
1717
HighlightPrivateKey.rawValue: NSColor(hex: "#643820"), // Preprocessor directives in Xcode
1818
HighlightPresharedKey.rawValue: NSColor(hex: "#643820"), // Preprocessor directives in Xcode
19+
HighlightProxyEndpoint.rawValue: NSColor(hex: "#9B2393"), // Preprocessor directives in Xcode
1920
HighlightIP.rawValue: NSColor(hex: "#0E0EFF"), // URLs in Xcode
2021
HighlightHost.rawValue: NSColor(hex: "#0E0EFF"), // URLs in Xcode
2122
HighlightCidr.rawValue: NSColor(hex: "#815F03"), // Attributes in Xcode
@@ -35,6 +36,7 @@ struct ConfTextDarkAquaColorTheme: ConfTextColorTheme {
3536
HighlightPublicKey.rawValue: NSColor(hex: "#FD8F3F"), // Preprocessor directives in Xcode
3637
HighlightPrivateKey.rawValue: NSColor(hex: "#FD8F3F"), // Preprocessor directives in Xcode
3738
HighlightPresharedKey.rawValue: NSColor(hex: "#FD8F3F"), // Preprocessor directives in Xcode
39+
HighlightProxyEndpoint.rawValue: NSColor(hex: "#9B2393"), // Preprocessor directives in Xcode
3840
HighlightIP.rawValue: NSColor(hex: "#53A5FB"), // URLs in Xcode
3941
HighlightHost.rawValue: NSColor(hex: "#53A5FB"), // URLs in Xcode
4042
HighlightCidr.rawValue: NSColor(hex: "#75B492"), // Attributes in Xcode

0 commit comments

Comments
 (0)