diff --git a/client.siteinfo.go b/client.siteinfo.go index 98148fe..71f97d8 100644 --- a/client.siteinfo.go +++ b/client.siteinfo.go @@ -1,15 +1,15 @@ package siterpc -// import ( -// "encoding/json" -// "errors" -// "strconv" -// "time" +import ( + "encoding/json" + "log" + "strconv" + "time" -// "git.tetele.net/tgo/crypter" + "git.tetele.net/tgo/crypter" -// "github.com/golang/protobuf/proto" -// ) + "github.com/golang/protobuf/proto" +) type SiteInfoReq struct { Master string @@ -17,9 +17,9 @@ type SiteInfoReq struct { } type SiteInfoRes struct { - SiteId string - Dbname string - Domainname string + SiteId string `json:"site_id"` + Dbname string `json:"database"` + Domainname string `json:"domainname"` } /** @@ -27,8 +27,8 @@ type SiteInfoRes struct { * 请求及回均加密验签 * 2021/06/24 * GZ - -func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) { + */ +func GetSiteInfoByHost(master, host string, url ...string) (*SiteInfoRes, error) { conn, err := rpc_server_conn(url...) if err != nil { @@ -36,7 +36,7 @@ func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) { } defer conn.Close() - arg := SiteInfoReq{host} + arg := SiteInfoReq{master, host} data_json, err := json.Marshal(arg) if err != nil { @@ -60,8 +60,13 @@ func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) { return nil, err } - res_data := GetOrgData(res) + res_data, err := GetOrgData(res) + + log.Println(res_data, err) + if err != nil { + return nil, err + } var res_arr SiteInfoRes err = json.Unmarshal([]byte(res_data), &res_arr) @@ -71,4 +76,3 @@ func GetSiteInfoByHost(host string, url ...string) (*SiteInfoRes, error) { } return &res_arr, nil } -*/ diff --git a/client.siteinfo_test.go b/client.siteinfo_test.go new file mode 100644 index 0000000..9bc7d26 --- /dev/null +++ b/client.siteinfo_test.go @@ -0,0 +1,13 @@ +package siterpc + +import ( + "testing" +) + +func Test_GetSiteInfoByHost(t *testing.T) { + + res, err := GetSiteInfoByHost("http://devmaster.tetele.net", "dev.tetele.net") + t.Log(res) + t.Log(err) + +}