feat(gocast_nat): Add listen port option

This commit is contained in:
Daniel Santos
2022-03-16 13:23:35 -06:00
parent f883e4d4b3
commit f1542981d6
3 changed files with 10 additions and 6 deletions

View File

@@ -86,10 +86,10 @@ func deleteLoopback(addr *net.IPNet) error {
return nil
}
func natRule(op string, vip, localAddr net.IP, protocol, port string) error {
func natRule(op string, vip, localAddr net.IP, protocol, lport, dport string) error {
cmd := fmt.Sprintf(
"iptables -t nat -%s PREROUTING -p %s -d %s --dport %s -j DNAT --to-destination %s:%s",
op, protocol, vip.String(), port, localAddr.String(), port,
op, protocol, vip.String(), lport, localAddr.String(), dport,
)
cmdList := getCmdList(cmd)
_, err := exec.Command(execCmd, cmdList...).Output()