惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
T
Tailwind CSS Blog
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
P
Proofpoint News Feed
D
Docker
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
有赞技术团队
有赞技术团队
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
博客园 - Franky
The GitHub Blog
The GitHub Blog
月光博客
月光博客
小众软件
小众软件
Martin Fowler
Martin Fowler
P
Palo Alto Networks Blog
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
T
Threat Research - Cisco Blogs
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
K
Kaspersky official blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Securelist
Spread Privacy
Spread Privacy
博客园 - 聂微东
B
Blog
The Hacker News
The Hacker News
Simon Willison's Weblog
Simon Willison's Weblog
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
P
Privacy International News Feed
腾讯CDC
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Threatpost
T
Tenable Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyberwarzone
Cyberwarzone
C
Cybersecurity and Infrastructure Security Agency CISA
Stack Overflow Blog
Stack Overflow Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Heimdal Security Blog

博客 on 打工人日志

k8s RKE2 cilium L2 + envoy gateway 安装配置 k8s RKE2 vSphere 存储配置 OpenClaw 全能指南:从安装到进阶自动化实战 (2026 最终版) Kubernetes — skywalking + banyanDB APM监控部署 Kubernetes — promtail + loki + grafana 日志系统部署 k8s master 节点 Unauthorized Kubernetes — metalLB + Traefik 部署 Kubernetes — SSL 证书自动更新 Kubernetes — RKE2 + kube-vip + cilium 部署 使用TLSv1.3 升级nginx和openssl Proxmox VE(PVE) 更新到最新版本 kindle 邮件发送失败,错误代码E999 metallb + ingress-nginx + argocd 本地部署 iStoreOS(旁路由)使用openclash实现dns劫持 异常流量分析:图片库服务黑客入侵 openwrt 硬盘扩容 Kubernetes — k8s 手动安装 1.17.9 SELinux 问题:导致端口无法创建,无法访问 【福利】免费!本地部署!去除视频中移动的物体 通知:《打工人日报》迁移到独立板块 KyBook 3 | calibre-web - IOS系统最佳图书伴侣 Tmux 安装和使用教程 DockerHub 加速镜像部署 - 使用cloudflare 代理 docker的零停机部署 SD-webui 批量处理图片 ubuntu 安装 ComfyUI ubuntu 安装 stable-diffusion-webui 测试策略:微服务架构 单元测试:测试单元质量提升 端到端测试:模拟用户体验 Kubernetes — containerd 安装和部署 CI/CD 可观察性-基于grafana Argo cd 安装和部署 linux服务器进程打开文件过多导致服务异常 使用 ElasticSearch Curator 7天定期删除日志 sonarqube docker安装和配置 SSH 通过 443 端口连接 GitHub iOS 17 「待机显示」适配普通 iPhone(非 Pro/Max),屏幕在充电时常亮 GNU/Linux 一键更换系统软件源脚本 解决Elasticsearch索引只读(read-only) 【福利】埃隆·马斯克传 [沃尔特·艾萨克森] 在线下载 【破解】小鹏P5和小鹏G9开启adb和网络adb Kubernetes — kubecost 分析 Kubernetes 成本 3D Gaussian Splatting:3D模型渲染 Linux 系统收包流程以及内核参数优化 2023亚运会电竞门票民购买指南(报名+抽签) Vue3 + vite + nginx项目部署后404问题 大麦抢票辅助软件(福利 TFBOYS十年之约演唱会 2023 全机位 视频) 黑群晖最新安装教程 Ansible部署ceph集群 最好的微信朋友圈集赞神器-福利推荐 推荐一下 容器云资源 2010年的天涯神贴聊房价 如何礼貌回绝不合理的需求 nginx 配置和编译 github 国内代理访问下载 使用scrapy-redis实现增量爬取 逆境和成长-2022年终总结 优雅的使用Conda管理python环境 Jenkins 编译Android apk 流水线 Kubernetes — 更新证书 shell功能脚本集合 Nexus3 使用和部署 githubAction set-output弃用错误 Kubernetes — Rook云存储介绍和部署 Kubernetes — 基于K8S搭建Ceph分布式存储 Kubernetes — 探针和生命周期 Kubernetes — 开放标准(OCI、CRI、CNI、CSI、SMI、CPI)概述 kubernetes 部署插件 (Flannel、Web UI、CoreDNS、Ingress Controller) Cloudflare Zero Trust 内网穿透 k8s CNI 问题 连接认证失效 k8s.gcr.io国内无法连接解决方法 headscale 部署使用 羊了个羊小程序 破解通关 K8S 问题排查:cgroup 内存泄露问题 RocketMQ k8s部署 4主4从集群 docker 问题处理 kubernetes 存储 linux服务器 删除空间却未释放 kubernetes 从1.23.x 升级到 1.24.x 编写 kubernetes 资源描述文件 nginx ssh-key connection exception kubernetes manual expansion VSCode插件推荐=> Code Runner ant build.xml 编写 kubernetes 调度过程 记录一次上门打散工 k8s本地联调神器kt-connect Ant中如何添加第三方jar包依赖 OpenELB:让k8s私有环境对外暴露端口 linux 网络测速 安装 docker 出现 ERROR: Unsupported distribution 'ol' 问题 logrotate 日志滚动的使用 nginx 编译参数详解 nginx 重写规则 rewrite模块 nginx.conf 配置文件详解 rsync 文件同步 nginx 日志格式整理 163企业邮箱设置教程 2021年第50周记
搭建ip地址检索服务
2024-10-11 · via 博客 on 打工人日志

