Awesome. I use BunnyCDN as well (previously KeyCDN) configured with ProCache, mainly because they publish the list of IPs they use if their edge-servers need to pull assets (and then serve) from your website.
While this post isn't directly related to your module, it matters if you are using WireRequestBlocker for the reasons I explained here (post only viewable if you have access).
Long story short, if a CDN makes a request to a URL on your site that matches a blocking rule in WireRequestBlocker (rare, but it's bound to happen by accident) then the IP of that particular BunnyCDN edge-server will get blocked. Then if a visitor on your site is being sent assets from that edge server, then it will error because the CDN was never able to obtain it due to the edge-server being blocked.
This is why the site might look fine in California, but broken in New York for example, as the user is being sent assets from different edge-servers.
To prevent this from happening, I have a cronjob set up (runs every 24 hours) to grab the list of BunnyCDN edge-server IPs and I insert it into WireRequestBlockers "IP addresses to whitelist" field.
This is a function that can do what I described above:
function bunnycdnWhitelistIps() {
if(!wire('modules')->isInstalled('WireRequestBlocker')) return false;
// Fetch BunnyCDN edge server list
$url = 'https://bunnycdn.com/api/system/edgeserverlist';
// Use cURL to fetch the content
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpCode !== 200 || $response === false) {
throw new WireException("Error fetching data from BunnyCDN API. HTTP Code: $httpCode\n");
}
// Parse the JSON response
$data = json_decode($response, true);
if(json_last_error() !== JSON_ERROR_NONE) {
throw new WireException("Invalid IPs.");
}
// Extract IP addresses into an array
$ipAddresses = [];
if(isset($data) && is_array($data)) {
foreach($data as $ip) {
if(filter_var($ip, FILTER_VALIDATE_IP)) {
$ipAddresses[] = $ip;
}
}
}
// Remove duplicates and sort
$ipAddresses = array_unique($ipAddresses);
sort($ipAddresses);
$data = wire('modules')->getModuleConfigData('WireRequestBlocker');
$data['goodIps'] = implode("\n", $ipAddresses);
wire('modules')->saveModuleConfigData('WireRequestBlocker', $data);
}