Skip to content

Commit

Permalink
CUSTOM_FORWARD compatible domain names.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkkgo committed May 29, 2024
1 parent e52b3fe commit 6ae1897
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,13 @@ dig +short www.youtube.com @127.0.0.1 -p5303 +retry=0 | head -3
blank
if echo "$CUSTOM_FORWARD" | grep -Eoq ":[0-9]+"; then
CUSTOM_FORWARD=$(echo "$CUSTOM_FORWARD" | sed 's/"//g')
CUSTOM_FORWARD_SERVER=$(echo "$CUSTOM_FORWARD" | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b|[0-9a-fA-F:]+" | head -1)
CUSTOM_FORWARD_PORT=$(echo "$CUSTOM_FORWARD" | rev | cut -d':' -f1 | rev)
if echo "$CUSTOM_FORWARD" | grep -q '\['; then
CUSTOM_FORWARD_SERVER=$(echo "$CUSTOM_FORWARD" | sed 's/\[//' | cut -d']' -f1)
CUSTOM_FORWARD_PORT=$(echo "$CUSTOM_FORWARD" | sed 's/.*\]://' | sed 's/[^0-9]*//')
else
CUSTOM_FORWARD_SERVER=$(echo "$CUSTOM_FORWARD" | cut -d':' -f1)
CUSTOM_FORWARD_PORT=$(echo "$CUSTOM_FORWARD" | cut -d':' -f2)
fi
echo "CUSTOM_FORWARD TEST [youtube]":
dig +short www.youtube.com @"$CUSTOM_FORWARD_SERVER" -p"$CUSTOM_FORWARD_PORT"
echo "CUSTOM_FORWARD TEST [taobao]":
Expand Down
9 changes: 7 additions & 2 deletions src/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,13 @@ if [ "$CNAUTO" != "no" ]; then
if echo "$CUSTOM_FORWARD" | grep -Eoq ":[0-9]+"; then
CUSTOM_FORWARD=$(echo "$CUSTOM_FORWARD" | sed 's/"//g')
sed -i "s/#customforward-seted//g" /tmp/mosdns.yaml
CUSTOM_FORWARD_SERVER=$(echo "$CUSTOM_FORWARD" | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b|[0-9a-fA-F:]+" | head -1)
CUSTOM_FORWARD_PORT=$(echo "$CUSTOM_FORWARD" | rev | cut -d':' -f1 | rev)
if echo "$CUSTOM_FORWARD" | grep -q '\['; then
CUSTOM_FORWARD_SERVER=$(echo "$CUSTOM_FORWARD" | sed 's/\[//' | cut -d']' -f1)
CUSTOM_FORWARD_PORT=$(echo "$CUSTOM_FORWARD" | sed 's/.*\]://' | sed 's/[^0-9]*//')
else
CUSTOM_FORWARD_SERVER=$(echo "$CUSTOM_FORWARD" | cut -d':' -f1)
CUSTOM_FORWARD_PORT=$(echo "$CUSTOM_FORWARD" | cut -d':' -f2)
fi
sed -i "s/{CUSTOM_FORWARD}/$CUSTOM_FORWARD/g" /tmp/mosdns.yaml
sed -i "s/{CUSTOM_FORWARD_SERVER}/$CUSTOM_FORWARD_SERVER/g" /tmp/mosdns.yaml
sed -i "s/{CUSTOM_FORWARD_PORT}/$CUSTOM_FORWARD_PORT/g" /tmp/mosdns.yaml
Expand Down

0 comments on commit 6ae1897

Please sign in to comment.