项目作者: librespeed

项目描述 :
Command line client for LibreSpeed
高级语言: Go
项目地址: git://github.com/librespeed/speedtest-cli.git
创建时间: 2020-03-05T09:03:45Z
项目社区:https://github.com/librespeed/speedtest-cli

开源协议:GNU Lesser General Public License v3.0

下载


LibreSpeed Logo

LibreSpeed command line tool

Don’t have a GUI but want to use LibreSpeed servers to test your Internet speed? 🚀

librespeed-cli comes to rescue!

This is a command line interface for LibreSpeed speed test backends, written in Go.

Features

  • Ping
  • Jitter
  • Download
  • Upload
  • IP address
  • ISP Information
  • Result sharing (telemetry) [optional]
  • Test with multiple servers in a single run
  • Use your own server list or telemetry endpoints
  • Tested with PHP and Go backends

asciicast

Requirements for compiling

  • Go 1.14+

Runtime requirements

Use prebuilt binaries

If you don’t want to build librespeed-cli yourself, you can find different binaries compiled for various platforms in
the releases page.

Building librespeed-cli

  1. First, you’ll have to install Go (at least version 1.11). For Windows users, you can download an installer from golang.org.
    For Linux users, you can use either the archive from golang.org, or install from your distribution’s package manager.

    For example, Arch Linux:

    ```shell script

    pacman -S go

    ```

  2. Then, clone the repository:

    shell script $ git clone -b v1.0.0 https://github.com/librespeed/speedtest-cli

  3. After you have Go installed on your system (and added to your $PATH if you’re using the archive from golang.org), you
    can now proceed to build librespeed-cli with the build script:

    ```shell script
    $ cd speedtest-cli
    $ ./build.sh

    1. If you want to build for another operating system or system architecture, use the `GOOS` and `GOARCH` environment
    2. variables. Run `go tool dist list` to get a list of possible combinations of `GOOS` and `GOARCH`.
    3. Note: Technically, the CLI can be compiled with older Go versions that support Go modules, with `GO111MODULE=on`
    4. set. If you're compiling with an older Go runtime, you might have to change the Go version in `go.mod`.
    5. ```shell script
    6. # Let's say we're building for 64-bit Windows on Linux
    7. $ GOOS=windows GOARCH=amd64 ./build.sh
  4. When the build script finishes, if everything went smoothly, you can find the built binary under directory out.

    shell script $ ls out librespeed-cli-windows-amd64.exe

  5. Now you can use the librespeed-cli and test your Internet speed!

Install from AUR

To install librespeed-cli from AUR, use your favorite AUR helper and install package librespeed-cli-bin

```shell script
$ yay librespeed-cli-bin

  1. ... or, clone it and build it yourself:
  2. ```shell script
  3. $ git clone https://aur.archlinux.org/librespeed-cli-bin.git
  4. $ cd librespeed-cli-bin
  5. $ makepkg -si

Install from Homebrew

See the librespeed-cli Homebrew tap.

Install on Windows

If you have either Scoop or Chocolatey installed you can use one of the following commands:

  • Scoop (ensure you have the extras bucket added):

    1. > scoop install librespeed-cli
  • Chocolatey:

    1. > choco install librespeed-cli

Container Image

You can run librespeed-cli in a container.

  1. Build the container image:

    shell script docker build -t librespeed-cli:latest .

  2. Run the container:

    ```shell script
    docker run —rm —name librespeed-cli librespeed-cli:latest

    With options

    docker run —rm —name librespeed-cli librespeed-cli:latest —telemetry-level disabled —no-upload

    To avoid “Failed to ping target host: socket: permission denied” errors when using —verbose

    docker run —rm —name librespeed-cli —sysctl net.ipv4.ping_group_range=”0 2147483647” librespeed-cli:latest —verbose
    ```

Usage

