mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-26 10:43:43 +00:00
Use existing IP regex
This commit is contained in:
+4
-4
@@ -10,7 +10,7 @@
|
||||
TAG="SS_SPEC" # iptables tag
|
||||
IPT="iptables -t nat" # alias of iptables
|
||||
FWI=$(uci get firewall.shadowsocks.path 2>/dev/null) # firewall include file
|
||||
REGEX="[^0-9.]" # used to check if hostnames have letters
|
||||
IP_REGEX="^([0-9]{1,3}\.){3}[0-9]{1,3}" # used to check if input is a valid IP
|
||||
|
||||
usage() {
|
||||
cat <<-EOF
|
||||
@@ -127,7 +127,7 @@ tp_rule() {
|
||||
}
|
||||
|
||||
get_wan_ip() {
|
||||
cat <<-EOF | grep -E "^([0-9]{1,3}\.){3}[0-9]{1,3}"
|
||||
cat <<-EOF | grep -E $IP_REGEX
|
||||
$server
|
||||
$SERVER
|
||||
$WAN_BP_IP
|
||||
@@ -173,7 +173,7 @@ while getopts ":s:l:S:L:i:I:e:a:b:w:ouUfh" arg; do
|
||||
s)
|
||||
command -v dig > /dev/null &&
|
||||
server=$(dig +short $OPTARG) ||
|
||||
if [[ $OPTARG =~ $REGEX ]]
|
||||
if ! [[ $OPTARG =~ $IP_REGEX ]]
|
||||
then
|
||||
loger 3 "Hostname detected for server but no dig present to resolve!"
|
||||
exit 1
|
||||
@@ -187,7 +187,7 @@ while getopts ":s:l:S:L:i:I:e:a:b:w:ouUfh" arg; do
|
||||
S)
|
||||
command -v dig > /dev/null &&
|
||||
SERVER=$(dig +short $OPTARG) ||
|
||||
if [[ $OPTARG =~ $REGEX ]]
|
||||
if ! [[ $OPTARG =~ $IP_REGEX ]]
|
||||
then
|
||||
loger 3 "Hostname detected for UDP server but no dig present to resolve!"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user