很多时候,我们需要查询一个IP地址,都得通过百度,谷歌,或者其他搜索引擎,非常麻烦。教大家一个使用cloudflare worker搭建一个只属于我们自己的ip地址检索服务。

  1addEventListener('fetch', event => {
  2  event.respondWith(handleRequest(event.request));
  3});
  4
  5/**
  6 * Handle the incoming request and return formatted IP information
  7 * @param {Request} request
  8 */
  9async function handleRequest(request) {
 10  const url = new URL(request.url);
 11  const queryIp = url.searchParams.get('ip');
 12  const clientIp = queryIp || request.headers.get('cf-connecting-ip');
 13  const path = url.pathname;
 14
 15  // 获取 IP 信息
 16  const ipInfo = await getIpInfo(clientIp);
 17
 18  // 根据路径选择返回格式
 19  if (path === '/table') {
 20    const tableFormat = formatAsTable(ipInfo);
 21    return new Response(tableFormat, {
 22      headers: { 'Content-Type': 'text/plain; charset=utf-8' },
 23      status: 200,
 24    });
 25  } else {
 26    return new Response(JSON.stringify(ipInfo), {
 27      headers: { 'Content-Type': 'application/json' },
 28      status: 200,
 29    });
 30  }
 31}
 32
 33/**
 34 * Get IP information and format it according to the required structure
 35 * @param {string} ip
 36 */
 37async function getIpInfo(ip) {
 38  try {
 39    const response = await fetch(`http://ip-api.com/json/${ip}`);
 40    const data = await response.json();
 41
 42    // Format the returned data
 43    return {
 44      ip: data.query || ip,
 45      city: data.city || "None",
 46      province: data.regionName || "None",
 47      country: data.country || "None",
 48      continent: data.continent || "None",
 49      isp: data.isp || "None",
 50      time_zone: data.timezone || "None",
 51      latitude: data.lat || 0,
 52      longitude: data.lon || 0,
 53      postal_code: data.zip || "None",
 54      iso_code: data.countryCode || "None",
 55      notice: "Let it be",
 56      provider: "Powered by Jobcher",
 57      blog: "https://www.jobcher.com",
 58      data_updatetime: new Date().toISOString().slice(0, 10).replace(/-/g, '')
 59    };
 60  } catch (error) {
 61    return {
 62      ip: ip,
 63      city: "None",
 64      province: "None",
 65      country: "None",
 66      continent: "None",
 67      isp: "None",
 68      time_zone: "None",
 69      latitude: 0,
 70      longitude: 0,
 71      postal_code: "None",
 72      iso_code: "None",
 73      notice: "Let it be",
 74      provider: "Powered by Jobcher",
 75      blog: "https://www.jobcher.com",
 76      data_updatetime: new Date().toISOString().slice(0, 10).replace(/-/g, '')
 77    };
 78  }
 79}
 80
 81/**
 82 * Format the IP information as a table-like structure
 83 * @param {Object} info
 84 */
 85function formatAsTable(info) {
 86  const pad = (str, length) => str.toString().padEnd(length, ' ');
 87  const keyWidth = 20;  // Adjusted width for keys
 88  const valueWidth = 60; // Adjusted width for values
 89
 90  const lineBorder = (keyLength, valueLength) =>
 91    `┏${'━'.repeat(keyLength)}${'━'.repeat(valueLength)}┓`;
 92  const lineMiddle = (keyLength, valueLength) =>
 93    `┡${'━'.repeat(keyLength)}${'━'.repeat(valueLength)}┩`;
 94  const lineEnd = (keyLength, valueLength) =>
 95    `└${'─'.repeat(keyLength)}${'─'.repeat(valueLength)}┘`;
 96
 97  const borderTop = lineBorder(keyWidth+2, valueWidth+2);
 98  const borderMiddle = lineMiddle(keyWidth+2, valueWidth+2);
 99  const borderBottom = lineEnd(keyWidth+2, valueWidth+2);
100
101  const lines = [
102    '                                  ip.jobcher.com                               ',
103    borderTop,
104    `┃ ${pad('key', keyWidth)}${pad('value', valueWidth)} ┃`,
105    borderMiddle,
106    `│ ${pad('ip', keyWidth)}${pad(info.ip, valueWidth)} │`,
107    `│ ${pad('city', keyWidth)}${pad(info.city, valueWidth)} │`,
108    `│ ${pad('province', keyWidth)}${pad(info.province, valueWidth)} │`,
109    `│ ${pad('country', keyWidth)}${pad(info.country, valueWidth)} │`,
110    `│ ${pad('continent', keyWidth)}${pad(info.continent, valueWidth)} │`,
111    `│ ${pad('isp', keyWidth)}${pad(info.isp, valueWidth)} │`,
112    `│ ${pad('time_zone', keyWidth)}${pad(info.time_zone, valueWidth)} │`,
113    `│ ${pad('latitude', keyWidth)}${pad(info.latitude, valueWidth)} │`,
114    `│ ${pad('longitude', keyWidth)}${pad(info.longitude, valueWidth)} │`,
115    `│ ${pad('postal_code', keyWidth)}${pad(info.postal_code, valueWidth)} │`,
116    `│ ${pad('iso_code', keyWidth)}${pad(info.iso_code, valueWidth)} │`,
117    `│ ${pad('notice', keyWidth)}${pad(info.notice, valueWidth)} │`,
118    `│ ${pad('', keyWidth)}${pad('©2020-01-01->now', valueWidth)} │`,
119    `│ ${pad('provider', keyWidth)}${pad(info.provider, valueWidth)} │`,
120    `│ ${pad('blog', keyWidth)}${pad(info.blog, valueWidth)} │`,
121    `│ ${pad('data_updatetime', keyWidth)}${pad(info.data_updatetime, valueWidth)} │`,
122    borderBottom,
123    ` `,
124  ];
125
126  return lines.join('\n');
127}
1# 查询本地ip
2curl ip.jobcher.com
1# 查询指定ip
2curl ip.jobcher.com?ip=1.1.1.1
1curl ip.jobcher.com/table
1curl ip.jobcher.com/table?ip=1.1.1.1