29
1月
2023
我的设备是单臂路由N1 刷openwrt(flippy版本)+VLAN交换机+k2p作无线ap
稳定运行五年多了,这两天升级了80+O的最新固件,记录下iptv设置
前提是已经在VLAN交换机里配置了51与85的VLAN
#nano /etc/dnsmasq.conf
在文件末尾加入
dhcp-option-force=lan,125,00:00:00:00:1a:02:06:48:47:57:2d:43:54:0a:02:20:00:0b:02:00:55:0d:02:00:2e
dhcp-option=lan,60,00:00:01:00:02:03:43:50:45:03:0e:45:38:20:47:50:4f:4e:20:52:4f:55:54:45:52:04:03:31:2E:30
dhcp-option=lan,15
dhcp-option=lan,28
最后重启下服务dnsmasq
#/etc/init.d/dnsmasq restart
最好把交换机也重启下。
最后应该整个无线与任意lan都可以iptv正常4K高清了。
11
6月
2020
题目:形如[2AE]表示AEAE,[2[2EB]A]表示EBEBAEBEBA…这种压缩规则为数字表示压缩次数范围1-99,压缩内容都是大写字母。现在给一个压缩字符串为输入,求解压缩的原文。
思路:通过正则表达式匹配到”[数字字母]”这种严格格式,每次匹配完就立即展开,直到再也没有[号或者]号出现。
import re
def Solution(S:str)->str:
while '[' in S:
for code in re.findall('\[[0-9]+[A-Z]+\]', S):
info = re.findall('\[([0-9]+)([A-Z]+)\]', code)[0]
S = S.replace(code, info[1]*int(info[0]))
return S
07
6月
2020
每次刷入网上的纯净固件后,自己肯定要配置一下,有些情况还要额外安装软件。
然后再刷固件后,恢复就得再配置和安装一番,体验真的让人难受。
其实有更快捷的方法,直接带配置备份固件(把私人配置与额外软件都备份)。然后直接导入即可。
1.查看firmware的位置
cat /proc/mtd
2.将目标位置的固件备份下来
以第一步找到的mtd5为例。
dd if=/dev/mtd5 of=/tmp/firmware_backup.bin
然后用scp软件直接把固件下载到自己电脑上保存一份。
3.将这个固件恢复
mtd -r write /tmp/firmware_backup.bin firmware
有些小固件会遇到备份固件太大的问题,解决方式就是手动缩小固件。
直接用nodepad++或者sublime text等软件编辑上面的bin文件,把后面连续是f的行删除。只保留非连续f的结尾位置,删除多少就是缩小多少。
然后再正常刷入就行了。
最后,最上面的几步其实用breed web界面去备份固件也可以,效果一样。
07
6月
2020
现在一般的大型固件都集成了server酱的微信推送插件。
但是一些小闪存路由就没这么方便,安装插件ipk也很麻烦,所以写了一个脚本,后台运行即可实现,非常简单。
#!/bin/sh
export PATH='/usr/sbin:/usr/bin:/sbin:/bin'
# Paraments
resub=1
push1="1" # Push online devices
push_ddns="1" # Push ddns message
serverchan_enable="1" # Enable ServerChan
serverchan_sckey="SCT456ghhKMAwZIecBAv3Qt6ljRfnw" # ServerChan api key
touch /tmp/tmp/lastIPAddress
[ ! -s /tmp/tmp/lastIPAddress ] && echo "爷刚启动!" > /tmp/tmp/lastIPAddress
touch /tmp/tmp/pushDevice
[ ! -s /tmp/tmp/pushDevice ] && echo "$push1" > /tmp/tmp/pushDevice
# Get wan IP
# Check curl exist, if not, use wget
getIpAddress() {
curltest=`which curl`
if [ -z "$curltest" ] || [ ! -s "`which curl`" ] ; then
wget --no-check-certificate --quiet --output-document=- "http://members.3322.org/dyndns/getip"
else
curl -k -s "http://members.3322.org/dyndns/getip"
fi
}
# load last IP
lastIPAddress() {
inter="/tmp/tmp/lastIPAddress"
cat $inter
}
# Get online devices
test(){
alias=`cat /tmp/dhcp.leases`
cat /proc/net/arp | sed 's/(//;s/)//' | while read -r IP HW FLAGS MAC MASK DEVICE
do
#echo $DEVICE
if [ $DEVICE == "br-lan" ]; then
NAME=`echo "$alias" | awk '/'$MAC'\ '$IP'/{print $4}'`
echo $NAME $IP >> /tmp/tmp/newhostname.txt
#echo $NAME $IP
fi
done
}
while [ "$serverchan_enable" == "1" ];
do
curltest=`which curl`
if [ -z "$curltest" ] ; then
wget --continue --no-check-certificate -q -T 10 http://www.baidu.com
[ "$?" == "0" ] && check=200 || check=404
else
check=`curl -k -s -w "%{http_code}" "http://www.baidu.com" -o /dev/null`
fi
if [ "$check" == "200" ] ; then
hostIP=$(getIpAddress)
lastIP=$(lastIPAddress)
if [ "$lastIP" != "$hostIP" ] && [ ! -z "$hostIP" ] ; then
sleep 60
# Check again
hostIP=$(getIpAddress)
lastIP=$(lastIPAddress)
fi
if [ "$lastIP" != "$hostIP" ] && [ ! -z "$hostIP" ] ; then
logger -t "公网IP变动" "目前 IP: ${hostIP}"
logger -t "公网IP变动" "上次 IP: ${lastIP}"
if [ "$?" == "0" ] ; then
if [ "$push_ddns" = "1" ] ; then
curl -s "http://sctapi.ftqq.com/$serverchan_sckey.send?text=703N的ip更新啦" -d "&desp=${hostIP}" &
logger -t "wechat push" "IP: ${hostIP} pushed"
fi
echo -n $hostIP > /tmp/tmp/lastIPAddress
fi
fi
if [ `cat /tmp/tmp/pushDevice` = "1" ] ; then
# 设备上、下线提醒
# 获取接入设备名称
touch /tmp/tmp/newhostname.txt
echo "接入设备名称" > /tmp/tmp/newhostname.txt
# 当前所有接入设备
test
# 读取已在线设备名称
touch /tmp/tmp/hostname_online.txt
[ ! -s /tmp/tmp/hostname_online.txt ] && echo "接入设备名称" > /tmp/tmp/hostname_online.txt
# 上线
awk 'NR==FNR{a[$0]++} NR>FNR&&a[$0]' /tmp/tmp/hostname_online.txt /tmp/tmp/newhostname.txt > /tmp/tmp/newhostname_same_online.txt
awk 'NR==FNR{a[$0]++} NR>FNR&&!a[$0]' /tmp/tmp/newhostname_same_online.txt /tmp/tmp/newhostname.txt > /tmp/tmp/newhostname_uniqe_online.txt
if [ -s "/tmp/tmp/newhostname_uniqe_online.txt" ] ; then
content=`cat /tmp/tmp/newhostname_uniqe_online.txt | grep -v "^$"`
curl -s "http://sctapi.ftqq.com/$serverchan_sckey.send?text=703N有设备上线啦" -d "&desp=${content}" &
logger -t "wechat push" "设备上线: ${content} pushed"
cat /tmp/tmp/newhostname_uniqe_online.txt | grep -v "^$" >> /tmp/tmp/hostname_online.txt
fi
# 下线
awk 'NR==FNR{a[$0]++} NR>FNR&&!a[$0]' /tmp/tmp/newhostname.txt /tmp/tmp/hostname_online.txt > /tmp/tmp/newhostname_uniqe_offline.txt
if [ -s "/tmp/tmp/newhostname_uniqe_offline.txt" ] ; then
content=`cat /tmp/tmp/newhostname_uniqe_offline.txt | grep -v "^$"`
curl -s "http://sctapi.ftqq.com/$serverchan_sckey.send?text=703N有设备下线啦" -d "&desp=${content}" &
logger -t "wechat push" "设备下线: ${content} pushed"
cat /tmp/tmp/newhostname.txt | grep -v "^$" > /tmp/tmp/hostname_online.txt
fi
fi
resub=`expr $resub + 1`
[ "$resub" -gt 360 ] && resub=1
else
logger -t "server chan" "Check network failed."
resub=1
fi
sleep 100
continue
done
把上面的代码保存在/root/serverchan.sh
再在管理界面-系统-startup最下面位置的脚本块的结尾加入一行
(/root/serverchan.sh) &
就成功了。
04
6月
2020
因为手里好几个384m-10g的小内存小硬盘机器,定期清理这些vps主机的磁盘非常必要。因此记录下一些常用步骤。
1.删除软件残余deb安装包
apt-get clean
apt-get autoclean
2.删除无用的依赖软件
apt-get autoremove
apt-get install deborphan
deborphan | xargs sudo apt-get purge -y
3.清理日志文件
apt-get install ncdu
ncdu /var/log
03
6月
2020
家里的路由只要是openwrt系列的,都可以通过设置hosts来实现屏蔽广告或者苹果系统的升级等功能。十分有用,而且效率高没有任何资源消耗。
修改方式
vi /etc/hosts
因此写一份配置进行记录,也会保持更新。
#20200603更新
#IOS OTA 屏蔽苹果系统升级
127.0.0.1 mesu.apple.com
127.0.0.1 appldnld.apple.com
127.0.0.1 xp.apple.com
127.0.0.1 gdmf.apple.com
127.0.0.1 ipsw.me
127.0.0.1 updates-http.cdn-apple.com
#屏蔽乐播投屏电视端广告
127.0.0.1 adeng.hpplay.cn
127.0.0.1 ad.hpplay.cn
#tcl-tv update 屏蔽tcl电视系统升级
127.0.0.1 launcher.TCLoudfamily.com
127.0.0.1 update.cedock.com
#屏蔽小米盒子或者电视系列广告
127.0.0.1 gvod.aiseejapp.atianqi.com
127.0.0.1 stat.pandora.xiaomi.com
127.0.0.1 upgrade.mishop.pandora.xiaomi.com
127.0.0.1 logonext.tv.kuyun.com
127.0.0.1 config.kuyun.com
127.0.0.1 mishop.pandora.xiaomi.com
127.0.0.1 dvb.pandora.xiaomi.com
127.0.0.1 api.ad.xiaomi.com
127.0.0.1 de.pandora.xiaomi.com
127.0.0.1 data.mistat.xiaomi.com
127.0.0.1 jellyfish.pandora.xiaomi.com
127.0.0.1 gallery.pandora.xiaomi.com
127.0.0.1 o2o.api.xiaomi.com
127.0.0.1 bss.pandora.xiaomi.com
02
6月
2020
最近遇到了一些小问题,我的tp703n(已经刷了openwrt)在单位usb连接手机自动共享网络到wifi。这种功能确实很好用,既能给手机充电也能直接共享网络(非手机热点,热点多设备非常不稳定)。
但是在用某酸酸插件时,会出现当我拔下手机出去有事一段时间后,回来该插件就会出问题,需要手动重启插件解决。这个体验太差了,所以想到直接写个简单热插拔的脚本监听wan接口,当wan接口发生变化时,就重启该插件。
这个思路源自openwrt的著名插件ddns的设计,ddns应该是全世界最出名最常用的插件了,非常好用。ddns,主要用于将域名动态绑定到路由器的ip上。该插件有个智能功能,就是监听wan接口事件,一旦出现断线重启,就会重启插件,实现更新ip到dns的功能。
具体实操很简单。
#在/etc/hotplug.d/iface目录新建一个脚本99-ssr
vi /etc/hotplug.d/iface/99-ssr
#写入以下内容即可
#!/bin/bash
if [ $ACTION=ifup -a $INTERFACE=wan ]; then
/etc/init.d/shadowsocksr restart
fi
解释下/etc/hotplug.d/iface 这个目录是openwrt监听wan或者lan接口的脚本目录,而且目录里脚本的执行顺序按照数字的顺序来的。所以上面99开头的脚本就是希望最后时间里去执行该脚本。
至于脚本内容那就很简单了,就是对于wan网络接口出现up上线的时候,执行目标插件的重启。
31
5月
2020
去广告主流插件有两个
一.koolproxy
优点:1.对http与https都有效
缺点:1.占用资源很多,规则复杂
2.设备需要安装证书,操作复制。
二.adbyby plus+广告屏蔽大师
优点:1.轻量级,占用资源少
缺点:1.确定只对http有效,对https无效。而目前大量广告都是基于后者。
留学插件有也有两个主流
一、ssrplus+
优点:1.自动切换节点功能更好用,采用的wget的方式判断节点是否异常。
缺点:1.与插件koolproxy不兼容,二者只能选一个。
二、passwall
优点:1.兼容性很好,目前没发现什么问题。
缺点:1.自动切换节点功能不太准确,采用ping方式检测。会导致经常自动高频切换节点。