站点RPC方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
984 B

  1. package siterpc
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. "time"
  6. "git.tetele.net/tgo/crypter"
  7. "github.com/golang/protobuf/proto"
  8. )
  9. /**
  10. * 由配置key取对应value
  11. * 请求及回均加密验签
  12. * 2021/01/20
  13. * GZ
  14. */
  15. func GetAllSite(url ...string) ([]map[string]string, error) {
  16. conn, err := rpc_server_conn(url...)
  17. if err != nil {
  18. return nil, err
  19. }
  20. defer conn.Close()
  21. now_int64 := time.Now().Unix()
  22. encryData := crypter.DesEn("get_from_cache", DES_KEY)
  23. now := strconv.FormatInt(now_int64, 10)
  24. sign := Sign(encryData, now)
  25. req := &Request{proto.String(encryData), proto.String(now), proto.String(sign), nil}
  26. res := &Response{}
  27. err = conn.GetAllSite(req, res)
  28. if err != nil {
  29. return nil, err
  30. }
  31. res_data, err := GetOrgData(res)
  32. if err != nil {
  33. return []map[string]string{}, err
  34. }
  35. var res_arr []map[string]string
  36. err = json.Unmarshal([]byte(res_data), &res_arr)
  37. if err != nil {
  38. return []map[string]string{}, err
  39. }
  40. return res_arr, nil
  41. }