Commit 33453ad2 authored by szh's avatar szh

添加反馈 无ssh功能

parent a49df86e
......@@ -566,12 +566,12 @@ type PaiProcessInfo struct {
}
func AutoSSHClean() error {
pai,err := getPaiProcessInfo()
pai,err := getAutoSSHProcessInfo()
if err != nil {
return err
}
tlog.Info("getPaiProcessInfo","pai",*pai)
tlog.Info("getAutoSSHProcessInfo","pai",*pai)
if pai.Stime > 0 && (time.Now().Unix()-pai.Stime) > 72 * 3600 && pai.Pid > 0 {
err := KillAutoSsh(pai.Pid)
......@@ -590,7 +590,7 @@ func KillAutoSsh(pid int32) error {
return cmd.Run()
}
func getPaiProcessInfo() (*PaiProcessInfo,error) {
func getAutoSSHProcessInfo() (*PaiProcessInfo,error) {
var pai PaiProcessInfo
var buf bytes.Buffer
cmd := exec.Command("bash","-c","ps -eo pid,lstart,cmd |grep autossh | grep -v grep")
......
......@@ -339,6 +339,70 @@ func FeedBack(c *gin.Context){
appG.Response(http.StatusOK,e.NETWORK_ERROR,nil)
}
//反馈信息
func FeedBackWithoutSSH(c *gin.Context){
appG:=app.Gin{C:c}
local_keyPair:=make(map[string]string)
results:=make(map[string]string)
keyPairStream,_:=ioutil.ReadAll(appG.C.Request.Body)
err:=json.Unmarshal(keyPairStream,&local_keyPair)
if err!=nil{
appG.Response(http.StatusOK,e.INVALID_PARAMS,nil)
log.Println(err)
return
}
local_keyPair["public"]=app.GetPubKey()
keyPairStream,_=json.Marshal(local_keyPair)
resp,err:=http.Post(setting.Chain33Pai.FeedBackUrl,"application/json",bytes.NewReader(keyPairStream))
if err!=nil{
appG.Response(http.StatusOK,e.NETWORK_ERROR,"网络错误")
log.Println(err)
return
}
keyPairStream,_=ioutil.ReadAll(resp.Body)
//log.Println(string(keyPairStream))
err=json.Unmarshal(keyPairStream,&results)
if err!=nil{
appG.Response(http.StatusOK,e.ENV_ERROR,"系统错误")
log.Println(err)
return
}
if results["code"]=="200"{
appG.Response(http.StatusOK,e.SUCCESS,nil)
return
}
appG.Response(http.StatusOK,e.NETWORK_ERROR,nil)
}
func FeedBackStatusWithoutSSH(c *gin.Context){
appG:=app.Gin{C:c}
results := make(map[string]interface{})
resp,err:=http.Post(setting.Chain33Pai.IsCompleteUrl,"application/json",nil)
if err!=nil{
appG.Response(http.StatusOK,e.NETWORK_ERROR,"网络错误")
log.Println(err)
return
}
data,_ :=ioutil.ReadAll(resp.Body)
err=json.Unmarshal(data,&results)
if err!=nil{
appG.Response(http.StatusOK,e.NETWORK_ERROR,"网络错误")
log.Println(err)
return
}
if results["code"]==float64(e.UNDONE){
appG.Response(http.StatusOK,e.UNDONE,"未解决")
return
}
if results["msg"]=="ok"{
appG.Response(http.StatusOK,e.SUCCESS,nil)
return
}
appG.Response(http.StatusOK,e.NETWORK_ERROR,"网络出错")
log.Println(results)
}
func FeedBackStatus(c *gin.Context){
appG:=app.Gin{C:c}
results:=make(map[string]interface{})
......
......@@ -42,6 +42,10 @@ func InitRouter() *gin.Engine {
apiv1.POST("/feedback",v1.FeedBack)
//反馈处理进度
apiv1.POST("/iscomplete",v1.FeedBackStatus)
//反馈信息
apiv1.POST("/feedbacknew",v1.FeedBackWithoutSSH)
//反馈处理进度
apiv1.POST("/iscompletenew",v1.FeedBackStatusWithoutSSH)
apiv1.POST("/escrowpassword",v1.EscrowPasswd)
//pai更新完成用户手动重启设备
//apiv1.POST("/isreboot",v1.IsReBoot)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment