mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-29 13:38:00 +00:00
proxy: tell the /port server the real external IP address
Before this we accidentally told it the vsock address, which obviously isn't much good. Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
parent
b0c4fdae37
commit
1d3b8b566e
@ -8,7 +8,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"libproxy"
|
"libproxy"
|
||||||
"strings"
|
"strings"
|
||||||
"vsock"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -41,7 +40,7 @@ func exposePort(host net.Addr, port int) error {
|
|||||||
log.Printf("Failed to open /port/%s/ctl: %#v\n", name, err)
|
log.Printf("Failed to open /port/%s/ctl: %#v\n", name, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = ctl.WriteString(fmt.Sprintf("%s:%d:%d", name, vsock.VSOCK_CID_SELF, vSockPortOffset + port))
|
_, err = ctl.WriteString(fmt.Sprintf("%s:%08x", name, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to open /port/%s/ctl: %#v\n", name, err)
|
log.Printf("Failed to open /port/%s/ctl: %#v\n", name, err)
|
||||||
return err
|
return err
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"libproxy"
|
"libproxy"
|
||||||
"vsock"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// sendError signals the error to the parent and quits the process.
|
// sendError signals the error to the parent and quits the process.
|
||||||
@ -49,13 +48,12 @@ func parseHostContainerAddrs() (host net.Addr, port int, container net.Addr) {
|
|||||||
|
|
||||||
switch *proto {
|
switch *proto {
|
||||||
case "tcp":
|
case "tcp":
|
||||||
|
host = &net.TCPAddr{IP: net.ParseIP(*hostIP), Port: *hostPort}
|
||||||
port = vSockPortOffset + *hostPort
|
port = vSockPortOffset + *hostPort
|
||||||
host = &vsock.VsockAddr{Port: uint(port)}
|
|
||||||
port = *hostPort
|
|
||||||
container = &net.TCPAddr{IP: net.ParseIP(*containerIP), Port: *containerPort}
|
container = &net.TCPAddr{IP: net.ParseIP(*containerIP), Port: *containerPort}
|
||||||
case "udp":
|
case "udp":
|
||||||
host = &net.UDPAddr{IP: net.ParseIP(*hostIP), Port: *hostPort}
|
host = &net.UDPAddr{IP: net.ParseIP(*hostIP), Port: *hostPort}
|
||||||
port = *hostPort
|
port = vSockPortOffset + *hostPort
|
||||||
container = &net.UDPAddr{IP: net.ParseIP(*containerIP), Port: *containerPort}
|
container = &net.UDPAddr{IP: net.ParseIP(*containerIP), Port: *containerPort}
|
||||||
default:
|
default:
|
||||||
log.Fatalf("unsupported protocol %s", *proto)
|
log.Fatalf("unsupported protocol %s", *proto)
|
||||||
|
Loading…
Reference in New Issue
Block a user