Commit ea6bda72 by 陶腾飞

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

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