| 
						
						
						
					 | 
					 | 
					@ -1,4 +1,8 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#Requires -Modules powershell-yaml
 | 
					 | 
					 | 
					 | 
					#Requires -Modules powershell-yaml
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					param (
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    [string]$Chain = $env:CHAIN,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    [string]$Stacks = $env:STACKS
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					$ErrorActionPreference = 'Stop'
 | 
					 | 
					 | 
					 | 
					$ErrorActionPreference = 'Stop'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					function Start-IptablesProcess {
 | 
					 | 
					 | 
					 | 
					function Start-IptablesProcess {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -92,16 +96,15 @@ function Get-DockerIngressAddress {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					# setup SWARM-NAT chain
 | 
					 | 
					 | 
					 | 
					# setup SWARM-NAT chain
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					$chain = 'SWARM-NAT'
 | 
					 | 
					 | 
					 | 
					Write-Output ('Create chain {0}' -f $Chain)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					Write-Output ('Create chain {0}' -f $chain)
 | 
					 | 
					 | 
					 | 
					Add-IptablesChain -Chain $Chain
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					Add-IptablesChain -Chain $chain
 | 
					 | 
					 | 
					 | 
					Add-IptablesRule -Chain 'PREROUTING' -Rule '-m','addrtype','--dst-type','LOCAL','-j',$Chain
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					Add-IptablesRule -Chain 'PREROUTING' -Rule '-m','addrtype','--dst-type','LOCAL','-j',$chain
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					$ingress_address = Get-DockerIngressAddress
 | 
					 | 
					 | 
					 | 
					$ingress_address = Get-DockerIngressAddress
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					foreach($yaml in (Get-ChildItem -Filter '*.yml')) {
 | 
					 | 
					 | 
					 | 
					foreach($yaml in (Get-ChildItem -Path $Stacks -Include '*.yml','*.yaml' -Recurse)) {
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    Write-Output ('Processing {0}' -f $yaml)
 | 
					 | 
					 | 
					 | 
					    Write-Output ('Processing {0}' -f $yaml)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    $definition = Get-Content -Path $yaml -Raw | ConvertFrom-Yaml
 | 
					 | 
					 | 
					 | 
					    $definition = Get-Content -Path $yaml -Raw | ConvertFrom-Yaml
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -156,7 +159,7 @@ foreach($yaml in (Get-ChildItem -Filter '*.yml')) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                '-j','DNAT'
 | 
					 | 
					 | 
					 | 
					                '-j','DNAT'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                '--to-destination','"{0}:{1}"' -f $ingress_address,$nat.port
 | 
					 | 
					 | 
					 | 
					                '--to-destination','"{0}:{1}"' -f $ingress_address,$nat.port
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            )
 | 
					 | 
					 | 
					 | 
					            )
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            Add-IptablesRule -Chain $chain -Rule $rule
 | 
					 | 
					 | 
					 | 
					            Add-IptablesRule -Chain $Chain -Rule $rule
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }
 | 
					 | 
					 | 
					 | 
					        }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 |