晨曦's Blog

This is a window to the soul

grep 过滤注释行和空白行

cat /etc/kibana/kibana.yml | grep "^\s*[^# \t].*$"

grep 查看非系统进程

ps -ef | grep -v ]$

Bash 脚本错误处理

1
2
3
4
5
6
# 写法一
set -euxo pipefail

# 写法二
set -eux
set -o pipefail

参考

前记

bitwarden_rs 一直是安装在群晖上的 Docker 中的,对外访问也是通过群晖应用门户程序->反向代理反向代理加路由器端口转发

但是有一个问题,就是群晖 UI 界面的反代没有办法编辑配置,也就没有办法利用 bitwarden_rsWebSocket 自动推送更新

解决

想到的解决方案有两个,第一是通过 Docker 再装一个 Nginx 来做反代,第二是通过群晖自身的 Nginx 来做反代;最后选择了通过自身 Nginx 来做反代

Nginx 配置

/usr/syno/etc/certificate/system/default/ 为群晖安全性->证书上传的默认证书的存储位置

8888、3012 端口为 bitwarden_rs80、3012 映射到群晖对应的端口

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
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name xxx.com;

ssl_certificate /usr/syno/etc/certificate/system/default/fullchain.pem;
ssl_certificate_key /usr/syno/etc/certificate/system/default/privkey.pem;

#ssl_session_cache shared:SSL:50m;
ssl_session_timeout 4h;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_buffer_size 4k;

if ($scheme = http) {
return 301 https://$host$request_uri;
}

location / {
proxy_pass http://127.0.0.1:8888;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http:// https://;
}

# bw WebSockets
location /notifications/hub {
proxy_pass http://127.0.0.1:3012;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

# bw WebSockets
location /notifications/hub/negotiate {
proxy_pass http://127.0.0.1:8888;
}

error_page 403 404 500 502 503 504 @error_page;

location @error_page {
root /usr/syno/share/nginx;
rewrite (.*) /error.html break;
allow all;
}
}

链接

将配置文件链接到 /etc/nginx/sites-enabled/
ln -s /volume1/docker/nginx/xxx.com.conf /etc/nginx/sites-enabled/

重启

最后只需要重启 Nginx 即可
sudo synoservicecfg --restart nginx


题外话:

利用第三方 FFMPEG 解码器让群晖的 Video Station 完美支持 DTS、EAC3、TrueHD

参考 01
参考 02

这里指的破解之法为无限期使用 30 天试用期

方法一

卸载重装

方法二

对于 Mac 系统删除以下两个文件即可

1
2
~/Library/Preferences/SmartGit/20.2/preferences.yml
~/Library/Preferences/SmartGit/20.2/license

前记

每次 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

适合懒人直接拷贝

0%