summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/tunnel/runtime.go
blob: 75bd4ef5ef47cdf3489b3f21559a37be5d5e1bde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package tunnel

import (
	"context"
	"os"
	"syscall"

	"github.com/containers/podman/v4/libpod/define"
	"github.com/containers/podman/v4/pkg/signal"
	"github.com/sirupsen/logrus"
)

// Image-related runtime using an ssh-tunnel to utilize Podman service
type ImageEngine struct {
	ClientCtx context.Context
}

// Container-related runtime using an ssh-tunnel to utilize Podman service
type ContainerEngine struct {
	ClientCtx context.Context
}

// Container-related runtime using an ssh-tunnel to utilize Podman service
type SystemEngine struct {
	ClientCtx context.Context
}

func remoteProxySignals(ctrID string, killFunc func(string) error) {
	sigBuffer := make(chan os.Signal, signal.SignalBufferSize)
	signal.CatchAll(sigBuffer)

	logrus.Debugf("Enabling signal proxying")

	go func() {
		for s := range sigBuffer {
			syscallSignal := s.(syscall.Signal)
			if signal.IsSignalIgnoredBySigProxy(syscallSignal) {
				continue
			}
			signalName, err := signal.ParseSysSignalToName(syscallSignal)
			if err != nil {
				logrus.Infof("Ceasing signal %v forwarding to container %s as it has stopped: %s", s, ctrID, err)
			}
			if err := killFunc(signalName); err != nil {
				if err.Error() == define.ErrCtrStateInvalid.Error() {
					logrus.Debugf("Ceasing signal %q forwarding to container %s as it has stopped", signalName, ctrID)
				}
			}
		}
	}()
}