You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fw-daemon/sgfw/snitch-ext.go

48 lines
833 B

package sgfw
import (
"github.com/subgraph/ozipc"
)
type ListSandboxesMsg struct {
_ string "ListSandboxes"
}
type SandboxInfo struct {
Id int
Address string
Profile string
Mounts []string
InitPid int
}
type ListSandboxesResp struct {
Sandboxes []SandboxInfo "ListSandboxesResp"
}
const socketPath = "@oz-control"
var ozCtrlFactory = ipc.NewMsgFactory(
new(ListSandboxesMsg),
new(ListSandboxesResp),
)
func getSandboxes() ([]SandboxInfo, error) {
c, err := ipc.Connect(socketPath, ozCtrlFactory, nil)
if err != nil {
log.Fatal("Error connecting to oz control socket: ", err)
return nil, err
}
defer c.Close()
rr, err := c.ExchangeMsg(&ListSandboxesMsg{})
if err != nil {
return nil, err
}
resp := <-rr.Chan()
rr.Done()
sboxes := resp.Body.(*ListSandboxesResp)
return sboxes.Sandboxes, nil
}