本文整理汇总了Golang中github.com/subgraph/oz/ipc.Message类的典型用法代码示例。如果您正苦于以下问题:Golang Message类的具体用法?Golang Message怎么用?Golang Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: handleListSandboxes
func (d *daemonState) handleListSandboxes(list *ListSandboxesMsg, msg *ipc.Message) error {
r := new(ListSandboxesResp)
for _, sb := range d.sandboxes {
r.Sandboxes = append(r.Sandboxes, SandboxInfo{Id: sb.id, Address: sb.addr, Mounts: sb.mountedFiles, Profile: sb.profile.Name})
}
return msg.Respond(r)
}
开发者ID:RoPe93,项目名称:oz,代码行数:7,代码来源:daemon.go
示例2: handleGetConfig
func (d *daemonState) handleGetConfig(msg *GetConfigMsg, m *ipc.Message) error {
d.Debug("received get config with data [%s]", msg.Data)
jdata, err := json.Marshal(d.config)
if err != nil {
return m.Respond(&ErrorMsg{err.Error()})
}
return m.Respond(&GetConfigMsg{string(jdata)})
}
开发者ID:RoPe93,项目名称:oz,代码行数:8,代码来源:daemon.go
示例3: handleListProfiles
func (d *daemonState) handleListProfiles(msg *ListProfilesMsg, m *ipc.Message) error {
r := new(ListProfilesResp)
index := 1
for _, p := range d.profiles {
r.Profiles = append(r.Profiles, Profile{Index: index, Name: p.Name, Path: p.Path})
index += 1
}
return m.Respond(r)
}
开发者ID:RoPe93,项目名称:oz,代码行数:9,代码来源:daemon.go
示例4: handleRunProgram
func (st *initState) handleRunProgram(rp *RunProgramMsg, msg *ipc.Message) error {
st.log.Info("Run program message received: %+v", rp)
_, err := st.launchApplication(rp.Path, rp.Pwd, rp.Args)
if err != nil {
err := msg.Respond(&ErrorMsg{Msg: err.Error()})
return err
} else {
err := msg.Respond(&OkMsg{})
return err
}
}
开发者ID:RoPe93,项目名称:oz,代码行数:11,代码来源:init.go
示例5: handleLogs
func (d *daemonState) handleLogs(logs *LogsMsg, msg *ipc.Message) error {
for n := d.memBackend.Head(); n != nil; n = n.Next() {
s := n.Record.Formatted(0)
msg.Respond(&LogData{Lines: []string{s}})
}
if logs.Follow {
d.followLogs(msg)
return nil
}
msg.Respond(&OkMsg{})
return nil
}
开发者ID:RoPe93,项目名称:oz,代码行数:12,代码来源:daemon.go
示例6: handleRunShell
func (st *initState) handleRunShell(rs *RunShellMsg, msg *ipc.Message) error {
if msg.Ucred == nil {
return msg.Respond(&ErrorMsg{"No credentials received for RunShell command"})
}
if (msg.Ucred.Uid == 0 || msg.Ucred.Gid == 0) && st.config.AllowRootShell != true {
return msg.Respond(&ErrorMsg{"Cannot open shell because allowRootShell is disabled"})
}
st.log.Info("Starting shell with uid = %d, gid = %d", msg.Ucred.Uid, msg.Ucred.Gid)
cmd := exec.Command(st.config.ShellPath, "-i")
cmd.SysProcAttr = &syscall.SysProcAttr{}
cmd.SysProcAttr.Credential = &syscall.Credential{
Uid: msg.Ucred.Uid,
Gid: msg.Ucred.Gid,
}
cmd.Env = append(cmd.Env, st.launchEnv...)
if rs.Term != "" {
cmd.Env = append(cmd.Env, "TERM="+rs.Term)
}
if msg.Ucred.Uid != 0 && msg.Ucred.Gid != 0 {
if st.user != nil && st.user.HomeDir != "" {
cmd.Dir = st.user.HomeDir
}
}
cmd.Env = append(cmd.Env, fmt.Sprintf("PS1=[%s] $ ", st.profile.Name))
st.log.Info("Executing shell...")
f, err := ptyStart(cmd)
defer f.Close()
if err != nil {
return msg.Respond(&ErrorMsg{err.Error()})
}
st.addChildProcess(cmd)
err = msg.Respond(&OkMsg{}, int(f.Fd()))
return err
}
开发者ID:drptbl,项目名称:oz,代码行数:34,代码来源:init.go
示例7: handleLaunch
func (d *daemonState) handleLaunch(msg *LaunchMsg, m *ipc.Message) error {
d.Debug("Launch message received. Path: %s Name: %s Pwd: %s Args: %+v", msg.Path, msg.Name, msg.Pwd, msg.Args)
p, err := d.getProfileFromLaunchMsg(msg)
if err != nil {
return m.Respond(&ErrorMsg{err.Error()})
}
if sbox := d.getRunningSandboxByName(p.Name); sbox != nil {
if msg.Noexec {
errmsg := "Asked to launch program but sandbox is running and noexec is set!"
d.Notice(errmsg)
return m.Respond(&ErrorMsg{errmsg})
} else {
d.Info("Found running sandbox for `%s`, running program there", p.Name)
sbox.launchProgram(d.config.PrefixPath, msg.Path, msg.Pwd, msg.Args, d.log)
}
} else {
d.Debug("Would launch %s", p.Name)
rawEnv := msg.Env
msg.Env = d.sanitizeEnvironment(p, rawEnv)
_, err = d.launch(p, msg, rawEnv, m.Ucred.Uid, m.Ucred.Gid, d.log)
if err != nil {
d.Warning("Launch of %s failed: %v", p.Name, err)
return m.Respond(&ErrorMsg{err.Error()})
}
}
return m.Respond(&OkMsg{})
}
开发者ID:RoPe93,项目名称:oz,代码行数:28,代码来源:daemon.go
示例8: handleUnmountFile
func (d *daemonState) handleUnmountFile(msg *UnmountFileMsg, m *ipc.Message) error {
sbox := d.sandboxById(msg.Id)
if sbox == nil {
return m.Respond(&ErrorMsg{fmt.Sprintf("no sandbox found with id = %d", msg.Id)})
}
if err := sbox.UnmountFile(msg.File, d.config.PrefixPath, d.log); err != nil {
return m.Respond(&ErrorMsg{fmt.Sprintf("Unable to unmount: %v", err)})
}
return m.Respond(&OkMsg{})
}
开发者ID:RoPe93,项目名称:oz,代码行数:10,代码来源:daemon.go
示例9: handleKillSandbox
func (d *daemonState) handleKillSandbox(msg *KillSandboxMsg, m *ipc.Message) error {
if msg.Id == -1 {
for _, sb := range d.sandboxes {
if err := sb.init.Process.Signal(os.Interrupt); err != nil {
return m.Respond(&ErrorMsg{fmt.Sprintf("failed to send interrupt signal: %v", err)})
}
}
} else {
sbox := d.sandboxById(msg.Id)
if sbox == nil {
return m.Respond(&ErrorMsg{fmt.Sprintf("no sandbox found with id = %d", msg.Id)})
}
if err := sbox.init.Process.Signal(os.Interrupt); err != nil {
return m.Respond(&ErrorMsg{fmt.Sprintf("failed to send interrupt signal: %v", err)})
}
}
return m.Respond(&OkMsg{})
}
开发者ID:RoPe93,项目名称:oz,代码行数:18,代码来源:daemon.go
示例10: handlePing
func handlePing(ping *PingMsg, msg *ipc.Message) error {
return msg.Respond(&PingMsg{Data: ping.Data})
}
开发者ID:RoPe93,项目名称:oz,代码行数:3,代码来源:init.go
示例11: handlePing
func (d *daemonState) handlePing(msg *PingMsg, m *ipc.Message) error {
d.Debug("received ping with data [%s]", msg.Data)
return m.Respond(&PingMsg{msg.Data})
}
开发者ID:RoPe93,项目名称:oz,代码行数:4,代码来源:daemon.go
注:本文中的github.com/subgraph/oz/ipc.Message类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论