blob: 7a711f657b4964893fc35fec82cca22d616ab87a [file] [log] [blame]
package proxy
import (
type Proxy interface {
// Start forwarding traffic back and forth the front and back-end
// addresses.
// Stop forwarding traffic and close both ends of the Proxy.
// Return the address on which the proxy is listening.
FrontendAddr() net.Addr
// Return the proxied address.
BackendAddr() net.Addr
func NewProxy(frontendAddr, backendAddr net.Addr) (Proxy, error) {
switch frontendAddr.(type) {
case *net.UDPAddr:
return NewUDPProxy(frontendAddr.(*net.UDPAddr), backendAddr.(*net.UDPAddr))
case *net.TCPAddr:
return NewTCPProxy(frontendAddr.(*net.TCPAddr), backendAddr.(*net.TCPAddr))
panic(fmt.Errorf("Unsupported protocol"))