Commit ea6bda72 by 陶腾飞

v1.8.1 解决无法处理收到的消息问题

parent eca29c2a
...@@ -64,6 +64,7 @@ UI: ...@@ -64,6 +64,7 @@ UI:
- 2020/08/12 v1.6.1 优化备份方案 - 2020/08/12 v1.6.1 优化备份方案
- 2020/08/19 v1.7.0 更新PDF转化工具,优化用户备份 - 2020/08/19 v1.7.0 更新PDF转化工具,优化用户备份
- 2020/08/21 v1.8.0 合并企业微信推送,转型HTTP服务器,增加活动检测,用户备份升级 - 2020/08/21 v1.8.0 合并企业微信推送,转型HTTP服务器,增加活动检测,用户备份升级
- 2020/08/21 v1.8.1 解决无法处理收到的消息问题
## 其他说明 ## 其他说明
......
...@@ -20,7 +20,7 @@ func initLog(){ ...@@ -20,7 +20,7 @@ func initLog(){
} }
} }
pub.Loger = pub.NewLoger(logpath) pub.Loger = pub.NewLoger(logpath + "adct.log")
} }
func main(){ func main(){
initLog() initLog()
......
...@@ -9,7 +9,9 @@ func main() { ...@@ -9,7 +9,9 @@ func main() {
// 写入日志 // 写入日志
pub.Loger = pub.NewLoger(pub.Dir_AD_log + `daemon.log`) pub.Loger = pub.NewLoger(pub.Dir_AD_log + `daemon.log`)
pub.PrintLog("start daemon!") pub.PrintLog("start daemon!")
http.HandleFunc("/", pub.DealMsgEnter) http.HandleFunc("/", pub.DealMsgEnter)
http.ListenAndServe(pub.DaemonListen,nil) http.ListenAndServe(pub.DaemonListen,nil)
} }
\ No newline at end of file
...@@ -5,7 +5,7 @@ package public ...@@ -5,7 +5,7 @@ package public
const Host_adserver string = "ADSERVER" const Host_adserver string = "ADSERVER"
const ADServerDaemon string = Host_adserver + DaemonListen const ADServerDaemon string = Host_adserver + DaemonListen
const DaemonListen string = ":16823" const DaemonListen string = ":16823"
const Version string = "1.8.0" const Version string = "1.8.1"
const Bak_Version string = "0819" const Bak_Version string = "0819"
var Active bool = true var Active bool = true
...@@ -65,7 +65,7 @@ const App_adct string = SMB_ADSoftApplication + "adct.exe" ...@@ -65,7 +65,7 @@ const App_adct string = SMB_ADSoftApplication + "adct.exe"
const App_MultiSplit string = SMB_ADSoftOthTool + "win_MultiSplit.exe" const App_MultiSplit string = SMB_ADSoftOthTool + "win_MultiSplit.exe"
const App_SyncExe string = App_Sync + `.exe` const App_SyncExe string = App_Sync + `.exe`
const App_Sync string = `syncappw` const App_Sync string = `syncappw`
const App_Sync_full string = `C:\Progra~1\zhiwei\AllWay_Sync\Bin\` + App_Sync const App_Sync_full string = `C:\Progra~1\zhiwei\AllWay_Sync\Bin\` + App_SyncExe
// reg info // // reg info //
......
...@@ -12,55 +12,59 @@ import( ...@@ -12,55 +12,59 @@ import(
func DealMsgEnter(w http.ResponseWriter, r *http.Request) { func DealMsgEnter(w http.ResponseWriter, r *http.Request) {
var msgtype string = r.URL.Path[1:] msgtype := r.URL.Path[1:]
url :=r.URL.RawQuery
unmsg,err := ioutil.ReadAll(r.Body) unmsg,err := ioutil.ReadAll(r.Body)
if err!=nil{ if err!=nil{
PntError(err) PntError(err)
w.Write([]byte("")) w.Write([]byte(""))
} }
var ret []byte ret := DealMsg(msgtype,url,unmsg)
switch msgtype{
// 报告 消息
case Msg_Report:
var pmsg MJreport
PntReport(string(unmsg))
ParseJson(unmsg,&pmsg)
ice := pmsg.MsgDeal()
ret = ReParseJson(&ice)
// 执行 消息
case Msg_Exec:
var pmsg MJexec
PntExec(string(unmsg))
ParseJson(unmsg,&pmsg)
ice := pmsg.MsgDeal()
ret = ReParseJson(&ice)
// 备份 消息
case Msg_Backup:
var pmsg MJbackup
PntBackup(string(unmsg))
ParseJson(unmsg,&pmsg)
ice := pmsg.MsgDeal()
ret = ReParseJson(&ice)
// 错误 消息
case Msg_Error:
PntError(string(unmsg))
var pmsg MJerror
ParseJson(unmsg,&pmsg)
ice := pmsg.MsgDeal()
ret = ReParseJson(&ice)
default:
pmsg := ParseWX(r.URL.RawQuery,&unmsg)
go pmsg.MsgDealSend()
}
w.Write(ret) w.Write(ret)
} }
func DealMsg(msgtype, url string, unmsg []byte) []byte {
var ret []byte
switch msgtype{
// 报告 消息
case Msg_Report:
var pmsg MJreport
PntReport(string(unmsg))
ParseJson(unmsg,&pmsg)
ice := pmsg.MsgDeal()
ret = ReParseJson(&ice)
// 执行 消息
case Msg_Exec:
var pmsg MJexec
PntExec(string(unmsg))
ParseJson(unmsg,&pmsg)
ice := pmsg.MsgDeal()
ret = ReParseJson(&ice)
// 备份 消息
case Msg_Backup:
var pmsg MJbackup
PntBackup(string(unmsg))
ParseJson(unmsg,&pmsg)
ice := pmsg.MsgDeal()
ret = ReParseJson(&ice)
// 错误 消息
case Msg_Error:
PntError(string(unmsg))
var pmsg MJerror
ParseJson(unmsg,&pmsg)
ice := pmsg.MsgDeal()
ret = ReParseJson(&ice)
default:
pmsg := ParseWX(url,&unmsg)
go pmsg.MsgDealSend()
}
return ret
}
// //
...@@ -74,7 +78,9 @@ func (rep *MJreport)MsgDeal() interface{} { ...@@ -74,7 +78,9 @@ func (rep *MJreport)MsgDeal() interface{} {
switch rep.Instruction{ switch rep.Instruction{
case Msg_Report_InitBak: case Msg_Report_InitBak:
PrintLog(rep.Computername,"初始化备份")
if !IsPrimaryUser(rep.Username) || RunAsPC(rep.Username){ if !IsPrimaryUser(rep.Username) || RunAsPC(rep.Username){
return nil return nil
} }
......
...@@ -14,7 +14,7 @@ func NewLoger(s string) * log.Logger{ ...@@ -14,7 +14,7 @@ func NewLoger(s string) * log.Logger{
s,os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766); s,os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766);
err !=nil && DomainComputer(){ err !=nil && DomainComputer(){
SendServerError(fmt.Errorf("%s %v-%v",s,Error_Fail_File_Open,err)) PrintLog(fmt.Errorf("%s %v-%v",s,Error_Fail_File_Open,err))
} }
return log.New(Log_file_obj,"",log.LstdFlags) return log.New(Log_file_obj,"",log.LstdFlags)
} }
......
...@@ -9,26 +9,26 @@ import ( ...@@ -9,26 +9,26 @@ import (
) )
func SendServerReport(s string)([]byte,error){ func SendServerReport(s string) {
return SendMsg(Msg_Report,GJreport(s)) SendMsg(Msg_Report,GJreport(s))
} }
func SendServerExec(s string)([]byte,error){ func SendServerExec(s string) {
return SendMsg(Msg_Exec,GJexec(s)) SendMsg(Msg_Exec,GJexec(s))
} }
func SendServerExecJ(v interface{})([]byte,error){ func SendServerExecJ(v interface{}) {
return SendMsg(Msg_Exec,v) SendMsg(Msg_Exec,v)
} }
func SendServerError(err error)([]byte,error){ func SendServerError(err error) {
return SendMsg(Msg_Error,GJerror(err)) SendMsg(Msg_Error,GJerror(err))
} }
// base // base
func SendMsg(msgtype string ,v interface{}) ([]byte,error){ func SendMsg(msgtype string ,v interface{}) {
//将结构体 转化成 byte
textbyte,err := json.Marshal(v) textbyte,err := json.Marshal(v)
if err !=nil { if err !=nil {
PntError("Json to String Error ",v,err) PntError("Json to String Error ",v,err)
return nil,err
} }
link := fmt.Sprintf("http://%s/%s",ADServerDaemon,msgtype) link := fmt.Sprintf("http://%s/%s",ADServerDaemon,msgtype)
PntSend(link,string(textbyte)) PntSend(link,string(textbyte))
...@@ -38,14 +38,20 @@ func SendMsg(msgtype string ,v interface{}) ([]byte,error){ ...@@ -38,14 +38,20 @@ func SendMsg(msgtype string ,v interface{}) ([]byte,error){
link, link,
"application/json; charset=utf-8", "application/json; charset=utf-8",
bytes.NewReader(textbyte)) bytes.NewReader(textbyte))
if err != nil { if err != nil {
return nil,err PntError(err)
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
return body,nil // 读取数据
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
PntError(err)
}
// 处理数据
DealMsg(GetMsgType(body),"",body)
} }
// 发送Get请求 // 发送Get请求
......
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