fix ip parsing
This commit is contained in:
		
							parent
							
								
									b0d3abcc9b
								
							
						
					
					
						commit
						03950c60ca
					
				
					 1 changed files with 27 additions and 25 deletions
				
			
		| 
						 | 
					@ -93,14 +93,24 @@ TUN needs to be enabled before running this installer."
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
new_client_dns () {
 | 
					new_client_dns () {
 | 
				
			||||||
	echo "Select a DNS server for the client:"
 | 
						# Locate the proper resolv.conf
 | 
				
			||||||
	echo "   1) Current system resolvers"
 | 
						# Needed for systems running systemd-resolved
 | 
				
			||||||
	echo "   2) Google"
 | 
						if grep '^nameserver' "/etc/resolv.conf" | grep -qv '127.0.0.53' ; then
 | 
				
			||||||
	echo "   3) 1.1.1.1"
 | 
							resolv_conf="/etc/resolv.conf"
 | 
				
			||||||
	echo "   4) OpenDNS"
 | 
						else
 | 
				
			||||||
	echo "   5) Quad9"
 | 
							resolv_conf="/run/systemd/resolve/resolv.conf"
 | 
				
			||||||
	echo "   6) AdGuard"
 | 
						fi
 | 
				
			||||||
	echo "   7) Custom resolvers"
 | 
						# Extract nameservers and provide them in the required format
 | 
				
			||||||
 | 
						system_dns=$(grep -v '^#\|^;' "$resolv_conf" | grep '^nameserver' | grep -v '127.0.0.53' | grep -oE '[0-9]{1,3}(\.[0-9]{1,3}){3}' | xargs | sed -e 's/ /, /g')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  echo "Select a DNS server for the client:"
 | 
				
			||||||
 | 
					  echo "   1) Current system resolvers        | $system_dns"
 | 
				
			||||||
 | 
					  echo "   2) 8.8.8.8, 8.8.4.4                | Google"
 | 
				
			||||||
 | 
					  echo "   3) 1.1.1.1, 1.0.0.1                | WARP "
 | 
				
			||||||
 | 
					  echo "   4) 208.67.222.222, 208.67.220.220  | OpenDNS"
 | 
				
			||||||
 | 
					  echo "   5) 9.9.9.9, 149.112.112.112        | Quad9"
 | 
				
			||||||
 | 
					  echo "   6) 94.140.14.14, 94.140.15.15      | AdGuard"
 | 
				
			||||||
 | 
					  echo "   7) Enter custom resolvers"
 | 
				
			||||||
	read -p "DNS server [1]: " dns
 | 
						read -p "DNS server [1]: " dns
 | 
				
			||||||
	until [[ -z "$dns" || "$dns" =~ ^[1-7]$ ]]; do
 | 
						until [[ -z "$dns" || "$dns" =~ ^[1-7]$ ]]; do
 | 
				
			||||||
		echo "$dns: invalid selection."
 | 
							echo "$dns: invalid selection."
 | 
				
			||||||
| 
						 | 
					@ -109,15 +119,7 @@ new_client_dns () {
 | 
				
			||||||
		# DNS
 | 
							# DNS
 | 
				
			||||||
	case "$dns" in
 | 
						case "$dns" in
 | 
				
			||||||
		1|"")
 | 
							1|"")
 | 
				
			||||||
			# Locate the proper resolv.conf
 | 
								dns=$system_dns
 | 
				
			||||||
			# Needed for systems running systemd-resolved
 | 
					 | 
				
			||||||
			if grep '^nameserver' "/etc/resolv.conf" | grep -qv '127.0.0.53' ; then
 | 
					 | 
				
			||||||
				resolv_conf="/etc/resolv.conf"
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				resolv_conf="/run/systemd/resolve/resolv.conf"
 | 
					 | 
				
			||||||
			fi
 | 
					 | 
				
			||||||
			# Extract nameservers and provide them in the required format
 | 
					 | 
				
			||||||
			dns=$(grep -v '^#\|^;' "$resolv_conf" | grep '^nameserver' | grep -v '127.0.0.53' | grep -oE '[0-9]{1,3}(\.[0-9]{1,3}){3}' | xargs | sed -e 's/ /, /g')
 | 
					 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
		2)
 | 
							2)
 | 
				
			||||||
			dns="8.8.8.8, 8.8.4.4"
 | 
								dns="8.8.8.8, 8.8.4.4"
 | 
				
			||||||
| 
						 | 
					@ -137,9 +139,9 @@ new_client_dns () {
 | 
				
			||||||
		7)
 | 
							7)
 | 
				
			||||||
			# Read from the command line, check the format is valid before exiting loop.
 | 
								# Read from the command line, check the format is valid before exiting loop.
 | 
				
			||||||
			while [[ 1 ]]; do
 | 
								while [[ 1 ]]; do
 | 
				
			||||||
			  read -p "Enter custom dns resolvers (e.g. '1.1.1.1, 1.0.0.1'): " dns
 | 
									read -p "Enter custom dns resolvers (e.g. '1.1.1.1, 1.0.0.1'): " dns
 | 
				
			||||||
			  [[ "$dns" =~ ^([0-9]{1,3}[\.]){3}[0-9]{1,3}\,\ ([0-9]{1,3}[\.]){3}[0-9]{1,3}$ ]] && break
 | 
									[[ "$dns" =~ ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ ]] && break
 | 
				
			||||||
			  echo "dns '$dns' incompatible format."
 | 
									echo "dns '$dns' invalid."
 | 
				
			||||||
			done
 | 
								done
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
	esac
 | 
						esac
 | 
				
			||||||
| 
						 | 
					@ -177,11 +179,11 @@ new_network () {
 | 
				
			||||||
			;;
 | 
								;;
 | 
				
			||||||
			5)
 | 
								5)
 | 
				
			||||||
				# Read from the command line, check the format is valid before exiting loop.
 | 
									# Read from the command line, check the format is valid before exiting loop.
 | 
				
			||||||
				while [[ 1 ]]; do
 | 
								while [[ 1 ]]; do
 | 
				
			||||||
					read -p "Enter custom network prefix (e.g. '192.168.1'): " network
 | 
									read -p "Enter custom network prefix (e.g. '192.168.1'): " network
 | 
				
			||||||
					[[ "$network" =~ ^([0-9]{1,3}[\.]){2}[0-9]{1,3}$ ]] && break
 | 
									[[ "$network" =~ ^([0-9]{1,3}[\.]){2}[0-9]{1,3}$ ]] && break
 | 
				
			||||||
					echo "Network '$network' incompatible format."
 | 
									echo "Network '$network' invalid. Note: only 3 subnets, not 4! (e.g. a.b.c)"
 | 
				
			||||||
				done
 | 
								done
 | 
				
			||||||
			;;
 | 
								;;
 | 
				
			||||||
		esac
 | 
							esac
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue