{"id":568,"date":"2025-08-01T11:03:17","date_gmt":"2025-08-01T03:03:17","guid":{"rendered":"https:\/\/blog.lcsoul.cn\/?p=568"},"modified":"2025-08-01T11:03:17","modified_gmt":"2025-08-01T03:03:17","slug":"%e4%bd%bf%e7%94%a8%e9%98%bf%e9%87%8c%e4%ba%91esa%e8%be%b9%e7%bc%98%e5%87%bd%e6%95%b0%e8%8e%b7%e5%8f%96%e8%ae%bf%e9%97%ae%e7%94%a8%e6%88%b7ip","status":"publish","type":"post","link":"https:\/\/blog.lcsoul.top\/index.php\/2025\/08\/01\/%e4%bd%bf%e7%94%a8%e9%98%bf%e9%87%8c%e4%ba%91esa%e8%be%b9%e7%bc%98%e5%87%bd%e6%95%b0%e8%8e%b7%e5%8f%96%e8%ae%bf%e9%97%ae%e7%94%a8%e6%88%b7ip\/","title":{"rendered":"\u4f7f\u7528\u963f\u91cc\u4e91ESA\u8fb9\u7f18\u51fd\u6570\u83b7\u53d6\u8bbf\u95ee\u7528\u6237IP"},"content":{"rendered":"<pre class=\"corepress-code-pre\"><code>\nasync function handleRequest(request) {\n    const url = new URL(request.url);\n    const path = url.pathname;\n    const ip = request.headers.get('x-forwarded-for')?.split(',')[0]||request.headers.get('x-alicdn-security-xff')\n    if(path==='\/'){\n        return new Response(ip, {\n            headers: {\n            \"content-type\": \"text\/html;charset=UTF-8\",\n            },\n        })\n    } else if(path==='\/json'){\n        return new Response(JSON.stringify({ ip }), {\n        headers: {\n            'content-type': 'application\/json',\n        },\n        });\n    } else if(path==='\/info'){\n        const info = {\n            ip,\n            geo: request.info\n        }\n        return new Response(JSON.stringify({ info }), {\n            headers: {\n                'content-type': 'application\/json',\n            },\n        });\n    } else {\n        return new Response(\"404\", {status: 404})\n    }\n    \n}\n\nexport default {\n  async fetch(request) {\n    return handleRequest(request);\n  }\n};\n<\/code><\/pre>\n<p><span style=\"color: #ffffff;\"><a style=\"color: #ffffff;\" href=\"http:\/\/ip.esa.lcsoul.cn\/\">\u83b7\u53d6\u8bbf\u95eeIP\uff08\u652f\u6301IPv6\uff09<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>async function handleRequest(request) { const url = new [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,17,18],"tags":[],"class_list":["post-568","post","type-post","status-publish","format-standard","hentry","category-esa","category-17","category-18"],"_links":{"self":[{"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/posts\/568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/comments?post=568"}],"version-history":[{"count":0,"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/posts\/568\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/media?parent=568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/categories?post=568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lcsoul.top\/index.php\/wp-json\/wp\/v2\/tags?post=568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}