使用CloudFlare时在底部显示当前节点代码


代码:

当前CDN节点: <span  id="cdn">unknown</span>
<!--在适当的地方放入需要显示CDN节点的信息-->
<script>
getCDNinfo = function() {
$.ajax({
    url: "/cdn-cgi/trace",
    success: function(data, status) {
        let areas = "Antananarivo, 
Madagascar - (TNR);Cape Town, South 
Africa - (CPT);Casablanca, Morocco - 
(CMN);Dar Es Salaam, Tanzania - 
(DAR);Djibouti City, Djibouti - 
(JIB);Durban, South Africa - 
(DUR);Johannesburg, South Africa - 
(JNB);Kigali, Rwanda - (KGL);Lagos, 
Nigeria - (LOS);Luanda, Angola - 
(LAD);Maputo, MZ - (MPM);Mombasa, Kenya - (MBA);Port Louis, Mauritius - 
(MRU);Réunion, France - 
(RUN);Bangalore, India - (BLR);Bangkok, Thailand - (BKK);Bandar 
Seri Begawan, Brunei - (BWN);Cebu, 
Philippines - (CEB);Chengdu, China - 
(CTU);Chennai, India - 
(MAA);Chittagong, Bangladesh - 
(CGP);Chongqing, China - 
(CKG);Colombo, Sri Lanka - 
(CMB);Dhaka, Bangladesh - 
(DAC);Dongguan, China - (SZX);Foshan, 
China - (FUO);Fuzhou, China - 
(FOC);Guangzhou, China - 
(CAN);Hangzhou, China - (HGH);Hanoi, 
Vietnam - (HAN);Hengyang, China - 
(HNY);Ho Chi Minh City, Vietnam - 
(SGN);Hong Kong - (HKG);Hyderabad, 
India - (HYD);Islamabad, Pakistan - 
(ISB);Jakarta, Indonesia - 
(CGK);Jinan, China - (TNA);Karachi, 
Pakistan - (KHI);Kathmandu, Nepal - 
(KTM);Kolkata, India - (CCU);Kuala Lumpur, Malaysia - (KUL);Lahore, Pakistan - (LHE);Langfang, China - (NAY);Luoyang, 
China - (LYA);Macau - (MFM);Malé, 
Maldives - (MLE);Manila, Philippines - 
(MNL);Mumbai, India - (BOM);Nagpur, India - (NAG);Nanning, China - (NNG);New 
Delhi, India - (DEL);Osaka, Japan - 
(KIX);Phnom Penh, Cambodia - 
(PNH);Qingdao, China - (TAO);Seoul, South Korea - (ICN);Shanghai, China - 
(SHA);Shenyang, China - 
(SHE);Shijiazhuang, China - 
(SJW);Singapore, Singapore - 
(SIN);Suzhou, China - (SZV);Taipei - 
(TPE);Thimphu, Bhutan - (PBH);Tianjin, 
China - (TSN);Tokyo, Japan - 
(NRT);Ulaanbaatar, Mongolia - 
(ULN);Vientiane, Laos - (VTE);Wuhan, 
China - (WUH);Wuxi, China - 
(WUX);Xi'an, China - (XIY);Yerevan, 
Armenia - (EVN);Zhengzhou, China - 
(CGO);Zuzhou, China - (CSX);Amsterdam, 
Netherlands - (AMS);Athens, Greece - 
(ATH);Barcelona, Spain - 
(BCN);Belgrade, Serbia - (BEG);Berlin, 
Germany - (TXL);Brussels, Belgium - 
(BRU);Bucharest, Romania - 
(OTP);Budapest, Hungary - 
(BUD);Chișinău, Moldova - 
(KIV);Copenhagen, Denmark - 
(CPH);Cork, Ireland -  (ORK);Dublin, 
Ireland - (DUB);Düsseldorf, Germany - 
(DUS);Edinburgh, United Kingdom - 
(EDI);Frankfurt, Germany - 
(FRA);Geneva, Switzerland - 
(GVA);Gothenburg, Sweden - 
(GOT);Hamburg, Germany - 
(HAM);Helsinki, Finland - 
(HEL);Istanbul, Turkey - (IST);Kyiv, 
Ukraine - (KBP);Lisbon, Portugal - 
(LIS);London, United Kingdom - 
(LHR);Luxembourg City, Luxembourg - 
(LUX);Madrid, Spain - 
(MAD);Manchester, United Kingdom - 
(MAN);Marseille, France - (MRS);Milan, 
Italy - (MXP);Moscow, Russia - 
(DME);Munich, Germany - (MUC);Nicosia, 
Cyprus - (LCA);Oslo, Norway - 
(OSL);Paris, France - (CDG);Prague, 
Czech Republic - (PRG);Reykjavík, 
Iceland - (KEF);Riga, Latvia - 
(RIX);Rome, Italy - (FCO);Saint 
Petersburg, Russia - (LED);Sofia, 
Bulgaria - (SOF);Stockholm, Sweden - 
(ARN);Tallinn, Estonia - 
(TLL);Thessaloniki, Greece - 
(SKG);Vienna, Austria - (VIE);Vilnius, 
Lithuania - (VNO);Warsaw, Poland - 
(WAW);Zagreb, Croatia - (ZAG);Zürich, 
Switzerland - (ZRH);Arica, Chile - 
(ARI);Asunción, Paraguay - 
(ASU);Bogotá, Colombia - (BOG);Buenos 
Aires, Argentina - (EZE);Curitiba, 
Brazil - (CWB);Fortaleza, Brazil - 
(FOR);Guatemala City, Guatemala - 
(GUA);Lima, Peru - (LIM);Medellín, 
Colombia - (MDE);Panama City, Panama - 
(PTY);Porto Alegre, Brazil - 
(POA);Quito, Ecuador - (UIO);Rio de 
Janeiro, Brazil - (GIG);São Paulo, Brazil - (GRU);Santiago, Chile - 
(SCL);Willemstad, Curaçao - (CUR);St. 
George's, Grenada - (GND);Amman, 
Jordan - (AMM);Baghdad, Iraq - (BGW);Baku, 
Azerbaijan - (GYD);Beirut, Lebanon - 
(BEY);Doha, Qatar - (DOH);Dubai, 
United Arab Emirates - (DXB);Kuwait 
City, Kuwait - (KWI);Manama, Bahrain - 
(BAH);Muscat, Oman - (MCT);Ramallah - 
(ZDM);Riyadh, Saudi Arabia - (RUH);Tel  Aviv, Israel - (TLV);Ashburn, VA, United 
States - (IAD);Atlanta, GA, United 
States - (ATL);Boston, MA, United 
States - (BOS);Buffalo, NY, United 
States - (BUF);Calgary, AB, Canada - 
(YYC);Charlotte, NC, United States - 
(CLT);Chicago, IL, United States - 
(ORD);Columbus, OH, United States - 
(CMH);Dallas, TX, United States - 
(DFW);Denver, CO, United States - 
(DEN);Detroit, MI, United States - 
(DTW);Honolulu, HI, United States - 
(HNL);Houston, TX, United States - 
(IAH);Indianapolis, IN, United States - (IND);Jacksonville, FL, United States - 
(JAX);Kansas City, MO, United States - 
(MCI);Las Vegas, NV, United States - 
(LAS);Los Angeles, CA, United States - 
(LAX);McAllen, TX, United States - 
(MFE);Memphis, TN, United States - 
(MEM);Mexico City, Mexico - 
(MEX);Miami, FL, United States - 
(MIA);Minneapolis, MN, United States - 
(MSP);Montgomery, AL, United States - 
(MGM);Montréal, QC, Canada - 
(YUL);Nashville, TN, United States - 
(BNA);Newark, NJ, United States - 
(EWR);Norfolk, VA, United States - 
(ORF);Omaha, NE, United States - 
(OMA);Philadelphia, United States - 
(PHL);Phoenix, AZ, United States - 
(PHX);Pittsburgh, PA, United States - 
(PIT);Port-Au-Prince, Haiti - 
(PAP);Portland, OR, United States - 
(PDX);Queretaro, MX, Mexico - 
(QRO);Richmond, Virginia - 
(RIC);Sacramento, CA, United States - 
(SMF);Salt Lake City, UT, United 
States - (SLC);San Diego, CA, United 
States - (SAN);San Jose, CA, United 
States - (SJC);Saskatoon, SK, Canada - 
(YXE);Seattle, WA, United States - 
(SEA);St. Louis, MO, United States - 
(STL);Tampa, FL, United States - 
(TPA);Toronto, ON, Canada - 
(YYZ);Vancouver, BC, Canada - 
(YVR);Tallahassee, FL, United States - 
(TLH);Winnipeg, MB, Canada - 
(YWG);Adelaide, SA, Australia - 
(ADL);Auckland, New Zealand - 
(AKL);Brisbane, QLD, Australia - 
(BNE);Melbourne, VIC, Australia - 
(MEL);Noumea, New caledonia - 
(NOU);Perth, WA, Australia - 
(PER);Sydney, NSW, Australia - 
(SYD)".split(";");
        let area = data.split("colo=")[1].split("\n")[0];
        for (var i = 0; i < areas.length; i++) {
            if (areas[i].indexOf(area) != -1) {
                document.getElementById("cdn").innerHTML = areas[i];
                break;
            }
        }
    }
})
}
$(document).ready(function() {
getCDNinfo();
//页面加载完毕就获取CDN信息
});
</script>

声明:渐行渐远|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - 使用CloudFlare时在底部显示当前节点代码