晨曦's Blog

This is a window to the soul

前记

每次 Mac 大的版本更新后 Git 都用不了

1
2
~ git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

解决

前往官网下载新的 Command_Line_Tools_for_Xcode 安装即可

下载地址

代码

1
2
from Crypto.Cipher import PKCS1_v1_5
from Crypto.PublicKey import RSA

错误

1
2
3
4
5
6
Traceback (most recent call last):
File "/Users/jakehu/Documents/Web/python-usability-cli/app.py", line 13, in <module>
from libs import cmdb, esutil, mysqlutil, redisutil, sendmsg
File "/Users/jakehu/Documents/Web/python-usability-cli/libs/sendmsg.py", line 14, in <module>
from Crypto.Cipher import PKCS1_v1_5
ModuleNotFoundError: No module named 'Crypto'

解决

1
2
3
pip3 uninstall crypto
pip3 uninstall pycrypto
pip3 install pycrypto

x-www-form-urlencoded

requestscontent-typ"content-type": "application/x-www-form-urlencoded; charset=UTF-8", 时请求参数当如下

1
2
3
4
5
r = requests.post(
url,
headers=headers,
data=data
)

json

requestscontent-typ"Content-Type": "application/json;charset=UTF-8", 时请求参数当如下

1
2
3
4
5
r = requests.post(
url,
headers=headers,
data=json.dumps(data)
)

x-www-form-urlencoded 时应该为一个字典,json 时应该为一个 json 字符串

前记

19 年的时候准备用群晖来做软路由,由于双网卡配置失败遂放弃

在群晖上利用 Virtual Machine Manager 玩转软路由之 LEDE

因为把 AC86UAC66UB1 都刷回了官方固件 386,所以就需要一个旁路由。既然单网卡的群晖做不了软路由,那就用来做旁路有吧

LEDE

镜像

K 站下载硬盘镜像后上传至 VMM

镜像下载地址:koolcenter.com

找到名为 openwrt-koolshare-mod-v2.36-r14941-67f6fa0a30-x86-64-generic-squashfs-combined.vmdk 的虚拟机磁盘,下载后上传至 VMM

网络

网络这里我们直接使用 Default VM Network 即可

开机

导入虚拟机

通过之前下载的虚拟机磁盘导入虚拟机


配置网络

其他配置

开机

修改 IP

通过 VMM -> 虚拟机 -> 连接进入虚拟机

通过命令 vi /etc/config/network 来修改网络 IP 地址

最后通过命令 /etc/init.d/network restart 来重启网络,或则 reboot 重启虚拟机

配置

关于 LEDE 的配置可以看看下面这篇文章

LEDE 配置

最后需要在路由器上修改路由器的网关和 DNS

到这里 LEDE 旁路由的配置就完成了

前记

由于我的 ADGuard Home 是安装在群晖的 Docker 中的,对外服务是在路由器上设置的 DNSDNS 请求如下

client->路由器->群晖->Docker->ADGuard Home

所以 ADGuard Home 的客户端列表只是显示了群晖 Docker 的网关地 172.17.0.1,没有显示具体的客户端 IP 地址,导致有很多请求都不知道是从哪个客户端发起的

解决

解决的办法就是将 ADGuard Home 所在的容器暴露到局域网中来,这就需要 DockerMacvlan 网络实现方式

对于 Docker3 种网络实现 HostBridgeMacvlan 可以参考这里

参考文档

第一步

开启 Open vSwitchOpen vSwitch 的作用是开启虚拟网络交换机,通过软件实现交换机的作用

控制面板->网络->网络界面->管理->Open vSwitch设置->启用Open vSwitch

第二步

创建 Macvlan 模式网络,SSH 到群晖上

1
docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 --ip-range=192.168.50.100/31 -o parent=ovs_eth0 macvlan

192.168.50.0/24 是路由器中 DHCP 的网段

192.168.50.1 是路由器管理 IP

192.168.50.100/31Docker 可用 IP,此段为 100101 可用

ovs_eth0 是群晖的网卡名称,可用 ip addr 查看

第三步

ADGuard Home 容器分配到 Macvlan 网络下

Docker->网络->macvlan->管理->新增

当然你也可以选择通过 Docker 命令的模式来创建容器指定网络

1
docker run -d --restart=always --network macvlan --ip=192.168.50.50 --name nginx nginx

问题

本来是 Bridge 下的一个 Frp 容器提供穿透服务,由于 Macvlan 下容器无法与宿主机通信,所以 ADGuard Home 管理平台也就无法穿透出外网

解决方案就是将 ADGuard Home 容器同时加入 BridgeMacvlan 网络下,Bridge 映射端口到宿主机进行穿透,而 Macvlan 下的 IP 用来提供 DNS 服务


大功告成

前记

之前一直是用华硕 AC86Uv2ray 做客户端,最近也想把它迁移到群晖中去,然后把路由器刷回官方固件

安装

因为是容器安装这里就一笔带过,官方容器镜像

v2fly-core

需要注意的就一点,在高级设置 -> 网络 -> 使用与Docker Host相同的网络这里需要打勾

再一个就是配置文件 config.json 所在的文件夹必须挂载到 /etc/v2ray

配置

我电脑使用的是 V2rayU 客户端,直接配置导出即可使用。将 inbounds 中的 listen 改为 "listen": "0.0.0.0",

最后需要将 geoip.datgeosite.dat 规则文件跟配置文件放在一起

文件下载

使用

socks5:群晖IP:1080

http:群晖IP:1087

安装

由于我是在群晖安装的,安装比较简单,直接镜像 adguard/adguardhome 拉起来即可。

注意数据盘和端口就好

管理端口:3000:3000,另外 updtcp 端口:53:53

