added possibility to add ipv4 and ipv6 address

This commit is contained in:
2021-07-06 15:34:18 +04:00
parent a0b63fa2ec
commit f7bae1100a
2 changed files with 17 additions and 2 deletions

View File

@@ -41,8 +41,15 @@ var CliAction = func(ctx *cli.Context) error {
//Create variable of type IpAddress and set IP address //Create variable of type IpAddress and set IP address
// to it // to it
var IpAddr p2p.IpAddress var IpAddr p2p.IpAddress
IpAddr.Ipv4 = AddServer
//Checking if the address is a ipv4
// or ipv6 address
ip4Orip6 := p2p.Ip4or6(AddServer)
if ip4Orip6 == "version 6" {
IpAddr.Ipv6 = AddServer
} else {
IpAddr.Ipv4 = AddServer
}
// Append IP address to variable result which // Append IP address to variable result which
// is a list // is a list
res.IpAddress = append(res.IpAddress, IpAddr) res.IpAddress = append(res.IpAddress, IpAddr)

View File

@@ -1,3 +1,11 @@
{ {
"ip_address": null "ip_address": [
{
"ipv4": "",
"ipv6": "2001:8f8:172d:ee93:8105:563b:dc98:6dbf",
"latency": 567539,
"download": 0,
"upload": 0
}
]
} }