mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 16:55:13 +08:00
🍕 Sync 2026-04-25 20:15:58
This commit is contained in:
1 parent
80f09ddc21
commit
8a2eefa223
19 files changed
+438
-39
No files matched your search
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
# teleproxy config updater
|
||||
# by koshev-msk 2026
|
||||
|
||||
URL=https://core.telegram.org/
|
||||
|
||||
which curl || echo "Error. cURL not found."
|
||||
|
||||
# Check proxy connectrion
|
||||
SOCKS_PROXY=$(uci -q get teleproxy.default.socks)
|
||||
[ -n $SOCKS_PROXY ] && {
|
||||
# Check autentification proxy
|
||||
SOCKS_AUTH=$(uci -q get teleproxy.default.socks_auth)
|
||||
[ -n $SOCKS_AUTH ] && {
|
||||
CURL="curl -x socks5://${SOCKS_AUTH}@${SOCKS_PROXY}"
|
||||
} || {
|
||||
CURL="curl -x socks://${SOCKS_PROXY}"
|
||||
}
|
||||
} || {
|
||||
CURL="curl"
|
||||
}
|
||||
|
||||
[ -d /etc/teleproxy ] || mkdir -p /etc/teleproxy
|
||||
|
||||
# Download latest configs and check new sha256
|
||||
${CURL} -s --max-time 60 $URL/cidr.txt -o /tmp/cidr.txt && \
|
||||
SHA256_CIDR_NEW=$(sha256sum /tmp/cidr.txt | awk '{print $1}') || SHA256_CIDR_NEW="failed"
|
||||
${CURL} -s --max-time 60 $URL/getProxyConfig -o /tmp/proxy-multi.conf && \
|
||||
SHA256_MULTI_NEW=$(sha256sum /tmp/proxy-multi.conf | awk '{print $1}') || SHA256_MULTI_NEW="failed"
|
||||
${CURL} -s --max-time 60 $URL/getProxySecret -o /tmp/aes-secret && \
|
||||
SHA256_AES_NEW=$(sha256sum /tmp/aes-secret | awk '{print $1}') || SHA256_AES_NEW="failed"
|
||||
|
||||
# Check old sha256 config
|
||||
[ -f /etc/teleproxy/cidr.txt ] && \
|
||||
SHA256_CIDR_OLD=$(sha256sum /etc/teleproxy/cidr.txt | awk '{print $1}') || SHA256_CIDR_OLD="failed"
|
||||
[ -f /etc/teleproxy/proxy-multi.conf ] && \
|
||||
SHA256_MULTI_OLD=$(sha256sum /etc/teleproxy/proxy-multi.conf | awk '{print $1}') || SHA256_MULTI_OLD="failed"
|
||||
[ -f /etc/teleproxy/aes-secret ] && \
|
||||
SHA256_AES_OLD=$(sha256sum /etc/teleproxy/aes-secret | awk '{print $1}') || SHA256_MULTI_OLD="failed"
|
||||
|
||||
# Comapre hashes
|
||||
[ "$SHA256_CIDR_NEW" = "$SHA256_CIDR_OLD" ] || \
|
||||
cp /tmp/cidr.txt /etc/teleproxy/cidr.txt && rm /tmp/cidr.txt
|
||||
[ "$SHA256_MULTI_NEW" = "$SHA256_MULTI_OLD" ] || \
|
||||
cp /tmp/proxy-multi.conf /etc/teleproxy/proxy-multi.conf && rm /tmp/proxy-multi.conf
|
||||
[ "$SHA256_AES_NEW" = "$SHA256_AES_OLD" ] || \
|
||||
cp /tmp/aes-secret /etc/teleproxy/aes-secret && rm /tmp/aes-secret
|
||||
@@ -6,7 +6,7 @@ BIN=/usr/bin/${NAME}
|
||||
PID=/var/run/${NAME}.pid
|
||||
|
||||
load_config(){
|
||||
for v in ipv6 address port secret direct aes_pwd auth_socks socks extra; do
|
||||
for v in ipv6 address port secret direct relay aes_pwd auth_socks socks extra; do
|
||||
config_get $v $1 $v
|
||||
done
|
||||
}
|
||||
@@ -14,14 +14,14 @@ load_config(){
|
||||
|
||||
start() {
|
||||
config_load teleproxy
|
||||
local ipv6 address port secret direct aes_pwd auth_socks socks extra
|
||||
local ipv6 address port secret direct relay aes_pwd auth_socks socks extra
|
||||
config_foreach load_config
|
||||
[ $ipv6 ] && args="-6"
|
||||
[ $address ] && args="$args --address $address"
|
||||
[ $port ] && args="$args -H $port"
|
||||
[ $secret ] && args="$args -S $secret"
|
||||
[ $aes_pwd ] && args="$args --aes-pwd $aes-pwd"
|
||||
[ $socks ] && {
|
||||
[ $aes_pwd ] && args="$args --aes-pwd $aes_pwd"
|
||||
[ $socks -a "$direct" -eq "1" ] && {
|
||||
[ $auth_socks ] && {
|
||||
args="$args --socks socks5://${auth_socks}@${socks}"
|
||||
} || {
|
||||
|
||||
Reference in new issue
Block a user