module Hans.Nat where
import Hans.Addr (toAddr)
import qualified Hans.Nat.State as Nat
import Hans.Network (Network)
import Hans.Tcp.Packet (TcpPort)
import Hans.Types
import Hans.Udp.Packet (UdpPort)
forwardTcpPort :: Network addr
=> NetworkStack
-> addr
-> TcpPort
-> addr
-> TcpPort
-> IO ()
forwardTcpPort ns src srcPort dest destPort =
Nat.addTcpPortForward ns
Nat.PortForward { pfSourceAddr = toAddr src
, pfSourcePort = srcPort
, pfDestAddr = toAddr dest
, pfDestPort = destPort }
removeTcpPortForward :: Network addr
=> NetworkStack
-> addr
-> TcpPort
-> IO ()
removeTcpPortForward ns src port = Nat.removeTcpPortForward ns (toAddr src) port
forwardUdpPort :: Network addr
=> NetworkStack
-> addr
-> UdpPort
-> addr
-> UdpPort
-> IO ()
forwardUdpPort ns src srcPort dest destPort =
Nat.addUdpPortForward ns
Nat.PortForward { pfSourceAddr = toAddr src
, pfSourcePort = srcPort
, pfDestAddr = toAddr dest
, pfDestPort = destPort }
removeUdpPortForward :: Network addr
=> NetworkStack
-> addr
-> UdpPort
-> IO ()
removeUdpPortForward ns src port = Nat.removeUdpPortForward ns (toAddr src) port