forked from openservicemesh/osm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
injector: support inbound port exclusions
Similar to outbound port exclusions (global and pod scoped), this change adds support to exclude specified ports from inbound sidecar redirection. This is required in certain scenarios when traffic destined to certain ports should not be proxied to the sidecar (ex. ports that terminate TLS connections in the app). Required for openservicemesh#3582 Signed-off-by: Shashank Ram <[email protected]>
1 parent
4320002
commit 0f7c274
Showing
20 changed files
with
221 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package injector | ||
|
||
import ( | ||
"testing" | ||
|
||
tassert "github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGenerateIptablesCommands(t *testing.T) { | ||
assert := tassert.New(t) | ||
|
||
outboundIPRangeExclusion := []string{"1.1.1.1/32", "2.2.2.2/32"} | ||
outboundPortExclusion := []int{10, 20} | ||
inboundPortExclusion := []int{30, 40} | ||
|
||
actual := generateIptablesCommands(outboundIPRangeExclusion, outboundPortExclusion, inboundPortExclusion) | ||
|
||
expected := []string{ | ||
"iptables -t nat -N PROXY_INBOUND", | ||
"iptables -t nat -N PROXY_IN_REDIRECT", | ||
"iptables -t nat -N PROXY_OUTPUT", | ||
"iptables -t nat -N PROXY_REDIRECT", | ||
"iptables -t nat -A PROXY_REDIRECT -p tcp -j REDIRECT --to-port 15001", | ||
"iptables -t nat -A PROXY_REDIRECT -p tcp --dport 15000 -j ACCEPT", | ||
"iptables -t nat -A OUTPUT -p tcp -j PROXY_OUTPUT", | ||
"iptables -t nat -A PROXY_OUTPUT -m owner --uid-owner 1500 -j RETURN", | ||
"iptables -t nat -A PROXY_OUTPUT -d 127.0.0.1/32 -j RETURN", | ||
"iptables -t nat -A PROXY_OUTPUT -j PROXY_REDIRECT", | ||
"iptables -t nat -A PROXY_IN_REDIRECT -p tcp -j REDIRECT --to-port 15003", | ||
"iptables -t nat -A PREROUTING -p tcp -j PROXY_INBOUND", | ||
"iptables -t nat -A PROXY_INBOUND -p tcp --dport 15010 -j RETURN", | ||
"iptables -t nat -A PROXY_INBOUND -p tcp --dport 15901 -j RETURN", | ||
"iptables -t nat -A PROXY_INBOUND -p tcp --dport 15902 -j RETURN", | ||
"iptables -t nat -A PROXY_INBOUND -p tcp --dport 15903 -j RETURN", | ||
"iptables -t nat -A PROXY_INBOUND -p tcp -j PROXY_IN_REDIRECT", | ||
"iptables -t nat -I PROXY_OUTPUT -d 1.1.1.1/32 -j RETURN", | ||
"iptables -t nat -I PROXY_OUTPUT -d 2.2.2.2/32 -j RETURN", | ||
"iptables -t nat -I PROXY_OUTPUT -p tcp --match multiport --dports 10,20 -j RETURN", | ||
"iptables -t nat -I PROXY_INBOUND -p tcp --match multiport --dports 30,40 -j RETURN", | ||
} | ||
|
||
assert.ElementsMatch(expected, actual) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters