patching fixes for server list
This commit is contained in:
@@ -47,14 +47,17 @@ func UpdateIpTable(IpAddress string) error {
|
||||
|
||||
// Updates IP table based on information provided
|
||||
// by the server
|
||||
err = ipStruct.SpeedTestUpdatedIPTable()
|
||||
if err != nil {
|
||||
return err
|
||||
if len(ipStruct.IpAddress) > 0 {
|
||||
err = ipStruct.SpeedTestUpdatedIPTable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// UpdateIpTableListClient updates IP tables (Default 3 hops) based on server information available
|
||||
//on the ip tables
|
||||
func UpdateIpTableListClient() error {
|
||||
|
||||
BIN
p2p/50.bin
BIN
p2p/50.bin
Binary file not shown.
@@ -2,15 +2,9 @@
|
||||
"ip_address": [
|
||||
{
|
||||
"ipv4": "145.40.90.151",
|
||||
"latency": 144024138,
|
||||
"download": 6.124989686501195,
|
||||
"upload": 3863.649528583081
|
||||
},
|
||||
{
|
||||
"ipv4": "86.99.70.106",
|
||||
"latency": 7972645,
|
||||
"download": 87.32677875720803,
|
||||
"upload": 6006.624976985241
|
||||
"latency": 139109233,
|
||||
"download": 6.383175565123993,
|
||||
"upload": 896786.5894533413
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,17 +2,38 @@ package p2p
|
||||
|
||||
// SpeedTest Runs a speed test and does updates IP tables accordingly
|
||||
func (ip *IpAddresses)SpeedTest() error{
|
||||
// Remove Duplicate IP addresses
|
||||
var DoNotRead IpAddresses
|
||||
|
||||
for i, _ := range ip.IpAddress {
|
||||
|
||||
Exists := false
|
||||
for k := range DoNotRead.IpAddress {
|
||||
if DoNotRead.IpAddress[k].Ipv4 == ip.IpAddress[i].Ipv4 {
|
||||
Exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if Exists {
|
||||
continue
|
||||
}
|
||||
|
||||
var err error
|
||||
if len(ip.IpAddress) == 1 {
|
||||
i = 0
|
||||
}
|
||||
|
||||
// Ping Test
|
||||
err := ip.IpAddress[i].PingTest()
|
||||
err = ip.IpAddress[i].PingTest()
|
||||
|
||||
if err != nil {
|
||||
// Remove IP address of element not pingable
|
||||
ip.IpAddress = remove(ip.IpAddress,i)
|
||||
ip.IpAddress = remove(ip.IpAddress,i)
|
||||
// Proceed to next element in the array
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
//Upload Speed Test
|
||||
err = ip.IpAddress[i].UploadSpeed()
|
||||
if err != nil {
|
||||
@@ -23,6 +44,8 @@ func (ip *IpAddresses)SpeedTest() error{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
DoNotRead.IpAddress = append(DoNotRead.IpAddress, ip.IpAddress[i])
|
||||
}
|
||||
|
||||
err := ip.WriteIpTable()
|
||||
|
||||
Reference in New Issue
Block a user