<?php
$result2 = '{
"wg0": {
"privateKey": "[hidden]",
"publicKey": "XXXXXXXXXXXXXXXXXXX",
"listenPort": 0,
"peers": {
"B3GtLuabWguXoG2Tz8KVukPXx3twn7A+X/SVT8=": {
"endpoint": "0.0.0.0:5377",
"latestHandshake": "Oct 28, 2020 1:58:32 UTC",
"transferRx": "2.432 GB",
"transferTx": "1.098 GB",
"allowedIps": [
"10.85.85.2/32"
]
},
"2Uqo3X2ubogU92LS4mWsZtF04ah3qJ4gt1g0=": {
"endpoint": "0.0.0.0:5412",
"latestHandshake": "Oct 28, 2020 1:58:52 UTC",
"transferRx": "32.239 MB",
"transferTx": "220.852 MB",
"allowedIps": [
"10.85.85.3/32"
]
}
}
}
}';
$obj2 = json_decode($result2, true);
$IPtoSearch = "10.85.85.2/32";
foreach ($obj2['wg0']['peers'] as $peer) {
if (in_array($IPtoSearch, $peer['allowedIps'])) {
$latestHandshake = $peer['latestHandshake'];
break;
}
}
echo "Last handshake for $IPtoSearch was at $latestHandshake\n";
preferences:
26.27 ms | 405 KiB | 5 Q