Browse Source

Use existing IP regex

pull/2230/head
Ptomerty 6 years ago
committed by GitHub
parent
commit
d05970fd0c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions
  1. 8
      src/ss-nat

8
src/ss-nat

@ -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

Loading…
Cancel
Save