mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-29 05:27:41 +00:00
commit
5799714117
@ -47,26 +47,26 @@ func NewVsockProxy(frontendAddr *vsock.VsockAddr, backendAddr net.Addr) (Proxy,
|
|||||||
|
|
||||||
// NewIPProxy creates a Proxy according to the specified frontendAddr and backendAddr.
|
// NewIPProxy creates a Proxy according to the specified frontendAddr and backendAddr.
|
||||||
func NewIPProxy(frontendAddr, backendAddr net.Addr) (Proxy, error) {
|
func NewIPProxy(frontendAddr, backendAddr net.Addr) (Proxy, error) {
|
||||||
switch frontendAddr.(type) {
|
switch frontendAddr.(type) {
|
||||||
case *net.UDPAddr:
|
case *net.UDPAddr:
|
||||||
listener, err := net.ListenUDP("udp", frontendAddr.(*net.UDPAddr))
|
listener, err := net.ListenUDP("udp", frontendAddr.(*net.UDPAddr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return NewUDPProxy(frontendAddr, listener, backendAddr.(*net.UDPAddr))
|
return NewUDPProxy(frontendAddr, listener, backendAddr.(*net.UDPAddr))
|
||||||
case *net.TCPAddr:
|
case *net.TCPAddr:
|
||||||
listener, err := net.Listen("tcp", frontendAddr.String())
|
listener, err := net.Listen("tcp", frontendAddr.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return NewTCPProxy(listener, backendAddr.(*net.TCPAddr))
|
return NewTCPProxy(listener, backendAddr.(*net.TCPAddr))
|
||||||
case *vsock.VsockAddr:
|
case *vsock.VsockAddr:
|
||||||
listener, err := vsock.Listen(frontendAddr.(*vsock.VsockAddr).Port)
|
listener, err := vsock.Listen(frontendAddr.(*vsock.VsockAddr).Port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return NewTCPProxy(listener, backendAddr.(*net.TCPAddr))
|
return NewTCPProxy(listener, backendAddr.(*net.TCPAddr))
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("Unsupported protocol"))
|
panic(fmt.Errorf("Unsupported protocol"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/rneugeba/virtsock/go/vsock"
|
|
||||||
"github.com/rneugeba/virtsock/go/hvsock"
|
"github.com/rneugeba/virtsock/go/hvsock"
|
||||||
|
"github.com/rneugeba/virtsock/go/vsock"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"proxy/libproxy"
|
"proxy/libproxy"
|
||||||
|
@ -34,9 +34,9 @@ func onePort() {
|
|||||||
sendOK()
|
sendOK()
|
||||||
if ipP != nil {
|
if ipP != nil {
|
||||||
ipP.Run()
|
ipP.Run()
|
||||||
} else {
|
} else {
|
||||||
select{} // sleep forever
|
select {} // sleep forever
|
||||||
}
|
}
|
||||||
ctl.Close() // ensure ctl remains alive and un-GCed until here
|
ctl.Close() // ensure ctl remains alive and un-GCed until here
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
var interactiveMode bool
|
var interactiveMode bool
|
||||||
|
|
||||||
|
|
||||||
// sendError signals the error to the parent and quits the process.
|
// sendError signals the error to the parent and quits the process.
|
||||||
func sendError(err error) {
|
func sendError(err error) {
|
||||||
if interactiveMode {
|
if interactiveMode {
|
||||||
@ -72,7 +71,7 @@ func parseHostContainerAddrs() (host net.Addr, port int, container net.Addr, loc
|
|||||||
default:
|
default:
|
||||||
log.Fatalf("unsupported protocol %s", *proto)
|
log.Fatalf("unsupported protocol %s", *proto)
|
||||||
}
|
}
|
||||||
localIP = ! *noLocalIP
|
localIP = !*noLocalIP
|
||||||
return host, port, container, localIP
|
return host, port, container, localIP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user