diff --git a/client/Iptable.go b/client/Iptable.go index 531c56b..25498d0 100644 --- a/client/Iptable.go +++ b/client/Iptable.go @@ -36,7 +36,7 @@ func UpdateIpTable(IpAddress string) error { return nil } -//updates IP tables (Default 3 hops) based on server information available +// UpdateIpTableListClient updates IP tables (Default 3 hops) based on server information available //on the ip tables func UpdateIpTableListClient() error { // Ensure that the IP Table has Node pingable @@ -89,7 +89,7 @@ func UpdateIpTableListClient() error { return nil } -// Sends a file as a POST request. +// SendPostRequest Sends a file as a POST request. // Reference (https://stackoverflow.com/questions/51234464/upload-a-file-with-post-request-golang) func SendPostRequest (url string, filename string, filetype string) ([]byte,error) { file, err := os.Open(filename) diff --git a/p2p/50.bin b/p2p/50.bin index 151a7c2..5d4587b 100644 Binary files a/p2p/50.bin and b/p2p/50.bin differ diff --git a/p2p/ip_table.json b/p2p/ip_table.json index 570b065..3cdd859 100644 --- a/p2p/ip_table.json +++ b/p2p/ip_table.json @@ -1,10 +1,7 @@ { "ip_address": [ { - "ipv4": "localhost", - "latency": 14981051, - "download": 8142.122540206258, - "upload": 3578.766512629995 + "ipv4": "145.40.90.151" } ] } \ No newline at end of file diff --git a/p2p/iptable.go b/p2p/iptable.go index 4bd3725..5f7f5bc 100644 --- a/p2p/iptable.go +++ b/p2p/iptable.go @@ -22,15 +22,14 @@ type IpAddress struct { Upload float64 `json:"upload"` } -// Read data from Ip tables from json file +// ReadIpTable Read data from Ip tables from json file func ReadIpTable()(*IpAddresses ,error){ // Get Path from config config, err := config.ConfigInit() if err != nil { return nil,err } - - jsonFile, err := os.Open(config.SpeedTestFile) + jsonFile, err := os.Open(config.IPTable) // if we os.Open returns an error then handle it if err != nil { return nil,err @@ -53,7 +52,7 @@ func ReadIpTable()(*IpAddresses ,error){ return &ipAddresses, nil } -// Write to IP table json file +// WriteIpTable Write to IP table json file func (i *IpAddresses) WriteIpTable() error { file, err := json.MarshalIndent(i, "", " ") if err != nil { @@ -74,7 +73,7 @@ func (i *IpAddresses) WriteIpTable() error { return nil } -// Print Ip table data for Cli +// PrintIpTable Print Ip table data for Cli func PrintIpTable() error { table, err := ReadIpTable() diff --git a/p2p/speedtest.go b/p2p/speedtest.go index 5e724d1..a5e2674 100644 --- a/p2p/speedtest.go +++ b/p2p/speedtest.go @@ -1,6 +1,6 @@ package p2p -// Runs a speed test and does updates IP tables accordingly +// SpeedTest Runs a speed test and does updates IP tables accordingly func (ip *IpAddresses)SpeedTest() error{ for i, _ := range ip.IpAddress { @@ -33,7 +33,7 @@ func (ip *IpAddresses)SpeedTest() error{ return nil } -// Called when ip tables from client/server is also passed on +// SpeedTestUpdatedIPTable Called when ip tables from client/server is also passed on func (ip *IpAddresses)SpeedTestUpdatedIPTable() error{ targets, err := ReadIpTable() if err != nil { @@ -71,7 +71,7 @@ func (ip *IpAddresses)SpeedTestUpdatedIPTable() error{ return nil } -// Runs speed test in iptables locally only +// LocalSpeedTestIpTable Runs speed test in iptables locally only func LocalSpeedTestIpTable() error { targets, err := ReadIpTable() if err != nil {