Skip to content

Commit e2ce889

Browse files
committed
First commit
1 parent e6d3b01 commit e2ce889

File tree

16 files changed

+2095
-0
lines changed

16 files changed

+2095
-0
lines changed

.gitignore

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Linux template
3+
*~
4+
5+
# temporary files which can be created if a process still has a handle open of a deleted file
6+
.fuse_hidden*
7+
8+
# KDE directory preferences
9+
.directory
10+
11+
# Linux trash folder which might appear on any partition or disk
12+
.Trash-*
13+
14+
# .nfs files are created when an open file is removed but is still being accessed
15+
.nfs*
16+
17+
### macOS template
18+
# General
19+
.DS_Store
20+
.AppleDouble
21+
.LSOverride
22+
23+
# Icon must end with two \r
24+
Icon
25+
26+
# Thumbnails
27+
._*
28+
29+
# Files that might appear in the root of a volume
30+
.DocumentRevisions-V100
31+
.fseventsd
32+
.Spotlight-V100
33+
.TemporaryItems
34+
.Trashes
35+
.VolumeIcon.icns
36+
.com.apple.timemachine.donotpresent
37+
38+
# Directories potentially created on remote AFP share
39+
.AppleDB
40+
.AppleDesktop
41+
Network Trash Folder
42+
Temporary Items
43+
.apdisk
44+
45+
### JetBrains template
46+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
47+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
48+
49+
# User-specific stuff
50+
.idea/**/workspace.xml
51+
.idea/**/tasks.xml
52+
.idea/**/usage.statistics.xml
53+
.idea/**/dictionaries
54+
.idea/**/shelf
55+
56+
# Generated files
57+
.idea/**/contentModel.xml
58+
59+
# Sensitive or high-churn files
60+
.idea/**/dataSources/
61+
.idea/**/dataSources.ids
62+
.idea/**/dataSources.local.xml
63+
.idea/**/sqlDataSources.xml
64+
.idea/**/dynamic.xml
65+
.idea/**/uiDesigner.xml
66+
.idea/**/dbnavigator.xml
67+
68+
# Gradle
69+
.idea/**/gradle.xml
70+
.idea/**/libraries
71+
72+
# Gradle and Maven with auto-import
73+
# When using Gradle or Maven with auto-import, you should exclude module files,
74+
# since they will be recreated, and may cause churn. Uncomment if using
75+
# auto-import.
76+
# .idea/artifacts
77+
# .idea/compiler.xml
78+
# .idea/modules.xml
79+
# .idea/*.iml
80+
# .idea/modules
81+
# *.iml
82+
# *.ipr
83+
84+
# CMake
85+
cmake-build-*/
86+
87+
# Mongo Explorer plugin
88+
.idea/**/mongoSettings.xml
89+
90+
# File-based project format
91+
*.iws
92+
93+
# IntelliJ
94+
out/
95+
96+
# mpeltonen/sbt-idea plugin
97+
.idea_modules/
98+
99+
# JIRA plugin
100+
atlassian-ide-plugin.xml
101+
102+
# Cursive Clojure plugin
103+
.idea/replstate.xml
104+
105+
# Crashlytics plugin (for Android Studio and IntelliJ)
106+
com_crashlytics_export_strings.xml
107+
crashlytics.properties
108+
crashlytics-build.properties
109+
fabric.properties
110+
111+
# Editor-based Rest Client
112+
.idea/httpRequests
113+
114+
# Android studio 3.1+ serialized cache file
115+
.idea/caches/build_file_checksums.ser
116+
117+
### Go template
118+
# Binaries for programs and plugins
119+
*.exe
120+
*.exe~
121+
*.dll
122+
*.so
123+
*.dylib
124+
125+
# Test binary, built with `go test -c`
126+
*.test
127+
128+
# Output of the go coverage tool, specifically when used with LiteIDE
129+
*.out
130+
131+
# Dependency directories (remove the comment below to include it)
132+
# vendor/

