Use internal port for forwarding rules
This commit is contained in:
parent
ac24dd602e
commit
ef01da8f04
|
@ -97,13 +97,13 @@ pub(crate) async fn forward_accept(
|
||||||
external_interface: &str,
|
external_interface: &str,
|
||||||
internal_interface: &str,
|
internal_interface: &str,
|
||||||
proto: Proto,
|
proto: Proto,
|
||||||
external_port: u16,
|
internal_port: u16,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
forward(
|
forward(
|
||||||
external_interface,
|
external_interface,
|
||||||
internal_interface,
|
internal_interface,
|
||||||
proto,
|
proto,
|
||||||
external_port,
|
internal_port,
|
||||||
move |cmd| cmd.arg("-I"),
|
move |cmd| cmd.arg("-I"),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -113,13 +113,13 @@ pub(crate) async fn delete_forward_accept(
|
||||||
external_interface: &str,
|
external_interface: &str,
|
||||||
internal_interface: &str,
|
internal_interface: &str,
|
||||||
proto: Proto,
|
proto: Proto,
|
||||||
external_port: u16,
|
internal_port: u16,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
forward(
|
forward(
|
||||||
external_interface,
|
external_interface,
|
||||||
internal_interface,
|
internal_interface,
|
||||||
proto,
|
proto,
|
||||||
external_port,
|
internal_port,
|
||||||
move |cmd| cmd.arg("-D"),
|
move |cmd| cmd.arg("-D"),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -129,7 +129,7 @@ async fn forward(
|
||||||
external_interface: &str,
|
external_interface: &str,
|
||||||
internal_interface: &str,
|
internal_interface: &str,
|
||||||
proto: Proto,
|
proto: Proto,
|
||||||
external_port: u16,
|
internal_port: u16,
|
||||||
func: impl Fn(&mut Command) -> &mut Command,
|
func: impl Fn(&mut Command) -> &mut Command,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
iptables_filter(move |cmd| {
|
iptables_filter(move |cmd| {
|
||||||
|
@ -142,7 +142,7 @@ async fn forward(
|
||||||
"-p",
|
"-p",
|
||||||
proto.as_iptables_str(),
|
proto.as_iptables_str(),
|
||||||
"--dport",
|
"--dport",
|
||||||
&external_port.to_string(),
|
&internal_port.to_string(),
|
||||||
"-m",
|
"-m",
|
||||||
"conntrack",
|
"conntrack",
|
||||||
"--ctstate",
|
"--ctstate",
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub(crate) async fn unset(interfaces: &Interfaces, rule: Rule) -> Result<(), any
|
||||||
&interfaces.external.interface,
|
&interfaces.external.interface,
|
||||||
&info.interface,
|
&info.interface,
|
||||||
rule.proto,
|
rule.proto,
|
||||||
rule.port,
|
dest_port,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ pub(crate) async fn apply(interfaces: &Interfaces, rule: Rule) -> Result<(), any
|
||||||
&interfaces.external.interface,
|
&interfaces.external.interface,
|
||||||
&info.interface,
|
&info.interface,
|
||||||
rule.proto,
|
rule.proto,
|
||||||
rule.port,
|
dest_port,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue