Skip to content

Commit

Permalink
Merge pull request #302 from YangSen-qn/dev
Browse files Browse the repository at this point in the history
solve the ip cmd error
  • Loading branch information
Mei-Zhao authored Mar 24, 2021
2 parents 93e428b + 268d113 commit bf7a6a0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,21 @@ func init() {
// 【ip】查询ip的相关信息
func IpQuery(cmd *cobra.Command, params []string) {
for _, ip := range params {
url := fmt.Sprintf("%s?ip=%s", TAOBAO_IP_QUERY, ip)

var ipInfo IpInfo
func() {
gResp, gErr := http.Get(url)
req, err := http.NewRequest("GET", TAOBAO_IP_QUERY, nil)
if err != nil {
logs.Error(err)
return
}

q := req.URL.Query()
q.Add("accessKey", "alibaba-inc")
q.Add("ip", ip)
req.URL.RawQuery = q.Encode()

gResp, gErr := http.DefaultClient.Do(req)
if gErr != nil {
logs.Error("Query ip info failed for %s, %s", ip, gErr)
return
Expand Down

0 comments on commit bf7a6a0

Please sign in to comment.