mirror of
https://codeberg.org/mayx/pages
synced 2026-01-01 19:03:53 +08:00
update
This commit is contained in:
364
2022/01/04/banned.html
Normal file
364
2022/01/04/banned.html
Normal file
@@ -0,0 +1,364 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>Github封禁了我的博客?! | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="Github封禁了我的博客?!" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="人在世上,无处可逃……" />
|
||||
<meta property="og:description" content="人在世上,无处可逃……" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-01-04T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="Github封禁了我的博客?!" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-01-04T00:00:00+08:00","datePublished":"2022-01-04T00:00:00+08:00","description":"人在世上,无处可逃……","headline":"Github封禁了我的博客?!","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/01/04/banned.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/01/04/banned.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/01/04/banned.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-01-04T00:00:00+08:00">4 January 2022</time> - 字数统计:2768 - 阅读大约需要9分钟 - Hits: <span id="/2022/01/04/banned.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">Github封禁了我的博客?!</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Tue, 04 Jan 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者在2021年12月被Github突然封禁博客仓库的经历,因为违反了他们的ToS。作者在没有事先通知的情况下被禁用,感到失望和不满,因为正常情况下至少会有违规通知。经过与Github的沟通,发现问题出在三年前的一个利用Git.io服务的脚本,被误用为恶意网站跳转。这次事件导致作者的博客星标、Fork和评论丢失,对Github的信任度大幅下降。尽管如此,作者仍考虑继续使用Github存储项目数据,但会采取措施防止单点故障,并减少对Github域名的依赖。同时,作者对帮助他备份文章的yzqzss和@saveweb项目表示感谢。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#封禁的原因">封禁的原因</a></li><li><a href="#造成的损失">造成的损失</a></li><li><a href="#以后的计划与反思">以后的计划与反思</a></li><li><a href="#特别感谢">特别感谢</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>人在世上,无处可逃……<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>在2021年12月28日,Github封禁了我的博客…… </p><p>
|
||||
就在我以很难过的心情写完<a href="/2021/12/27/summary.html">去年最后一篇文章</a>的后一天,Github发邮件告诉我,我的博客仓库因为违反Github的ToS被禁用了:</p>
|
||||
<blockquote>
|
||||
<p>Access to the Mabbs/mabbs.github.io repository has been disabled by GitHub staff due to a terms of service violation. You may contact us for more information or to request a review of this decision:</p>
|
||||
|
||||
<p><a href="https://support.github.com/contact?subject=TOS+Review%3A+Mabbs%2Fmabbs.github.io&tags=tos-vru">https://support.github.com/contact?subject=TOS+Review%3A+Mabbs%2Fmabbs.github.io&tags=tos-vru</a></p>
|
||||
|
||||
<p>You may review our terms of service here:</p>
|
||||
|
||||
<p><a href="https://docs.github.com/articles/github-terms-of-service">https://docs.github.com/articles/github-terms-of-service</a></p>
|
||||
</blockquote>
|
||||
|
||||
<p>Github在没有<strong>任何通知</strong>的情况下禁用了我的博客仓库,仅仅告诉我有违反ToS,也没有说是具体哪里违反了,这让我十分悲伤。虽然吧我现在倒也基本上感受不到悲伤还是难过的心情,但总而言之我对Github很失望,正常来说即使是违反DMCA的仓库至少也会先提前通知,然后72个小时之后才会删除,结果我这个倒是啥通知也没有,直接Disabled,我真的是无言以对。</p>
|
||||
<h1 id="封禁的原因">
|
||||
|
||||
|
||||
<a href="#封禁的原因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 封禁的原因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>在发现问题后我就给Github开了一个Ticket,询问到底是什么原因,也许是圣诞节的原因吧,Github没有给出回应,直到今天,可能他们才开始上班,然后才来给我解决问题。他们回复的原文如下:</p>
|
||||
<blockquote>
|
||||
<p>Hi Mayx, </p><p>
|
||||
Thanks for reaching out. Your repository was actioned following reports that its activity may have been in violation of the following prohibition found in our <a href="https://docs.github.com/en/github/site-policy/github-acceptable-use-policies">Acceptable Use Policies</a>:</p>
|
||||
<blockquote>
|
||||
<p>Under no circumstances will Users upload, post, host, execute, or transmit any Content that:</p>
|
||||
|
||||
<p>directly supports unlawful active attack or malware campaigns that are causing technical harms — such as using our platform to deliver malicious executables or as attack infrastructure, for example by organizing denial of service attacks or managing command and control servers — with no implicit or explicit dual-use purpose prior to the abuse occurring</p>
|
||||
</blockquote>
|
||||
|
||||
<p>Because of the nature and volume of the prohibited activity, we will not be reinstating your account. </p><p>
|
||||
Regards, </p><p>
|
||||
GitHub Trust & Safety</p>
|
||||
</blockquote>
|
||||
|
||||
<p>好家伙,直接说明我的仓库因为其破坏力之高,没有恢复的机会,而且还说我的博客正在用于作为攻击其他网站的手段,具体可以参见<a href="https://docs.github.com/en/github/site-policy/github-community-guidelines#active-malware-or-exploits">这里</a>,这个意思……难不成是我<a href="/2021/05/15/vulnerability.html">发现的Windows漏洞</a>?我寻思Github这个协议里面有说允许讨论漏洞啊,不然Github里面一堆的exploit早就死光了。不过我想了想之前被禁用的仓库占着位置我也没办法重新开博客,就先问了一下能不能先把我之前的仓库删掉,Github倒是同意了。</p>
|
||||
<blockquote>
|
||||
<p>The repository can be deleted if you confirm you would wish this.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>不过如果我直接把博客的原始档案放上去,那怕是就直接封禁账户而不是仓库了,所以继续问到底是哪个文件违反了?最后Github才像个人一样告诉了我原因:</p>
|
||||
<blockquote>
|
||||
<p>The repository has been deleted per your request. </p><p>
|
||||
Kindly note further instances that hosts a script that leverages git.io URL shortener to redirect to a malicious site may lead to further action, such as permanent suspension.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>🌿,原来是我3年前写的<a href="/2019/03/23/gitio.html">让Git.io无限制</a>所提供的服务被人利用做坏事了,麻了,这Github是真的不长嘴吗?提前说一声我又不是不会删,而且我的服务被利用,上来就先干我是吧?这和某政府对付ICP有什么区别。</p>
|
||||
<h1 id="造成的损失">
|
||||
|
||||
|
||||
<a href="#造成的损失"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 造成的损失
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<ol>
|
||||
<li>我的博客所有Star、Fork和评论全部消失</li>
|
||||
<li>我对Github的信任大幅降低</li>
|
||||
<li>我得考虑换域名了,SEO相当于无了</li>
|
||||
</ol>
|
||||
<h1 id="以后的计划与反思">
|
||||
|
||||
|
||||
<a href="#以后的计划与反思"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 以后的计划与反思
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>原来我是相当信任Github的,原因之一应该是<a href="/2019/11/18/archive.html">GitHub Archive Program</a>,我才决定一直待在Github写博客,另外Github也确实是一个很好的社区平台,在这里可以遇到更多的项目,还有Github的功能确实很全,具体的在之前<a href="/2021/10/23/microsoft.html#github">评价微软产品</a>中也有说过,所以我基本上对Github这个平台非常信任。不过现在嘛,既然它会做出完全不考虑用户感受,没有通知直接删我仓库这种情况,说明Github自信了,不在意我这个普通的用户。既然如此,那我也没有什么可以说明的了。不过考虑到我有些项目还在Github上面,而且之前我因为这个信任,绝大多数地方留的链接都是 <a href="https://mabbs.github.io">https://mabbs.github.io</a> ,所以我还是打算继续用Github。 </p><p>
|
||||
不过这并不表示这就结束了,既然Github已经不再是可信任的平台,那我就只能想其他办法了,不过为了方便更新,数据我还是打算放在Github上,但是我会开始用起来之前调查的<a href="/2021/08/15/blog.html">博客平台</a>,并且以最大可能性来避免单点故障的问题(比如每次更新把代码同步到Gitlab上,然后再往CloudFlare上面部署一份)。还有就是以后我留下博客地址的时候,也不会再优先考虑Github的域名了,原来我整的<a href="/proxylist.html">反代列表</a>本来是为了避免被PRC的防火长城Ban的,看来现在又要多一个要注意的地方了。</p>
|
||||
<h1 id="特别感谢">
|
||||
|
||||
|
||||
<a href="#特别感谢"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 特别感谢
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>在此事件中,特别感谢<a href="https://github.com/yzqzss">yzqzss</a>和<a href="https://github.com/saveweb">@saveweb</a>项目,虽然我自己也有做备份,不过不是实时的(信任的原因)。正是因为他们的帮助,我的文章没有任何丢失,另外我觉得他们的项目挺不错的,能在一定程度上保留大家写的文章,不因为像我遇到的这种破事而让作者的努力消失,还是挺不错的。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Github"><em>Github</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%B0%81%E7%A6%81"><em>封禁</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8D%9A%E5%AE%A2"><em>博客</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-01-04-banned.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/01/04/banned.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2021/12/27/summary.html">
|
||||
上一篇:年终总结
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/01/16/wssocks.html">
|
||||
下一篇:wssocks的简单评测
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/01/04/banned', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/01/04/banned.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
357
2022/01/16/wssocks.html
Normal file
357
2022/01/16/wssocks.html
Normal file
@@ -0,0 +1,357 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>wssocks的简单评测 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="wssocks的简单评测" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="一堆花里胡哨的梯子会不会是障眼法?" />
|
||||
<meta property="og:description" content="一堆花里胡哨的梯子会不会是障眼法?" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-01-16T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="wssocks的简单评测" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-01-16T00:00:00+08:00","datePublished":"2022-01-16T00:00:00+08:00","description":"一堆花里胡哨的梯子会不会是障眼法?","headline":"wssocks的简单评测","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/01/16/wssocks.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/01/16/wssocks.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/01/16/wssocks.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-01-16T00:00:00+08:00">16 January 2022</time> - 字数统计:3149 - 阅读大约需要10分钟 - Hits: <span id="/2022/01/16/wssocks.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">wssocks的简单评测</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Sun, 16 Jan 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章主要评测了一个名为wssocks的代理软件,作者对比了它与SSH隧道和v2ray等工具。 wssocks的特点包括支持TLS+Websocket+socks5、配置简单、参数较少。作者发现使用wssocks配合Cloudflare时速度慢并有丢包问题,推测可能是因为Cloudflare的检测策略。尽管wssocks在性能上有待提升,但作者质疑某些代理软件通过设计复杂的原创协议可能有提高制作成本并增加IP被Ban的风险。对于一般用户而言,作者认为专业的机场服务提供了更高级别的线路和更低的边际成本,适合大规模平摊成本。作者也提到了技术问题外,连接国际网络还需警惕社交工程攻击。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#使用评测">使用评测</a><ul><li><a href="#配置">配置</a></li><li><a href="#效果">效果</a></li></ul></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>一堆花里胡哨的梯子会不会是障眼法?<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>最近我手头能用的梯子真的是越来越少了,除了防火墙越来越高的原因之外,也可能和大家对专业机场的信任导致免费的梯子越来越少了 <del>(毕竟我在网络上只用免费的东西lol)</del> 。所以我想着应该用手头的资源赶紧整点梯子用,不然以后可能就真连不上国际互联网了。 </p><p>
|
||||
对于怎么搭梯子,我以前也有很多经验,像我之前也发过<a href="/2021/05/07/ssh.html">网络任意互联指南</a>以及<a href="/2019/04/27/antiban.html">不依赖代理连被Ban网站的方法</a>之类的文章,不过在我实际运用的时候还是会发现有些问题,比如之前我用SSH隧道,确实很好用,手机上也能找到可以连接的软件,要说问题确实也没啥问题,只是感觉速度不太行?其实我个人觉得SSH隧道挺好用的,不过我目前手头没有合适的直连的主机,所以不太方便用。 </p><p>
|
||||
其实我也是想多做一些测试,想多试试看怎么样可以避免被防火墙检测,另外就是我一般都是做IP已经被Ban的假设(主要是不太希望IP暴露,可以参考<a href="/2021/04/18/hide.html">这篇</a>文章),所以会想着用比如说Cloudflare的办法。所以会考虑这个代理软件应该支持TLS+Websocket。目前我看比较主流支持这个方案的基本上就是<a href="https://github.com/v2fly/v2ray-core">v2ray</a>或者是<a href="https://github.com/p4gefau1t/trojan-go">Trojan-Go</a>之类的……不过我想如果说我直接用TLS+Websocket+socks5那不是啥问题都解决了嘛,毕竟目前来说无论啥隧道,都不如TLS稳当。一开始我想着是自己用Python写一个(其实Python也有人写,我后来搜了一下有个叫<a href="https://github.com/abersheeran/websocks">websocks</a>的项目和我的想法有点像),不过考虑到还是别重复造轮子了就上网搜了一下,结果还真有人用Go写了一个,就是今天要讲的<a href="https://github.com/genshen/wssocks">wssocks</a>。 </p><p>
|
||||
其实相似的项目好像还挺多,后来我又搜了搜,还有比如<a href="https://github.com/erebe/wstunnel">wstunnel</a>(这个看起来用的是啥Haskell语言,我都没听说过)和<a href="https://github.com/Mikubill/wsSocks">wsSocks</a>也都是类似的项目,看来大家的想法都差不多,另外wssocks貌似还不是专门穿透防火长城用的,看介绍好像是他用来穿透他们学校USTB的防火墙用的。</p>
|
||||
<h1 id="使用评测">
|
||||
|
||||
|
||||
<a href="#使用评测"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用评测
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<h2 id="配置">
|
||||
|
||||
|
||||
<a href="#配置"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 配置
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>其实这个软件主要吸引我的除了很符合我想要的TLS+Websocket+socks5之外,主要是配置简单,参数少,看起来舒服,现在那些乱七八糟的代理软件搞一大堆乱七八糟的功能,看半天不知道哪个是干啥的,还有就是那个什么原创协议,比如vmess,我是真搞不明白那原创协议到底有啥用,配置也复杂,整那么复杂也不过是增加了容易被检测的特征。而且最主要的是无论啥协议,最终到客户端不还得用Socks5或者是http代理,不如一开始就整Socks5多方便。 </p><p>
|
||||
wssocks的使用非常简单,服务端的话我用的是以下命令:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./wssocks-linux-amd64 server --addr :10000 --auth --auth_key <YOUR_CONNECTION_KEY> --ws_base_path <YOUR_BASE_PATH>
|
||||
</code></pre></div></div>
|
||||
<p>另外在服务器上为了安全起见,最好不要用root权限启动(毕竟是冷门的项目有可能会有未知的漏洞),所以我实际会用以下命令:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>chroot --userspec=99:99 / /wssocks-linux-amd64 server --addr :10000 --auth --auth_key <YOUR_CONNECTION_KEY> --ws_base_path <YOUR_BASE_PATH>
|
||||
</code></pre></div></div>
|
||||
<p>为了方便使用Cloudflare(其实主要是我这服务器还有别的网站),所以配置了一下Nginx(参见<a href="https://github.com/genshen/wssocks/issues/11#issuecomment-669324542">wssocks#11</a>):</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>server {
|
||||
listen 0.0.0.0:443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
server_name proxy.example.com;
|
||||
ssl_certificate /etc/nginx/ssl/server.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/server.key;
|
||||
|
||||
location / {
|
||||
client_max_body_size 1024m;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_http_version 1.1; # wssocks v0.5.0 require HTTP 1.1 at least
|
||||
proxy_pass http://127.0.0.1:10000;
|
||||
}
|
||||
}
|
||||
</code></pre></div></div>
|
||||
<p>设置好Cloudflare解析之后客户端用以下命令连接:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wssocks-windows-amd64.exe client --addr :10808 --remote wss://proxy.example.com/<YOUR_BASE_PATH>/ --key <YOUR_CONNECTION_KEY>
|
||||
</code></pre></div></div>
|
||||
<p>然后就可以用Socks5客户端连接代理并上网了,配置真的是很简单,也不用那些不太靠谱的一键脚本。另外它也支持HTTP代理,这样就算没有Socks5客户端也可以用系统代理,倒是挺方便的。不过我因为用的Proxifier所以不用HTTP代理,另外我也非常不推荐大家用系统代理,因为有的时候有些网站会利用WebRTC协议绕过系统代理,获得用户的真实IP,当然如果说用梯子单纯只是想上个外网那当我没说,毕竟那种人就是直接开着PAC,就没打算隐藏自己的IP。</p>
|
||||
<h2 id="效果">
|
||||
|
||||
|
||||
<a href="#效果"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 效果
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>我设置了Cloudflare解析之后试着连接了一下,连确实能连上,网页也勉强能打得开,但就是速度极其的慢,可能还不到1Mbps的样子,而且时不时会丢包。我寻思这个方案按理来说应该是不可能被检测啊,难不成Cloudflare一检测到长连接就会被干吗?我实在是搞不清,另外我也试了试不通过Cloudflare,直接走公网IP的效果,这个倒是还行,和v2ray的速度差不多,看来还是线路的问题。 </p><p>
|
||||
不过我后来又换了一些网络,以及在不同时间又测试了一下,其实可能只是某些运营商针对Cloudflare,我换了网络之后速度还不错,另外也可以试试<a href="https://github.com/XIU2/CloudflareSpeedTest">CloudflareSpeedTest</a>选择更快的节点。 </p><p>
|
||||
另外其实v2ray可能也有一些优势,我后来在同一台服务器上测了v2ray tcp vmess的效果和wssocks比较,v2ray速度好像更快些。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>我用wssocks其实也只是想验证我的一些想法,像HTTPS和SSH都是非常常见的协议,防火长城不可能在包着一层加密的情况下猜里面走的到底是不是正常的流量,我觉得这种事情不难想象吧,但是目前用来反检测的代理软件我也不知道他们想干嘛,就喜欢整一堆原创协议,不知道是想证明什么,而且配置也很复杂,一堆乱七八糟的配置一般人能用到哪些?所以我才怀疑会不会是有人刻意通过设计这堆莫名其妙的东西提高制作代理的成本,而且偷偷整点特征就是为了多Ban一些IP?这个我是真的不太能理解…… </p><p>
|
||||
当然也不是说那些代理软件毫无意义,这个wssocks性能上还是有点问题,我打算回头有时间再试试Trojan-Go。 </p><p>
|
||||
不过在这次实验看来,用什么协议还是什么软件其实不怎么重要,这些乱七八糟的软件也就是我们这些自己租的国外主机拿来玩玩,真正的机场还是专业,都是各种各样的神奇线路,像CN2 GIA都是过时的东西,现在都流行的是什么IPLC,直接就整一个物理上的私有线路,那种高级东西我们这种人确实整不来,而且自己一个人用也太贵了,机场都是通过租给一堆人用来平摊成本的,毕竟这种就是边际成本很低的东西,也只有机场能搞。 </p><p>
|
||||
看来,在连接国际网络的路上,除了技术问题,还要警惕可能存在的社工专家。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=wssocks"><em>wssocks</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E4%BB%A3%E7%90%86"><em>代理</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E8%AF%84%E6%B5%8B"><em>评测</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-01-16-wssocks.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/01/16/wssocks.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/01/04/banned.html">
|
||||
上一篇:Github封禁了我的博客?!
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/02/14/move.html">
|
||||
下一篇:Mayx的博客分发方案
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/01/16/wssocks', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/01/16/wssocks.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
340
2022/02/14/move.html
Normal file
340
2022/02/14/move.html
Normal file
@@ -0,0 +1,340 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>Mayx的博客分发方案 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="Mayx的博客分发方案" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="无论什么资料,都有保存的价值!" />
|
||||
<meta property="og:description" content="无论什么资料,都有保存的价值!" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-02-14T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="Mayx的博客分发方案" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-02-14T00:00:00+08:00","datePublished":"2022-02-14T00:00:00+08:00","description":"无论什么资料,都有保存的价值!","headline":"Mayx的博客分发方案","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/02/14/move.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/02/14/move.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/02/14/move.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-02-14T00:00:00+08:00">14 February 2022</time> - 字数统计:2342 - 阅读大约需要7分钟 - Hits: <span id="/2022/02/14/move.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">Mayx的博客分发方案</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Mon, 14 Feb 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者因为Github封禁博客而失去信任,决定建立博客分发和备份方案的过程。作者选择Gitlab作为源代码托管平台,因为它支持自动推送和拉取,且没有被墙,Web IDE体验良好且有中文界面。部署方面,作者在多个平台如Cloudflare Pages和Vercel上设置部署,并提供了全站下载选项。作者还计划实现博客的自动化发布和分布式备份,以提高博客的长期存续性和匿名性。最后,作者提到会更换Github Pages的默认域名以解决部分地区访问问题,并考虑更换评论系统。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#方案">方案</a><ul><li><a href="#源代码托管平台的选择">源代码托管平台的选择</a></li><li><a href="#部署平台的选择">部署平台的选择</a></li></ul></li><li><a href="#未来的方案">未来的方案</a></li><li><a href="#补充">补充</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>无论什么资料,都有保存的价值!<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>在今年年初,<a href="/2022/01/04/banned.html">Github封禁了我的博客</a>,因此我也对Github失去了信任。之前因为信任的关系,我几乎不会在其他地方备份我的博客,发生了这种事情之后我才明白这并不可靠,虽然我有时候会把我的博客整站隔段时间手动下载下来,但是这样实时性不高。其实我也不是不会做自动化方案,只是因为懒,就像这篇文章一样,分发我在上个月就已经完成了,现在才在这里写文章……</p>
|
||||
<h1 id="方案">
|
||||
|
||||
|
||||
<a href="#方案"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 方案
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>去年我在<a href="/2021/08/15/blog.html">研究博客平台的时候</a>已经调查过很多放静态站的平台了,所以这次进行分发的时候有了之前的经验,也简单了不少。</p>
|
||||
<h2 id="源代码托管平台的选择">
|
||||
|
||||
|
||||
<a href="#源代码托管平台的选择"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 源代码托管平台的选择
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>因为Github不可信,于是我自然想到了用Gitlab来存放博客源代码。虽然吧Gitlab曾经也发生过用户数据丢失的问题,不过反正目标也是同时放在Github和Gitlab上,总不至于两个一起炸吧。其实最开始我的计划是用Github Actions进行同步,不过在我进行调查之后我发现Gitlab功能还是挺强大的,它支持对一个Git仓库进行自动的推送和拉取,也不需要做过多的配置,就只需要配置个地址和令牌就可以,还是挺方便的。 </p><p>
|
||||
在我做完Github与Gitlab双向同步之后,我发现Gitlab还挺好用的,首先,Gitlab有个很棒的地方就是没被墙,我有时候写文章的时候不挂梯子用Github真的是非常难受,目前依我所感受,防火长城会对Github先进行一下TCP RST,然后刷新一下让你连上,连上之后如果长连接断开或者大概5分钟的样子就再阻断,然后再RST一波,非常的挑战心态。有时候我写了半天然后点预览结果就阻断,等半天还是连不上,还要挂梯子,能预览的时候就得赶紧提交,万一提交的时候再阻断要是没备份就炸了。像Gitlab我就从来没遇到过类似的情况,这一点还是很不错的,大概是因为Gitlab不是社区,而且滥用的人也少,所以政府也不太关心吧。 </p><p>
|
||||
另外就是Web IDE,相比Github的VSCode Web IDE,Gitlab的要轻量很多了,也不容易发生卡的情况,而且其实Github的VSCode Web IDE也装不了几个插件,功能上也没强到哪去。 </p><p>
|
||||
还有就是翻译,明明用Github的中国人/华人挺多的,官方就是不出中文界面,明明文档都有中文了……Gitlab可能是因为作为一个开源产品,i18n做的很好,虽然吧英文也不影响我使用,但是毕竟作为用户体验的一项,Gitlab做的确实更好。 </p><p>
|
||||
不过其实我觉得Gitlab也许只是表面没那么出名,毕竟不是做社区的,大多数公司都用的是自建Gitlab托管代码,而且很多时候Github其实是在抄Gitlab的(虽然最早是Gitlab抄Github),比如Actions抄CI/CD,还有最近又出的一堆什么代码扫描和检查,Gitlab出现的都更早。不过这说着也跑题了这个文章又不是为了专门夸Gitlab的😂。</p>
|
||||
<h2 id="部署平台的选择">
|
||||
|
||||
|
||||
<a href="#部署平台的选择"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 部署平台的选择
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>源代码平台整完之后就是部署平台了,除了Github和Gitlab上自己的Pages上各部署了一份,另外我也在Cloudflare Pages和Vercel上面也设置了部署,以后我也可能增加更多的部署和备份平台,具体目前可以参考<a href="/proxylist.html">代理列表</a>。 </p><p>
|
||||
在部署的时候目前我也增加了一些新的东西,比如下载全站的按钮,原来我是想把源代码和生成后的代码合到一起下载,不过没想到Cloudflare Pages竟然不能上传超过25MiB的文件,所以没办法,我只好光放下载全站的按钮。不过我也有做判断,如果是Github生成的代码,会放Github的下载链接,因为Github Pages生成没办法使用脚本,也没法打包全站代码,其他部署因为支持的多所以我就写了一个脚本来进行打包,一是方便在Wayback Machine保存我的全站代码,二是希望能通过这种方式让有兴趣的人帮助我来备份我的博客。 </p><p>
|
||||
另外为什么是生成后的代码呢?因为如果用源代码要考虑很多依赖的项目会不会炸,比如Ruby、Jekyll、还有各种插件和模板,如果未来的某个时候它们其中有一个炸了,那么感兴趣的人就没办法再构建我的博客了。 </p><p>
|
||||
在此之后也算是激发了我对博客代码修改的灵感,比如我改了下博客分页器,现在就没那么凌乱,使用select标签就更加简洁了。</p>
|
||||
<h1 id="未来的方案">
|
||||
|
||||
|
||||
<a href="#未来的方案"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 未来的方案
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>之后我会想办法在Blogger之类的平台整个自动化发布脚本,还有就是上链啥的,不过上ETH这种公链的成本实在是太高了,我要是想把我的博客全部上传到公链上估计得要上百万CNY了吧……而且也没法编辑,回头看看能不能整个分布式社区,让大家的独立博客互相备份。另外这也是我之后想做的计划的一部分,我想整一个开放的匿名解决方案,比如整一个“OpenAnonymous”的项目,分布式在一定程度上能大幅提高追踪成本,其实在社会中就像谣言一样,为什么说“造谣一张嘴,辟谣跑断腿”?其实也是因为分布式的特性,对于已经散播的信息很难溯源,也很难制止。 </p><p>
|
||||
总之希望作为Mayx Forever Project的载体——Mayx的博客能在我有生之年想出合理的方案,存在1000年吧!</p>
|
||||
<h1 id="补充">
|
||||
|
||||
|
||||
<a href="#补充"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 补充
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>刚才在Gitlab上发布了文章之后我不知道Github Pages这里又犯什么神经病,没有给我构建,所以我又想到了些东西在这里补充一下: </p><p>
|
||||
Github Pages还有个地方让我比较难受,那就是Github Pages的默认域名在有些运营商会被屏蔽,我不知道是DNS的问题还是啥,总之这样我有时候发文章之后其他人就看不到了,所以现在我以后常用的域名也打算改了,我目前决定使用 <a href="https://mayx.eu.org">https://mayx.eu.org</a> ,好听也好记。 </p><p>
|
||||
另外还有个比较难受的地方就是我的博客目前用的评论系统是Gitalk,这个是依赖Github的,之前评论全炸这个我也是非常难受,我之后再想想办法改一下评论系统吧。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Mayx"><em>Mayx</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=Github"><em>Github</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=Gitlab"><em>Gitlab</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%88%86%E5%8F%91"><em>分发</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-02-14-move.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/02/14/move.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/01/16/wssocks.html">
|
||||
上一篇:wssocks的简单评测
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/02/15/termux.html">
|
||||
下一篇:在平板上使用Termux的经历
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/02/14/move', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/02/14/move.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
331
2022/02/15/termux.html
Normal file
331
2022/02/15/termux.html
Normal file
@@ -0,0 +1,331 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>在平板上使用Termux的经历 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="在平板上使用Termux的经历" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="更好的利用闲置的设备吧!" />
|
||||
<meta property="og:description" content="更好的利用闲置的设备吧!" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-02-15T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="在平板上使用Termux的经历" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-02-15T00:00:00+08:00","datePublished":"2022-02-15T00:00:00+08:00","description":"更好的利用闲置的设备吧!","headline":"在平板上使用Termux的经历","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/02/15/termux.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/02/15/termux.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/02/15/termux.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-02-15T00:00:00+08:00">15 February 2022</time> - 字数统计:2076 - 阅读大约需要7分钟 - Hits: <span id="/2022/02/15/termux.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">在平板上使用Termux的经历</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Tue, 15 Feb 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章描述了作者在平板电脑上使用Termux的实验经历。起初出于专业需求,作者想要验证Android平板能否作为Linux环境的替代品,特别关注了远程桌面和SSH解决方案。经过一年的测试,发现Termux是一个可行的方案,可以安装各种Linux软件如Python、Django等。然而,由于硬件限制(如老旧的处理器、屏幕常关导致程序无法运行)、软件兼容性问题(尤其是在国内使用时)以及版本更新带来的问题(如源问题和官网下载限制),作者在使用过程中遇到不少挑战。为改善体验,作者做了额外的配置,如创建额外的键位和安装Linux发行版。总的来说,作者认为Termux是利用闲置Android设备的有效方式,使得旧设备的使用价值得到提升。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#方案">方案</a></li><li><a href="#对旧设备的兼容性调整">对旧设备的兼容性调整</a></li><li><a href="#增强性改动">增强性改动</a></li><li><a href="#总结">总结</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>更好的利用闲置的设备吧!<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>在去年,我的同学买了一块Android的平板电脑,因为我的专业主要需要使用Linux系统,平时学习也需要用到电脑,所以也是想做一个实验想验证一下Android系统的平板能不能在一定程度上替代电脑。虽然笔记本电脑不算很重,但是如果说平板就能替代笔记本电脑,那么使用的时候也会更加方便吧,而且平板的续航一般也比笔记本电脑好,我觉得如果实验能成功,其实做一个这样的方案也不错。 </p><p>
|
||||
我手头也正好有些闲置的平板,不过去年因为在Alpha实验阶段,所以我平时上课还是用的电脑。最终对同学进行经过一年左右的测试,我感觉这个方案是个不错的选择,而且随着ARM服务器的盛行,也不需要担心软件包因为架构的原因不能用的问题。</p>
|
||||
<h1 id="方案">
|
||||
|
||||
|
||||
<a href="#方案"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 方案
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>最开始我是想着绝大多数情况下使用远程桌面应该是个不错的选择,平板作为瘦客户机是个非常好的选择,不过在实际的实验中发现,使用这种方式对网络的要求很高,就像我之前<a href="/2021/09/28/cloudgame.html">玩云游戏</a>那样,很多时候很考验心态,动不动就会卡,包括使用SSH的方案也差不多,虽然SSH可能对网络的要求更小一点,但是问题在于SSH连接的假如是内网服务器,需要看一些Web项目的效果会很麻烦。所以在最终我选定了Termux来作为实际实验的方案。 </p><p>
|
||||
最终体验效果还是挺不错的,平时使用各种需要的东西基本上都不受限制,比如Python、Django、Jupyter、Ansible之类的,只要是电脑上Linux能装的软件,Termux都可以装,而且运行效果也还不错,这也多亏了那些ARM服务器和树莓派对ARM的大力支持。不过有时候一些定制化的系统导致的一些限制也比较烦,国内的定制系统很多对后台程序限制很严格,而且一般屏幕一关掉程序就没法执行了,导致某些情况下体验不是很好,不过还好绝大多数情况这些限制都是可以调整的,用的话还是可以用的。 </p><p>
|
||||
接下来我打算把实验推到Beta阶段,在这个阶段我打算用上我闲置的平板,验证各种情况下使用平板来进行各种操作。</p>
|
||||
<h1 id="对旧设备的兼容性调整">
|
||||
|
||||
|
||||
<a href="#对旧设备的兼容性调整"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 对旧设备的兼容性调整
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>我同学使用的是新买的平板电脑,Android的版本也比较高,另外处理器也是ARM架构的,但是我的平板不是新的,闲置的平板Android版本也比较低,处理器还是个X86架构的,这导致我在一些操作中和同学的操作不一样。 </p><p>
|
||||
从Termux v0.73开始,它的Android兼容性要求变成了Android 7.0+,可是我的平板是Android 5.0的,所以我只好下载Termux v0.72用。不过这个这个版本用的时候问题好像还挺多的,最开始我为了下载包快一些换了源,但是不知道为什么用国内镜像源怎么都会出错,下载的包会直接没法运行,后来没办法就只能用官方源。不过官方源也会出点问题,在<code class="language-plaintext highlighter-rouge">/etc/apt/source.list.d/</code>中有一些已经炸掉的源,在执行<code class="language-plaintext highlighter-rouge">apt update</code>之前要把这里面所有的文件都删掉,另外删掉之后执行<code class="language-plaintext highlighter-rouge">apt upgrade</code>之后那个文件夹里面的文件又会出现,所以还得再删一次。 </p><p>
|
||||
(2022.06.05更新)由于官网termux.net已经彻底炸了,以后Android 7.0以下安装不能再安装这个需要在线下载bootstrap的版本了,可以去Archive.org上下载<a href="https://archive.org/details/termux-repositories-legacy">其他人上传的离线版</a> ,另外源的话可以用<a href="https://github.com/UtermuxBlog/termux-android5-repo">这个</a>提供的源。 </p><p>
|
||||
不过用官方源也不是办法,在国内用还是速度慢,而且Termux的源里面软件也比较少,所以想了想还是装Linux发行版比较好。不过旧版的Termux不像新版那样可以安装proot-distro,直接一键安装Linux发行版,旧版要想用只能用AnLinux安装。结果AnLinux也还有些问题,他们把资源都保存到Github上了,但是Github在国内下载raw是完全没办法的,结果我就只能在电脑上提前在<a href="https://github.com/EXALAB/Anlinux-Resources">AnLinux资源仓库</a>里面下载好需要的脚本和镜像,然后再传到平板上进行安装。 </p><p>
|
||||
在安装了发行版之后,换源安装软件就不会再出问题了,在那个上面可以随便安装最新的软件包。我安装了一套Python和Jupyter都可以正常运行,接下来如果可以的话就让我试试看平板使用Termux效果如何吧。</p>
|
||||
<h1 id="增强性改动">
|
||||
|
||||
|
||||
<a href="#增强性改动"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 增强性改动
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>我的平板没有物理键盘,然后输入法上也没有上下左右键,导致我操作的时候很麻烦,后来我在网上查了一下,只要运行</p>
|
||||
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> ~/.termux <span class="o">&&</span> <span class="nb">echo</span> <span class="s2">"extra-keys = [['ESC','/','-','HOME','UP','END','PGUP'],['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN']]"</span> <span class="o">></span> ~/.termux/termux.properties
|
||||
</code></pre></div></div>
|
||||
<p>然后重启Termux就可以在键盘上方出现需要的大多数按键,感觉效果还不错。</p>
|
||||
<h1 id="总结">
|
||||
|
||||
|
||||
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>其实这也是更好利用旧设备的方案,之前我也有写过<a href="/2020/03/08/oldphone.html">怎样更好的利用旧手机</a>,现在如果用了Termux效果就更好了,之前想要安装Web环境用的还是KSWEB的方案,现在的话想安什么环境就和操作电脑和服务器一样简单了。无论如何旧设备还是用起来更好,闲置确实就毫无意义了,不如回收掉或者换盆啥的。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Termux"><em>Termux</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=Android"><em>Android</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-02-15-termux.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/02/15/termux.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/02/14/move.html">
|
||||
上一篇:Mayx的博客分发方案
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/03/12/alpine.html">
|
||||
下一篇:Alpine的使用体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/02/15/termux', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/02/15/termux.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
368
2022/03/12/alpine.html
Normal file
368
2022/03/12/alpine.html
Normal file
@@ -0,0 +1,368 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>Alpine的使用体验 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="Alpine的使用体验" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="没别的,小就是好!" />
|
||||
<meta property="og:description" content="没别的,小就是好!" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-03-12T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="Alpine的使用体验" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-03-12T00:00:00+08:00","datePublished":"2022-03-12T00:00:00+08:00","description":"没别的,小就是好!","headline":"Alpine的使用体验","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/03/12/alpine.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/03/12/alpine.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/03/12/alpine.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-03-12T00:00:00+08:00">12 March 2022</time> - 字数统计:3472 - 阅读大约需要11分钟 - Hits: <span id="/2022/03/12/alpine.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">Alpine的使用体验</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Sat, 12 Mar 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章主要介绍了作者在学习Docker的过程中,体验了Alpine Linux作为其容器化环境的优势。Alpine Linux因其小巧轻量、稳定性高、安装简单和内存占用低等特点,适合在生产环境中使用,尤其是对于资源有限的服务器,可以节省空间和提升性能。作者在虚拟机里安装了LEMP环境(Linux、Nginx、MySQL和PHP),并经历了从理论上学习到实际操作的过程,对安装和配置进行了详细分享。最后,作者表示在测试阶段,使用Alpine搭建的Discuz环境表现良好,验证了其作为未来项目基础环境的可行性,强调了“小就是好”的优势。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#alpine的特点">Alpine的特点</a></li><li><a href="#预期的问题解决方案">预期的问题解决方案</a></li><li><a href="#alpine的安装与环境测试">Alpine的安装与环境测试</a><ul><li><a href="#安装lemp">安装LEMP</a></li><li><a href="#配置bbr">配置BBR</a></li></ul></li><li><a href="#体验和总结">体验和总结</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>没别的,小就是好!<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>最近一段时间,我开始学习Docker了。在学习期间,我知道了Docker官方推荐的Alpine Linux系统。以前我也听说过这个系统,但是名字没什么特色就没关心过。不过既然学了Docker,我也体验了一下,发现还真是相当不错,而且正好能解决我手头的问题。</p>
|
||||
<h1 id="alpine的特点">
|
||||
|
||||
|
||||
<a href="#alpine的特点"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Alpine的特点
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>Alpine Linux和我之前用过的<a href="/2020/12/07/picore.html">piCore</a>在PC上用的版本TinyCore Linux有相似之处,他们都是基于Busybox来驱动整个系统的,不过TinyCore的软件要少很多,而且软件都是用类似镜像的方式打包,系统也是在内存中运行的,所以并不适合在生产环境中使用。Alpine就不一样了,它库中的软件很明显要多得多,而且现在很多人都在使用基于Docker构建的程序上,稳定性肯定是没有任何问题的,大小虽然比TinyCore Linux大了些,但是相比于CentOS之类的发行版要小太多了,而且在没有装程序的时候内存基础占用才不到100MiB。 </p><p>
|
||||
另外它安装软件也特别简单,使用的命令是<code class="language-plaintext highlighter-rouge">apk add</code>,比如我想在Alpine上安装Docker,就直接输入<code class="language-plaintext highlighter-rouge">apk add docker</code>就行了,基本上不需要其他什么操作,Docker就安装好了,然后再执行个<code class="language-plaintext highlighter-rouge">rc-update add docker boot</code>加到启动项里,不像其他发行版还要加什么源啊,还要安装什么containerd啊,就很麻烦。 </p><p>
|
||||
不过据说Alpine不适合开发,好像是因为系统用的是musl libc,用的人少,有些程序会不兼容……不过在我这次测试当中,没有碰见类似的问题。所以对于我来说,在生产服务器上使用CentOS实在是太浪费了,浪费硬盘空间又浪费内存空间,像我能用的服务器性能都不怎么高,要是用Alpine那就可以在一定程度上再提高性能了。</p>
|
||||
<h1 id="预期的问题解决方案">
|
||||
|
||||
|
||||
<a href="#预期的问题解决方案"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 预期的问题解决方案
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>在两年前,我为了优化我所维护的花火学园曾经把系统<a href="/2020/01/05/devops.html">Ubuntu换成CentOS</a>,而最近,我接手了另一个ACGN资源论坛——资源统筹局。这个论坛的体积也不小,因为之前论坛里对附件的上传限制不高,导致很大部分都是附件占的体积。像现在花火学园从以前的只有2GiB到现在有20GiB了,再加上统筹局又有十几GiB,还有CentOS本身又要10GiB左右,我原来租的64GiB大小的硬盘基本上不够用了,所以现在只好先升到了80GiB的硬盘。不过考虑到可持续发展,增加硬盘容量就要增加成本,这对可持续发展不是一件好事。想想CentOS要占掉这么大的空间实在是不合适,如果我能把这部分空间节省下来的话,那我还能继续用64GiB硬盘的服务器。 </p><p>
|
||||
不过因为现在的数据量比较大,而且服务的用户也比较多,如果计划出问题恢复起来也比较麻烦,所以我想先在自己在电脑上创建一个类似的服务器,安装上Alpine进行预演测试,然后再找空闲时间在服务器上进行迁移操作,这样就能尽可能保证服务不会因为操作失误而中断了。</p>
|
||||
<h1 id="alpine的安装与环境测试">
|
||||
|
||||
|
||||
<a href="#alpine的安装与环境测试"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Alpine的安装与环境测试
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>我在选取Alpine镜像的时候是使用的virt镜像,因为介绍上说这个版本对虚拟机有优化,而云服务器本质上就是一个KVM的虚拟机,我在电脑上装的话则是Hyper-V的虚拟机,所以我用的是这个版本。在启动之后,首先需要执行<code class="language-plaintext highlighter-rouge">setup-alpine</code>进行配置和安装,这么看来用光盘启动的Alpine有点像LiveCD,另外在服务器上安装的话在选择那个硬盘模式的时候可以选LVM,选了LVM之后方便以后调硬盘大小,然后再选sys。不过LVM有可能会影响性能,所以追求极致性能的话可以直接选sys。其他部分安装都很人性化,包括选择源还能自动找到最合适的源,这个比Ubuntu好多了,apt想换源还得手动换。</p>
|
||||
<h2 id="安装lemp">
|
||||
|
||||
|
||||
<a href="#安装lemp"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 安装LEMP
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>安装完成之后弹出光盘然后重启就OK了,接下来是安装LEMP环境。我以前用LEMP基本上要么是配好的,要么就是一键包,我既没有体验过编译安装,也没有试过用软件包管理器安装。所以这次在Alpine上安装也算是一个挑战了。像Docker安装既然直接安就可以,那这三个组件应该也差不多,我一开始是找的网上的文章,装倒是能正常装,但是我找了一个探针试着运行了一下总是报500的错误……结果发现网上那些在Alpine上安装的PHP连像php-json这种核心库都没装😓,后面我只好自己摸索,把Discuz需要的PHP扩展装全了,在安装软件之前,要启用community源,不然好多包会找不到,具体位置是在<code class="language-plaintext highlighter-rouge">/etc/apk/repositories</code>,把里面那个community源前面的#去掉,然后执行一下<code class="language-plaintext highlighter-rouge">apk update</code>就行了。</p>
|
||||
<ol>
|
||||
<li>安装PHP的命令主要是:<code class="language-plaintext highlighter-rouge">apk add php7 php7-fpm php7-opcache php7-gd php7-mysqli php7-zlib php7-curl php7-pdo php7-mysqlnd php7-json php7-exif php7-zip php7-redis php7-imagick php7-fileinfo php7-xml</code>,安装完之后别忘记把php-fpm加到启动项里:<code class="language-plaintext highlighter-rouge">rc-update add php-fpm7 default</code>,这些库安装完基本上大多数网站引擎就能正常用了。</li>
|
||||
<li>还有就是MySQL,我装的是MariaDB,反正也是相互兼容的,应该也不影响。具体命令是<code class="language-plaintext highlighter-rouge">apk add mariadb mariadb-client</code>,然后执行<code class="language-plaintext highlighter-rouge">/etc/init.d/mariadb setup</code>初始化,执行<code class="language-plaintext highlighter-rouge">rc-update add mariadb default</code>和<code class="language-plaintext highlighter-rouge">rc-service mariadb start</code>加入启动项和启动数据库,再执行<code class="language-plaintext highlighter-rouge">mysql_secure_installation</code>配置一些安全上的东西就OK了。</li>
|
||||
<li>Nginx安装起来就简单多了,直接执行<code class="language-plaintext highlighter-rouge">apk add nginx</code>,然后加入启动项<code class="language-plaintext highlighter-rouge">rc-update add nginx default</code>就行了。当然这只是安装,之后还需要一些配置才能连接到PHP。</li>
|
||||
<li>额外的一些比如Redis我也试着装了一下,用<code class="language-plaintext highlighter-rouge">apk add redis</code>和<code class="language-plaintext highlighter-rouge">rc-update add redis default</code>就OK。</li>
|
||||
</ol>
|
||||
|
||||
<p>所有操作完成之后Nginx改一下配置文件,需要在<code class="language-plaintext highlighter-rouge">/etc/nginx/http.d</code>里的配置文件中增加一段:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
</code></pre></div></div>
|
||||
<p>这个文件夹里面的<code class="language-plaintext highlighter-rouge">default.conf</code>中没配root,而且默认404,这些使用的时候都需要改一下。 </p><p>
|
||||
所有的东西改完之后就可以使用完整的LEMP环境了。当然这些都是预演,这篇文章也是为了接下来在服务器上配置做准备。 </p><p>
|
||||
另外还有些安全上的问题,默认情况下是没有配禁用函数的,还有防火墙默认也没有安装,Alpine倒是支持安装ufw也挺方便的,这些实际使用的时候都得配一下。 </p><p>
|
||||
除此之外还有把php-fpm和redis配置成监听Unix Domain之类的优化操作,这些之前的文章都有写,这里就不多做描述了。</p>
|
||||
<h2 id="配置bbr">
|
||||
|
||||
|
||||
<a href="#配置bbr"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 配置BBR
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>之前用CentOS的时候我是直接用的脚本整的BBR,不过BBR好像是高版本Linux内核自带的功能,本来就不需要安装,Alpine的内核版本好像是5.15,就不用像CentOS那样还要升级内核了,所以只要执行以下命令:</p>
|
||||
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sed</span> <span class="nt">-i</span> <span class="s1">'/net.core.default_qdisc/d'</span> /etc/sysctl.conf
|
||||
<span class="nb">sed</span> <span class="nt">-i</span> <span class="s1">'/net.ipv4.tcp_congestion_control/d'</span> /etc/sysctl.conf
|
||||
<span class="nb">echo</span> <span class="s2">"net.core.default_qdisc = fq"</span> <span class="o">>></span> /etc/sysctl.conf
|
||||
<span class="nb">echo</span> <span class="s2">"net.ipv4.tcp_congestion_control = bbr"</span> <span class="o">>></span> /etc/sysctl.conf
|
||||
sysctl <span class="nt">-p</span>
|
||||
</code></pre></div></div>
|
||||
<p>然后重启,执行<code class="language-plaintext highlighter-rouge">lsmod | grep bbr</code>只要有<code class="language-plaintext highlighter-rouge">tcp_bbr</code>就OK。</p>
|
||||
<h1 id="体验和总结">
|
||||
|
||||
|
||||
<a href="#体验和总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 体验和总结
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>最终整完之后安装了Discuz,感觉还挺不错的,功能简单试了一下都没有问题,用探针测试了一下速度也很不错,感觉作为接下来花火学园和资源统筹局的基础环境没有任何问题。 </p><p>
|
||||
在结束之后我看了一下占用硬盘才600MiB,空载内存才200MiB左右,这简直比CentOS好太多了,像CentOS的LEMP空载内存都要600MiB左右,我整个服务器才2GiB的内存,被系统占掉那么多它到底干了些啥?目前我没有发现任何坑,到时候迁移完再看吧,总之现在的我只能说,小就是好!</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Alpine"><em>Alpine</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=LEMP"><em>LEMP</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-03-12-alpine.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/03/12/alpine.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/02/15/termux.html">
|
||||
上一篇:在平板上使用Termux的经历
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/03/27/radio.html">
|
||||
下一篇:用树莓派自制FM电台
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/03/12/alpine', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/03/12/alpine.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
351
2022/03/27/radio.html
Normal file
351
2022/03/27/radio.html
Normal file
@@ -0,0 +1,351 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>用树莓派自制FM电台 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="用树莓派自制FM电台" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="无线电还挺有意思啊。" />
|
||||
<meta property="og:description" content="无线电还挺有意思啊。" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-03-27T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="用树莓派自制FM电台" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-03-27T00:00:00+08:00","datePublished":"2022-03-27T00:00:00+08:00","description":"无线电还挺有意思啊。","headline":"用树莓派自制FM电台","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/03/27/radio.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/03/27/radio.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/03/27/radio.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-03-27T00:00:00+08:00">27 March 2022</time> - 字数统计:2543 - 阅读大约需要9分钟 - Hits: <span id="/2022/03/27/radio.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">用树莓派自制FM电台</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Sun, 27 Mar 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章介绍了作者如何用树莓派自制FM电台的过程,从一开始没有尝试官方系统,到选择RPiTX和fm_transmitter,最终找到并改进了PiFmAdv项目。作者通过实验发现PiFmAdv在音质和信号范围上有所提升,并提醒了可能的法律风险,如功率限制和频率使用规定。文章结尾作者表达了对无线电技术的兴趣,但也提到了法律限制和专业认证的要求。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#树莓派电台软件的选择">树莓派电台软件的选择</a></li><li><a href="#pifmadv的体验">PiFmAdv的体验</a></li><li><a href="#可能的风险与危害">可能的风险与危害</a></li><li><a href="#来点阴谋论">来点阴谋论</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>无线电还挺有意思啊。<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>其实我在很早以前就知道树莓派可以当广播电台了,但是我由于我作死的最早开始用的系统是<a href="/2020/12/07/picore.html">piCore</a>,而且感觉它功能够用就再没换回成官方系统。然而树莓派很多有趣的项目都是基于官方系统而不是不知名的发行版制作的,所以实际上虽然我知道树莓派有能力成为电台但是从来没有试过。然后最近突然想试试看,所以就把Raspberry Pi OS lite又下载回来刷到卡里,想试试看做个电台怎么样。</p>
|
||||
<h1 id="树莓派电台软件的选择">
|
||||
|
||||
|
||||
<a href="#树莓派电台软件的选择"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 树莓派电台软件的选择
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>一般从网上找教程的话好像推荐直接安装<a href="https://github.com/F5OEO/rpitx">rpitx</a>,不过我看这个项目有段时间没有更新了,虽然功能好像更强大吧……不过我目前就只用的是FM电台的功能,我更希望它的电台功能更强大,所以我又看了看别的项目。我最先看的是<a href="https://github.com/markondej/fm_transmitter">fm_transmitter</a>这个项目,根据文档所述的方法安装之后确实能用,不过在整这个项目的时候因为我没有杜邦线传输距离很短,大概信号范围也就1m左右吧。后来我又搜了一下找到了<a href="https://github.com/miegl/PiFmAdv">PiFmAdv</a>这个项目,它看起来是基于<a href="https://github.com/ChristopheJacquet/PiFmRds">PiFmRds</a>项目改编升级的,功能多了很多,但是我不知道这个作者是怎么想的,原来的项目还支持ARM64(aarch64),结果改完之后反倒不支持了😓,最开始我怎么编译都不通过,后来看了一眼Makefile发现不太对劲,然后我就简单改了一下参数总算可以编译通过了。这一点我已经<a href="https://github.com/miegl/PiFmAdv/issues/93">提了issue</a>,不知道作者会不会改,如果不会改的话大家要是想在64位的树莓派系统上运行需要注意改一下Makefile。</p>
|
||||
<h1 id="pifmadv的体验">
|
||||
|
||||
|
||||
<a href="#pifmadv的体验"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> PiFmAdv的体验
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>用了一下PiFmAdv之后发现这个清晰度真的和项目描述一样音质比fm_transmitter好了很多,也没有杂音了。后来我又看了看文档,发现它最多支持同时通过3个GPIO接口发射信号,于是我试了试用以下命令启动:</p>
|
||||
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sox audio.mp3 <span class="nt">-t</span> wav - repeat - | <span class="nb">sudo</span> ./pi_fm_adv <span class="nt">--audio</span> - <span class="nt">--freq</span> 108.0 <span class="nt">--power</span> 7 <span class="nt">--gpio</span> 4 <span class="nt">--gpio</span> 20 <span class="nt">--gpio</span> 32 <span class="nt">--rds</span> 0
|
||||
</code></pre></div></div>
|
||||
<p>信号也真的好了很多。这下一下就让我起了兴趣,于是就去淘宝上买了点杜邦线回来当天线。按照说明来看,这个程序只能在GPIO的4、20和32号口输出信号,貌似是用到了GPCLK的功能,所以只能用这些针脚。4号和20号口很容易找,具体位置可以看下面我打”x”的位置:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>,--------------------------------.
|
||||
| ooooooooooooooooooxo J8 +====
|
||||
| 1ooxoooooooooooooooo | USB
|
||||
| +====
|
||||
| Pi Model 3B V1.2 |
|
||||
| +----+ +====
|
||||
| |D| |SoC | | USB
|
||||
| |S| | | +====
|
||||
| |I| +----+ |
|
||||
| |C| +======
|
||||
| |S| | Net
|
||||
| pwr |HDMI| |I||A| +======
|
||||
`-| |--------| |----|V|-------'
|
||||
</code></pre></div></div>
|
||||
<p>但是32号口我是怎么找都没找到,在网上各种查资料都没有找到32号GPIO口……可能它是走的板子内的某根线吧…… </p><p>
|
||||
具体要接多长的天线呢?我看一般人推荐就接一节杜邦线就行了(大概10cm),当然这我肯定不会满足,我查了一下相关原理,好像说4号口理论上接1.5m长的天线可以最大化利用它的能力,所以我就直接买的公对母的线,接了2条大概1.4m的线,接到了4号和20号口,打开一试,信号真的一下就扩展到了将近1km的样子,我用手机的收音机功能测试在只有1道墙隔开的情况基本上1km没有任何问题,如果隔得墙多了大概只能到50m左右。不过这个发射信号的能力倒是比WiFi强了不少,估计是因为频率比较低吧。 </p><p>
|
||||
这个程序不仅支持发射音频信号,还能发射RDS数据,不过很遗憾我没有接收RDS数据的设备,所以我也测不了……</p>
|
||||
<h1 id="可能的风险与危害">
|
||||
|
||||
|
||||
<a href="#可能的风险与危害"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 可能的风险与危害
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>首先,个人发射无线电波在很多国家都是违法的,我搜了一下大多数国家在电台频段个人发射的功率限制基本上连1mW都不到,树莓派一个针脚最大发射电流是16mA,和电压3.3V相乘就要接近50mW了,所以要想玩的话要么就不要接天线,或者说不要接太长的天线,或者不要开时间太长,免得被别人搜到,还有就是不要占用有信号的频道,一是自己听着也乱,二是这样如果有人在用更容易被发现。另外不推荐设置超过87-108Mhz的频率,一是这样中国的收音机也接收不到,二是再往上就要到航空用频道,再往下就可能到军用频道的,那些频道占用的话还是挺危险的,所以一般给无线电爱好者分的频段好像都在300-400Mhz的样子,当然这样那就不是FM电台了,在那个频段的好像都是对讲机啥的。所以最终还是推荐别开时间太长,而且不推荐播小广告啥的,放音乐一般好像没人管,播广告那就是妥妥的“黑广播”了。 </p><p>
|
||||
另外还有可能的危害比如说假如有人在飞机上在航空频段开广播,这个程序可是没有限制频率的,那可能真的可以让飞机驾驶舱播广播,这可就不是小问题了。严重的可能飞行员就只能迫降了,毕竟要是听不清塔台的信号那还是有大问题的。</p>
|
||||
<h1 id="来点阴谋论">
|
||||
|
||||
|
||||
<a href="#来点阴谋论"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 来点阴谋论
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>综上所述,我觉得从权力机构的层面可能因此有限制无线电知识的情况。其实普通人想发射无线电是非常容易的事情,有电流通过的地方就有电磁波,这么说来那我觉得不只是树莓派这种连接虚拟与现实的设备能做得到发射无线电,但凡是有导线,能改变通电状态的设备理论上应该都可以。那我是不是用扬声器,USB线等能传输信号的设备都可以发射?这让我想起了Fabrice Bellard大神写的一个<a href="https://bellard.org/dvbt/">用VGA显卡来发射DVB-T信号的程序</a>,那个程序应该说是非常厉害了,我觉得理论上我用扬声器发射FM信号这种事情应该是能做到的,就是不知道声卡能不能不解码直接向扬声器发射电流,另外还有个好处就是树莓派实际上是用PMW模拟的FM信号,而扬声器是可以调整电流大小的,理论上实现可能更简单吧……其实要是说呢以前的手机是支持当作FM电台的,现在就都不支持了,所以我觉得说不定不是大家做不出来这样的程序,而是做出来的人都消失了😂。希望能有大佬给点力吧,能把这种软件多开源点出来。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>感觉无线电还挺有意思的,要不然回头学一学考个业余电台操作证书?我之前还看过一位大佬<a href="https://blog.aoaoao.me/p/amateur-satellite/">用卫星和世界各地的人通信</a>,感觉真的非常厉害。不过在这里面有好多法律的限制还挺麻烦的……可能也就只能自己玩玩了吧。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%A0%91%E8%8E%93%E6%B4%BE"><em>树莓派</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%94%B5%E5%8F%B0"><em>电台</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=FM"><em>FM</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-03-27-radio.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/03/27/radio.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/03/12/alpine.html">
|
||||
上一篇:Alpine的使用体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/04/17/pcdn.html">
|
||||
下一篇:体验成为PCDN的节点
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/03/27/radio', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/03/27/radio.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
315
2022/04/17/pcdn.html
Normal file
315
2022/04/17/pcdn.html
Normal file
@@ -0,0 +1,315 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>体验成为PCDN的节点 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="体验成为PCDN的节点" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="用闲置带宽挣钱也许是个不错的选择。" />
|
||||
<meta property="og:description" content="用闲置带宽挣钱也许是个不错的选择。" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-04-17T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="体验成为PCDN的节点" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-04-17T00:00:00+08:00","datePublished":"2022-04-17T00:00:00+08:00","description":"用闲置带宽挣钱也许是个不错的选择。","headline":"体验成为PCDN的节点","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/04/17/pcdn.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/04/17/pcdn.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/04/17/pcdn.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-04-17T00:00:00+08:00">17 April 2022</time> - 字数统计:1297 - 阅读大约需要4分钟 - Hits: <span id="/2022/04/17/pcdn.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">体验成为PCDN的节点</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Sun, 17 Apr 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者再次尝试通过闲置带宽加入PCDN的经历,重点描述了从刷机升级小米路由器、配置网心云虚拟机(PCDN节点)以及遇到的网络与性能问题。作者提到升级路由器后的网络速度提升明显,全锥形模式的发现促使他想继续利用闲置带宽赚钱。虽然初期配置遇到了无线网络问题导致电脑卡顿,但最终通过有线连接解决了。作者认为PCDN成本低,是个成本合理且有盈利潜力的选择。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#折腾路由器的经历">折腾路由器的经历</a></li><li><a href="#用闲置带宽赚钱的经历">用闲置带宽赚钱的经历</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>用闲置带宽挣钱也许是个不错的选择。<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>其实以前我也整过PCDN,比如迅雷的网心云啥的,主要是当时的网络正好是全锥形的,所以才搞了段时间,一个月赚了大概50CNY。不过后来我遇到的网络几乎全部都是对称型网络,所以就再没搞。不过最近又做了些小实验,我所在的网络是移动网,众所周知移动网家宽几乎很难获得公网IP,有时候闲了用NAT类型检测测出来的结果是对称型。因为移动自己也有一层NAT,所以我就没往自己路由器上想,觉得自己路由器应该不会有什么莫名其妙的限制。不过后来我把路由器刷成OpenWRT之后才发现事情好像不对劲。</p>
|
||||
<h1 id="折腾路由器的经历">
|
||||
|
||||
|
||||
<a href="#折腾路由器的经历"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 折腾路由器的经历
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>我用的路由器是小米路由器4A百兆版(R4AC),有一天偶然看到一篇文章是讲<a href="https://www.yeliulee.com/archives/149.html">关于这个路由器的刷机教程</a>的。一般小米路由器要刷机都要接U盘,但是这个路由器它没有USB接口。不过想不到的是小米路由器的固件有漏洞,有大佬写了一个<a href="https://github.com/acecilia/OpenWRTInvasion">通用脚本</a>来直接进入小米的系统来刷机。因为小米路由器系统本身也是基于OpenWRT改的,所以操作也和普通的Linux系统一样。 </p><p>
|
||||
结果我运气还不错,跟着教程搞一次就刷成功了,刷完配置完之后体验了一下,无论从管理面板的速度还是使用时的网速和延迟,感觉都比官方固件快了好多,而且功能也更加强大了,比如能直接在路由器上挂frp,很方便。在体验的过程中我发现了一个选项叫“启用FullCone-NAT”,虽然感觉上层网络应该不支持全锥形吧……总之是试验,就打开了这个选项。打开之后我在电脑上使用NAT类型检测工具试了一下,好家伙,是真的全锥形网络。这时候我又回想起以前搞网心云的经历,打算这次继续搞一搞。</p>
|
||||
<h1 id="用闲置带宽赚钱的经历">
|
||||
|
||||
|
||||
<a href="#用闲置带宽赚钱的经历"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 用闲置带宽赚钱的经历
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>我在官网上下了网心云的虚拟机之后放到了Hyper-V里,这个我还是挺喜欢的,我不喜欢在电脑上装莫名其妙的国产软件,总感觉他们会在我电脑上留点啥,虚拟机就好多了。不过在配置过程中,虚拟交换机的配置出了些问题,因为作为PCDN的节点,NAT肯定是穿透的越少越好,毕竟用NAT的话实际上穿透的端口是有数量限制的,所以我不应该使用默认的交换机,而是使用桥接到外部网络的交换机。我是用的笔记本连接的网络,所以我一开始计划的是用无线网络作为桥接网络的上层。配置好交换机之后倒是也能用,但问题是我的电脑莫名其妙的出现了特别卡的问题,而且问题主要出现在需要网络的地方,比如打开浏览器会卡,打开设置的网络配置页面会卡,下载文件也会卡。这样可不行,整这个不能影响到我正常使用电脑啊……最终没办法,在包里翻了一会找到了一条网线,接到路由器上然后把虚拟交换机的网络配置到有线网络上之后就好多了。 </p><p>
|
||||
网心云的系统做的也还不错,系统本身基本上不需要配置,只要填好激活码,配置好网络和硬盘,就基本上没有问题了。现在的话激活码还能免费领取,想当年我的激活码还是花了15CNY买的😂。 </p><p>
|
||||
目前的话我已经都配置好了,跑了一晚上还不错,赚了0.7CNY,因为是新安装的机器,还没有缓存,之后缓存多起来之后就会好很多了。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>搞PCDN挺不错的,成本的话基本上就只有电费和硬盘损耗,其他的可以不算做成本,毕竟带宽和电脑都是正常支出,如果能搞到不错的网络,整点这种东西也是个不错的选择。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=PCDN"><em>PCDN</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BD%91%E7%BB%9C"><em>网络</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-04-17-pcdn.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/04/17/pcdn.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/03/27/radio.html">
|
||||
上一篇:用树莓派自制FM电台
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/05/27/zongzi.html">
|
||||
下一篇:在宿舍煮粽子的小方案
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/04/17/pcdn', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/04/17/pcdn.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
308
2022/05/27/zongzi.html
Normal file
308
2022/05/27/zongzi.html
Normal file
@@ -0,0 +1,308 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>在宿舍煮粽子的小方案 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="在宿舍煮粽子的小方案" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="没有锅想吃粽子怎么办?" />
|
||||
<meta property="og:description" content="没有锅想吃粽子怎么办?" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-05-27T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="在宿舍煮粽子的小方案" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-05-27T00:00:00+08:00","datePublished":"2022-05-27T00:00:00+08:00","description":"没有锅想吃粽子怎么办?","headline":"在宿舍煮粽子的小方案","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/05/27/zongzi.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/05/27/zongzi.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/05/27/zongzi.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-05-27T00:00:00+08:00">27 May 2022</time> - 字数统计:624 - 阅读大约需要2分钟 - Hits: <span id="/2022/05/27/zongzi.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">在宿舍煮粽子的小方案</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Fri, 27 May 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章介绍了一个在宿舍没有锅的情况下煮粽子的创新方法。作者首先通过购买并尝试生吃和热水泡发现,虽然真空包装的粽子直接生吃口感不佳,但通过热水多次替换并持续泡20分钟,粽子的内外都变软了。尝试用这种方法处理肉粽子和甜粽子后,效果都较好,虽然与锅煮的粽子口感略逊,但满足了在宿舍的粽子需求。作者认为这个方法在火车上方便食用,相比泡面更舒适。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#调研的经历">调研的经历</a></li><li><a href="#细细品味">细细品味</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>没有锅想吃粽子怎么办?<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>马上就到端午节了,也有点想吃粽子。不过我平时都住在宿舍,没有锅,也没办法持续加热。那我怎么才能吃到粽子呢?</p>
|
||||
<h1 id="调研的经历">
|
||||
|
||||
|
||||
<a href="#调研的经历"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 调研的经历
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>首先我得买点粽子,我下了单之后过了半天发现它竟然降价了😂,之后还花了不少时间让商家退差价。等粽子到了之后,我想着即使是真空包装,粽子本身应该也是煮熟了才包装的吧,所以刚到我就直接生吃了一个。我以为生吃只是会凉一些,结果吃起来就像土一样😂。第二次我试了试在热水中泡7分钟,泡完之后发现外面一层米已经变黏了,但是里面还是像土一样……不过这么看来,用热水泡肯定是能把真空粽子泡开的,那就只是时间问题了。 </p><p>
|
||||
我大概搜了一下,小火慢煮粽子大概20分钟就能熟,那我就隔10分钟换一次热水,一共泡20分钟吧。 </p><p>
|
||||
最终这样做出来效果还不错,粽子的里面和外面都变软了。 </p><p>
|
||||
不过这次买的粽子是肉粽子,为了更可靠的结果,正好最近公司过节又发了一箱粽子,正好可以做个对比。 </p><p>
|
||||
之前我是2个咸粽子泡在热水里,每10分钟换一次热水,共20分钟,现在是4个甜粽子也是泡在热水里同样也是20分钟。最终做出来效果同样也很不错,吃起来感觉就像刚煮出来一样。</p>
|
||||
<h1 id="细细品味">
|
||||
|
||||
|
||||
<a href="#细细品味"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 细细品味
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>虽然这泡出来的粽子刚做好的时候看起来和吃起来感觉都和锅里煮出来的一样,但是细细品味的话会感觉米还是有点硬,没有用锅煮出来的效果好。不过能在没法加热的地方能吃到粽子已经很不错了,本来这个办法就是没办法的办法…… </p><p>
|
||||
之后想想感觉这个方法如果在火车上貌似还挺有用的,在火车上吃粽子感觉要比吃泡面更舒服吧。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%B2%BD%E5%AD%90"><em>粽子</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-05-27-zongzi.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/05/27/zongzi.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/04/17/pcdn.html">
|
||||
上一篇:体验成为PCDN的节点
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/07/03/fast-ver.html">
|
||||
下一篇:关于字节跳动旗下某些“极速版”软件的探索
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/05/27/zongzi', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/05/27/zongzi.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
326
2022/07/03/fast-ver.html
Normal file
326
2022/07/03/fast-ver.html
Normal file
@@ -0,0 +1,326 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>关于字节跳动旗下某些“极速版”软件的探索 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="关于字节跳动旗下某些“极速版”软件的探索" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="想不到不止是上传可以赚钱……" />
|
||||
<meta property="og:description" content="想不到不止是上传可以赚钱……" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-07-03T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="关于字节跳动旗下某些“极速版”软件的探索" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-07-03T00:00:00+08:00","datePublished":"2022-07-03T00:00:00+08:00","description":"想不到不止是上传可以赚钱……","headline":"关于字节跳动旗下某些“极速版”软件的探索","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/07/03/fast-ver.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/07/03/fast-ver.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/07/03/fast-ver.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-07-03T00:00:00+08:00">3 July 2022</time> - 字数统计:1429 - 阅读大约需要5分钟 - Hits: <span id="/2022/07/03/fast-ver.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">关于字节跳动旗下某些“极速版”软件的探索</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Sun, 03 Jul 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者试用字节跳动旗下“极速版”应用赚钱的经历,通过完成任务赚取收益,并将其与PCDN网络服务进行对比。这些“极速版”软件的门槛低,初期收益高,适宜手机和手机号丰富的用户,通过批量安装和使用脚本自动化完成任务,但收益会随着时间减少。虽然这类软件看起来实现了多方获益(观看者、制作者和平台),但作者认为长期价值不大,关心的是对网络空间的贡献,因此计划在收益降低后卸载此类软件。作者也提到,即便有刷广告的行为,对广告商仍有价值。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#赚钱的方式">赚钱的方式</a></li><li><a href="#和pcdn的对比">和PCDN的对比</a></li><li><a href="#快速利用此类软件赚钱的方式">快速利用此类软件赚钱的方式</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>想不到不止是上传可以赚钱……<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>由于被家人邀请使用字节跳动旗下某个“极速版”应用,据说这邀请一次可以直接得50CNY左右,看在能拿钱的份上我就下载试了试,倒是还真拿上了,另外正好和我之前整的<a href="/2022/04/17/pcdn.html">PCDN</a>做个对比。</p>
|
||||
<h1 id="赚钱的方式">
|
||||
|
||||
|
||||
<a href="#赚钱的方式"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 赚钱的方式
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>使用这类软件赚钱也比较简单,就只要完成软件提出的任务就行,比如我被邀请的那一款就只要打开视频然后挂机就行,经过我一段时间研究,如果刷那种比较长的视频就会很轻松,打开就基本上挂机就行,因为它一个视频只有第一次播放才会计算任务时长。至于其他同类型的软件因为懒得搞而且貌似触发了风控被邀请了也没有收益所以就没试。 </p><p>
|
||||
做完任务提现倒是也不复杂,只要输入支付宝信息就行,比之前搞的PCDN的网心云好些,那个还要身份证号啥的比较麻烦。不过有个问题就是我用的这个软件虽然每天都能提,但要么是0.3CNY,要么就是15CNY,跨度实在是太大了,除非真的能赚很多钱,不然这种提现方式还是挺折磨人的。 <del>(钱还是早点到手比较安心😂)</del></p>
|
||||
<h1 id="和pcdn的对比">
|
||||
|
||||
|
||||
<a href="#和pcdn的对比"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 和PCDN的对比
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>相比之下这种软件的加入门槛低,初期收益高。一般来说PCDN对网络和设备要求都很高,除了网络NAT需要全锥形,硬盘也得比较大,速度也得快;而某些“极速版”软件就只要一个手机就可以用。这种赚钱方式也挺神奇的,作为视频缓存方PCDN(上传方)也能赚到钱,看视频的人(下载方)也能赚到钱,制作视频的人(生产者)也能靠广告签约赚钱,那么到底是谁亏了呢?字节也赚了那么多钱总不是他们亏了吧,但也不存在双赢的情况,那大概是广告商亏了? </p><p>
|
||||
不过在这段时间的使用我发现虽然前期收益确实高,相比我费不少功夫整PCDN好不少,但是后期收益就会越来越低,最终低到想把它卸掉,PCDN的收益就相对稳定了,基本上如果一段时间赚这么多,之后也一样是赚这么多。</p>
|
||||
<h1 id="快速利用此类软件赚钱的方式">
|
||||
|
||||
|
||||
<a href="#快速利用此类软件赚钱的方式"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 快速利用此类软件赚钱的方式
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>因为这类软件收益会越来越少,所以不需要在此上投入大量的精力,如果手机和手机号很多那效果会更好,因为这类软件没有实名,只需要手机号,那么我只要在每台手机上安装这个软件,相应的用这些手机号登录,然后全部填一个人的邀请码,首先按照平均一号50CNY的收益就会立即到账,为了避免被风控,最好在操作时不要在同一个WiFi下,禁止蓝牙/WiFi或者关闭周围蓝牙设备,关闭定位功能。 </p><p>
|
||||
之后的一周内每个账户也会有大概几十CNY的收益,也可以全部转到一起,在邀请成功之后就不会有风控了。这个期间可以手动刷,因为确实也费不了很长时间,基本上十几分钟就能搞定任务,也可以用脚本刷,我看GitHub上也有相关的项目,比如<a href="https://github.com/c0411034/autoVideo">autoVideo</a>,不过我也没试过,看起来也好长时间了没更新了,总之原理也很简单,就是隔个几秒模拟向上滑的动作就行了。 </p><p>
|
||||
超过10天后收益就会达到常规老用户的水平,这时候继续人力刷基本上就不再有意义了,当然有条件的也可以整新的电话号码继续整。如果想搞继续用脚本也可以,就是配置比较麻烦,在我看来如果有条件还是搞PCDN舒服,配好基本上就不用管了,比用脚本刷视频啥的好多了。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>在我看来,这种东西虽然我不会去看视频内容,即使有广告广告商也是白投,不过效果应该还是有的,像我的家人用了这个软件之后还认真看了广告,还买了相应的东西,那这样看来即使有我们这种单纯想薅广告商的钱的人,他们的行为依然是有价值的。 </p><p>
|
||||
另外我对这种东西不是很感兴趣,PCDN在一定程度上算是一种对网络空间的贡献,所以在我看来是有意义的。但是这种刷视频我是真感觉没啥意义,所以我打算等这个软件收益减少之后就把它卸载掉。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BD%91%E7%BB%9C"><em>网络</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%AD%97%E8%8A%82%E8%B7%B3%E5%8A%A8"><em>字节跳动</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-07-03-fast-ver.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/07/03/fast-ver.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/05/27/zongzi.html">
|
||||
上一篇:在宿舍煮粽子的小方案
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/07/16/privacy.html">
|
||||
下一篇:关于在网络中隐私的研究
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/07/03/fast-ver', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/07/03/fast-ver.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
382
2022/07/16/privacy.html
Normal file
382
2022/07/16/privacy.html
Normal file
@@ -0,0 +1,382 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>关于在网络中隐私的研究 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="关于在网络中隐私的研究" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="没有保护隐私的权利,我们也能自己来维护" />
|
||||
<meta property="og:description" content="没有保护隐私的权利,我们也能自己来维护" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-07-16T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="关于在网络中隐私的研究" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-07-16T00:00:00+08:00","datePublished":"2022-07-16T00:00:00+08:00","description":"没有保护隐私的权利,我们也能自己来维护","headline":"关于在网络中隐私的研究","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/07/16/privacy.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/07/16/privacy.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/07/16/privacy.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-07-16T00:00:00+08:00">16 July 2022</time> - 字数统计:4098 - 阅读大约需要12分钟 - Hits: <span id="/2022/07/16/privacy.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">关于在网络中隐私的研究</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Sat, 16 Jul 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讨论了在网络隐私保护的复杂性,指出尽管个人隐私容易被泄露,但通过合理的准备和策略,可以在一定程度上防止隐私被滥用。主要内容包括:1) 保护隐私的挑战,比如信息关联的易发性,特别在中国由于实名制的限制;2) 隐私泄露的常见原因,如网站访问、用户输入信息、网络服务提供商的监控以及DNS和SNI等技术的缺陷;3) 提供的隐私保护方法,包括身份伪造(使用虚拟身份和代理)、链路伪造(多层代理)、行为伪造(使用专门系统和时间掩饰);4) 总结,强调在地球上实现全程隐私的困难,但通过特定场景下的策略可以增强隐私保护。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#保护的前提">保护的前提</a></li><li><a href="#隐私泄露的原因与渠道">隐私泄露的原因与渠道</a><ul><li><a href="#针对向普通访问者泄露的原因">针对向普通访问者泄露的原因</a></li><li><a href="#针对向网站管理员泄露的原因">针对向网站管理员泄露的原因</a></li><li><a href="#针对网络服务提供商泄露的原因">针对网络服务提供商泄露的原因</a></li></ul></li><li><a href="#对于隐私泄露的解决方法">对于隐私泄露的解决方法</a><ul><li><a href="#身份伪造">身份伪造</a></li><li><a href="#链路伪造">链路伪造</a></li><li><a href="#行为伪造">行为伪造</a></li></ul></li><li><a href="#总结">总结</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>没有保护隐私的权利,我们也能自己来维护<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>前段时间可谓是盒泄漏时代,各个组织和公司都在争着把自己拥有的用户隐私数据往出送,以致于现在在一定程度上可以说没有准备的人默认就是实名上网了 <del>(我也没有准备好😂)</del> 。不过其实如果说做好准备的话除非对方有天大的本事,不然都无法找到在网络中实际操作的人。所以我这次想从原理上来说一说关于隐私的保护方案。</p>
|
||||
<h1 id="保护的前提">
|
||||
|
||||
|
||||
<a href="#保护的前提"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 保护的前提
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>因为考虑到泄露隐私这种事情实在是太容易了,所以我们一般来说如果想保护的话也很难做到面面俱到,只能针对单独的身份或者行为进行保护,如果真的想保证完全的隐私,那恐怕就不能待在地球上网了。所以尤其是在中国这种地方就更加困难,毕竟实名的东西也很多,关联起来也很简单。</p>
|
||||
<h1 id="隐私泄露的原因与渠道">
|
||||
|
||||
|
||||
<a href="#隐私泄露的原因与渠道"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 隐私泄露的原因与渠道
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<h2 id="针对向普通访问者泄露的原因">
|
||||
|
||||
|
||||
<a href="#针对向普通访问者泄露的原因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 针对向普通访问者泄露的原因
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>一般来说如果只是访问网站的话是很难泄露隐私的,毕竟获取隐私信息的主要方法是通过关键信息关联,比如手机号、邮箱还有IM账号等方便关联实人的联系信息,所以对于其他访问者来说这些信息本来就是不可见的。一般能泄露给访问者的信息基本上只有在网站上进行了写入可以公开信息的东西,比如注册账号、发帖、发消息之类的,当然一般来说普通人之所以开盒也都是因为发送了东西才会引起其他人的注意,不发东西也没有目标啊。 </p><p>
|
||||
在这种情况下的泄露关联很简单,也很好避免,一般这种就是查发送的信息和公开的个人信息,可能不是所有人都会公开手机号,不过IM账号大多数人都会公开,也许是腾讯的系统并不怎么安全,像QQ号查绑定手机的社工库还挺多的,尤其是用的时间比较长,比较常用的QQ号可以说是100%泄露了手机号。通过手机号查人就更简单了,对于普通人来说什么转账查询、通过快递订单泄露查询什么的可以说是应有尽有,我自己也查过自己,可以说是轻松就能查到,加上我常用的用户名,我只能说其实我在实名上网😭。 </p><p>
|
||||
当然除了上述普通的社工方案,也有比较高级的技术方案,比如MITM攻击、钓鱼攻击、以及第三方引用泄露等等,不过这些难度还是挺大的,主要还是因为现在加密技术的成熟,可以大大提高这些攻击的难度。</p>
|
||||
<h2 id="针对向网站管理员泄露的原因">
|
||||
|
||||
|
||||
<a href="#针对向网站管理员泄露的原因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 针对向网站管理员泄露的原因
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>作为在互联网上访问的人来说,你对目标网站的任何访问网站管理员自然是知道的一清二楚,毕竟你的访问肯定得让网站程序知道吧,不然网站程序怎么给用户返回正确的信息?在这种情况下泄露的信息就更多了,防御的难度也更大了。首先最先泄露的就是IP地址,毕竟在TCP协议中访问一个网站那数据想原路返回也得提前知道访问者的地址啊,就像访问者也能很轻松知道网站的IP地址一样。对于大多数网站管理员来说其实IP地址能获知的隐私信息也不是特别多,最多就是知道你在哪个城市,再精确估计也最多到小区,在IPv4已经被分配完的时代,大多数运营商都用了NAT,所以一个IP下可能包含很多个用户,当然对于运营商的人来说那就不一样了,他们可以根据地址分配的时间以及使用的端口精准的找到访问者的物理位置。顺便一说,如果这个网站允许其他用户使用第三方的图片等资源同样也可以获得访问者的IP。 </p><p>
|
||||
除了IP之外,还有就是用户自己输入的信息,像对其他访问者不可见的信息对于网站管理员那自然是一览无余的,这个就实在是太简单了,其实说来钓鱼网站也是一样的道理,没有防备的人可能输入的信息就是完全准确的,以致于当网站被攻破时泄露的数据也是准确的。 </p><p>
|
||||
上述的信息可以说是一些显式的信息,除此之外还有一些隐式的隐私信息,比如访问习惯,访问时间,还有访问的终端信息之类的,虽然这些信息单独拿出来都是没有意义的,但是统一整理出来就能定位到一个人,像很多广告的精准投放就是这个原理。而且这些隐式的隐私信息相比之下就会更加难以去除,相对来说利用也更加困难。</p>
|
||||
<h2 id="针对网络服务提供商泄露的原因">
|
||||
|
||||
|
||||
<a href="#针对网络服务提供商泄露的原因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 针对网络服务提供商泄露的原因
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>作为用户与网站之间的连接者ISP,他们获取隐私信息的方式就相当于是MITM,像以前数据没有加密的时候,那所有信息对于ISP来说都是完全透明的,那也没有什么隐私而言,还好现在成熟的加密技术可以有效的防止他们获取到用户的信息。不过即使是在加密时代,不恰当的处理依然是会泄露自己的信息。首先我们要知道他们会知道什么,虽然访问的内容对于运营商可能是不可知的,但是大多数情况现在人们都不会使用加密的DNS,所以用户访问的网站域名首先就会被泄露。另外即使使用了加密的DNS,很遗憾的是TLS1.2及以前版本有个叫做SNI的特性,这个东西是完全明文的,运营商同样也能根据这个知道你访问的网站。除此之外就是访问的IP了。一般来说现在的统计信息能很轻松知道哪个IP对应于哪个域名,还好有像Cloudflare这种CDN公司,许多网站指向的IP都是相同的,以致于根本没法根据访问的IP来推测用户访问的是哪个网站(当然对于CDN公司本身肯定是知道的一清二楚,包括访问与输入输出的内容也一样),因此运营商现在也几乎没办法仅通过IP来获知用户在访问哪个网站了。</p>
|
||||
<h1 id="对于隐私泄露的解决方法">
|
||||
|
||||
|
||||
<a href="#对于隐私泄露的解决方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 对于隐私泄露的解决方法
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<h2 id="身份伪造">
|
||||
|
||||
|
||||
<a href="#身份伪造"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 身份伪造
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>首先对于上述问题,我们可以发现大多数的隐私泄露都是用户自己造成的,主要是自己输入的信息。一般来说如果遇到一定需要输入自己信息的一些网站,我们可以提前设定好一个完整的虚拟网络身份,名字和一些住址信息啥的还是比较好整的,不过难整的是联系信息,像中国手机号是实名的,如果用其他国家不实名的手机号运营商还是能通过基站定位到,而其他在中国的很多服务则必须使用手机号登录,这就是所谓的前台匿名,后台实名吧。当然中国服务不能用,我们也可以考虑用国外的,比如Google Voice啥的,不过我也没整过,我也只用过一些公共接码平台。邮箱的话相对倒是好整一些,注册一个邮箱不是什么复杂的事情。银行卡虽然很难整不过大多数网站我们应该不需要用到银行卡,真要付款可以考虑一下数字货币,国外的很多支付平台现在也都支持了。在上述信息准备好后我们在需要用到隐私信息的地方就只需要填自己做好的信息就可以。另外密码最好用密码管理器,所有网站的密码都使用随机字符,保存密码的设备最好用硬件Key,而且方便销毁的那种,以避免钓鱼事件的发生。</p>
|
||||
<h2 id="链路伪造">
|
||||
|
||||
|
||||
<a href="#链路伪造"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 链路伪造
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>在上述情况我们可以很明显的看出来除了自己泄露的隐私信息,还有很大一部分是由于主动访问导致的,这种情况倒是也有很多解决办法,比较常见的就是使用代理,当然一层代理不行,一层代理实际上对于ISP来说跟没挂差不多,很轻松就能关联起来,要挂至少得两层以上,这样访问时的IP才能和实际上使用的IP脱钩,不然运营商一查目标网站访问IP的访问者,一看流量就知道是谁在访问了。 </p><p>
|
||||
当然像我们这种没什么钱的人想整多层代理还是比较困难的,毕竟一台服务器不便宜,这时候我们可以用Cloudflare做中间那一层(虽然Cloudflare想追踪也很容易),这样ISP的追踪就很困难了,基本上就只能查到用户正在访问Cloudflare下保护的网站,其他什么也不知道。 </p><p>
|
||||
如果连服务器都没有也可以用Tor,这个网络就相当于是一个社区维护的多层代理了,通常因为用的人多,所以安全性可能比自己搭的还要好。当然如果有条件的话可以自己的服务器和Tor叠起来用,这样还能避免某些网站歧视Tor出口节点以及可能会遇到蜜罐节点的问题。其实相比之下I2P要更加安全,但是体验……实在是有点拉跨,再怎么隐私我们也得考虑一下体验问题。 </p><p>
|
||||
另外再希望安全些的话最好买用于当代理的服务器时也挂上Tor,付款的时候使用数字货币,以避免服务器商出卖或者信息泄露的问题。
|
||||
还有一个很重要的问题就是DNS和SNI,想要解决这个问题,首先DNS也得过代理,不过也行,还有一种叫做DoH的DNS也可以在一定程度上保证安全,至少运营商看不到了,但是DoH的服务商还是能看到,所以还是都过代理比较好。SNI的话主要是现在有些网站它不支持像ESNI或者ECH啥的所以没办法,反正只要出口节点不要关联到自己就行。另外代理最好使用透明代理,而不是系统代理,因为有些软件它不想走代理,比如在使用带有穿透的功能,像直播或者语音电话啥的如果过网站服务器比较费流量,所以为了避免因为这些情况导致的代理失效,使用透明代理是更好的选择。</p>
|
||||
<h2 id="行为伪造">
|
||||
|
||||
|
||||
<a href="#行为伪造"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 行为伪造
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>这里算是比较复杂的部分了,因为要做到这一点可能成本会更高。为了防止网站管理员获知访问者的行为,我们一般除了上述的操作外还要做一些别的操作,比如需要使用纯净的系统,并且在这个系统上不能够操作任何与现实有关的事情,而且随时都要挂着透明代理,一旦做了不正确的操作一定要及时销毁。据说Subgraph OS就挺好的(最好不要用Windows),有些时候管理员可以通过你不细心的地方发现你的关联性,所以最好用虚拟机或者另外的物理机,我的意见是用树莓派就挺好,系统装TF卡里,有必要的时候把卡直接拔出来一折就销毁掉了,非常的方便,内存用打火机稍微烤一下数据就消失了(危)。 </p><p>
|
||||
用了上面的方式已经可以避免访问环境造成的隐私泄露了,但还有一个是时间,比如我要发布一个东西,时间一般来说是我按下发布按钮时就会发布,但是这样如果有人从你家窗口看到你按下回车的瞬间文章就出现在了他的屏幕上,那不就很轻松的发现了你与发布的东西的关联性了嘛,所以如果真的要考虑的话时间问题也很重要,比如我想在发送这篇文章的时候不想让别人知道我什么时候发送的,我可以在我的服务器上写一个脚本,当它在某个时间点时在自动commit&push上来,这样大伙就不知道我发送的具体时间了。评论也是差不多的道理,只是操作更复杂一些,有可能会用到浏览器自动化工具,就是操作起来更麻烦一些。</p>
|
||||
<h1 id="总结">
|
||||
|
||||
|
||||
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>从上面来看想搞比较完美的隐私还是很困难的,所以全程隐私基本上在地球上不太现实。如果只是希望在发布或查看某些信息时需要隐私就可以用到以上方案了,我们可以编一个身份,拿树莓派安装个自己喜欢的Linux系统去个咖啡厅连上公共WiFi在上面用数字货币挂着Tor在服务器商买个VPS然后用Tor连上去在上面再搭个代理,再用这个Tor+代理去访问网站,用编好的身份注册,看好想发布的位置再用VPS写个脚本选个喜欢的时间通过自动化脚本把想说的话发出去,有必要的时候再随手找个焚烧炉把树莓派丢进去销毁,我们的隐私行动就完满结束啦😂。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BD%91%E7%BB%9C"><em>网络</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E9%9A%90%E7%A7%81"><em>隐私</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-07-16-privacy.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/07/16/privacy.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/07/03/fast-ver.html">
|
||||
上一篇:关于字节跳动旗下某些“极速版”软件的探索
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/08/15/cdn-verify.html">
|
||||
下一篇:如何避免Cloudflare背后的源站被恶意访问
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/07/16/privacy', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/07/16/privacy.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
324
2022/08/15/cdn-verify.html
Normal file
324
2022/08/15/cdn-verify.html
Normal file
@@ -0,0 +1,324 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>如何避免Cloudflare背后的源站被恶意访问 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="如何避免Cloudflare背后的源站被恶意访问" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="Cloudflare还是非常完善的,只是我们不会用!" />
|
||||
<meta property="og:description" content="Cloudflare还是非常完善的,只是我们不会用!" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-08-15T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="如何避免Cloudflare背后的源站被恶意访问" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-08-15T00:00:00+08:00","datePublished":"2022-08-15T00:00:00+08:00","description":"Cloudflare还是非常完善的,只是我们不会用!","headline":"如何避免Cloudflare背后的源站被恶意访问","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/08/15/cdn-verify.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/08/15/cdn-verify.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/08/15/cdn-verify.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-08-15T00:00:00+08:00">15 August 2022</time> - 字数统计:1295 - 阅读大约需要4分钟 - Hits: <span id="/2022/08/15/cdn-verify.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">如何避免Cloudflare背后的源站被恶意访问</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Mon, 15 Aug 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者如何避免Cloudflare源站被恶意访问的问题。作者最初通过防火墙白名单进行防护,但随着Cloudflare功能的增加,这种方法不可靠。作者发现双向认证的“经过身份验证的源服务器拉取”功能可以有效防止使用Cloudflare功能绕过WAF的请求,通过SSL验证确保只有Cloudflare和授权的服务器能访问源站。作者建议Cloudflare在新手教程中增加此配置以提高用户的安全意识。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#关于防火墙白名单的缺陷">关于防火墙白名单的缺陷</a></li><li><a href="#解决方法">解决方法</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>Cloudflare还是非常完善的,只是我们不会用!<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>很久以前我写过一篇文章是介绍关于<a href="/2019/05/03/origip.html">如何简单的找到Cloudflare背后源站IP</a>的文章。虽然当时的我知道设置了防火墙白名单可以有效的解决这类问题。 </p><p>
|
||||
不过随着Cloudflare的业务越来越广泛,设置白名单这种方法我感觉已经很不靠谱了。而且最近也遇到一个问题,就是花火学园的用户有些人会使用自动签到的脚本,比如<a href="https://github.com/LovesAsuna/ForumSignin">ForumSignin</a>,使用这种脚本破坏了大家公平竞争的原则。虽然我用Cloudflare WAF写了一个很简单的规则解决掉了这个问题,但是万一有人悄悄的绕过了Cloudflare直接访问源站的方式签到那我设置的防火墙就没有一点点用处了。今天正好看到了Cloudflare的双向认证的功能,配置好之后也正好分享一下。</p>
|
||||
<h1 id="关于防火墙白名单的缺陷">
|
||||
|
||||
|
||||
<a href="#关于防火墙白名单的缺陷"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 关于防火墙白名单的缺陷
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>我们现在已经知道了Cloudflare除了本身CDN的业务外还加了很多花里胡哨的功能,比如Workers,WARP之类的,这些功能有一个特点就是能利用Cloudflare自己的IP来任意发起请求,那防火墙本来就是通过检测访问的IP是不是来自Cloudflare这种方式来判断,那如果能使用这些功能来向我的源站发起请求不就可以绕过WAF了嘛。</p>
|
||||
<h1 id="解决方法">
|
||||
|
||||
|
||||
<a href="#解决方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 解决方法
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>以前我的想法是如果Cloudflare能发送一个只有我和Cloudflare知道的请求头那不就可以了嘛,比如Token啥的,但是我没在Cloudflare上发现这个功能。不过今天又没事看了看Cloudflare的功能,发现居然有个叫做“经过身份验证的源服务器拉取”功能,看了看<a href="https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/explanation/">功能解释</a>,原来这是通过双向认证实现的,这配置起来也非常的简单,所以就按照<a href="https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/set-up">配置文档</a>的说明设置了。 </p><p>
|
||||
如果看不懂英文,我大概解释一下,首先下载<a href="https://developers.cloudflare.com/ssl/static/authenticated_origin_pull_ca.pem">Cloudflare 客户端CA</a>,如果是Apache服务器就直接在配置文件里面写:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SSLVerifyClient require
|
||||
SSLVerifyDepth 1
|
||||
SSLCACertificateFile /path/to/authenticated_origin_pull_ca.pem
|
||||
</code></pre></div></div>
|
||||
<p>不过Nginx使用这个功能貌似要crt格式的证书,可以执行<code class="language-plaintext highlighter-rouge">openssl x509 -in authenticated_origin_pull_ca.pem -out cloudflare.crt</code>获得crt证书,然后再配置:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssl_client_certificate /etc/nginx/certs/cloudflare.crt;
|
||||
ssl_verify_client on;
|
||||
</code></pre></div></div>
|
||||
<p>就可以了。 </p><p>
|
||||
设置完之后,如果我不开“经过身份验证的源服务器拉取”的功能,就会报“400 Bad Request, No required SSL certificate was sent”的错误,这个效果我非常的满意,这样即使其他人通过比如Workers,WARP之类的功能去请求我的源站IP,也会因为没有Cloudflare的私钥而无法访问,就可以完全避免通过源站IP来绕过WAF这种问题。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>不过这个配置实在是不够显眼,希望Cloudflare能把它放到新手教程里面,让更多人避免因为源站IP泄露导致的安全问题。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Cloudflare"><em>Cloudflare</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=CDN"><em>CDN</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%AE%89%E5%85%A8"><em>安全</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-08-15-cdn-verify.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/08/15/cdn-verify.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/07/16/privacy.html">
|
||||
上一篇:关于在网络中隐私的研究
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/09/05/trayicon.html">
|
||||
下一篇:制作程序运行提示标志的历程
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/08/15/cdn-verify', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/08/15/cdn-verify.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
472
2022/09/05/trayicon.html
Normal file
472
2022/09/05/trayicon.html
Normal file
@@ -0,0 +1,472 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>制作程序运行提示标志的历程 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="制作程序运行提示标志的历程" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="有图形界面的程序可真是难做啊……" />
|
||||
<meta property="og:description" content="有图形界面的程序可真是难做啊……" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-09-05T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="制作程序运行提示标志的历程" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-09-05T00:00:00+08:00","datePublished":"2022-09-05T00:00:00+08:00","description":"有图形界面的程序可真是难做啊……","headline":"制作程序运行提示标志的历程","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/09/05/trayicon.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/09/05/trayicon.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/09/05/trayicon.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-09-05T00:00:00+08:00">5 September 2022</time> - 字数统计:4273 - 阅读大约需要14分钟 - Hits: <span id="/2022/09/05/trayicon.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">制作程序运行提示标志的历程</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Mon, 05 Sep 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者从使用Python的PyQt5库制作程序运行提示图标,遇到体积过大问题,到尝试Pystray库,结果依然不理想,再到最终选择Tkinter和PyQt5实现跨平台悬浮图标过程中的经历。作者在寻求轻量级解决方案时,虽然Tkinter在Windows上表现尚可但在Linux上遇到透明度问题,而Qt5虽能提供跨平台一致性,但学习和使用起来较为复杂。作者对跨平台开发的复杂性以及选择不同工具的权衡有了深入的认识。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#制作的历程">制作的历程</a><ul><li><a href="#使用托盘区图标">使用托盘区图标</a><ul><li><a href="#使用pyqt5库实现">使用PyQt5库实现</a></li><li><a href="#使用pystray库实现">使用pystray库实现</a></li></ul></li><li><a href="#制作悬浮图标">制作悬浮图标</a><ul><li><a href="#通过tkinter实现">通过Tkinter实现</a></li><li><a href="#使用pyqt5库实现-1">使用PyQt5库实现</a></li></ul></li></ul></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>有图形界面的程序可真是难做啊……<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>最近我做了一个程序,类似于守护进程那样的一个用Python制作的脚本。脚本做出来很简单,可是我做出来之后需要向其他人证明我做的脚本正在运行,而且是给一个不懂电脑的人知道。在这个前提下我不可能让其他人去看任务管理器、或者执行<code class="language-plaintext highlighter-rouge">ps -ef | grep xxx</code>这种东西吧。所以还是得让它在运行的时候在桌面这样的图形界面显示一些东西才行。</p>
|
||||
<h1 id="制作的历程">
|
||||
|
||||
|
||||
<a href="#制作的历程"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 制作的历程
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<h2 id="使用托盘区图标">
|
||||
|
||||
|
||||
<a href="#使用托盘区图标"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用托盘区图标
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>像一般的后台程序证明自己存在的方式就是任务栏的托盘区显示一个图标。于是首先我就按照这个想法先用PyQt5然后在网上找了一段代码然后自己改了改:</p>
|
||||
<h3 id="使用pyqt5库实现">
|
||||
|
||||
|
||||
<a href="#使用pyqt5库实现"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用PyQt5库实现
|
||||
|
||||
|
||||
</h3>
|
||||
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="kn">from</span> <span class="nn">PyQt5</span> <span class="kn">import</span> <span class="n">QtCore</span><span class="p">,</span> <span class="n">QtGui</span><span class="p">,</span> <span class="n">QtWidgets</span>
|
||||
<span class="kn">from</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="n">Thread</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">SystemTrayIcon</span><span class="p">(</span><span class="n">QtWidgets</span><span class="p">.</span><span class="n">QSystemTrayIcon</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">icon</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
|
||||
<span class="n">QtWidgets</span><span class="p">.</span><span class="n">QSystemTrayIcon</span><span class="p">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">icon</span><span class="p">,</span> <span class="n">parent</span><span class="p">)</span>
|
||||
|
||||
<span class="n">app</span> <span class="o">=</span> <span class="n">QtWidgets</span><span class="p">.</span><span class="n">QApplication</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">)</span>
|
||||
|
||||
<span class="n">w</span> <span class="o">=</span> <span class="n">QtWidgets</span><span class="p">.</span><span class="n">QWidget</span><span class="p">()</span>
|
||||
<span class="n">trayIcon</span> <span class="o">=</span> <span class="n">SystemTrayIcon</span><span class="p">(</span><span class="n">QtGui</span><span class="p">.</span><span class="n">QIcon</span><span class="p">(</span><span class="s">"pic.ico"</span><span class="p">),</span> <span class="n">w</span><span class="p">)</span>
|
||||
<span class="n">trayIcon</span><span class="p">.</span><span class="n">show</span><span class="p">()</span>
|
||||
<span class="n">Thread</span><span class="p">(</span><span class="n">target</span><span class="o">=</span><span class="n">some_random_function</span><span class="p">).</span><span class="n">start</span><span class="p">()</span> <span class="c1"># 我的脚本函数
|
||||
</span><span class="n">sys</span><span class="p">.</span><span class="nb">exit</span><span class="p">(</span><span class="n">app</span><span class="p">.</span><span class="n">exec_</span><span class="p">())</span>
|
||||
</code></pre></div></div>
|
||||
<p>这样做完之后东西确实可以运行了,不过我的代码还要在其他人的电脑上运行,所以我先用Pyinstaller打包了一下,不过打包出来的程序很大,就几十行代码就算加上Python解析器最多也就不到10MiB,结果这加上PyQt库之后直接上升到40MiB左右,就算用upx压缩完也有30多MiB,实在是让人无法忍受,于是我就考虑看看能不能用其他方式来制作这个图标。 </p><p>
|
||||
后来我在网上找到有一个叫做pystray的库似乎是专门干这个活的。那既然是专门干这个的那大小肯定比什么Qt库要小得多吧?于是我按照示例的代码随便写了一段:</p>
|
||||
<h3 id="使用pystray库实现">
|
||||
|
||||
|
||||
<a href="#使用pystray库实现"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用pystray库实现
|
||||
|
||||
|
||||
</h3>
|
||||
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">from</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="n">Thread</span>
|
||||
<span class="kn">import</span> <span class="nn">pystray</span>
|
||||
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
|
||||
|
||||
<span class="n">image</span> <span class="o">=</span> <span class="n">Image</span><span class="p">.</span><span class="nb">open</span><span class="p">(</span><span class="s">"pic.png"</span><span class="p">)</span>
|
||||
<span class="n">icon</span> <span class="o">=</span> <span class="n">pystray</span><span class="p">.</span><span class="n">Icon</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">"SomeRandom"</span><span class="p">,</span> <span class="n">icon</span><span class="o">=</span><span class="n">image</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s">"SomeRandom"</span><span class="p">,</span> <span class="n">menu</span><span class="o">=</span><span class="bp">None</span><span class="p">)</span>
|
||||
|
||||
<span class="n">Thread</span><span class="p">(</span><span class="n">target</span><span class="o">=</span><span class="n">some_random_function</span><span class="p">).</span><span class="n">start</span><span class="p">()</span> <span class="c1"># 我的脚本函数
|
||||
</span><span class="n">icon</span><span class="p">.</span><span class="n">run</span><span class="p">()</span>
|
||||
</code></pre></div></div>
|
||||
<p>这个代码我没有测试过,不过在我写完之后首先用Pyinstaller打包了一下,结果大小比用PyQt5还要大😂,打包完大小要60多MiB,所以没办法我就只能继续用Qt的那个版本了……</p>
|
||||
<h2 id="制作悬浮图标">
|
||||
|
||||
|
||||
<a href="#制作悬浮图标"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 制作悬浮图标
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>后来我的脚本由于应用面广泛需要在Ubuntu上使用,最新的Ubuntu使用的GNOME桌面<a href="https://blogs.gnome.org/aday/2017/08/31/status-icons-and-gnome/">不再支持托盘区</a>了😓,所以没办法,只能想别的办法了。 </p><p>
|
||||
现在的程序除了托盘区图标证明自己的存在可能还有就是悬浮球了吧?国产很多软件喜欢把自己程序整成悬浮球那样放在桌面上吸引用户的注意力,所以我的程序也要这样搞。我想了想用PyQt库实在是太重了,我想整个轻量的图形引擎,像Python自带的Tkinter就挺不错的,所以我首先用Tkinter做了一个版本出来:</p>
|
||||
<h3 id="通过tkinter实现">
|
||||
|
||||
|
||||
<a href="#通过tkinter实现"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 通过Tkinter实现
|
||||
|
||||
|
||||
</h3>
|
||||
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">tkinter</span>
|
||||
<span class="kn">from</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="n">Thread</span>
|
||||
|
||||
<span class="n">root</span> <span class="o">=</span> <span class="n">tkinter</span><span class="p">.</span><span class="n">Tk</span><span class="p">()</span>
|
||||
<span class="n">height</span> <span class="o">=</span> <span class="mi">100</span>
|
||||
<span class="n">width</span> <span class="o">=</span> <span class="mi">100</span>
|
||||
<span class="n">root</span><span class="p">.</span><span class="n">overrideredirect</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
|
||||
<span class="n">root</span><span class="p">.</span><span class="n">attributes</span><span class="p">(</span><span class="s">'-transparentcolor'</span><span class="p">,</span> <span class="s">"white"</span><span class="p">)</span>
|
||||
<span class="n">root</span><span class="p">.</span><span class="n">attributes</span><span class="p">(</span><span class="s">"-alpha"</span><span class="p">,</span> <span class="mf">0.9</span><span class="p">)</span> <span class="c1"># 窗口透明度10 %
|
||||
</span><span class="n">root</span><span class="p">.</span><span class="n">attributes</span><span class="p">(</span><span class="s">"-topmost"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">root</span><span class="p">.</span><span class="n">geometry</span><span class="p">(</span><span class="sa">f</span><span class="s">"</span><span class="si">{</span><span class="n">height</span><span class="si">}</span><span class="s">x</span><span class="si">{</span><span class="n">width</span><span class="si">}</span><span class="s">-40+60"</span><span class="p">)</span>
|
||||
<span class="n">canvas</span> <span class="o">=</span> <span class="n">tkinter</span><span class="p">.</span><span class="n">Canvas</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="n">height</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="n">width</span><span class="p">,</span> <span class="n">bg</span><span class="o">=</span><span class="s">"white"</span><span class="p">)</span>
|
||||
<span class="n">canvas</span><span class="p">.</span><span class="n">config</span><span class="p">(</span><span class="n">highlightthickness</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
|
||||
<span class="n">image_file</span> <span class="o">=</span> <span class="n">tkinter</span><span class="p">.</span><span class="n">PhotoImage</span><span class="p">(</span><span class="nb">file</span><span class="o">=</span><span class="sa">r</span><span class="s">'pic.png'</span><span class="p">)</span>
|
||||
<span class="n">image</span> <span class="o">=</span> <span class="n">canvas</span><span class="p">.</span><span class="n">create_image</span><span class="p">(</span>
|
||||
<span class="n">height</span><span class="o">//</span><span class="mi">2</span><span class="p">,</span> <span class="n">width</span><span class="o">//</span><span class="mi">2</span><span class="p">,</span> <span class="n">anchor</span><span class="o">=</span><span class="n">tkinter</span><span class="p">.</span><span class="n">CENTER</span><span class="p">,</span> <span class="n">image</span><span class="o">=</span><span class="n">image_file</span><span class="p">)</span>
|
||||
<span class="n">canvas</span><span class="p">.</span><span class="n">pack</span><span class="p">()</span>
|
||||
<span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span>
|
||||
|
||||
<span class="n">show_menu</span> <span class="o">=</span> <span class="n">tkinter</span><span class="p">.</span><span class="n">Menu</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="n">tearoff</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
|
||||
<span class="n">show_menu</span><span class="p">.</span><span class="n">add_command</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s">"SomeRandom"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">move</span><span class="p">(</span><span class="n">event</span><span class="p">):</span>
|
||||
<span class="k">global</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
|
||||
<span class="n">new_x</span> <span class="o">=</span> <span class="p">(</span><span class="n">event</span><span class="p">.</span><span class="n">x</span><span class="o">-</span><span class="n">x</span><span class="p">)</span><span class="o">+</span><span class="n">root</span><span class="p">.</span><span class="n">winfo_x</span><span class="p">()</span><span class="o">-</span><span class="n">height</span><span class="o">//</span><span class="mi">2</span>
|
||||
<span class="n">new_y</span> <span class="o">=</span> <span class="p">(</span><span class="n">event</span><span class="p">.</span><span class="n">y</span><span class="o">-</span><span class="n">y</span><span class="p">)</span><span class="o">+</span><span class="n">root</span><span class="p">.</span><span class="n">winfo_y</span><span class="p">()</span><span class="o">-</span><span class="n">width</span><span class="o">//</span><span class="mi">2</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="sa">f</span><span class="s">"</span><span class="si">{</span><span class="n">height</span><span class="si">}</span><span class="s">x</span><span class="si">{</span><span class="n">width</span><span class="si">}</span><span class="s">+"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">new_x</span><span class="p">)</span><span class="o">+</span><span class="s">"+"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">new_y</span><span class="p">)</span>
|
||||
<span class="n">root</span><span class="p">.</span><span class="n">geometry</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
|
||||
|
||||
<span class="n">canvas</span><span class="p">.</span><span class="n">bind</span><span class="p">(</span><span class="s">"<B1-Motion>"</span><span class="p">,</span> <span class="n">move</span><span class="p">)</span>
|
||||
<span class="n">canvas</span><span class="p">.</span><span class="n">bind</span><span class="p">(</span><span class="s">"<Enter>"</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">event</span><span class="p">:</span> <span class="n">show_menu</span><span class="p">.</span><span class="n">post</span><span class="p">(</span><span class="n">event</span><span class="p">.</span><span class="n">x_root</span><span class="p">,</span> <span class="n">event</span><span class="p">.</span><span class="n">y_root</span><span class="p">))</span>
|
||||
<span class="n">canvas</span><span class="p">.</span><span class="n">bind</span><span class="p">(</span><span class="s">"<Leave>"</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">show_menu</span><span class="p">.</span><span class="n">unpost</span><span class="p">())</span>
|
||||
|
||||
<span class="n">Thread</span><span class="p">(</span><span class="n">target</span><span class="o">=</span><span class="n">some_random_function</span><span class="p">).</span><span class="n">start</span><span class="p">()</span> <span class="c1"># 我的脚本函数
|
||||
</span>
|
||||
<span class="n">root</span><span class="p">.</span><span class="n">mainloop</span><span class="p">()</span>
|
||||
</code></pre></div></div>
|
||||
<p>这个代码在Windows上工作还算可以,问题不是很多,但是在Linux上就出现了很糟糕的问题,根据tcl/tk <a href="https://wiki.tcl-lang.org/page/wm+attributes">documentation</a> <del>好像也没写🤣</del> ,“-transparentcolor”属性只能在Windows等系统使用(貌似MacOS也能用?),因此在Linux中会报错。如果不能使用透明背景效果就会很差,我看Stack Overflow上有人说可以安装一个pqiv图片查看器,然后使用<code class="language-plaintext highlighter-rouge">os.popen()</code>或者<code class="language-plaintext highlighter-rouge">subprocess.Popen()</code>执行<code class="language-plaintext highlighter-rouge">pqiv -c -c -i pic.png</code>也能达到类似的效果,不过这种东西先不说还要安装,而且这个东西点两下就能看见它的窗口,还能关闭,那肯定是不符合我们的要求的。所以没办法……只能再考虑Qt的办法了。</p>
|
||||
<h3 id="使用pyqt5库实现-1">
|
||||
|
||||
|
||||
<a href="#使用pyqt5库实现-1"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用PyQt5库实现
|
||||
|
||||
|
||||
</h3>
|
||||
|
||||
<p>我在网上又找了些资料把PyQt的版本也做出来了,而且还加了支持Gif动态图片的效果:</p>
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="kn">from</span> <span class="nn">PyQt5.QtWidgets</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
<span class="kn">from</span> <span class="nn">PyQt5.QtGui</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
<span class="kn">from</span> <span class="nn">PyQt5.QtCore</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">Example</span><span class="p">(</span><span class="n">QWidget</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">().</span><span class="n">__init__</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">initUI</span><span class="p">()</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">mouseMoveEvent</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">QMouseEvent</span><span class="p">):</span> <span class="c1"># 重写移动事件
|
||||
</span> <span class="k">if</span> <span class="bp">self</span><span class="p">.</span><span class="n">_tracking</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">_endPos</span> <span class="o">=</span> <span class="n">e</span><span class="p">.</span><span class="n">pos</span><span class="p">()</span> <span class="o">-</span> <span class="bp">self</span><span class="p">.</span><span class="n">_startPos</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">move</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">pos</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="p">.</span><span class="n">_endPos</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">mousePressEvent</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">QMouseEvent</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">e</span><span class="p">.</span><span class="n">button</span><span class="p">()</span> <span class="o">==</span> <span class="n">Qt</span><span class="p">.</span><span class="n">LeftButton</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">_startPos</span> <span class="o">=</span> <span class="n">QPoint</span><span class="p">(</span><span class="n">e</span><span class="p">.</span><span class="n">x</span><span class="p">(),</span> <span class="n">e</span><span class="p">.</span><span class="n">y</span><span class="p">())</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">_tracking</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">mouseReleaseEvent</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="n">QMouseEvent</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">e</span><span class="p">.</span><span class="n">button</span><span class="p">()</span> <span class="o">==</span> <span class="n">Qt</span><span class="p">.</span><span class="n">LeftButton</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">_tracking</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">_startPos</span> <span class="o">=</span> <span class="bp">None</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">_endPos</span> <span class="o">=</span> <span class="bp">None</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">initUI</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">layout</span> <span class="o">=</span> <span class="n">QStackedLayout</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">lbl1</span> <span class="o">=</span> <span class="n">QLabel</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">movie</span> <span class="o">=</span> <span class="n">QMovie</span><span class="p">(</span><span class="s">"pic.gif"</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">lbl1</span><span class="p">.</span><span class="n">setMovie</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">movie</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">movie</span><span class="p">.</span><span class="n">start</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">lbl1</span><span class="p">.</span><span class="n">setToolTip</span><span class="p">(</span><span class="s">"SomeRandom"</span><span class="p">)</span>
|
||||
<span class="n">layout</span><span class="p">.</span><span class="n">addWidget</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">lbl1</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">setAttribute</span><span class="p">(</span><span class="n">Qt</span><span class="p">.</span><span class="n">WA_TranslucentBackground</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">setWindowFlags</span><span class="p">(</span><span class="n">Qt</span><span class="p">.</span><span class="n">WindowStaysOnTopHint</span> <span class="o">|</span> <span class="n">Qt</span><span class="p">.</span><span class="n">FramelessWindowHint</span> <span class="o">|</span> <span class="n">Qt</span><span class="p">.</span><span class="n">Tool</span><span class="p">)</span>
|
||||
|
||||
<span class="c1">#layout area for widgets
|
||||
</span> <span class="n">layout</span><span class="p">.</span><span class="n">setCurrentIndex</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">setLayout</span><span class="p">(</span><span class="n">layout</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">setGeometry</span><span class="p">(</span><span class="n">QApplication</span><span class="p">.</span><span class="n">desktop</span><span class="p">().</span><span class="n">width</span><span class="p">()</span><span class="o">-</span><span class="mi">130</span><span class="p">,</span><span class="mi">50</span><span class="p">,</span><span class="mi">100</span><span class="p">,</span><span class="mi">100</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">show</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">'__main__'</span><span class="p">:</span>
|
||||
<span class="n">app</span> <span class="o">=</span> <span class="n">QApplication</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">)</span>
|
||||
<span class="n">Thread</span><span class="p">(</span><span class="n">target</span><span class="o">=</span><span class="n">some_random_function</span><span class="p">).</span><span class="n">start</span><span class="p">()</span> <span class="c1"># 我的脚本函数
|
||||
</span> <span class="n">ex</span> <span class="o">=</span> <span class="n">Example</span><span class="p">()</span>
|
||||
<span class="n">sys</span><span class="p">.</span><span class="nb">exit</span><span class="p">(</span><span class="n">app</span><span class="p">.</span><span class="n">exec_</span><span class="p">())</span>
|
||||
</code></pre></div></div>
|
||||
<p>最终做出来效果还不错,说不定加点功能放组简单的立绘动画就能做一个像我博客左下角的看板娘一样的东西呢🤣,虽然我也见过用Electron写的<a href="https://github.com/zenghongtu/PPet">PPet</a>,不过用Python写的话可能对更多人更友好吧 <del>(Gif哪能和Live2D比😂)</del> 。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>这次做这么一个Python程序运行的提示标志还真是复杂啊,尤其是为了跨平台,其实专门对应一个平台做起来可能也没有很复杂,不过想能在各个平台上都能使用还是挺难的。这次来看Qt的跨平台性确实很强,无论是在哪个平台上都能获得不错的体验,就是用起来感觉比较麻烦,其实说来如果能用C++之类的语言去开发Qt程序应该更好,Python这个基本上也就只能当作一个玩具算是熟悉一下Qt的各种功能了。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Python"><em>Python</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%A8%8B%E5%BA%8F"><em>程序</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%A0%87%E5%BF%97"><em>标志</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-09-05-trayicon.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/09/05/trayicon.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/08/15/cdn-verify.html">
|
||||
上一篇:如何避免Cloudflare背后的源站被恶意访问
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/09/21/cron.html">
|
||||
下一篇:使用Python制作可热载的定时调度器
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/09/05/trayicon', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/09/05/trayicon.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
383
2022/09/21/cron.html
Normal file
383
2022/09/21/cron.html
Normal file
@@ -0,0 +1,383 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>使用Python制作可热载的定时调度器 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="使用Python制作可热载的定时调度器" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="定时任务用CRON难道不够吗?" />
|
||||
<meta property="og:description" content="定时任务用CRON难道不够吗?" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-09-21T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="使用Python制作可热载的定时调度器" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-09-21T00:00:00+08:00","datePublished":"2022-09-21T00:00:00+08:00","description":"定时任务用CRON难道不够吗?","headline":"使用Python制作可热载的定时调度器","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/09/21/cron.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/09/21/cron.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/09/21/cron.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-09-21T00:00:00+08:00">21 September 2022</time> - 字数统计:2238 - 阅读大约需要8分钟 - Hits: <span id="/2022/09/21/cron.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">使用Python制作可热载的定时调度器</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Wed, 21 Sep 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章介绍了如何使用Python制作一个可热载的定时调度器,作者开始时考虑了使用CRON表达式,但发现它不够直观且不支持Windows。接着,作者发现了schedule库,用其以更自然的语言结构编写定时任务,比APScheduler易于理解和使用。在创建调度器时,作者开始用轮询监控文件变化,但性能不佳,转而引入了watchdog库以提高监测效率。通过FileEventHandler和Observer,程序可以实时检测并重载修改的脚本。作者以一个简单的示例脚本和管理器函数阐述了整个过程,并表达了对编写简洁、功能单一的程序的偏好。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#探索过程">探索过程</a></li><li><a href="#代码">代码</a><ul><li><a href="#管理器">管理器</a></li><li><a href="#被管理脚本示例">被管理脚本示例</a></li></ul></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>定时任务用CRON难道不够吗?<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>最近因为写的Python脚本比较多,另外也有好多脚本都是定时运行的脚本,然后Linux自带的CRON可能不是很直观,不然为什么那么多人开发CRON表达式生成器😂,另外CRON不能和脚本绑定到一起,也不能在Windows上使用,所以就想用Python来实现一个。 </p><p>
|
||||
当然如果只是想用Python为一个程序做一个定时任务还是很简单的,不想用CRON也能直接用一个死循环if判断时间来做,比如想要每小时什么时候执行,那就不停的判断,直到那个时间到了以后然后去执行就好了。不过很多个脚本都用这种方法的话就显得太凌乱了,想要停止哪个脚本还不太好整,所以写一个定时调度器来统一管理所有的定时脚本也许会更好一些。</p>
|
||||
<h1 id="探索过程">
|
||||
|
||||
|
||||
<a href="#探索过程"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 探索过程
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>其实我最开始是想着把CRON表达式放到脚本里,然后让管理器像配置文件那样读取它,不过我自己解析CRON表达式有点麻烦,一时也没找到好的办法。不过在找这个东西的时候找到了一个有意思的库,叫做<a href="https://github.com/dbader/schedule">schedule</a>,用pip就能安装。它可以用类似自然语言的语法结构去写定时语句,看起来很有意思,于是我就打算用这个库来写我的调度器。 </p><p>
|
||||
写它不算很复杂,这个库还是挺方便理解的,比据说Python常用的什么APScheduler那个库好用多了,那个玩意看着就不怎么人性化。功能很快就写好了,但是有个问题,就是既然我要写一个可以热载(自动重加载)的调度器,用什么办法监视文件比较好呢?最开始我实现的时候是想着用列出目录和stat方法来读取文件的元数据,然后轮询,如果内容有变化就进行重载。不过这样写起来也麻烦,准确来说也不算准确,而且性能也不怎么好,还要轮询,文件一多整个程序的执行效率就会变低。然后我想着之前我用的Django好像就有这样的功能,它到底用的是什么方法呢?一般我们运行Django项目的时候它第一句会写“Watching for file changes with StatReloader”,那看来StatReloader就是它用来监视文件的模块,听这名字怎么和我之前想的差不多😂,另外也没有找到叫这个名字的库,所以就算了,我还是搜一下找找别的库吧。后来我找到了一个看起来不错的库,叫做watchdog,看起来好像用法也不算很复杂,而且据说是用的内核的什么东西来监测,性能比轮询好很多,所以我就整了这个库,感觉效果还不错,可靠性也很好,文件一有修改程序就会检测到然后进行重载。</p>
|
||||
<h1 id="代码">
|
||||
|
||||
|
||||
<a href="#代码"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 代码
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<h2 id="管理器">
|
||||
|
||||
|
||||
<a href="#管理器"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 管理器
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">threading</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
<span class="kn">import</span> <span class="nn">schedule</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">importlib</span>
|
||||
<span class="kn">from</span> <span class="nn">watchdog.observers</span> <span class="kn">import</span> <span class="n">Observer</span>
|
||||
<span class="kn">from</span> <span class="nn">watchdog.events</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
|
||||
<span class="n">reload_status</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">run_threaded</span><span class="p">(</span><span class="n">job_func</span><span class="p">):</span>
|
||||
<span class="n">job_thread</span> <span class="o">=</span> <span class="n">threading</span><span class="p">.</span><span class="n">Thread</span><span class="p">(</span><span class="n">target</span><span class="o">=</span><span class="n">job_func</span><span class="p">)</span>
|
||||
<span class="n">job_thread</span><span class="p">.</span><span class="n">start</span><span class="p">()</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">FileEventHandler</span><span class="p">(</span><span class="n">FileSystemEventHandler</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">reload_status</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">reload_status</span> <span class="o">=</span> <span class="n">reload_status</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">on_any_event</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">event</span><span class="p">.</span><span class="n">is_directory</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="p">.</span><span class="n">reload_status</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
|
||||
<span class="n">observer</span> <span class="o">=</span> <span class="n">Observer</span><span class="p">()</span>
|
||||
<span class="n">event_handler</span> <span class="o">=</span> <span class="n">FileEventHandler</span><span class="p">(</span><span class="n">reload_status</span><span class="p">)</span>
|
||||
<span class="n">observer</span><span class="p">.</span><span class="n">schedule</span><span class="p">(</span><span class="n">event_handler</span><span class="p">,</span> <span class="s">"tasks"</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
|
||||
<span class="n">observer</span><span class="p">.</span><span class="n">start</span><span class="p">()</span>
|
||||
<span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
|
||||
<span class="n">reload_status</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">taskList</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">listdir</span><span class="p">(</span><span class="s">"tasks"</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="n">taskList</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="s">"__"</span> <span class="ow">in</span> <span class="n">task</span> <span class="ow">or</span> <span class="n">task</span><span class="p">.</span><span class="n">rsplit</span><span class="p">(</span><span class="s">"."</span><span class="p">,</span> <span class="mi">1</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="s">"py"</span><span class="p">:</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">importlib</span><span class="p">.</span><span class="nb">reload</span><span class="p">(</span><span class="n">importlib</span><span class="p">.</span><span class="n">import_module</span><span class="p">(</span><span class="s">"tasks."</span> <span class="o">+</span> <span class="n">task</span><span class="p">.</span><span class="n">split</span><span class="p">(</span><span class="s">"."</span><span class="p">)[</span><span class="mi">0</span><span class="p">])).</span><span class="n">run</span><span class="p">(</span><span class="n">run_threaded</span><span class="p">,</span> <span class="n">schedule</span><span class="p">)</span>
|
||||
<span class="k">except</span><span class="p">:</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"Task </span><span class="si">{</span><span class="n">task</span><span class="p">.</span><span class="n">split</span><span class="p">(</span><span class="s">'.'</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s"> import failure"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">reload_status</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="s">"Task change, reloading..."</span><span class="p">)</span>
|
||||
<span class="n">time</span><span class="p">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">schedule</span><span class="p">.</span><span class="n">clear</span><span class="p">()</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">schedule</span><span class="p">.</span><span class="n">run_pending</span><span class="p">()</span>
|
||||
<span class="n">time</span><span class="p">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
</code></pre></div></div>
|
||||
<h2 id="被管理脚本示例">
|
||||
|
||||
|
||||
<a href="#被管理脚本示例"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 被管理脚本示例
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="n">run_threaded</span><span class="p">,</span> <span class="n">schedule</span><span class="p">):</span>
|
||||
<span class="n">schedule</span><span class="p">.</span><span class="n">every</span><span class="p">().</span><span class="n">second</span><span class="p">.</span><span class="n">do</span><span class="p">(</span><span class="n">run_threaded</span><span class="p">,</span> <span class="n">job</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">job</span><span class="p">():</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="s">"The job is running."</span><span class="p">)</span>
|
||||
</code></pre></div></div>
|
||||
<p>注:脚本应该放到管理器所在文件夹下的“tasks”文件夹,具体定时的写法可以看看<a href="https://schedule.readthedocs.io/en/stable/examples.html">schedule官方示例</a>。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>感觉程序果然还是写的越简单越好,功能也是越单一越好。据说APScheduler是用Python实现的像Java的Quartz那样的东西,看着就很难受,像我这个50行写的管理器看起来还挺不错的吧😁。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Python"><em>Python</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%A8%8B%E5%BA%8F"><em>程序</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%A0%87%E5%BF%97"><em>标志</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-09-21-cron.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/09/21/cron.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/09/05/trayicon.html">
|
||||
上一篇:制作程序运行提示标志的历程
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/10/05/rules.html">
|
||||
下一篇:Cloudflare规则新功能体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/09/21/cron', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/09/21/cron.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
334
2022/10/05/rules.html
Normal file
334
2022/10/05/rules.html
Normal file
@@ -0,0 +1,334 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>Cloudflare规则新功能体验 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="Cloudflare规则新功能体验" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="Cloudflare真是良心,为广大站长节约了无数成本!♥" />
|
||||
<meta property="og:description" content="Cloudflare真是良心,为广大站长节约了无数成本!♥" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-10-05T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="Cloudflare规则新功能体验" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-10-05T00:00:00+08:00","datePublished":"2022-10-05T00:00:00+08:00","description":"Cloudflare真是良心,为广大站长节约了无数成本!♥","headline":"Cloudflare规则新功能体验","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/10/05/rules.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/10/05/rules.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/10/05/rules.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-10-05T00:00:00+08:00">5 October 2022</time> - 字数统计:2631 - 阅读大约需要8分钟 - Hits: <span id="/2022/10/05/rules.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">Cloudflare规则新功能体验</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Wed, 05 Oct 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章分享了Cloudflare新增的几个规则功能的体验,包括二级域名重定向、动态重定向和内容转换,如重写URL、请求头、响应头以及应对防盗链问题。作者赞赏Cloudflare的免费服务和强大功能,但也指出了一些限制,比如免费用户不能随意使用正则表达式,以及规则配置上的局限。作者表达了对于更自由配置的向往,但同时也认可Cloudflare在性能和实用性上的优势。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#使用体验">使用体验</a><ul><li><a href="#二级域名重定向到用户页面">二级域名重定向到用户页面</a></li><li><a href="#pixiv图片反代">Pixiv图片反代</a></li><li><a href="#iwara下载地址解析与dns解析">Iwara下载地址解析与DNS解析</a></li></ul></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>Cloudflare真是良心,为广大站长节约了无数成本!♥<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>之前登录到Cloudflare的时候看规则的时候发现了一些新功能,现在好像增加了什么转换规则,动态重定向啥的。看到之后好像还挺有意思,就试用了一下。用了一下之后发现还真不错,功能很强大,而且还免费。所以这次想说说关于Cloudflare规则新出的几个功能体验。</p>
|
||||
<h1 id="使用体验">
|
||||
|
||||
|
||||
<a href="#使用体验"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用体验
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>为了更好的描述,我就直接用实例说明了。</p>
|
||||
<h2 id="二级域名重定向到用户页面">
|
||||
|
||||
|
||||
<a href="#二级域名重定向到用户页面"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 二级域名重定向到用户页面
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>之前Telegram出了个新功能,可以直接用二级域名作为自己的Telegram名片,比如我的用户名是unmayx,在Telegram上就是 <a href="https://unmayx.t.me/">https://unmayx.t.me/</a> 。这个功能看起来还挺有意思的,所以我也想给自己的网站整一个。其实这个东西如果说自己的网站没有二级域名,直接用页面规则就可以做出来,这个功能能实现也是多亏了Cloudflare愿意让免费用户使用泛解析的代理,真是太良心了😭。首先在解析里加一条泛解析,A或者CNAME都行,目标也可以随便填。然后在页面规则里加一条URL为<code class="language-plaintext highlighter-rouge">*.example.com/*</code>这样的地址,具体域名写自己的就行,然后设置为转发URL,状态代码301或者302都行,目标URL填类似于<code class="language-plaintext highlighter-rouge">https://example.com/username-$1.html</code>,具体规则根据自己网站来,像Telegram那样的规则就可以填<code class="language-plaintext highlighter-rouge">https://t.me/$1</code>这样子 <del>(当然Telegram不可能用Cloudflare的CDN啦🤣)</del> 。 </p><p>
|
||||
不过这样设定有个问题,大多数网站不会只有一级域名,如果有二级域名而且也用了Cloudflare CDN会和规则冲突导致优先匹配规则。Cloudflare原来的页面规则比较拉跨的地方就是除了匹配URL没有别的可以操作的地方,像我要不匹配某个东西也没办法做到。还好新出的动态重定向有这样的功能,它可以匹配一串东西,比如我要不匹配某个地址,比如www开头的我可以写<code class="language-plaintext highlighter-rouge">not starts_with(http.host, "www.")</code>,反正Cloudflare的证书也没法用在三级以上的域名,这样匹配也没啥问题。另外还要除了自己,所以最终写成<code class="language-plaintext highlighter-rouge">(not starts_with(http.host, "www.") and http.host ne "example.com")</code>就可以啦,接下来就是写动态重定向到哪里了。我翻了半天<a href="https://developers.cloudflare.com/ruleset-engine/rules-language/">文档</a>发现除非用正则表达式,否则没有办法单独把<code class="language-plaintext highlighter-rouge">http.host</code>中“.”前面的东西取出来,然而正则功能不是免费的😂。 </p><p>
|
||||
但是之前用页面规则的时候也没有这个问题啊,怎么这个新功能还有这种问题……不过既然页面规则支持这个功能那我们就可以把两个结合一下,先用动态重定向接收,然后发给页面规则处理就好啦,所以我们可以把刚刚动态重定向的表达式写成一个和现有网站不冲突的地址,比如<code class="language-plaintext highlighter-rouge">concat("https://example.com/user/", http.host, "/")</code>,这时候它会先重定向到一级域名的某个位置,然后用页面规则接收一下,URL设定为<code class="language-plaintext highlighter-rouge">example.com/user/*.example.com/</code>,然后目标URL设定为<code class="language-plaintext highlighter-rouge">https://example.com/username-$1.html</code>就可以啦。</p>
|
||||
<h2 id="pixiv图片反代">
|
||||
|
||||
|
||||
<a href="#pixiv图片反代"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Pixiv图片反代
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>之前我也有搭过Pixiv的图片反代,是学着<a href="https://pixiv.re/reverseproxy.html">Pixiv圖片代理</a>的教程搭的,用的是Cloudflare Workers,不过我大概看了下代码其实我们的主要目的只是想让服务器收到可以用的Referer嘛,正好这个新出的转换规则就挺不错的,可以重写URL、请求头和响应头,那么我们这次的需求就是把请求Pixiv图片服务器的请求头改掉吧,那么我们就首先给自己的域名加一条指向i.pximg.net的CNAME解析,像我整的就是 <a href="https://pixiv.mayx.eu.org">https://pixiv.mayx.eu.org</a> ,然后添加一条修改请求头的转换规则,内容就写当<code class="language-plaintext highlighter-rouge">(http.host eq "pixiv.mayx.eu.org")</code>时,将Referer设定为 <a href="https://www.pixiv.net/">https://www.pixiv.net/</a> 就好啦(实际上好像是只要包含pixiv字样就可以)。 </p><p>
|
||||
为了让它能发挥更大的用处,我想起来我以前写的<a href="/2021/02/23/picbotpro.html">发图微信机器人</a>,这次我想整个直接在Web界面就可以用的,于是<a href="https://github.com/Mabbs/pixiv-index/blob/main/setu.html">Viewer</a>就诞生了,而且用的就是我新设定的反代,相比原来的Workers反代不仅没有了请求次数限制,而且还可以设定页面规则来设置更长时间的缓存,来达到更快的速度。</p>
|
||||
<h2 id="iwara下载地址解析与dns解析">
|
||||
|
||||
|
||||
<a href="#iwara下载地址解析与dns解析"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Iwara下载地址解析与DNS解析
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>看着这个规则我就又想起来了高中的时候写的<a href="/2019/04/13/iwara.html">Iwara Viewer</a>,因为跨域我不能直接用Web调用Iwara的API,而且当时主要是为了给服务器获取下载地址。现在我既然可以用转换规则改响应头,那相应的我就可以加一个<code class="language-plaintext highlighter-rouge">Access-Control-Allow-Origin: *</code>了吧,那这样我也可以用前端去直接调用Iwara的API了吧,所以我简单写了一个<a href="/iwara.html">Iwara Downloader</a>,因为对JavaScript不是特别熟悉,而且Iwara的目录老是出问题,所以就懒得写Viewer了。现在只要把Iwara的地址粘到输入框里,比如<a href="https://ecchi.iwara.tv/videos/jemn7sgm7wuw0oqv9">OBSERVATION DIARY</a>,就可以获取到这个视频的下载地址。不过这个东西确实有点鸡肋了😂,毕竟Iwara又不是不给你下载地址。 </p><p>
|
||||
其实我写这个还有个想法就是做在国内下载的加速器,但是那个防盗链实在是整的让人难受,它的Hash目前来看好像是由文件名,Host,过期时间和访问者IP四个值算出来的(有没有更多的我也不清楚),我要是修改了这四个中的任意一项就会403,然而Iwara的域名又被DNS污染了,首先先解决这个问题吧,Cloudflare能代理除了它本身的其他不检查Host的网站,我想了想可以反代Google DNS的DoH,这样我就可以获取到下载地址的真实IP了(顺便dns.mayx.eu.org就相当于我的DoH了)。不过获取到了也没什么用😂,如果改hosts会发现有SNI RST,直接用IP访问防盗链会检查Host字段,我也想过要不然把下载的地址再反代一下?不过因为会检查Host,那个转换规则又不能改Host,所以没办法,就先写这么个东西吧。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>Cloudflare真是良心啊,其他就算是付费CDN可能都没有这么多功能吧,而且还抗打。不过限制还是比较多的,要是能像Nginx那样随意配置该多好啊😂,不过想想也不可能,真那样估计就被大规模滥用了。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Cloudflare"><em>Cloudflare</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E8%A7%84%E5%88%99"><em>规则</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8A%9F%E8%83%BD"><em>功能</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-10-05-rules.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/10/05/rules.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/09/21/cron.html">
|
||||
上一篇:使用Python制作可热载的定时调度器
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/10/08/tinyaes.html">
|
||||
下一篇:用Python写一个超简单的加密程序
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/10/05/rules', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/10/05/rules.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
335
2022/10/08/tinyaes.html
Normal file
335
2022/10/08/tinyaes.html
Normal file
@@ -0,0 +1,335 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>用Python写一个超简单的加密程序 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="用Python写一个超简单的加密程序" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="有些冷门的库也许更容易解决问题" />
|
||||
<meta property="og:description" content="有些冷门的库也许更容易解决问题" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-10-08T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="用Python写一个超简单的加密程序" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-10-08T00:00:00+08:00","datePublished":"2022-10-08T00:00:00+08:00","description":"有些冷门的库也许更容易解决问题","headline":"用Python写一个超简单的加密程序","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/10/08/tinyaes.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/10/08/tinyaes.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/10/08/tinyaes.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-10-08T00:00:00+08:00">8 October 2022</time> - 字数统计:1699 - 阅读大约需要6分钟 - Hits: <span id="/2022/10/08/tinyaes.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">用Python写一个超简单的加密程序</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Sat, 08 Oct 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章介绍了一种使用Python编写的简单加密程序,作者发现TinyAES库非常适合对数据进行AES-128-CTR加密,因为其加密和解密方法一致,使用起来非常直观。作者通过导入MD5哈希来处理非16位长度的密码,然后举例编写了一个加密脚本,用户只需提供文件路径和密钥即可执行加密或解密。这种库相比于复杂的加密库(如pycryptodome或cryptography),被作者认为更符合Python的简洁性和易用性。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#探索">探索</a></li><li><a href="#使用方法">使用方法</a></li><li><a href="#示例">示例</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>有些冷门的库也许更容易解决问题<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>最近在写Python脚本的时候遇到一个问题,就是怎么样轻松的加密一串字符。在网上随便一搜大都是介绍的使用比如pycryptodome或者cryptography库进行加密,我以前写的一个<a href="/2020/06/13/encrypt.html">加密传输Demo</a>作业的时候就用过。不过现在总感觉看着很难受,倒不是说有多复杂,主要是这些库的算法太多了,什么AES,RSA啥的都有,而且还有一堆乱七八糟的参数,我用的时候还要去思考到底用哪个算法比较好,还要考虑有些有什么向量之类乱七八糟的。但是很多时候我只是单纯要个加密,不想去考虑这些乱七八糟的东西,那我应该怎么做比较好呢?</p>
|
||||
<h1 id="探索">
|
||||
|
||||
|
||||
<a href="#探索"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 探索
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>这时候我想起来我以前用的Pyinstaller库如果想要使用Key参数的时候会要求安装一个叫做<a href="https://pypi.org/project/tinyaes/">tinyaes</a>的库,我搜了一下这个库,网上几乎没有对这个库的介绍,没办法就只好去Github找找它<a href="https://github.com/naufraghi/tinyaes-py">源代码的仓库</a>。去看了一眼说了跟没说一样,就几句话连个示例也没有的……不过大概意思就是C也有个叫<a href="https://github.com/kokke/tiny-AES-c">tiny-AES-c</a>的库,它是在Python上对这个库做的一个简单的包装,但那个仓库里面也没有示例😂……还好tinyaes仓库里面有个测试脚本,我看了一眼又回去看了看C的库那个文档,结合“Same function for encrypting as for decrypting in CTR mode”这句话我才明白,这个tinyaes原来就用一个方法就能进行加解密了!怪不得叫“xcrypt”,就像xor加密那样,用同样的方法就可以做到加密和解密,这个仓库加密的算法是AES-128-CTR,这样我也不用费心考虑到底选什么加密算法了,使用也非常简单,非常的符合我的需求啊,可惜就是这个库不怎么出名,100个⭐都不到。</p>
|
||||
<h1 id="使用方法">
|
||||
|
||||
|
||||
<a href="#使用方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用方法
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>tinyaes的使用方法非常简单,一句话就可以搞定,而且加密和解密的代码完全一致:</p>
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">__import__</span><span class="p">(</span><span class="s">"tinyaes"</span><span class="p">).</span><span class="n">AES</span><span class="p">(</span><span class="sa">b</span><span class="s">"十六位的密码"</span><span class="p">,</span> <span class="sa">b</span><span class="s">"十六位的向量,可以不要"</span><span class="p">).</span><span class="n">CTR_xcrypt_buffer</span><span class="p">(</span><span class="sa">b</span><span class="s">"需要加密/解密的内容"</span><span class="p">)</span>
|
||||
</code></pre></div></div>
|
||||
<p>使用起来非常的简单啊,就是密码要求必须是16位的……那我要是想要一个随意位数的密码怎么办呢?我想起来MD5的hash长度好像就是16位的,所以如果想要其他位数的密码就用MD5哈希之后再用吧。</p>
|
||||
<h1 id="示例">
|
||||
|
||||
|
||||
<a href="#示例"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 示例
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>既然使用方法如此简单,我估摸了一下,如果写一个加密文件的小程序估计用不了10行,用其他的加密库我估计应该做不到吧,所以说就随手写了一个试试看,果然不到10行就写了出来,看起来非常不错。</p>
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">hashlib</span><span class="p">,</span> <span class="n">tinyaes</span><span class="p">,</span> <span class="n">sys</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">len</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
|
||||
<span class="nb">exit</span><span class="p">(</span><span class="sa">f</span><span class="s">"Usage: </span><span class="si">{</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s"> [filepath] [key]"</span><span class="p">)</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="n">tinyaes</span><span class="p">.</span><span class="n">AES</span><span class="p">(</span><span class="n">hashlib</span><span class="p">.</span><span class="n">md5</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">].</span><span class="n">encode</span><span class="p">()).</span><span class="n">digest</span><span class="p">())</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="s">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">orig</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="s">".xc"</span><span class="p">,</span> <span class="s">'wb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">enc</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">byte_block</span> <span class="ow">in</span> <span class="nb">iter</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="n">orig</span><span class="p">.</span><span class="n">read</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span> <span class="sa">b</span><span class="s">''</span><span class="p">):</span>
|
||||
<span class="n">enc</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="n">key</span><span class="p">.</span><span class="n">CTR_xcrypt_buffer</span><span class="p">(</span><span class="n">byte_block</span><span class="p">))</span>
|
||||
</code></pre></div></div>
|
||||
<p>用法很简单,比如我给这个脚本起名叫“encrypt_file.py”,我想加密就可以直接输入<code class="language-plaintext highlighter-rouge">python3 encrypt_file.py 要加密的文件.txt 密码</code>就可以了,执行完之后会生成一个“.xc”为后缀的文件,解密也一样,输入<code class="language-plaintext highlighter-rouge">python3 encrypt_file.py 要加密的文件.txt.xc 密码</code>就OK了,不过因为我这个程序并不能判断一个文件有没有加密,所以解密的时候就会给后缀再加一个“.xc”,这时候就只能手动把它去掉了。如果密码不正确,那就相当于二次加密了,解密就要按顺序依次反过来执行,很有意思。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>这样的库我感觉更符合Pythonic,用什么pycryptodome或者cryptography库写的就感觉像是Java程序那样臃肿,这种程序感觉就很直观,不用考虑那么多奇怪的东西。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Python"><em>Python</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8A%A0%E5%AF%86"><em>加密</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-10-08-tinyaes.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/10/08/tinyaes.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/10/05/rules.html">
|
||||
上一篇:Cloudflare规则新功能体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/10/14/crack-aes.html">
|
||||
下一篇:如何破解我上次写的加密程序?
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/10/08/tinyaes', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/10/08/tinyaes.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
352
2022/10/14/crack-aes.html
Normal file
352
2022/10/14/crack-aes.html
Normal file
@@ -0,0 +1,352 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>如何破解我上次写的加密程序? | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="如何破解我上次写的加密程序?" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="不按规则使用加密算法是非常不安全的!" />
|
||||
<meta property="og:description" content="不按规则使用加密算法是非常不安全的!" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-10-14T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="如何破解我上次写的加密程序?" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-10-14T00:00:00+08:00","datePublished":"2022-10-14T00:00:00+08:00","description":"不按规则使用加密算法是非常不安全的!","headline":"如何破解我上次写的加密程序?","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/10/14/crack-aes.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/10/14/crack-aes.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/10/14/crack-aes.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-10-14T00:00:00+08:00">14 October 2022</time> - 字数统计:2126 - 阅读大约需要7分钟 - Hits: <span id="/2022/10/14/crack-aes.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">如何破解我上次写的加密程序?</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Fri, 14 Oct 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者在尝试破解自己的Python加密程序时,发现使用AES-128-CTR加密模式且省略了初始化向量(iv)的情况下,加密的不安全性。作者后来了解到,CTR模式因为直接将密钥与iv通过AES加密后再异或数据,导致如果使用相同的iv和密钥加密不同的数据,通过异或运算可以轻易地从已知的密文和明文对中推断出其他密文的对应明文。为了解决这个问题,作者意识到按照官方建议添加iv并正确使用加密模式是必要的,最终调整了加密程序以确保安全性。作者也表达了一个教训,那就是在不了解的领域应遵循标准方法,否则可能会导致意想不到的问题。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#探索">探索</a></li><li><a href="#解决办法">解决办法</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>不按规则使用加密算法是非常不安全的!<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>前几天我用Python写了一个<a href="/2022/10/08/tinyaes.html">很简单的加密程序</a>,用的是tinyaes提供的AES-128-CTR加密方式,然后因为嫌麻烦没有整iv。最近几天我一直在搜关于AES中关于iv的信息,我一直没想明白那个iv到底是干啥用的。 </p><p>
|
||||
在我看了几天那些关于AES的5种加密模式之后,关于ECB和CBC的加密模式讲的很多,而对其他加密模式讲的很不清楚……但唯一写的很清楚的就是ECB很不安全,重复使用相同的密钥和iv加密数据很不安全,尤其是CTR模式,直接完全丧失了机密性😂,这不是在完全否定我前几天写的东西嘛,然而除了这些就再没有写别的了……那它到底是怎么个丧失了机密性啊,又不说清楚,所以就只好我自己想了😓。</p>
|
||||
<h1 id="探索">
|
||||
|
||||
|
||||
<a href="#探索"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 探索
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>首先我先看了看AES中5种加密模式的区别,发现CTR模式和其他模式有个不同的地方是它加密的是密码,而不是数据,它是把密码和iv通过AES加密算法加密之后把获得的东西和明文数据异或后来得到密文的,怪不得它可以加密和解密用相同的方法,原来它真的就是异或加密啊😂,那异或加密安全吗?我在网上也搜了搜,很多人说这是一种非常不安全的加密方式,只有不懂的人和刚入门密码学的人才会用,巧了,我就是不懂密码学的人😂,然而异或加密又怎么不安全网上又不说……我真的是无语了。 </p><p>
|
||||
不说我就只能自己想了……首先,他们说CTR不安全的加密仅限于相同的iv和密码去加密不同的数据,而加密的方式是通过异或,那么我们先这样去算一下: </p><p>
|
||||
K = AES(key, iv) </p><p>
|
||||
C1 = K xor P1</p><p>
|
||||
C2 = K xor P2</p><p>
|
||||
其中K是用AES加密密码和iv获得的值,C代表密文,P代表明文。然后想着想着,如果用C1 xor C2会怎么样呢?最终用异或运算律算了一下,大概明白了为什么它不安全了,因为: </p><p>
|
||||
C1 xor C2 = P1 xor P2 </p><p>
|
||||
我们知道,在这种情况下假如你用P1或P2去异或上面式子得到的值,那你就能得到另一个明文,也就是: </p><p>
|
||||
(C1 xor C2) xor P1 = P2 </p><p>
|
||||
这样你只要知道一组用这个密钥加密的密文和明文,就能破解所有其他密文了! </p><p>
|
||||
于是根据这个原理我试着用Python写了一个根据已知明文密文对获得密文的程序出来:</p>
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">sys</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">len</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">)</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span>
|
||||
<span class="nb">exit</span><span class="p">(</span><span class="sa">f</span><span class="s">"Usage: </span><span class="si">{</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s"> [enc_file1] [enc_file2] [plain_file2]"</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="s">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">enc_file1</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="s">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">enc_file2</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="s">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">plain_file2</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="s">".crack"</span><span class="p">,</span> <span class="s">"wb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">crack_file1</span><span class="p">:</span>
|
||||
<span class="n">crack_file1</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="nb">bytes</span><span class="p">(</span><span class="n">a</span> <span class="o">^</span> <span class="n">b</span> <span class="k">for</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="nb">bytes</span><span class="p">(</span><span class="n">a</span> <span class="o">^</span> <span class="n">b</span> <span class="k">for</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">enc_file1</span><span class="p">.</span><span class="n">read</span><span class="p">(),</span> <span class="n">enc_file2</span><span class="p">.</span><span class="n">read</span><span class="p">())),</span> <span class="n">plain_file2</span><span class="p">.</span><span class="n">read</span><span class="p">())))</span>
|
||||
</code></pre></div></div>
|
||||
<p>写完之后发现和加密的程序用了一样多的行数😂,试了一下,真的可以获得另外密文的对应的明文!而且是在不需要知道密码的情况,不过我不知道是我程序写的有问题还是推算的有问题,当想要破解的文件长度比已知明文密文的文件长时,破解出来的明文就只能破解到和已知明文密文一样长的位置……总之能证明之前写的加密确实“完全丧失了机密性”就行了。</p>
|
||||
<h1 id="解决办法">
|
||||
|
||||
|
||||
<a href="#解决办法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 解决办法
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>为了弥补上一篇文章写的加密程序所遇到的问题,这次我还是乖乖的按照官方说明使用iv吧,根据这个原理我重新写了一下我的程序:</p>
|
||||
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">hashlib</span><span class="p">,</span> <span class="n">tinyaes</span><span class="p">,</span> <span class="n">sys</span><span class="p">,</span> <span class="n">os</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">len</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
|
||||
<span class="nb">exit</span><span class="p">(</span><span class="sa">f</span><span class="s">"Usage: </span><span class="si">{</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s"> [filepath] [key]"</span><span class="p">)</span>
|
||||
<span class="n">enc</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">></span> <span class="mi">4</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">4</span><span class="p">:]</span> <span class="o">==</span> <span class="s">".enc"</span><span class="p">:</span>
|
||||
<span class="n">enc</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="s">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">orig</span><span class="p">:</span>
|
||||
<span class="n">iv</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">urandom</span><span class="p">(</span><span class="mi">16</span><span class="p">)</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="n">tinyaes</span><span class="p">.</span><span class="n">AES</span><span class="p">(</span><span class="n">hashlib</span><span class="p">.</span><span class="n">md5</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">].</span><span class="n">encode</span><span class="p">()).</span><span class="n">digest</span><span class="p">(),</span> <span class="n">orig</span><span class="p">.</span><span class="n">read</span><span class="p">(</span><span class="mi">16</span><span class="p">)</span> <span class="k">if</span> <span class="n">enc</span> <span class="k">else</span> <span class="n">iv</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">][:</span><span class="o">-</span><span class="mi">4</span><span class="p">]</span> <span class="k">if</span> <span class="n">enc</span> <span class="k">else</span> <span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="s">".enc"</span><span class="p">,</span> <span class="s">'wb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">targetfile</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">enc</span><span class="p">:</span>
|
||||
<span class="n">targetfile</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="n">iv</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">byte_block</span> <span class="ow">in</span> <span class="nb">iter</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="n">orig</span><span class="p">.</span><span class="n">read</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span> <span class="sa">b</span><span class="s">''</span><span class="p">):</span>
|
||||
<span class="n">targetfile</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="n">key</span><span class="p">.</span><span class="n">CTR_xcrypt_buffer</span><span class="p">(</span><span class="n">byte_block</span><span class="p">))</span>
|
||||
</code></pre></div></div>
|
||||
<p>这次我把随机生成的iv存到了文件的开头,不过也正是如此,我没办法用完全相同的办法去进行加密和解密了……所以用了<code class="language-plaintext highlighter-rouge">.enc</code>后缀名作为明文和密文的区分。还有程序的行数几乎增加了一倍😂。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>看来对于不太了解的学科还是好好的按照人家说明书上写的做比较好,不然不懂装懂就会达不到预期的想法了。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Python"><em>Python</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8A%A0%E5%AF%86"><em>加密</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%A0%B4%E8%A7%A3"><em>破解</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-10-14-crack-aes.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/10/14/crack-aes.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/10/08/tinyaes.html">
|
||||
上一篇:用Python写一个超简单的加密程序
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/10/19/web3.html">
|
||||
下一篇:在Web3上搭建一个自己的博客
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/10/14/crack-aes', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/10/14/crack-aes.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
326
2022/10/19/web3.html
Normal file
326
2022/10/19/web3.html
Normal file
@@ -0,0 +1,326 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>在Web3上搭建一个自己的博客 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="在Web3上搭建一个自己的博客" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="感觉Web3可以真正的为现在的人们使用了呢。" />
|
||||
<meta property="og:description" content="感觉Web3可以真正的为现在的人们使用了呢。" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-10-19T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="在Web3上搭建一个自己的博客" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-10-19T00:00:00+08:00","datePublished":"2022-10-19T00:00:00+08:00","description":"感觉Web3可以真正的为现在的人们使用了呢。","headline":"在Web3上搭建一个自己的博客","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/10/19/web3.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/10/19/web3.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/10/19/web3.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-10-19T00:00:00+08:00">19 October 2022</time> - 字数统计:1994 - 阅读大约需要6分钟 - Hits: <span id="/2022/10/19/web3.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">在Web3上搭建一个自己的博客</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Wed, 19 Oct 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章介绍了作者在Web3上使用xLog搭建博客的经历,提到xLog基于Crossbell区块链使用智能合约和IPFS存储内容,强调了其去中心化和防止审查的优点。尽管作者认为IPFS不能提供永久存储(除非结合Arweave或其他服务付费存储),但他利用4EVERLAND实现了静态博客的Git同步和DNSlink访问,提到了社交功能和成本问题。此外,作者对零网ZeroNet的体验并不理想,但也对Web3技术的发展和去中心化社区的建设表达了期待。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#技术人员的方法">技术人员的方法</a></li><li><a href="#从ipfs直接访问">从IPFS直接访问</a></li><li><a href="#更好的永久存储">更好的永久存储</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>感觉Web3可以真正的为现在的人们使用了呢。<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>最近偶然看到了一个很有意思的东西,叫<a href="https://xlog.app/">xLog</a>,大概试了试,这是在一条叫Crossbell的区块链上使用智能合约操作和存储元数据,并把实际数据存到IPFS上的项目。看了一眼还挺有意思,就在上面搭了一个自己的<a href="https://mayx.xlog.app/">另一个博客</a>,另外他们还使用这套方案写了一个类似Twitter的社交系统,也叫Crossbell,非常的人性化,可以说是把Web3真正的带给了普通用户。至于怎么搭他们的项目成员写了篇教程,<a href="https://song.xlog.app/5m-zh">5分钟就能搭好在Web3的博客</a>。 </p><p>
|
||||
不过使用xLog那就不是技术人员的事了,而是让一个不怎么懂电脑的人来做的事情了。另外他们宣称数据是“Permanently stored on the blockchain”这一点我不太认同,要是说存到了Web3成为了其他人无法修改的数据,这倒是没什么问题,但是存到IPFS上只要没有被Pin,就有可能在节点GC的过程中永远消失。另外我其实对区块链接触不多,不清楚能不能完整的同步他们的链,如果不能那就是私链了,那样元数据也不能永久保留了……所以我只能说这个平台是Web3,可以保证不因为审查而404,但是不能在时间的长河中保留信息。</p>
|
||||
<h1 id="技术人员的方法">
|
||||
|
||||
|
||||
<a href="#技术人员的方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 技术人员的方法
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>所以作为技术人员,我的博客当然直接上IPFS那更好啦,因为他们的平台毕竟可定制性不高,而且好多组件不知道有没有可替代性,比如以太坊JSON-RPC,不过他们的服务好像是都开源了,只要这个链可以被同步,能搭属于自己的RPC那倒是问题不大。 </p><p>
|
||||
直接用IPFS客户端直接上传是最原生的办法,但是我不喜欢在自己电脑上安一堆莫名其妙的软件,像我现在写博客都是直接在Github或者Gitlab上写好然后直接用<a href="/2022/02/14/move.html">之前提到的静态页面服务商</a>一次性部署好。所以我也希望能有一个类似的服务商能帮我把我的博客上传到IPFS上。最后我找到的服务商就是<a href="https://www.4everland.org/">4EVERLAND</a>。它可以绑定Git仓库并监听变化,当有变化的时候就会自动部署到IPFS上,并且他们提供免费的Gateway来直接访问在IPFS上的内容,非常的不错。不过有个问题就是不知道什么原因,它的部署模板里面没有Jekyll的语句,然后前端还不能自定义……所以只能靠抓包的方式来修改成自己想要的部署语句。</p>
|
||||
<h1 id="从ipfs直接访问">
|
||||
|
||||
|
||||
<a href="#从ipfs直接访问"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 从IPFS直接访问
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>使用4everland部署完之后直接访问当然也很好,但是总感觉和其他服务商差不多,谁知道它读取网页到底是从自己服务器上还是IPFS网络上读取呢?所以我还想整个更好的方式从IPFS上读取,也能证明它确实在IPFS上了。 </p><p>
|
||||
直接通过Gateway去访问我的博客当然也没问题,但是每次部署的时候CID是会变化的,那这样我想访问也不方便啊……后来我听说可以把CID用一种叫dnslink的方式记录到DNS里,这样就能通过固定又好记的方式来访问。不过那时候我不知道怎么访问dnslink记录的网站……而且每次部署CID会变,那部署完我还要更新我的DNS记录啊?后来我查了查原来还有一种叫IPNS的东西,看了一眼4everland的控制台,原来每个网站它也会生成一个固定的IPNS,然后用dnslink可以指向IPNS。那如何访问呢?IPFS又没有一个IP地址,光TXT记录肯定不够的吧?后来我才知道原来要用CNAME解析到Gateway才能访问,设置之后每次访问Gateway就会自动解析在TXT记录里的dnslink了。现在 <a href="https://ipfs.mayx.eu.org">https://ipfs.mayx.eu.org</a> 这个网站就可以直接访问我博客在IPFS上的数据了。这不比xLog自由度高?不过我这个没办法存评论数据,可能xLog的特色就是社交吧,毕竟他们的主项目Crossbell就是主打的社交。希望可以整一个单独的插件,专门用他们的网络来为我这种静态博客提供评论功能,也是一个不错的选择(毕竟ETH公链上的手续费太贵啦😂)。</p>
|
||||
<h1 id="更好的永久存储">
|
||||
|
||||
|
||||
<a href="#更好的永久存储"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 更好的永久存储
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>前面我说过,IPFS只能防止篡改,但不是作为永久存储的方案,上公链当然是也一种永久存储的方案但是成本太高了我付不起。后来我了解到一种叫做Arweave的东西可以永久存储你的数据,不过这不是免费的,想存得要付AR币到链上才可以。还好4EVERLAND提供了一些免费上传到AR网络的额度,非常的不错,这样我以后每次上传我会把地址写到<a href="https://github.com/Mabbs/mabbs.github.io/releases">Github的Releases</a>里面,进一步的提高我博客永久存储的可能性。 </p><p>
|
||||
另外我还听说似乎还有一种叫做ZeroNet的东西也是通过分布式的方式存储数据,据群友所说也能在一定程度上永久存储。不过我试了试访问实在是太困难了😂,而且现在程序也不在维护了,所以也就放弃了。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>Web3真是发展的越来越好了,希望能有更多的人参与其中,一起创建不受管束的网络吧。(还有实现我的Mayx Forever计划😝) </p><p>
|
||||
不过说来我也挺担心那个Crossbell的项目,作为不受监管的平台只要知名度上来肯定会被滥用到死,希望他们能活得更长一些吧。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Web3"><em>Web3</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8D%9A%E5%AE%A2"><em>博客</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%90%AD%E5%BB%BA"><em>搭建</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-10-19-web3.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/10/19/web3.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/10/14/crack-aes.html">
|
||||
上一篇:如何破解我上次写的加密程序?
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/11/08/cf-acc.html">
|
||||
下一篇:提高Cloudflare站点在中国的体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/10/19/web3', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/10/19/web3.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
324
2022/11/08/cf-acc.html
Normal file
324
2022/11/08/cf-acc.html
Normal file
@@ -0,0 +1,324 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>提高Cloudflare站点在中国的体验 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="提高Cloudflare站点在中国的体验" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="从此,Cloudflare不再是减速CDN了" />
|
||||
<meta property="og:description" content="从此,Cloudflare不再是减速CDN了" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-11-08T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="提高Cloudflare站点在中国的体验" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-11-08T00:00:00+08:00","datePublished":"2022-11-08T00:00:00+08:00","description":"从此,Cloudflare不再是减速CDN了","headline":"提高Cloudflare站点在中国的体验","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/11/08/cf-acc.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/11/08/cf-acc.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/11/08/cf-acc.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-11-08T00:00:00+08:00">8 November 2022</time> - 字数统计:2202 - 阅读大约需要7分钟 - Hits: <span id="/2022/11/08/cf-acc.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">提高Cloudflare站点在中国的体验</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Tue, 08 Nov 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章主要介绍了如何改善在中国使用Cloudflare服务的网站访问体验。由于中国对Cloudflare网络的某些限制,用户常会遇到速度问题。文章提供了两种方法:一是利用CloudflareSpeedTest工具检测最佳IP并修改 Hosts;二是通过第三方反代节点,这些节点可能绕过速度限制,但需注意潜在的安全风险如中间人攻击和匿名性导致的防火墙失效。对于网站站长,云flare官方的新CNAME接入方式允许绑定信用卡进行限制性接入,通过设置不重要的域名作为跳板,可灵活选择节点以优化访问速度,但需开启证书透明度监视以防止中间人攻击。作者还提到可以考虑使用DDNS脚本来自动调整IP,但缺乏实操条件。文章最后表达了对Cloudflare优化服务的肯定。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#普通用户的解决方法">普通用户的解决方法</a></li><li><a href="#对于站长的解决方法">对于站长的解决方法</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>从此,Cloudflare不再是减速CDN了<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>众所周知,因为很多人用Cloudflare当作梯子中转之类的原因,中国对Cloudflare网络的速度会有很大程度的劣化,所以在上面的网站访问速度也会非常烂。最近我发现了一个不错的办法可以在一定程度上避免这个问题,所以今天就来说一说。</p>
|
||||
<h1 id="普通用户的解决方法">
|
||||
|
||||
|
||||
<a href="#普通用户的解决方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 普通用户的解决方法
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>对于网站的访问者来说,使用<a href="https://github.com/XIU2/CloudflareSpeedTest">CloudflareSpeedTest</a>这个工具就挺不错的,它能检测到当前网络连哪个IP是最好的。因为Cloudflare网络用的是Anycast,无论从哪个IP进入都可以,所以用这个检测出来的IP直接改Hosts访问就能解决访问网站慢的问题。 </p><p>
|
||||
不过有些地区可能是服务商主动对Cloudflare的IP段进行限速,那这样有可能测试出来没有可以使用的节点,那么还有一种方法,网络上有些可能是企业之类的人会反代Cloudflare的网站用于解决在国内访问慢的问题,并且没有对host头做限制,那么这些第三方的节点同样也可以作为访问Cloudflare网站的方法。具体怎么找到这样的IP有一个<a href="https://github.com/ip-scanner/cloudflare">仓库</a>每天都会扫描全网去找像这样的节点。 </p><p>
|
||||
当然这些节点也不是所有的IP从中国连接速度都很好,这时候可以把这个仓库的所有IP收集起来然后再丢给CloudflareSpeedTest去测试,具体我写了个简单的脚本来处理:</p>
|
||||
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/ip-scanner/cloudflare.git
|
||||
<span class="nb">cat </span>cloudflare/<span class="k">*</span>.txt <span class="o">></span> proxy.txt
|
||||
./CloudflareST <span class="nt">-allip</span> <span class="nt">-sl</span> 0.1 <span class="nt">-f</span> proxy.txt <span class="nt">-n</span> 500
|
||||
|
||||
</code></pre></div></div>
|
||||
<p>这样获得的第三方IP就基本上不会被限速,里面甚至有可能有通过IPLC或者IEPL的节点,包括拿来当梯子中转速度都几乎可以跑满带宽,另外还有一个优点是这样Cloudflare获得的IP就是第三方节点的IP,可以起到匿名的作用。</p>
|
||||
<h1 id="对于站长的解决方法">
|
||||
|
||||
|
||||
<a href="#对于站长的解决方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 对于站长的解决方法
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>上面的方法相当于是用户自己去解决访问的问题,但是操作可能还是会有点复杂,所以对于网站站长来说不可能去期待访客通过这种方法来提高访问自己网站的速度。不过Cloudflare网站接入只能通过NS方式接入,这样接入的话域名解析的IP就是自动分配的,没办法自己设定解析,也就不能选择更合适的IP,另外之前用CF Partner通过CNAME接入的方法基本上都全死光了,那现在应该怎么办呢?后来我搜了一下,Cloudflare原来已经提供了官方通过CNAME接入的方法(应该是新加的功能),除了要绑信用卡之外就没别的要求了。 </p><p>
|
||||
在使用这个功能之前,必须先有2个域名,一个是不重要的域名,通过NS方式接入Cloudflare,另一个是主要使用的域名,可以接到Cloudflare上,也可以接到别的NS服务商上。然后在那个不重要的域名中先设定好源站的解析,可以解析到“@”或者随便一个二级域名也可以,并且打开代理。然后点开SSL/TLS->自定义主机名,第一次使用需要绑定信用卡或者PayPal,好像是因为它是个什么预付费的项目,免费100个CNAME,超过100个每个0.1USD。打开以后在回退源中输入刚刚设置好解析的那个域名,当回退源状态显示有效后就可以添加自定义主机名了。这里添加的主机名就是主要使用的域名,输入后根据提示在主域名上设定好TXT记录,完成后只要看到刚刚设定的主机名后面跟了两个有效就可以了。 </p><p>
|
||||
这样准备工作就做完了,现在只要把主域名的解析设定到Cloudflare网络的任意节点,它就会自动连接到不重要的域名所解析的IP上。至于怎么获得优秀的IP,就可以像普通用户那样操作了,获得优秀的IP以后我们就可以设定一个A记录解析过去。 </p><p>
|
||||
不过这里需要注意一些地方,如果使用的优选IP是Cloudflare官方的IP,那基本上也不会有什么问题,只是这个IP可能有些地区还是会访问缓慢,毕竟它也算是在重点关注对象中。如果是选择第三方节点IP,大多数情况速度都能保障,但是有个很大的问题就是那些节点的主人如果发现了你在使用他们的节点,他们是可以很轻易的进行中间人攻击的,毕竟域名都解析过去了,整个SSL证书也很简单,为了能避免这个问题一定要开启“证书透明度监视”保证能在第一时间避免有人进行中间人攻击。另外还有一个问题就是既然第三方IP可以匿名,那么网站也没办法获取到用户的真实IP地址了,像Cloudflare一些根据IP的防火墙也会无法生效,像WAF中的速率限制规则是万万不能开的,开了很大可能网站就访问不了了。还有就是DDoS是可以击垮第三方节点的,可能会使网站的可用性下降。所以如果对速度没有特别在意的情况下还是解析到官方IP上更好一些。 </p><p>
|
||||
所以为了避免节点可能会用不了的情况,我有个想法(因为我没有大陆地区的服务器所以只是设想),之前我用过一个可以给Cloudflare设定DDNS的脚本,叫<a href="https://github.com/aipeach/cloudflare-api-v4-ddns">cloudflare-api-v4-ddns</a>,原本它是去请求获取本机IP的API设定解析的,那么如果把上面优选IP的结果输入到这个脚本中,放到国内的服务器上,每天自动执行一次,那这样我的网站不就会一直使用最优秀的IP了嘛,可惜我没有国内的服务器,改起来还要费点事就算了吧。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>有了很多辅助的工具,能让Cloudflare不再成为减速CDN,那它岂不是可以吊打国内其他CDN厂商了😆,果然还是良心厂商啊。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Cloudflare"><em>Cloudflare</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8A%A0%E9%80%9F"><em>加速</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-11-08-cf-acc.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/11/08/cf-acc.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/10/19/web3.html">
|
||||
上一篇:在Web3上搭建一个自己的博客
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/11/16/tor.html">
|
||||
下一篇:Tor在服务器上的使用体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/11/08/cf-acc', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/11/08/cf-acc.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
409
2022/11/16/tor.html
Normal file
409
2022/11/16/tor.html
Normal file
@@ -0,0 +1,409 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>Tor在服务器上的使用体验 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="Tor在服务器上的使用体验" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="就像和普通网络一样使用Tor吧" />
|
||||
<meta property="og:description" content="就像和普通网络一样使用Tor吧" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-11-16T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="Tor在服务器上的使用体验" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-11-16T00:00:00+08:00","datePublished":"2022-11-16T00:00:00+08:00","description":"就像和普通网络一样使用Tor吧","headline":"Tor在服务器上的使用体验","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/11/16/tor.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/11/16/tor.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/11/16/tor.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-11-16T00:00:00+08:00">16 November 2022</time> - 字数统计:2334 - 阅读大约需要9分钟 - Hits: <span id="/2022/11/16/tor.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">Tor在服务器上的使用体验</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Wed, 16 Nov 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者在服务器上设置Socks代理(v2ray)以访问洋葱网络(如Zlibrary)的体验。作者成功地将Tor核心与代理结合,通过v2ray的路由功能实现访问洋葱域名的同时保持外网连接。虽然访问速度一般,但这方法并不匿名,容易暴露IP。文章还提到利用vanity address建立隐藏服务,使用Unix domain Socket提高安全性。作者对洋葱网络的友好性表示认同,认为其易用性是它受欢迎的原因。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#探索过程">探索过程</a></li><li><a href="#使用tor进行建站">使用Tor进行建站</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>就像和普通网络一样使用Tor吧<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>前段时间全世界最大的电子书图书馆——Zlibrary的域名被FBI回收了,以致于想要访问它只能用Tor(洋葱路由器)或者Tor2Web访问它的Onion域名。 <del>(众所周知,只有恋童癖,瘾君子和读书人才会用Tor🤣)</del> 当然,想要访问洋葱网络用Tor2Web最简单,但是最不安全,太容易被中间人攻击了,或者安装洋葱浏览器也很简单,只不过我有个理念就是一个设备不应该安装超过一个浏览器,正因如此,我也很不喜欢Electron的软件。既然我使用Windows本身就已经有个Egde浏览器了,我为什么还要安装其他浏览器呢?所以我就想能不能用更加简单的方式来访问Onion域名。</p>
|
||||
<h1 id="探索过程">
|
||||
|
||||
|
||||
<a href="#探索过程"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 探索过程
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>要想不使用洋葱浏览器访问也可以,只要装一个Tor核心,然后让浏览器去连它的Socks代理就可以了,只不过……在国内想要连接洋葱网络实在是太麻烦了,还要整网桥(前置代理)啥的。不过要说代理……我自己倒是有一个,那这么说来我干脆把代理和Tor组合到一起都放到服务器上,然后我只要连代理就可以同时访问外网和洋葱网络了吧,还不影响我访问其他网站的速度。 </p><p>
|
||||
那应该怎么做呢?Tor安装倒是很简单,大多数软件包管理器都能直接安装,甚至可以什么都不配置就可以用9050端口访问它的Socks5代理了,我的话虽然之前用的是<a href="/2022/01/16/wssocks.html">wssocks</a>,但是并发效果很差,也没有手机客户端,所以最后还是换成了v2ray。像v2ray这种相比其他的还有一个优点就是它的路由配置功能还挺强大的,这次也是用到了它的路由功能。其实去看官网文档上也有关于<a href="https://guide.v2fly.org/advanced/tor.html">将Tor和v2ray配合使用的教程</a>,只是不知道为什么它那个配置文件里面只有关于客户端的路由,没有服务端的路由……不过不影响,v2ray作为一个服务端和客户端等价的程序稍微改下那个配置文件就可以用了:</p>
|
||||
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"log"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"loglevel"</span><span class="p">:</span><span class="w"> </span><span class="s2">"warning"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"routing"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"domainStrategy"</span><span class="p">:</span><span class="w"> </span><span class="s2">"AsIs"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"strategy"</span><span class="p">:</span><span class="w"> </span><span class="s2">"rules"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"settings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"rules"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"field"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"domain"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"regexp:</span><span class="se">\\</span><span class="s2">.onion$"</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"outboundTag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"tor"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"field"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"outboundTag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"block"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"bittorrent"</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
|
||||
</span><span class="nl">"inbounds"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"sniffing"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"enabled"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"destOverride"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"http"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"tls"</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"listen"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/dev/shm/proxy.sock"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"vless"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"settings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"udp"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"clients"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"***"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"alterId"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"flow"</span><span class="p">:</span><span class="w"> </span><span class="s2">""</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"decryption"</span><span class="p">:</span><span class="w"> </span><span class="s2">"none"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"allowTransparent"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"streamSettings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"network"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ws"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"security"</span><span class="p">:</span><span class="w"> </span><span class="s2">"none"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"wsSettings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"***"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"headers"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"Host"</span><span class="p">:</span><span class="w"> </span><span class="s2">"***"</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"outbounds"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"freedom"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"socks"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"settings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"servers"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"address"</span><span class="p">:</span><span class="w"> </span><span class="s2">"127.0.0.1"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"port"</span><span class="p">:</span><span class="w"> </span><span class="mi">9050</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"tag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"tor"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"blackhole"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"tag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"block"</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span></code></pre></div></div>
|
||||
<p>顺便我为了避免不小心服务器被封也屏蔽了bt下载(其实也许把bt流量转发到洋葱网络里面也可以?)。配置好之后试着找了些Onion网站试了试,还不错,访问速度一般,也不影响我访问其他网站。 </p><p>
|
||||
不过需要注意的一点是这个方法<strong>不能匿名</strong>,仅仅是作为访问Onion网站的手段,因为普通的浏览器不会有那么多保护隐私的机制,这样的配置方法很容易会导致IP泄露(就算是有代理也会有WebRTC泄露的可能性),想匿名还是用洋葱浏览器+前置代理或者Tor做透明代理会更好一些。</p>
|
||||
<h1 id="使用tor进行建站">
|
||||
|
||||
|
||||
<a href="#使用tor进行建站"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用Tor进行建站
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>既然在服务器上安装了Tor,正好我之前用<a href="https://github.com/cathugger/mkp224o">mkp224o</a>算了几个vanity address,这次可以直接拿已经算好了私钥开网站。方法也很简单,在<code class="language-plaintext highlighter-rouge">HiddenServiceDir</code>后面加私钥的存放位置,然后在<code class="language-plaintext highlighter-rouge">HiddenServicePort</code>后面加想要服务的端口号和被映射的端口,一般教程会说用nginx映射127.0.0.1:80,而我会建议使用Unix domain Socket,更加安全,性能也会更好,像我就会配成:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>HiddenServiceDir /var/lib/tor/hidden_service/
|
||||
HiddenServicePort 80 unix:/dev/shm/nginx.sock
|
||||
</code></pre></div></div>
|
||||
<p>顺便加两句反蜜罐配置:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ExcludeNodes {cn},{hk},{mo},{kp},{ir},{sy},{pk},{cu},{vn}
|
||||
StrictNodes 1
|
||||
</code></pre></div></div>
|
||||
<p>nginx的监听也要注意监听/dev/shm/nginx.sock,这样能保证即使在服务器内扫描端口也不会泄露你的网站😆。 </p><p>
|
||||
其实我本来想让v2ray的连接Tor也通过Unix domain Socket走,但是很遗憾的是我没找到v2ray的Outbound怎么样设置Unix domain Socket连接……</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>感觉洋葱网络其实还是对用户挺友好的,使用起来还是挺方便的,就像访问普通网络那样,大概也正是这种原因它才能成为匿名网络中最受欢迎的吧。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=tor"><em>tor</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BD%91%E7%BB%9C"><em>网络</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-11-16-tor.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/11/16/tor.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/11/08/cf-acc.html">
|
||||
上一篇:提高Cloudflare站点在中国的体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/11/23/i2p.html">
|
||||
下一篇:i2pd在服务器上的使用体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/11/16/tor', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/11/16/tor.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
422
2022/11/23/i2p.html
Normal file
422
2022/11/23/i2p.html
Normal file
@@ -0,0 +1,422 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>i2pd在服务器上的使用体验 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="i2pd在服务器上的使用体验" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="Java果不其然是垃圾😁,i2p还是得靠其他语言支撑!" />
|
||||
<meta property="og:description" content="Java果不其然是垃圾😁,i2p还是得靠其他语言支撑!" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-11-23T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="i2pd在服务器上的使用体验" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-11-23T00:00:00+08:00","datePublished":"2022-11-23T00:00:00+08:00","description":"Java果不其然是垃圾😁,i2p还是得靠其他语言支撑!","headline":"i2pd在服务器上的使用体验","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/11/23/i2p.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/11/23/i2p.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/11/23/i2p.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-11-23T00:00:00+08:00">23 November 2022</time> - 字数统计:2549 - 阅读大约需要10分钟 - Hits: <span id="/2022/11/23/i2p.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">i2pd在服务器上的使用体验</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Wed, 23 Nov 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章主要讲述了作者在服务器上使用i2pd——一个C++实现的i2P服务的体验。相较于官方Java版本的I2P客户端,i2pd因为非Java编写而被认为更易用。作者发现i2pd的安装和使用相对简单,通过HTTP代理连接隐形网络速度快于官方客户端,并提到了i2pd的域名解析系统和vanity address的计算工具vain的问题。尽管如此,作者仍认为i2pd的用户体验比官方客户端要好,但指出访问i2P网络的网站较少,且因为缺乏多样性的服务,不如Tor那样有丰富的内容。文章以一种轻松的口吻表达了作者对Java语言的调侃。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#探索过程">探索过程</a></li><li><a href="#建站体验">建站体验</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>Java果不其然是垃圾😁,i2p还是得靠其他语言支撑!<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>前几天<a href="/2022/11/16/tor.html">我在服务器上体验了Tor</a>,让我的代理在访问互联网的同时也能访问洋葱网络上的网站。其实我整完这个之后也想整出能访问i2p的功能,只是我之前体验了下官方的I2P客户端,体验不是一般的差,再加上还是Java写的,导致我对i2p的印象不怎么好。 </p><p>
|
||||
不过最近我看到有一个使用C++实现的i2p,叫<a href="https://github.com/PurpleI2P/i2pd">i2pd</a>。其他先不说,只要不是Java写的首先加一分,闭着眼睛都知道它的体验一定比官方的Java I2P体验要好得多。随后我就按照官网的文档在我的服务器上安装了一下。</p>
|
||||
<h1 id="探索过程">
|
||||
|
||||
|
||||
<a href="#探索过程"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 探索过程
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>安装完成之后使用也非常的简单,虽然它也有Web管理界面,但是为了安全我的服务器上开了几层防火墙,也懒得配置所以也没有登进去看一眼。不过使用还是相当简单的,它和官方的I2P一样也是可以直接用4444端口的HTTP代理连接隐形网络,为了能让我的电脑也能上,我也在我的v2ray配置文件基于上次写的照猫画虎的加了几句规则:</p>
|
||||
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"log"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"loglevel"</span><span class="p">:</span><span class="w"> </span><span class="s2">"warning"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"routing"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"domainStrategy"</span><span class="p">:</span><span class="w"> </span><span class="s2">"AsIs"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"strategy"</span><span class="p">:</span><span class="w"> </span><span class="s2">"rules"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"settings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"rules"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"field"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"domain"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"regexp:</span><span class="se">\\</span><span class="s2">.onion$"</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"outboundTag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"tor"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"field"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"domain"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"regexp:</span><span class="se">\\</span><span class="s2">.i2p$"</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"outboundTag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"i2p"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"field"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"outboundTag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"block"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"bittorrent"</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
|
||||
</span><span class="nl">"inbounds"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"sniffing"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"enabled"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"destOverride"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="s2">"http"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="s2">"tls"</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"listen"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/dev/shm/proxy.sock"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"vless"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"settings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"udp"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"clients"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"***"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"alterId"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"flow"</span><span class="p">:</span><span class="w"> </span><span class="s2">""</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"decryption"</span><span class="p">:</span><span class="w"> </span><span class="s2">"none"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"allowTransparent"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"streamSettings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"network"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ws"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"security"</span><span class="p">:</span><span class="w"> </span><span class="s2">"none"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"wsSettings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"***"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"headers"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"Host"</span><span class="p">:</span><span class="w"> </span><span class="s2">"***"</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">],</span><span class="w">
|
||||
</span><span class="nl">"outbounds"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"freedom"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"socks"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"settings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"servers"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"address"</span><span class="p">:</span><span class="w"> </span><span class="s2">"127.0.0.1"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"port"</span><span class="p">:</span><span class="w"> </span><span class="mi">9050</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"tag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"tor"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"http"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"settings"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"servers"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"address"</span><span class="p">:</span><span class="w"> </span><span class="s2">"127.0.0.1"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"port"</span><span class="p">:</span><span class="w"> </span><span class="mi">4444</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="nl">"tag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"i2p"</span><span class="w">
|
||||
</span><span class="p">},</span><span class="w">
|
||||
</span><span class="p">{</span><span class="w">
|
||||
</span><span class="nl">"protocol"</span><span class="p">:</span><span class="w"> </span><span class="s2">"blackhole"</span><span class="p">,</span><span class="w">
|
||||
</span><span class="nl">"tag"</span><span class="p">:</span><span class="w"> </span><span class="s2">"block"</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span><span class="p">]</span><span class="w">
|
||||
</span><span class="p">}</span><span class="w">
|
||||
</span></code></pre></div></div>
|
||||
<p>顺便再提醒一下,这样的配置<strong>不能</strong>匿名,仅仅是一种更方便访问隐形网络的方式,如果有匿名需要,建议使用Firefox或者Tor浏览器,安装I2P的插件并设置相应的代理,或者使用<a href="https://github.com/PurpleI2P/i2pdbrowser">i2pdbrowser</a>(也是基于Firefox的)。 </p><p>
|
||||
另外如果只是访问还有一种更加不匿名的方式,i2p也有类似tor2web那样的东西,不过很少,我找了一圈只找到了<a href="https://i2phides.me/">i2phides.me</a>可以用。当然也是强烈不推荐的,在不知明细的情况下使用这种东西是会被中间人攻击+记录访问日志的。 </p><p>
|
||||
配置好之后试着用电脑上了一下,体验相当好,比之前在手机和电脑上安装的官方的I2P Java客户端速度快多了,随便开了几个网站感觉甚至比上次配置的Tor速度还快,不过这可能只是延迟比较低,之后我找了几个文件下载Tor的实际网速还是更快一些,I2P虽然感觉延迟低但是实际下载速度也只有1Mb/s左右。</p>
|
||||
<h1 id="建站体验">
|
||||
|
||||
|
||||
<a href="#建站体验"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 建站体验
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>隐形网络比洋葱网络感觉更好的一点大概就是它有一套自己的域名解析系统,洋葱网络访问的时候基本上没办法记忆,想整个好看的域名还得算。隐形网络的话有了域名解析系统就可以不用花大力气去算vanity address了。不过我搞这个也算是玩了,算一个也挺好。想整的话可以用i2pd提供的一套工具<a href="https://github.com/PurpleI2P/i2pd-tools">i2pd-tools</a>,里面有个叫vain的工具可以用来算vanity address。不过实际上试了一下感觉没有Tor里的<a href="https://github.com/cathugger/mkp224o">mkp224o</a>好用,速度慢是一方面,比较离谱的是它还能计算出错,6位以下的自定义字母倒是能正常计算,6位以上的就会计算错误,好不容易计算出一个,结果检验的时候报“bad key file format”……看那个仓库好像人家也不怎么想解决的样子,大概也因为有域名解析系统的原因,网上也没有其他人开发这样的程序…… </p><p>
|
||||
算好喜欢的私钥之后,就可以进行建站了,他们这个配置文件感觉比Tor客户端的要好,配置也很简单,按照<a href="https://i2pd.readthedocs.io/en/latest/tutorials/http/#host-anonymous-website">i2pd的文档</a>就行了,不过他们这个有个缺点就是好像不支持Unix Domain Socket连接,这样我就得再占掉一个端口,比较令人遗憾……另外这个私钥官方没有说放到哪里,我找了一下,需要放到“/var/lib/i2pd/”路径下,这个应该是它以服务形式启动之后默认的工作目录。 </p><p>
|
||||
配置好之后网站就可以访问了,不过既然它有域名解析系统,还是免费的,肯定还是要注册一个的。注册也很简单,上面提到的i2pd-tools里面有个regaddr程序,把自己想要的域名和私钥按照说明传进去,把输出的结果粘贴到 <a href="http://reg.i2p/add">http://reg.i2p/add</a> 或者 <a href="http://stats.i2p/i2p/addkey.html">http://stats.i2p/i2p/addkey.html</a> 里面,然后过段时间等他们收录了之后就可以使用了。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>虽然i2pd的体验还不错,不过也许是官方使用的是Java编写的客户端,导致用户量很少,网站也非常少,以致于感觉访问i2p的网站都似乎失去了意义……不像洋葱网络那样,随便搜一搜就能找到互联网肯定找不到的东西。 <del>(所以Java什么时候死啊😂)</del></p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=i2p"><em>i2p</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E9%9A%90%E7%A7%81"><em>隐私</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BD%91%E7%BB%9C"><em>网络</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-11-23-i2p.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/11/23/i2p.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/11/16/tor.html">
|
||||
上一篇:Tor在服务器上的使用体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/11/29/free-server.html">
|
||||
下一篇:体验小白也会使用的免费容器云
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/11/23/i2p', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/11/23/i2p.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
374
2022/11/29/free-server.html
Normal file
374
2022/11/29/free-server.html
Normal file
@@ -0,0 +1,374 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>体验小白也会使用的免费容器云 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="体验小白也会使用的免费容器云" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="Heroku虽然倒了,但是我们还有更多的选择" />
|
||||
<meta property="og:description" content="Heroku虽然倒了,但是我们还有更多的选择" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-11-29T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="体验小白也会使用的免费容器云" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-11-29T00:00:00+08:00","datePublished":"2022-11-29T00:00:00+08:00","description":"Heroku虽然倒了,但是我们还有更多的选择","headline":"体验小白也会使用的免费容器云","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/11/29/free-server.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/11/29/free-server.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/11/29/free-server.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-11-29T00:00:00+08:00">29 November 2022</time> - 字数统计:2368 - 阅读大约需要8分钟 - Hits: <span id="/2022/11/29/free-server.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">体验小白也会使用的免费容器云</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Tue, 29 Nov 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者在Heroku不再提供免费容器云服务后,发现了一家名为Koyeb的平台作为替代。Koyeb的特色在于可以直接部署Docker Hub上的项目,无需安装复杂软件,操作相对人性化。作者利用Koyeb部署了宝塔面板和VerySimple梯子服务,而且还提到为了解决网站资源访问问题,使用了Cloudflare Workers做反代。尽管免费,作者认为Koyeb是个不错的临时选择,但需要珍惜这种免费服务。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#koyeb的体验">Koyeb的体验</a><ul><li><a href="#建站方法">建站方法</a></li><li><a href="#搭梯子的方法">搭梯子的方法</a></li></ul></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>Heroku虽然倒了,但是我们还有更多的选择<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>从昨天开始,Heroku就不再提供免费的容器云服务了,虽然我有Github的学生包,但是试了一下要绑银行卡就算了。不过虽然这么说,我其实一次也没用过Heroku,因为它要安装奇奇怪怪的软件用起来很不人性化。不过最近也正好需要一个服务器来供我测试,那应该怎么办呢?</p>
|
||||
<h1 id="koyeb的体验">
|
||||
|
||||
|
||||
<a href="#koyeb的体验"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Koyeb的体验
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>后来我在寻找的时候找到了一家叫做<a href="https://www.koyeb.com/">Koyeb</a>的平台,也是容器云,还是免费的。用Github登录之后就可以使用了,试了一下感觉很不错啊,它和其他免费容器云最不一样的可能就是它能直接部署Docker Hub上的项目,不用在Github上新建乱七八糟的仓库,也不用安装乱七八糟的软件,非常的人性化啊。 </p><p>
|
||||
既然能部署Docker Hub的项目,那可选择的余地就太大了,我直接随便部署一个发行版就能当免费的VPS来用,不过既然能直接部署了,还是安点什么好吧……我想了想干脆安装个宝塔面板吧,正好他们官方也提供了<a href="https://hub.docker.com/r/btpanel/baota">Docker镜像</a>,直接部署就行,另外为了正常访问,需要映射8888端口,另外为了方便访问网站,还要映射一个80端口。不过它只给了一个地址,所以如果要映射多个端口就只能设定路径……像我是给面板设定的根目录,方便我配置,至于网站嘛……之后再考虑吧,这里我先填了一个<code class="language-plaintext highlighter-rouge">/app</code>的路径便于之后使用。 </p><p>
|
||||
这样安装出来的面板直接根据镜像文档的说明就可以登录了,不过登录之后会要求绑定手机号……我不太想整这个东西,于是在网上找了个宝塔纯净版,在Koyeb的Console里面执行:</p>
|
||||
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>curl http://v7.hostcli.com/install/update6.sh|bash
|
||||
</code></pre></div></div>
|
||||
<p>运行之后就可以跳过绑定宝塔账号的步骤了,还能安装企业版插件,还是挺不错的。不过不知道是什么问题,网页端的SSH好像用不了……这个建议使用frp等方式反代一下再用,免费的frp服务器还是比较好找的。</p>
|
||||
<h2 id="建站方法">
|
||||
|
||||
|
||||
<a href="#建站方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 建站方法
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>因为之前已经映射了80端口,所以直接用提供的链接就能打开之前建好的网站(例如example.koyeb.app/app)。不过对于有些网站来说有个问题,那就是它的程序可能资源不允许在不是根目录的地方,这样它读取文件的时候就会从宝塔面板的路径读取了,然后就会出现例如404的错误。为了解决这个问题我想了一下,干脆让Cloudflare Workers反代它吧(理论上应该绑定域名然后在Cloudflare上配置重写规则应该也行),所以就写了个简单的脚本:</p>
|
||||
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">addEventListener</span><span class="p">(</span>
|
||||
<span class="dl">"</span><span class="s2">fetch</span><span class="dl">"</span><span class="p">,</span><span class="nx">event</span> <span class="o">=></span> <span class="p">{</span>
|
||||
<span class="kd">let</span> <span class="nx">url</span><span class="o">=</span><span class="k">new</span> <span class="nx">URL</span><span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">request</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span>
|
||||
<span class="nx">url</span><span class="p">.</span><span class="nx">protocol</span><span class="o">=</span><span class="dl">"</span><span class="s2">https</span><span class="dl">"</span><span class="p">;</span>
|
||||
<span class="nx">url</span><span class="p">.</span><span class="nx">hostname</span><span class="o">=</span><span class="dl">"</span><span class="s2">example.koyeb.app</span><span class="dl">"</span><span class="p">;</span>
|
||||
<span class="nx">url</span><span class="p">.</span><span class="nx">pathname</span><span class="o">=</span><span class="dl">"</span><span class="s2">/app</span><span class="dl">"</span> <span class="o">+</span> <span class="nx">event</span><span class="p">.</span><span class="nx">request</span><span class="p">.</span><span class="nx">url</span><span class="p">.</span><span class="nx">substring</span><span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">request</span><span class="p">.</span><span class="nx">url</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="dl">'</span><span class="s1">/</span><span class="dl">'</span><span class="p">,</span><span class="mi">8</span><span class="p">),(</span><span class="nx">event</span><span class="p">.</span><span class="nx">request</span><span class="p">.</span><span class="nx">url</span> <span class="o">+</span> <span class="dl">"</span><span class="s2">?</span><span class="dl">"</span><span class="p">).</span><span class="nx">indexOf</span><span class="p">(</span><span class="dl">'</span><span class="s1">?</span><span class="dl">'</span><span class="p">));</span>
|
||||
<span class="kd">let</span> <span class="nx">request</span><span class="o">=</span><span class="k">new</span> <span class="nx">Request</span><span class="p">(</span><span class="nx">url</span><span class="p">,</span><span class="nx">event</span><span class="p">.</span><span class="nx">request</span><span class="p">);</span>
|
||||
<span class="nx">event</span><span class="p">.</span> <span class="nx">respondWith</span><span class="p">(</span>
|
||||
<span class="nx">fetch</span><span class="p">(</span><span class="nx">request</span><span class="p">)</span>
|
||||
<span class="p">)</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">)</span>
|
||||
</code></pre></div></div>
|
||||
<p>这样访问网站的时候就不会遇到404的情况了。不过这样做还有一个缺陷就是HTTP_HOST环境变量会是错的,有些程序会读取它,导致链接可能会出问题,这种情况就只能通过修改fastcgi的环境变量配置文件来解决了……</p>
|
||||
<h2 id="搭梯子的方法">
|
||||
|
||||
|
||||
<a href="#搭梯子的方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 搭梯子的方法
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<p>一般租服务器,可能除了搭网站,就是搭梯子了。所以我想在建站的同时搭个梯子,正好网站也算是梯子的伪装了。 </p><p>
|
||||
这次我搭梯子不想用v2ray了,我想换个之前在Github上看到的一个重新实现的v2ray,叫<a href="https://github.com/e1732a364fed/v2ray_simple">verysimple</a>,据说速度比v2ray要快很多,不过它用的那个toml我看的不是很明白,因为之前配了<a href="/2022/11/16/tor.html">Tor</a>和<a href="/2022/11/23/i2p.html">i2p</a>,用到了路由功能,它这个路由功能……也没个文档,本来想给自己的服务器换一下,这看起来不知道怎么配就算了。不过在这个免费的测试机上不需要有那么多功能,只是当个普通梯子还是很简单的,而且它的配置文件能通过交互模式生成还挺有意思的。 </p><p>
|
||||
像我的话配置文件很简单,就是这个样子:</p>
|
||||
<div class="language-toml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nn">[[listen]]</span>
|
||||
<span class="py">tag</span> <span class="p">=</span> <span class="s">"my_proxy"</span>
|
||||
<span class="py">host</span> <span class="p">=</span> <span class="s">"***"</span>
|
||||
<span class="py">ip</span> <span class="p">=</span> <span class="s">"0.0.0.0"</span>
|
||||
<span class="py">port</span> <span class="p">=</span> <span class="mi">8080</span>
|
||||
<span class="py">xver</span> <span class="p">=</span> <span class="mi">0</span>
|
||||
<span class="py">tls</span> <span class="p">=</span> <span class="kc">false</span>
|
||||
<span class="py">path</span> <span class="p">=</span> <span class="s">"***"</span>
|
||||
<span class="py">advancedLayer</span> <span class="p">=</span> <span class="s">"ws"</span>
|
||||
<span class="py">protocol</span> <span class="p">=</span> <span class="s">"vless"</span>
|
||||
<span class="py">uuid</span> <span class="p">=</span> <span class="s">"***"</span>
|
||||
<span class="py">version</span> <span class="p">=</span> <span class="mi">0</span>
|
||||
|
||||
<span class="nn">[[dial]]</span>
|
||||
<span class="py">port</span> <span class="p">=</span> <span class="mi">0</span>
|
||||
<span class="py">xver</span> <span class="p">=</span> <span class="mi">0</span>
|
||||
<span class="py">protocol</span> <span class="p">=</span> <span class="s">"direct"</span>
|
||||
<span class="py">version</span> <span class="p">=</span> <span class="mi">0</span>
|
||||
</code></pre></div></div>
|
||||
<p>然后在我的网站的nginx里配置相应的路由:</p>
|
||||
<div class="language-conf highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="n">location</span> /***{
|
||||
<span class="n">proxy_set_header</span> <span class="n">X</span>-<span class="n">Original</span>-<span class="n">Host</span> $<span class="n">host</span>;
|
||||
<span class="n">proxy_set_header</span> <span class="n">X</span>-<span class="n">Real</span>-<span class="n">IP</span> $<span class="n">remote_addr</span>;
|
||||
<span class="n">proxy_set_header</span> <span class="n">X</span>-<span class="n">Forwarded</span>-<span class="n">For</span> $<span class="n">proxy_add_x_forwarded_for</span>;
|
||||
<span class="n">proxy_set_header</span> <span class="n">Host</span> ***;
|
||||
<span class="n">proxy_http_version</span> <span class="m">1</span>.<span class="m">1</span>;
|
||||
<span class="n">proxy_set_header</span> <span class="n">Upgrade</span> $<span class="n">http_upgrade</span>;
|
||||
<span class="n">proxy_set_header</span> <span class="n">Connection</span> <span class="s2">"Upgrade"</span>;
|
||||
<span class="n">proxy_pass</span> <span class="n">http</span>://<span class="m">127</span>.<span class="m">0</span>.<span class="m">0</span>.<span class="m">1</span>:<span class="m">8080</span>;
|
||||
}
|
||||
</code></pre></div></div>
|
||||
<p>就可以正常使用了,试了一下效果还不错,不知道这个流量是怎么算的,Koyeb的面板上也没有关于流量费的介绍……难不成是不限流量?</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>免费的东西虽好,不过既然Heroku都被薅没了,Koyeb这种小白都能免费用的容器云……只能说且用且珍惜了……</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Docker"><em>Docker</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%AE%B9%E5%99%A8"><em>容器</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%85%8D%E8%B4%B9"><em>免费</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-11-29-free-server.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/11/29/free-server.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/11/23/i2p.html">
|
||||
上一篇:i2pd在服务器上的使用体验
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/12/12/bt-s3-comp.html">
|
||||
下一篇:如何自定义宝塔亚马逊S3云存储插件的端点
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/11/29/free-server', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/11/29/free-server.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
307
2022/12/12/bt-s3-comp.html
Normal file
307
2022/12/12/bt-s3-comp.html
Normal file
@@ -0,0 +1,307 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>如何自定义宝塔亚马逊S3云存储插件的端点 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="如何自定义宝塔亚马逊S3云存储插件的端点" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="会点Python就可以自己改插件啦!" />
|
||||
<meta property="og:description" content="会点Python就可以自己改插件啦!" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-12-12T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="如何自定义宝塔亚马逊S3云存储插件的端点" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-12-12T00:00:00+08:00","datePublished":"2022-12-12T00:00:00+08:00","description":"会点Python就可以自己改插件啦!","headline":"如何自定义宝塔亚马逊S3云存储插件的端点","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/12/12/bt-s3-comp.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/12/12/bt-s3-comp.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/12/12/bt-s3-comp.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-12-12T00:00:00+08:00">12 December 2022</time> - 字数统计:1174 - 阅读大约需要4分钟 - Hits: <span id="/2022/12/12/bt-s3-comp.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">如何自定义宝塔亚马逊S3云存储插件的端点</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Mon, 12 Dec 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章主要讲述了作者如何自定义宝塔面板上的亚马逊S3云存储插件,因为原插件不支持非AWS的S3服务端点,如Filebase。作者发现通过Python的boto3库可以实现自定义连接,只需要在插件的`build_auth()`方法中添加`endpoint_url`参数。作者对宝塔插件的设计和功能表示不满,认为它只支持了基本功能且依赖臃肿,但对于不会编程的小白用户来说,尽管功能有限,仍需使用。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#插件的使用与修改">插件的使用与修改</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>会点Python就可以自己改插件啦!<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>上次<a href="/2022/11/29/free-server.html">用Koyeb安装了宝塔面板</a>之后在上面写了些测试用的网站,不过因为我开发网站的时候喜欢直接在面板上面改,本地基本上都是没代码备份的,不过最近宝塔面板好像有不少关于漏洞的传言,为了避免由于各种奇怪的事情把我的网站搞没,我想整点备份用的插件。</p>
|
||||
<h1 id="插件的使用与修改">
|
||||
|
||||
|
||||
<a href="#插件的使用与修改"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 插件的使用与修改
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>宝塔面板的插件还是挺多的,想要备份的话支持的平台也挺多的,而且都很人性化,功能啥的小白也能操作的来。不过考虑到宝塔面板的不安全性,我也不希望我常用的网盘挂在上面当备份,万一被攻破了我网盘上的文件就被别人拿走了。 </p><p>
|
||||
综合考虑下来,什么OSS还是什么云盘感觉还是不太好选择,但是S3 API兼容的平台还挺多的,比如我<a href="/2022/10/19/web3.html">之前用过的4EVERLAND</a>也有存储桶。另外之前随便逛的时候注册了一个Filebase也支持(都是0门槛免费5GB)。所以想用这个存我的备份文件。 </p><p>
|
||||
不过宝塔面板上带的亚马逊S3云存储插件只能用亚马逊的云服务,不能改endpoint……但是我也不想注册AWS,除了看着难受,不人性化,而且好像免费用要绑信用卡?(最主要是我想备份到Filebase, <del>不然白注册了?😂</del> ) </p><p>
|
||||
所以我就去看了看这个插件的源代码,还好代码是Python的,理解起来倒是不难。最开始我是想着它会不会是直接通过HTTP API访问AWS S3的端点,所以就直接各种搜索,但是找了半天没看到一个和AWS有关的域名……看来投机取巧不太行……就只能慢慢看代码了。最终找了半天发现它好像用的一个叫boto3的库来连接AWS的……这名字起的是真的……我完全没法从这个名字中看出来它和AWS有半毛钱关系(好像因为Boto是亚马逊河豚,据说是粉色的),尤其它代码里是通过<code class="language-plaintext highlighter-rouge">from boto3 import client</code>这种方式引入的,代码里就没有和boto3有关系的词了……client这个词又很通用,这代码看着是真的难受啊…… </p><p>
|
||||
不过还好最终起码找到要改的地方了,其实很简单,它的“/www/server/panel/plugin/aws_s3/s3lib/client/aws_s3.py”这个文件是引入的关键,其中<code class="language-plaintext highlighter-rouge">build_auth()</code>方法是连接S3的关键,我在网上搜了一下boto3,它也是支持自定义端点的,只要在第100行后面加一个endpoint_url参数就可以了,比如Filebase就加一句<code class="language-plaintext highlighter-rouge">endpoint_url="https://s3.filebase.com"</code>,保存之后其他的就在面板上配置就行了。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>这下就能看出来宝塔是有多垃圾了吧,明明就一个参数就能搞定的事情,它偏偏不给你加,而且就这样还啥功能都不支持,文件夹也删不了,也没法在面板里上传/下载文件,而且还要给你装个boto3的依赖,啥都不支持还要装个全功能的依赖,实在是太垃圾了。不过小白不会写代码,再垃圾的东西该用还得用吧🤣。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=S3"><em>S3</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%8F%92%E4%BB%B6"><em>插件</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-12-12-bt-s3-comp.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/12/12/bt-s3-comp.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/11/29/free-server.html">
|
||||
上一篇:体验小白也会使用的免费容器云
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2022/12/26/i2p-ssl.html">
|
||||
下一篇:为自己的i2p站点添加一个SSL证书
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/12/12/bt-s3-comp', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/12/12/bt-s3-comp.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
332
2022/12/26/i2p-ssl.html
Normal file
332
2022/12/26/i2p-ssl.html
Normal file
@@ -0,0 +1,332 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
||||
<title>为自己的i2p站点添加一个SSL证书 | Mayx的博客</title>
|
||||
<meta name="generator" content="Jekyll v3.9.5" />
|
||||
<meta property="og:title" content="为自己的i2p站点添加一个SSL证书" />
|
||||
<meta name="author" content="mayx" />
|
||||
<meta property="og:locale" content="zh_CN" />
|
||||
<meta name="description" content="虽然没啥用,不过很有意思所以还是整一个!" />
|
||||
<meta property="og:description" content="虽然没啥用,不过很有意思所以还是整一个!" />
|
||||
<meta property="og:site_name" content="Mayx的博客" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="article:published_time" content="2022-12-26T00:00:00+08:00" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="twitter:title" content="为自己的i2p站点添加一个SSL证书" />
|
||||
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
|
||||
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
|
||||
<meta name="yandex-verification" content="fc0e535abed800be" />
|
||||
<script type="application/ld+json">
|
||||
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2022-12-26T00:00:00+08:00","datePublished":"2022-12-26T00:00:00+08:00","description":"虽然没啥用,不过很有意思所以还是整一个!","headline":"为自己的i2p站点添加一个SSL证书","mainEntityOfPage":{"@type":"WebPage","@id":"/2022/12/26/i2p-ssl.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2022/12/26/i2p-ssl.html"}</script>
|
||||
<!-- End Jekyll SEO tag -->
|
||||
|
||||
<link rel="canonical" href="https://mabbs.github.io/2022/12/26/i2p-ssl.html" />
|
||||
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
|
||||
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
|
||||
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css?v=1767196818" />
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
|
||||
<!-- <![endif]-->
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
|
||||
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
|
||||
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
|
||||
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
|
||||
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
|
||||
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
|
||||
<link rel="me" href="https://github.com/Mabbs" />
|
||||
<script src="/assets/js/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<script>
|
||||
var lastUpdated = new Date("Thu, 01 Jan 2026 00:00:18 +0800");
|
||||
var BlogAPI = "https://summary.mayx.eu.org";
|
||||
</script>
|
||||
<script src="/assets/js/main.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-137710294-1');
|
||||
</script>
|
||||
|
||||
<script src="/assets/js/instant.page.js" type="module"></script>
|
||||
<!-- <![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
|
||||
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer,这不影响你的浏览,但可能会有一些功能无法使用……</small></marquee><![endif]-->
|
||||
<div class="wrapper">
|
||||
<header class="h-card">
|
||||
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
|
||||
|
||||
|
||||
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
|
||||
|
||||
|
||||
<p class="p-note">Mayx's Home Page</p>
|
||||
|
||||
<form action="/search.html">
|
||||
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." /> <input type="submit" value="搜索" />
|
||||
</form>
|
||||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
|
||||
|
||||
<ul class="downloads">
|
||||
|
||||
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
|
||||
|
||||
</ul>
|
||||
</header>
|
||||
<section class="h-entry">
|
||||
|
||||
<small><time class="date dt-published" datetime="2022-12-26T00:00:00+08:00">26 December 2022</time> - 字数统计:2008 - 阅读大约需要7分钟 - Hits: <span id="/2022/12/26/i2p-ssl.html" class="visitors">Loading...</span></small>
|
||||
<h1 class="p-name">为自己的i2p站点添加一个SSL证书</h1>
|
||||
|
||||
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
|
||||
<div id="outdate" style="display:none;">
|
||||
<hr /><p>
|
||||
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
|
||||
</p>
|
||||
</div>
|
||||
<script>
|
||||
daysold = Math.floor((new Date().getTime() - new Date("Mon, 26 Dec 2022 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
|
||||
if (daysold > 90) {
|
||||
document.getElementById("outdate").style.display = "block";
|
||||
document.getElementById("outime").innerHTML = daysold;
|
||||
}
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
|
||||
<b>AI摘要</b>
|
||||
<p id="ai-output">这篇文章讲述了作者为自己的i2p站点添加SSL证书的探索过程。虽然i2p作为一个小项目没有官方认可的SSL证书,但有一个由PurpleI2P开发团队维护的自签名CA可以用于证书签名。申请过程相对简单,但部署到网站和配置有所挑战,因为缺乏相关的教程。作者最后成功配置并实现了网站的加密访问,但他提到i2p对SSL证书的管理不太严格,仅用于娱乐性质。此外,i2p的域名注册也很随意。整个过程虽然麻烦但充满了趣味性。</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
|
||||
<ul><li><a href="#起因">起因</a></li><li><a href="#探索i2p的ssl证书">探索I2P的SSL证书</a></li><li><a href="#感想">感想</a></li></ul>
|
||||
<hr />
|
||||
|
||||
|
||||
<main class="post-content e-content" role="main"><p>虽然没啥用,不过很有意思所以还是整一个!<!--more--></p>
|
||||
<h1 id="起因">
|
||||
|
||||
|
||||
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>在上个月,我用<a href="/2022/11/23/i2p.html">i2pd</a>和<a href="/2022/11/16/tor.html">tor</a>在两个不同的匿名网络上试着建了网站,不过因为这些网络的特性,他们不需要使用HTTPS访问就能保证内容不被窃取和篡改。不过SSL证书的意义不止这些,还有一个很重要的意义是验证网站身份,比如<a href="https://www.facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion/">Facebook</a>就有一个被信任的EV SSL证书,它的意义就是在保证其他人也偷偷算了一个facebook开头的域名(家用电脑大概花1天左右的时间就能算出来)时能很轻易的知道这个网站是不是真的Facebook的网站,因为EV SSL证书的审核很严格,基本上没办法去伪造一个相同公司的。Onion的DV SSL我查了一下,普通人倒是也能整,有家叫<a href="https://www.harica.gr/en/Products/SSL">HARICA</a>的证书商家每年花30EUR就可以在上面买一个。不过我嘛……肯定是不愿意花钱的,所以就打消了整Onion的证书的想法。</p>
|
||||
<h1 id="探索i2p的ssl证书">
|
||||
|
||||
|
||||
<a href="#探索i2p的ssl证书"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 探索I2P的SSL证书
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>那i2p域名呢?因为Tor有一定的政府背景,而且有大公司撑腰,所以受到了那些管理互联网的组织的承认,才会被允许注册可信的SSL证书。而i2p怎么说还是一个比较小的项目,虽然它可能是除了Tor外第二大的匿名路由网络(不是Freenet之类的共享内容的网络,那种东西没法交互),不过没有靠山,就不会被那些管理互联网的组织所承认,也就不可能允许注册可信的SSL证书……那难道就没有办法了吗?作为社区动力的项目,什么政府啊,还是什么标准化的组织都是没用的东西,不被承认可以自己承认!正好我在逛i2p那些网站的时候看到了一个由i2pd的开发团队PurpleI2P所维护的一个<a href="http://ca.i2pd.i2p/">CA</a>,从这个CA签名的证书虽然也只是自签名的,但是他们开发的浏览器<a href="https://github.com/PurpleI2P/i2pdbrowser">I2PdBrowser</a>内嵌了这个CA证书,所以也可以看作是可信的证书了(至少在这个浏览器上是)。具体的申请方法很简单,网站上都有说,给作者发邮件申请就行了,至于怎么用普通的邮箱给mail.i2p发邮件……只要把它替换成官方网关i2pmail.org就可以了。 </p><p>
|
||||
虽然证书很容易申请,但是申请下来的证书部署到网站上之后怎么才能被访问那还是挺麻烦的。因为网络上完全没有相关的教程,毕竟i2p用的人就少,i2pd更少,用i2pd还整SSL证书的人可能全世界一只手都数得过来😂。这没办法我只能先看着i2pd的文档先自己琢磨,结果怎么整效果都不对……没办法就只好问作者了,他回复的原文如下:</p>
|
||||
<blockquote>
|
||||
<p>It must be added like current tunnel for HTTP with same key. Example with HTTP and HTTPS:</p>
|
||||
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[website]
|
||||
type = http
|
||||
host = 127.0.0.1
|
||||
port = 8080
|
||||
inport = 80
|
||||
inbound.length = 2
|
||||
outbound.length = 2
|
||||
inbound.quantity = 3
|
||||
outbound.quantity = 3
|
||||
gzip = false
|
||||
keys = website.dat
|
||||
|
||||
[website-SSL]
|
||||
type = server
|
||||
host = 127.0.0.1
|
||||
port = 8443
|
||||
inport = 443
|
||||
keys = website.dat
|
||||
</code></pre></div> </div>
|
||||
<p>Note that I use same key file both for HTTP and HTTPS tunnel, and HTTPS (443 port) using type <code class="language-plaintext highlighter-rouge">server</code>, because i2pd mustn’t interact with encrypted by SSL data. </p><p>
|
||||
Also, you can skip the i2cp options in the second tunnel, because they apply to all tunnels with the same key. The main thing is to write them only in the first tunnel.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>这下我总算搞明白我之前配置的问题出在哪了😂,它文档里写的关于inport的说明是“what port at local destination server tunnel listens to. Same as port by default”,我看到它说的“local destination”以为是隧道访问的那个端口,结果是面向隐形网络的端口……怪不得我配置之后返回的证书老是443端口的证书……而且http隧道文档里也没有说到关于inport的参数啊,还有那个莫名其妙的ssl参数……这文档写的真是有点不太行…… </p><p>
|
||||
按照邮件说明配置好之后总算可以正常访问了,试了一下用I2PdBrowser访问我的网站终于出现了代表加密的小锁。</p>
|
||||
<h1 id="感想">
|
||||
|
||||
|
||||
<a href="#感想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 感想
|
||||
|
||||
|
||||
</h1>
|
||||
|
||||
<p>不过他们对生成证书的要求实在是不严格,我不需要证明任何东西,就能获得任意i2p网站的SSL证书(当然,也起不到验证网站身份的功能),不过由于这个网络的特点,也没办法中间人攻击,而且本来用的人就少,估计他们也是当玩吧😂,所以也没有认真搞。另外其实那个域名系统也一样,注册也很随便…… </p><p>
|
||||
不过搞的过程还是挺有意思的,如果有谁有兴趣也可以搞一个玩玩。</p></main>
|
||||
|
||||
|
||||
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=SSL"><em>SSL</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=i2p"><em>i2p</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E9%9A%90%E7%A7%81"><em>隐私</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BD%91%E7%BB%9C"><em>网络</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2022-12-26-i2p-ssl.md">查看原始文件</a></span></small>
|
||||
|
||||
|
||||
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
|
||||
<p id="suggest-container">Loading...</p>
|
||||
<script>
|
||||
var suggest = $("#suggest-container");
|
||||
$.get(BlogAPI + "/suggest?id=/2022/12/26/i2p-ssl.html&update=" + lastUpdated.valueOf(), function (data) {
|
||||
if (data.length) {
|
||||
getSearchJSON(function (search) {
|
||||
suggest.empty();
|
||||
var searchMap = {};
|
||||
for (var i = 0; i < search.length; i++) {
|
||||
searchMap[search[i].url] = search[i];
|
||||
}
|
||||
|
||||
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var item = searchMap[data[j].id];
|
||||
if (item) {
|
||||
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
|
||||
var contentPreview = item.content.substring(0, 100);
|
||||
if (item.content.length > 100) {
|
||||
contentPreview += "……";
|
||||
}
|
||||
link.hover(
|
||||
function(e) {
|
||||
tooltip.text($(this).data('content'))
|
||||
.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
})
|
||||
.show();
|
||||
},
|
||||
function() {
|
||||
tooltip.hide();
|
||||
}
|
||||
).mousemove(function(e) {
|
||||
tooltip.css({
|
||||
top: e.pageY + 10,
|
||||
left: e.pageX + 10
|
||||
});
|
||||
}).data('content', contentPreview);
|
||||
|
||||
suggest.append(link);
|
||||
suggest.append(' - ' + item.date + '<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
suggest.html("暂无推荐文章……");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
<div class="pagination">
|
||||
|
||||
<span class="prev">
|
||||
<a href="/2022/12/12/bt-s3-comp.html">
|
||||
上一篇:如何自定义宝塔亚马逊S3云存储插件的端点
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<br />
|
||||
|
||||
<span class="next">
|
||||
<a href="/2023/01/01/summary.html">
|
||||
下一篇:年终总结
|
||||
</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!--[if !IE]> -->
|
||||
<link rel="stylesheet" href="/assets/css/gitalk.css">
|
||||
<script src="/assets/js/gitalk.min.js"></script>
|
||||
|
||||
<div id="gitalk-container"></div>
|
||||
|
||||
<script>
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '36557aec4c3cb04f7ac6',
|
||||
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
|
||||
repo: 'mabbs.github.io',
|
||||
owner: 'Mabbs',
|
||||
admin: ['Mabbs'],
|
||||
id: '/2022/12/26/i2p-ssl', // Ensure uniqueness and length less than 50
|
||||
distractionFreeMode: false, // Facebook-like distraction free mode
|
||||
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
</script>
|
||||
<!-- <![endif]-->
|
||||
|
||||
</section>
|
||||
<!--[if !IE]> -->
|
||||
<div id="landlord" style="left:5px;bottom:0px;">
|
||||
<div class="message" style="opacity:0"></div>
|
||||
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
|
||||
<div class="live_talk_input_body">
|
||||
<form id="live_talk_input_form">
|
||||
<div class="live_talk_input_name_body" >
|
||||
<input type="checkbox" id="load_this" />
|
||||
<input type="hidden" id="post_id" value="/2022/12/26/i2p-ssl.html" />
|
||||
<label for="load_this">
|
||||
<span style="font-size: 11px; color: #fff;"> 想问这篇文章</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="live_talk_input_text_body">
|
||||
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
|
||||
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<input name="live_talk" id="live_talk" value="1" type="hidden" />
|
||||
<div class="live_ico_box" style="display:none;">
|
||||
<div class="live_ico_item type_info" id="showInfoBtn"></div>
|
||||
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
|
||||
<div class="live_ico_item type_music" id="musicButton"></div>
|
||||
<div class="live_ico_item type_youdu" id="youduButton"></div>
|
||||
<div class="live_ico_item type_quit" id="hideButton"></div>
|
||||
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
|
||||
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
|
||||
<input id="duType" value="douqilai" type="hidden" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="open_live2d">召唤伊斯特瓦尔</div>
|
||||
<!-- <![endif]-->
|
||||
<footer>
|
||||
<p>
|
||||
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-01 00:00:18<br /> 总字数:614622 - 文章数:178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/js/scale.fix.js"></script>
|
||||
<!--[if !IE]> -->
|
||||
<script src="/assets/js/main_new.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
|
||||
<script src="/Live2dHistoire/live2d/js/message.js"></script>
|
||||
<!-- <![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user