数据文件:/opt/adguardhome/work
配置文件:/opt/adguardhome/conf

Rules

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
filters:
- enabled: true
url: https://gitee.com/xinggsf/Adblock-Rule/raw/master/rule.txt
name: 乘风 广告过滤规则
id: 1610615684
- enabled: true
url: https://gitee.com/xinggsf/Adblock-Rule/raw/master/mv.txt
name: 乘风 视频广告过滤规则
id: 1610615685
- enabled: true
url: https://anti-ad.net/easylist.txt
name: anti-AD
id: 1610615686
- enabled: true
url: https://banbendalao.coding.net/p/adgk/d/ADgk/git/raw/master/ADgk.txt
name: adgk手机去广告规则
id: 1610615687
- enabled: true
url: https://raw.githubusercontent.com/VeleSila/yhosts/master/hosts.txt
name: yhosts
id: 1610615689
- enabled: true
url: https://easylist-downloads.adblockplus.org/easylistchina.txt
name: easylistchina
id: 1610615690
- enabled: true
url: https://easylist-downloads.adblockplus.org/easyprivacy.txt
name: easyprivacy
id: 1610615691
- enabled: true
url: https://easylist-downloads.adblockplus.org/easylist.txt
name: easylist
id: 1610615692
- enabled: true
url: https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts
name: 大圣净化
id: 1610615704
- enabled: true
url: https://gitee.com/xinggsf/Adblock-Rule/raw/master/ublock-dynamic-rule.txt
name: 乘风 uBlock Origin过滤规则
id: 1610713745
- enabled: true
url: https://gitee.com/cjx82630/cjxlist/raw/master/cjxlist.txt
name: cjxlist
id: 1610713749
- enabled: true
url: https://gitee.com/cjx82630/cjxlist/raw/master/cjx-annoyance.txt
name: cjxlist cjx-annoyance
id: 1610713750
- enabled: true
url: https://gitee.com/cjx82630/cjxlist/raw/master/cjx-ublock.txt
name: cjxlist cjx-ublock
id: 1610713751
- enabled: true
url: https://gitee.com/cjx82630/cjxlist/raw/master/chinese.txt
name: cjxlist chinese
id: 1610713752
- enabled: true
url: https://gitee.com/halflife/list/raw/master/ad.txt
name: halflife ad
id: 1610713753
- enabled: true
url: https://gitee.com/halflife/list/raw/master/ad-edentw.txt
name: halflife ad-edentw
id: 1610713754
- enabled: true
url: https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext
name: yoyo
id: 1610713767
- enabled: true
url: https://cdn.jsdelivr.net/gh/AdguardTeam/AdGuardSDNSFilter@master/Filters/rules.txt
name: AdGuardSDNSFilter(默认)
id: 1611042639
- enabled: true
url: https://cdn.jsdelivr.net/gh/AdAway/adaway.github.io@master/hosts.txt
name: AdAway
id: 1611042640
- enabled: true
url: https://cdn.jsdelivr.net/gh/lhbill/xiaomiad@master/xiaomi.txt
name: 小米盒子广告
id: 1611042641
- enabled: true
url: https://cdn.jsdelivr.net/gh/neoFelhz/neohosts@gh-pages/full/hosts.txt
name: neohosts
id: 1611042642

适合懒人直接拷贝

agnoster 主题乱码

原因:是缺少 Menlo for Powerline 字体

下载字体:Menlo for Powerline

安装字体:mv "Menlo for Powerline.ttf" ~/Library/Fonts

配置:Text->Font

ls 文件夹颜色

配置:Colors->Brighten bold text 勾选掉之后

rz/sz 配置

参考文档

zsh-autosuggestion 颜色与底色相同

更改 zsh-autosuggestion 颜色,在.zshrc 最后加入 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=5'

参考文档

隐藏用户名和主机名

.zshrc 最后加入

1
prompt_context() {}

只显示用户名

.zshrc 最后加入

1
2
3
4
5
6
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
fi
}

只显示主机名

.zshrc 最后加入

1
2
3
4
5
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$HOST"
fi
}

自定义

.zshrc 最后加入

1
2
3
prompt_context () {
prompt_segment black default "JakeHu@MBP";
}

powerlevel10k

重新配置 p10k configure

参考

案例一

案例二

前记

AC86U 升级固件后挂载虚拟内存总是提示读写速度不够,新固件的读取速度要求 20M/s,写入速度要求 30M/s

解决

修改参数限制

ssh 登录到路由器,执行如下命令

1
2
3
4
5
6
# 修改写入速度限制,30替换为10
sed -i 's/^W_LIMIT=30/W_LIMIT=10/' /koolshare/scripts/swap_make.sh

# 修改读取速度限制,20替换为10
sed -i 's/^R_LIMIT=20/R_LIMIT=10/' /koolshare/scripts/swap_make.sh

以上参数可以根据自己的实际情况进行调整

完成后重新进入管理界面挂载虚拟内存即可

前记

搭建在群晖上的 gogs 还是 0.11.X 最近心血来潮升级到了 0.12.3 没想到升级后却出现了权限的问题 Permission denied 具体报错如下

1
2
3
4
5
6
Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决

后查阅文档发现可能是目录权限问题,权限设置如下:

1
2
3
4
5
# /data/git/.ssh/ 目录权限为0700
chmod 0700 /data/git/.ssh/

# /data/git/.ssh/authorized_keys 文件权限为0600
chmod 0600 /data/git/.ssh/authorized_keys

最后需要在后台重新生成 /data/git/.ssh/authorized_keys 文件

管理面板->管理员操作->重新生成 '.ssh/authorized_keys' 文件(警告:不是 Gogs 的密钥也会被删除)


大功告成

0%