<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Linus的FUN天地</title><description>Linus Xiong 的个人博客：技术笔记、运维实践与生活记录。</description><link>https://blog.xsy.fun/</link><language>zh-CN</language><lastBuildDate>Wed, 21 Oct 2026 01:00:00 GMT</lastBuildDate><atom:link href="https://blog.xsy.fun/rss.xml" rel="self" type="application/rss+xml"/><generator>Astro</generator><item><title>新博客为什么这么快？从技术选型到每一个字节</title><link>https://blog.xsy.fun/posts/why-this-blog-is-fast/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/why-this-blog-is-fast/</guid><description>把博客从 Hexo 重写为 Astro 之后，首屏约一秒、Lighthouse 四项 100。这篇文章深入浅出地讲清楚技术选型、构建管线，以及 CSS、JavaScript、字体、图片、导航、SEO 每一层各做了什么取舍，并给出实测数字。</description><pubDate>Wed, 21 Oct 2026 01:00:00 GMT</pubDate><content:encoded>&lt;p&gt;博客重做了一遍。最直观的变化是：点开任何一页，内容几乎是瞬间出现的。这不是换了更贵的服务器，而是从技术选型开始，把每一层&quot;没必要的东西&quot;都拿掉了。这篇文章把背后的取舍讲清楚：为什么选静态站点和 Astro，构建管线长什么样，CSS、JavaScript、字体、图片、页面切换、SEO 各做了什么，以及用数字说明效果。&lt;/p&gt;
&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;先看结果&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E5%85%88%E7%9C%8B%E7%BB%93%E6%9E%9C&quot;&gt;先看结果&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;下面是一篇典型文章页在生产环境的数据（移动端 Lighthouse，模拟慢速网络）：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot; tabindex=&quot;0&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;指标&lt;/th&gt;&lt;th&gt;数值&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;HTML（gzip 后）&lt;/td&gt;&lt;td&gt;16–18 KB，样式已包含在内&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;CSS&lt;/td&gt;&lt;td&gt;约 20 KB，内联在页面里，零额外请求&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;首屏 JavaScript&lt;/td&gt;&lt;td&gt;约 6 KB（主题切换、搜索框、复制按钮、链接预取）&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Web 字体&lt;/td&gt;&lt;td&gt;0 字节&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;首屏第三方请求&lt;/td&gt;&lt;td&gt;0 个&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Lighthouse&lt;/td&gt;&lt;td&gt;性能 100 · 无障碍 100 · 最佳实践 100 · SEO 100&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;CLS（布局偏移）&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;这些数字不是靠某一个&quot;黑科技&quot;，而是每一层都少做一点事的累积结果。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;为什么是静态站点为什么是-astro&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E4%B8%BA%E4%BB%80%E4%B9%88%E6%98%AF%E9%9D%99%E6%80%81%E7%AB%99%E7%82%B9%E4%B8%BA%E4%BB%80%E4%B9%88%E6%98%AF-astro&quot;&gt;为什么是静态站点，为什么是 Astro&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;博客的本质是&quot;写好的文章给人读&quot;，内容在我提交的那一刻就确定了。那就没有理由让服务器在每次访问时重新渲染，更没有理由让读者的浏览器下载一个应用框架再把文章&quot;水合&quot;一遍。所以第一个决定是：&lt;strong&gt;全部在构建时生成静态 HTML&lt;/strong&gt;，服务器（其实是 CDN）只负责把文件发出去。&lt;/p&gt;
&lt;p&gt;选型时我实际构建了几个候选方案，量了它们在一个&quot;预渲染好的文章页&quot;上下发多少 JavaScript：&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot; tabindex=&quot;0&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;方案&lt;/th&gt;&lt;th&gt;文章页下发的 JS（gzip）&lt;/th&gt;&lt;th&gt;说明&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Astro 7（静态输出）&lt;/td&gt;&lt;td&gt;&lt;strong&gt;0 B&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;默认零 JS，需要交互时按需加载&quot;岛屿&quot;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;TanStack Start 1.0（React）&lt;/td&gt;&lt;td&gt;约 108 KB&lt;/td&gt;&lt;td&gt;预渲染之后仍然要整页水合，没有零 JS 模式&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;TanStack Start（Solid）&lt;/td&gt;&lt;td&gt;约 48 KB&lt;/td&gt;&lt;td&gt;同上，只是运行时更小&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Next.js App Router&lt;/td&gt;&lt;td&gt;数十 KB + RSC 负载&lt;/td&gt;&lt;td&gt;某知名博客的存档页 HTML 达 645 KB，其中 61% 是内联的组件数据&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;TanStack 系列做应用很好，但它的 Markdown 包刚到 1.0、官方示例还是在浏览器里解析 Markdown，这和&quot;文章型站点&quot;的目标相反。Astro 的内容集合、图片优化、Shiki 高亮、sitemap 与 RSS 都是一等公民，而且页面默认一个字节 JS 都不带——这正是我要的。&lt;/p&gt;
&lt;p&gt;HeroUI 这类 React 组件库也测过：一个按钮岛屿要 96 KB（其中 React 约 70 KB）。最终只借用了它的视觉语言，所有按钮、标签、卡片都用零 JS 的 Astro 组件实现。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;构建管线&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E6%9E%84%E5%BB%BA%E7%AE%A1%E7%BA%BF&quot;&gt;构建管线&lt;/a&gt;&lt;/h2&gt;
&lt;figure class=&quot;diagram&quot; data-pagefind-ignore=&quot;&quot;&gt;&lt;pre class=&quot;mermaid&quot; data-source=&quot;graph LR
  A[content/posts/*.md] --&gt; B[内容集合 + Zod 校验]
  B --&gt; C[remark 插件&lt;br/&gt;摘要 · 阅读时间]
  C --&gt; D[rehype 插件&lt;br/&gt;标题锚点 · 代码块外壳 · 表格 · 章节]
  D --&gt; E[Shiki 高亮&lt;br/&gt;浅色 + 深色]
  E --&gt; F[页面 HTML&lt;br/&gt;CSS 内联]
  F --&gt; G[dist/ + Pagefind 索引 + OG 图 + sitemap]&quot;&gt;graph LR
  A[content/posts/*.md] --&gt; B[内容集合 + Zod 校验]
  B --&gt; C[remark 插件&amp;#x3C;br/&gt;摘要 · 阅读时间]
  C --&gt; D[rehype 插件&amp;#x3C;br/&gt;标题锚点 · 代码块外壳 · 表格 · 章节]
  D --&gt; E[Shiki 高亮&amp;#x3C;br/&gt;浅色 + 深色]
  E --&gt; F[页面 HTML&amp;#x3C;br/&gt;CSS 内联]
  F --&gt; G[dist/ + Pagefind 索引 + OG 图 + sitemap]&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;文章就是 &lt;code&gt;content/posts/&lt;/code&gt; 下的 Markdown 文件，frontmatter 由 Zod 校验：日期格式错了、slug 里混进中文或空格，构建直接失败，而不是上线后才发现。Markdown 经过 remark/rehype 管线：&lt;code&gt;&amp;#x3C;!-- more --&gt;&lt;/code&gt; 之前的内容成为摘要；阅读时间按&quot;中文 300 字/分钟 + 英文 200 词/分钟&quot;分别计算；每个标题带稳定的 id 与锚点；代码块被包进带语言标签和复制按钮的外壳；每个二级标题的章节包成一个 &lt;code&gt;&amp;#x3C;section&gt;&lt;/code&gt;，并开启 &lt;code&gt;content-visibility: auto&lt;/code&gt;，长文章的布局计算只做可见部分。&lt;/p&gt;
&lt;p&gt;代码高亮在构建时完成。Shiki 同时输出浅色和深色两套颜色，以 CSS 变量的形式写在每个 token 上，切换主题只是换一组变量，浏览器里没有任何高亮程序在跑。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;css20-kb内联不闪&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#css20-kb%E5%86%85%E8%81%94%E4%B8%8D%E9%97%AA&quot;&gt;CSS：20 KB，内联，不闪&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;样式用 Tailwind v4，设计令牌（颜色、字号、圆角）写在 &lt;code&gt;@theme&lt;/code&gt; 里，所有组件只引用令牌。构建时 Tailwind 只输出真正用到的工具类，整站样式约 20 KB，并通过 &lt;code&gt;inlineStylesheets: &apos;always&apos;&lt;/code&gt; 直接内联进每个页面：少一次请求，首屏渲染不需要等任何外部文件。&lt;/p&gt;
&lt;p&gt;我给 CSS 定了一条硬预算：文章页内联样式不超过 20 KiB，每次改样式都重新测量。有两次差点超标，原因很有代表性：Tailwind 会扫描源码里所有像类名的词，组件样式里写的 &lt;code&gt;transition&lt;/code&gt;、&lt;code&gt;grid&lt;/code&gt; 这种属性名也会被当成工具类打进全局；解决方法是把这些词加进扫描排除表。另一次是把只有文章页需要的样式放进了全局样式表——Astro 按导入关系打包组件样式，而不是按是否渲染。&lt;/p&gt;
&lt;p&gt;深色模式由 &lt;code&gt;&amp;#x3C;head&gt;&lt;/code&gt; 里一段不到 1 KB 的内联脚本在首次绘制前设置 &lt;code&gt;data-theme&lt;/code&gt;，所以不会出现先白后黑的闪烁；深色底色用的是接近黑的 &lt;code&gt;#121214&lt;/code&gt;，而不是纯黑，长文阅读不刺眼，层级靠&quot;更亮的表面&quot;而不是描边来表达。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;javascript按需而且很小&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#javascript%E6%8C%89%E9%9C%80%E8%80%8C%E4%B8%94%E5%BE%88%E5%B0%8F&quot;&gt;JavaScript：按需，而且很小&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;文章页只有四个小脚本：主题切换（1.0 KB）、搜索框启动器（1.4 KB）、代码复制（0.5 KB）、链接预取（2.4 KB）。真正&quot;重&quot;的东西全部延迟：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;评论（Disqus）&lt;/strong&gt;：评论区距离视口 600 px 以内才注入 embed 脚本。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;搜索（Pagefind）&lt;/strong&gt;：静态索引在构建时生成，点开搜索框才加载 UI 和索引分片。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;流程图（Mermaid）&lt;/strong&gt;：库有几 MB，只在含图表的页面、图表接近视口时才动态 &lt;code&gt;import()&lt;/code&gt;，并随主题重新渲染。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;没有 React，没有客户端路由，没有在浏览器里解析 Markdown。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;字体一个字节都不下载&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E5%AD%97%E4%BD%93%E4%B8%80%E4%B8%AA%E5%AD%97%E8%8A%82%E9%83%BD%E4%B8%8D%E4%B8%8B%E8%BD%BD&quot;&gt;字体：一个字节都不下载&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;中文 Web 字体动辄几 MB，再怎么子集化也是首屏的负担。这里直接用设备自带的字体栈：Apple 平台上是 SF Pro 和苹方，Windows 上是微软雅黑，Linux/Android 上是 Noto Sans CJK。图标用内联 SVG，不用图标字体。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;图片构建时处理好&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E5%9B%BE%E7%89%87%E6%9E%84%E5%BB%BA%E6%97%B6%E5%A4%84%E7%90%86%E5%A5%BD&quot;&gt;图片：构建时处理好&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;文章目录里的图片在构建时由 sharp 转成 WebP，并按 640–1280 px 等多个宽度生成 &lt;code&gt;srcset&lt;/code&gt;；&lt;code&gt;sizes&lt;/code&gt; 按正文栏宽（832 px）设置，手机不会去下载桌面尺寸。每张图都带固有宽高，页面不会因为图片加载而跳动，这是 CLS 为 0 的关键。封面是首屏最大元素（LCP），所以用 eager 加载并加 &lt;code&gt;fetchpriority=&quot;high&quot;&lt;/code&gt;；正文图片一律原生懒加载。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;页面切换像翻书&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E9%A1%B5%E9%9D%A2%E5%88%87%E6%8D%A2%E5%83%8F%E7%BF%BB%E4%B9%A6&quot;&gt;页面切换：像翻书&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;三件事叠在一起：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;鼠标悬停时预取链接（Astro 的 prefetch，2.4 KB）。&lt;/li&gt;
&lt;li&gt;Chromium 的 Speculation Rules：一段 JSON，浏览器在悬停时直接在后台预渲染下一页，零 JS。&lt;/li&gt;
&lt;li&gt;跨文档 View Transition：纯 CSS 的 &lt;code&gt;@view-transition { navigation: auto }&lt;/code&gt;，切换时淡入淡出。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;第三点踩过一个坑：浏览器会在新页面&quot;第一次有机会渲染&quot;时截取快照，而 Chromium 在 &lt;code&gt;&amp;#x3C;body&gt;&lt;/code&gt; 解析完之前就会渲染，于是过渡会落在一张空白页上、内容再弹出来。解决办法是一行标记，让渲染等到页面末尾解析完成：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; rel&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;expect&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;#page-end&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; blocking&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;render&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;页面本身只有几十 KB，这一行不影响首屏时间，但换来了完整的过渡。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;seo-与-url&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#seo-%E4%B8%8E-url&quot;&gt;SEO 与 URL&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;URL 全部 ASCII&lt;/strong&gt;：中文标题自动转拼音作为 slug，旧的 Hexo 链接（带空格和中文）保存在 frontmatter 的 &lt;code&gt;aliases&lt;/code&gt; 里；构建会为每条旧链接生成带 canonical 的跳转页，Vercel 上还会配置成真正的 308 重定向，搜索引擎的收录可以平滑迁移。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;每篇文章的 OG 图&lt;/strong&gt;在构建时用 satori + resvg 生成（中文字体按文字子集下载并缓存），社交平台分享有图。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;sitemap 带 &lt;code&gt;lastmod&lt;/code&gt;&lt;/strong&gt;，RSS/Atom/JSON Feed 三种订阅源输出全文，JSON-LD 标注 &lt;code&gt;BlogPosting&lt;/code&gt; 和面包屑。&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;中英双语&lt;/strong&gt;：英文版是与原文并列的 &lt;code&gt;.en.md&lt;/code&gt; 文件，带 &lt;code&gt;hreflang&lt;/code&gt; 与各自的订阅源；翻译可以人工写，也可以用 DeepL、Google 或大模型的接口批量生成，译文记录原文哈希，原文改动后会被标记为过期。&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;托管&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E6%89%98%E7%AE%A1&quot;&gt;托管&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;站点部署在 Vercel，静态文件走 CDN。&lt;code&gt;/_astro/*&lt;/code&gt; 这类带哈希的资源缓存一年且 &lt;code&gt;immutable&lt;/code&gt;，HTML 走 &lt;code&gt;must-revalidate&lt;/code&gt;；安全响应头和尾斜杠策略写在 &lt;code&gt;vercel.json&lt;/code&gt; 里。构建在 CI 里跑 &lt;code&gt;pnpm build&lt;/code&gt;，类型检查和 500 多个单元测试一起跑。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;取舍与没做的事&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E5%8F%96%E8%88%8D%E4%B8%8E%E6%B2%A1%E5%81%9A%E7%9A%84%E4%BA%8B&quot;&gt;取舍与没做的事&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Disqus 的 iframe 会阻止 bfcache（浏览器的前进/后退缓存），这是第三方评论的代价；它只在滚到评论区时才加载，影响已经降到最小。&lt;/li&gt;
&lt;li&gt;Mermaid 的体积很大，所以只按需加载；如果以后图表多了，可以改成构建时渲染成 SVG。&lt;/li&gt;
&lt;li&gt;Pagefind 不做中文词干化，子串搜索够用。&lt;/li&gt;
&lt;li&gt;拼音 slug 不如英文可读，所以提供了用大模型生成英文 slug 的命令，旧 slug 自动变成别名。&lt;/li&gt;
&lt;li&gt;没有用任何运行时 UI 库。想要 HeroUI 那种交互组件时，也只会放进&quot;点击后再加载&quot;的岛屿里。&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;怎么衡量&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/why-this-blog-is-fast/#%E6%80%8E%E4%B9%88%E8%A1%A1%E9%87%8F&quot;&gt;怎么衡量&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;每次改动都重新跑移动端 Lighthouse，同时用脚本测量文章页的内联 CSS 字节数和脚本总大小，超出预算就算失败。这些工具不难，难的是把&quot;少做事&quot;坚持成一条规矩。&lt;/p&gt;
&lt;p&gt;整套代码是开源的。如果你也想自己搭一个，&lt;code&gt;pnpm build&lt;/code&gt; 一条命令就能把 &lt;code&gt;content/&lt;/code&gt; 里的 Markdown 变成一个这样的站点。&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>Astro</category><category>性能</category><category>前端</category><category>博客</category><category>Markdown</category></item><item><title>在 BIRD2 主机上将IPv6 地址池绑定到新网卡并实现多源 IPv6 出网</title><link>https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/</guid><description>记录一次在 Linux + BIRD2 环境下，将一个 IPv6 /47 地址池作为本机可绑定地址使用，并通过新建 dummy 网卡实现可绑定、可出网的配置过程。</description><pubDate>Wed, 15 Apr 2026 14:00:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;这次的目标很明确：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;机器已经在运行 BIRD2，并且正常通过 BGP 广播 IPv6 前缀&lt;/li&gt;
&lt;li&gt;现在希望把一段 &lt;code&gt;/47&lt;/code&gt; IPv6 前缀作为&lt;strong&gt;本机可使用的 IPv6 地址池&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;同时为了让结构更清晰，计划将这段地址“挂”到一个新的逻辑网卡上&lt;/li&gt;
&lt;li&gt;最终实现：
&lt;ul&gt;
&lt;li&gt;应用可以绑定这段 &lt;code&gt;/47&lt;/code&gt; 里的任意 IPv6 地址&lt;/li&gt;
&lt;li&gt;流量仍然从真实物理网卡出网&lt;/li&gt;
&lt;li&gt;BIRD 只负责广播，不去干扰系统默认路由和地址管理&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;说明：本文中的 IPv4、IPv6、ASN、BGP 邻居、认证口令等信息都已经替换为&lt;strong&gt;文档示例值&lt;/strong&gt;，用于记录配置思路，避免暴露真实生产环境信息。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;现有-bird2-配置梳理&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E7%8E%B0%E6%9C%89-bird2-%E9%85%8D%E7%BD%AE%E6%A2%B3%E7%90%86&quot;&gt;现有 BIRD2 配置梳理&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;当前机器上的 BIRD2 配置大致有几个关键点：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;protocol direct&lt;/code&gt; 只跟踪 &lt;code&gt;dummy*&lt;/code&gt; 接口&lt;/li&gt;
&lt;li&gt;&lt;code&gt;protocol kernel&lt;/code&gt; 对 IPv4 / IPv6 都是 &lt;code&gt;import none; export none;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;protocol static static_v6&lt;/code&gt; 里通过 &lt;code&gt;reject&lt;/code&gt; 的方式把需要广播的 IPv6 前缀放进 BIRD RIB&lt;/li&gt;
&lt;li&gt;BGP 对外只导出 &lt;code&gt;RTS_STATIC&lt;/code&gt; 的 IPv6 前缀&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;也就是说，这套设计本身就已经把职责分得很清楚了：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;BIRD 负责广播&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;内核负责真实转发与本机地址绑定&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;不会让 BIRD 去改内核默认路由&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;这个思路是对的，应该继续保持。&lt;/p&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;先说结论这件事不应该只改-bird&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E5%85%88%E8%AF%B4%E7%BB%93%E8%AE%BA%E8%BF%99%E4%BB%B6%E4%BA%8B%E4%B8%8D%E5%BA%94%E8%AF%A5%E5%8F%AA%E6%94%B9-bird&quot;&gt;先说结论：这件事不应该只改 BIRD&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;很多人在第一次做这类配置时，会直觉认为“既然是广播的前缀，就在 BIRD 里把它绑到接口上”。&lt;/p&gt;
&lt;p&gt;实际上不是这样。&lt;/p&gt;
&lt;h3 id=&quot;bird-的职责&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#bird-%E7%9A%84%E8%81%8C%E8%B4%A3&quot;&gt;BIRD 的职责&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;BIRD 只需要完成一件事：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;把目标 &lt;code&gt;/47&lt;/code&gt; 前缀继续宣告出去&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;linux-内核的职责&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#linux-%E5%86%85%E6%A0%B8%E7%9A%84%E8%81%8C%E8%B4%A3&quot;&gt;Linux 内核的职责&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;真正让这段 &lt;code&gt;/47&lt;/code&gt;：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;可以在本机 &lt;code&gt;bind()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;可以作为源地址发起连接&lt;/li&gt;
&lt;li&gt;可以通过真实物理网卡出网&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;靠的是 Linux 网络栈，而不是 BIRD。&lt;/p&gt;
&lt;p&gt;所以最终方案是：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;新建一个 &lt;strong&gt;dummy 网卡&lt;/strong&gt;，例如 &lt;code&gt;dummy47&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;给它放一个池内“锚点地址”&lt;/li&gt;
&lt;li&gt;通过 &lt;code&gt;ip -6 route add local ...&lt;/code&gt; 告诉内核：这一整段 &lt;code&gt;/47&lt;/code&gt; 都属于本机&lt;/li&gt;
&lt;li&gt;开启 &lt;code&gt;net.ipv6.ip_nonlocal_bind=1&lt;/code&gt;，允许应用绑定未显式加到接口上的地址&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;为什么要用-dummy-网卡&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E7%94%A8-dummy-%E7%BD%91%E5%8D%A1&quot;&gt;为什么要用 dummy 网卡&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;我这里没有直接把整段 &lt;code&gt;/47&lt;/code&gt; 塞进真实物理网卡，而是单独新建一个逻辑接口 &lt;code&gt;dummy47&lt;/code&gt;，原因有三点：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;职责更清晰&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dummy47&lt;/code&gt; 表示“这是一段本机管理的业务地址池”&lt;/li&gt;
&lt;li&gt;物理网卡只负责真正收发包&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;更容易排障&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;看接口配置时一眼就能知道这段地址池是专门干什么的&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;和现有 BIRD 配置兼容&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;当前 &lt;code&gt;protocol direct&lt;/code&gt; 已经匹配 &lt;code&gt;dummy*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;新建 &lt;code&gt;dummy47&lt;/code&gt; 后不需要大改&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;要注意的是：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;dummy47&lt;/code&gt; 不是实际出网网卡。&lt;br&gt;
真正的发包依然会走默认路由对应的物理接口，比如 &lt;code&gt;eth0&lt;/code&gt; 或 &lt;code&gt;ens3&lt;/code&gt;。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;参考思路local-route--ip_nonlocal_bind&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E5%8F%82%E8%80%83%E6%80%9D%E8%B7%AFlocal-route--ip_nonlocal_bind&quot;&gt;参考思路：local route + ip_nonlocal_bind&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;这次配置的核心思路是：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;不去枚举添加大量静态地址&lt;/li&gt;
&lt;li&gt;不去把整段前缀当作普通地址直接 &lt;code&gt;addr add&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;而是通过：&lt;/li&gt;
&lt;/ul&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; add&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; local&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::/47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; lo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;sysctl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; net.ipv6.ip_nonlocal_bind=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;让内核认为：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;这整段 &lt;code&gt;/47&lt;/code&gt; 都是“本机可接收”的地址&lt;/li&gt;
&lt;li&gt;进程可以直接绑定其中任意地址&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;这是最关键的两步。&lt;/p&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;脱敏后的-bird2-配置示意&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E8%84%B1%E6%95%8F%E5%90%8E%E7%9A%84-bird2-%E9%85%8D%E7%BD%AE%E7%A4%BA%E6%84%8F&quot;&gt;脱敏后的 BIRD2 配置示意&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;下面是一份经过脱敏处理的配置骨架，用来说明和本文相关的关键部分。&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bird&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bird&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bird&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#                 Variables                     #&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; OWNAS   &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 64500&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; OWNIP   &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 198.51.100.10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; OWNIPv6 &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 2001:db8:100::10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; OWNNETSET_V4 &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; [];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;define&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; OWNNETSET_V6 &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;    2001:db8:4700::/47&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#                 Global                        #&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;router&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; OWNIP;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; device&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    scan&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#                  Direct                       #&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; direct&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;dummy*&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#              Kernel isolation                 #&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; kernel&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; krt_ipv4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    scan&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 20&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        import &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        export &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; kernel&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; krt_ipv6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    scan&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; time&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 20&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        import &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        export &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#              Static announcements             #&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; static&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; static_v6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 2001:db8:4700::/47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; reject&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        import &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;all&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        export &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#               BGP template                    #&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;template&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; bgp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; tpl_bgp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    local&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; as&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; OWNAS&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    path metric&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    graceful restart&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        import &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        export filter { &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;reject&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;; };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;        export limit&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; action&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; disable&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;        extended next hop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; on&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        import &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        export filter {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;            if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; source&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; !=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; RTS_STATIC&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; then&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; reject&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;            accept&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;        export limit&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; action&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; disable&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#                 Upstream BGP                  #&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;################################################&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; bgp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; bgp_upstream_v4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; tpl_bgp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;    source&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; address&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; OWNIP;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    neighbor&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 169.254.0.1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; as&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 64496&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    multihop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    password&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;REDACTED_PASSWORD&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; bgp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; bgp_upstream_v6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; tpl_bgp&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;    source&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; address&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; OWNIPv6;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    neighbor&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 2001:db8:ffff::1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; as&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 64496&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    multihop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    password&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;REDACTED_PASSWORD&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;bird2-配置是否需要修改&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#bird2-%E9%85%8D%E7%BD%AE%E6%98%AF%E5%90%A6%E9%9C%80%E8%A6%81%E4%BF%AE%E6%94%B9&quot;&gt;BIRD2 配置是否需要修改&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;结论&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E7%BB%93%E8%AE%BA&quot;&gt;结论&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;大多数情况下几乎不用改。&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;因为当前已经有：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bird&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bird&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bird&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; direct&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;dummy*&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;所以只要新的逻辑网卡叫 &lt;code&gt;dummy47&lt;/code&gt;，它天然就会被匹配。&lt;/p&gt;
&lt;p&gt;而 IPv6 静态广播部分本身也是对的：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bird&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bird&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bird&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;protocol&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; static&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; static_v6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 2001:db8:4700::/47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; reject&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ipv6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        import &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;all&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        export &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h3 id=&quot;为什么不用把-47-从-reject-改掉&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E7%94%A8%E6%8A%8A-47-%E4%BB%8E-reject-%E6%94%B9%E6%8E%89&quot;&gt;为什么不用把 &lt;code&gt;/47&lt;/code&gt; 从 reject 改掉&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;因为这里的 &lt;code&gt;reject&lt;/code&gt; 路由只是为了：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;让前缀进入 BIRD RIB&lt;/li&gt;
&lt;li&gt;满足 BGP 导出条件&lt;/li&gt;
&lt;li&gt;作为“我拥有并广播这个前缀”的声明&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;它&lt;strong&gt;不是&lt;/strong&gt;为了给 Linux 内核做真实转发或本机地址绑定。&lt;/p&gt;
&lt;p&gt;所以 &lt;code&gt;/47&lt;/code&gt; 继续保留 &lt;code&gt;reject&lt;/code&gt; 方式是合理的。&lt;/p&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;实际配置步骤&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E5%AE%9E%E9%99%85%E9%85%8D%E7%BD%AE%E6%AD%A5%E9%AA%A4&quot;&gt;实际配置步骤&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;下面开始做 Linux 网络配置。&lt;/p&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;第一步创建新的-dummy-网卡&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E7%AC%AC%E4%B8%80%E6%AD%A5%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84-dummy-%E7%BD%91%E5%8D%A1&quot;&gt;第一步：创建新的 dummy 网卡&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;先加载模块并创建逻辑网卡：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;modprobe&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; link&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; add&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; link&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; up&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;执行后可以用下面命令确认：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; link&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;第二步给-dummy47-加一个锚点地址&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E7%AC%AC%E4%BA%8C%E6%AD%A5%E7%BB%99-dummy47-%E5%8A%A0%E4%B8%80%E4%B8%AA%E9%94%9A%E7%82%B9%E5%9C%B0%E5%9D%80&quot;&gt;第二步：给 dummy47 加一个锚点地址&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;虽然我们要使用的是整个 &lt;code&gt;/47&lt;/code&gt; 地址池，但还是建议在 &lt;code&gt;dummy47&lt;/code&gt; 上放一个明确的单地址作为“锚点”：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; addr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; add&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::1/128&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;这里使用 &lt;code&gt;/128&lt;/code&gt; 即可，不需要把整个 &lt;code&gt;/47&lt;/code&gt; 当作普通接口地址加上去。&lt;/p&gt;
&lt;h3 id=&quot;为什么不用&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E4%B8%BA%E4%BB%80%E4%B9%88%E4%B8%8D%E7%94%A8&quot;&gt;为什么不用：&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; addr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; add&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::/47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;因为这并不能达到“本机可以绑定整个 &lt;code&gt;/47&lt;/code&gt;”的目的。&lt;br&gt;
它只是给接口加了一个 connected route 的语义，不等于把整段前缀都变成可直接绑定的本地地址池。&lt;/p&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;第三步把整个-47-加为-local-route&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E7%AC%AC%E4%B8%89%E6%AD%A5%E6%8A%8A%E6%95%B4%E4%B8%AA-47-%E5%8A%A0%E4%B8%BA-local-route&quot;&gt;第三步：把整个 &lt;code&gt;/47&lt;/code&gt; 加为 local route&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;这一步是最关键的。&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; replace&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; local&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::/47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; lo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;这样内核会认为：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;2001:db8:4700::/47&lt;/code&gt; 整段都属于本机 local address space&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;也就是说，只要后续应用去绑定这一段里的任意 IPv6 地址，内核都会接受。&lt;/p&gt;
&lt;h3 id=&quot;为什么挂到-lo&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E4%B8%BA%E4%BB%80%E4%B9%88%E6%8C%82%E5%88%B0-lo&quot;&gt;为什么挂到 &lt;code&gt;lo&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;因为这是一条 &lt;strong&gt;local route&lt;/strong&gt;，它表达的意思不是“从 loopback 发包”，而是：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;这段前缀按本地地址处理&lt;/li&gt;
&lt;li&gt;由本机持有&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;这是 Linux 处理这类场景的标准方式。&lt;/p&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;第四步开启-ip_nonlocal_bind&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E7%AC%AC%E5%9B%9B%E6%AD%A5%E5%BC%80%E5%90%AF-ip_nonlocal_bind&quot;&gt;第四步：开启 ip_nonlocal_bind&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;即使有了 &lt;code&gt;local route&lt;/code&gt;，很多程序默认仍然不能随便绑定“没有显式加在接口上的地址”。&lt;/p&gt;
&lt;p&gt;所以还要开启：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;sysctl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -w&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; net.ipv6.ip_nonlocal_bind=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;为了持久化，建议写入单独的 sysctl 配置文件：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;cat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;/etc/sysctl.d/99-ipv6-pool.conf&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; &amp;#x3C;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;EOF&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;net.ipv6.ip_nonlocal_bind = 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;EOF&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;sysctl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --system&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;第五步重新加载-bird2&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E7%AC%AC%E4%BA%94%E6%AD%A5%E9%87%8D%E6%96%B0%E5%8A%A0%E8%BD%BD-bird2&quot;&gt;第五步：重新加载 BIRD2&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;如果 BIRD 配置本身没有改动，这一步理论上不是必须的。&lt;br&gt;
但如果顺手调整了配置，执行一次重载最保险：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;birdc&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; configure&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;然后检查路由是否在 BIRD RIB 中：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;birdc&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::/47&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;验证方法&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E9%AA%8C%E8%AF%81%E6%96%B9%E6%B3%95&quot;&gt;验证方法&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;查看-dummy47-地址&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E6%9F%A5%E7%9C%8B-dummy47-%E5%9C%B0%E5%9D%80&quot;&gt;查看 dummy47 地址&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; addr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;预期至少能看到：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;inet6 2001:db8:4700::1/128 scope global&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h3 id=&quot;查看-local-route&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E6%9F%A5%E7%9C%8B-local-route&quot;&gt;查看 local route&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; table&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; local&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; grep&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;2001:db8:4700::/47&apos;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;预期看到类似：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;text&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;local 2001:db8:4700::/47 dev lo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h3 id=&quot;用指定源-ipv6-测试出网&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E7%94%A8%E6%8C%87%E5%AE%9A%E6%BA%90-ipv6-%E6%B5%8B%E8%AF%95%E5%87%BA%E7%BD%91&quot;&gt;用指定源 IPv6 测试出网&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;这里不要写接口名 &lt;code&gt;dummy47&lt;/code&gt;，而是直接绑定具体源地址：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; https://ipv6.ip.sb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::200&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; https://ipv6.ip.sb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4701::1234&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; https://ipv6.ip.sb&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;如果返回值分别就是你指定的源地址，说明配置成功。&lt;/p&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;一个容易踩坑的点绑定接口不等于绑定源地址&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E4%B8%80%E4%B8%AA%E5%AE%B9%E6%98%93%E8%B8%A9%E5%9D%91%E7%9A%84%E7%82%B9%E7%BB%91%E5%AE%9A%E6%8E%A5%E5%8F%A3%E4%B8%8D%E7%AD%89%E4%BA%8E%E7%BB%91%E5%AE%9A%E6%BA%90%E5%9C%B0%E5%9D%80&quot;&gt;一个容易踩坑的点：绑定“接口”不等于绑定“源地址”&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;很多人会下意识这样测：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; https://ipv6.ip.sb&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;这个测试方式并不适合这里。&lt;/p&gt;
&lt;p&gt;因为 &lt;code&gt;dummy47&lt;/code&gt; 不是物理出口网卡，它只是一个逻辑承载接口。&lt;br&gt;
真正的流量出网仍然依赖系统默认路由，一般还是会走类似 &lt;code&gt;eth0&lt;/code&gt; 或 &lt;code&gt;ens3&lt;/code&gt; 这样的真实物理网卡。&lt;/p&gt;
&lt;p&gt;所以正确姿势应该是：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;绑定具体源 IPv6 地址&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;而不是绑定 &lt;code&gt;dummy47&lt;/code&gt; 这个接口名&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;即：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; https://ipv6.ip.sb&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;关于-ndppd这次场景一般不需要&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E5%85%B3%E4%BA%8E-ndppd%E8%BF%99%E6%AC%A1%E5%9C%BA%E6%99%AF%E4%B8%80%E8%88%AC%E4%B8%8D%E9%9C%80%E8%A6%81&quot;&gt;关于 ndppd：这次场景一般不需要&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;一些“整段 IPv6 绑定并直接使用”的文章里，会额外提到 &lt;code&gt;ndppd&lt;/code&gt;。&lt;br&gt;
那通常是因为上游把 IPv6 前缀作为 &lt;strong&gt;on-link 网络&lt;/strong&gt; 给到机器，需要对每个地址做 NDP 邻居发现。&lt;/p&gt;
&lt;p&gt;但这里的场景不同：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;机器已经通过 &lt;strong&gt;BGP&lt;/strong&gt; 广播这段前缀&lt;/li&gt;
&lt;li&gt;上游更像是把这段前缀&lt;strong&gt;路由到这台机器&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;而不是要求本机在二层上对整段地址逐个做 NDP 响应&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;所以在这种设计下，一般：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;不需要 &lt;code&gt;ndppd&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;只需要：
&lt;ul&gt;
&lt;li&gt;BIRD 正常广播前缀&lt;/li&gt;
&lt;li&gt;内核有 &lt;code&gt;local route&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;开启 &lt;code&gt;ip_nonlocal_bind&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;只有当服务商明确要求这段前缀是二层直连、必须对目标地址进行邻居发现时，才需要额外考虑 &lt;code&gt;ndppd&lt;/code&gt; 或 &lt;code&gt;proxy_ndp&lt;/code&gt;。&lt;/p&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;持久化方案systemd-service&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E6%8C%81%E4%B9%85%E5%8C%96%E6%96%B9%E6%A1%88systemd-service&quot;&gt;持久化方案：systemd service&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;为了避免重启后丢失，我最后把这套配置写成了一个简单的 systemd 服务。&lt;/p&gt;
&lt;p&gt;创建文件：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;vim&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; /etc/systemd/system/dummy47-v6pool.service&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;内容如下：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;ini&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;ini&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;ini&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;[Unit]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;Description&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=IPv6 pool on dummy47&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;After&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=network-online.target&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;Wants&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=network-online.target&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;[Service]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;Type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=oneshot&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;RemainAfterExit&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=yes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStart&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/modprobe dummy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStart&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/ip link add dummy47 type dummy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStart&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/ip link set dummy47 up&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStart&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/ip -6 addr add 2001:db8:4700::1/128 dev dummy47&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStart&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/ip -6 route replace local 2001:db8:4700::/47 dev lo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStart&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/sysctl -w &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;net.ipv6.ip_nonlocal_bind&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/ip -6 route del local 2001:db8:4700::/47 dev lo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/ip -6 addr del 2001:db8:4700::1/128 dev dummy47&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;ExecStop&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=/sbin/ip link del dummy47&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;[Install]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;WantedBy&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=multi-user.target&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;然后执行：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;systemctl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; daemon-reload&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;systemctl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; enable&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --now&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47-v6pool.service&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;一份完整的操作命令汇总&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E4%B8%80%E4%BB%BD%E5%AE%8C%E6%95%B4%E7%9A%84%E6%93%8D%E4%BD%9C%E5%91%BD%E4%BB%A4%E6%B1%87%E6%80%BB&quot;&gt;一份完整的操作命令汇总&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;为了方便复制，这里把完整步骤汇总成一段：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;modprobe&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; link&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; add&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; link&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; up&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; addr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; add&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::1/128&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; replace&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; local&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::/47&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; lo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;sysctl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -w&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; net.ipv6.ip_nonlocal_bind=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;birdc&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; configure&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;birdc&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::/47&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;验证：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;bash&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;bash&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; addr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; dummy47&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; route&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; table&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; local&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; grep&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;2001:db8:4700::/47&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; https://ipv6.ip.sb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4700::200&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; https://ipv6.ip.sb&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -6&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --interface&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; 2001:db8:4701::1234&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; https://ipv6.ip.sb&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;我的最终理解&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E6%88%91%E7%9A%84%E6%9C%80%E7%BB%88%E7%90%86%E8%A7%A3&quot;&gt;我的最终理解&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;这次配置做完之后，整个结构就很清晰了：&lt;/p&gt;
&lt;h3 id=&quot;bird2-做什么&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#bird2-%E5%81%9A%E4%BB%80%E4%B9%88&quot;&gt;BIRD2 做什么&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;继续通过 BGP 广播目标 &lt;code&gt;/47&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;继续使用 &lt;code&gt;static ... reject&lt;/code&gt; 的方式将前缀放入 BIRD RIB&lt;/li&gt;
&lt;li&gt;不导入、不导出 Linux 内核路由&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;linux-内核做什么&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#linux-%E5%86%85%E6%A0%B8%E5%81%9A%E4%BB%80%E4%B9%88&quot;&gt;Linux 内核做什么&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;通过 &lt;code&gt;dummy47&lt;/code&gt; 提供逻辑承载&lt;/li&gt;
&lt;li&gt;通过 &lt;code&gt;local route&lt;/code&gt; 将整个 &lt;code&gt;/47&lt;/code&gt; 标记为本机地址空间&lt;/li&gt;
&lt;li&gt;通过 &lt;code&gt;ip_nonlocal_bind&lt;/code&gt; 允许应用绑定池中任意 IPv6&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;应用怎么用&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E5%BA%94%E7%94%A8%E6%80%8E%E4%B9%88%E7%94%A8&quot;&gt;应用怎么用&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;不是绑定 &lt;code&gt;dummy47&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;而是绑定目标 &lt;code&gt;/47&lt;/code&gt; 中的具体某个 IPv6 作为源地址&lt;/li&gt;
&lt;li&gt;流量最终仍然走系统默认路由，从真实物理接口出网&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;后记&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/bird2-ipv6-pool-sanitized/#%E5%90%8E%E8%AE%B0&quot;&gt;后记&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;一开始我也很容易把“前缀广播”和“本机地址绑定”混成一件事。&lt;br&gt;
但真正拆开以后就会发现，这其实是两个层面的事情：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;路由控制面&lt;/strong&gt;：BIRD/BGP&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;主机数据面&lt;/strong&gt;：Linux 网络栈&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;把这两者分开处理后，整套方案就会非常稳定，也更容易维护和排障。&lt;/p&gt;
&lt;p&gt;如果后续还要继续扩展这台机器承载更多 IPv6 地址池，我会优先继续沿用这个思路：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;BIRD 只负责广播&lt;/li&gt;
&lt;li&gt;业务地址池通过 &lt;code&gt;dummy + local route + ip_nonlocal_bind&lt;/code&gt; 管理&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;这样结构最干净。&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>bird2</category><category>ipv6</category><category>linux</category><category>bgp</category><category>网络</category></item><item><title>AWS服务和Kafka集群实操日记</title><link>https://blog.xsy.fun/posts/kafka-experience/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/kafka-experience/</guid><description>记录第一次上手AWS的实操过程，串联IoT Core、MSK Kafka、Lambda、S3与IAM权限配置组成的数据流。</description><pubDate>Thu, 12 Jun 2025 15:41:55 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;简介&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/kafka-experience/#%E7%AE%80%E4%BB%8B&quot;&gt;简介&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;最近有一个项目需要使用AWS服务，鉴于我是第一次上手AWS和使用其中的服务，我认为有必要写一篇博客记录下我新接触到的技术，一些理解和感悟，并且保留一些实际操作经历方便我回顾和重新使用其中的一些命令。&lt;/p&gt;
&lt;p&gt;这个项目涉及到了&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Amazon MSK也就是Fully Managed Apache Kafka，说白了就是一个kafka集群&lt;/li&gt;
&lt;li&gt;Amazon的Iot Core，是一个MQTT broker类似的东西&lt;/li&gt;
&lt;li&gt;Amazon的Lambda，一个支持多编程语言的serverless平台&lt;/li&gt;
&lt;li&gt;Amazon的S3，Scalable Storage in the Cloud&lt;/li&gt;
&lt;li&gt;Amazon的IAM的权限控制&lt;/li&gt;
&lt;li&gt;Amazon的CloudWatch - 类似于Grafana的平台&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;这篇日记将会围绕上述内容展开，并且将所有服务串成一个数据流&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;正文&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/kafka-experience/#%E6%AD%A3%E6%96%87&quot;&gt;正文&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;业务流程&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/kafka-experience/#%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B&quot;&gt;业务流程&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;我们从数据的入口开始逐步追随数据的脚步完成追踪从而串联所有使用到的服务。&lt;/p&gt;
&lt;p&gt;Iot Core将会作为入口，接受来自iot设备或者其他使用mqtt协议的服务，将接收到的数据使用Message routing的Rules功能将信息转发到kafka的topic中或者发送到Lambda经过处理写入S3的Json文件中。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img alt=&quot;&quot; sizes=&quot;(min-width: 864px) 832px, 100vw&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1288&quot; height=&quot;344&quot; src=&quot;https://blog.xsy.fun/_astro/chart.BXZSZmvX_Zn5uoX.webp&quot; srcset=&quot;https://blog.xsy.fun/_astro/chart.BXZSZmvX_2ct5ky.webp 640w, https://blog.xsy.fun/_astro/chart.BXZSZmvX_Z3F7N3.webp 750w, https://blog.xsy.fun/_astro/chart.BXZSZmvX_Z1Hvz7r.webp 828w, https://blog.xsy.fun/_astro/chart.BXZSZmvX_Z2pkx6I.webp 1080w, https://blog.xsy.fun/_astro/chart.BXZSZmvX_ZjvvEG.webp 1280w, https://blog.xsy.fun/_astro/chart.BXZSZmvX_Zn5uoX.webp 1288w&quot;&gt;&lt;/figure&gt;
&lt;figure class=&quot;diagram&quot; data-pagefind-ignore=&quot;&quot;&gt;&lt;pre class=&quot;mermaid&quot; data-source=&quot;graph LR
A[mqtt message]-- Message Rule ---&gt;B[Kafka Cluster topic]
A-- Message Rule ---&gt;C[Lambda - Process Data] ---&gt; D[S3]&quot;&gt;graph LR
A[mqtt message]-- Message Rule ---&gt;B[Kafka Cluster topic]
A-- Message Rule ---&gt;C[Lambda - Process Data] ---&gt; D[S3]&lt;/pre&gt;&lt;/figure&gt;
&lt;h3 id=&quot;iam权限控制&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/kafka-experience/#iam%E6%9D%83%E9%99%90%E6%8E%A7%E5%88%B6&quot;&gt;IAM权限控制&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;其中如果Iot Core在遇到错误抛出将会将日志写入CloudWatch服务。完成上述要求首先要求用户配置多个服务的Policy，然后将不同的Policy分配给多种Role，然后这些服务将会使用Role提供的权限来操作AWS中的各类服务，总而言之Policy是包含多单个权限的集合，例如s3:ListBucket就是Policy中所有权限的例子。&lt;/p&gt;
&lt;p&gt;而Role则包含一个或多个Policy的集合，例如分别有S3 Admin Policy和CloudWatch Write Policy，这些将会为Role中的Policy。只有将拥有相应权限的Role分配给AWS服务的instance，这个instance才能操作和有访问权限，这是一大先决条件。&lt;/p&gt;
&lt;h3 id=&quot;msk配置&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/kafka-experience/#msk%E9%85%8D%E7%BD%AE&quot;&gt;MSK配置&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;首先MSK分为Provisioned和Serverless两种类型，其中&lt;strong&gt;serverless不能具有除了IAM之外的验证方式&lt;/strong&gt;，这就使得如果想让Iot core和msk搭配使用，必须要使用provision版本的，因为Iot core rule只支持使用SASL/SCRAM身份验证或者SSL身份验证。&lt;/p&gt;
&lt;p&gt;此外如果想从外部访问MSK集群中的节点去创建topic有多种方式，而我采用的是使用一个EC2的client machine，也就是一台虚拟机作为一个跳板机，并且在跳板机器上搭建代理，使得从外部可以通过代理连接到Amazon内部与EC2同一VPC网络下的节点，但是很重要的一点是&lt;strong&gt;不能疏忽了MSK和EC2的防火墙配置是否放通，如果不放通会无法连接&lt;/strong&gt;，我在这里排查了很久才发现是防火墙的问题&lt;/p&gt;
&lt;p&gt;关于如何设置跳板机可以参见官方的文档&lt;a href=&quot;https://docs.aws.amazon.com/msk/latest/developerguide/create-client-machine.html&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;https://docs.aws.amazon.com/msk/latest/developerguide/create-client-machine.html&lt;/a&gt;&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img alt=&quot;firewall example&quot; sizes=&quot;(min-width: 864px) 832px, 100vw&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;2778&quot; height=&quot;616&quot; src=&quot;https://blog.xsy.fun/_astro/firewall.XWH4oXXv_Z1kat7i.webp&quot; srcset=&quot;https://blog.xsy.fun/_astro/firewall.XWH4oXXv_1MU77U.webp 640w, https://blog.xsy.fun/_astro/firewall.XWH4oXXv_Z1zRx32.webp 750w, https://blog.xsy.fun/_astro/firewall.XWH4oXXv_PMRDa.webp 828w, https://blog.xsy.fun/_astro/firewall.XWH4oXXv_ZaeDuO.webp 1080w, https://blog.xsy.fun/_astro/firewall.XWH4oXXv_ZmgObE.webp 1280w, https://blog.xsy.fun/_astro/firewall.XWH4oXXv_23OIk6.webp 1668w, https://blog.xsy.fun/_astro/firewall.XWH4oXXv_Z1x3JyB.webp 2048w, https://blog.xsy.fun/_astro/firewall.XWH4oXXv_1jzJYu.webp 2560w, https://blog.xsy.fun/_astro/firewall.XWH4oXXv_Z1kat7i.webp 2778w&quot;&gt;&lt;/figure&gt;
&lt;p&gt;讲清楚了访问，我们再深入讲讲连接和权限控制，首先确保EC2的IAM Role有权限访问MSK集群的节点和topic，然后连接跳板机可以通过如下命令完成topic的创建和订阅和发送消息到topic&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;console&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;console&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;console&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;# subscribe topic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;./kafka-console-consumer.sh \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --bootstrap-server url:port,url2:port \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --topic topic \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --consumer.config client.properties&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;# push data to topic, producer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;./kafka-console-producer.sh \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --bootstrap-server url:port,url2:port \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --topic topic \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --producer.config client.properties&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;# check all the topic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;./kafka-topics.sh --list \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --bootstrap-server url:port,url2:port \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --consumer.config sasl.properties&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;# create a topic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;./kafka-topics.sh --create \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --bootstrap-server url:port,url2:port \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --topic topic \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --partitions 6 \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  --replication-factor 2 \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --command-config sasl.properties&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;其中如果遇到了诸如提示Error while executing topic command : The AdminClient thread has exited. Call: createTopics，基本上可以判定是权限问题，请先检查你配置的IAM和SASL/SCRAM/SSL是否正确，其中IAM如果在EC2上只要在网站上正确配置了IAM role，那么使用那个IP就可以直接使用IAM方式访问。&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;console&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;console&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;console&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;[ec2-user@ bin]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$ ./kafka-topics.sh --create --bootstrap-server url:port --topic your_topic --partitions 6 --replication-factor 2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;WARNING: Due to limitations in metric names, topics with a period (&apos;.&apos;) or underscore (&apos;&apos;) could collide. To avoid issues it is best to use either, but not both.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;Error while executing topic command : The AdminClient thread has exited. Call: createTopics&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;[2025-06-11 05:00:49,875] ERROR org.apache.kafka.common.errors.TimeoutException: The AdminClient thread has exited. Call: createTopics&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; (org.apache.kafka.tools.TopicCommand)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;[2025-06-11 05:00:49,890] ERROR Uncaught exception in thread &apos;kafka-admin-client-thread | adminclient-1&apos;: (org.apache.kafka.common.utils.KafkaThread)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;java.lang.OutOfMemoryError: Java heap space&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at java.base/java.nio.HeapByteBuffer.&amp;#x3C;init&gt;(HeapByteBuffer.java:61)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at java.base/java.nio.ByteBuffer.allocate(ByteBuffer.java:348)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.common.memory.MemoryPool$1.tryAllocate(MemoryPool.java:30)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:103)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:462)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:412)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.common.network.Selector.attemptRead(Selector.java:694)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:596)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.common.network.Selector.poll(Selector.java:501)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:596)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.processRequests(KafkaAdminClient.java:1542)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.run(KafkaAdminClient.java:1473)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        at java.base/java.lang.Thread.run(Thread.java:829)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h3 id=&quot;iot-core设置&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/kafka-experience/#iot-core%E8%AE%BE%E7%BD%AE&quot;&gt;Iot Core设置&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;我们可以通过打开AWS IoT - Message routing - Rules，来新增一条规则，我这里记录我使用Rule将数据转发到Kafka的过程，首先我们选择Rule actions为Kafka，并且在Destination里添加一个VPC，这个同样需要对应的IAM Role去完成，接着我们可以设置Kafka topic为你之前创建的topic，Key我填写了${clientid()}，主要是提供给kafka做数据分区使用，如果单个key太多可能会导致某个分区中的内容过多导致倾斜。&lt;/p&gt;
&lt;p&gt;特别需要注意的是在SASL Configuration中，username和password需要先在AWS Secrets Manager中填写用户密码的键值对，然后绑定在Key Management Service (KMS)中生成的Key即可，后续的访问中如果使用SASL/SCRAM，这里设置的键值对就是你的用户密码&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img alt=&quot;alt text&quot; sizes=&quot;(min-width: 864px) 832px, 100vw&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1986&quot; height=&quot;1588&quot; src=&quot;https://blog.xsy.fun/_astro/secrets.BukECRdb_1ESl7f.webp&quot; srcset=&quot;https://blog.xsy.fun/_astro/secrets.BukECRdb_1xEe9N.webp 640w, https://blog.xsy.fun/_astro/secrets.BukECRdb_Z1g1I3x.webp 750w, https://blog.xsy.fun/_astro/secrets.BukECRdb_ZpktBj.webp 828w, https://blog.xsy.fun/_astro/secrets.BukECRdb_ZbdwRm.webp 1080w, https://blog.xsy.fun/_astro/secrets.BukECRdb_Z1gb4cz.webp 1280w, https://blog.xsy.fun/_astro/secrets.BukECRdb_26s2qa.webp 1668w, https://blog.xsy.fun/_astro/secrets.BukECRdb_1ESl7f.webp 1986w&quot;&gt;&lt;/figure&gt;
&lt;p&gt;然后我们需要使用这个来获取存储在Secrets Manager中的键值，这个是用户名，密码则替换username即可
&lt;code&gt; ${get_secret(&apos;AmazonMSK_iot&apos;, &apos;SecretString&apos;, &apos;username&apos;, &apos;you role arn&apos;)}&lt;/code&gt;
当然你也可以设置一些header来方便识别信息，但是如果设置过多也许会些许影响性能&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img alt=&quot;alt text&quot; sizes=&quot;(min-width: 864px) 832px, 100vw&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;1968&quot; height=&quot;692&quot; src=&quot;https://blog.xsy.fun/_astro/headers.Bz7JxUWd_1TGk04.webp&quot; srcset=&quot;https://blog.xsy.fun/_astro/headers.Bz7JxUWd_pQGNK.webp 640w, https://blog.xsy.fun/_astro/headers.Bz7JxUWd_Z2g9jH2.webp 750w, https://blog.xsy.fun/_astro/headers.Bz7JxUWd_1nJvNa.webp 828w, https://blog.xsy.fun/_astro/headers.Bz7JxUWd_Z25GGWA.webp 1080w, https://blog.xsy.fun/_astro/headers.Bz7JxUWd_ZhoOYI.webp 1280w, https://blog.xsy.fun/_astro/headers.Bz7JxUWd_1RQO7P.webp 1668w, https://blog.xsy.fun/_astro/headers.Bz7JxUWd_1TGk04.webp 1968w&quot;&gt;&lt;/figure&gt;
&lt;h3 id=&quot;lambda设置&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/kafka-experience/#lambda%E8%AE%BE%E7%BD%AE&quot;&gt;Lambda设置&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;只需要在Lambda中添加一个Functions，然后在Iot core中的rule设置一个action到这个function就可以将iot的数据一同发送过来，然后我就在这里合并获取到的mqtt数据然后上传到s3,如果直接将数据通过iot core的rule转发到s3的话，会为每条数据生成一个文件，似乎不方便管理和查看，所以为什么这里要使用Lambda去转发。&lt;/p&gt;
&lt;p&gt;但是由于我这里直接而使用了Lambda去上传数据到s3，并没有做任何缓存，如果数据量比较大可能会出问题&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;结尾&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/kafka-experience/#%E7%BB%93%E5%B0%BE&quot;&gt;结尾&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;这就是所有我最近上手的AWS服务了，如果有什么新的，以后可以再加&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>AWS</category><category>Kafka</category><category>IAM</category><category>MQTT</category><category>S3</category></item><item><title>将Typecho文章迁移到Hexo系统</title><link>https://blog.xsy.fun/posts/hello-world/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/hello-world/</guid><description>介绍如何用一个Python脚本把Typecho博客的文章和标签迁移到Hexo，并说明评论数据取舍和图片处理方式。</description><pubDate>Sun, 03 Nov 2024 09:24:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/hello-world/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;将Typecho文章迁移到Hexo系统，实在是过去太久了，我终于又把我的博客捡起来了，上次写博客还是在5年前，一转眼我就快大学毕业了，想想我之前加入的十年之约博客项目真的是笑话，确实坚持续费服务器的花费是不小的，但是随着年龄的增长和知识储备的增加，应该会使这个博客应该能活到10年吧。&lt;/p&gt;
&lt;p&gt;废话说完，这篇文章是讲我如何将typecho的博客系统迁移到hexo的，其实很简单就一个python文件就搞定了，但是评论系统的更换导致原来的记录很难被迁移，所以只能有所取舍，目前我只迁移了所有的文章，并且将tag对应上，至于图片我一开始就用的是对象存储所以问题应该不大。&lt;/p&gt;
&lt;p&gt;代码如下&lt;/p&gt;
&lt;h3 id=&quot;迁移代码&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/hello-world/#%E8%BF%81%E7%A7%BB%E4%BB%A3%E7%A0%81&quot;&gt;迁移代码&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;python&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;python&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;# -*- coding: utf-8 -*-&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; os&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; pymysql&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; arrow&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; box &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; Box&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; create_data&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(db):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    cursor &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; db.cursor()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;    # 创建文章&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    cursor.execute(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;select cid, title, slug, text, created, modified from ty_contents where type=&apos;post&apos;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;    # 创建分类和标签&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    entries &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; cursor.fetchall()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; e &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; entries:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        e &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; Box(e)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        title &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; e.title&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        title &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; title.strip(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        print&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(title)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        content &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(e.text).replace(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&amp;#x3C;!--markdown--&gt;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;        # 文章太长截断&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        max_length &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 150&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;  # Set the maximum content length here&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; len&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(content) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; max_length:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;            content &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; content[:max_length] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&amp;#x3C;!--more--&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; content[max_length:]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        tags &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        cursor.execute(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;select type, name, slug from `ty_relationships` ts, ty_metas tm where tm.mid = ts.mid and ts.cid = &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; e.cid)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        metas &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; cursor.fetchall()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;        for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; m &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; metas:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;            m &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; Box(m)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;            if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; m.type &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;tag&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;                tags.append(m.name)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        path &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;data/_posts/&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; not&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; os.path.exists(path):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;            os.makedirs(path)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        filename &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; arrow.get(e.created).format(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;YYYY-MM-DD&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot; &quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; title.replace(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;/&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;-&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; open&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;filename&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;.md&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;w&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;---&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;title: &apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;%s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; title)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;date: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;%s\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; arrow.get(e.created).format(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;YYYY-MM-DD HH:mm:ss&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;updated: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;%s\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; arrow.get(e.modified).format(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;YYYY-MM-DD HH:mm:ss&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;tags: [&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;%s&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;,&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.join(tags))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;published: true&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;lang: zh-cn&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;---&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.write(content)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        f.close()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; main&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;():&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;    # 把数据库连接信息&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    db &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; pymysql.connect(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;host&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;localhost&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;                                 user&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;root&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;                                 password&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;xxxxx&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;                                 database&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;typecho&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;                                 cursorclass&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;pymysql.cursors.DictCursor)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    create_data(db)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; __name__&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;__main__&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    main()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;这个代码也不是全是我原创的，我从网上翻出来然后改了改适应了下我自己的情况，如果需要进一步的迁移你也可以自己修改代码。&lt;/p&gt;
&lt;h3 id=&quot;结语&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/hello-world/#%E7%BB%93%E8%AF%AD&quot;&gt;结语&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;总算是回来了，从年轻时候花里胡哨的主题页面，到如今追求访问性能和主题简洁真的是变化不小啊&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>Hexo</category><category>Typecho</category><category>数据迁移</category><category>Python</category><category>博客</category></item><item><title>为Typecho添加两步验证</title><link>https://blog.xsy.fun/posts/2020-05-16-wei-typecho-tian-jia-liang-bu-yan-zheng/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2020-05-16-wei-typecho-tian-jia-liang-bu-yan-zheng/</guid><description>介绍如何为Typecho博客安装Google Authenticator插件并绑定两步验证客户端，提升后台登录安全性。</description><pubDate>Sat, 16 May 2020 20:23:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-05-16-wei-typecho-tian-jia-liang-bu-yan-zheng/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;今天发现了超级好用的应用Google系的Authenticator，这是一款基于时间与哈希算法的两步验证软件客户端，并且符合 RFC 6238 和 RFC 4226标准，因为博客的安全性还是很重要的，毕竟事关服务器，所以两步验证在这里就十分有必要。而刚好Typecho有一款Google Authenticator插件，开源在Github，质疑安全性的小伙伴可以自行查看：&lt;a href=&quot;https://github.com/naicfeng/typecho-Authenticator&quot; title=&quot;项目地址&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;项目地址&lt;/a&gt;&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;使用方法&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-05-16-wei-typecho-tian-jia-liang-bu-yan-zheng/#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95&quot;&gt;使用方法&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;修改文件名为GAuthenticator放到/usr/plugins目录，然后到后台启用&lt;/p&gt;
&lt;p&gt;插件默认关闭，首次开启需要扫描二维码绑定之后填写手机上显示的代码，验证成功之后才可以启用&lt;/p&gt;
&lt;h4 id=&quot;下载地址在此点我&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-05-16-wei-typecho-tian-jia-liang-bu-yan-zheng/#%E4%B8%8B%E8%BD%BD%E5%9C%B0%E5%9D%80%E5%9C%A8%E6%AD%A4%E7%82%B9%E6%88%91&quot;&gt;下载地址在此：&lt;/a&gt;&lt;a href=&quot;https://github.com/naicfeng/typecho-Authenticator/releases&quot; title=&quot;github&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;点我&lt;/a&gt;&lt;/h4&gt;
&lt;h3 id=&quot;安装客户端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-05-16-wei-typecho-tian-jia-liang-bu-yan-zheng/#%E5%AE%89%E8%A3%85%E5%AE%A2%E6%88%B7%E7%AB%AF&quot;&gt;安装客户端&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;兼容所有符合 &lt;a href=&quot;https://tools.ietf.org/html/rfc6238&quot; title=&quot;rfc6238&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;RFC6238&lt;/a&gt; 规范的AuthOTP软件&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Microsoft Authenticator&lt;/li&gt;
&lt;li&gt;Google Authenticator&lt;/li&gt;
&lt;li&gt;1Password&lt;/li&gt;
&lt;li&gt;Authy&lt;/li&gt;
&lt;li&gt;KeePass&lt;/li&gt;
&lt;li&gt;LastPass&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;在这里，我个人使用的是Google系的Authenticator，对于系统的占用也比较小，简洁方便&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>Typecho</category><category>网络安全</category><category>两步验证</category><category>博客</category></item><item><title>小程序版Typecho构建</title><link>https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/</guid><description>介绍如何基于WeChat-Typecho项目搭建并修改微信小程序版Typecho博客，包括域名配置、插件设置与页面定制。</description><pubDate>Mon, 20 Apr 2020 18:35:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;最近我看到不少博主都发布了微信小程序版Typecho，但是质量层次不齐，开源的界面不美观，也有美观的，但是要收费，秉着节俭的原则，还是在github尝试了n多的项目之后找到了个真正能跑起来的项目，先不说界面怎么样，起码是可以跑起来的，其他项目多多少少在我这个主题下有些问题，也可能是当时的调试问题吧，毕竟是第一次接触微信小程序，最开始还不是很熟悉项目的构建，后来慢慢花的时间多了才摸清楚具体的操作，正是因为开源的程序界面并不是很美观而且handsome主题启用他们比较困难，例如头图的丢失，文章摘要的丢失，等等，所以我选择在一版能跑起来的项目上修改前端页面。&lt;/p&gt;
&lt;h3 id=&quot;项目地址&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E9%A1%B9%E7%9B%AE%E5%9C%B0%E5%9D%80&quot;&gt;项目地址&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/xsy2004/WeChat-Typecho&quot; title=&quot;WeChat-Typecho&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;WeChat-Typecho&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;求求大佬Star啊，卑微&lt;/p&gt;
&lt;h4 id=&quot;扫码预览&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E6%89%AB%E7%A0%81%E9%A2%84%E8%A7%88&quot;&gt;扫码预览&lt;/a&gt;&lt;/h4&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;a href=&quot;https://cdn.xsiy.ltd/photo/cid178/cxm.jpg&quot; title=&quot;小程序码&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/cid178/cxm.jpg&quot; alt=&quot;小程序码&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/a&gt;&lt;figcaption&gt;小程序码&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;特别鸣谢&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E7%89%B9%E5%88%AB%E9%B8%A3%E8%B0%A2&quot;&gt;特别鸣谢&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;把致谢放在最开头是因为我自己也是一个&lt;del&gt;码农&lt;/del&gt;菜鸡，所以深知写代码的不容易，所以在此特别感谢&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/MingliangLu/WeTypecho&quot; title=&quot;WeTypecho&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;WeTypecho&lt;/a&gt;——成都第七帅大佬，博客端插件作者&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://gitee.com/Byclemon/Pisces-Mini-Program&quot; title=&quot;Pisces-Mini-Program&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;Pisces-Mini-Program&lt;/a&gt;——基于WeTypecho修改作者&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/weilanwl/ColorUI&quot; title=&quot;ColorUI&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;ColorUI&lt;/a&gt;——小程序CSS库&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;说明&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E8%AF%B4%E6%98%8E&quot;&gt;说明&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;为什么我没有选择github上的其他作者的项目？&lt;/p&gt;
&lt;p&gt;因为我希望我的微信小程序不仅仅是可以浏览，而是可以交互，用户可以做到使用小程序评论，去表达对文章的看法与思考，如果以后我有能力去编写后端js了，我会将github上我觉得很好看的项目给完善&lt;/p&gt;
&lt;p&gt;例如 &lt;a href=&quot;https://github.com/loveempathy/WxappForTypecho&quot; title=&quot;WxappForTypecho&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;WxappForTypecho&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&quot;项目中的字母函数命名不是我写的&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E9%A1%B9%E7%9B%AE%E4%B8%AD%E7%9A%84%E5%AD%97%E6%AF%8D%E5%87%BD%E6%95%B0%E5%91%BD%E5%90%8D%E4%B8%8D%E6%98%AF%E6%88%91%E5%86%99%E7%9A%84&quot;&gt;项目中的字母函数命名不是我写的！！！&lt;/a&gt;&lt;/h4&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;小程序发布要求&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%8F%91%E5%B8%83%E8%A6%81%E6%B1%82&quot;&gt;小程序发布要求&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;域名已备案&lt;/li&gt;
&lt;li&gt;域名开启Https&lt;/li&gt;
&lt;li&gt;已成年，或者拥有18岁以上微信绑卡账号&lt;/li&gt;
&lt;/ol&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;a href=&quot;https://cdn.xsiy.ltd/photo/cid178/1.png&quot; title=&quot;微信端域名配置&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/cid178/1.png&quot; alt=&quot;微信端域名配置&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/a&gt;&lt;figcaption&gt;微信端域名配置&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;将你的域名添加进去，如果你的图片等资源存放的地址不是你上面设置的域名&lt;/p&gt;
&lt;p&gt;还需要将你的图片资源域名添加进去，否则小程序端可能无法显示资源。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;功能&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E5%8A%9F%E8%83%BD&quot;&gt;功能&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;目前支持的基本功能如下：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;查看分类目录文章&lt;/li&gt;
&lt;li&gt;个人关于界面显示&lt;/li&gt;
&lt;li&gt;首页文章轮播图&lt;/li&gt;
&lt;li&gt;评论文章&lt;/li&gt;
&lt;li&gt;自动获取文章头图&lt;/li&gt;
&lt;li&gt;图片视频显示&lt;/li&gt;
&lt;li&gt;支持markdown,html解析&lt;/li&gt;
&lt;li&gt;推荐阅读文章&lt;/li&gt;
&lt;li&gt;搜索文章&lt;/li&gt;
&lt;li&gt;自定义字符显示不同卡片样式&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;自定义字符&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AD%97%E7%AC%A6&quot;&gt;自定义字符&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;style （首页文章显示样式，值默认为3，其他的我也没测试）&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;代码大图卡片形式&lt;/li&gt;
&lt;li&gt;代表小图卡片显示形式&lt;/li&gt;
&lt;li&gt;代表背景卡片形式&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;isPay（文章是否需要广告启动，默认为0） 1：是 0：否&lt;/p&gt;
&lt;p&gt;thumb（文章缩略图）&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;教程&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E6%95%99%E7%A8%8B&quot;&gt;教程&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;在&lt;code&gt;/common/vendor.js&lt;/code&gt;第236行修改你的信息，这函数命名规则不是我写的，别打我&lt;/p&gt;
&lt;p&gt;在微信开发者工具调试的时候要在详情里面勾选，不校验合法域名，web-view，那一项，要不然在调试的时候会显示不了文章&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;修改r和i并且与后端小程序对应上&lt;/strong&gt;&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/cid178/2.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;在&lt;code&gt;/pages/about/home/home.wxml&lt;/code&gt;第6行和第8行修改你的博客名和简介&lt;/p&gt;
&lt;p&gt;在&lt;code&gt;/pages/index/index.wxml&lt;/code&gt;第三行修改小程序最顶上的名称&lt;/p&gt;
&lt;p&gt;在&lt;code&gt;/pages/index/index.js&lt;/code&gt;第57行修改每篇文章下的作者信息&lt;/p&gt;
&lt;p&gt;在&lt;code&gt;/app.json&lt;/code&gt;第16行修改你的博客名&lt;/p&gt;
&lt;p&gt;在&lt;code&gt;/pages/about/home/home.wxss&lt;/code&gt;第2行修改关于界面的头像地址&lt;/p&gt;
&lt;p&gt;在&lt;code&gt;/pages/about/home/home.wxml&lt;/code&gt;第4行修改头像地址&lt;/p&gt;
&lt;p&gt;在&lt;code&gt;/pages/about/home/home.js第73&lt;/code&gt;和74行修改微信赞赏码的图片地址&lt;/p&gt;
&lt;p&gt;在&lt;code&gt;/pages/details/details.wxml&lt;/code&gt;第157行修改你自己想点赞后出现的图片，反正自己改&lt;/p&gt;
&lt;h3 id=&quot;typecho插件端&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#typecho%E6%8F%92%E4%BB%B6%E7%AB%AF&quot;&gt;Typecho插件端&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;复制&lt;code&gt;WeTypecho&lt;/code&gt;到插件目录， 在后台激活并设置，名字要对否则报错。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;APISEC&lt;/li&gt;
&lt;li&gt;博客作者名称&lt;/li&gt;
&lt;li&gt;博客网址&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;这三项必填，其他随便（吧）&lt;/p&gt;
&lt;p&gt;要与小程序端config.js中API_SECRET字段保持一致，否则无法从服务器读取数据&lt;/p&gt;
&lt;h3 id=&quot;代码解释&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-20-xiao-cheng-xu-ban-typecho-gou-jian/#%E4%BB%A3%E7%A0%81%E8%A7%A3%E9%87%8A&quot;&gt;代码解释&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;app.js是最初的入口文件，wxss是相当于html项目中的css，如果在js里添加新代码要再json文件中声明。&lt;/p&gt;
&lt;p&gt;static是放资源文件的地方，可以自行修改素材，但好像不是全部都引用了，自己慢慢找吧。&lt;/p&gt;
&lt;p&gt;pages是所有的页面，可以被引用跳转，例如跳转关于页面，地址为&lt;code&gt;pages/about/home/home&lt;/code&gt;about下的home目录的home方法叭，大概就这意思，我也是第一次接触微信小程序。。&lt;/p&gt;
&lt;p&gt;这个项目引入了Color UI，可以自己去下载demo自己 &lt;del&gt;抄&lt;/del&gt; 写。&lt;/p&gt;
&lt;p&gt;在/pages/index/index.js第26行下面是修改首页那两个跳转按钮的&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	categories: [{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		cuIcon: &quot;write&quot;,//这个是图标，可以自己去color ui的小程序找名称修改&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		color: &quot;white&quot;,//这个是文字颜色&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		bg_color: &quot;bg-gradual-green&quot;,//这个是背景颜色，可自行修改&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		badge: 1,//小红点文章个数，填1就是一个小红点，大于1就是显示数字，大于99显示99+&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		mid: &quot;24&quot;,//这个是分类id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		title: &quot;随笔&quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		name: &quot;Essay&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	}，&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;可以自行添加参数，调用方法如下&lt;code&gt;{{item.title}}&lt;/code&gt;使用前要声明&lt;code&gt;wx:for=&quot;{{categories}}&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;求大佬赞赏啦&lt;img src=&quot;https://cdn.xsiy.ltd/wxxcx/zsm.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>Typecho</category><category>微信小程序</category><category>前端</category><category>博客</category></item><item><title>网站全局变灰操作方式及实现CSS代码</title><link>https://blog.xsy.fun/posts/2020-04-04-wang-zhan-quan-ju-bian-hui-cao-zuo-fang-shi-ji-shi-xian-css-dai-ma/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2020-04-04-wang-zhan-quan-ju-bian-hui-cao-zuo-fang-shi-ji-shi-xian-css-dai-ma/</guid><description>介绍如何用 CSS 的 grayscale 滤镜让整个网站变灰，并给出兼容主流浏览器和旧版 IE 的写法。</description><pubDate>Sat, 04 Apr 2020 08:24:00 GMT</pubDate><content:encoded>&lt;br&gt;
&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-04-wang-zhan-quan-ju-bian-hui-cao-zuo-fang-shi-ji-shi-xian-css-dai-ma/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;为表达全国各族人民对抗击新冠肺炎疫情斗争牺牲烈士和逝世同胞的深切哀悼，国务院决定，2020年4月4日举行全国性哀悼活动。&lt;/p&gt;
&lt;p&gt;为响应国务院办公厅关于为新冠肺炎疫情牺牲烈士和逝世同胞举行全国性哀悼活动的通知，同时按照客户的要求将部分客户网站于4月4日0时至24时变黑白。同时我们伟致官网也同步变灰，以悼念抗击新冠肺炎疫情斗争牺牲烈士和逝世同胞，简单描述下如何将网站变灰。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;正文&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-04-wang-zhan-quan-ju-bian-hui-cao-zuo-fang-shi-ji-shi-xian-css-dai-ma/#%E6%AD%A3%E6%96%87&quot;&gt;正文&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;css方法&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-04-04-wang-zhan-quan-ju-bian-hui-cao-zuo-fang-shi-ji-shi-xian-css-dai-ma/#css%E6%96%B9%E6%B3%95&quot;&gt;CSS方法&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;在网站需要变灰的页面head部分加入一行style&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;text/css&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;html {&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;-webkit-filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;grayscale&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);}&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;以上代码适用于主流浏览器，如新版的chrom，edge等&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;    html&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        -webkit-filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;grayscale&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        -moz-filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;grayscale&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        -ms-filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;grayscale&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        -o-filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;grayscale&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;%&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;        filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:progid:DXImageTransform.Microsoft.BasicImage(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;grayscale&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        _&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;filter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;以上代码兼容绝大多数浏览器，包括QQ浏览器，360极速浏览器，IE浏览器等&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>前端</category><category>CSS</category><category>兼容性</category></item><item><title>将Chrome离线小恐龙嵌入博客</title><link>https://blog.xsy.fun/posts/2020-03-31-jiang-chrome-li-xian-xiao-kong-long-qian-ru-bo-ke/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2020-03-31-jiang-chrome-li-xian-xiao-kong-long-qian-ru-bo-ke/</guid><description>介绍如何把 Chrome 离线小恐龙游戏嵌入 Typecho 博客，包括通用网页引入方式、iframe 嵌入代码和使用注意事项。</description><pubDate>Tue, 31 Mar 2020 17:22:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-31-jiang-chrome-li-xian-xiao-kong-long-qian-ru-bo-ke/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;最近我逛各位大佬的博客时，看到了将chrome的离线游戏嵌入博客，就觉得比较有意思，想抄过来，发现原博客的实现方法和源代码实在粗糙，于是我在github上找到了源码，将其进一步更方便嵌入博客，现在讲讲步骤&lt;/p&gt;
&lt;p&gt;先来玩下我的吧 &lt;a href=&quot;https://www.xsy.fun/game.html&quot; title=&quot;点我开始玩耍&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;点我开始玩耍&lt;/a&gt;&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;正文&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-31-jiang-chrome-li-xian-xiao-kong-long-qian-ru-bo-ke/#%E6%AD%A3%E6%96%87&quot;&gt;正文&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;首先，项目源码在此：&lt;a href=&quot;https://github.com/xsy2004/chrome_dino_game&quot; title=&quot;Github&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;Github&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;一般网页&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-31-jiang-chrome-li-xian-xiao-kong-long-qian-ru-bo-ke/#%E4%B8%80%E8%88%AC%E7%BD%91%E9%A1%B5&quot;&gt;一般网页&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;使用方法很简单，如果在一般的网页中使用直接添加&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;runner.js&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; initRunner&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;#container&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;其中&lt;code&gt;runner.js&lt;/code&gt;可以为任意地址，你可以把runner放在本地，也可以把runner放在OSS（阿里云对象储存）等储存。&lt;/p&gt;
&lt;h3 id=&quot;typecho博客&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-31-jiang-chrome-li-xian-xiao-kong-long-qian-ru-bo-ke/#typecho%E5%8D%9A%E5%AE%A2&quot;&gt;Typecho博客&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;我们还可以将这段代码嵌入到博客里去，当然因为在这里图个方便，我直接使用iframe方法来引入，比较方便，我在这贴下我的方法&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;iframe&lt;/span&gt;&lt;span style=&quot;--shiki-light:#B31D28;--shiki-light-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic&quot;&gt; align&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;center&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; width&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;100%&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; height&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;200px&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://cdn.xsiy.ltd/site/typecho/game/index.html&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;  frameborder&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;no&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#B31D28;--shiki-light-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic&quot;&gt; border&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;  scrolling&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;no&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; marginwidth&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; marginheight&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; &gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;iframe&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;很简单啊，就一句话就可以了，当然你也可以选择常规的方式去嵌入。&lt;/p&gt;
&lt;p&gt;我的方法是引入我OSS（阿里云对象储存）存放的html文件，所以要保证你的OSS（阿里云对象储存）和你的网站活的一样久。&lt;/p&gt;
&lt;p&gt;index.html的网页源码如下&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;!&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;DOCTYPE&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; html&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;zh-CN&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; charset&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;viewport&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;Runner&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://cdn.xsiy.ltd/site/typecho/game/runner.js&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;    initRunner&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;( &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;#test&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; );&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;你可以自己存放在本地服务器去引用，js同理&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;注意&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-31-jiang-chrome-li-xian-xiao-kong-long-qian-ru-bo-ke/#%E6%B3%A8%E6%84%8F&quot;&gt;注意&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;在typecho中的markdown语法&lt;code&gt;!!!你的代码!!!&lt;/code&gt;这样是嵌入代码，记得是英文感叹号。&lt;/p&gt;
&lt;p&gt;不要直接复制我的代码使用，因为设置了Referer白名单防止盗链，直接使用是无效的。&lt;/p&gt;
&lt;p&gt;本方法支持手机，电脑，等设备玩耍。&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>前端</category><category>Typecho</category><category>博客</category><category>Markdown</category></item><item><title>Visual Studio远程开发</title><link>https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/</guid><description>介绍如何在 Ubuntu 上部署 code-server 并用 systemd 守护进程，实现 VS Code 远程开发环境。</description><pubDate>Mon, 02 Mar 2020 16:24:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;近期，搞了个远程开发的项目&lt;code&gt;Visual Studio Code Remote Development&lt;/code&gt;就是将vscode客户端搬上云端，&lt;/p&gt;
&lt;p&gt;让你可以在容器中、远程设备上、甚至是 Windows 的 Linux 子系统（WSL）上使用具有完整功能的开发环境&lt;/p&gt;
&lt;h3 id=&quot;官方说明&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#%E5%AE%98%E6%96%B9%E8%AF%B4%E6%98%8E&quot;&gt;官方说明&lt;/a&gt;&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;在您部署到的同一操作系统上进行开发，或使用更大或更专业的硬件。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;将开发环境沙盒化，以免影响本地计算机配置。&lt;/p&gt;
&lt;p&gt;使新贡献者易于上手，并使每个人都保持一致的环境。&lt;/p&gt;
&lt;p&gt;使用本地操作系统上不可用的工具或运行时，或管理它们的多个版本。&lt;/p&gt;
&lt;p&gt;使用Windows Linux子系统开发Linux部署的应用程序。&lt;/p&gt;
&lt;p&gt;从多台机器或位置访问现有的开发环境。&lt;/p&gt;
&lt;p&gt;调试在其他位置（例如客户站点或云中）运行的应用程序。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://code.visualstudio.com/assets/docs/remote/remote-overview/architecture.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;如何安装&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#%E5%A6%82%E4%BD%95%E5%AE%89%E8%A3%85&quot;&gt;如何安装&lt;/a&gt;&lt;/h2&gt;
&lt;h4 id=&quot;系统要求&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#%E7%B3%BB%E7%BB%9F%E8%A6%81%E6%B1%82&quot;&gt;系统要求&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;本地：还必须安装受支持的OpenSSH兼容SSH客户端。&lt;/p&gt;
&lt;h4 id=&quot;远程ssh主机在以下位置运行的ssh服务器&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#%E8%BF%9C%E7%A8%8Bssh%E4%B8%BB%E6%9C%BA%E5%9C%A8%E4%BB%A5%E4%B8%8B%E4%BD%8D%E7%BD%AE%E8%BF%90%E8%A1%8C%E7%9A%84ssh%E6%9C%8D%E5%8A%A1%E5%99%A8&quot;&gt;远程SSH主机：在以下位置运行的SSH服务器：&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;x86_64 Debian 8以上版本，Ubuntu 16.04以上版本，CentOS / RHEL 7以上版本。&lt;/p&gt;
&lt;p&gt;ARMv7l（AArch32）Raspbian Stretch / 9 +（32位）。&lt;/p&gt;
&lt;p&gt;ARMv8l（AArch64）Ubuntu 18.04+（64位）。&lt;/p&gt;
&lt;h4 id=&quot;实验性ssh主机支持仅vs-code-insiders&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#%E5%AE%9E%E9%AA%8C%E6%80%A7ssh%E4%B8%BB%E6%9C%BA%E6%94%AF%E6%8C%81%E4%BB%85vs-code-insiders&quot;&gt;实验性SSH主机支持（仅VS Code Insiders）：&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Windows 10 / Server 2016/2019（1803+），使用官方的OpenSSH Server并remote.SSH.useLocalServer 在VS Code设置中启用。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;ubuntu-1804&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#ubuntu-1804&quot;&gt;Ubuntu 18.04&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;首先先在github下载软件包&lt;a href=&quot;https://github.com/cdr/code-server/releases&quot; title=&quot;下载地址&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;下载地址&lt;/a&gt;&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;wget https://github.com/cdr/code-server/releases/download/2.1698/code-server2.1698-vsc1.41.1-linux-x86_64.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;tar xvzf code-server2.1698-vsc1.41.1-linux-x86_64.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;cd code-server2.1698-vsc1.41.1-linux-x86_64&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# 设置密码&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;export PASSWORD=password&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;./code-server --auth password&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h3 id=&quot;进程守护&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#%E8%BF%9B%E7%A8%8B%E5%AE%88%E6%8A%A4&quot;&gt;进程守护&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;sudo nano /etc/systemd/system/code-server.service&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;添加下面的配置：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;[Unit]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Description=Code Server IDE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;After=network.target&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;[Service]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Type=simple&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;User=root&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Restart=on-failure&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;RestartSec=10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Environment=&quot;PASSWORD=password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;ExecStart=/path/to/code-server --auth password &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;StandardOutput=file:/var/log/code-server-output.log&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;StandardError=file:/var/log/code-server-error.log&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;[Install]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;WantedBy=multi-user.target&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;启动服务&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2020-03-02-visual-studio-yuan-cheng-kai-fa/#%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1&quot;&gt;启动服务&lt;/a&gt;&lt;/h2&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;systemctl start code-server&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>linux</category><category>运维</category><category>网络</category></item><item><title>洞庭湖考察-Day 3</title><link>https://blog.xsy.fun/posts/2019-11-15-dong-ting-hu-kao-cha-day-3/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-11-15-dong-ting-hu-kao-cha-day-3/</guid><description>记录洞庭湖研学第三天的行程，包括江豚巡游、与保护站站长的交流以及返程经历。</description><pubDate>Sat, 16 Nov 2019 04:53:00 GMT</pubDate><content:encoded>&lt;p&gt;在为期三天的研学的最后一天，我们于上午七点二十分出发，车行将近两个小时九十公里后到达了我们研学旅途的最后一站:江豚江道保护站。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/cid163/1D7S%24U9Y%7E3KAU73J_SP51JX.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;我们在简单的休整后便开始了江道巡游，全班站在船上观察有无江豚活动，而我们不仅看到了江豚跃出水面的画面，还看到了稀有禽类在天空飞翔，所谓收获颇丰。&lt;/p&gt;
&lt;p&gt;站在船头感受江风吹过，江水在脚底激荡着，浪花在不断拍击着，呼吸无污染的纯净空气，我们打心底地意识到环境保护是多么的重要，而且我们也下定决心去以身作则，自觉保护生态环境。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/cid163/EW%7DU%251A%25G2%40_4%40JU%24Q%7E_QDM.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;巡游结束后，我们有幸见到了保护站的站长。作为长期在保护长江环境战斗的第一线，站长对保护江豚有着非常独到的见解和渊博的知识。于是我们问出了我们准备许久的几个问题，如保护江豚与经济发展是否有冲突，江豚能否与同科物种进行杂交等等。站长十分热切地为我们解答，他的回答独树一帜，开拓了我们新的思维，使我们受益匪浅。&lt;/p&gt;
&lt;p&gt;在离去前，为作此次巡江活动的纪念，我们主动向站长提出合影的请求，站长也积极地回应了我们，与我们集体学生和带队老师留下了一张意义非凡的合影照片。&lt;/p&gt;
&lt;p&gt;在离开后我们到就近餐馆用了午餐，正式标志着最后一项活动的落幕，随后便开始了返回长沙东高铁站的车程。经历4个小时的大巴，2个小时的火车，我们在7:00顺利回到了南昌，结束了最后一天的行程。&lt;/p&gt;
&lt;p&gt;回望三天我们荣幸看到了我们从未了解过的江豚；认识了研学负责人稻哥，麋鹿保护区李站长，洞庭湖民间保护人大明哥，湖南华容集成长江故道邓主任。因为他们我们学习到了关于江豚，麋鹿，候鸟各个方面的知识。经过三天的研学我们了解到保护江豚有多么重要，保护江豚的种子在心里发芽，改善江豚的生存环境需要每个人都行动起来。&lt;/p&gt;
&lt;p&gt;江豚研学三天虽短，但这些记忆我们将永存！&lt;/p&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>读书笔记</category><category>运维</category></item><item><title>洞庭湖考察-Day 2</title><link>https://blog.xsy.fun/posts/2019-11-14-dong-ting-hu-kao-cha-day-2/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-11-14-dong-ting-hu-kao-cha-day-2/</guid><description>记录2019年洞庭湖研学第二天的行程，包括江豚观察、底栖生物与水质实验以及当日总结。</description><pubDate>Thu, 14 Nov 2019 21:14:00 GMT</pubDate><content:encoded>&lt;p&gt;2019年11月14日是我们来到湖南岳阳研学的第二天。这是世界著名的中国传统文化发源地——洞庭湖。我们小组搭上了游艇，去近距离接触国家一级珍惜保护动物——江豚。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid162/-4fb97907021e7194.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;江豚是世界濒危物种，在洞庭湖的存活数量也仅仅300只左右。但是，在幸运女神的庇护下，我们有幸见到江豚并幸运的记录下了江豚出水的瞬间。&lt;/p&gt;
&lt;p&gt;在游艇上吹着海风，看着蓝天白云，在不经意间看到两道黑色的弧线“:是江豚！”同学们惊喜地喊着。在江豚出水的一瞬间，几位同学拿出相机拍下江豚出水的优雅姿态。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid162/qq_pic_merged_1573745529532.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;登上瞭望塔所属的小岛上，同学们见到了两个“守卫者”，那是被工作人员收养的两只小狗，在喂食的过程中，有几位同学为了“研学伟业”，不甚陷入沼泽地，牺牲了自己的鞋子，经过了这些小插曲，我们准备返航了。&lt;/p&gt;
&lt;p&gt;突然，一艘庞然大物出现了。稻哥说：“看那，前面应该是非法采砂，整个洞庭湖江面严禁采砂。”，听到这个消息我们愤慨，却又无可奈何，我们能做的就只是向国家相关部门进行举报，但是我转念一想，群众的见证就是对非法采砂者最好的震慑，我们，让他们感受到了社会的关注，我们真正的为江豚的保护事业出一份力！&lt;/p&gt;
&lt;p&gt;警笛声响起，我们知道，是船政工作人员到来了，相信不法分子会得到严惩。但是，船政工作人员对我们解释道：“那是有合法手续的清淤船”。我们只是手里拿着相机，什么也不说，就默默拍下这一幅画面，沙一斗一斗的运上，钱一捆一捆的进账，我们能做的，也只有这些了。&lt;/p&gt;
&lt;p&gt;人性是复杂的，商人是逐利的，但世界也不总是黑暗的，那一丝的光明，将由我们点亮，在黑暗中，打开一盏灯，照亮黑暗，温暖人心。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid162/220e8f7b8ff41454.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;午饭后我们稍时休息，把鞋子和衣服上的泥土收拾了一下，开始了我们下午的两个实验调查。&lt;/p&gt;
&lt;p&gt;第一个实验是底栖生物实验。我们用刘老师带来的专业仪器——彼得逊底泥采样器，我们把底泥捞上来后，经过层层过滤，多道工序，筛序出适合采集生物的样本，紧接着用镊子把贝壳，田螺，蜻蜓幼虫等生物收集在瓶内，这样我们就可以通过收集到的生物来判断水质是否良好。&lt;/p&gt;
&lt;p&gt;经过刘老师的讲解，我们了解到，每当在一片水域中出现蜻蜓幼虫时则表明此地水质较好，而出现水蛭，蚂蟥时表明此地水域污染严重。在实验中，我们小组很幸运的收集到了蜻蜓幼虫，当然还有一些贝壳和田螺。由此可见洞庭湖的水质相对来说不错。&lt;/p&gt;
&lt;p&gt;第二个实验是样本水通过PH试纸，氨氮和高锰酸钾的数据来判断水质的好坏。我们对污水排放处和地表水面的样本进行对比，发现污水排放处的水质污染严重超标，可见一些工厂对环境伤害的理所应当。但可惜的是我们即使发现了这个问题，也不能制止污染环境行为，只能将样本放回湖中。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid162/0s01032834384P91114-164110.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;在晚饭过后，我们驱车回到了宾馆，来到二楼会议室参加今日总结小会。首先刘老师给我们介绍了明日计划——去集成研究所和迁地保护区，告诉我们明天需要到达的目标和注意事项。然后总结了今天的日程，通过这次小会我们体会到研学旅行注重“研”而不是“旅”，我们要透过现象看到本质问题，并对相应问题提出建议。最后今天的行程在观看了刘老师之前去长江巡航探测江豚的纪录片落下帷幕。&lt;/p&gt;
&lt;p&gt;明天既是新的开始又是我们归航的日子，我们定会珍惜去集成所的机会，希望明天不留遗憾！&lt;/p&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>网络安全</category><category>运维</category><category>读书笔记</category></item><item><title>洞庭湖考察-Day 1</title><link>https://blog.xsy.fun/posts/2019-11-13-dong-ting-hu-kao-cha-day-1/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-11-13-dong-ting-hu-kao-cha-day-1/</guid><description>记录南昌高一学生在湖南岳阳开展江豚科研调查的第一天行程，包括麋鹿保护区参观和洞庭湖候鸟观察。</description><pubDate>Wed, 13 Nov 2019 18:26:00 GMT</pubDate><content:encoded>&lt;p&gt;在11月13号早晨10点08分，南昌市心远学校高一国际班的学生们从南昌来到湖南岳阳进行为期三天的江豚科研调查活动，活动第一天圆满结束，动态报告如下：&lt;/p&gt;
&lt;p&gt;上午经过了2个小时的车程，我们抵达了长沙东火车站，经过短暂的休息之后，我们又启程前往岳阳，于12点56分抵达岳阳，在用完午餐后，跟随刘老师到达李站长所管理的麋鹿保护区，近距离观察到了国家一级珍惜保护动物麋鹿——点点。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid160/_1397309447_DSCF8077_1573652006000_xg_0.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;我们积极地询问了李站长有关麋鹿的形态特征，栖息环境，生活习性，分布范围，繁殖方式，种族现状等信息，而李站长也热切地回应了我们。&lt;/p&gt;
&lt;p&gt;我们不仅了解到了关于麋鹿的具体信息，并且我们每一位同学都在李站长的带领下亲手将食物喂给了麋鹿点点&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid160/mmexport1573651769998.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;通过我们设身处地的调查与研究，我们感受到了李站长对保护野生动物与自然环境的毅力和决心，这使得我们下定决心，也要学习李站长，以李站长为榜样，树立保护野生动物的意识。&lt;/p&gt;
&lt;p&gt;临走前，我们主动向李站长提出了合照的请求，李站长欣然接受，于是我们留下了一张与李站长和点点的大合照以作为我们此次研学调查的纪念与回忆。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid160/mmexport1573652297114.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;在结束对点点的调查后，我们驱车来到了东洞庭湖自然保护区。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid160/%7DQL0J67T9%5BPA5ZI%25W%5DK22U2.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;在东洞庭湖国家级自然保护区湿地生物科学馆我们观看了保护洞庭湖环境的纪录片，在纪录片中“支撑着湖南整个用水和曾使长江无数次的洪患化险为夷”“洞庭湖以水而名，以鸟而盛”使我们更深刻体会到洞庭湖的重要性。同时，我们还了解到鸟，野生植物，淡水鱼，江豚等8类真实标本。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid160/mmexport1573651768653.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;在刘老师的带领下我们运用专业的望远镜观察到雁，鸭等候鸟物种，其中在采桑湖上有一群鸭子在湖上休闲嬉戏。刘老师告诉我们识别候鸟种类分三步骤:先看喙，再看腿，最后看羽毛；我们还了解到有一些游客曾经为了拍出漂亮的照片，被迫候鸟飞起来使得他们的翅膀受到伤害。我们体会到观察候鸟不仅仅要观察他们的外观，辨别他们的种类，还要学会保护他们的环境，他们的习性，在观察同时尽量不打扰他们的生活。在晚饭过后，我们结束了第一天的行程。&lt;/p&gt;
&lt;p&gt;这一天有陌生，有惊喜，也有失望，学会了很多知识也知道我们的一举一动都会影响着环境。夜幕降临，我们期待着明天洞庭湖江豚之旅，愿明天有更多新收获！&lt;/p&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>读书笔记</category><category>写作</category></item><item><title>中考前的生活</title><link>https://blog.xsy.fun/posts/2019-06-19-zhong-kao-qian-de-sheng-huo/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-06-19-zhong-kao-qian-de-sheng-huo/</guid><description>作者记录中考前十天补习的经历、考后心态，并顺带提到给家里路由器加装散热改装件的小事。</description><pubDate>Wed, 19 Jun 2019 19:41:00 GMT</pubDate><content:encoded>&lt;p&gt;今天12点钟以后能限制我的只有中华人民共和国宪法了，考完了是真的开心，也就有时间来写这一篇博客了，先说说考试前吧，那个日子真的是惨啊，因为我考试的前十天就没在学校上课了，跑去了一个教育机构补习物理化学和英语，这十天真的是过的难受啊，也算是为自己拼搏了一次吧，我想，也许学霸每个周末都是这么过的吧。想到这，我就有点惭愧了，平时不努力就只能临时抱抱佛脚了呗。&lt;/p&gt;
&lt;p&gt;说说这十天我是怎么过的吧，每天有着不亚于学校上课强度的课程，早上8点到10点的英语，接着是物理，下午2点到4点的化学课，接着就是写卷子，一般是物理两张，化学一张，英语听力和阅读理解了，这个是每天的训练量，最后转化率只有英语比较低，化学也进步了20分吧，可想而知我之前的成绩是有多差啊，物理呢进步了10分左右，有时候不逼自己一把也不知道自己能做到怎样的一种程度吧！也许苦尽甘来就是这样了！虽然这十天过的很累，但是我体会了一种劳动人民收获的喜悦，只能说这感觉非常棒，人，是要给自己定目标的，而我呢，比较喜欢去执行而不去指导，所以也就不怎么给自己定目标吧。&lt;/p&gt;
&lt;p&gt;虽然只有10天但是还是发生了很多事情吧，第一天过去或许还有新鲜感，但是过了第二天只剩下痛苦了，所以呐，经常一个人到天台上散散心，这种感觉真的很不错呢。&lt;/p&gt;
&lt;p&gt;貌似到最后还跟老师发生了点冲突，但是没关系啦，过了这些时间也就见不到她了，怎么说呢，有人认为我比较轴，仔细想想好像有一点，但是我只是在我自己坚决认同的事情上比较轴，而我认为我并没有做错什么啊，比如说一个人想抢我的零食，我就算丢掉也不会给他，但是如果他礼貌的向我要的话我是会给他的（当然，关系很好的除外）这毕竟侵犯了公民的财产权对吧，所以说我认为我没有什么错误啊，反而是他的这种行为损害了我的财产权。&lt;/p&gt;
&lt;p&gt;而且我非常讨厌别人威胁我，如果有人拿着一把刀子对着我的话，并且有想要捅我的欲望我会毫不犹豫的还手，这也许的一种人的本能吧，但是在生活中呢，有人威胁我吧，我一定会报复她，而且是悄无声息的报复，脸上一定会对敌人带着笑容，背地里捅刀子，我觉得这样是最好不过的了，毕竟体面人是吧。&lt;/p&gt;
&lt;p&gt;文章写的有点杂，基本上是想到什么写什么吧，见谅了！&lt;/p&gt;
&lt;p&gt;最近我还干了一件事情，最近我哥到我家来就反映打游戏老是会460ms，我就觉得肯定是mesh路由器的问题，所以我把路由器挂到闲鱼卖400多再花300买了个斐讯K3和一个散热改装件&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid158/IMG_20190618_201209.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;这个就是成品啦，应该降温了10多度，效果还是很明显的！但是还是要等我哥来我家实测啦！我又不打游戏（小声BB）&lt;/p&gt;
&lt;p&gt;还有就是拍了几个视频，虽然没什么人看，但是我觉得还是要坚持下去把，毕竟是一个自己爱好的兴趣，所以我应该会在这个假期更新很多视频把，也许技术性的东西会少很多，而记录生活的写实视频会占大部分，假期来的太快了，多少有一点不真实，想想马上就要进入到一个全新的环境——高中，心里不免有些失落，这条从家里到学校的路我都习惯了呢！&lt;/p&gt;
&lt;p&gt;但是呢，人还是要学会跳出自己的舒适区，去学会改变一些事情，因为我本身就是个乐观主义者（可能是经历不好的事情太多了罢）所以说新的环境有新的老师，新的同学啊，也会遇到更好的人呢，也希望自己在接下来的新的旅途中做到更多更好玩还有更重要的是更努力的学习吧！&lt;/p&gt;
&lt;p&gt;好像没啥好写的了。就这样结束吧，感谢你看完我一个人瞎写些的什么东西。&lt;/p&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>写作</category><category>运维</category><category>网络</category></item><item><title>ImgURL图床的安装</title><link>https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/</guid><description>介绍自建图床ImgURL的功能特点、环境要求、Nginx伪静态配置以及宝塔面板下的安装步骤。</description><pubDate>Sat, 27 Apr 2019 12:46:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;上篇文章我们写的是新浪图床失效的解决方案，但是我们的广大博主不甘心在新浪的制约下并且随着新浪的心情而变化使得博客收到影响，特意写此篇文章，来保证广大博主的图片资料安全！&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ImgURL是一款简单、纯粹的图床程序，使用PHP + SQLite 3开发。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid155/68747470733a2f2f692e626d702e6f76682f696d67732f323031382f31322f303663663061633362373632356236622e706e67.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid155/68747470733a2f2f692e626d702e6f76682f696d67732f323031382f31322f663062353635653265306666613136362e706e67.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid155/68747470733a2f2f692e626d702e6f76682f696d67732f323031382f31322f303137633565363662353364623464312e706e67.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;h3 id=&quot;主要功能&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/#%E4%B8%BB%E8%A6%81%E5%8A%9F%E8%83%BD&quot;&gt;主要功能&lt;/a&gt;&lt;/h3&gt;
&lt;ul class=&quot;contains-task-list&quot;&gt;
&lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; checked disabled&gt; 支持拽拖上传、多图上传、Ctrl + V粘贴上传、URL上传&lt;/li&gt;
&lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; checked disabled&gt; 支持图片裁剪，自动生成缩略图&lt;/li&gt;
&lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; checked disabled&gt; 限制访客上传数量&lt;/li&gt;
&lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; checked disabled&gt; 图片压缩/批量压缩&lt;/li&gt;
&lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; checked disabled&gt; 图片鉴黄/批量鉴黄&lt;/li&gt;
&lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; checked disabled&gt; API支持&lt;/li&gt;
&lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; disabled&gt; 在线更新&lt;/li&gt;
&lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; disabled&gt; 外部存储&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;环境要求&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/#%E7%8E%AF%E5%A2%83%E8%A6%81%E6%B1%82&quot;&gt;环境要求&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;PHP &gt;= 5.6&lt;/li&gt;
&lt;li&gt;PDO_SQLite&lt;/li&gt;
&lt;li&gt;GD2&lt;/li&gt;
&lt;li&gt;ImageMagick&lt;/li&gt;
&lt;li&gt;fileinfo&lt;/li&gt;
&lt;li&gt;pathinfo&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;正文&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/#%E6%AD%A3%E6%96%87&quot;&gt;正文&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;废话不多说，直接开搞&lt;/p&gt;
&lt;h3 id=&quot;配置伪静态&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/#%E9%85%8D%E7%BD%AE%E4%BC%AA%E9%9D%99%E6%80%81&quot;&gt;配置伪静态&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Nginx&lt;/strong&gt;&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;location / {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;try_files $uri $uri/ /index.php?$query_string;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;location ~* \.(db3|json)$ {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  deny all;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;location ~* ^/(temp|upload|imgs|data|application|static|system)/.*.(php|php5)$ {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    return 403;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;将上面的规则添加到Nginx server段内，别忘记重载一次Nginx&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Apache&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;默认已经包含**.htaccess**规则，默认无需设置。&lt;/p&gt;
&lt;h3 id=&quot;安装&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/#%E5%AE%89%E8%A3%85&quot;&gt;安装&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;访问：&lt;a href=&quot;https://github.com/helloxz/imgurl/releases&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;https://github.com/helloxz/imgurl/releases&lt;/a&gt; 下载最新版源码，并解压到站点根目录。（注意目录权限、注意目录权限、注意目录权限）&lt;/p&gt;
&lt;p&gt;访问您的域名&lt;code&gt;http(s)://domain.com/install/?setup=1&lt;/code&gt; 根据提示进行安装，如果环境检测不通过，请自行解决环境问题。&lt;/p&gt;
&lt;h3 id=&quot;安装fileinfo--imagemagick&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/#%E5%AE%89%E8%A3%85fileinfo--imagemagick&quot;&gt;安装fileinfo &amp;#x26; imagemagick&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;如果您未安装，就接着往下看&lt;/p&gt;
&lt;p&gt;（演示均使用宝塔面板）&lt;/p&gt;
&lt;p&gt;在宝塔后台 - 软件管理 - 找到您站点对应的PHP版本 - 设置PHP - 安装扩展 - 勾选fileinfo和imagemagick，如下截图。&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid155/snipaste_20190109_185759.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;p&gt;PS：ImageMagick非必须，这个操作需要您的imgURL版本在ImgURL v2.1以上&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;最后&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-imgurl-tu-chuang-de-an-zhuang/#%E6%9C%80%E5%90%8E&quot;&gt;最后&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;祝您使用愉快，嘿嘿，多多分享哦！&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>运维</category><category>PHP</category><category>Nginx</category><category>Markdown</category></item><item><title>新浪图床失效解决方案</title><link>https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/</guid><description>介绍新浪图床因Referer防盗链失效后，通过PHP中转、meta标签等方法绕过验证的几种解决方案。</description><pubDate>Sat, 27 Apr 2019 12:31:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;最近，新浪云对图床做了Referer防盗链验证，导致广大使用新浪当图床的博主的文章内的引用素材失效，无法显示，为此，我们可以经过中转或者伪装等方式来绕过Referer防盗链验证&lt;/p&gt;
&lt;h3 id=&quot;referer防盗链是什么&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#referer%E9%98%B2%E7%9B%97%E9%93%BE%E6%98%AF%E4%BB%80%E4%B9%88&quot;&gt;Referer防盗链是什么&lt;/a&gt;&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;HTTP Referer是Header的一部分，当浏览器向web服务器发送请求的时候，一般会带上Referer，告诉服务器我是从哪个页面链接过来的，服务器藉此可以获得一些信息用于处理。比如从我主页上链接到一个朋友那里，他的服务器就能够从HTTP Referer中统计出每天有多少用户点击我主页上的链接访问他的网站。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;基于Referer我们就可以在服务端知道哪些是“友军”哪些是外链，从而达到过滤和节约服务器资源的目的。&lt;/p&gt;
&lt;p&gt;我们的解决方案就是通过不发送referer的方式来访问，所以就需要伪装或者中转，话不多说，贴解决方案&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;解决方案&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88&quot;&gt;解决方案&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;php文件中转&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#php%E6%96%87%E4%BB%B6%E4%B8%AD%E8%BD%AC&quot;&gt;PHP文件中转&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;php&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;php&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;php&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;#x3C;?&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;php&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;Content-type: image/jpeg&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;echo&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; file_get_contents&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;isset&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($_GET[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$_GET[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;原理：通过传入Url再输出来显示图片&lt;/p&gt;
&lt;p&gt;优缺点：&lt;strong&gt;可以使用统计类组件&lt;/strong&gt;，效率低，需要大批量更换链接&lt;/p&gt;
&lt;p&gt;使用方法：建立一个PHP文件在某个服务器上&lt;/p&gt;
&lt;p&gt;http（s）://你的域名/img.php?url=照片地址&lt;/p&gt;
&lt;p&gt;使用实例：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;php&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;php&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;php&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;img&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://your-domain-name/img.php?url=https://ws3.sinaimg.cn/large/006tNbRwly1fyq4yujgssj30jg0jgmxg.jpg&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; /&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;（已验证可用）&lt;/p&gt;
&lt;h3 id=&quot;使用iframe&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#%E4%BD%BF%E7%94%A8iframe&quot;&gt;使用iframe&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;window.sc&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&amp;#x3C;img src=&apos;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/%E5%9B%BE%E7%89%87%E9%93%BE%E6%8E%A5?%22%3C/span%3E%3Cspan%20style=%22--shiki-light:#D73A49;--shiki-dark:#F97583%22%3E+%3C/span%3E%3Cspan%20style=%22--shiki-light:#24292E;--shiki-dark:#E1E4E8%22%3EMath.%3C/span%3E%3Cspan%20style=%22--shiki-light:#6F42C1;--shiki-dark:#B392F0%22%3Erandom%3C/span%3E%3Cspan%20style=%22--shiki-light:#24292E;--shiki-dark:#E1E4E8%22%3E()%3C/span%3E%3Cspan%20style=%22--shiki-light:#D73A49;--shiki-dark:#F97583%22%3E+%3C/span%3E%3Cspan%20style=%22--shiki-light:#032F62;--shiki-dark:#9ECBFF%22%3E%22&apos;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;iframe&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;imiframe&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;javascript:parent.sc&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;border:none; overflow: hidden;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; scrolling&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;no&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; frameborder&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; onload&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;javascript&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;(&apos;imiframe&apos;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;contentWindow&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;images&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;];&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;iframe&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;原理：通过iframe引用&lt;/p&gt;
&lt;p&gt;优缺点：慢，吧&lt;/p&gt;
&lt;p&gt;（未验证）&lt;/p&gt;
&lt;h3 id=&quot;curl&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#curl&quot;&gt;Curl&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;php&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;php&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;php&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;#x3C;?&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;php&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$url &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; $_GET[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;];  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$dir &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; pathinfo&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($url);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$host &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; $dir[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;dirname&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;];  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$refer &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; $host&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;/&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$ch &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; curl_init&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($url);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;curl_setopt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; ($ch, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;CURLOPT_REFERER&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, $refer);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;curl_setopt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($ch, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;CURLOPT_RETURNTRANSFER&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;//激活可修改页面,Activation can modify the page  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;curl_setopt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($ch, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;CURLOPT_RETURNTRANSFER&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;curl_setopt&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($ch, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;CURLOPT_BINARYTRANSFER&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$data &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; curl_exec&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($ch);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;curl_close&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($ch);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$ext &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; strtolower&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;substr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;strrchr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;($img,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;.&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;));  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$types &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; array&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;            &apos;gif&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;image/gif&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;            &apos;jpeg&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;image/jpeg&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;            &apos;jpg&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;image/jpeg&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;            &apos;jpe&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;image/jpeg&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;            &apos;png&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;image/png&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$type &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; $types[$ext] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; $types[$ext] &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;image/jpeg&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;Content-type: &quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;$type);  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;echo&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; $data;   &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;原理：不发送Referer&lt;/p&gt;
&lt;p&gt;优缺点：&lt;strong&gt;可以使用统计类组件&lt;/strong&gt;，慢，需要大批量更换链接&lt;/p&gt;
&lt;p&gt;使用方法：建立一个PHP文件在某个服务器上&lt;/p&gt;
&lt;p&gt;http（s）://你的域名/img.php?url=照片地址&lt;/p&gt;
&lt;p&gt;使用实例：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;php&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;php&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;php&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;img&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://your-domain-name/img.php?url=https://ws3.sinaimg.cn/large/006tNbRwly1fyq4yujgssj30jg0jgmxg.jpg&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; /&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;（已验证可用）&lt;/p&gt;
&lt;h3 id=&quot;meta-标签&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#meta-%E6%A0%87%E7%AD%BE&quot;&gt;Meta 标签&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;referrer&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;never&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;**原理：**不发送Referer，通过指定 name 值为 referrer 的 meta 标签&lt;/p&gt;
&lt;p&gt;优缺点：统计类组件无法使用，因为统计也是通过这个原理&lt;/p&gt;
&lt;p&gt;（未验证）&lt;/p&gt;
&lt;h3 id=&quot;csp-响应头&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#csp-%E5%93%8D%E5%BA%94%E5%A4%B4&quot;&gt;CSP 响应头&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; http-equiv&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;Content-Security-Policy&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; content&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;referrer&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;**原理：**CSP（Content Security Policy），是一个跟页面内容安全有关的规范。在 HTTP 中通过响应头中的 Content-Security-Policy 字段来告诉浏览器当前页面要使用何种 CSP 策略&lt;/p&gt;
&lt;p&gt;（未验证）&lt;/p&gt;
&lt;h3 id=&quot;a-标签的-referer-属性&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#a-%E6%A0%87%E7%AD%BE%E7%9A%84-referer-%E5%B1%9E%E6%80%A7&quot;&gt;&lt;code&gt;&amp;#x3C;a&gt; &lt;/code&gt;标签的 Referer 属性&lt;/a&gt;&lt;/h3&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;html&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;html&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://www.xsy.fun&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; referrer&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;no-referrer&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;XSY的FUN天地&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;**原理：**在&lt;code&gt;&amp;#x3C;a&gt; &lt;/code&gt;标签内添加no-referrer策略&lt;/p&gt;
&lt;p&gt;优缺点：这种方式作用的只是这一个链接。&lt;/p&gt;
&lt;p&gt;并且，&lt;code&gt;&amp;#x3C;a&gt; &lt;/code&gt;标签可用的 Referrer 策略只有三种：no-referrer、origin 以及 unsafe-url 。&lt;/p&gt;
&lt;p&gt;另外，这样针对单个链接设置的策略优先级比CSP要高。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;emmm&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-04-27-xin-lang-tu-chuang-shi-xiao-jie-jue-fang-an/#emmm&quot;&gt;Emmm&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;最好的办法就是使用自建图床或者使用对象储存&lt;/p&gt;
&lt;p&gt;推荐阿里云的OSS，资费低，速度快，可以使用CDN全球加速（另收费）&lt;/p&gt;
&lt;p&gt;云产品通用红包：&lt;a href=&quot;https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=w7yzqy3r&quot; title=&quot;点我&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;点我&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;另外，&lt;strong&gt;迁移方案&lt;/strong&gt;已经有大佬放出&lt;/p&gt;
&lt;p&gt;参见Github：&lt;a href=&quot;https://github.com/ihewro/PullSinaimgtoTypecho&quot; title=&quot;链接&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;链接&lt;/a&gt;&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>网络安全</category><category>Typecho</category><category>数据迁移</category><category>前端</category></item><item><title>仅需 3 行 代码，让迅雷无视“应版权方要求，无法下载”</title><link>https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/</guid><description>介绍如何通过修改 Windows hosts 文件屏蔽迅雷的部分域名，绕过版权方限制提示的操作步骤。</description><pubDate>Thu, 28 Mar 2019 18:12:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;哇，真的好久没水文章了，最近真的很忙，每天作业什么的。本文测试环境仅限于迅雷极速版，不保证所有客户端均有效。&lt;/p&gt;
&lt;p&gt;如果实在不行，就用迅雷5 吧，不需要修改什么文件，直接用即可，没有版权限制。&lt;/p&gt;
&lt;p&gt;其实实现过程很简单啦，直接修改hosts就好了&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;教程&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/#%E6%95%99%E7%A8%8B&quot;&gt;教程&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;step-1&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/#step-1&quot;&gt;Step 1&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;打开 hosts，具体文件位置：&lt;/p&gt;
&lt;p&gt;&lt;code&gt;C:\Windows\System32\drivers\etc\hosts&lt;/code&gt;&lt;/p&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid132/1.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;h3 id=&quot;step-2&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/#step-2&quot;&gt;Step 2&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;鼠标右键点击 hosts，打开方式选择&lt;code&gt;记事本&lt;/code&gt;打开。&lt;/p&gt;
&lt;h3 id=&quot;step-3&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/#step-3&quot;&gt;Step 3&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;别改里面的东西，直接在最后一排加上以下三行代码，保存即可。&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;127.0.0.1 hub5btmain.sandai.net &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;127.0.0.1 hub5emu.sandai.net &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;127.0.0.1 upgrade.xl9.xunlei.com&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;figure class=&quot;post-figure&quot;&gt;&lt;img src=&quot;https://cdn.xsiy.ltd/photo/pid132/2.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;/figure&gt;
&lt;h3 id=&quot;step-4&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/#step-4&quot;&gt;Step 4&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;刷新 DNS（不要输入下面的直角引号）&lt;/p&gt;
&lt;p&gt;按下快捷键&lt;code&gt;Win + R&lt;/code&gt;打开运行窗口输入「cmd」，点击确定即可打开命令符窗口。&lt;/p&gt;
&lt;p&gt;在命令行窗口输入&lt;code&gt;ipconfig /flushdns&lt;/code&gt;按下回车键，即可刷新本地的DNS缓存数据。&lt;/p&gt;
&lt;h3 id=&quot;ps&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-03-28-jin-xu-3-xing-dai-ma-rang-xun-lei-wu-shi-ying-ban-quan-fang-yao-qiu-wu-fa-xia-zai/#ps&quot;&gt;PS&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;若提示需要管理员权限则把文件拉到桌面再修改保存，拖回去就行了！&lt;/p&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>网络</category><category>网络安全</category><category>运维</category></item><item><title>博客运行一周年啦</title><link>https://blog.xsy.fun/posts/2019-03-25-bo-ke-yun-xing-yi-zhou-nian-la/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-03-25-bo-ke-yun-xing-yi-zhou-nian-la/</guid><description>作者记录个人博客稳定运行满一年的纪念短文，并补发了迟到的周年说明。</description><pubDate>Mon, 25 Mar 2019 17:11:00 GMT</pubDate><content:encoded>&lt;p&gt;恭喜博客稳定运行一周年（昨天忘记发了）&lt;/p&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>博客</category><category>写作</category></item><item><title>卸载阿里云监控及屏蔽云盾IP</title><link>https://blog.xsy.fun/posts/2019-02-07-xie-zai-a-li-yun-jian-kong-ji-ping-bi-yun-dun-ip/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2019-02-07-xie-zai-a-li-yun-jian-kong-ji-ping-bi-yun-dun-ip/</guid><description>介绍如何卸载阿里云盾（安骑士）及其残留文件，并通过 iptables 屏蔽云盾漏洞扫描机 IP。</description><pubDate>Thu, 07 Feb 2019 12:46:00 GMT</pubDate><content:encoded>&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;前言&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-02-07-xie-zai-a-li-yun-jian-kong-ji-ping-bi-yun-dun-ip/#%E5%89%8D%E8%A8%80&quot;&gt;前言&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;我相信大家都发现在阿里云购买的云服务器开机后进程里都会自带AliYunDun、aliyun-service、AliYunDunUpdate程序。&lt;/p&gt;
&lt;p&gt;其实它就是阿里云盾（安骑士），是用来监控云服务器是否安全，可用以起到自动扫描查杀病毒的作用，同时还可以检测服务器是否有违规进程。那么云盾IP又是做什么的？云盾IP是来自阿里云的漏洞扫描机，主要是检测你的服务器是否存在已知漏洞。阿里云盾（安骑士）有好处，也有坏处，好处是一定程度保证你的服务器安全（估计作用不大），坏处时时刻刻监控你的云服务器，你完全没有任何隐私而言，不但对病毒起监控作用，还对你存放的内容进行监控。&lt;/p&gt;
&lt;p&gt;那么把自带的阿里云盾（安骑士）卸载了吧！方法很简单，执行下面三段命令即可。&lt;/p&gt;
&lt;/section&gt;&lt;section class=&quot;post-section&quot;&gt;&lt;h2 id=&quot;命令&quot;&gt;&lt;a class=&quot;heading-anchor&quot; href=&quot;https://blog.xsy.fun/posts/2019-02-07-xie-zai-a-li-yun-jian-kong-ji-ping-bi-yun-dun-ip/#%E5%91%BD%E4%BB%A4&quot;&gt;命令&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;卸载安骑士&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;wget http://update.aegis.aliyun.com/download/uninstall.sh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;chmod +x uninstall.sh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;./uninstall.sh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;wget http://update.aegis.aliyun.com/download/quartz_uninstall.sh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;chmod +x quartz_uninstall.sh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;./quartz_uninstall.sh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;删除残留：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;pkill aliyun-service&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;rm -fr /etc/init.d/agentwatch /usr/sbin/aliyun-service&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;rm -rf /usr/local/aegis*&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;p&gt;屏蔽云盾IP：&lt;/p&gt;
&lt;figure class=&quot;code-block&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;code-block__bar&quot;&gt;&lt;span class=&quot;code-block__lang&quot;&gt;text&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.201.0/28 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.201.16/29 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.201.32/28 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.225.192/29 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.225.200/30 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.225.184/29 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.225.183/32 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.225.206/32 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.225.205/32 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.225.195/32 -j DROP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;iptables -I INPUT -s 140.205.225.204/32 -j DROP&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;&lt;/section&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>运维</category><category>linux</category><category>网络安全</category><category>iptables</category></item><item><title>中考</title><link>https://blog.xsy.fun/posts/2018-12-21-zhong-kao/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2018-12-21-zhong-kao/</guid><description>博主因临近中考，暂时无暇处理博客中的诸多问题，向读者致歉。</description><pubDate>Fri, 21 Dec 2018 18:34:00 GMT</pubDate><content:encoded>&lt;p&gt;博主马上中考啦，所以博客很多问题没有处理，见谅。&lt;/p&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>写作</category><category>博客</category></item><item><title>纯净版手机WPS</title><link>https://blog.xsy.fun/posts/2018-11-11-chun-jing-ban-shou-ji-wps/</link><guid isPermaLink="true">https://blog.xsy.fun/posts/2018-11-11-chun-jing-ban-shou-ji-wps/</guid><description>分享从手机预装系统中提取的纯净无广告版WPS安装包，并提醒需先卸载原版再安装。</description><pubDate>Sun, 11 Nov 2018 14:17:00 GMT</pubDate><content:encoded>&lt;p&gt;我从某火腿肠手机上提取了HTC定制版本的WPS，纯净无广告，记得要卸载原来的再安装哦！&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://cdn.xsiy.ltd/share/hTC%E9%A2%84%E8%A3%85%E7%89%88WPS.apk&quot; rel=&quot;noopener noreferrer nofollow&quot; target=&quot;_blank&quot;&gt;https://cdn.xsiy.ltd/share/hTC预装版WPS.apk&lt;/a&gt;&lt;/p&gt;</content:encoded><dc:creator>Linus Xiong</dc:creator><category>兼容性</category><category>运维</category></item></channel></rss>