Ejemplo n.º 1
0
func main() {
	if debug.DEBUG {
		fmt.Printf("Loading config from speedtest.net\n")
	}
	sthttp.CONFIG = sthttp.GetConfig()

	if debug.DEBUG {
		fmt.Printf("Getting servers list...")
	}
	allServers := sthttp.GetServers()
	if debug.DEBUG {
		fmt.Printf("(%d) found\n", len(allServers))
	}

	closestServers := sthttp.GetClosestServers(NUMCLOSEST, allServers)

	fmt.Printf("Finding fastest server...")
	fastestServer := sthttp.GetFastestServer(NUMLATENCYTESTS, closestServers)
	fmt.Printf("%s (%s - %s)\n", fastestServer.Sponsor, fastestServer.Name, fastestServer.Country)

	dmbps := downloadTest(fastestServer)
	umbps := uploadTest(fastestServer)

	fmt.Printf("Ping: %s | Download: %3.2f Mbps | Upload: %3.2f Mbps\n", fastestServer.AvgLatency, dmbps, umbps)
}
Ejemplo n.º 2
0
func main() {
	if debug.DEBUG {
		fmt.Printf("Loading config from speedtest.net\n")
	}
	sthttp.CONFIG = sthttp.GetConfig()

	if debug.DEBUG {
		fmt.Printf("Getting servers list...")
	}
	allServers := sthttp.GetServers()
	if debug.DEBUG {
		fmt.Printf("(%d) found\n", len(allServers))
	}

	if TESTSERVERID != "" {
		// they specified a server so find it in the list
		TESTSERVER = findServer(TESTSERVERID, allServers)
		fmt.Printf("(ID: %s) - %s (%s - %s) - %s\n", TESTSERVER.Id, TESTSERVER.Sponsor, TESTSERVER.Name, TESTSERVER.Country, TESTSERVER.Url)
		//FIXME: this is ugly, eventually we watn to get a true avg latency using NUMLATENCYTESTS
		fmt.Printf("Testing latency...\n")
		TESTSERVER.AvgLatency = sthttp.GetLatency(TESTSERVER)
	} else {
		// find a fast server for them
		closestServers := sthttp.GetClosestServers(NUMCLOSEST, allServers)
		fmt.Printf("Finding fastest server...")
		TESTSERVER = sthttp.GetFastestServer(NUMLATENCYTESTS, closestServers)
		fmt.Printf("(ID: %s) - %s (%s - %s) - %s\n", TESTSERVER.Id, TESTSERVER.Sponsor, TESTSERVER.Name, TESTSERVER.Country, TESTSERVER.Url)
	}

	dmbps := downloadTest(TESTSERVER)
	umbps := uploadTest(TESTSERVER)

	fmt.Printf("Ping: %s | Download: %3.2f Mbps | Upload: %3.2f Mbps\n", TESTSERVER.AvgLatency, dmbps, umbps)
}
Ejemplo n.º 3
0
func init() {
	rand.Seed(time.Now().UTC().UnixNano())

	flag.BoolVar(&debug.DEBUG, "d", false, "Turn on debugging")
	verFlag := flag.Bool("v", false, "Display version")
	listFlag := flag.Bool("l", false, "List servers")
	flag.StringVar(&TESTSERVERID, "s", "", "Specify a server (use -l to get a server list, then specify it's id)")

	flag.Parse()

	if *verFlag == true {
		fmt.Printf("%s - Version: %s\n", os.Args[0], VERSION)
		os.Exit(0)
	}

	if debug.DEBUG {
		log.Printf("Debugging on...\n")
	}

	if *listFlag == true {
		if debug.DEBUG {
			fmt.Printf("Loading config from speedtest.net\n")
		}
		sthttp.CONFIG = sthttp.GetConfig()

		if debug.DEBUG {
			fmt.Printf("Getting servers list...")
		}
		allServers := sthttp.GetServers()
		if debug.DEBUG {
			fmt.Printf("(%d) found\n", len(allServers))
		}
		for s := range allServers {
			server := allServers[s]
			fmt.Printf("(ID: %s) - %s (%s - %s) - %s\n", server.Id, server.Sponsor, server.Name, server.Country, server.Url)
		}
		os.Exit(0)
	}
}
Ejemplo n.º 4
0
func init() {
	flag.BoolVar(&debug.DEBUG, "d", false, "Turn on debugging")
	verFlag := flag.Bool("v", false, "Display version")
	listFlag := flag.Bool("l", false, "List servers")
	flag.Parse()
	if *verFlag == true {
		fmt.Printf("%s - Version: %s\n", os.Args[0], VERSION)
		os.Exit(0)
	}
	rand.Seed(time.Now().UTC().UnixNano())
	if debug.DEBUG {
		log.Printf("Debugging on...\n")
	}
	if *listFlag == true {
		if debug.DEBUG {
			fmt.Printf("Loading config from speedtest.net\n")
		}
		sthttp.CONFIG = sthttp.GetConfig()

		if debug.DEBUG {
			fmt.Printf("Getting servers list...")
		}
		allServers := sthttp.GetServers()
		if debug.DEBUG {
			fmt.Printf("(%d) found\n", len(allServers))
		}
		for s := range allServers {
			server := allServers[s]
			u := server.Url
			splits := strings.Split(u, "/")
			baseUrl := strings.Join(splits[1:len(splits)-1], "/")
			fullUrl := "http:/" + baseUrl
			fmt.Printf("%s (%s - %s) - %s\n", server.Sponsor, server.Name, server.Country, fullUrl)
		}
		os.Exit(0)
	}
}