Use internal port for forwarding rules

This commit is contained in:
Aode 2021-06-13 11:58:42 -05:00
parent ac24dd602e
commit ef01da8f04
2 changed files with 8 additions and 8 deletions

View file

@ -97,13 +97,13 @@ pub(crate) async fn forward_accept(
external_interface: &str,
internal_interface: &str,
proto: Proto,
external_port: u16,
internal_port: u16,
) -> Result<(), anyhow::Error> {
forward(
external_interface,
internal_interface,
proto,
external_port,
internal_port,
move |cmd| cmd.arg("-I"),
)
.await
@ -113,13 +113,13 @@ pub(crate) async fn delete_forward_accept(
external_interface: &str,
internal_interface: &str,
proto: Proto,
external_port: u16,
internal_port: u16,
) -> Result<(), anyhow::Error> {
forward(
external_interface,
internal_interface,
proto,
external_port,
internal_port,
move |cmd| cmd.arg("-D"),
)
.await
@ -129,7 +129,7 @@ async fn forward(
external_interface: &str,
internal_interface: &str,
proto: Proto,
external_port: u16,
internal_port: u16,
func: impl Fn(&mut Command) -> &mut Command,
) -> Result<(), anyhow::Error> {
iptables_filter(move |cmd| {
@ -142,7 +142,7 @@ async fn forward(
"-p",
proto.as_iptables_str(),
"--dport",
&external_port.to_string(),
&internal_port.to_string(),
"-m",
"conntrack",
"--ctstate",

View file

@ -96,7 +96,7 @@ pub(crate) async fn unset(interfaces: &Interfaces, rule: Rule) -> Result<(), any
&interfaces.external.interface,
&info.interface,
rule.proto,
rule.port,
dest_port,
)
.await?;
}
@ -182,7 +182,7 @@ pub(crate) async fn apply(interfaces: &Interfaces, rule: Rule) -> Result<(), any
&interfaces.external.interface,
&info.interface,
rule.proto,
rule.port,
dest_port,
)
.await?;
}