1// API Integration for AS215666 Website 2// Fetches data from PeeringDB and RIPE Stat APIs 3 4const AS_NUMBER = 215666; 5const PEERINGDB_NET_ID = 39997; 6 7// Static fallback data 8const FALLBACK_DATA = { 9 asn: 215666, 10 name: 'AS215666', 11 prefixes: { 12 ipv4: '5.175.209.0/24', 13 ipv6: ['2a14:1ec1:7b10::/44', '2a14:7581:9e00::/40'] 14 }, 15 ixp_count: 1, 16 peering_policy: 'Open', 17 ixps: [ 18 { name: 'Inter-IX', city: 'Den Haag', country: 'NL', facility: 'ColoCenter', lat: 52.033362664736394, lng: 4.497329547368041, type: 'ixp' }, 19 { name: 'NETMOUNTAINS Velbert 1', city: 'Velbert', country: 'DE', lat: 51.34926588668576, lng: 7.068135060649708, main: true, type: 'datacenter' }, 20 { name: 'Realtox Media', city: 'Upstream Provider', country: 'DE', lat: 51.34926588668576, lng: 7.068135060649708, type: 'upstream' } 21 ] 22}; 23 24/** 25 * Fetch data from PeeringDB API 26 */ 27async function fetchPeeringDBData() { 28 try { 29 const response = await fetch(`https://www.peeringdb.com/api/net/${PEERINGDB_NET_ID}`); 30 31 if (!response.ok) { 32 throw new Error('PeeringDB API request failed'); 33 } 34 35 const data = await response.json(); 36 console.log('PeeringDB data loaded:', data); 37 return data; 38 } catch (error) { 39 console.warn('Failed to fetch PeeringDB data, using fallback:', error); 40 return null; 41 } 42} 43 44/** 45 * Fetch network data from RIPE Stat API 46 */ 47async function fetchRIPEData() { 48 try { 49 const response = await fetch(`https://stat.ripe.net/data/network-info/data.json?resource=AS${AS_NUMBER}`); 50 51 if (!response.ok) { 52 throw new Error('RIPE Stat API request failed'); 53 } 54 55 const data = await response.json(); 56 console.log('RIPE data loaded:', data); 57 return data; 58 } catch (error) { 59 console.warn('Failed to fetch RIPE data, using fallback:', error); 60 return null; 61 } 62} 63 64/** 65 * Get IXP locations data 66 */ 67function getIXPLocations() { 68 return FALLBACK_DATA.ixps; 69} 70 71/** 72 * Get network stats 73 */ 74async function getNetworkStats() { 75 const peeringdbData = await fetchPeeringDBData(); 76 const ripeData = await fetchRIPEData(); 77 78 // Use API data if available, otherwise use fallback 79 return { 80 asn: AS_NUMBER, 81 prefix_count: 3, 82 ixp_count: FALLBACK_DATA.ixp_count, 83 peering_policy: FALLBACK_DATA.peering_policy, 84 prefixes: FALLBACK_DATA.prefixes 85 }; 86} 87 88/** 89 * Update stats on homepage 90 */ 91async function updateHomepageStats() { 92 const stats = await getNetworkStats(); 93 94 // Update prefix count if element exists 95 const prefixCountEl = document.getElementById('prefix-count'); 96 if (prefixCountEl) { 97 prefixCountEl.textContent = stats.prefix_count; 98 } 99 100 // Update IXP count if element exists 101 const ixpCountEl = document.getElementById('ixp-count'); 102 if (ixpCountEl) { 103 ixpCountEl.textContent = stats.ixp_count; 104 } 105} 106 107// Auto-initialize on page load 108if (document.readyState === 'loading') { 109 document.addEventListener('DOMContentLoaded', () => { 110 if (document.getElementById('prefix-count') || document.getElementById('ixp-count')) { 111 updateHomepageStats(); 112 } 113 }); 114} else { 115 if (document.getElementById('prefix-count') || document.getElementById('ixp-count')) { 116 updateHomepageStats(); 117 } 118} 119 120// Export functions for use in other scripts 121window.AS215666 = { 122 fetchPeeringDBData, 123 fetchRIPEData, 124 getIXPLocations, 125 getNetworkStats, 126 FALLBACK_DATA 127};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.