소스 검색

Check port is number

Edvinas Valatka 9 년 전
부모
커밋
3ddc4a9d7f
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      e-router

+ 4 - 4
e-router

@@ -60,22 +60,22 @@ banwanin() {
 
 dropwanin() {
     while read -r port ; do
-        [[ -n "$port" ]] || continue
+        [[ "$port" =~ ^[0-9]{1,}$ ]] || continue
         iptables -A WANIN -i ${wan} -m udp -p udp --dport $port -j DROP
     done < $CONFD/DROP.udp
     while read -r port ; do
-        [[ -n "$port" ]] || continue
+        [[ "$port" =~ ^[0-9]{1,}$ ]] || continue
         iptables -A WANIN -i ${wan} -m tcp -p tcp --dport $port -j DROP
     done < $CONFD/DROP.tcp
 }
 
 passwanin() {
     while read -r port ; do
-        [[ -n "$port" ]] || continue
+        [[ "$port" =~ ^[0-9]{1,}$ ]] || continue
         iptables -A WANIN -i ${wan} -m udp -p udp --dport $port -j ACCEPT
     done < $CONFD/ACCEPT.udp
     while read -r port ; do
-        [[ -n "$port" ]] || continue
+        [[ "$port" =~ ^[0-9]{1,}$ ]] || continue
         iptables -A WANIN -i ${wan} -m tcp -p tcp --dport $port -j ACCEPT
     done < $CONFD/ACCEPT.tcp
 }