-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.xml
544 lines (262 loc) · 92 KB
/
search.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>hexo集成simiki搭建个人Wiki</title>
<link href="2020/08/20/hexo%E9%9B%86%E6%88%90simiki%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BAWiki/"/>
<url>2020/08/20/hexo%E9%9B%86%E6%88%90simiki%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BAWiki/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>一直想搭建个个人Wiki,放一些备忘的东西,苦于没有遇到合适的工具。今天无意之间在别人的博客看到了这个<a href="http://simiki.org/zh-docs/">simiki</a>,和hexo一样,都是基于Markdown的静态系统。于是折腾了一下,将这两者结合了起来。</p><h1>前提条件</h1><ul><li>Hexo目录:<code>D:\hexo</code></li><li>Wiki目录:<code>D:\wiki</code></li><li>本地系统:<code>Windows 10</code></li></ul><h1>具体步骤</h1><ul><li>按照simiki文档进行配置,确保output目录里有生成后的静态文件。</li><li>修改Wiki目录中的_config.yml文件,加入一行内容<code>root: /wiki</code></li><li>使用<code>mklink /j D:\hexo\source\wiki D:\wiki\output</code>,将Wiki目录软链接进hexo目录中。</li><li>修改hexo目录中的_config.yml文件,将<code>skip_render:""</code>替换为<code>skip_render: "wiki/**/*"</code>,否则hexo会渲染wiki目录中的文件,导致wiki中出现两种css。</li><li>使用<code>hexo clean & hexo generate & cd d:/wiki & simiki g & cd d:/hexo & hexo d</code>,一键部署hexo和wiki。</li></ul><h1>效果</h1><blockquote><p><a href="https://shura.eu.org/wiki">https://shura.eu.org/wiki</a></p></blockquote>]]></content>
<categories>
<category> tools </category>
</categories>
<tags>
<tag> windows </tag>
<tag> wiki </tag>
<tag> github </tag>
</tags>
</entry>
<entry>
<title>ipv6 NAT后配置端口转发</title>
<link href="2018/12/06/ipv6-NAT%E5%90%8E%E9%85%8D%E7%BD%AE%E7%AB%AF%E5%8F%A3%E8%BD%AC%E5%8F%91/"/>
<url>2018/12/06/ipv6-NAT%E5%90%8E%E9%85%8D%E7%BD%AE%E7%AB%AF%E5%8F%A3%E8%BD%AC%E5%8F%91/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>我校是先进行PPPOE认证,认证通过后在pppoe虚拟动态接口上通过DHCPv6下发ipv6地址,因此只能用ipv6 NAT让路由器下的终端进行ipv6地址的访问。之前按照网上的教程配置好了ipv6 nat,但是只能进行传出连接,为了优化PT的上传连接性,我们还需要让终端能建立传入连接。在<a href="https://nanyangpt.com/forums.php?action=viewtopic&topicid=5842">南洋pt的rewindcat1的帮助</a>下,我在我的路由器上实现了这个需求,配置ipv6端口转发的命令也是来源于他的脚本。</p><h1>前提条件</h1><ul><li>路由器系统:<code>OpenWrt 18.06.1</code></li><li>软件包:<code>bash ip6tables kmod-ip6tables kmod-ipt-nat6 luci-proto-ipv6</code></li><li>已经按照网上教程配置好ipv6 nat,即路由器下的终端设备能访问ipv6地址,我是通过如下命令配置的ipv6 nat,仅供参考。</li></ul><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ip -6 r add default via IPv6上游网关地址 dev pppoe-wan</span><br><span class="line">ip6tables -t nat -A POSTROUTING -o pppoe-wan -j MASQUERADE</span><br></pre></td></tr></table></figure><h1>具体步骤</h1><ul><li>在luci界面上,依次点击“网络”->“防火墙”->“通信规则”->“打开路由器端口”,填入共享名和外部端口,点击“添加”,然后“编辑”刚刚添加的规则,如下图所示,将区域都改为“任意区域”。<img data-src="https://pic.superbed.cn/item/5caf63ab3a213b04170ceb9a.jpg" alt="防火墙配置"></li><li>端口转发可参考下面的命令,将中文参数改为你自己的值即可,如果想要配置udp的端口转发,将tcp改为udp再运行一次命令就行了。</li></ul><p>模板:<code>ip6tables -t nat -A PREROUTING -d 公网ipv6地址 -p tcp --dport 转发端口号 -m comment --comment V6FWD -j DNAT --to-destination [目标ipv6地址]:目标端口号</code></p><p>实例:<code>ip6tables -t nat -A PREROUTING -d 2001:250:xxxx -p tcp --dport 49461 -m comment --comment V6FWD -j DNAT --to-destination [2fff::17c]:49461</code></p><h3 id="感谢评论区-唐海力-的补充,无需填入公网IP。">感谢评论区 @唐海力 的补充,无需填入公网IP。</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">ip6tables -t nat -I PREROUTING -p udp --dport 49461 -j DNAT --to [2fff::17c]:49461</span><br><span class="line">ip6tables -t nat -I PREROUTING -p tcp --dport 49461 -j DNAT --to [2fff::17c]:49461</span><br><span class="line">ip6tables -I INPUT -p udp --dport 49461 -j ACCEPT</span><br><span class="line">ip6tables -I INPUT -p tcp --dport 49461 -j ACCEPT</span><br></pre></td></tr></table></figure><h1>效果</h1><p>配置好端口转发,寝室的PC终于能愉快的刷pt,可以看到ut上确实有传入连接。<img data-src="https://pic.superbed.cn/item/5d8a1b8e451253d1785d5a6c.jpg" alt="ut用户列表"></p><blockquote><p>utorrent标识解释:U = 正在上传,I = 传入连接,E = 加密连接,P = μTP,X = 通过用户交换连接的peer</p></blockquote>]]></content>
<categories>
<category> 计算机网络 </category>
</categories>
<tags>
<tag> ipv6 </tag>
<tag> nat </tag>
<tag> openwrt </tag>
</tags>
</entry>
<entry>
<title>为 OpenVZ 构架 VPS 添加 ISATAP 隧道</title>
<link href="2018/10/08/%E4%B8%BAOpenVZ%E6%9E%84%E6%9E%B6VPS%E6%B7%BB%E5%8A%A0ISATAP%E9%9A%A7%E9%81%93/"/>
<url>2018/10/08/%E4%B8%BAOpenVZ%E6%9E%84%E6%9E%B6VPS%E6%B7%BB%E5%8A%A0ISATAP%E9%9A%A7%E9%81%93/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>之前一直用的是按照<a href="https://blog.rhilip.info/archives/705/">这篇文档</a>,配置的HE隧道。因为教育网ipv6出口在洛杉矶,所以虽然时延很高,但是速度却挺快的。然而最近我校网络中心对海外的ipv6连接进行了限速,在多次进行混淆操作无果后,我想把vps的ipv6换成清华的ISATAP隧道的,看看还会不会限速。</p><h1>操作</h1><p>通过参阅tb-tun<a href="https://github.com/acgrid/tb-tun/blob/master/HOWTO.md">官方文档</a>,可以发现用tb-tun也可以配置ISATAP。修改后的脚本如下:</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">! /bin/sh</span></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment">## BEGIN INIT INFO</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Provides: ipv6</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Required-Start: <span class="variable">$local_fs</span> <span class="variable">$all</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Required-Stop: <span class="variable">$local_fs</span> <span class="variable">$network</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Default-Start: 2 3 4 5</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Default-Stop: 0 1 6</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Short-Description: starts the ipv6 tunnel </span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Description: ipv6 tunnel start-stop-daemon</span></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment">## END INIT INFO</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> /etc/init.d/ipv6tb</span></span><br><span class="line">touch /var/lock/ipv6tb</span><br><span class="line">case "$1" in</span><br><span class="line"> start)</span><br><span class="line"> echo "Starting ipv6tb "</span><br><span class="line"> setsid /etc/tb_userspace isatap 166.111.21.1 [Client IPv4 Address] sit > /dev/null 2>&1 &</span><br><span class="line"> sleep 3s # ugly, but doesn't seem to work at startup otherwise</span><br><span class="line"> ifconfig isatap up</span><br><span class="line"> ifconfig isatap inet6 add 2402:f000:1:1501:200:5efe:[Client IPv4 Address]/64 # Add as many of these as you need from your routed /64 allocation</span><br><span class="line"> ifconfig isatap mtu 1480</span><br><span class="line"> route -A inet6 add ::/0 dev isatap</span><br><span class="line"> route -A inet6 del ::/0 dev venet0</span><br><span class="line"> ;;</span><br><span class="line"> stop)</span><br><span class="line"> echo "Stopping ipv6tb"</span><br><span class="line"> ifconfig isatap down</span><br><span class="line"> route -A inet6 del ::/0 dev tb</span><br><span class="line"> killall tb_userspace</span><br><span class="line"> ;;</span><br><span class="line"> *)</span><br><span class="line"> echo "Usage: /etc/init.d/ipv6tb <ruby>start<rp> (</rp><rt>stop</rt><rp>) </rp></ruby>"</span><br><span class="line"> exit 1</span><br><span class="line"> ;;</span><br><span class="line">esac</span><br><span class="line">exit 0</span><br></pre></td></tr></table></figure><p>其他的设置按照<a href="https://blog.rhilip.info/archives/705/">这篇文档</a>中的教程进行修改即可。</p><h1>效果</h1><p>比he隧道的效果好一些,不过还是被限速了。<img data-src="https://ws1.sinaimg.cn/large/77b38843ly1fw12up570gj20mm09nq32.jpg" alt="">本地时延还是很高,毕竟一次通信需要往返的时延。<img data-src="https://ws1.sinaimg.cn/large/77b38843ly1fw12vf1lrnj20hh01da9u.jpg" alt=""></p><h1>总结</h1><p>因为我的vps还顺便当seedbox用,为了兼顾与海外盒子做种的需要以及时延的考虑,还是用回之前的he隧道吧,23333。</p>]]></content>
<categories>
<category> 计算机网络 </category>
</categories>
<tags>
<tag> ipv6 </tag>
<tag> openvz </tag>
<tag> tb-tun </tag>
</tags>
</entry>
<entry>
<title>合肥移动IPTV抓包真实地址</title>
<link href="2018/06/19/%E5%90%88%E8%82%A5%E7%A7%BB%E5%8A%A8IPTV%E6%8A%93%E5%8C%85%E7%9C%9F%E5%AE%9E%E5%9C%B0%E5%9D%80/"/>
<url>2018/06/19/%E5%90%88%E8%82%A5%E7%A7%BB%E5%8A%A8IPTV%E6%8A%93%E5%8C%85%E7%9C%9F%E5%AE%9E%E5%9C%B0%E5%9D%80/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p><a href="http://www.txrjy.com/thread-1035495-1-1.html">移动宽带终于拿到IPTV的牌照了</a>,其之前使用的ott解决方案为<a href="http://www.ysten.com/product">易视腾</a>,该厂商也有iptv的解决方案,希望移动能早日从ott过渡到iptv,让用户能摆脱节目延迟播放的困扰。</p><p>今天无意中看到了这篇博文,<a href="https://www.polarxiong.com/archives/%E8%8B%8F%E5%B7%9E%E7%A7%BB%E5%8A%A8IPTV%E6%8A%93%E5%8C%85.html">苏州移动IPTV抓包 - Penguin</a>,按部就班地也抓了一下合肥移动的iptv地址。</p><h1>路由器抓包</h1><p>和原博主抓包方法不同,我的网络环境是光猫桥接-路由器拨号,因此我直接在路由器上用tcpdump抓包导出成文件再用Wireshark分析。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tcpdump -i br-lan -s 0 -w iptv.pcap</span><br></pre></td></tr></table></figure><h1>合肥移动IPTV真实地址</h1><p>合肥移动的url格式和苏州移动的格式差别不小,没有channelName,直接更改uuid即可。</p><ul><li>所有频道列表:<a href="http://looktvepg.aha.bcs.ottcn.com:8080/ysten-lvoms-epg/epg/getChannelIndexs.shtml?deviceGroupId=924">http://looktvepg.aha.bcs.ottcn.com:8080/ysten-lvoms-epg/epg/getChannelIndexs.shtml?deviceGroupId=924</a></li><li>构造URL:<a href="http://112.30.36.17:8112//120000001001/wlds:8080/ysten-business/live/uuid/1.m3u8">http://112.30.36.17:8112//120000001001/wlds:8080/ysten-business/live/uuid/1.m3u8</a></li><li>以CCTV-5为例,其真实地址为:<a href="http://112.30.36.17:8112//120000001001/wlds:8080/ysten-business/live/HD-8000k-1080P-cctv1/1.m3u8">http://112.30.36.17:8112//120000001001/wlds:8080/ysten-business/live/HD-8000k-1080P-cctv1/1.m3u8</a></li></ul><h1>2021年1月20日更新</h1><p>刚刚又抓了一下包,发现地址变了,而且多了个详细版的列表,其中直接带有m3u8地址,无需自己拼接了。另外都2021年了,移动还是OTT,实测有三分钟延迟。</p><ul><li><p>普通版频道列表:<a href="http://looktvepg.aha.bcs.ottcn.com:8080/ysten-lvoms-epg/epg/getChannelIndexs.shtml?deviceGroupId=4631&channelType=OMS">http://looktvepg.aha.bcs.ottcn.com:8080/ysten-lvoms-epg/epg/getChannelIndexs.shtml?deviceGroupId=4631&channelType=OMS</a></p></li><li><p>详细版频道列表:<a href="http://looktvepg.aha.bcs.ottcn.com:8080/ysten-lvoms-epg/epg/getNewPrograms.shtml?actionType=OpenNew&deviceGroupId=4631">http://looktvepg.aha.bcs.ottcn.com:8080/ysten-lvoms-epg/epg/getNewPrograms.shtml?actionType=OpenNew&deviceGroupId=4631</a></p></li><li><p>模板URL:<a href="http://120.210.193.151:8006/120000001001/wlds:8080/ysten-business/live/uuid/1.m3u8">http://120.210.193.151:8006/120000001001/wlds:8080/ysten-business/live/uuid/1.m3u8</a></p></li><li><p>以CCTV-1为例,其真实地址为:<a href="http://120.210.193.151:8006/120000001001/wlds:8080/ysten-business/live/cctv-1/1.m3u8">http://120.210.193.151:8006/120000001001/wlds:8080/ysten-business/live/cctv-1/1.m3u8</a></p><p>PS:高清频道需要将uuid中的8000k改为8M,例如安徽卫视高清频道的uuid是“HD-8000k-1080P-anhuistv”,其真实地址为:<a href="http://120.210.193.151:8006/120000001001/wlds:8080/ysten-business/live/HD-8M-1080P-anhuistv/1.m3u8">http://120.210.193.151:8006/120000001001/wlds:8080/ysten-business/live/HD-8M-1080P-anhuistv/1.m3u8</a></p></li></ul><h1>总结</h1><p>安徽移动应该都能访问这个URL,欢迎大家测试然后反馈给我。</p>]]></content>
<categories>
<category> 计算机网络 </category>
</categories>
<tags>
<tag> tcpdump </tag>
<tag> wireshark </tag>
<tag> iptv </tag>
<tag> 合肥移动 </tag>
</tags>
</entry>
<entry>
<title>博客内容恢复</title>
<link href="2018/05/23/%E5%8D%9A%E5%AE%A2%E5%86%85%E5%AE%B9%E6%81%A2%E5%A4%8D/"/>
<url>2018/05/23/%E5%8D%9A%E5%AE%A2%E5%86%85%E5%AE%B9%E6%81%A2%E5%A4%8D/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>在vps上操作的时候误删了_post文件夹,导致博文源代码全部丢失,于是只好手动根据html内容恢复源代码,正好把一些水文删了,把一些文章的图片地址更新了一下。</p><h1>教训</h1><ol><li>不要在生产环境上用<code>rm * -R</code>。</li><li>备份是个好习惯,你值得拥有。</li><li>openvz的vps是simfs格式的文件系统,文件一旦删除很难恢复。</li></ol>]]></content>
<categories>
<category> 站点 </category>
</categories>
<tags>
<tag> linux </tag>
<tag> 手贱 </tag>
</tags>
</entry>
<entry>
<title>在Ubuntu 18.04 LTS 服务器上配置静态IPv6地址</title>
<link href="2018/05/22/%E5%9C%A8Ubuntu-18.04-LTS%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E9%85%8D%E7%BD%AE%E9%9D%99%E6%80%81IPv6%E5%9C%B0%E5%9D%80/"/>
<url>2018/05/22/%E5%9C%A8Ubuntu-18.04-LTS%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E9%85%8D%E7%BD%AE%E9%9D%99%E6%80%81IPv6%E5%9C%B0%E5%9D%80/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>今天南洋pt开放注册,为了挂pt,我在digitalocean的vps上安装了deluge。可是教育网挂PT基本上都是ipv6,正好digitalocean也支持ipv6,可是没想到踩到Ubuntu 18.04的坑上了。</p><h1>过程</h1><p>Ubuntu 18.04的网络接口配置默认使用NetPlan,这个新工具取代了以前用于配置Ubuntu网络接口的静态接口(/etc/network/interfaces)文件。现在必须使用/etc/netplan/*.yaml来配置Ubuntu的网络接口。</p><p>所以在digitalocean配置静态ip应该修改/etc/netplan/50-cloud-init.yaml文件,填充为一下内容:</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># This file is generated from information provided by</span></span><br><span class="line"><span class="comment"># the datasource. Changes to it will not persist across an instance.</span></span><br><span class="line"><span class="comment"># To disable cloud-init's network configuration capabilities, write a file</span></span><br><span class="line"><span class="comment"># /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:</span></span><br><span class="line"><span class="comment"># network: {config: disabled}</span></span><br><span class="line"><span class="attr">network:</span></span><br><span class="line"> <span class="attr">version:</span> <span class="number">2</span></span><br><span class="line"> <span class="attr">ethernets:</span></span><br><span class="line"> <span class="attr">eth0:</span></span><br><span class="line"> <span class="attr">addresses:</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">公共ipv4地址/20</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">私有ipv4地址/16</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">公共ipv6地址/64</span></span><br><span class="line"> <span class="attr">gateway4:</span> <span class="string">公共ipv4网关</span></span><br><span class="line"> <span class="attr">gateway6:</span> <span class="string">公共ipv6网关</span></span><br><span class="line"> <span class="attr">match:</span></span><br><span class="line"> <span class="attr">macaddress:</span> <span class="string">MAC地址</span></span><br><span class="line"> <span class="attr">nameservers:</span></span><br><span class="line"> <span class="attr">addresses:</span></span><br><span class="line"> <span class="bullet">-</span> <span class="number">67.207</span><span class="number">.67</span><span class="number">.2</span></span><br><span class="line"> <span class="bullet">-</span> <span class="number">67.207</span><span class="number">.67</span><span class="number">.3</span></span><br><span class="line"> <span class="attr">set-name:</span> <span class="string">eth0</span></span><br></pre></td></tr></table></figure><p>然后输入下面的命令,应用此文件:</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netplan apply</span><br></pre></td></tr></table></figure><h1>效果</h1><p><img data-src="https://pic.superbed.cn/item/5cc1c0ff3a213b0417efde12.jpg" alt="digitalocean's ipv6"></p><h1>参考来源</h1><p><a href="https://websiteforstudents.com/configure-static-ip-addresses-on-ubuntu-18-04-beta/">Configure Static IP Addresses on Ubuntu 18.04 LTS Server – Website for Students</a></p>]]></content>
<categories>
<category> linux </category>
</categories>
<tags>
<tag> linux </tag>
<tag> ipv6 </tag>
<tag> ubuntu </tag>
</tags>
</entry>
<entry>
<title>Debian下koolproxy一键安装脚本</title>
<link href="2018/05/22/Debian%E4%B8%8Bkoolproxy%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E8%84%9A%E6%9C%AC/"/>
<url>2018/05/22/Debian%E4%B8%8Bkoolproxy%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E8%84%9A%E6%9C%AC/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>在vps上安装广告过滤软件配合shadowsocks,就可以实现代理+广告过滤。考虑到安全问题,只过滤HTTP内容,否则还得安装koolproxy的自定义证书,有安全隐患。</p><p>第一次运行脚本会安装koolproxy,以后再运行脚本就只更新规则了。防火墙规则重启之后失效,所以重启后需要再次运行脚本。</p><h1>一键安装</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">wget -O koolproxy.sh https://raw.githubusercontent.com/xiuluo/shell/master/koolproxy.sh</span><br><span class="line">bash koolproxy.sh</span><br></pre></td></tr></table></figure><h1>自动更新</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">crontab -e</span><br><span class="line"><span class="comment"># 每星期(周日凌晨4:22)更新</span></span><br><span class="line">22 4 * * 0 /root/koolproxy.sh</span><br></pre></td></tr></table></figure><h1>卸载</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">pkill -9 koolproxy</span><br><span class="line">rm -R koolproxy</span><br><span class="line">reboot</span><br></pre></td></tr></table></figure><h1>源代码</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/usr/bin/env bash</span></span><br><span class="line">PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/<span class="built_in">local</span>/bin:/usr/<span class="built_in">local</span>/sbin:~/bin</span><br><span class="line"><span class="built_in">export</span> PATH</span><br><span class="line">folder=<span class="string">"/root/koolproxy"</span></span><br><span class="line"><span class="comment">#install</span></span><br><span class="line"><span class="keyword">if</span> [ ! -d <span class="string">"<span class="variable">$folder</span>"</span> ]; <span class="keyword">then</span></span><br><span class="line"> mkdir <span class="variable">$folder</span></span><br><span class="line"> mkdir <span class="variable">$folder</span>/data</span><br><span class="line"> mkdir <span class="variable">$folder</span>/data/rules</span><br><span class="line"> <span class="built_in">cd</span> <span class="variable">$folder</span>/data/rules</span><br><span class="line"> wget https://kprule.com/koolproxy.txt</span><br><span class="line"> wget https://kprule.com/kp.dat</span><br><span class="line"> wget https://kprule.com/daily.txt</span><br><span class="line"> wget https://kprule.com/user.txt</span><br><span class="line"> <span class="built_in">cd</span> <span class="variable">$folder</span></span><br><span class="line"> wget -O koolproxy https://koolproxy.com/downloads/x86_64</span><br><span class="line"> chmod +x koolproxy</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment">#update</span></span><br><span class="line"><span class="keyword">if</span> [ -d <span class="string">"<span class="variable">$folder</span>"</span> ]; <span class="keyword">then</span></span><br><span class="line"> pkill -9 koolproxy</span><br><span class="line"> <span class="built_in">cd</span> <span class="variable">$folder</span>/data/rules</span><br><span class="line"> rm koolproxy.txt kp.dat daily.txt</span><br><span class="line"> wget https://kprule.com/koolproxy.txt</span><br><span class="line"> wget https://kprule.com/kp.dat</span><br><span class="line"> wget https://kprule.com/daily.txt</span><br><span class="line"> <span class="built_in">cd</span> <span class="variable">$folder</span></span><br><span class="line"> rm koolproxy</span><br><span class="line"> wget -O koolproxy https://koolproxy.com/downloads/x86_64</span><br><span class="line"> chmod +x koolproxy</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"1"</span> > /proc/sys/net/ipv4/ip_forward</span><br><span class="line">iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000</span><br><span class="line"><span class="built_in">cd</span> <span class="variable">$folder</span></span><br><span class="line">./koolproxy > <span class="variable">$folder</span>/data/koolproxy.log 2>&1 &</span><br></pre></td></tr></table></figure>]]></content>
<categories>
<category> linux </category>
</categories>
<tags>
<tag> linux </tag>
<tag> shell </tag>
</tags>
</entry>
<entry>
<title>sha256 hash算法的输出是否是均匀的?</title>
<link href="2018/05/15/sha256%E6%95%A3%E5%88%97%E7%AE%97%E6%B3%95%E7%9A%84%E8%BE%93%E5%87%BA%E6%98%AF%E5%90%A6%E6%98%AF%E5%9D%87%E5%8C%80%E5%88%86%E5%B8%83%E7%9A%84/"/>
<url>2018/05/15/sha256%E6%95%A3%E5%88%97%E7%AE%97%E6%B3%95%E7%9A%84%E8%BE%93%E5%87%BA%E6%98%AF%E5%90%A6%E6%98%AF%E5%9D%87%E5%8C%80%E5%88%86%E5%B8%83%E7%9A%84/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>5月16日更新</h1><p>今天偶然想到可以将单线程执行的for循环,拆成多线程来并发执行(在多核处理器上),用我的CPU(AMD A10 6700 3.7GHz 4核4线程)同样是生成一百万个sha256的散列值,所需的时间如下:</p><ul><li>单线程:time:26.917543172836304</li><li>多线程:time:17.500558376312256</li></ul><p><strong>所以“将for循环拆为多线程执行提高效率的”这个思路是可行的,因为没有涉及对同一地址空间读写,所以也不用考虑加锁问题。</strong></p><h1>前言</h1><p>最近偶然在v2ex看到<a href="https://www.v2ex.com/t/454535">这个问题</a>,直觉告诉我其输出显然是均匀分布在值域上的,否则就不满足香农的<a href="https://zh.wikipedia.org/wiki/%E6%B7%B7%E6%B7%86%E8%88%87%E6%93%B4%E6%95%A3">混淆与扩散</a>原则了。但是如何验证这个假设的正确性呢?</p><h1>验证方法</h1><p>找了很久,终于通过<a href="https://liam0205.me/2015/08/12/does-the-result-of-md5-hash-function-uniform/">这篇文章</a>学习到了验证这个假设的方法:算出散列算法结果的<a href="https://zh.wikipedia.org/zh-hans/%E7%86%B5_(%E4%BF%A1%E6%81%AF%E8%AE%BA)">信息熵</a>,生成大量散列输出,计算每一位的信息熵,与假设比较。</p><h1>模拟实验</h1><p>每一位的信息熵理论值:$$\sum_0^{15} - \frac{1}{16} \log_2 \frac{1}{16} = 4$$</p><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!/usr/bin/env python3</span></span><br><span class="line"><span class="comment"># -*- coding:utf-8 -*-</span></span><br><span class="line"><span class="keyword">import</span> threading</span><br><span class="line"><span class="keyword">from</span> hashlib <span class="keyword">import</span> sha256</span><br><span class="line"><span class="keyword">from</span> math <span class="keyword">import</span> log</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">entropy</span>(<span class="params">wkList</span>):</span> <span class="comment"># 计算信息熵</span></span><br><span class="line"> wkSet = set(wkList)</span><br><span class="line"> rate = {}</span><br><span class="line"> lenList = len(wkList)</span><br><span class="line"> <span class="keyword">for</span> k <span class="keyword">in</span> wkSet:</span><br><span class="line"> rate[k] = float(wkList.count(k)) / lenList</span><br><span class="line"> <span class="keyword">return</span> sum([-p * log(p, <span class="number">2</span>) <span class="keyword">for</span> p <span class="keyword">in</span> rate.values()])</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment"># def gen_sha(n):</span></span><br><span class="line"><span class="comment"># for i in range(n):</span></span><br><span class="line"><span class="comment"># s = sha256(str(i).encode('utf-8')).hexdigest()</span></span><br><span class="line"><span class="comment"># for j in range(64):</span></span><br><span class="line"><span class="comment"># if j not in wkDict:</span></span><br><span class="line"><span class="comment"># wkDict[j] = [s[j]]</span></span><br><span class="line"><span class="comment"># else:</span></span><br><span class="line"><span class="comment"># wkDict[j].append(s[j])</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">gen_sha</span>(<span class="params">_wkDict, start, stop</span>):</span></span><br><span class="line"> <span class="keyword">for</span> _i <span class="keyword">in</span> range(start, stop):</span><br><span class="line"> s = sha256(str(_i).encode(<span class="string">'utf-8'</span>)).hexdigest()</span><br><span class="line"> <span class="keyword">for</span> j <span class="keyword">in</span> range(<span class="number">64</span>):</span><br><span class="line"> <span class="keyword">if</span> j <span class="keyword">not</span> <span class="keyword">in</span> _wkDict:</span><br><span class="line"> _wkDict[j] = [s[j]]</span><br><span class="line"> <span class="keyword">else</span>:</span><br><span class="line"> _wkDict[j].append(s[j])</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line"></span><br><span class="line"> <span class="comment"># gen_sha(1000)</span></span><br><span class="line"> wkDict = {} <span class="comment"># key: 某个十六进制位; value: 该位上的所有结果</span></span><br><span class="line"> threads = []</span><br><span class="line"> threadNum = <span class="number">4</span></span><br><span class="line"> interval = int(<span class="number">1000000</span> / threadNum)</span><br><span class="line"> <span class="keyword">for</span> i <span class="keyword">in</span> range(threadNum):</span><br><span class="line"> threads.append(threading.Thread(target=gen_sha, args=(wkDict, i * interval, (i + <span class="number">1</span>) * interval)))</span><br><span class="line"> [t.start() <span class="keyword">for</span> t <span class="keyword">in</span> threads]</span><br><span class="line"> [t.join() <span class="keyword">for</span> t <span class="keyword">in</span> threads]</span><br><span class="line"></span><br><span class="line"> x = list(range(<span class="number">64</span>))</span><br><span class="line"> y = []</span><br><span class="line"> <span class="keyword">for</span> j <span class="keyword">in</span> x:</span><br><span class="line"> y.append(entropy(wkDict[j]))</span><br><span class="line"> plt.plot(x, y)</span><br><span class="line"> plt.xlim(<span class="number">0</span>, <span class="number">63</span>)</span><br><span class="line"> plt.ylim(<span class="number">3.9999</span>, <span class="number">4</span>)</span><br><span class="line"> plt.rcParams[<span class="string">'font.sans-serif'</span>] = [<span class="string">'SimHei'</span>] <span class="comment"># 设置中文字体</span></span><br><span class="line"> plt.xlabel(<span class="string">'十六进制位'</span>)</span><br><span class="line"> plt.ylabel(<span class="string">'信息熵'</span>)</span><br><span class="line"> plt.show()</span><br></pre></td></tr></table></figure><p><img data-src="https://ws1.sinaimg.cn/large/77b38843gy1frc8claimlj20hs0dcmxh.jpg" alt="实验结果"></p><h1>结论</h1><p>根据图像可以看出输出结果的每一个十六进制位的信息熵都无限接近于4,因此假设可能正确。该假设还可以推广到所有密码学散列函数上:密码学Hash函数的输出结果是均匀分布的。</p>]]></content>
<categories>
<category> 密码学 </category>
</categories>
<tags>
<tag> python </tag>
<tag> hash </tag>
<tag> 密码学 </tag>
</tags>
</entry>
<entry>
<title>利用travis-ci在线编译并发布二进制文件</title>
<link href="2018/03/17/%E5%88%A9%E7%94%A8travis-ci%E5%9C%A8%E7%BA%BF%E7%BC%96%E8%AF%91%E5%B9%B6%E5%8F%91%E5%B8%83%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6/"/>
<url>2018/03/17/%E5%88%A9%E7%94%A8travis-ci%E5%9C%A8%E7%BA%BF%E7%BC%96%E8%AF%91%E5%B9%B6%E5%8F%91%E5%B8%83%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>simple-obfs最新版支持obfs-uri功能,simple-obfs-android也有人及时跟进了这个特性。无奈作者没发布安装文件,我又懒得下载Android环境本地编译。但是因为这个作者使用travis-ci做了集成测试(这是个好习惯啊),所以我们可以通过travis-ci实现在线编译并下载安装包文件。</p><p>但是因为travis-ci不支持文件下载,所以我们只能先生成二进制然后发布到相应的平台上再下载,通过官网以看到travis-ci支持很多发布平台,本文以GitHub releases为例。</p><h1>操作步骤</h1><p>1.先安装ruby环境,再安装travis</p> <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">apt install ruby ruby-dev</span><br><span class="line">gem install travis</span><br></pre></td></tr></table></figure><ol start="2"><li>创建私钥并加密 先去https://github.com/settings/tokens/new 创建一个token,仅勾选repo。</li></ol><p><img data-src="https://pic.superbed.cn/item/5d8ad034451253d17877ae5d.jpg" alt="image"></p><ol start="3"><li>用下面的命令加密</li></ol> <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">travis encrypt <key> -r <owner>/<repo></span><br></pre></td></tr></table></figure><ol start="4"><li>修改fork后项目里的.travis.yml文件,再文件末尾加入以下内容</li></ol> <figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">before_deploy:</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">git</span> <span class="string">config</span> <span class="string">--local</span> <span class="string">user.name</span> <span class="string">"用户名"</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">git</span> <span class="string">config</span> <span class="string">--local</span> <span class="string">user.email</span> <span class="string">"邮箱"</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">git</span> <span class="string">tag</span> <span class="string">"$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)"</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">find</span> <span class="string">$HOME/</span> <span class="string">-name</span> <span class="string">"二进制文件名"</span> <span class="string">-exec</span> <span class="string">mv</span> {} <span class="string">$HOME/</span></span><br><span class="line"><span class="attr">deploy:</span></span><br><span class="line"> <span class="attr">provider:</span> <span class="string">releases</span></span><br><span class="line"> <span class="attr">api_key:</span></span><br><span class="line"> <span class="attr">secure:</span> <span class="string">"第2步在cli中生成的密文"</span></span><br><span class="line"> <span class="attr">file:</span> <span class="string">"$HOME/二进制文件名"</span></span><br><span class="line"> <span class="attr">skip_cleanup:</span> <span class="literal">true</span></span><br></pre></td></tr></table></figure><h1>踩坑经验</h1><ol><li>github会自动删除在其平台明文出现的token,所以官方文档是错误的,必须要对api_key加密;</li><li>必须要指明要发布的文件的完整路径,最便捷的方法就是在before_deploy用find找到文件并移动到home目录下;</li></ol><h1>效果</h1><p><img data-src="https://pic.superbed.cn/item/5d8ad071451253d17877b71e.jpg" alt="image"></p><p><img data-src="https://pic.superbed.cn/item/5d8ad096451253d17877bcc8.jpg" alt="image"></p><h1>参考来源</h1><ul><li><a href="https://docs.travis-ci.com/user/deployment/releases/">https://docs.travis-ci.com/user/deployment/releases/</a></li><li><a href="https://docs.travis-ci.com/user/encryption-keys/#Encryption-scheme">https://docs.travis-ci.com/user/encryption-keys/#Encryption-scheme</a></li></ul>]]></content>
<categories>
<category> github </category>
</categories>
<tags>
<tag> linux </tag>
<tag> github </tag>
<tag> travis-ci </tag>
</tags>
</entry>
<entry>
<title>用ffmpeg快速校验目录内的视频文件的完整性</title>
<link href="2018/03/09/%E7%94%A8ffmpeg%E5%BF%AB%E9%80%9F%E6%A0%A1%E9%AA%8C%E7%9B%AE%E5%BD%95%E5%86%85%E7%9A%84%E8%A7%86%E9%A2%91%E6%96%87%E4%BB%B6%E7%9A%84%E5%AE%8C%E6%95%B4%E6%80%A7/"/>
<url>2018/03/09/%E7%94%A8ffmpeg%E5%BF%AB%E9%80%9F%E6%A0%A1%E9%AA%8C%E7%9B%AE%E5%BD%95%E5%86%85%E7%9A%84%E8%A7%86%E9%A2%91%E6%96%87%E4%BB%B6%E7%9A%84%E5%AE%8C%E6%95%B4%E6%80%A7/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>第一次遇到遇到损坏的视频文件,想来应该是用VPS下载时文件出现了问题。用神器ffmpeg可在vps上快速地校验视频完整性。避免出现我这种用学校的小水管从vps拖回本地,下载了一个下午发现文件是损坏的悲剧。</p><h1>方法</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ffmpeg -v error -i filename.mkv -map 0:1 -f null -</span><br></pre></td></tr></table></figure><h2 id="规范化文件名">规范化文件名</h2><p>在下载动画的时候经常遇到类似于这种"[压制组&组2] 番名 [GB][1080P][x264_AAC×2].mp4"的文件,此文件名不符合Linux对文件名的规范要求,此时用上面的命令将无法生成log文件,需要批量重命名文件使其规范化。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">rename <span class="string">'s/[ ]+/_/g'</span> *</span><br><span class="line">rename <span class="string">"s/&/-/g"</span> *</span><br></pre></td></tr></table></figure><h2 id="递归检测">递归检测</h2><p>递归的对整个目录的视频文件进行快速校验,并且对每个视频文件都生成一个相对应的错误日志文件。如果没有错误则是个空文件。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">find . -name <span class="string">"*.mkv"</span> -o -name <span class="string">"*.mp4"</span> -<span class="built_in">exec</span> sh -c <span class="string">"ffmpeg -v error -i {} -map 0:1 -f null - 2>{}.log"</span> \;</span><br><span class="line"></span><br></pre></td></tr></table></figure><h2 id="效果">效果</h2><p><img data-src="https://ws1.sinaimg.cn/large/77b38843gy1fp6s1vtmu4j20pr0ef76o.jpg" alt="image"></p><p>用ll列出目录内文件,若log文件不为空则说明视频文件出现了错误。</p><p><img data-src="https://ws1.sinaimg.cn/large/77b38843gy1fp6sznk57nj20k103mq33.jpg" alt="image"></p><p><img data-src="https://ws1.sinaimg.cn/large/77b38843gy1fp6sxhf8sbj20mg0l8gqv.jpg" alt="image"></p><h1>来源</h1><p><a href="https://stackoverflow.com/questions/34077302/quickly-check-the-integrity-of-video-files-inside-a-directory-with-ffmpeg">https://stackoverflow.com/questions/34077302/quickly-check-the-integrity-of-video-files-inside-a-directory-with-ffmpeg</a></p>]]></content>
<categories>
<category> Linux </category>
</categories>
<tags>
<tag> linux </tag>
<tag> ubuntu </tag>
<tag> ffmpeg </tag>
</tags>
</entry>
<entry>
<title>在Linux kernel 4.13上使用BBR魔改版</title>
<link href="2018/01/30/%E5%9C%A8Linux-kernel-4.13%E4%B8%8A%E4%BD%BF%E7%94%A8BBR%E9%AD%94%E6%94%B9%E7%89%88/"/>
<url>2018/01/30/%E5%9C%A8Linux-kernel-4.13%E4%B8%8A%E4%BD%BF%E7%94%A8BBR%E9%AD%94%E6%94%B9%E7%89%88/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>所谓的bbr魔改版最初是由hostloc论坛的用户Yankee发布的。因为原贴设置了阅读权限,所以我只能找到<a href="https://www.91yun.co/archives/16781">转帖</a>和其修改的<a href="https://gist.githubusercontent.com/anonymous/ba338038e799eafbba173215153a7f3a/raw/55ff1e45c97b46f12261e07ca07633a9922ad55d/tcp_tsunami.c">源码</a>。该魔改版通过修改bbr中的一些参数使该拥塞协议较之Linux kernel中的协议更加“暴力”(但与此同时也破坏了tcp的公平性,如果这样做的人多了,反而会引起更加严重的网络拥塞),解决拥塞的效果更加明显。但是该修改版无法在Linux kernel 4.13+上编译,需要使用<a href="https://github.com/liberal-boy/tcp_tsunami">另一个修改版</a>。</p><h1>使用教程</h1><ol><li>使用root权限在shell里依次输入一下命令,编译内核模块并插入内核,启用新的拥塞协议</li></ol> <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">apt install make gcc</span><br><span class="line">wget -O ./tcp_tsunami.c https://raw.githubusercontent.com/liberal-boy/tcp_tsunami/master/tcp_tsunami.c</span><br><span class="line"><span class="built_in">echo</span> <span class="string">"obj-m:=tcp_tsunami.o"</span> > Makefile</span><br><span class="line">make -C /lib/modules/$(uname -r)/build M=`<span class="built_in">pwd</span>` modules CC=/usr/bin/gcc</span><br><span class="line">cp -rf ./tcp_tsunami.ko /lib/modules/$(uname -r)/kernel/net/ipv4</span><br><span class="line">insmod tcp_tsunami.ko</span><br><span class="line">sysctl -w net.core.default_qdisc=fq</span><br><span class="line">sysctl -w net.ipv4.tcp_congestion_control=tsunami</span><br><span class="line"></span><br></pre></td></tr></table></figure><ol start="2"><li>查看内核模块:<code>lsmod | grep tcp_tsunami</code></li><li>查看tcp拥塞协议:<code>cat /proc/sys/net/ipv4/tcp_congestion_control</code><img data-src="https://ws1.sinaimg.cn/large/77b38843ly1fnymle445tj20h404gq32.jpg" alt="image"></li></ol><p>PS:重启后需要重新加载内核,启用协议(为了安全起见,不要设置自启)</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">insmod tcp_tsunami.ko</span><br><span class="line">sysctl -w net.core.default_qdisc=fq</span><br><span class="line">sysctl -w net.ipv4.tcp_congestion_control=tsunami</span><br></pre></td></tr></table></figure><h1>效果</h1><ul><li><p>服务器:<a href="https://m.do.co/c/4c2ccc8b2845">digitalocean</a>旧金山2号机房+共享1G出口带宽(Linux ubuntu 4.13.0-32-generic #35-Ubuntu SMP Thu Jan 25 09:13:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux)</p></li><li><p>客户端:<a href="https://wikidevi.com/wiki/MediaTek_MT7621">MediaTek MT7621</a> + 50M中国移动带宽(Linux RT-N56U_B1 3.4.113 #3 SMP Tue Jan 16 23:14:25 CST 2018 mips GNU/Linux)</p></li></ul><h2 id="测速">测速</h2><p>在两个著名的测试网站测试,都能很快达到宽带的标称速率,当然这主要归功于移动国际出口的用户少,没有明显的拥塞,如果是电信的163线路,再暴力的拥塞协议都抵不过ISP的QoS。<img data-src="https://ws1.sinaimg.cn/large/77b38843ly1fnymm0n2vpj20jt0nyq3k.jpg" alt="image"><img data-src="https://ws1.sinaimg.cn/large/77b38843ly1fnymqmih96j20rj0c4q3k.jpg" alt="image"></p><h1>扩展阅读</h1><ol><li>之所以50M带宽,能跑出50M以上的速度。我猜测可能是因为移动在流量整形中使用了令牌桶算法,该算法能够在限制数据的平均传输速率的同时还允许某种程度的突发传输。但是这些流量都是你自己令牌桶中剩余的,所以你是无法一直突破标称速率的。</li><li></li><li>speedtest里显示Google是因为我修改了http header里的X-Forwarded-For参数,很多网站提供这个参数获取用户在访问时CDN的IP地址,但是显然这种做法并不安全。</li></ol>]]></content>
<categories>
<category> Linux </category>
</categories>
<tags>
<tag> linux </tag>
<tag> ubuntu </tag>
<tag> bbr </tag>
</tags>
</entry>
<entry>
<title>又双叒叕迁移网站了</title>
<link href="2018/01/10/%E5%8F%88%E5%8F%8C%E5%8F%92%E5%8F%95%E8%BF%81%E7%A7%BB%E7%BD%91%E7%AB%99%E4%BA%86/"/>
<url>2018/01/10/%E5%8F%88%E5%8F%8C%E5%8F%92%E5%8F%95%E8%BF%81%E7%A7%BB%E7%BD%91%E7%AB%99%E4%BA%86/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>用了一下午的时间又又将网站转移到了github page上。现在hexo的生态圈很成熟,动态博客的一些功能都能找到相应的插件替代,甚至连<a href="https://github.com/jaredly/hexo-admin">后台管理</a>的插件都有了。<img data-src="https://pic.superbed.cn/item/5d8ad461451253d178783720.jpg" alt="image"></p><h1>主机</h1><p>github pages配合CDN应该能持续很久不用迁移网站。虽然因为科学上网的需求我有一些海外vps,但是回顾一下去年gfw的疯狂认证,还是低调使用吧。</p><h1>CDN</h1><p>cloudflare与电信直接peer,移动到cloudflare走香港的数据中心,现在就联通到cloudflare比较慢了。cloudflare还可以通过cname托管,实现直接将IP解析到cloudflare的精品网段,可以使用更多的机房,低调使用cloudflare也就睁一只眼闭一只眼。</p><h1>域名</h1><p>eu.org从1996年开始提供免费域名服务,虽然是二级域名,可是能够被搜索引擎收录,已经很好了。不知道为什么,于2015年被gfw认证,不过可以用https+HSTS+HSTS preload list完美解决。</p><p>解析倒是一个麻烦的事情,国内的域名解析服务都要实名认证,国外免费的解析服务都不支持裸域cname(dnspod国际版倒是支持,不过已经停止维护了,用着没有安全感),最后用京东云解析了,免费版还给SLA 99.99%的保证。</p><h1>博客主题</h1><p><a href="http://theme-next.iissnan.com/getting-started.html">next主题</a>比我16年用的时候功能丰富了许多而且文档也很详尽,主要集成了很多第三方服务和插件,让静态博客也有了动态博客的体验。</p><h1>图床</h1><p>用的是Chrome扩展,由新浪提供服务器资源,支持https,还提供MD格式的导出,很方便。<img data-src="https://ws1.sinaimg.cn/large/77b38843ly1fnf5lbvecgj20ws0mo0ti.jpg" alt="image"></p><h1>总结</h1><p>博客能提供一个安安静静写东西的地方即可,不用太多折腾,还是用海外的免费服务长久一些。</p><ul><li>2018年5月23日注:果然啪啪打脸,在vps误用<code> rm -R xxx*</code>,将_post文件夹整个都删除了,而且我的博客专用vps还是基于openvz,无法直接挂载硬件恢复文件,只能一个一个手动恢复了,也是够折腾的。备份是个好习惯!</li></ul>]]></content>
<categories>
<category> 站点 </category>
</categories>
<tags>
<tag> hexo </tag>
<tag> github-pages </tag>
</tags>
</entry>
<entry>
<title>Android Studio gradle代理https失败的解决办法</title>
<link href="2016/08/10/Android-Studio-gradle%E4%BB%A3%E7%90%86https%E5%A4%B1%E8%B4%A5%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/"/>
<url>2016/08/10/Android-Studio-gradle%E4%BB%A3%E7%90%86https%E5%A4%B1%E8%B4%A5%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>这篇文章所有的方法全都是在stackoverflow上找到的,我也是最近强迫自己使用英语搜索,才发现stackoverflow的好处。以前虽然看一些大牛说stackoverflow是开发者圣,但是我基本都是用中文作为关键词搜索,虽然同样是在Google上搜索,但是找到的内容不可相提并论。越来越后悔以前没有好好学英语了,只能慢慢补了。</p><h1>设置gradle代理</h1><p>在 USER_HOME/.gradle/中新建一个gradle.properties,然后输入以下内容</p><figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">systemProp.https.proxyHost</span>=<span class="string">127.0.0.1</span></span><br><span class="line"><span class="meta">systemProp.https.proxyPort</span>=<span class="string">1080</span></span><br><span class="line"><span class="meta">systemProp.http.proxyHost</span>=<span class="string">127.0.0.1</span></span><br><span class="line"><span class="meta">systemProp.http.proxyPort</span>=<span class="string">1080</span></span><br><span class="line"><span class="meta">systemProp.socks.proxyHost</span>=<span class="string">127.0.0.1</span></span><br><span class="line"><span class="meta">systemProp.socks.proxyPort</span>=<span class="string">1080</span></span><br></pre></td></tr></table></figure><h2 id="解决https证书错误">解决https证书错误</h2><p>设置好代理之后,可能出现htpps代理失败的问题。因为jc库默认是https的,我用的免费代理软件,需要导入自签证书才能使用。然而我安装官方教程使用keytool向java导入了CA证书,还是无法使用。一般会显示如下的错误</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">"Error:(26, 13) Failed to resolve: com.alibaba:fastjson:1.1.34.android"</span></span><br><span class="line"><span class="string">"Error:A problem occurred configuring project ':app'.peer not authenticated.</span></span><br></pre></td></tr></table></figure><p>去代理软件后台看到其报错</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Aug 10 16:59:59.618 - [INFO] ssl error: [SSL: SSLV3_ALERT_CERTIFICATE_UNKNOWN] sslv3 alert certificate unknown (_ssl.c:590),create full domain cert <span class="keyword">for</span> host:jcenter.bintray.com</span><br></pre></td></tr></table></figure><p>就是因为软件不能信任我们自己的证书,所以导致https通讯失败。而解决办法就是将jcenter仓库地址替换为http。即将build.gradle中的</p><figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">repositories</span> {</span><br><span class="line"> jacenter()</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>全部替换为(应该有两个,一个是app的,一个是module的)</p><figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">repositories</span> {</span><br><span class="line"> jcenter </span><br><span class="line"> { </span><br><span class="line"> url <span class="string">'http://jcenter.bintray.com'</span> </span><br><span class="line"> } </span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="永久替换jcenter">永久替换jcenter()</h2><p>按照上述方法,就成功的设置了代理。但是缺点是需要每次新建项目后都修改一下仓库地址,尤其是初学Android时,基本上每个示例都要新建一个项目,难不成每个都改一遍么?当然不可能,自然有替换方法,将下面的内容,保存为init.gradle,和gradle.properties一样,也放到USER_HOME/.gradle/中。</p><figure class="highlight gradle"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">allprojects</span>{</span><br><span class="line"> <span class="keyword">repositories</span> {</span><br><span class="line"> <span class="keyword">def</span> REPOSITORY_URL = <span class="string">'http://jcenter.bintray.com/'</span></span><br><span class="line"> all { ArtifactRepository repo -&gt;</span><br><span class="line"> <span class="keyword">println</span> repo.url.toString()</span><br><span class="line"> <span class="keyword">if</span> ((repo <span class="keyword">instanceof</span> MavenArtifactRepository) &amp;&amp; repo.url.toString().startsWith(<span class="string">"https://jcenter.bintray.com/"</span>)) {</span><br><span class="line"> <span class="keyword">project</span>.logger.lifecycle <span class="string">"Repository ${repo.url} replaced by $REPOSITORY_URL."</span></span><br><span class="line"> remove repo</span><br><span class="line"> } </span><br><span class="line"> }</span><br><span class="line"> jcenter { </span><br><span class="line"> url REPOSITORY_URL</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>重新打开Android Studio并进行同步gradle,你会发现一切都正常了。</p><p>init.gradle是Gradle的初始化脚本(Initialization Scripts),会再每次gradle运行时执行,即上述代码是在gradle运行时修改jcenter仓库链接而不会去修改build.gradle文件里的内容。</p><h1>参考来源</h1><ul><li><a href="https://stackoverflow.com/questions/27056733/change-gradle-mavencentral-url-to-my-repo">https://stackoverflow.com/questions/27056733/change-gradle-mavencentral-url-to-my-repo</a></li><li><a href="https://stackoverflow.com/questions/27206040/android-studio-intellij-gradle-errorcause-peer-not-authenticated">https://stackoverflow.com/questions/27206040/android-studio-intellij-gradle-errorcause-peer-not-authenticated</a></li><li><a href="http://gradle.org/docs/current/userguide/init_scripts.html">http://gradle.org/docs/current/userguide/init_scripts.html</a></li></ul>]]></content>
<categories>
<category> Android </category>
</categories>
<tags>
<tag> Linux </tag>
<tag> Android </tag>
<tag> gradle </tag>
</tags>
</entry>
<entry>
<title>Bash On Windows beta版食用笔记</title>
<link href="2016/08/03/Bash-On-Windows-beta%E7%89%88%E9%A3%9F%E7%94%A8%E7%AC%94%E8%AE%B0/"/>
<url>2016/08/03/Bash-On-Windows-beta%E7%89%88%E9%A3%9F%E7%94%A8%E7%AC%94%E8%AE%B0/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>微软于今天发布了Windows一周年版(RS1,1607版,10.0.14393,版本名真多),其中我感兴趣的就是Bash On Windows这个功能了,这个就是Windows内嵌了一个Linux子系统,只不过目前还是beta版,所以和原生的Ubuntu功能上有些缺陷,不过大部分软件都是可以正常使用的,启动这个功能的方式网上一大堆,这里就不再赘述了。只是有个小坑,开启bash功能后,需要在cmd或powershell里输入bash,它会下载一个镜像文件完成初始化工作,此时它会提示“正在从 Windows 应用商店下载…”,如果你在用一些小运营商的宽度,会立即显示“无法从 Windows 应用商店下载。请检查网络连接。”,然而我打开应用商店却能正常下载应用啊。</p><p><img data-src="https://ws1.sinaimg.cn/large/77b38843gy1frkj4fqhi7j20as04c3yo.jpg" alt=""></p><p>而事实上它并不是从Windows应用商店上下载的,而且通过访问这里,跳转到微软的一个CDN上,而这个CDN并没有国内节点(我写这篇文章的时候,微软已经把那个链接跳转到Ubuntu网站了,然而依旧没有国内节点),所以你懂得,而解决办法也很简单,给IE设置个代理就可以了,这个包大小为180.02MB,而且微软的下载机制没有考虑到断点续传,so有一点网络波动,你就得重下(我不会告诉你我下了十几次,真坑啊)。<img data-src="https://ws1.sinaimg.cn/large/77b38843gy1frkj50n8mwj20m20a9gmq.jpg" alt=""></p><h1>换源</h1><p>之后你从cmd或者ps里输入bash就可以进入Linux子系统啦,后面的操作就和你用ubuntu一模一样,比如你用ubuntu一般都会换源的吧,默认镜像是14.04的,你按照同样的方法就可以换源了。(其实你直接通过修改sources.list就能从14.04升级到16.04了,不过我在BashOnWindows的issue里看到有人升级会出问题,虽然有解决方法,但是我感觉微软工程师应该是基于14.04进行开发的,所以建议没必要不要升级大版本,除非微软推送镜像包)</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo sed -i <span class="string">'s/archive.ubuntu.com/mirrors.163.com/g'</span> /etc/apt/sources.list</span><br><span class="line">sudo sed -i <span class="string">'s/security.ubuntu.com/mirrors.163.com/g'</span> /etc/apt/sources.list</span><br></pre></td></tr></table></figure><h1>取消系统提示音</h1><p>如果你进入shell没有输入认识内容,直接按回车,就会触发系统提示音,反正我觉得这个声音听起来挺烦的,你可以输入:</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo <span class="built_in">echo</span> <span class="string">"set bell-style none"</span> >> ~/.inputrc</span><br></pre></td></tr></table></figure><p>但是这个不能取消掉VIM里的提示声,你可以选择关闭系统声音,按照如下步骤:打开控制面板——>打开硬件和声音——>打开声音——>选择声音——>修改关键性停止的声音方案,来取消提示音。<img data-src="https://ws1.sinaimg.cn/large/77b38843gy1frkj7ccx4tj20cs0g1dgh.jpg" alt=""></p><h1>美化</h1><p>如果你以后经常用这个子系统,那么肯定不能忍受cmd的字体和配色,我之前用cygwin时喜欢用cmder,但是cmder和bash.exe不兼容,如果你直接输入bash,那么进入子系统后将无法使用方向键和Home/PageUp/PageDown等键,需要输入下面的命令进入bash</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">%windir%\system32\bash.exe -cur_console:p1</span><br></pre></td></tr></table></figure><p>你可以把这个命令加入cmder的启动项里<img data-src="https://ws1.sinaimg.cn/large/77b38843gy1frkj8cnd44j20lb0dowfr.jpg" alt="">我个人习惯用zsh了,而进入这个子系统必须先进入bash(这背后一定有交易,手动滑稽),所以启动项里多了个zsh的切换命令。</p><p>PS:这个子系统的文件系统和Windows是融合的,进入bash后默认路径为你的用户文件夹内(/mnt/c/Users/Shura),所以你每次下载时确保当前目录在home目录(~)下,否则你可以会发现你把文件下载到Windows分区里了-XD</p><h1>8月7日更新</h1><p>感谢 @Snapsisy的方法,输入bash ~即可从~启动bash,不用再切换目录了。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">%windir%\system32\bash.exe ~ -cur_console:p1</span><br></pre></td></tr></table></figure><p>最后Show一下</p><p><img data-src="https://ws1.sinaimg.cn/large/77b38843gy1frkj9mzc1mj20jb0d40tn.jpg" alt=""></p>]]></content>
<categories>
<category> Linux </category>
</categories>
<tags>
<tag> Linux </tag>
<tag> windows </tag>
<tag> bash </tag>
</tags>
</entry>
<entry>
<title>长城宽带等小运营商PPPoE频繁掉线重连解决办法</title>
<link href="2016/07/27/%E9%95%BF%E5%9F%8E%E5%AE%BD%E5%B8%A6%E7%AD%89%E5%B0%8F%E8%BF%90%E8%90%A5%E5%95%86PPPoE%E9%A2%91%E7%B9%81%E6%8E%89%E7%BA%BF%E9%87%8D%E8%BF%9E%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/"/>
<url>2016/07/27/%E9%95%BF%E5%9F%8E%E5%AE%BD%E5%B8%A6%E7%AD%89%E5%B0%8F%E8%BF%90%E8%90%A5%E5%95%86PPPoE%E9%A2%91%E7%B9%81%E6%8E%89%E7%BA%BF%E9%87%8D%E8%BF%9E%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>吐槽</h1><p>这个月被这个垃圾宽带折腾死了,总是不定期的掉线要重新拨号,这里就要介绍一下了,我家里有两个路由器,一个是如意云(就是现在的联想路由器的前身)刷了OpenWrt系统,另一个就是TP-Link了。</p><p>一开始遇到这个问题,我还以为是我路由器问题,因为把网线直接插电脑可以正常拨号,于是我就换上了家里旧的TP-Link,然后就一切就仿佛正常了,因为我要用路由器全局去广告 :oops: ,所以不得不用上了双路由器。入户线插TP-Link的WAN口关闭其无线模块,然后从其LAN口上用网线与如意云WAN口相连,然后全家设备全连如意云。这样也仿佛没有问题了,可是我还是没有发现问题本质,于是谷歌得知可能是因为OpenWrt默认发送lcp-echo(让运营商服务器发送请求,确认自己是否在线)导致的,因为TP-Link默认不发送lcp-echo,于是我把OpenWrt里的lcp-echo发送间隔调到非常大,等于关闭了。但是问题还是没有解决,只有用TP-Link才正常,用如意云就是不正常。 :-(</p><p>本来到这里,我就打算一直用双路由器了,但是最近几天,断网太频繁了,我也发现并非是因为TP-Link就正常了,而是TP-Link能自动重新进行PPPoE拨号连接,而OpenWrt在PPPoE掉线之后无法重新连接,需要断电重启(就是这个问题害得我研究了好久,真坑啊!),以前拨号掉线不频繁,TP-Link重连机制让我以为没有问题了。到这里,我就怀疑是不是线路问题,因为我在学校网络中心兼职,平时也帮老师维护这些网络问题,一般这样都是端口接触不良。没辙,只能打电话给客服,维修人员下午来了之后,用测线仪测了一下线路,电信号都正常,为了应付我,他还是给我换了水晶头,然而问题并没有解决,反而更严重了,一晚上能掉十几次线。</p><p>于是我再次骚扰客服,最后他们怀疑我家里装修时埋的网线有问题,要给我重新拉个明线,然而我在家等了一天也没人来拉线,打电话问维修,他说是我家模块有问题,balabala,至此我对长宽维修人员已经彻底失去信心,因为线路是通的,所以我一直坚信是运营商的问题,然后我把网线直接插电脑,一直在那里看有线状态(大哭),皇天不负有心人,终于发现问题所在了,交换机和电脑网卡端口速率协商有问题,有时候协商出10Mbps,有时候协商出100Mbps,而每次重新协商都会导致有线连接中断,拨号当然也断了啊。这长城宽带为了节省成本,把一根网线分成双绞线,给两户人家用,端口都不知道怎么设置的,导致根本协商不出来正确的速度。</p><h1>解决方案</h1><p>请强制设置路由器或者电脑的WAN口速率,4M以下宽带选择10M半双工,4M-8M宽带选择10M全双工,10M-20M宽带选择100M半双工,20M-100M宽带选择100M全双工。不要相信这些小运营商交换机的自动协商,我估计它们交换机早就年久失修了,实在太坑了啊。</p>]]></content>
<categories>
<category> 宽带 </category>
</categories>
<tags>
<tag> 长城宽带 </tag>
<tag> PPPoE </tag>
</tags>
</entry>
<entry>
<title>Python批量获取京东商品列表信息</title>
<link href="2016/07/27/Python%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E4%BA%AC%E4%B8%9C%E5%95%86%E5%93%81%E5%88%97%E8%A1%A8%E4%BF%A1%E6%81%AF/"/>
<url>2016/07/27/Python%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E4%BA%AC%E4%B8%9C%E5%95%86%E5%93%81%E5%88%97%E8%A1%A8%E4%BF%A1%E6%81%AF/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><p>今天在逛网站的时候无意间发现一个京东获取单个商品价格接口:</p><blockquote><p><a href="http://p.3.cn/prices/mgets?skuIds=J_%E5%95%86%E5%93%81ID&type=1">http://p.3.cn/prices/mgets?skuIds=J_商品ID&type=1</a></br> ps:商品ID这么获取:<a href="http://item.jd.com/954086.html">http://item.jd.com/954086.html</a></p></blockquote><p>于是我就从Google上找了利用此接口批量获取价格信息的源码,稍作修改使其支持Python3(PS:通过这段代码,我对Python的易用性不再怀疑了,23333)</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/usr/bin/env python</span></span><br><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line">import requests</span><br><span class="line">from bs4 import BeautifulSoup</span><br><span class="line"></span><br><span class="line">url = <span class="string">'http://list.jd.com/list.html?cat=9987,653,655&amp;page=1&amp;delivery=1&amp;trans=1&amp;JL=4_21_0'</span></span><br><span class="line">request = requests.get(url)</span><br><span class="line">soup = BeautifulSoup(request.text, <span class="string">"html.parser"</span>)</span><br><span class="line">items = soup.select(<span class="string">'li.gl-item'</span>)</span><br><span class="line">i = 1</span><br><span class="line"><span class="keyword">for</span> item <span class="keyword">in</span> items:</span><br><span class="line"> sku = item.find(<span class="string">'div'</span>)[<span class="string">'data-sku'</span>]</span><br><span class="line"> price_url = <span class="string">'http://p.3.cn/prices/mgets?skuIds=J_'</span> + str(sku)</span><br><span class="line"> price = requests.get(price_url).json()[0][<span class="string">'p'</span>]</span><br><span class="line"> name = item.find(<span class="string">'div'</span>, class_=<span class="string">"p-name"</span>).find(<span class="string">'em'</span>).string</span><br><span class="line"> item_url = <span class="string">'http:'</span> + item.find(<span class="string">'div'</span>, class_=<span class="string">"p-name"</span>).find(<span class="string">'a'</span>)[<span class="string">'href'</span>]</span><br><span class="line"> commit = item.find(<span class="string">'div'</span>, class_=<span class="string">"p-commit"</span>).find(<span class="string">'a'</span>).string</span><br><span class="line"> <span class="built_in">print</span>(<span class="string">"%d、\n 名称: %s \n 价格: %s 元 \n 评价: %s 个 \n 链接: %s"</span> % (i, name, price, commit, item_url))</span><br><span class="line"> <span class="keyword">if</span> i &gt;= 10:</span><br><span class="line"> <span class="built_in">break</span></span><br><span class="line"> <span class="keyword">else</span>:</span><br><span class="line"> i += 1</span><br></pre></td></tr></table></figure>]]></content>
<categories>
<category> python </category>
</categories>
<tags>
<tag> jd </tag>
<tag> python </tag>
</tags>
</entry>
<entry>
<title>Windows配置Cygwin或msys2模拟Linux终端环境</title>
<link href="2016/04/09/Windows%E9%85%8D%E7%BD%AECygwin%E6%88%96msys2%E6%A8%A1%E6%8B%9FLinux%E7%BB%88%E7%AB%AF%E7%8E%AF%E5%A2%83/"/>
<url>2016/04/09/Windows%E9%85%8D%E7%BD%AECygwin%E6%88%96msys2%E6%A8%A1%E6%8B%9FLinux%E7%BB%88%E7%AB%AF%E7%8E%AF%E5%A2%83/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>(Update:2016-08-20)推荐使用msys2</h1><p>今天试了一下msys2,真的比cygwin好用多了,主要体现在包管理上,而且软件包都比cygwin新。大家可以按照<a href="https://segmentfault.com/a/1190000002789600">从cygwin迁移到msys2的原因和步骤</a>中的步骤来迁移。之前有人评论让我用msys2,我没有去尝试而且还敷衍了他,现在向他表示歉意。</p><h1>原文</h1><p>今天想个Windows配个linux终端,但网上的cygwin安装教程都比较旧,软件链接基本都失效了,所以我折腾了一下,整理了这篇笔记。(非常期待Windows预览版内置的Linux 子系统,这篇笔记可能以后就用不上喽!)</p><p>下载Cygwin <a href="https://cygwin.com/setup-x86_64.exe%EF%BC%8C%E9%BB%98%E8%AE%A4%E5%AE%89%E8%A3%85%E4%B9%8B%E5%90%8E%EF%BC%8C%E5%B0%86C:%5Ccygwin64%5Cbin%E5%8A%A0%E5%85%A5%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8Fpath%E4%B8%AD">https://cygwin.com/setup-x86_64.exe,默认安装之后,将C:\cygwin64\bin加入环境变量path中</a>(Windows 10的环境变量比之前好多了,能够将每条记录分行编辑,不用担心漏掉分号了)</p><p>配置apt-cyg 在Cygwin64 Terminal里输入:</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">lynx -<span class="built_in">source</span> rawgit.com/transcode-open/apt-cyg/master/apt-cyg && apt-cyg install apt-cyg /bin</span><br></pre></td></tr></table></figure><p>设置apt-cyg缓存</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">apt-cyg cache /cygdrive/d/Download/cygwin -m http://mirrors.ustc.edu.cn/cygwin/</span><br></pre></td></tr></table></figure><p>测试安装</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">apt-cyg install vim</span><br></pre></td></tr></table></figure><p>注意:用ustc源安装软件可能遇到"sha512sum: 警告:1 个校验和不匹配"的错误,这时请确保你卸载了wget,使用它自带的lynx下载软件包,才能能跳过校验安装软件。</p><p>配置zsh 以管理员身份运行终端,安装zsh git curl,然后touch ~/.zshrc,再运行</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sh -c <span class="string">"<span class="subst">$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)</span>"</span></span><br></pre></td></tr></table></figure><p>安装ohMyZsh</p><p>备注dig命令的包名为:bind-utils</p>]]></content>
<categories>
<category> linux </category>
</categories>
<tags>
<tag> linux </tag>
<tag> cygwin </tag>
</tags>
</entry>
<entry>
<title>JAVA只有传值调用(call by value)</title>
<link href="2016/03/21/JAVA%E5%8F%AA%E6%9C%89%E4%BC%A0%E5%80%BC%E8%B0%83%E7%94%A8/"/>
<url>2016/03/21/JAVA%E5%8F%AA%E6%9C%89%E4%BC%A0%E5%80%BC%E8%B0%83%E7%94%A8/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>目前程序设计语言中有关将参数传递给函数调用有两种方法,按值传递(call by value)和按引用传递(call by reference)(C语言中可以通过指针直接传递地址,和传引用效果类似)。因为我之前是学C++的,所以想当然认为JAVA也有这两种参数传递方式。</p><p>可是看书之后才知道Java里只有传值调用,即在调用函数时,传递给形参的永远都是实参的副本,无论形参是基本数据类型(int,boolean)还是对象。</p><p>假设如果Java传递对象是按引用传递的,那么下列代码的结果应该是b,a。可是实际结果还是a,b,说明swap函数没有成功交换两个对象。</p><h1>代码</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">class Employee{</span><br><span class="line"> private String name;</span><br><span class="line"> public Employee(String name){</span><br><span class="line"> this.name = name;</span><br><span class="line"> }</span><br><span class="line"> public void <span class="function"><span class="title">getName</span></span>(){</span><br><span class="line"> System.out.println(this.name);</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">public class Study {</span><br><span class="line"> public static void swap(Employee x, Employee y){</span><br><span class="line"> Employee tmp;</span><br><span class="line"> tmp = x;</span><br><span class="line"> x = y;</span><br><span class="line"> y = tmp;</span><br><span class="line"> }</span><br><span class="line"> public static void main(String[] args) {</span><br><span class="line"> Employee a = new Employee(<span class="string">"a"</span>);</span><br><span class="line"> Employee b = new Employee(<span class="string">"b"</span>);</span><br><span class="line"> swap(a,b);</span><br><span class="line"> a.getName();</span><br><span class="line"> b.getName();</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h1>疑问</h1><p>但是如果按值调用,为什么能修改传入函数中对象的属性呢?</p><p>如果之前有C/C++基础,从指针角度理解,很容易就想通了。a、b为实参,x、y为形参,当调用swap()是,你可以理解Java新生成了a的值,并且将其赋值给了x,y亦然。然后这四个变量相当于四个指针,他们分别指向两块堆内存空间,如果修改对象属性,那么通过这个指向关系,通过成功修改堆内存空间里的内容,如果想交换对象,那么在函数内交换的只是形参的指向关系(如红色箭头所示),并不会影响到a、b对象的指向关系。</p><h1>总结</h1><p>Java只有传值调用,函数调用不能修改基本数据类型参数的内容,可以修改对象参数的属性内容,不能修改对象参数的指向关系,即不能让对象参数引用到别的对象上去。</p>]]></content>
<categories>
<category> java </category>
</categories>
<tags>
<tag> java </tag>
</tags>
</entry>
<entry>
<title>php7.0与Mysql5.7的连接使用</title>
<link href="2016/03/09/php7.0%E4%B8%8EMysql5.7%E7%9A%84%E8%BF%9E%E6%8E%A5%E4%BD%BF%E7%94%A8/"/>
<url>2016/03/09/php7.0%E4%B8%8EMysql5.7%E7%9A%84%E8%BF%9E%E6%8E%A5%E4%BD%BF%E7%94%A8/</url>
<content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="\assets\css\APlayer.min.css"><script src="\assets\js\APlayer.min.js" class="aplayer-secondary-script-marker"></script><script class="meting-secondary-script-marker" src="\assets\js\Meting.min.js"></script><h1>前言</h1><p>我这个博客用的是linuxeye制作的lnmp安装脚本搭建的,因为用于个人折腾不用于生产环境,所以打算折腾一下,于是配了个php7与mysql5.7的环境,还启用了https协议,但是因为这个腾讯云的VPS配置太低,无法成功编译mysql,于是我只能用官方的deb包直接安装二进制文件,但是安装完成之后,发现php一直无法连接mysql。</p><h1>方法</h1><p>研究了半天发现是php_mysqli扩展的配置问题,使用deb安装的mysql5.7社区版的sock链接默认为/var/run/mysqld/mysqld.sock,所以需要修改php.ini:</p><figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">mysqli.default_socket</span> = /var/run/mysqld/mysqld.sock</span><br></pre></td></tr></table></figure><p>然后重启php-fpm服务即可。</p>]]></content>
<categories>
<category> 教程 </category>
</categories>
<tags>
<tag> ipv6 </tag>
<tag> mysql </tag>
<tag> php </tag>
</tags>
</entry>
</search>