Filled out FreeBSD port forwarding control.
This commit is contained in:
parent
fee5f4d293
commit
d6a3d8ad99
@ -14,7 +14,19 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func setupPortForward(ip, port string) {
|
||||
func setupPortForward(ruleName, ip, port string) {
|
||||
pfrule := "\"rdr pass on $ext_if proto { tcp, udp } from any to any port {" + port + "} -> " + ip + "\""
|
||||
|
||||
in, err := exec.Command("pfctl", "-a", "\""+ruleName+"\"", "-f", "-").StdinPipe()
|
||||
defer in.Close()
|
||||
if err != nil {
|
||||
log.Println("Port Forwarding:", err)
|
||||
}
|
||||
|
||||
_, err = in.Write([]byte(pfrule))
|
||||
if err != nil {
|
||||
log.Println("Port Forwarding:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func portUsageCount(ports ...int) int {
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
// just have this stub to allow building on Linux
|
||||
func setupPortForward(ip, port string) {
|
||||
func setupPortForward(ruleName, ip, port string) {
|
||||
log.Print("Port forwarding not currently implemented for Linux/iptables")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user