Merge pull request #44 from Akilan1999/gitignore-iptable
gitignore iptable
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -7,4 +7,7 @@ server/docker/__pycache__
|
||||
p2p-rendering-computation
|
||||
p2prc
|
||||
config.json
|
||||
.vscode/
|
||||
.vscode/
|
||||
|
||||
#ignore generated iptables
|
||||
p2p/iptable/
|
||||
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -39,6 +40,30 @@ func fileExists(name string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Copy the src file to dst. Any existing file will be overwritten and will not
|
||||
// copy file attributes.
|
||||
// Source: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file
|
||||
func Copy(src, dst string) error {
|
||||
in, err := os.Open(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer in.Close()
|
||||
|
||||
out, err := os.Create(dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
_, err = io.Copy(out, in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return out.Close()
|
||||
}
|
||||
|
||||
|
||||
// SetDefaults This function to be called only during a
|
||||
// make install
|
||||
func SetDefaults() error {
|
||||
@@ -48,8 +73,15 @@ func SetDefaults() error {
|
||||
//Setting current directory to default path
|
||||
defaultPath = curDir + "/"
|
||||
|
||||
//Create ip_table.json in the json directory
|
||||
err := Copy("p2p/ip_table.json","p2p/iptable/ip_table.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
//Setting default paths for the config file
|
||||
defaults["IPTable"] = defaultPath + "p2p/ip_table.json"
|
||||
defaults["IPTable"] = defaultPath + "p2p/iptable/ip_table.json"
|
||||
defaults["DefaultDockerFile"] = defaultPath + "server/docker/containers/docker-ubuntu-sshd/"
|
||||
defaults["DockerContainers"] = defaultPath + "server/docker/containers/"
|
||||
defaults["SpeedTestFile"] = defaultPath + "p2p/50.bin"
|
||||
@@ -68,7 +100,7 @@ func SetDefaults() error {
|
||||
}
|
||||
|
||||
//Calling configuration file
|
||||
_, err := ConfigInit()
|
||||
_, err = ConfigInit()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
{
|
||||
"ip_address": [
|
||||
{
|
||||
"ipv4": "",
|
||||
"ipv6": "2001:8f8:172d:7e27:f1ba:1531:413f:1177",
|
||||
"latency": 500894,
|
||||
"download": 0,
|
||||
"upload": 0
|
||||
},
|
||||
{
|
||||
"ipv4": "172.104.44.195",
|
||||
"ipv6": "",
|
||||
"latency": 140786917,
|
||||
"latency": 0,
|
||||
"download": 0,
|
||||
"upload": 0
|
||||
}
|
||||
|
||||
0
p2p/iptable/.gitkeep
Normal file
0
p2p/iptable/.gitkeep
Normal file
@@ -1,21 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/showwin/speedtest-go/speedtest"
|
||||
)
|
||||
|
||||
func main() {
|
||||
user, _ := speedtest.FetchUserInfo()
|
||||
|
||||
serverList, _ := speedtest.FetchServerList(user)
|
||||
targets, _ := serverList.FindServer([]int{})
|
||||
|
||||
for _, s := range targets {
|
||||
s.PingTest()
|
||||
s.DownloadTest(false)
|
||||
s.UploadTest(false)
|
||||
|
||||
fmt.Printf("Latency: %s, Download: %f, Upload: %f\n", s.Latency, s.DLSpeed, s.ULSpeed)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user