Commit 8df1cb1
fix: resolve hostname and strip port in WireGuard peer detection
When a WireGuard endpoint uses a hostname with a custom port
(e.g. myvpn.example.com:51820), scutil reports the RemoteAddress
in that form. The previous code attempted to parse it directly as
an IpAddr, which fails both because of the port suffix and because
hostnames require DNS resolution.
Strip the port suffix (handling host:port and [ipv6]:port), then
resolve the hostname to an IPv4 address before passing it to
is_valid_vpn_peer.
Fixes #35
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent da86b2d commit 8df1cb1
1 file changed
Lines changed: 41 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
235 | | - | |
236 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
237 | 270 | | |
238 | | - | |
| 271 | + | |
239 | 272 | | |
240 | | - | |
| 273 | + | |
241 | 274 | | |
242 | | - | |
| 275 | + | |
243 | 276 | | |
244 | 277 | | |
245 | 278 | | |
| |||
0 commit comments