Skip to content

Commit f5dcd5d

Browse files
SgrA*SgrA*
authored andcommitted
feat: block-count
1 parent d9c4085 commit f5dcd5d

File tree

11 files changed

+38
-718
lines changed

11 files changed

+38
-718
lines changed

Sources/Shared/Model/TunnelConfiguration+WgQuickConfig.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extension TunnelConfiguration {
2929
case peerHasInvalidEndpoint(String)
3030
case peerHasInvalidPersistentKeepAlive(String)
3131
case peerHasInvalidTransferBytes(String)
32+
case peerHasInvalidBlockedCount(String)
3233
case peerHasInvalidLastHandshakeTime(String)
3334
case peerHasUnrecognizedKey(String)
3435
case multiplePeersWithSamePublicKey

Sources/WireGuardApp/Tunnel/TunnelConfiguration+UapiConfig.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension TunnelConfiguration {
5252
}
5353

5454
let interfaceSectionKeys: Set<String> = ["private_key", "listen_port", "fwmark"]
55-
let peerSectionKeys: Set<String> = ["public_key", "preshared_key", "allowed_ip", "endpoint", "persistent_keepalive_interval", "last_handshake_time_sec", "last_handshake_time_nsec", "rx_bytes", "tx_bytes", "protocol_version"]
55+
let peerSectionKeys: Set<String> = ["public_key", "preshared_key", "allowed_ip", "endpoint", "persistent_keepalive_interval", "last_handshake_time_sec", "last_handshake_time_nsec", "rx_bytes", "tx_bytes", "protocol_version", "blocked"]
5656

5757
if parserState == .inInterfaceSection {
5858
guard interfaceSectionKeys.contains(key) else {
@@ -163,6 +163,13 @@ extension TunnelConfiguration {
163163
if txBytes != 0 {
164164
peer.txBytes = txBytes
165165
}
166+
if let blockedString = attributes["blocked"] {
167+
guard let blocked = UInt64(blockedString) else {
168+
throw ParseError.peerHasInvalidBlockedCount(blockedString)
169+
}
170+
if blocked != 0 {
171+
peer.blocked = blocked
172+
}
166173
}
167174
if let lastHandshakeTimeSecString = attributes["last_handshake_time_sec"] {
168175
var lastHandshakeTimeSince1970: TimeInterval = 0

Sources/WireGuardApp/UI/TunnelViewModel.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class TunnelViewModel {
4545
case allowedIPs
4646
case rxBytes
4747
case txBytes
48+
case blocked
4849
case lastHandshakeTime
4950
case excludePrivateIPs
5051
case deletePeer
@@ -58,6 +59,7 @@ class TunnelViewModel {
5859
case .allowedIPs: return tr("tunnelPeerAllowedIPs")
5960
case .rxBytes: return tr("tunnelPeerRxBytes")
6061
case .txBytes: return tr("tunnelPeerTxBytes")
62+
case .blocked: return tr("blocked")
6163
case .lastHandshakeTime: return tr("tunnelPeerLastHandshakeTime")
6264
case .excludePrivateIPs: return tr("tunnelPeerExcludePrivateIPs")
6365
case .deletePeer: return tr("deletePeerButtonTitle")
@@ -323,6 +325,9 @@ class TunnelViewModel {
323325
if let txBytes = config.txBytes {
324326
scratchpad[.txBytes] = prettyBytes(txBytes)
325327
}
328+
if let blocked = config.blocked {
329+
scratchpad[.blocked] = prettyBytes(blocked)
330+
}
326331
if let lastHandshakeTime = config.lastHandshakeTime {
327332
scratchpad[.lastHandshakeTime] = prettyTimeAgo(timestamp: lastHandshakeTime)
328333
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TunnelDetailTableViewController: UITableViewController {
2121
static let peerFields: [TunnelViewModel.PeerField] = [
2222
.publicKey, .preSharedKey, .endpoint,
2323
.allowedIPs, .persistentKeepAlive,
24-
.rxBytes, .txBytes, .lastHandshakeTime
24+
.rxBytes, .txBytes, .blocked, .lastHandshakeTime
2525
]
2626

2727
static let onDemandFields: [ActivateOnDemandViewModel.OnDemandField] = [

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ extension TunnelEditTableViewController {
367367
cell.keyboardType = .numberPad
368368
case .excludePrivateIPs, .deletePeer:
369369
cell.keyboardType = .default
370-
case .rxBytes, .txBytes, .lastHandshakeTime:
370+
case .rxBytes, .txBytes, .blocked, .lastHandshakeTime:
371371
fatalError()
372372
}
373373

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ extension TunnelConfiguration.ParseError: WireGuardAppError {
4545
return (tr(format: "macAlertUnrecognizedPeerKey (%@)", value), tr("macAlertInfoUnrecognizedPeerKey"))
4646
case .peerHasInvalidTransferBytes(let line):
4747
return (tr(format: "macAlertInvalidLine (%@)", String(line)), "")
48+
case .peerHasInvalidBlockedCount(let line):
49+
return (tr(format: "macAlertInvalidLine (%@)", String(line)), "")
4850
case .peerHasInvalidLastHandshakeTime(let line):
4951
return (tr(format: "macAlertInvalidLine (%@)", String(line)), "")
5052
case .multiplePeersWithSamePublicKey:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TunnelDetailTableViewController: NSViewController {
4141
static let peerFields: [TunnelViewModel.PeerField] = [
4242
.publicKey, .preSharedKey, .endpoint,
4343
.allowedIPs, .persistentKeepAlive,
44-
.rxBytes, .txBytes, .lastHandshakeTime
44+
.rxBytes, .txBytes, .blocked, .lastHandshakeTime
4545
]
4646

4747
static let onDemandFields: [ActivateOnDemandViewModel.OnDemandField] = [

Sources/WireGuardKit/PeerConfiguration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public struct PeerConfiguration {
1111
public var persistentKeepAlive: UInt16?
1212
public var rxBytes: UInt64?
1313
public var txBytes: UInt64?
14+
public var blocked: UInt64?
1415
public var lastHandshakeTime: Date?
1516

1617
public init(publicKey: PublicKey) {

Sources/WireGuardKitGo/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ GOARCH_x86_64 := amd64
2121
GOOS_macosx := darwin
2222
GOOS_iphoneos := ios
2323

24-
GO_VERSION := 1.17.13
24+
GO_VERSION := 1.20.2
2525
GO_PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]')-$(GOARCH_$(shell uname -m))
2626
GO_TARBALL := go$(GO_VERSION).$(GO_PLATFORM).tar.gz
27-
GO_HASH_darwin-amd64 := 0fea4e2498067dcf199c71be78bb940f7861efd8ae03c672992d2d65d31f9fc8
28-
GO_HASH_darwin-arm64 := e4ccc9c082d91eaa0b866078b591fc97d24b91495f12deb3dd2d8eda4e55a6ea
27+
GO_HASH_darwin-amd64 := c93b8ced9517d07e1cd4c362c6e2d5242cb139e29b417a328fbf19aded08764c
28+
GO_HASH_darwin-arm64 := 7343c87f19e79c0063532e82e1c4d6f42175a32d99f7a4d15e658e88bf97f885
2929

3030
build: $(DESTDIR)/libwg-go.a
3131
version-header: $(DESTDIR)/wireguard-go-version.h

Sources/WireGuardKitGo/go.mod

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
module golang.zx2c4.com/wireguard/apple
22

3-
go 1.17
3+
go 1.20
44

55
require (
6-
golang.org/x/sys v0.5.0
7-
golang.zx2c4.com/wireguard v0.0.0-20230209153558-1e2c3e5a3c14
6+
golang.org/x/sys v0.6.0
7+
golang.zx2c4.com/wireguard v0.0.0-20230309202816-787da6420c65
88
)
99

1010
require (
11-
golang.org/x/crypto v0.6.0 // indirect
12-
golang.org/x/net v0.6.0 // indirect
11+
golang.org/x/crypto v0.7.0 // indirect
12+
golang.org/x/net v0.8.0 // indirect
1313
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
1414
)
15+
16+
replace golang.zx2c4.com/wireguard => github.com/safehousetech/wireguard-go v0.0.20200321-0.20230312122755-9baf4cf4bcfe

0 commit comments

Comments
 (0)