package siterpc
|
|
|
|
// import (
|
|
// "encoding/json"
|
|
// "errors"
|
|
// "strconv"
|
|
// "time"
|
|
|
|
// "git.tetele.net/tgo/crypter"
|
|
|
|
// "github.com/golang/protobuf/proto"
|
|
// )
|
|
|
|
type SiteInfoReq struct {
|
|
Master string
|
|
Host string
|
|
}
|
|
|
|
type SiteInfoRes struct {
|
|
SiteId string
|
|
Dbname string
|
|
Domainname string
|
|
}
|
|
|
|
/**
|
|
* 由host取对应站点关键信息
|
|
* 请求及回均加密验签
|
|
* 2021/06/24
|
|
* GZ
|
|
|
|
func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) {
|
|
|
|
conn, err := rpc_server_conn(url...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer conn.Close()
|
|
|
|
arg := SiteInfoReq{host}
|
|
|
|
data_json, err := json.Marshal(arg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
now_int64 := time.Now().Unix()
|
|
|
|
encryData := crypter.DesEn(string(data_json), DES_KEY)
|
|
|
|
now := strconv.FormatInt(now_int64, 10)
|
|
|
|
sign := Sign(encryData, now)
|
|
|
|
req := &Request{proto.String(encryData), proto.String(now), proto.String(sign), nil}
|
|
|
|
res := &Response{}
|
|
|
|
err = conn.GetSiteInfoByHost(req, res)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
res_data := GetOrgData(res)
|
|
|
|
var res_arr SiteInfoRes
|
|
|
|
err = json.Unmarshal([]byte(res_data), &res_arr)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res_arr, nil
|
|
}
|
|
*/
|