Browse Source

修改获取站点信息接口

master v0.6.1
guzeng 3 years ago
parent
commit
462630527b
1 changed files with 74 additions and 0 deletions
  1. +74
    -0
      client.siteinfo.go

+ 74
- 0
client.siteinfo.go View File

@ -0,0 +1,74 @@
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
}
*/

Loading…
Cancel
Save