added map port response as JSON output
This commit is contained in:
@@ -6,10 +6,14 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func MAPPort(port string, domainName string) (string, error) {
|
||||
type ResponseMAPPort struct {
|
||||
IPAddress string
|
||||
}
|
||||
|
||||
func MAPPort(port string, domainName string) (*ResponseMAPPort, error) {
|
||||
Config, err := config.ConfigInit(nil, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//if version == "version 6" {
|
||||
@@ -19,14 +23,17 @@ func MAPPort(port string, domainName string) (string, error) {
|
||||
//}
|
||||
resp, err := http.Get(URL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Convert response to byte value
|
||||
byteValue, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return string(byteValue), nil
|
||||
var response ResponseMAPPort
|
||||
response.IPAddress = string(byteValue)
|
||||
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user