update
This commit is contained in:
parent
38de051978
commit
f99145deac
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@ -87,10 +86,10 @@ func (ss *SSHService) RunShell(shell string) {
|
|||||||
session *ssh.Session
|
session *ssh.Session
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
//获取session,这个session是用来远程执行操作的
|
//获取session,这个session是用来远程执行操作的
|
||||||
if session, err = ss.Client.NewSession(); err != nil {
|
if session, err = ss.Client.NewSession(); err != nil {
|
||||||
log.Fatalln("error occurred:", err)
|
logrus.Errorf("error newsession:%v", err)
|
||||||
}
|
}
|
||||||
// 使用 session.Shell() 模拟终端时,所建立的终端参数
|
// 使用 session.Shell() 模拟终端时,所建立的终端参数
|
||||||
modes := ssh.TerminalModes{
|
modes := ssh.TerminalModes{
|
||||||
@ -105,7 +104,7 @@ func (ss *SSHService) RunShell(shell string) {
|
|||||||
|
|
||||||
//执行shell
|
//执行shell
|
||||||
if output, err := session.CombinedOutput(shell); err != nil {
|
if output, err := session.CombinedOutput(shell); err != nil {
|
||||||
log.Fatalln("error occurred:", err)
|
logrus.Errorf("error CombinedOutput:%v", err)
|
||||||
} else {
|
} else {
|
||||||
ss.LastResult = string(output)
|
ss.LastResult = string(output)
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ type (
|
|||||||
// 随机任务
|
// 随机任务
|
||||||
IRtask interface {
|
IRtask interface {
|
||||||
//任务触发
|
//任务触发
|
||||||
SendToRtask(session IUserSession, param *pb.RtaskParam) (code pb.ErrorCode)
|
SendToRtask(session IUserSession, rtaskType int32, params ...interface{}) (code pb.ErrorCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
//好友
|
//好友
|
||||||
|
@ -61,13 +61,13 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
|||||||
frtaskArr = &pb.FrtaskIds{}
|
frtaskArr = &pb.FrtaskIds{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新完成的任务
|
|
||||||
//验证该任务是否已完成
|
//验证该任务是否已完成
|
||||||
if _, ok := utils.Findx(frtaskArr.RtaskIds, req.RtaskId); ok {
|
if _, ok := utils.Findx(frtaskArr.RtaskIds, req.RtaskId); ok {
|
||||||
code = pb.ErrorCode_RtaskFinished
|
code = pb.ErrorCode_RtaskFinished
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新完成的任务
|
||||||
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
||||||
if rtask.FrtaskIds == nil {
|
if rtask.FrtaskIds == nil {
|
||||||
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
|
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
|
||||||
@ -80,9 +80,6 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
|||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
}
|
}
|
||||||
|
|
||||||
//发奖励
|
|
||||||
code = this.moduleRtask.DispenseRes(session, sideConf.Reward, true)
|
|
||||||
|
|
||||||
rsp := &pb.RtaskChooseResp{
|
rsp := &pb.RtaskChooseResp{
|
||||||
RtaskId: req.RtaskId,
|
RtaskId: req.RtaskId,
|
||||||
ChooseId: req.ChooseId,
|
ChooseId: req.ChooseId,
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -112,3 +113,7 @@ func (this *ModuleRtask) initRtaskHandle() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SendToRtask(session comm.IUserSession, rtaskType int32, params ...interface{}) (code pb.ErrorCode) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user