Skip to content

Commit a35bb2e

Browse files
author
Ravi Sankar Penta
committed
Indent egress-router.sh: consistent spacing, convert all tabs to spaces
1 parent 29d64d1 commit a35bb2e

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

images/egress/router/egress-router.sh

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ function setup_network() {
3131
# The pod may die and get restarted; only try to add the
3232
# address/route/rules if they are not already there.
3333
if ! ip route get "${EGRESS_GATEWAY}" | grep -q macvlan0; then
34-
ip addr add "${EGRESS_SOURCE}"/32 dev macvlan0
35-
ip link set up dev macvlan0
34+
ip addr add "${EGRESS_SOURCE}"/32 dev macvlan0
35+
ip link set up dev macvlan0
3636

37-
ip route add "${EGRESS_GATEWAY}"/32 dev macvlan0
38-
ip route del default
39-
ip route add default via "${EGRESS_GATEWAY}" dev macvlan0
37+
ip route add "${EGRESS_GATEWAY}"/32 dev macvlan0
38+
ip route del default
39+
ip route add default via "${EGRESS_GATEWAY}" dev macvlan0
4040
fi
4141

4242
# Update neighbor ARP caches in case another node previously had the IP. (This is
@@ -61,43 +61,43 @@ function gen_iptables_rules() {
6161
did_fallback=
6262
declare -A used_ports=()
6363
while read dest; do
64-
if [[ "${dest}" =~ ^${BLANK_LINE_OR_COMMENT_REGEX}$ ]]; then
65-
# comment or blank line
66-
continue
67-
fi
68-
if [[ -n "${did_fallback}" ]]; then
69-
die "EGRESS_DESTINATION fallback IP must be the last line" 1>&2
70-
fi
71-
72-
localport=""
73-
if [[ "${dest}" =~ ^${IP_REGEX}$ ]]; then
74-
# single IP address: do fallback "all ports to same IP"
75-
echo -A PREROUTING -i eth0 -j DNAT --to-destination "${dest}"
76-
did_fallback=1
77-
78-
elif [[ "${dest}" =~ ^${PORT_REGEX}\ +${PROTO_REGEX}\ +${IP_REGEX}$ ]]; then
79-
read localport proto destip <<< "${dest}"
80-
echo -A PREROUTING -i eth0 -p "${proto}" --dport "${localport}" -j DNAT --to-destination "${destip}"
81-
82-
elif [[ "${dest}" =~ ^${PORT_REGEX}\ +${PROTO_REGEX}\ +${IP_REGEX}\ +${PORT_REGEX}$ ]]; then
83-
read localport proto destip destport <<< "${dest}"
84-
validate_port ${destport}
85-
echo -A PREROUTING -i eth0 -p "${proto}" --dport "${localport}" -j DNAT --to-destination "${destip}:${destport}"
86-
87-
else
88-
die "EGRESS_DESTINATION value '${dest}' is invalid" 1>&2
89-
90-
fi
91-
92-
if [[ -n "${localport}" ]]; then
93-
validate_port ${localport}
94-
95-
if [[ "${used_ports[${localport}]:-x}" == "x" ]]; then
96-
used_ports[${localport}]=1
97-
else
98-
die "EGRESS_DESTINATION localport $localport is already used, must be unique for each destination"
99-
fi
64+
if [[ "${dest}" =~ ^${BLANK_LINE_OR_COMMENT_REGEX}$ ]]; then
65+
# comment or blank line
66+
continue
67+
fi
68+
if [[ -n "${did_fallback}" ]]; then
69+
die "EGRESS_DESTINATION fallback IP must be the last line" 1>&2
70+
fi
71+
72+
localport=""
73+
if [[ "${dest}" =~ ^${IP_REGEX}$ ]]; then
74+
# single IP address: do fallback "all ports to same IP"
75+
echo -A PREROUTING -i eth0 -j DNAT --to-destination "${dest}"
76+
did_fallback=1
77+
78+
elif [[ "${dest}" =~ ^${PORT_REGEX}\ +${PROTO_REGEX}\ +${IP_REGEX}$ ]]; then
79+
read localport proto destip <<< "${dest}"
80+
echo -A PREROUTING -i eth0 -p "${proto}" --dport "${localport}" -j DNAT --to-destination "${destip}"
81+
82+
elif [[ "${dest}" =~ ^${PORT_REGEX}\ +${PROTO_REGEX}\ +${IP_REGEX}\ +${PORT_REGEX}$ ]]; then
83+
read localport proto destip destport <<< "${dest}"
84+
validate_port ${destport}
85+
echo -A PREROUTING -i eth0 -p "${proto}" --dport "${localport}" -j DNAT --to-destination "${destip}:${destport}"
86+
87+
else
88+
die "EGRESS_DESTINATION value '${dest}' is invalid" 1>&2
89+
90+
fi
91+
92+
if [[ -n "${localport}" ]]; then
93+
validate_port ${localport}
94+
95+
if [[ "${used_ports[${localport}]:-x}" == "x" ]]; then
96+
used_ports[${localport}]=1
97+
else
98+
die "EGRESS_DESTINATION localport $localport is already used, must be unique for each destination"
10099
fi
100+
fi
101101

102102
done <<< "${EGRESS_DESTINATION}"
103103
echo -A POSTROUTING -j SNAT --to-source "${EGRESS_SOURCE}"
@@ -133,23 +133,23 @@ function wait_until_killed() {
133133

134134
case "${EGRESS_ROUTER_MODE:=legacy}" in
135135
init)
136-
setup_network
137-
setup_iptables
138-
;;
136+
setup_network
137+
setup_iptables
138+
;;
139139

140140
legacy)
141-
setup_network
142-
setup_iptables
143-
wait_until_killed
144-
;;
141+
setup_network
142+
setup_iptables
143+
wait_until_killed
144+
;;
145145

146146
http-proxy)
147-
setup_network
148-
;;
147+
setup_network
148+
;;
149149

150150
unit-test)
151-
gen_iptables_rules
152-
;;
151+
gen_iptables_rules
152+
;;
153153

154154
*)
155155
die "Unrecognized EGRESS_ROUTER_MODE '${EGRESS_ROUTER_MODE}'"

0 commit comments

Comments
 (0)