wg-quick: darwin: account for "link#XX" gateways
On macOS, under specific configurations, the `netstat -nr -f inet` and `netstat -nr -f inet6` outputs break gateway collection. Signed-off-by: Laura Hausmann <laura@hausmann.dev> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		
							parent
							
								
									52597c3515
								
							
						
					
					
						commit
						b3aafa6103
					
				@ -194,14 +194,14 @@ collect_gateways() {
 | 
			
		||||
 | 
			
		||||
	GATEWAY4=""
 | 
			
		||||
	while read -r destination gateway _; do
 | 
			
		||||
		[[ $destination == default ]] || continue
 | 
			
		||||
		[[ $destination == default && $gateway != "link#"* ]] || continue
 | 
			
		||||
		GATEWAY4="$gateway"
 | 
			
		||||
		break
 | 
			
		||||
	done < <(netstat -nr -f inet)
 | 
			
		||||
 | 
			
		||||
	GATEWAY6=""
 | 
			
		||||
	while read -r destination gateway _; do
 | 
			
		||||
		[[ $destination == default ]] || continue
 | 
			
		||||
		[[ $destination == default && $gateway != "link#"* ]] || continue
 | 
			
		||||
		GATEWAY6="$gateway"
 | 
			
		||||
		break
 | 
			
		||||
	done < <(netstat -nr -f inet6)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user