fix(deps): update module github.com/rootless-containers/rootlesskit/v2 to v2.3.2

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2025-01-21 16:48:08 +00:00
committed by GitHub
parent dbed85889c
commit cfac38a0f2
6 changed files with 41 additions and 16 deletions

View File

@ -123,6 +123,11 @@ func (d *childDriver) handleConnectRequest(c *net.UnixConn, req *msg.Request) er
ip := req.IP
if ip == "" {
ip = "127.0.0.1"
if req.ParentIP != "" {
if req.ParentIP != req.HostGatewayIP && req.ParentIP != "0.0.0.0" {
ip = req.ParentIP
}
}
} else {
p := net.ParseIP(ip)
if p == nil {

View File

@ -19,10 +19,12 @@ const (
// Request and Response are encoded as JSON with uint32le length header.
type Request struct {
Type string // "init" or "connect"
Proto string // "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6"
IP string
Port int
Type string // "init" or "connect"
Proto string // "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6"
IP string
Port int
ParentIP string
HostGatewayIP string
}
// Reply may contain FD as OOB
@ -48,14 +50,33 @@ func Initiate(c *net.UnixConn) error {
return c.CloseRead()
}
func hostGatewayIP() string {
addrs, err := net.InterfaceAddrs()
if err != nil {
return ""
}
for _, addr := range addrs {
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
return ipnet.IP.String()
}
}
}
return ""
}
// ConnectToChild connects to the child UNIX socket, and obtains TCP or UDP socket FD
// that corresponds to the port spec.
func ConnectToChild(c *net.UnixConn, spec port.Spec) (int, error) {
req := Request{
Type: RequestTypeConnect,
Proto: spec.Proto,
Port: spec.ChildPort,
IP: spec.ChildIP,
Type: RequestTypeConnect,
Proto: spec.Proto,
Port: spec.ChildPort,
IP: spec.ChildIP,
ParentIP: spec.ParentIP,
HostGatewayIP: hostGatewayIP(),
}
if _, err := lowlevelmsgutil.MarshalToWriter(c, &req); err != nil {
return 0, err

View File

@ -159,8 +159,7 @@ func (d *driver) AddPort(ctx context.Context, spec port.Spec) (*port.Status, err
case "udp", "udp4", "udp6":
err = udp.Run(d.socketPath, spec, routineStopCh, routineStoppedCh, d.logWriter)
default:
// NOTREACHED
return nil, errors.New("spec was not validated?")
return nil, fmt.Errorf("unsupported port protocol %s", spec.Proto)
}
if err != nil {
if isEPERM(err) {