Skip to content

Commit b576b77

Browse files
committed
fix(config): Properly set default idle timeout for stateful NAT
Previously idle_timeout would be set to 0 if not explicitly set when calling VpcExpose::make_stateful_nat. This commit restructures the make_stateful_nat code to use the default implementation of the stateful NAT options which has the correct default duration. Signed-off-by: Manish Vachharajani <manish@githedgehog.com>
1 parent 380419a commit b576b77

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

config/src/external/overlay/vpcpeering.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,21 @@ impl VpcExpose {
110110
mut self,
111111
idle_timeout: Option<Duration>,
112112
) -> Result<Self, ConfigError> {
113+
let options = idle_timeout
114+
.map(|to| VpcExposeStatefulNat { idle_timeout: to })
115+
.unwrap_or_default();
113116
match self.nat.as_mut() {
114117
Some(nat) if nat.is_stateful() => {
115-
nat.config = VpcExposeNatConfig::Stateful(VpcExposeStatefulNat {
116-
idle_timeout: idle_timeout.unwrap_or_default(),
117-
});
118+
nat.config = VpcExposeNatConfig::Stateful(options);
118119
Ok(self)
119120
}
120121
Some(_) => Err(ConfigError::Invalid(format!(
121122
"refusing to overwrite stateless NAT mode with stateful NAT mode for VpcExpose {self}"
122123
))),
124+
123125
None => {
124126
self.nat = Some(VpcExposeNat {
125-
config: VpcExposeNatConfig::Stateful(VpcExposeStatefulNat {
126-
idle_timeout: idle_timeout.unwrap_or_default(),
127-
}),
127+
config: VpcExposeNatConfig::Stateful(options),
128128
..VpcExposeNat::default()
129129
});
130130
Ok(self)

0 commit comments

Comments
 (0)