README.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
![LibreSpeed Logo](https://github.com/librespeed/speedtest/blob/master/.logo/logo3.png?raw=true)
2+
3+
# LibreSpeed command line tool
4+
Don't have a GUI but wants to use LibreSpeed servers to test your Internet speed? 🚀
5+
6+
`librespeed-cli` comes to rescue!
7+
8+
This is a command line interface for LibreSpeed speed test backends, written in Go.
9+
10+
## Features
11+
- Ping
12+
- Jitter
13+
- Download
14+
- Upload
15+
- IP address
16+
- ISP Information
17+
- Result sharing (telemetry) *[optional]*
18+
- Test with multiple servers in a single run
19+
- Use your own server list or telemetry endpoints
20+
- Tested with PHP and Go backends
21+
22+
[![asciicast](https://asciinema.org/a/J17bUAilWI3qR12JyhfGvPwu2.svg)](https://asciinema.org/a/J17bUAilWI3qR12JyhfGvPwu2)
23+
24+
## Requirements for compiling
25+
- Go 1.14
26+
27+
## Runtime requirements
28+
- Any [Go supported platforms](https://github.com/golang/go/wiki/MinimumRequirements)
29+
30+
## Building `librespeed-cli`
31+
32+
1. First, you'll have to install Go. For Windows users, [you can download an installer from golang.org](https://golang.org/dl/).
33+
For Linux users, you can use either the archive from golang.org, or install from your distribution's package manager.
34+
35+
For example, Arch Linux:
36+
37+
```shell script
38+
# pacman -S go
39+
```
40+
41+
2. Then, clone the repository:
42+
43+
```shell script
44+
$ git clone -b v1.0.0 https://github.com/librespeed/speedtest-cli
45+
```
46+
47+
3. After you have Go installed on your system (and added to your `$PATH` if you're using the archive from golang.org), you
48+
can now proceed to build `librespeed-cli` with the build script:
49+
50+
```shell script
51+
$ cd speedtest-cli
52+
$ ./build.sh
53+
```
54+
55+
If you want to build for another operating system or system architecture, use the `GOOS` and `GOARCH` environment
56+
variables. Run `go tool dist list` to get a list of possible combinations of `GOOS` and `GOARCH`.
57+
58+
```shell script
59+
# Let's say we're building for 64-bit Windows on Linux
60+
$ GOOS=windows GOARCH=amd64 ./build.sh
61+
```
62+
63+
4. When the build script finishes, if everything went smoothly, you can find the built binary under directory `out`.
64+
65+
```shell script
66+
$ ls out
67+
librespeed-cli-windows-amd64.exe
68+
```
69+
70+
5. Now you can use the `librespeed-cli` and test your Internet speed!
71+
72+
## Install from AUR/Homebrew
73+
74+
TODO
75+
76+
## Usage
77+
78+
You can see the full list of supported options with `librespeed-cli -h`:
79+
80+
```shell script
81+
$ librespeed-cli -h
82+
NAME:
83+
librespeed-cli - Test your Internet speed with LibreSpeed 🚀
84+
85+
USAGE:
86+
librespeed-cli [global options] [arguments...]
87+
88+
GLOBAL OPTIONS:
89+
--help, -h show help (default: false)
90+
--version Show the version number and exit (default: false)
91+
--no-download Do not perform download test (default: false)
92+
--no-upload Do not perform upload test (default: false)
93+
--bytes Display values in bytes instead of bits. Does not affect
94+
the image generated by --share, nor output from
95+
--json or --csv (default: false)
96+
--distance value Change distance unit shown in ISP info, use 'mi' for miles,
97+
'km' for kilometres, 'NM' for nautical miles (default: "km")
98+
--share Generate and provide a URL to the LibreSpeed.org share results
99+
image, not displayed with --csv (default: false)
100+
--simple Suppress verbose output, only show basic information
101+
(default: false)
102+
--csv Suppress verbose output, only show basic information in CSV
103+
format. Speeds listed in bit/s and not affected by --bytes
104+
(default: false)
105+
--csv-delimiter CSV_DELIMITER Single character delimiter (CSV_DELIMITER) to use in
106+
CSV output. (default: ",")
107+
--csv-header Print CSV headers (default: false)
108+
--json Suppress verbose output, only show basic information
109+
in JSON format. Speeds listed in bit/s and not
110+
affected by --bytes (default: false)
111+
--list Display a list of LibreSpeed.org servers (default: false)
112+
--server SERVER Specify a SERVER ID to test against. Can be supplied
113+
multiple times. Cannot be used with --exclude
114+
--exclude EXCLUDE EXCLUDE a server from selection. Can be supplied
115+
multiple times. Cannot be used with --server
116+
--server-json value Use an alternative server list from remote JSON file
117+
--local-json value Use an alternative server list from local JSON file
118+
--source SOURCE SOURCE IP address to bind to
119+
--timeout TIMEOUT HTTP TIMEOUT in seconds. (default: 15)
120+
--secure Use HTTPS instead of HTTP when communicating with
121+
LibreSpeed.org operated servers (default: false)
122+
--no-pre-allocate Do not pre allocate upload data. Pre allocation is
123+
enabled by default to improve upload performance. To
124+
support systems with insufficient memory, use this
125+
option to avoid out of memory errors (default: false)
126+
--telemetry-json value Load telemetry server settings from a JSON file. This
127+
options overrides --telemetry-level, --telemetry-server,
128+
--telemetry-path, and --telemetry-share
129+
--telemetry-level value Set telemetry data verbosity, available values are:
130+
disabled, basic, full, debug
131+
--telemetry-server value Set the telemetry server base URL
132+
--telemetry-path value Set the telemetry upload path
133+
--telemetry-share value Set the telemetry share link path
134+
--telemetry-extra value Send a custom message along with the telemetry results
135+
```
136+
137+
## Use a custom backend server list
138+
The `librespeed-cli` supports loading custom backend server list from a JSON file (remotely via `--server-json` or
139+
locally via `--local-json`). The format is as below:
140+
141+
```json
142+
[
143+
{
144+
"name": "PHP Backend",
145+
"server": "https://example.com/",
146+
"dlURL": "garbage.php",
147+
"ulURL": "empty.php",
148+
"pingURL": "empty.php",
149+
"getIpURL": "getIP.php"
150+
},
151+
{
152+
"name": "Go Backend",
153+
"server": "http://example.com/speedtest/",
154+
"dlURL": "garbage",
155+
"ulURL": "empty",
156+
"pingURL": "empty",
157+
"getIpURL": "getIP"
158+
}
159+
]
160+
```
161+
162+
As you can see in the example, all servers have their schemes defined. In case of undefined scheme (e.g. `//example.com`),
163+
`librespeed-cli` will use `http` by default, or `https` when the `--secure` option is enabled.
164+
165+
## Use a custom telemetry server
166+
By default, the telemetry result will be sent to `librespeed.org` by default. You can also customize your telemetry settings
167+
via the `--telemetry` prefixed options. In order to load a custom telemetry endpoint configuration, you'll have to use the
168+
`--telemetry-json` option to specify a local JSON file containing the configuration bits. The format is as below:
169+
170+
```json
171+
{
172+
"telemetryLevel": "full",
173+
"server": "https://example.com",
174+
"path": "/results/telemetry.php",
175+
"shareURL": "/results/"
176+
}
177+
```
178+
179+
For `telemetryLevel`, four values are available:
180+
181+
- `disabled` to disable telemetry
182+
- `basic` to enable telemetry with result only)
183+
- `full` to enable telemetry with result and timing
184+
- `debug` to enable the most verbose telemetry information
185+
186+
`server` defines the base URL for the backend's endpoints. `path` is the path for uploading the telemetry result, and
187+
`shareURL` is the path for fetching the uploaded result in PNG format.
188+
189+
Currently, `--telemetry-json` only supports loading a local JSON file.
190+
191+
## Bugs?
192+
193+
Although we have tested the cli, it's still in its early days. Please open an issue if you encounter any bugs, or even
194+
better, submit a PR.
195+
196+
## How to contribute
197+
198+
If you have some good ideas on improving `librespeed-cli`, you can always submit a PR via GitHub.
199+
200+
## License
201+
202+
`librespeed-cli` is licensed under [GNU Lesser General Public License v3.0](https://github.com/librespeed/speedtest-cli/blob/master/LICENSE)

build.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ -z "$1" ]]; then
4+
PROGVER="$(git describe --tag)"
5+
else
6+
PROGVER="$1"
7+
fi
8+
9+
CURRENT_DIR=$(pwd)
10+
OUT_DIR=${CURRENT_DIR}/out
11+
12+
PROGNAME="librespeed-cli"
13+
BINARY=${PROGNAME}-$(go env GOOS)-$(go env GOARCH)
14+
BUILD_DATE=$(date -u "+%Y-%m-%d %H:%M:%S %Z")
15+
LDFLAGS="-w -s -X \"librespeed-cli/defs.ProgName=${PROGNAME}\" -X \"librespeed-cli/defs.ProgVersion=${PROGVER}\" -X \"librespeed-cli/defs.BuildDate=${BUILD_DATE}\""
16+
17+
if [[ -n "${GOARM}" ]] && [[ "${GOARM}" -gt 0 ]]; then
18+
BINARY=${BINARY}v${GOARM}
19+
fi
20+
21+
if [[ -n "${GOMIPS}" ]]; then
22+
BINARY=${BINARY}-${GOMIPS}
23+
fi
24+
25+
if [[ -n "${GOMIPS64}" ]]; then
26+
BINARY=${BINARY}-${GOMIPS64}
27+
fi
28+
29+
if [[ "$(go env GOOS)" = "windows" ]]; then
30+
BINARY=${BINARY}.exe
31+
fi
32+
33+
if [[ ! -d ${OUT_DIR} ]]; then
34+
mkdir "${OUT_DIR}"
35+
fi
36+
37+
if [[ -e ${OUT_DIR}/${BINARY} ]]; then
38+
rm -f "${OUT_DIR}/${BINARY}"
39+
fi
40+
41+
go build -o "${OUT_DIR}/${BINARY}" -ldflags "${LDFLAGS}" -trimpath main.go
42+
43+
if [[ ! $(go env GOARCH) == mips64* ]] && [[ -x $(command -v upx) ]]; then
44+
upx -qqq -9 "${OUT_DIR}/${BINARY}"
45+
fi

0 commit comments

Comments
 (0)