diff --git a/.DS_Store b/.DS_Store index 48af73f..4ed94e3 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.goreleaser.yml b/.goreleaser.yml index 47dc55e..6f8696c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -20,9 +20,6 @@ archives: windows: Windows 386: i386 amd64: x86_64 - files: - - install-binary.sh - - install-binary.bat checksum: name_template: 'checksums.txt' snapshot: diff --git a/client/clientIPTable/Iptable.go b/client/clientIPTable/Iptable.go index db885dc..d6da7e0 100644 --- a/client/clientIPTable/Iptable.go +++ b/client/clientIPTable/Iptable.go @@ -150,6 +150,15 @@ func UpdateIpTableListClient() error { return nil } +func RemoveOfflineNodes() error { + // Ensure that the IP Table has Node pingable + err := p2p.LocalSpeedTestIpTable() + if err != nil { + return err + } + return nil +} + // SendPostRequest Sends a file as a //POST request. // Reference (https://stackoverflow.com/questions/51234464/upload-a-file-with-post-request-golang) diff --git a/server/server.go b/server/server.go index 950af2b..f665cde 100644 --- a/server/server.go +++ b/server/server.go @@ -170,6 +170,9 @@ func Server() (*gin.Engine, error) { // if not update current entry as proxy address // with appropriate port on IP Table if config.BehindNAT == "True" { + // Remove nodes currently not pingable + clientIPTable.RemoveOfflineNodes() + table, err := p2p.ReadIpTable() if err != nil { return nil, err @@ -182,7 +185,7 @@ func Server() (*gin.Engine, error) { for i, _ := range table.IpAddress { // Checks if the ping is the lowest and if the following node is acting as a proxy //if table.IpAddress[i].Latency.Milliseconds() < lowestLatency && table.IpAddress[i].ProxyPort != "" { - if table.IpAddress[i].Latency.Milliseconds() < lowestLatency { + if table.IpAddress[i].Latency.Milliseconds() < lowestLatency && table.IpAddress[i].NAT != "" { lowestLatency = table.IpAddress[i].Latency.Milliseconds() lowestLatencyIpAddress = table.IpAddress[i] } @@ -212,9 +215,19 @@ func Server() (*gin.Engine, error) { // append the following to the ip table table.IpAddress = append(table.IpAddress, ProxyIpAddr) // write information back to the IP Table - table.WriteIpTable() + err = table.WriteIpTable() + if err != nil { + return nil, err + } // update ip table - go clientIPTable.UpdateIpTableListClient() + go func() error { + err := clientIPTable.UpdateIpTableListClient() + if err != nil { + fmt.Println(err) + return err + } + return nil + }() } }