You can see the full list of supported options with librespeed-cli -h:

  1. $ librespeed-cli -h
  2. NAME:
  3. librespeed-cli - Test your Internet speed with LibreSpeed 🚀
  4. USAGE:
  5. librespeed-cli [global options] [arguments...]
  6. GLOBAL OPTIONS:
  7. --help, -h show help (default: false)
  8. --version Show the version number and exit (default: false)
  9. --ipv4, -4 Force IPv4 only (default: false)
  10. --ipv6, -6 Force IPv6 only (default: false)
  11. --no-download Do not perform download test (default: false)
  12. --no-upload Do not perform upload test (default: false)
  13. --no-icmp Do not use ICMP ping. ICMP doesn't work well under Linux
  14. at this moment, so you might want to disable it (default: false)
  15. --concurrent value Concurrent HTTP requests being made (default: 3)
  16. --bytes Display values in bytes instead of bits. Does not affect
  17. the image generated by --share, nor output from
  18. --json or --csv (default: false)
  19. --mebibytes Use 1024 bytes as 1 kilobyte instead of 1000 (default: false)
  20. --distance value Change distance unit shown in ISP info, use 'mi' for miles,
  21. 'km' for kilometres, 'NM' for nautical miles (default: "km")
  22. --share Generate and provide a URL to the LibreSpeed.org share results
  23. image, not displayed with --csv (default: false)
  24. --simple Suppress verbose output, only show basic information
  25. (default: false)
  26. --csv Suppress verbose output, only show basic information in CSV
  27. format. Speeds listed in bit/s and not affected by --bytes
  28. (default: false)
  29. --csv-delimiter CSV_DELIMITER Single character delimiter (CSV_DELIMITER) to use in
  30. CSV output. (default: ",")
  31. --csv-header Print CSV headers (default: false)
  32. --json Suppress verbose output, only show basic information
  33. in JSON format. Speeds listed in bit/s and not
  34. affected by --bytes (default: false)
  35. --list Display a list of LibreSpeed.org servers (default: false)
  36. --server SERVER Specify a SERVER ID to test against. Can be supplied
  37. multiple times. Cannot be used with --exclude
  38. --exclude EXCLUDE EXCLUDE a server from selection. Can be supplied
  39. multiple times. Cannot be used with --server
  40. --server-json value Use an alternative server list from remote JSON file
  41. --local-json value Use an alternative server list from local JSON file,
  42. or read from stdin with "--local-json -".
  43. --source SOURCE SOURCE IP address to bind to. Incompatible with --interface.
  44. --interface INTERFACE The name of the network interface to bind to. Example: "enp0s3".
  45. Not supported on Windows and incompatible with --source.
  46. Implies --no-icmp.
  47. --timeout TIMEOUT HTTP TIMEOUT in seconds. (default: 15)
  48. --duration value Upload and download test duration in seconds (default: 15)
  49. --chunks value Chunks to download from server, chunk size depends on server configuration (default: 100)
  50. --upload-size value Size of payload being uploaded in KiB (default: 1024)
  51. --secure Use HTTPS instead of HTTP when communicating with
  52. LibreSpeed.org operated servers (default: false)
  53. --ca-cert value Use the specified CA certificate PEM bundle file instead
  54. of the system certificate trust store
  55. --skip-cert-verify Skip verifying SSL certificate for HTTPS connections (self-signed certs) (default: false)
  56. --no-pre-allocate Do not pre allocate upload data. Pre allocation is
  57. enabled by default to improve upload performance. To
  58. support systems with insufficient memory, use this
  59. option to avoid out of memory errors (default: false)
  60. --telemetry-json value Load telemetry server settings from a JSON file. This
  61. options overrides --telemetry-level, --telemetry-server,
  62. --telemetry-path, and --telemetry-share. Implies --share
  63. --telemetry-level value Set telemetry data verbosity, available values are:
  64. disabled, basic, full, debug. Implies --share
  65. --telemetry-server value Set the telemetry server base URL. Implies --share
  66. --telemetry-path value Set the telemetry upload path. Implies --share
  67. --telemetry-share value Set the telemetry share link path. Implies --share
  68. --telemetry-extra value Send a custom message along with the telemetry results.
  69. Implies --share

Use a custom backend server list

The librespeed-cli supports loading custom backend server list from a JSON file (remotely via --server-json or
locally via --local-json). The format is as below:

  1. [
  2. {
  3. "id": 1,
  4. "name": "PHP Backend",
  5. "server": "https://example.com/",
  6. "dlURL": "garbage.php",
  7. "ulURL": "empty.php",
  8. "pingURL": "empty.php",
  9. "getIpURL": "getIP.php"
  10. },
  11. {
  12. "id": 2,
  13. "name": "Go Backend",
  14. "server": "http://example.com/speedtest/",
  15. "dlURL": "garbage",
  16. "ulURL": "empty",
  17. "pingURL": "empty",
  18. "getIpURL": "getIP"
  19. }
  20. ]

The --local-json option can also read from stdin:

echo '[{"id": 1,"name": "a","server": "https://speedtest.example.com/","dlURL": "garbage.php","ulURL": "empty.php","pingURL": "empty.php","getIpURL": "getIP.php"}]' | librespeed-cli --local-json -

As you can see in the example, all servers have their schemes defined. In case of undefined scheme (e.g. //example.com),
librespeed-cli will use http by default, or https when the --secure option is enabled.

Use a custom telemetry server

By default, the telemetry result will be sent to librespeed.org. You can also customize your telemetry settings
via the --telemetry prefixed options. In order to load a custom telemetry endpoint configuration, you’ll have to use the
--telemetry-json option to specify a local JSON file containing the configuration bits. The format is as below:

  1. {
  2. "telemetryLevel": "full",
  3. "server": "https://example.com",
  4. "path": "/results/telemetry.php",
  5. "shareURL": "/results/"
  6. }

For telemetryLevel, four values are available:

  • disabled to disable telemetry
  • basic to enable telemetry with result only)
  • full to enable telemetry with result and timing
  • debug to enable the most verbose telemetry information

server defines the base URL for the backend’s endpoints. path is the path for uploading the telemetry result, and
shareURL is the path for fetching the uploaded result in PNG format.

Currently, --telemetry-json only supports loading a local JSON file.

Bugs?

Although we have tested the cli, it’s still in its early days. Please open an issue if you encounter any bugs, or even
better, submit a PR.

How to contribute

If you have some good ideas on improving librespeed-cli, you can always submit a PR via GitHub.

License

librespeed-cli is licensed under GNU Lesser General Public License v3.0