|
|
|
@ -3,6 +3,7 @@ package core |
|
|
|
import ( |
|
|
|
"aufs/config" |
|
|
|
"aufs/util" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"net" |
|
|
|
"net/http" |
|
|
|
@ -19,6 +20,13 @@ type ZipBlock struct { |
|
|
|
SelFile []string // 选中的文件
|
|
|
|
} |
|
|
|
|
|
|
|
// 返回的结果结构
|
|
|
|
type FsResp struct { |
|
|
|
Status int `json:"status"` |
|
|
|
Message string `json:"message"` |
|
|
|
Data map[string]interface{} `json:"data"` |
|
|
|
} |
|
|
|
|
|
|
|
// 远程调用压缩包
|
|
|
|
func SendZip(w http.ResponseWriter, r *http.Request) { |
|
|
|
r.ParseForm() |
|
|
|
@ -40,16 +48,15 @@ func SendZip(w http.ResponseWriter, r *http.Request) { |
|
|
|
SelFile: zipfarr, |
|
|
|
} |
|
|
|
// 从serip 切割出ip 和端口
|
|
|
|
// splitip := strings.Split(serip[0], ":")
|
|
|
|
// if len(splitip) != 2 {
|
|
|
|
// http.Error(w, "remote server ip is error!", http.StatusInternalServerError)
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
// srcip := splitip[0]
|
|
|
|
// sport := splitip[1]
|
|
|
|
splitip := strings.Split(serip[0], ":") |
|
|
|
if len(splitip) != 2 { |
|
|
|
http.Error(w, "remote server ip is error!", http.StatusInternalServerError) |
|
|
|
return |
|
|
|
} |
|
|
|
srcip := splitip[0] |
|
|
|
sport := splitip[1] |
|
|
|
//
|
|
|
|
// service := fmt.Sprintf("%v:%v", srcip, sport)
|
|
|
|
service := serip[0] |
|
|
|
service := fmt.Sprintf("%v:%v", srcip, sport) |
|
|
|
client, err := jsonrpc.Dial("tcp", service) |
|
|
|
if err != nil { |
|
|
|
fmt.Fprintf(w, "jsonrpc dial faild %v", err) |
|
|
|
@ -67,7 +74,15 @@ func SendZip(w http.ResponseWriter, r *http.Request) { |
|
|
|
} |
|
|
|
// 输出内容
|
|
|
|
w.Header().Set("Content-Type", "application/json") |
|
|
|
w.Write([]byte(reply)) |
|
|
|
// w.Write([]byte(reply))
|
|
|
|
|
|
|
|
// 封装json
|
|
|
|
resp := FsResp{ |
|
|
|
Status: 200, |
|
|
|
Message: "success", |
|
|
|
Data: map[string]interface{}{"reply": reply}, |
|
|
|
} |
|
|
|
json.NewEncoder(w).Encode(resp) |
|
|
|
} |
|
|
|
|
|
|
|
// 将文件打包成压缩包
|
|
|
|
|