-
-
Save wd/e0bc83b33ce63506a9bdbc3b81658c52 to your computer and use it in GitHub Desktop.
{ | |
"log": { | |
"loglevel": "none" | |
}, | |
"inbound": { | |
"port": 23456, | |
"listen": "127.0.0.1", | |
"protocol": "socks", | |
"settings": { | |
"udp": true | |
} | |
}, | |
"inboundDetour": | |
[{ | |
"port": 3333, | |
"listen": "0.0.0.0", | |
"protocol": "dokodemo-door", | |
"settings": { | |
"network": "tcp,udp", | |
"followRedirect": true | |
} | |
}], | |
"outbound": { | |
"protocol": "vmess", | |
"settings": { | |
"vnext": [ | |
{ | |
"address": "这里输入你的服务器信息", | |
"port": 443, | |
"users": [ | |
{ | |
"id": "这里输入你的id,其他配置根据你需要配置", | |
"alterId": 64, | |
"security": "auto" | |
} | |
] | |
} | |
] | |
}, | |
"streamSettings": | |
{ | |
"network": "tcp", | |
"security": "tls", | |
"tlsSettings": { "allowInsecure": true } | |
} | |
}, | |
"policy": { | |
"levels": { | |
"0": {"uplinkOnly": 0} | |
} | |
} | |
} |
#!/bin/sh | |
CUR_VER="" | |
NEW_VER="" | |
ARCH="" | |
VDIS="arm" | |
ZIPFILE="/tmp/v2ray/v2ray.zip" | |
V2RAY_DIR="/jffs/v2ray" | |
CMD_INSTALL="" | |
CMD_UPDATE="" | |
SOFTWARE_UPDATED=0 | |
#######color code######## | |
RED="31m" | |
GREEN="32m" | |
YELLOW="33m" | |
BLUE="36m" | |
sysArch(){ | |
ARCH=$(uname -m) | |
if [[ "$ARCH" == "i686" ]] || [[ "$ARCH" == "i386" ]]; then | |
VDIS="32" | |
elif [[ "$ARCH" == *"armv7"* ]] || [[ "$ARCH" == "armv6l" ]]; then | |
VDIS="arm" | |
elif [[ "$ARCH" == *"armv8"* ]] || [[ "$ARCH" == "aarch64" ]]; then | |
VDIS="arm64" | |
elif [[ "$ARCH" == *"mips64le"* ]]; then | |
VDIS="mips64le" | |
elif [[ "$ARCH" == *"mips64"* ]]; then | |
VDIS="mips64" | |
elif [[ "$ARCH" == *"mipsle"* ]]; then | |
VDIS="mipsle" | |
elif [[ "$ARCH" == *"mips"* ]]; then | |
VDIS="mips" | |
elif [[ "$ARCH" == *"s390x"* ]]; then | |
VDIS="s390x" | |
fi | |
return 0 | |
} | |
colorEcho(){ | |
COLOR=$1 | |
echo -e "\033[${COLOR}${@:2}\033[0m" | |
} | |
downloadV2Ray(){ | |
rm -rf /tmp/v2ray | |
mkdir -p /tmp/v2ray | |
colorEcho ${BLUE} "Downloading V2Ray." | |
DOWNLOAD_LINK="https://github.com/v2ray/v2ray-core/releases/download/${NEW_VER}/v2ray-linux-${VDIS}.zip" | |
curl -L -H "Cache-Control: no-cache" -o ${ZIPFILE} ${DOWNLOAD_LINK} | |
if [ $? != 0 ];then | |
colorEcho ${RED} "Failed to download! Please check your network or try again." | |
exit 1 | |
fi | |
return 0 | |
} | |
installSoftware(){ | |
COMPONENT=$1 | |
if [[ -n `command -v $COMPONENT` ]]; then | |
return 0 | |
fi | |
getPMT | |
if [[ $? -eq 1 ]]; then | |
colorEcho $YELLOW "The system package manager tool isn't APT or YUM, please install ${COMPONENT} manually." | |
exit | |
fi | |
colorEcho $GREEN "Installing $COMPONENT" | |
if [[ $SOFTWARE_UPDATED -eq 0 ]]; then | |
colorEcho ${BLUE} "Updating software repo" | |
$CMD_UPDATE | |
SOFTWARE_UPDATED=1 | |
fi | |
colorEcho ${BLUE} "Installing ${COMPONENT}" | |
$CMD_INSTALL $COMPONENT | |
if [[ $? -ne 0 ]]; then | |
colorEcho ${RED} "Install ${COMPONENT} fail, please install it manually." | |
exit | |
fi | |
return 0 | |
} | |
extract(){ | |
colorEcho ${BLUE}"Extracting V2Ray package to /tmp/v2ray." | |
mkdir -p /tmp/v2ray | |
unzip $1 -d "/tmp/v2ray/" | |
if [[ $? -ne 0 ]]; then | |
colorEcho ${RED} "Extracting V2Ray faile!" | |
exit | |
fi | |
return 0 | |
} | |
# 1: new V2Ray. 0: no | |
getVersion(){ | |
CUR_VER=`$V2RAY_DIR/v2ray -version 2>/dev/null | head -n 1 | cut -d " " -f2` | |
TAG_URL="https://api.github.com/repos/v2ray/v2ray-core/releases/latest" | |
NEW_VER=`curl ${PROXY} -s ${TAG_URL} --connect-timeout 10| grep 'tag_name' | cut -d\" -f4` | |
if [[ $? -ne 0 ]] || [[ $NEW_VER == "" ]]; then | |
colorEcho ${RED} "Network error! Please check your network or try again." | |
exit | |
elif [[ "$NEW_VER" != "$CUR_VER" ]];then | |
return 1 | |
fi | |
return 0 | |
} | |
copyFile() { | |
NAME=$1 | |
MANDATE=$2 | |
ERROR=`cp "/tmp/v2ray/v2ray-${NEW_VER}-linux-${VDIS}/${NAME}" "$V2RAY_DIR/${NAME}"` | |
if [[ $? -ne 0 ]]; then | |
colorEcho ${YELLOW} "${ERROR}" | |
if [ "$MANDATE" = true ]; then | |
exit | |
fi | |
fi | |
} | |
installV2Ray(){ | |
# Install V2Ray binary to $V2RAY_DIR | |
mkdir -p $V2RAY_DIR | |
copyFile v2ray true | |
makeExecutable v2ray | |
copyFile v2ctl false | |
makeExecutable v2ctl | |
copyFile geoip.dat false | |
copyFile geosite.dat false | |
return 0 | |
} | |
makeExecutable() { | |
chmod +x "$V2RAY_DIR/$1" | |
} | |
updateWatchDog() { | |
colorEcho ${GREEN} "Update v2ray_watchdog.sh" | |
echo "IyEvYmluL3NoCgp2MnJheT0nL2pmZnMvdjJyYXkvdjJyYXknCgppc192MnJheV9hbGl2ZSgpIHsKICAgIHYycmF5X2NvdW50PWBwcyAtdyB8Z3JlcCAnL2pmZnMvdjJyYXkvdjJyYXknfGdyZXAgLXYgZ3JlcHxncmVwIC12IHdhdGNoZG9nfHdjIC1sYAogICAgaWYgWyAiJHYycmF5X2NvdW50IiAtZXEgMSBdO3RoZW4KICAgICAgICByZXR1cm4gMCAgIyB3b3JrIG9rCiAgICBlbHNlCiAgICAgICAgcmV0dXJuIDEKICAgIGZpCn0KCnJlc3RhcnRfdjJyYXkoKSB7CiAgICBraWxsYWxsIHYycmF5ID4vZGV2L251bGwgMj4mMQogICAgJHYycmF5ICYKICAgIGVjaG8gJCQgPiAvdG1wL3YycmF5LnBpZAp9CgpzdG9wX3NzKCkgewogICAga2lsbGFsbCBzcy1sb2NhbCA+L2Rldi9udWxsIDI+JjEKICAgIGtpbGxhbGwgc3MtcmVkaXIgPi9kZXYvbnVsbCAyPiYxCn0KCm1haW4oKXsKICAgIGlzX3YycmF5X2FsaXZlCiAgICBpZiBbICIkPyIgLW5lIDAgXTt0aGVuCiAgICAgICAgc3RvcF9zcwogICAgICAgIHJlc3RhcnRfdjJyYXkKICAgICAgICBlY2hvICJ2MnJheSByZXN0YXJ0IGF0ICIkKGRhdGUpID4+IC90bXAvdjJyYXkubG9nCiAgICBmaQp9CgptYWluCg==" > /tmp/dog.in | |
base64 -d /tmp/dog.in > "$V2RAY_DIR/v2ray_watchdog.sh" | |
rm /tmp/dog.in | |
} | |
main() { | |
# dowload via network and extract | |
updateWatchDog | |
getVersion | |
if [[ $? == 0 ]]; then | |
colorEcho ${GREEN} "Lastest version ${NEW_VER} is already installed." | |
exit | |
else | |
colorEcho ${BLUE} "Installing V2Ray ${NEW_VER} on ${ARCH}" | |
downloadV2Ray | |
extract ${ZIPFILE} | |
fi | |
installV2Ray | |
colorEcho ${GREEN} "V2Ray ${NEW_VER} is installed." | |
rm -rf /tmp/v2ray | |
return 0 | |
} | |
main |
# 修改 /jffs/scripts/nat-start 和 /jffs/scripts/wan-start 都增加一行 cron 的配置,定时跑 watchdog 检查服务 | |
# 注意:下面的 admin 需要改成你自己的用户名 | |
grep -q 'v2ray_watchdog.sh' /var/spool/cron/crontabs/admin || echo "*/5 * * * * /bin/sh /jffs/v2ray/v2ray_watchdog.sh" >> /var/spool/cron/crontabs/admin |
#!/bin/sh | |
v2ray='/jffs/v2ray/v2ray' # v2ray 的所有文件放到 /jffs/v2ray 下面 | |
is_v2ray_alive() { | |
v2ray_count=`ps -w |grep '/jffs/v2ray/v2ray'|grep -v grep|grep -v watchdog|wc -l` | |
if [ "$v2ray_count" -eq 1 ];then | |
return 0 # work ok | |
else | |
return 1 | |
fi | |
} | |
restart_v2ray() { | |
killall v2ray >/dev/null 2>&1 | |
$v2ray & | |
echo $$ > /tmp/v2ray.pid | |
} | |
stop_ss() { | |
killall ss-local >/dev/null 2>&1 | |
killall ss-redir >/dev/null 2>&1 | |
} | |
main(){ | |
is_v2ray_alive #判断 v2ray 是不是还活着 | |
if [ "$?" -ne 0 ];then | |
stop_ss # 停止 ss 相关进程,因为我们会用 v2ray 代替他 | |
restart_v2ray # 启动 v2ray | |
echo "v2ray restart at "$(date) >> /tmp/v2ray.log | |
fi | |
} | |
main |
3.8.5版插件支持脚本了,可以做成v2ray脚本吗?这样可以省掉开机和定时运行监控脚本,维护升级也方便多了。
@imoldchen 做了一个新的方案 https://gist.github.com/wd/1445e3fcf0c9bc535a6e70d2de1d1624 有兴趣可以试试看。
Thanks!
感谢!!!!!!!
这个arm版本为啥能跑起来的?我看梅林用的是uClibc。如果用普通的libc编译出来的二进制,应该跑不起来才对的呀。
我从V2ray的官网下载的linux arm版本的v2ray,一跑直接就是Illegal Instruction。只好自己编译了一个针对梅林的V2ray版本。
arm 似乎有 arm, armv7, arm64,我看 v2ray 提供了 arm 和 arm64 版本,是不是都试试看?我这跑没问题的,不用自己编译。
我的是 AC86u,uname -a
输出如下
Linux tux 4.1.27 #2 SMP PREEMPT Wed Jul 31 14:51:32 EDT 2019 aarch64 ASUSWRT-Merlin
v2ray -version
输出
V2Ray 4.22.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.13.5 linux/arm64)
A unified platform for anti-censorship.
大佬可否做一个独立版的安装包啊?完全没理解为何你(似乎)连独立的插件控制页面都做出来了,为何还需要通过ss补丁的方式安装?
现在可否更新xray或者v2fly内核?另外你博客里说的奔溃了自动重启插件似乎被你删了?谢谢
不是已经有官方插件了吗?别用这个了吧。我好久不用 merlin 和 v2ray 了。
😅啊?!有官方的吗?我是想跑服务端的,梅林我只找到ssserver和fancyss。但是fancyss是客户端的。看了下你的代码,似乎是跑v2ray然后可以自定义config.json?所以可以当成服务器用?(所以你说的替换ss是指替换ss客户端啊?)
这个基于 kooshare 梅林固件的,你可以去看看他们有没有 v2ray 支持。我记得是有了的。
看过了,没有。。。或许是谁在论坛上发布的吧😅。。。就是没找到v2ray,xray之类的插件。整个github感觉你的最接近了。。。
https://github.com/koolshare/armsoft
https://github.com/orgs/koolshare/repositories
感谢作者的辛苦劳动,如果能有现成安装包就好了。我通过ssh登录8500 后台后使用代替1-3那步,提示下载v2ray结果一直走下载,下了整整20分钟还是不行,不知道什么原因,不知道是不是我路由ssr没关闭的原因。