Compare commits

..

189 Commits

Author SHA1 Message Date
Henry Whitaker
4e9fbe6742 Change download link 2021-05-04 14:34:07 +01:00
Henry Whitaker
a11555d239 Merge pull request #519 from henrywhitaker3/dev-docker 2021-03-07 11:06:47 +00:00
Henry Whitaker
d563797a7e Merge pull request #518 from henrywhitaker3/alpha-docker 2021-03-07 09:27:56 +00:00
Henry Whitaker
2219b0213c npm install 2021-03-07 09:24:01 +00:00
Henry Whitaker
974384db8a composer install 2021-03-07 09:18:45 +00:00
Henry Whitaker
8e80edc8f8 Update base files 2021-03-07 09:17:53 +00:00
Henry Whitaker
1835449c7b Merge branch 'alpha-docker' into dev-docker 2020-12-20 01:17:59 +00:00
Henry Whitaker
4cf6164459 Added in modified files 2020-12-20 01:17:32 +00:00
Henry Whitaker
257eb18306 Merge pull request #424 from henrywhitaker3/alpha-docker 2020-12-20 01:13:58 +00:00
Henry Whitaker
fd47856ea4 Checkbox 2020-12-20 01:01:43 +00:00
Henry Whitaker
87009940d1 npm & composer 2020-12-20 00:56:04 +00:00
Henry Whitaker
fc924bc85e Added files for 1.10.3 2020-12-20 00:53:22 +00:00
Henry Whitaker
be2e2b04c9 Merge branch 'alpha-docker' into dev-docker 2020-12-13 16:45:31 +00:00
Henry Whitaker
8dd6df08ca Updated to v1.10.1 2020-12-13 16:45:00 +00:00
Henry Whitaker
f37d3f7116 Merge pull request #414 from henrywhitaker3/dev-docker 2020-12-13 16:41:01 +00:00
Henry Whitaker
5a3fdfe132 Merge branch 'alpha-docker' into dev-docker 2020-12-13 16:13:42 +00:00
Henry Whitaker
efa1840ca6 Updated arm dockerfile 2020-12-13 16:12:54 +00:00
Henry Whitaker
6d2cfa4f5e Merge pull request #412 from henrywhitaker3/alpha-docker 2020-12-13 16:01:40 +00:00
Henry Whitaker
aa5b0ca309 Added dockerfile for arm 2020-12-13 15:59:52 +00:00
Henry Whitaker
54ce0ece35 npm and composer 2020-12-13 15:59:35 +00:00
Henry Whitaker
ec51c2def6 Updated files for 1.10.0 2020-12-13 15:52:13 +00:00
Henry Whitaker
b09b912555 Merge pull request #374 from henrywhitaker3/alpha-docker
Updated to v1.9.10
2020-11-07 15:58:00 +00:00
Henry Whitaker
faf56bf852 Updated to v1.9.10 2020-11-07 15:53:44 +00:00
Henry Whitaker
4f0334fdb9 Merge pull request #372 from henrywhitaker3/alpha-docker
Updated to v1.9.9
2020-11-07 15:29:57 +00:00
Henry Whitaker
8d811862a0 Updated to v1.9.9 2020-11-07 15:27:50 +00:00
Henry Whitaker
c26b54374a Merge pull request #316 from henrywhitaker3/alpha-docker 2020-09-11 01:33:09 +01:00
Henry Whitaker
15d3583423 Updated to v1.9.8 2020-09-11 01:30:31 +01:00
Henry Whitaker
e7bd0cf5d9 npm run prod 2020-09-11 01:15:26 +01:00
Henry Whitaker
5b4e455176 Updated node & composer dependencies 2020-09-11 01:14:41 +01:00
Henry Whitaker
bdb273e9f8 Added v1.9.7 files 2020-09-11 01:13:38 +01:00
Henry Whitaker
002c564b4d Merge pull request #302 from henrywhitaker3/dev-docker 2020-09-05 01:34:25 +01:00
Henry Whitaker
61ff1157ee Merge pull request #301 from henrywhitaker3/alpha-docker 2020-09-05 01:22:34 +01:00
Henry Whitaker
b9e95d4de8 Composer & npm 2020-09-05 01:17:18 +01:00
Henry Whitaker
5fc88ed287 Update files to v1.9.6 2020-09-05 01:09:36 +01:00
Henry Whitaker
4e73322e0c Merge pull request #298 from henrywhitaker3/alpha-docker
Explicitly set speedtest bin permissions
2020-09-03 22:43:23 +01:00
Henry Whitaker
a282a0d082 Explicitly set speedtest bin permissions
re #296
2020-09-03 22:41:25 +01:00
Henry Whitaker
0c60e14a10 Merge pull request #287 from henrywhitaker3/alpha-docker 2020-08-28 20:52:32 +01:00
Henry Whitaker
fde92f60fe composer and npm 2020-08-28 20:42:05 +01:00
Henry Whitaker
871c225bab Updated files to v1.9.5 2020-08-28 20:39:18 +01:00
Henry Whitaker
9f607f1571 Merge pull request #280 from henrywhitaker3/alpha-docker
Fix changelog formatting
2020-08-25 22:04:18 +01:00
Henry Whitaker
10756e27f0 Fix changelog formatting 2020-08-25 22:02:43 +01:00
Henry Whitaker
ebe80c7cd5 Merge pull request #278 from henrywhitaker3/alpha-docker
Updated to v1.9.4
2020-08-25 21:35:28 +01:00
Henry Whitaker
f11d3cf842 Updated files to v1.9.4 2020-08-25 21:29:12 +01:00
Henry Whitaker
437cd96c87 Merge pull request #276 from henrywhitaker3/alpha-docker
Updated to v1.9.3
2020-08-25 01:12:36 +01:00
Henry Whitaker
c8f853dc84 composer and npm 2020-08-25 00:59:44 +01:00
Henry Whitaker
6726d93cc6 Updated files to v1.9.3 2020-08-25 00:56:32 +01:00
Henry Whitaker
ca553dda59 Merge pull request #271 from henrywhitaker3/alpha-docker
Updated to v1.9.2
2020-08-21 23:48:39 +01:00
Henry Whitaker
83519ec605 Implement v1.9.2 bugfix 2020-08-21 23:45:22 +01:00
Henry Whitaker
94854e43ee composer dump-autoload 2020-08-21 23:31:43 +01:00
Henry Whitaker
9dee371740 npm 2020-08-21 23:31:21 +01:00
Henry Whitaker
07e7f856a0 Added v1.9.1 files 2020-08-21 23:29:31 +01:00
Henry Whitaker
c72c78c32c Merge pull request #269 from henrywhitaker3/alpha-docker
Updated to v1.9.0
2020-08-21 18:26:28 +01:00
Henry Whitaker
e77a806de1 Updated init script 2020-08-21 18:21:22 +01:00
Henry Whitaker
94c51a418c Updated npm stuff 2020-08-21 18:21:11 +01:00
Henry Whitaker
07b0ff6bf1 Updated to v1.9.0 2020-08-21 18:02:38 +01:00
Henry Whitaker
0558e31624 Merge pull request #263 from henrywhitaker3/alpha-docker
Updated to v1.8.1
2020-08-15 17:39:09 +01:00
Henry Whitaker
489e47f729 Added docker workflows 2020-08-15 17:37:26 +01:00
Henry Whitaker
2e68abf665 composer and node 2020-08-15 17:32:47 +01:00
Henry Whitaker
a97ebea83e Update site files 2020-08-15 17:29:18 +01:00
Henry Whitaker
68a5ef50e3 Merge pull request #259 from henrywhitaker3/alpha-docker
Updated to v1.8.0
2020-08-12 14:24:19 +01:00
Henry Whitaker
180c0e367a Updated config to docker info 2020-08-12 14:23:32 +01:00
Henry Whitaker
4cca793e2a composer and npm 2020-08-12 14:14:16 +01:00
Henry Whitaker
03c37f4442 Updated files to v1.8.0 2020-08-12 14:12:35 +01:00
Henry Whitaker
df68b7a968 Merge pull request #256 from henrywhitaker3/alpha-docker
Updated to v1.7.19
2020-08-12 13:29:37 +01:00
Henry Whitaker
b6f261649d composer install 2020-08-12 13:25:13 +01:00
Henry Whitaker
6c457a32e9 Update files to v1.7.19 2020-08-12 13:23:05 +01:00
Henry Whitaker
c54d25e397 Merge pull request #246 from henrywhitaker3/alpha-docker
Updated to v1.7.17
2020-08-08 23:32:36 +01:00
Henry Whitaker
379ca5e699 Updated config for docker 2020-08-08 23:29:46 +01:00
Henry Whitaker
59815dbdcd Updated dependencies 2020-08-08 23:20:34 +01:00
Henry Whitaker
e709239dc8 Updated files to v1.7.17 2020-08-08 23:18:16 +01:00
Henry Whitaker
9173539d63 Merge pull request #237 from henrywhitaker3/alpha-docker
Updated to v1.7.16
2020-08-03 14:32:33 +01:00
Henry Whitaker
840c8d7249 Updated to v1.7.16 2020-08-03 14:29:52 +01:00
Henry Whitaker
c639c8cae2 Merge pull request #233 from henrywhitaker3/dev-docker
Updated docker from dev-docker
2020-08-03 12:26:04 +01:00
Henry Whitaker
b8a91a99ca Merge pull request #232 from henrywhitaker3/alpha-docker
Updated readme
2020-08-03 12:25:10 +01:00
Henry Whitaker
a652afde39 Updated readme 2020-08-03 12:09:53 +01:00
Henry Whitaker
53f6035798 Merge pull request #228 from henrywhitaker3/alpha-docker
Updated to v1.7.15
2020-08-03 12:02:15 +01:00
Henry Whitaker
1d1c2a4839 Updated files to v1.7.15 2020-08-03 11:50:38 +01:00
Henry Whitaker
cf32b10cbb Merge pull request #226 from henrywhitaker3/dev-docker
Fixed gitignore
2020-08-03 09:53:35 +01:00
Henry Whitaker
f4a6960c82 Merge pull request #224 from henrywhitaker3/alpha-docker
Fixed dependenciy files missing
2020-08-03 09:53:05 +01:00
Henry Whitaker
cb64260f9b Fixed dependenciy files missing 2020-08-03 09:52:12 +01:00
Henry Whitaker
c4d52b6b62 Merge pull request #223 from henrywhitaker3/dev-docker
Added another missing vendor file
2020-08-03 09:39:41 +01:00
Henry Whitaker
b5b57db54b Merge pull request #222 from henrywhitaker3/alpha-docker
Added another missing vendor file
2020-08-03 09:39:00 +01:00
Henry Whitaker
224c293c47 Added another missing vendor file 2020-08-03 09:38:32 +01:00
Henry Whitaker
1e3f7488fb Merge pull request #218 from henrywhitaker3/dev-docker
Merge dev-docker into docker
2020-08-02 20:53:02 +01:00
Henry Whitaker
9867ccd10d Merge pull request #219 from henrywhitaker3/alpha-docker
Fix bug with missing file
2020-08-02 20:46:00 +01:00
Henry Whitaker
20dda28e34 Missing file 2020-08-02 20:45:18 +01:00
Henry Whitaker
e1868ba2fb composer dump 2020-08-02 20:40:28 +01:00
Henry Whitaker
bad27a1985 Merge pull request #216 from henrywhitaker3/docker-reset-settings
Updated to v1.7.14
2020-08-02 20:25:55 +01:00
Henry Whitaker
7dbbf04fb8 composer and npm install 2020-08-02 20:25:20 +01:00
Henry Whitaker
136353be80 Updated files to v1.7.14 2020-08-02 20:21:01 +01:00
Henry Whitaker
f4e9467eb9 Merge pull request #206 from henrywhitaker3/docker-reset-settings
Updated to v1.7.13
2020-07-24 12:53:49 +01:00
Henry Whitaker
dddfca4eb1 Updated to v1.7.13
Clear queue on container restart (#192)
2020-07-24 12:53:08 +01:00
Henry Whitaker
a556541399 Merge pull request #204 from henrywhitaker3/docker-reset-settings
Updated to v1.7.12
2020-07-24 12:06:54 +01:00
Henry Whitaker
10b995e86d Updated to v1.7.12 2020-07-24 12:05:51 +01:00
Henry Whitaker
b9be9e6499 Merge pull request #197 from henrywhitaker3/docker-reset-settings
Updated to v1.7.10
2020-07-22 12:04:28 +01:00
Henry Whitaker
48e6e2d0ab Updated to v1.7.10 2020-07-22 12:03:49 +01:00
Henry Whitaker
a1e861459c Merge pull request #195 from henrywhitaker3/docker-reset-settings
Updated to v1.7.9
2020-07-22 11:39:10 +01:00
Henry Whitaker
1a94317551 Fixed bug causing speedtests to fail with "permission denied" error 2020-07-22 11:38:23 +01:00
Henry Whitaker
73b990869a Merge pull request #191 from henrywhitaker3/docker-reset-settings
Updated to v1.7.9
2020-07-22 01:53:29 +01:00
Henry Whitaker
9da79ea697 Updated to v1.7.9 2020-07-22 01:52:25 +01:00
Henry Whitaker
9e62ff43c8 Merge pull request #189 from henrywhitaker3/dev-docker
Merge dev into latest
2020-07-20 17:32:25 +01:00
Henry Whitaker
3cbb45f3a4 Merge pull request #188 from henrywhitaker3/docker-speedtest-error
Updated to v1.7.8
2020-07-20 17:22:12 +01:00
Henry Whitaker
1e25197063 Updated to v1.7.8 2020-07-20 17:20:17 +01:00
Henry Whitaker
d417976610 Merge pull request #171 from henrywhitaker3/docker-speedtest-error
Updated to v1.7.7
2020-07-08 12:14:26 +01:00
Henry Whitaker
5d28876b2b Updated dependencies 2020-07-08 12:08:03 +01:00
Henry Whitaker
40916a0c83 Copied over changed files from dev 2020-07-08 12:05:47 +01:00
Henry Whitaker
c6dad52ef5 Merge pull request #163 from henrywhitaker3/docker-speedtest-error
More settings bugfixes
2020-07-07 23:36:37 +01:00
Henry Whitaker
2e401908c6 More settings bugfixes 2020-07-07 23:36:07 +01:00
Henry Whitaker
f68e440352 Merge pull request #161 from henrywhitaker3/docker-speedtest-error
Bug fix
2020-07-07 23:02:34 +01:00
Henry Whitaker
90f083404c Bug fix 2020-07-07 23:00:02 +01:00
Henry Whitaker
6b2d29cbce Merge pull request #159 from henrywhitaker3/docker-speedtest-error
Updated to v1.7.5
2020-07-07 22:38:49 +01:00
Henry Whitaker
5032eaf2e5 Fixed some bugs/changed scripts 2020-07-07 22:38:13 +01:00
Henry Whitaker
04414f7659 Added missed updated file 2020-07-07 21:28:23 +01:00
Henry Whitaker
3a31cec789 Updated files to v1.7.5 2020-07-07 21:25:46 +01:00
Henry Whitaker
5b2b8262e3 Merge pull request #151 from henrywhitaker3/docker-speedtest-error
Updated to v1.7.4
2020-07-06 19:53:21 +01:00
Henry Whitaker
df54a4c523 Updated to v1.7.4 2020-07-06 19:52:48 +01:00
Henry Whitaker
d652b375e2 Merge pull request #147 from henrywhitaker3/docker-speedtest-error
Updated speedtest controller
2020-07-03 12:50:03 +01:00
Henry Whitaker
56edd8e79b Updated speedtest controller 2020-07-03 12:48:32 +01:00
Henry Whitaker
a21553f242 Merge pull request #145 from henrywhitaker3/docker-speedtest-error
Updated to v1.7.3
2020-07-03 12:15:47 +01:00
Henry Whitaker
c5b9e6adc5 Updated to v1.7.3 2020-07-03 12:15:02 +01:00
Henry Whitaker
21759f1c62 Merge pull request #133 from henrywhitaker3/dev-docker
Merge dev into latest
2020-06-27 01:45:46 +01:00
Henry Whitaker
6516e43a2a Merge pull request #134 from henrywhitaker3/dev-conf
MF
2020-06-25 00:37:00 +01:00
Henry Whitaker
7bd082e6a0 Merge branch 'dev-docker' into docker 2020-06-25 00:35:41 +01:00
Henry Whitaker
0c902d3c93 Updated README.md 2020-06-24 23:55:50 +01:00
Henry Whitaker
1dc8df50b3 Added some error checking on speedtest:run 2020-06-24 23:51:18 +01:00
Henry Whitaker
6469916536 Merge pull request #131 from henrywhitaker3/docker-notifications
Updated to v1.7.1
2020-06-24 22:59:32 +01:00
Henry Whitaker
24146eb333 Updated to v1.7.1 2020-06-24 22:58:46 +01:00
Henry Whitaker
220312fb47 Merge pull request #123 from henrywhitaker3/docker-notifications
Updated to v1.7.0
2020-06-21 20:49:50 +01:00
Henry Whitaker
651f7508b6 Updated to v1.7.0 2020-06-21 20:48:58 +01:00
Henry Whitaker
505e3b9247 Merge pull request #121 from henrywhitaker3/docker-telegram
Updated to v1.6.1
2020-06-21 15:29:45 +01:00
Henry Whitaker
2bfcb22895 Updated to v1.6.1 2020-06-21 15:28:15 +01:00
Henry Whitaker
6844585bc1 Merge pull request #120 from henrywhitaker3/docker-telegram
Updated to v1.6.0
2020-06-21 14:21:38 +01:00
Henry Whitaker
75e512ee07 Updated init script 2020-06-21 14:20:46 +01:00
Henry Whitaker
a62755c42a Installed new composer packages 2020-06-21 14:20:11 +01:00
Henry Whitaker
6e33cb5e14 Added updated site files 2020-06-21 14:11:23 +01:00
Henry Whitaker
61bc0f3493 Merge pull request #116 from henrywhitaker3/docker-speedtest-data
Updated to v1.5.6
2020-06-20 20:05:12 +01:00
Henry Whitaker
29caaf5d8d Updated to v1.5.6
Added auto-updates on all tests table
2020-06-20 20:04:20 +01:00
Henry Whitaker
b4d910f8a0 Merge pull request #114 from henrywhitaker3/docker-speedtest-data
Updated site to v1.5.5
2020-06-20 18:34:49 +01:00
Henry Whitaker
1f4e9e3271 Updated dependencies 2020-06-20 18:31:58 +01:00
Henry Whitaker
258b6f1c8a Updated site to v1.5.5 2020-06-20 18:26:12 +01:00
Henry Whitaker
77976d9240 Fixed DB permissions issue
issue #110
2020-06-19 16:47:37 +01:00
Henry Whitaker
d7d6cebcc6 Updated README.md
Added disclaimer about Ookla EULA
2020-06-19 02:02:28 +01:00
Henry Whitaker
bb72ffc41a Merge pull request #109 from henrywhitaker3/docker-speedtest-client
Moved to Ookla binary
2020-06-19 01:08:53 +01:00
Henry Whitaker
dfd8799de5 Stopped accepting EULA in new process
Would cause scripts to re-run and mess up logs
2020-06-19 01:08:21 +01:00
Henry Whitaker
155fbc81b3 Merge pull request #108 from henrywhitaker3/docker-speedtest-client
Moved to Ookla binary
2020-06-19 00:29:28 +01:00
Henry Whitaker
cd7f5af8b1 Moved to Ookla binary 2020-06-19 00:28:25 +01:00
Henry Whitaker
c042ff9fdb Merge pull request #106 from henrywhitaker3/docker-speedtest-client
Small changes
2020-06-18 18:22:15 +01:00
Henry Whitaker
c0fabd7217 Updated dependencies 2020-06-18 18:21:24 +01:00
Henry Whitaker
c545613d79 Changed dockerfile
Added changes from 1489a8f8a4
2020-06-18 18:06:11 +01:00
Henry Whitaker
c093cf8ea6 Merge pull request #101 from henrywhitaker3/docker-speedtest-client
Changed speedtest client
2020-06-17 21:24:38 +01:00
Henry Whitaker
e767d8a0e7 Changed speedtest client 2020-06-17 21:23:30 +01:00
Henry Whitaker
bd867d140d Merge pull request #98 from henrywhitaker3/docker-backup-format
Updated to v1.5.2
2020-06-17 18:35:13 +01:00
Henry Whitaker
7d0681e77b Updated to v1.5.2 2020-06-17 18:33:53 +01:00
Henry Whitaker
cd1c9fe493 Merge pull request #97 from henrywhitaker3/dev-docker
Permissions fix
2020-06-17 18:24:02 +01:00
Henry Whitaker
be64825f3d Merge pull request #95 from henrywhitaker3/dev-docker-lsio
DB readonly issue fix
2020-06-17 17:35:14 +01:00
Henry Whitaker
248151bbb1 DB readonly issue fix 2020-06-17 17:34:31 +01:00
Henry Whitaker
c275b40f65 Merge pull request #92 from henrywhitaker3/dev-docker
Merge dev features into master
2020-06-17 11:04:56 +01:00
Henry Whitaker
9a50efe0cc Merge branch 'docker' into dev-docker 2020-06-17 11:04:45 +01:00
Henry Whitaker
83d047343d Merge pull request #87 from henrywhitaker3/dev-docker-lsio
Moved over to lsio base image
2020-06-10 09:54:39 +01:00
Henry Whitaker
e2e9221871 Moved over to lsio base image 2020-06-10 09:51:51 +01:00
Henry Whitaker
133a34f1e3 Set JWT secret in entrypoint 2020-05-25 02:59:48 +01:00
Henry Whitaker
ad97579af4 Added base url setting 2020-05-21 00:31:06 +01:00
Henry Whitaker
faf292b68c Updated to v1.4.1 2020-05-20 12:34:50 +01:00
Henry Whitaker
2961fe6236 Updated to v1.4.0 2020-05-20 12:20:05 +01:00
Henry Whitaker
60690cb114 Updated to v1.3.7 2020-05-18 20:12:18 +01:00
Henry Whitaker
f5186ea7fd Updated to v1.3.6 2020-05-13 10:19:22 +01:00
Henry Whitaker
acccfced1b Updated to v1.3.5 2020-05-12 11:57:22 +01:00
Henry Whitaker
d6f3c02bdb Updated to v1.3.4 2020-05-07 12:12:08 +01:00
Henry Whitaker
3a99dc5495 Updated to v1.3.3 2020-05-05 09:34:02 +01:00
Henry Whitaker
4c515c3c80 Updated to v1.3.2 2020-04-30 16:04:23 +01:00
Henry Whitaker
b96bbacfd1 Updated to v1.3.1 2020-04-29 00:18:30 +01:00
Henry Whitaker
89dce90211 Updated to v1.3.0
Added slack webhook notifications
2020-04-27 19:32:18 +01:00
Henry Whitaker
eb95e062a9 Updated to v1.2.9 2020-04-27 15:16:05 +01:00
Henry Whitaker
478c5eff31 Updated to v1.2.8
Added favicons
2020-04-25 12:31:41 +01:00
Henry Whitaker
1090335cdd Updated to v1.2.7 2020-04-24 18:29:30 +01:00
Henry Whitaker
229bb30cf5 Updated to v1.2.6 2020-04-21 23:41:44 +01:00
Henry Whitaker
4fa6d2d366 Shuffled UI elements 2020-04-13 23:27:17 +01:00
Henry Whitaker
e533ac6b43 Added max/min 2020-04-13 23:00:04 +01:00
Henry Whitaker
913a2d546c Update README.md 2020-04-13 17:52:36 +01:00
Henry Whitaker
d12a909028 Updated to v1.2.4 2020-04-13 10:59:06 +01:00
Henry Whitaker
bf6d5ca901 Merge pull request #10 from henrywhitaker3/add-license-1
Create LICENSE
2020-04-13 08:30:17 +01:00
Henry Whitaker
56e23559c5 Create LICENSE 2020-04-13 08:30:07 +01:00
Henry Whitaker
6f3f8ca38d Changed permissions RUN command
Now only chmods storage and bootstrap to speed up building the image
2020-04-13 08:24:00 +01:00
Henry Whitaker
527135e412 Updated site to newest version
Changed order of speedtests table
2020-04-13 08:23:02 +01:00
Henry Whitaker
e1ca4dcca9 Added a table of all speedtests 2020-04-13 01:31:26 +01:00
Henry Whitaker
ea5808047f Tweaked gitignore
gitignore removed all composer and npm files, so automated builds would fail
2020-04-12 21:24:03 +01:00
Henry Whitaker
698687f12d Added all files to build image from 2020-04-12 21:01:43 +01:00
Henry Whitaker
5e1e673cee Added site files 2020-04-12 18:49:36 +01:00
Henry Whitaker
7b87339d46 Removed default db 2020-04-12 18:31:02 +01:00
31190 changed files with 3976199 additions and 38987 deletions

View File

@@ -1,19 +0,0 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.vscode/
_ide_helper.php
.idea
.config
reports/

16
.github/workflows/docker-image-dev.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: Docker Dev
on:
push:
branches: [ dev-docker ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

View File

@@ -13,4 +13,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

View File

@@ -0,0 +1,16 @@
name: Docker Stable
on:
push:
branches: [ docker ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

19
.gitignore vendored
View File

@@ -1,19 +0,0 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.vscode/
_ide_helper.php
.idea
.config
reports/

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}

View File

@@ -3,8 +3,7 @@ LABEL maintainer=henrywhitaker3@outlook.com
ENV arch='x86_64'
COPY docker/conf/ /
COPY . /site
COPY conf/ /
EXPOSE 80 443

View File

@@ -1,12 +1,12 @@
# Speedtest Tracker
[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.12.1-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE)
[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.10.4-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE)
This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses the [Ookla's speedtest cli](https://www.speedtest.net/apps/cli) package to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results.
This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses [Ookla's Speedtest cli](https://www.speedtest.net/apps/cli) to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results.
A demo can be found [here](https://speedtest.henrywhitaker.com)
A demo site is available [here](https://speedtest.henrywhitaker.com).
Disclaimer: You will need to accept Ookla's EULA and privacy agreements in order to use this container.
Disclaimer: You will need to accept Ookla's [EULA](https://www.speedtest.net/about/eula) and privacy agreements in order to use this container.
![speedtest](https://user-images.githubusercontent.com/36062479/78822484-a82b8300-79ca-11ea-8525-fdeae496a0bd.gif)
@@ -18,13 +18,8 @@ Disclaimer: You will need to accept Ookla's EULA and privacy agreements in order
- Slack/Discord/Telegram notifications
- [healthchecks.io](https://healthchecks.io) integration
- Organizr integration
- InfluxDB integration (currently v1 only, v2 is a WIP)
## Installation & Setup
### Using Docker
A docker image is available [here](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker), you can create a new conatiner by running:
## Usage
```bash
docker create \
@@ -36,7 +31,7 @@ docker create \
henrywhitaker3/speedtest-tracker
```
### Using Docker Compose
### Docker compose
```yml
version: '3.3'
@@ -70,7 +65,7 @@ There are 2 different docker images:
| latest | This is the stable release of the app |
| dev | This release has more features, although could have some bugs |
#### Parameters
### Parameters
Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate `<external>:<internal>` respectively. For example, `-p 8080:80` would expose port `80` from inside the container to be accessible from the host's IP on port `8080` outside the container.
@@ -85,12 +80,10 @@ Container images are configured using parameters passed at runtime (such as thos
| `-e PUID` | Optional. Supply a local user ID for volume permissions |
| `-e PGID` | Optional. Supply a local group ID for volume permissions |
| `-e AUTH` | Optional. Set to 'true' to enable authentication for the app |
| `-e INFLUXDB_RETENTION`| Optional. Sets the InfluxDB retention period, defaults to `30d` |
| `-e INFLUXDB_HOST_TAG | Optional. Sets the InfluxDB host tag value, defaults to `speedtest` |
### Authentication
Authentication is optional. When enabled, unauthenticated users will only be able to see the graphs and tests table. To be able to queue a new speedtest, backup/restore data and update instance settings you will need to log in. To enable authentication, pass the `AUTH=true` environment variable in docker or run `php artisan speedtest:auth --enable` for manual installs (same command with `--disable` to turn it off).
Authentication is optional. When enabled, unauthenticated users will only be able to see the graphs and tests table. To be able to queue a new speedtest, backup/restore data and update instance settings you will need to log in. To enable authentication, pass the `AUTH=true` environment variable.
The default credentials are:
@@ -100,11 +93,24 @@ The default credentials are:
| password | password |
After enabling, you should change the password through the web UI.
### Manual Install
For manual installations, please follow the instructions [here](https://github.com/henrywhitaker3/Speedtest-Tracker/wiki/Manual-Installation).
## Getting the Image
### Kubernetes
To get the base image, you have 2 options:
There is a 3rd party helm chart available [here](https://github.com/sOblivionsCall/charts).
- Use the pre-built image on dockerhub
- Build the image yourself
### Pre-built Image
Run `docker pull henrywhitaker3/speedtest-tracker`
### Dockerfile
Clone the required files from the github repo [here](https://github.com/henrywhitaker3/Speedtest-Tracker/tree/docker) making sure to use the `docker` branch of the repo.
Build the image from the docker file by running (within the cloned git repo):
```bash
docker build . -f Dockerfile --tag=henrywhitaker3/speedtest-tracker:<tag>
```

View File

@@ -1,48 +0,0 @@
<?php
namespace App\Actions;
use App\Models\Speedtest;
use Cache;
use Carbon\Carbon;
use DB;
use Henrywhitaker3\LaravelActions\Interfaces\ActionInterface;
class GetFailedSpeedtestData implements ActionInterface
{
/**
* Run the action.
*
* @return mixed
*/
public function run($days = 7)
{
$ttl = Carbon::now()->addDays(1);
return Cache::remember('failure-rate-' . $days, $ttl, function () use ($days) {
$range = [
Carbon::today()
];
for ($i = 0; $i < ($days - 1); $i++) {
$prev = end($range);
$new = $prev->copy()->subDays(1);
array_push($range, $new);
}
$rate = [];
foreach ($range as $day) {
$success = Speedtest::select(DB::raw('COUNT(id) as rate'))->whereDate('created_at', $day)->where('failed', false)->get()[0]['rate'];
$fail = Speedtest::select(DB::raw('COUNT(id) as rate'))->whereDate('created_at', $day)->where('failed', true)->get()[0]['rate'];
array_push($rate, [
'date' => $day->toDateString(),
'success' => $success,
'failure' => $fail,
]);
}
return array_reverse($rate);
});
}
}

View File

@@ -1,52 +0,0 @@
<?php
namespace App\Actions;
use App\Helpers\SettingsHelper;
use App\Helpers\SpeedtestHelper;
use App\Models\Speedtest;
use DB;
use Henrywhitaker3\LaravelActions\Interfaces\ActionInterface;
class GetLatestSpeedtestData implements ActionInterface
{
/**
* Run the action.
*
* @return mixed
*/
public function run()
{
$data = SpeedtestHelper::latest();
$response = [
'data' => $data,
];
if (SettingsHelper::get('show_average')) {
$avg = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload'))
->where('failed', false)
->first()
->toArray();
$response['average'] = $avg;
}
if (SettingsHelper::get('show_max')) {
$max = Speedtest::select(DB::raw('MAX(ping) as ping, MAX(download) as download, MAX(upload) as upload'))
->where('failed', false)
->first()
->toArray();
$response['maximum'] = $max;
}
if (SettingsHelper::get('show_min')) {
$min = Speedtest::select(DB::raw('MIN(ping) as ping, MIN(download) as download, MIN(upload) as upload'))
->where('failed', false)
->first()
->toArray();
$response['minimum'] = $min;
}
return $response;
}
}

View File

@@ -1,37 +0,0 @@
<?php
namespace App\Actions;
use App\Helpers\SettingsHelper;
use App\Models\Speedtest;
use Cache;
use Carbon\Carbon;
use Henrywhitaker3\LaravelActions\Interfaces\ActionInterface;
class GetSpeedtestTimeData implements ActionInterface
{
/**
* Run the action.
*
* @return mixed
*/
public function run($days = 7)
{
$ttl = Carbon::now()->addDays(1);
return Cache::remember('speedtest-days-' . $days, $ttl, function () use ($days) {
$showFailed = (bool)SettingsHelper::get('show_failed_tests_on_graph')->value;
if ($showFailed === true) {
return Speedtest::where('created_at', '>=', Carbon::now()->subDays($days))
->orderBy('created_at', 'asc')
->get();
}
return Speedtest::where('created_at', '>=', Carbon::now()->subDays($days))
->where('failed', false)
->orderBy('created_at', 'asc')
->get();
});
}
}

View File

@@ -1,35 +0,0 @@
<?php
namespace App\Actions;
use App\Helpers\SettingsHelper;
use App\Interfaces\SpeedtestProvider;
use App\Jobs\SpeedtestJob;
use Henrywhitaker3\LaravelActions\Interfaces\ActionInterface;
class QueueSpeedtest implements ActionInterface
{
private SpeedtestProvider $speedtestProvider;
/**
* Create a new action instance.
*
* @return void
*/
public function __construct(SpeedtestProvider $speedtestProvider)
{
$this->speedtestProvider = $speedtestProvider;
}
/**
* Run the action.
*
* @return mixed
*/
public function run()
{
SettingsHelper::loadIntegrationConfig();
SpeedtestJob::dispatch(false, config('integrations'), $this->speedtestProvider);
}
}

1
app/Bin/.gitignore vendored
View File

@@ -1 +0,0 @@
speedtest

View File

@@ -1,52 +0,0 @@
<?php
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
class CommaSeparatedArrayCast implements CastsAttributes
{
/**
* Array of settings that should be cast
*/
private array $shouldCast = [
'visible_columns',
'hidden_columns',
];
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
*/
public function get($model, $key, $value, $attributes)
{
if (!in_array($model->name, $this->shouldCast)) {
return $value;
}
return explode(',', $value);
}
/**
* Prepare the given value for storage.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
*/
public function set($model, $key, $value, $attributes)
{
if (!in_array($model->name, $this->shouldCast)) {
return $value;
}
return implode(',', $value);
}
}

View File

@@ -1,65 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Exceptions\SpeedtestFailureException;
use App\Helpers\SpeedtestHelper;
use App\Interfaces\SpeedtestProvider;
use Illuminate\Console\Command;
class SpeedtestCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'speedtest:run';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Performs a new speedtest';
private SpeedtestProvider $speedtestProvider;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct(SpeedtestProvider $speedtestProvider)
{
$this->speedtestProvider = $speedtestProvider;
parent::__construct();
}
/**
* Runs a speedtest synchroonously and displays the results..
*
* @return void
*/
public function handle()
{
$this->info('Running speedtest, this might take a while...');
try {
$results = $this->speedtestProvider->run(false, false);
} catch (SpeedtestFailureException $e) {
$this->error('Something went wrong running the speedtest.');
exit();
}
if (property_exists($results, 'ping') && property_exists($results, 'download') && property_exists($results, 'upload')) {
$this->error('Something went wrong running the speedtest.');
exit();
}
$this->info('Ping: ' . $results->ping . ' ms');
$this->info('Download: ' . $results->download . ' Mbit/s');
$this->info('Upload: ' . $results->upload . ' Mbit/s');
}
}

View File

@@ -1,58 +0,0 @@
<?php
namespace App\Console;
use App\Events\SpeedtestOverviewEvent;
use App\Helpers\SettingsHelper;
use App\Helpers\SpeedtestHelper;
use App\Interfaces\SpeedtestProvider;
use App\Jobs\SpeedtestJob;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
if ((bool)SettingsHelper::get('schedule_enabled')->value) {
$schedule->job(
new SpeedtestJob(
true,
config('integrations'),
app()->make(SpeedtestProvider::class)
)
)
->cron(SettingsHelper::get('schedule')['value'])
->timezone(env('TZ', 'UTC'));
}
$schedule->command('speedtest:overview')->cron('0 ' . SettingsHelper::get('speedtest_overview_time')->value . ' * * *')->timezone(env('TZ', 'UTC'));
$schedule->command('speedtest:clear-sessions')->everyMinute();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__ . '/Commands');
require base_path('routes/console.php');
}
}

View File

@@ -1,10 +0,0 @@
<?php
namespace App\Exceptions;
use Exception;
class InfluxDBConnectionErrorException extends Exception
{
//
}

View File

@@ -1,10 +0,0 @@
<?php
namespace App\Exceptions;
use Exception;
class InfluxDBNotEnabledException extends Exception
{
//
}

View File

@@ -1,10 +0,0 @@
<?php
namespace App\Exceptions;
use Exception;
class SpeedtestFailureException extends Exception
{
//
}

View File

@@ -1,270 +0,0 @@
<?php
namespace App\Helpers;
use App\Interfaces\SpeedtestProvider;
use App\Models\Speedtest;
use App\Utils\OoklaTester;
use Carbon\Carbon;
use Exception;
use Henrywhitaker3\Healthchecks\Healthchecks;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use InvalidArgumentException;
use JsonException;
class SpeedtestHelper
{
/**
* Runs/processes speedtest output to created a Speedtest object
*
* @param boolean|string $output If false, new speedtest runs. If anything else, will try to parse as JSON for speedtest results.
* @return \App\Speedtest|bool
*/
public static function runSpeedtest()
{
$tester = app()->make(SpeedtestProvider::class);
return $tester->run();
}
/**
* Get a 24 hour average of speedtest results
*
* @return array
*/
public static function last24Hours()
{
$t = Carbon::now()->subDay();
$s = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload'))
->where('created_at', '>=', $t)
->where('failed', false)
->first()
->toArray();
return $s;
}
/**
* Converts bytes/s to Mbps
*
* @param int|float $bytes
* @return int|float
*/
public static function convert($bytes)
{
return ($bytes * 8) / 1000000;
}
/**
* Returns the latest speedtest object.
*
* @return boolean|\App\Speedtest
*/
public static function latest()
{
$data = Speedtest::latest()->get();
if ($data->isEmpty()) {
return false;
}
return $data->first();
}
/**
* Parses network speeds and return converted to Mbps
*
* @param string $input
* @return array
*/
public static function parseUnits($input)
{
$input = explode(' ', $input);
$val = (float)$input[0];
$unit = explode('/', $input[1])[0];
switch ($unit) {
case 'Mbyte':
$val = $val * 8;
break;
case 'Kbit':
$val = $val / 1000;
break;
case 'Kbyte':
$val = $val / 125;
break;
case 'Mbit':
default:
break;
}
return [
'val' => $val,
'unit' => 'Mbit/s'
];
}
/**
* Create a backup of the SQLite database
*
* @return null|boolean
*/
public static function dbBackup()
{
if (env('DB_CONNECTION') === 'sqlite') {
if (env('DB_DATABASE') !== null) {
$current = env('DB_DATABASE');
try {
if (File::copy($current, $current . '.bak')) {
return true;
}
} catch (Exception $e) {
return false;
}
}
return false;
}
return null;
}
/**
* Delete all speedtests from the database
*
* @return array
*/
public static function deleteAll()
{
Cache::flush();
SpeedtestHelper::dbBackup();
if (sizeof(Speedtest::whereNotNull('id')->get()) > 0) {
if (Speedtest::whereNotNull('id')->delete()) {
return [
'success' => true,
];
}
}
return [
'success' => true,
];
}
/**
* Work out if a test is lower than the threshold for historic tests
*
* @param String $type
* @param Speedtest $test
* @return array
*/
public static function testIsLowerThanThreshold(String $type, Speedtest $test)
{
if ($type == 'percentage') {
$avg = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload'))
->where('failed', false)
->get()
->toArray()[0];
$threshold = SettingsHelper::get('threshold_alert_percentage')->value;
if ($threshold == '') {
return [];
}
$errors = [];
foreach ($avg as $key => $value) {
if ($key == 'ping') {
$threshold = (float)$value * (1 + ($threshold / 100));
if ($test->$key > $threshold) {
array_push($errors, $key);
}
} else {
$threshold = (float)$value * (1 - ($threshold / 100));
if ($test->$key < $threshold) {
array_push($errors, $key);
}
}
}
return $errors;
}
if ($type == 'absolute') {
$thresholds = [
'download' => SettingsHelper::get('threshold_alert_absolute_download')->value,
'upload' => SettingsHelper::get('threshold_alert_absolute_upload')->value,
'ping' => SettingsHelper::get('threshold_alert_absolute_ping')->value,
];
$errors = [];
foreach ($thresholds as $key => $value) {
if ($value == '') {
continue;
}
if ($key == 'ping') {
if ($test->$key > $value) {
array_push($errors, $key);
}
} else {
if ($test->$key < $value) {
array_push($errors, $key);
}
}
}
return $errors;
}
throw new InvalidArgumentException();
}
/**
* Get a percentage rate of failure by days
*
* @param integer $days number of days to get rate for
* @return integer percentage fail rate
*/
public static function failureRate(int $days)
{
$ttl = Carbon::now()->addDays(1);
$rate = Cache::remember('failure-rate-' . $days, $ttl, function () use ($days) {
$range = [
Carbon::today()
];
for ($i = 0; $i < ($days - 1); $i++) {
$prev = end($range);
$new = $prev->copy()->subDays(1);
array_push($range, $new);
}
$rate = [];
foreach ($range as $day) {
$success = Speedtest::select(DB::raw('COUNT(id) as rate'))->whereDate('created_at', $day)->where('failed', false)->get()[0]['rate'];
$fail = Speedtest::select(DB::raw('COUNT(id) as rate'))->whereDate('created_at', $day)->where('failed', true)->get()[0]['rate'];
array_push($rate, [
'date' => $day->toDateString(),
'success' => $success,
'failure' => $fail,
]);
}
return array_reverse($rate);
});
return $rate;
}
}

View File

@@ -1,35 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Actions\GetFailedSpeedtestData;
use App\Actions\GetLatestSpeedtestData;
use App\Actions\GetSpeedtestTimeData;
use App\Helpers\SettingsHelper;
use Illuminate\Http\Request;
use Validator;
class HomepageDataController extends Controller
{
public function __invoke($days)
{
$validator = Validator::make(
['days' => $days],
['days' => ['required', 'numeric']],
);
if ($validator->fails()) {
return response()->json([
'method' => 'get speedtests in last x days',
'error' => $validator->errors(),
], 422);
}
return [
'latest' => run(GetLatestSpeedtestData::class),
'time' => run(GetSpeedtestTimeData::class, $days),
'fail' => run(GetFailedSpeedtestData::class),
'config' => SettingsHelper::getConfig(),
];
}
}

View File

@@ -1,188 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Actions\GetFailedSpeedtestData;
use App\Actions\GetLatestSpeedtestData;
use App\Actions\GetSpeedtestTimeData;
use App\Actions\QueueSpeedtest;
use App\Helpers\SettingsHelper;
use App\Helpers\SpeedtestHelper;
use App\Jobs\SpeedtestJob;
use App\Models\Speedtest;
use Carbon\Carbon;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\JsonResponse;
class SpeedtestController extends Controller
{
public function __construct()
{
if ((bool)SettingsHelper::get('auth')->value === true) {
$this->middleware('auth:api')
->only(['run', 'delete', 'deleteAll']);
}
}
/**
* Returns paginated list of speedtests
*
* @return JsonResponse
*/
public function index()
{
$data = Speedtest::orderBy('created_at', 'desc')
->paginate();
return response()->json([
'method' => 'index of speedtests',
'data' => $data,
], 200);
}
/**
* Returns speedtest going back 'x' days
*
* @param int $days
* @return JsonResponse
*/
public function time($days)
{
$rule = [
'days' => ['required', 'integer'],
];
$validator = Validator::make(['days' => $days], $rule);
if ($validator->fails()) {
return response()->json([
'method' => 'get speedtests in last x days',
'error' => $validator->errors(),
], 422);
}
$data = run(GetSpeedtestTimeData::class, $days);
return response()->json([
'method' => 'get speedtests in last x days',
'days' => $days,
'data' => $data
], 200);
}
/**
* Returns speedtest failure rate going back 'x' days
*
* @param int $days
* @return JsonResponse
*/
public function fail($days)
{
$rule = [
'days' => ['required', 'integer'],
];
$validator = Validator::make(['days' => $days], $rule);
if ($validator->fails()) {
return response()->json([
'method' => 'get speedtests in last x days',
'error' => $validator->errors(),
], 422);
}
$data = run(GetFailedSpeedtestData::class, $days);
return response()->json([
'method' => 'get speedtests in last x days',
'days' => $days,
'data' => $data
], 200);
}
/**
* Return latest speedtest
*
* @return JsonResponse
*/
public function latest()
{
$data = run(GetLatestSpeedtestData::class);
if ($data['data']) {
return response()->json($data, 200);
} else {
return response()->json([
'method' => 'get latest speedtest',
'error' => 'no speedtests have been run'
], 404);
}
}
/**
* Queue a new speedtest
*
* @return JsonResponse
*/
public function run()
{
try {
run(QueueSpeedtest::class);
return response()->json([
'method' => 'run speedtest',
'data' => 'a new speedtest has been added to the queue'
], 200);
} catch (Exception $e) {
return response()->json([
'method' => 'run speedtest',
'error' => $e
], 500);
}
}
/**
* Delete all speedtests from db
*
* @return JsonResponse
*/
public function deleteAll()
{
$ret = SpeedtestHelper::deleteAll();
if ($ret['success']) {
return response()->json([
'method' => 'delete all speedtests from the database',
'success' => true
], 200);
}
return response()->json([
'method' => 'delete all speedtests from the database',
'success' => false,
'error' => $ret['msg'],
], 500);
}
/**
* Delete a specific speedtest from the database
*
* @param Speedtest $speedtest
* @return JsonResponse
*/
public function delete(Speedtest $speedtest)
{
$speedtest->delete();
Cache::flush();
return response()->json([
'method' => 'delete a speedtest from the database',
'success' => true,
], 200);
}
}

View File

@@ -1,13 +0,0 @@
<?php
namespace App\Interfaces;
use App\Models\Speedtest;
interface InfluxDBWrapperInterface
{
public function testConnection(): bool;
public function doesDatabaseExist(string $database): bool;
public function createDatabase(string $database): bool;
public function store(Speedtest $speedtest): bool;
}

View File

@@ -1,11 +0,0 @@
<?php
namespace App\Interfaces;
use App\Models\Speedtest;
interface SpeedtestProvider
{
public function run(): Speedtest;
public function output();
}

View File

@@ -1,25 +0,0 @@
<?php
namespace App\Models;
use App\Casts\CommaSeparatedArrayCast;
use App\Helpers\SettingsHelper;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'value', 'description'
];
protected $table = 'settings';
protected $casts = [
'value' => CommaSeparatedArrayCast::class,
];
}

View File

@@ -1,45 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Speedtest extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'ping',
'download',
'upload',
'created_at',
'server_id',
'server_name',
'server_host',
'url',
'scheduled',
'failed',
];
protected $table = 'speedtests';
public function formatForInfluxDB()
{
return [
'id' => (int) $this->id,
'download' => (float) $this->download,
'upload' => (float) $this->upload,
'ping' => (float) $this->ping,
'server_id' => (int) $this->server_id,
'server_host' => $this->server_host,
'server_name' => $this->server_name,
'scheduled' => (bool) $this->scheduled,
];
}
}

View File

@@ -1,114 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'id', 'email_verified_at'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
protected $primaryKey = 'id';
protected $keyType = 'uuid';
public $incrementing = false;
public static function loginRules()
{
return [
'email' => 'required',
'password' => 'required'
];
}
public static function registerRules()
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed']
];
}
public static function updateRules()
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users']
];
}
public function verification()
{
return $this->hasOne('\App\Auth\EmailVerification');
}
/**
* Returns a user's login sessions
*
* @return mixed
*/
public function sessions()
{
return $this->hasMany('\App\Auth\LoginSession');
}
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}
public function setPasswordAttribute($password)
{
if (!empty($password)) {
$this->attributes['password'] = Hash::make($password);
}
}
}

View File

@@ -1,30 +0,0 @@
<?php
namespace App\Observers;
use App\Exceptions\InfluxDBNotEnabledException;
use App\Models\Speedtest;
use App\Utils\InfluxDB\InfluxDB;
use Exception;
use Log;
class SpeedtestObserver
{
/**
* Handle the Speedtest "created" event.
*
* @param \App\Speedtest $speedtest
* @return void
*/
public function created(Speedtest $speedtest)
{
try {
InfluxDB::connect()
->store($speedtest);
} catch (InfluxDBNotEnabledException $e) {
// /
} catch (Exception $e) {
Log::error($e);
}
}
}

View File

@@ -1,56 +0,0 @@
<?php
namespace App\Providers;
use App\Events\SpeedtestCompleteEvent;
use App\Events\SpeedtestFailedEvent;
use App\Events\SpeedtestOverviewEvent;
use App\Events\TestNotificationEvent;
use App\Listeners\SpeedtestCompleteListener;
use App\Listeners\SpeedtestFailedListener;
use App\Listeners\SpeedtestOverviewListener;
use App\Listeners\TestNotificationListener;
use App\Observers\SpeedtestObserver;
use App\Models\Speedtest;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
SpeedtestCompleteEvent::class => [
SpeedtestCompleteListener::class,
],
SpeedtestOverviewEvent::class => [
SpeedtestOverviewListener::class
],
SpeedtestFailedEvent::class => [
SpeedtestFailedListener::class
],
TestNotificationEvent::class => [
TestNotificationListener::class
]
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
Speedtest::observe(SpeedtestObserver::class);
}
}

View File

@@ -1,81 +0,0 @@
<?php
namespace App\Providers;
use App\Helpers\SettingsHelper;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = null;
/**
* The path to the "home" route for your application.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix(SettingsHelper::getBase() . 'api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}

View File

@@ -1,28 +0,0 @@
<?php
namespace App\Providers;
use App\Helpers\SettingsHelper;
use App\Interfaces\SpeedtestProvider;
use App\Utils\OoklaTester;
use File;
use Illuminate\Support\ServiceProvider;
use Schema;
class SpeedtestServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
$this->app->singleton(
SpeedtestProvider::class,
function () {
return new OoklaTester();
}
);
}
}

View File

@@ -1,113 +0,0 @@
<?php
namespace App\Utils\InfluxDB;
use App\Exceptions\InfluxDBConnectionErrorException;
use App\Exceptions\InfluxDBNotEnabledException;
use App\Helpers\SettingsHelper;
use App\Models\Speedtest;
use InfluxDB\Client as Version1;
use InfluxDB2\Client as Version2;
use App\Interfaces\InfluxDBWrapperInterface as Client;
class InfluxDB
{
private Client $client;
private string $database;
public function __construct(Client $client)
{
$this->client = $client;
}
/**
* Connect to influx db
*
* @param string $host
* @param integer $port
* @param string $database
* @return InfluxDB
*/
public static function connect()
{
if (!(bool) SettingsHelper::get('influx_db_enabled')->value) {
throw new InfluxDBNotEnabledException();
}
$host = SettingsHelper::get('influx_db_host')->value;
$port = SettingsHelper::get('influx_db_port')->value;
$username = SettingsHelper::get('influx_db_username')->value;
$password = SettingsHelper::get('influx_db_password')->value;
$database = SettingsHelper::get('influx_db_database')->value;
$version = (int) SettingsHelper::get('influx_db_version')->value;
$wrapper = $version === 1
? new InfluxDBVersion1Wrapper(
new Version1(
str_replace(['http://', 'https://'], '', $host),
$port,
$username,
$password
)
)
: new InfluxDBVersion2Wrapper(
new Version2([
'url' => $host . ':' . $port,
'token' => '',
])
);
return (new self($wrapper))->setDatabase($database)
->testConnection();
}
/**
* Set the database field
*
* @param string $database
* @return InfluxDB
*/
public function setDatabase(string $database): InfluxDB
{
$this->database = $database;
return $this;
}
/**
* Test the connection
*
* @throws InfluxDBConnectionErrorException
* @return InfluxDB
*/
public function testConnection(): InfluxDB
{
if (!$this->client->testConnection()) {
throw new InfluxDBConnectionErrorException();
}
if (!$this->doesDatabaseExist()) {
$this->createDatabase();
}
return $this;
}
public function doesDatabaseExist(): bool
{
return $this->client->doesDatabaseExist($this->database);
}
public function createDatabase(): bool
{
return $this->client->createDatabase($this->database);
}
public function store(Speedtest $speedtest): InfluxDB
{
$this->client->store($speedtest);
return $this;
}
}

View File

@@ -1,74 +0,0 @@
<?php
namespace App\Utils\InfluxDB;
use App\Interfaces\InfluxDBWrapperInterface;
use App\Models\Speedtest;
use Exception;
use InfluxDB\Client;
use InfluxDB\Database;
use InfluxDB\Database\RetentionPolicy;
use InfluxDB\Point;
use Log;
class InfluxDBVersion1Wrapper implements InfluxDBWrapperInterface
{
private Client $client;
private Database $database;
public function __construct(Client $client)
{
$this->client = $client;
}
public function testConnection(): bool
{
try {
$this->client->listDatabases();
return true;
} catch (Exception $e) {
Log::error($e);
return false;
}
}
public function doesDatabaseExist(string $database): bool
{
$this->database = $this->client->selectDB($database);
return (bool) $this->database->exists();
}
public function createDatabase(string $database): bool
{
try {
$this->database->create(
new RetentionPolicy(
'speedtest_retention_policy',
config('services.influxdb.retention'),
1,
true
)
);
return true;
} catch (Exception $e) {
Log::error($e);
return false;
}
}
public function store(Speedtest $speedtest): bool
{
return $this->database->writePoints([
new Point(
'speedtest',
null,
['host' => config('services.influxdb.host')],
$speedtest->formatForInfluxDB(),
)
]);
}
}

View File

@@ -1,37 +0,0 @@
<?php
namespace App\Utils\InfluxDB;
use App\Interfaces\InfluxDBWrapperInterface;
use App\Models\Speedtest;
use InfluxDB2\Client;
class InfluxDBVersion2Wrapper implements InfluxDBWrapperInterface
{
private Client $client;
public function __construct(Client $client)
{
$this->client = $client;
}
public function testConnection(): bool
{
return $this->client->health()->getStatus() !== 'pass';
}
public function doesDatabaseExist(string $database): bool
{
return true;
}
public function createDatabase(string $database): bool
{
return true;
}
public function store(Speedtest $speedtest): bool
{
return true;
}
}

View File

@@ -1,128 +0,0 @@
<?php
namespace App\Utils;
use App\Exceptions\SpeedtestFailureException;
use App\Helpers\SettingsHelper;
use App\Helpers\SpeedtestHelper;
use App\Interfaces\SpeedtestProvider;
use App\Models\Speedtest;
use Cache;
use Exception;
use JsonException;
use Log;
class OoklaTester implements SpeedtestProvider
{
public function run($output = false, $scheduled = true): Speedtest
{
if ($output === false) {
$output = $this->output();
}
try {
$output = json_decode($output, true, 512, JSON_THROW_ON_ERROR);
if (!$this->isOutputComplete($output)) {
$test = false;
}
$test = Speedtest::create([
'ping' => $output['ping']['latency'],
'download' => SpeedtestHelper::convert($output['download']['bandwidth']),
'upload' => SpeedtestHelper::convert($output['upload']['bandwidth']),
'server_id' => $output['server']['id'],
'server_name' => $output['server']['name'],
'server_host' => $output['server']['host'] . ':' . $output['server']['port'],
'url' => $output['result']['url'],
'scheduled' => $scheduled
]);
} catch (JsonException $e) {
Log::error('Failed to parse speedtest JSON');
Log::error($output);
$test = false;
} catch (Exception $e) {
Log::error($e->getMessage());
$test = false;
}
if ($test == false) {
Speedtest::create([
'ping' => 0,
'upload' => 0,
'download' => 0,
'failed' => true,
'scheduled' => $scheduled,
]);
throw new SpeedtestFailureException(json_encode($output));
}
Cache::flush();
return $test;
}
public function output()
{
$server = SettingsHelper::get('server')['value'];
$binPath = app_path() . DIRECTORY_SEPARATOR . 'Bin' . DIRECTORY_SEPARATOR . 'speedtest';
$homePrefix = config('speedtest.home') . ' && ';
if ($server != '' && $server != false) {
$server = explode(',', $server);
$server = $server[array_rand($server)];
if ($server == false) {
Log::error('Speedtest server undefined');
return false;
}
return shell_exec($homePrefix . $binPath . ' -f json -s ' . $server);
}
return shell_exec($homePrefix . $binPath . ' -f json');
}
/**
* Checks that the speedtest JSON output is complete/valid
*
* @param array $output
* @return boolean
*/
public static function isOutputComplete($output)
{
/**
* Array of indexes that must exist in $output
*/
$checks = [
'type' => 'result',
'download' => ['bandwidth' => '*'],
'upload' => ['bandwidth' => '*'],
'ping' => ['latency' => '*'],
'server' => [
'id' => '*',
'name' => '*',
'host' => '*',
'port' => '*'
],
'result' => [
'url' => '*'
],
];
/**
* Array of indexes that must not exist
*/
$checkMissing = [
'type' => 'error'
];
foreach ($checks as $key => $value) {
if (!isset($output[$key])) {
return false;
}
}
return true;
}
}

View File

@@ -3,8 +3,7 @@ LABEL maintainer=henrywhitaker3@outlook.com
ENV arch='arm'
COPY docker/conf/ /
COPY . /site
COPY conf/ /
EXPOSE 80 443

View File

@@ -1,74 +0,0 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5",
"doctrine/dbal": "^2.10",
"dragonmantank/cron-expression": "^3",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"henrywhitaker3/healthchecks-io": "^1.0",
"henrywhitaker3/laravel-actions": "^1.0",
"influxdata/influxdb-client-php": "^1.12",
"influxdb/influxdb-php": "^1.15",
"laravel-notification-channels/telegram": "^0.5.0",
"laravel/framework": "^8.0",
"laravel/slack-notification-channel": "^2.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^3.0",
"tymon/jwt-auth": "^1.0"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.8",
"brianium/paratest": "^6.2",
"facade/ignition": "^2.3.6",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.3",
"nunomaduro/larastan": "^0.7.0",
"phpunit/phpunit": "^9.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}

9415
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -26,11 +26,10 @@ else
tar zxvf speedtest.tgz > /dev/null
cp speedtest /site/app/Bin/
chmod +x /site/artisan
HOME=/config && s6-setuidgid abc /site/app/Bin/speedtest --accept-license --accept-gdpr > /dev/null
HOME=/config && timeout 5s s6-setuidgid abc /site/app/Bin/speedtest --accept-license --accept-gdpr > /dev/null
HOME=/root
else
HOME=/config && s6-setuidgid abc /site/app/Bin/speedtest --accept-license --accept-gdpr > /dev/null
else
HOME=/config && timeout 5s s6-setuidgid abc /config/www/app/Bin/speedtest --accept-license --accept-gdpr > /dev/null
HOME=/root
fi
fi
@@ -56,15 +55,6 @@ else
echo "Env file exists"
fi
if [ ! -f /config/www/.composer-time ]; then
echo 'Removing old packages'
rm -rf /config/www/vendor/
fi
echo 'Updating packages'
apk add composer
cd /config/www && composer install && echo date > /config/www/.composer-time
sed "s,DB_DATABASE=.*,DB_DATABASE=/config/speed.db," -i.bak /config/www/.env
echo "Running database migrations"
@@ -136,4 +126,3 @@ cp /defaults/crontab /etc/crontabs/root
chown -R abc:abc /config
chmod +x /config/www/app/Bin/speedtest
chmod -R 777 /config/www/storage/clockwork

View File

@@ -0,0 +1,16 @@
name: DockerPR
on:
pull_request:
branches: [ docker, dev-docker, alpha-docker ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

View File

@@ -10,9 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@b7d1d9c9a92d8d8463ce36d7f60da34d461724f8
with:
php-version: '7.4'
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
@@ -46,7 +43,7 @@ jobs:
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Download Speedtest binary
run: wget https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
run: wget https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
- name: Accept EULA
env:
DB_CONNECTION: sqlite

View File

@@ -10,9 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@b7d1d9c9a92d8d8463ce36d7f60da34d461724f8
with:
php-version: '7.4'
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
@@ -46,7 +43,7 @@ jobs:
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Download Speedtest binary
run: wget https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
run: wget https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
- name: Accept EULA
env:
DB_CONNECTION: sqlite
@@ -56,4 +53,4 @@ jobs:
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: php artisan test --parallel
run: vendor/bin/phpunit

View File

@@ -10,9 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@b7d1d9c9a92d8d8463ce36d7f60da34d461724f8
with:
php-version: '7.4'
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
@@ -46,7 +43,7 @@ jobs:
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Download Speedtest binary
run: wget https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
run: wget https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz && tar zxvf speedtest.tgz && mv speedtest app/Bin/
- name: Accept EULA
env:
DB_CONNECTION: sqlite

16
conf/site/.gitignore vendored Normal file
View File

@@ -0,0 +1,16 @@
/public/hot
/public/storage
/storage/*.key
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.vscode/
_ide_helper.php
.idea
.config

674
conf/site/LICENSE Normal file
View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

103
conf/site/README.md Normal file
View File

@@ -0,0 +1,103 @@
# Speedtest Tracker
[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.10.4-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE)
This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses the [Ookla's speedtest cli](https://www.speedtest.net/apps/cli) package to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results.
A demo can be found [here](https://speedtest.henrywhitaker.com)
Disclaimer: You will need to accept Ookla's EULA and privacy agreements in order to use this container.
![speedtest](https://user-images.githubusercontent.com/36062479/78822484-a82b8300-79ca-11ea-8525-fdeae496a0bd.gif)
## Features
- Automatically run a speedtest every hour
- Graph of previous speedtests going back x days
- Backup/restore data in JSON/CSV format
- Slack/Discord/Telegram notifications
- [healthchecks.io](https://healthchecks.io) integration
- Organizr integration
## Installation & Setup
### Using Docker
A docker image is available [here](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker), you can create a new conatiner by running:
```bash
docker create \
--name=speedtest \
-p 8765:80 \
-v /path/to/data:/config \
-e OOKLA_EULA_GDPR=true \
--restart unless-stopped \
henrywhitaker3/speedtest-tracker
```
### Using Docker Compose
```yml
version: '3.3'
services:
speedtest:
container_name: speedtest
image: henrywhitaker3/speedtest-tracker
ports:
- 8765:80
volumes:
- /path/to/data:/config
environment:
- TZ=
- PGID=
- PUID=
- OOKLA_EULA_GDPR=true
logging:
driver: "json-file"
options:
max-file: "10"
max-size: "200k"
restart: unless-stopped
```
#### Images
There are 2 different docker images:
| Tag | Description |
| :----: | --- |
| latest | This is the stable release of the app |
| dev | This release has more features, although could have some bugs |
#### Parameters
Container images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate `<external>:<internal>` respectively. For example, `-p 8080:80` would expose port `80` from inside the container to be accessible from the host's IP on port `8080` outside the container.
| Parameter | Function |
| :----: | --- |
| `-p 8765:80` | Exposes the webserver on port 8765 |
| `-v /config` | All the config files reside here. |
| `-e OOKLA_EULA_GDPR` | Set to 'true' to accept the Ookla [EULA](https://www.speedtest.net/about/eula) and privacy agreement. If this is not set, the container will not start |
| `-e SLACK_WEBHOOK` | Optional. Put a slack webhook here to get slack notifications when a speedtest is run. To use discord webhooks, just append `/slack` to the end of your discord webhook URL |
| `-e TELEGRAM_BOT_TOKEN` | Optional. Telegram bot API token. |
| `-e TELEGRAM_CHAT_ID` | Optional. Telegram chat ID. |
| `-e PUID` | Optional. Supply a local user ID for volume permissions |
| `-e PGID` | Optional. Supply a local group ID for volume permissions |
| `-e AUTH` | Optional. Set to 'true' to enable authentication for the app |
### Authentication
Authentication is optional. When enabled, unauthenticated users will only be able to see the graphs and tests table. To be able to queue a new speedtest, backup/restore data and update instance settings you will need to log in. To enable authentication, pass the `AUTH=true` environment variable in docker or run `php artisan speedtest:auth --enable` for manual installs (same command with `--disable` to turn it off).
The default credentials are:
| Field | Function |
| --- | --- |
| username | admin@admin.com |
| password | password |
After enabling, you should change the password through the web UI.
### Manual Install
For manual installations, please follow the instructions [here](https://github.com/henrywhitaker3/Speedtest-Tracker/wiki/Manual-Installation).

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Models\Auth;
namespace App\Auth;
use Illuminate\Database\Eloquent\Model;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Models\Auth;
namespace App\Auth;
use Illuminate\Database\Eloquent\Model;

1
conf/site/app/Bin/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
speedtest

View File

@@ -38,7 +38,6 @@ class AcceptEULACommand extends Command
*/
public function handle()
{
$this->info('Acceping EULA');
shell_exec(config('speedtest.home') . ' && timeout 10s ' . app_path() . '/Bin/speedtest --accept-license --accept-gdpr');
shell_exec(config('speedtest.home') . ' && ' . app_path() . '/Bin/speedtest --accept-license --accept-gdpr');
}
}

View File

@@ -2,7 +2,7 @@
namespace App\Console\Commands;
use App\Models\Auth\LoginSession;
use App\Auth\LoginSession;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Log;

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Console\Commands;
use App\Helpers\SpeedtestHelper;
use Illuminate\Console\Command;
class SpeedtestCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'speedtest:run';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Performs a new speedtest';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Runs a speedtest synchroonously and displays the results..
*
* @return void
*/
public function handle()
{
$this->info('Running speedtest, this might take a while...');
$results = SpeedtestHelper::runSpeedtest(false, false);
if(!is_object($results)) {
$this->error('Something went wrong running the speedtest.');
exit();
}
if(property_exists($results, 'ping') && property_exists($results, 'download') && property_exists($results, 'upload')) {
$this->error('Something went wrong running the speedtest.');
exit();
}
$this->info('Ping: ' . $results->ping . ' ms');
$this->info('Download: ' . $results->download . ' Mbit/s');
$this->info('Upload: ' . $results->upload . ' Mbit/s');
}
}

View File

@@ -3,7 +3,6 @@
namespace App\Console\Commands;
use App\Helpers\SpeedtestHelper;
use App\Interfaces\SpeedtestProvider;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
@@ -23,17 +22,13 @@ class SpeedtestLatestCommand extends Command
*/
protected $description = 'Returns the latest speedtest result';
private SpeedtestProvider $speedtestProvider;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct(SpeedtestProvider $speedtestProvider)
public function __construct()
{
$this->speedtestProvider = $speedtestProvider;
parent::__construct();
}
@@ -46,8 +41,8 @@ class SpeedtestLatestCommand extends Command
{
$latest = SpeedtestHelper::latest();
if ($latest) {
if ($latest->scheduled) {
if($latest) {
if($latest->scheduled) {
$extra = '(scheduled)';
} else {
$extra = '(manual)';
@@ -55,7 +50,7 @@ class SpeedtestLatestCommand extends Command
$this->info('Last speedtest run at: ' . $latest->created_at . ' ' . $extra);
if ($latest->failed) {
if($latest->failed) {
$this->error('Speedtest failed');
} else {
$this->info('Ping: ' . $latest->ping . ' ms');
@@ -67,7 +62,7 @@ class SpeedtestLatestCommand extends Command
$this->info('Running speedtest, this might take a while...');
$results = $this->speedtestProvider->run();
$results = SpeedtestHelper::runSpeedtest();
$this->info('Ping: ' . $results->ping . ' ms');
$this->info('Download: ' . $results->download . ' Mbit/s');

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Console;
use App\Events\SpeedtestOverviewEvent;
use App\Helpers\SettingsHelper;
use App\Helpers\SpeedtestHelper;
use App\Jobs\SpeedtestJob;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
if ((bool)SettingsHelper::get('schedule_enabled')->value) {
$schedule->job(new SpeedtestJob(true, config('integrations')))->cron(SettingsHelper::get('schedule')['value']);
}
$schedule->command('speedtest:overview')->cron('0 ' . SettingsHelper::get('speedtest_overview_time')->value . ' * * *');
$schedule->command('speedtest:clear-sessions')->everyMinute();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__ . '/Commands');
require base_path('routes/console.php');
}
}

View File

@@ -2,7 +2,7 @@
namespace App\Helpers;
use App\Models\Speedtest;
use App\Speedtest;
use Cache;
use DateTime;
use Exception;

View File

@@ -2,8 +2,8 @@
namespace App\Helpers;
use App\Models\Auth\EmailVerification;
use App\Models\User;
use App\Auth\EmailVerification;
use App\User;
class EmailVerificationHelper {
public static function checkVerificationAttempt($userID, $token)

View File

@@ -3,13 +3,12 @@
namespace App\Helpers;
use App\Events\TestNotificationEvent;
use App\Models\Setting;
use App\Setting;
use Cache;
use Carbon\Carbon;
class SettingsHelper
{
private static $settings = null;
/**
* Get a Setting object by name
@@ -24,7 +23,7 @@ class SettingsHelper
if (sizeof($name) == 0) {
return false;
} else if (sizeof($name) == 1) {
return $name->first();
return $name[0];
} else {
$name = $name->keyBy('name');
return $name->all();
@@ -164,10 +163,6 @@ class SettingsHelper
'telegram_bot_token' => SettingsHelper::settingIsEditable('telegram_bot_token'),
'telegram_chat_id' => SettingsHelper::settingIsEditable('telegram_chat_id'),
],
'tables' => [
'visible_columns' => SettingsHelper::get('visible_columns')->value,
'hidden_columns' => SettingsHelper::get('hidden_columns')->value,
],
'auth' => (bool)SettingsHelper::get('auth')->value
];
}

View File

@@ -0,0 +1,377 @@
<?php
namespace App\Helpers;
use App\Speedtest;
use Carbon\Carbon;
use Exception;
use Henrywhitaker3\Healthchecks\Healthchecks;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use InvalidArgumentException;
use JsonException;
class SpeedtestHelper {
/**
* Runs/processes speedtest output to created a Speedtest object
*
* @param boolean|string $output If false, new speedtest runs. If anything else, will try to parse as JSON for speedtest results.
* @return \App\Speedtest|bool
*/
public static function runSpeedtest($output = false, $scheduled = true)
{
if($output === false) {
$output = SpeedtestHelper::output();
}
try {
$output = json_decode($output, true, 512, JSON_THROW_ON_ERROR);
if(!SpeedtestHelper::checkOutputIsComplete($output)) {
$test = false;
}
$test = Speedtest::create([
'ping' => $output['ping']['latency'],
'download' => SpeedtestHelper::convert($output['download']['bandwidth']),
'upload' => SpeedtestHelper::convert($output['upload']['bandwidth']),
'server_id' => $output['server']['id'],
'server_name' => $output['server']['name'],
'server_host' => $output['server']['host'] . ':' . $output['server']['port'],
'url' => $output['result']['url'],
'scheduled' => $scheduled
]);
} catch(JsonException $e) {
Log::error('Failed to parse speedtest JSON');
Log::error($output);
$test = false;
} catch(Exception $e) {
Log::error($e->getMessage());
$test = false;
}
if($test == false) {
Speedtest::create([
'ping' => 0,
'upload' => 0,
'download' => 0,
'failed' => true,
'scheduled' => $scheduled,
]);
return false;
}
Cache::flush();
return $test;
}
/**
* Gets the output of executing speedtest binary.
*
* @return boolean|string
*/
public static function output()
{
$server = SettingsHelper::get('server')['value'];
$binPath = app_path() . DIRECTORY_SEPARATOR . 'Bin' . DIRECTORY_SEPARATOR . 'speedtest';
$homePrefix = config('speedtest.home') . ' && ';
if($server != '' && $server != false) {
$server = explode(',', $server);
$server = $server[array_rand($server)];
if($server == false) {
Log::error('Speedtest server undefined');
return false;
}
return shell_exec($homePrefix . $binPath . ' -f json -s ' . $server);
}
return shell_exec($homePrefix . $binPath . ' -f json');
}
/**
* Get a 24 hour average of speedtest results
*
* @return array
*/
public static function last24Hours()
{
$t = Carbon::now()->subDay();
$s = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload'))
->where('created_at', '>=', $t)
->where('failed', false)
->first()
->toArray();
return $s;
}
/**
* Converts bytes/s to Mbps
*
* @param int|float $bytes
* @return int|float
*/
public static function convert($bytes) {
return ( $bytes * 8 ) / 1000000;
}
/**
* Returns the latest speedtest object.
*
* @return boolean|\App\Speedtest
*/
public static function latest()
{
$data = Speedtest::latest()->get();
if($data->isEmpty()) {
return false;
}
return $data->first();
}
/**
* Parses network speeds and return converted to Mbps
*
* @param string $input
* @return array
*/
public static function parseUnits($input)
{
$input = explode(' ', $input);
$val = (float)$input[0];
$unit = explode('/', $input[1])[0];
switch($unit) {
case 'Mbyte':
$val = $val * 8;
break;
case 'Kbit':
$val = $val / 1000;
break;
case 'Kbyte':
$val = $val / 125;
break;
case 'Mbit':
default:
break;
}
return [
'val' => $val,
'unit' => 'Mbit/s'
];
}
/**
* Checks that the speedtest JSON output is complete/valid
*
* @param array $output
* @return boolean
*/
public static function checkOutputIsComplete($output)
{
/**
* Array of indexes that must exist in $output
*/
$checks = [
'type' => 'result',
'download' => [ 'bandwidth' => '*' ],
'upload' => [ 'bandwidth' => '*' ],
'ping' => [ 'latency' => '*' ],
'server' => [
'id' => '*',
'name' => '*',
'host' => '*',
'port' => '*'
],
'result' => [
'url' => '*'
],
];
/**
* Array of indexes that must not exist
*/
$checkMissing = [
'type' => 'error'
];
foreach($checks as $key => $value) {
if(!isset($output[$key])) {
return false;
}
}
return true;
}
/**
* Get a percentage rate of failure by days
*
* @param integer $days number of days to get rate for
* @return integer percentage fail rate
*/
public static function failureRate(int $days)
{
$ttl = Carbon::now()->addDays(1);
$rate = Cache::remember('failure-rate-' . $days, $ttl, function () use ($days) {
$range = [
Carbon::today()
];
for($i = 0; $i < ($days - 1); $i++) {
$prev = end($range);
$new = $prev->copy()->subDays(1);
array_push($range, $new);
}
$rate = [];
foreach($range as $day) {
$success = Speedtest::select(DB::raw('COUNT(id) as rate'))->whereDate('created_at', $day)->where('failed', false)->get()[0]['rate'];
$fail = Speedtest::select(DB::raw('COUNT(id) as rate'))->whereDate('created_at', $day)->where('failed', true)->get()[0]['rate'];
array_push($rate, [
'date' => $day->toDateString(),
'success' => $success,
'failure' => $fail,
]);
}
return array_reverse($rate);
});
return $rate;
}
/**
* Create a backup of the SQLite database
*
* @return null|boolean
*/
public static function dbBackup()
{
if(env('DB_CONNECTION') === 'sqlite') {
if(env('DB_DATABASE') !== null) {
$current = env('DB_DATABASE');
try {
if(File::copy($current, $current . '.bak')) {
return true;
}
}catch(Exception $e) {
return false;
}
}
return false;
}
return null;
}
/**
* Delete all speedtests from the database
*
* @return array
*/
public static function deleteAll()
{
Cache::flush();
SpeedtestHelper::dbBackup();
if(sizeof(Speedtest::whereNotNull('id')->get()) > 0) {
if(Speedtest::whereNotNull('id')->delete()) {
return [
'success' => true,
];
}
}
return [
'success' => true,
];
}
/**
* Work out if a test is lower than the threshold for historic tests
*
* @param String $type
* @param Speedtest $test
* @return array
*/
public static function testIsLowerThanThreshold(String $type, Speedtest $test)
{
if($type == 'percentage') {
$avg = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload'))
->where('failed', false)
->get()
->toArray()[0];
$threshold = SettingsHelper::get('threshold_alert_percentage')->value;
if($threshold == '') {
return [];
}
$errors = [];
foreach($avg as $key => $value) {
if($key == 'ping') {
$threshold = (float)$value * (1 + ( $threshold / 100 ));
if($test->$key > $threshold) {
array_push($errors, $key);
}
} else {
$threshold = (float)$value * (1 - ( $threshold / 100 ));
if($test->$key < $threshold) {
array_push($errors, $key);
}
}
}
return $errors;
}
if($type == 'absolute') {
$thresholds = [
'download' => SettingsHelper::get('threshold_alert_absolute_download')->value,
'upload' => SettingsHelper::get('threshold_alert_absolute_upload')->value,
'ping' => SettingsHelper::get('threshold_alert_absolute_ping')->value,
];
$errors = [];
foreach($thresholds as $key => $value) {
if($value == '') {
continue;
}
if($key == 'ping') {
if($test->$key > $value) {
array_push($errors, $key);
}
} else {
if($test->$key < $value) {
array_push($errors, $key);
}
}
}
return $errors;
}
throw new InvalidArgumentException();
}
}

View File

@@ -2,14 +2,14 @@
namespace App\Http\Controllers;
use App\Models\Auth\EmailVerification;
use App\Models\Auth\LoginSession as AuthLoginSession;
use App\Auth\EmailVerification;
use App\Auth\LoginSession as AuthLoginSession;
use App\Helpers\EmailVerificationHelper;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\LoginSession;
use App\Rules\CurrentPasswordMatches;
use App\Models\User;
use App\User;
use DateTime;
use Hash;
use Illuminate\Support\Facades\Request as RequestFacade;

View File

@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
use App\Helpers\SettingsHelper;
use App\Rules\Cron;
use App\Models\Setting;
use App\Setting;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;

View File

@@ -0,0 +1,227 @@
<?php
namespace App\Http\Controllers;
use App\Helpers\SettingsHelper;
use App\Helpers\SpeedtestHelper;
use App\Jobs\SpeedtestJob;
use App\Speedtest;
use Carbon\Carbon;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\JsonResponse;
class SpeedtestController extends Controller
{
public function __construct()
{
if ((bool)SettingsHelper::get('auth')->value === true) {
$this->middleware('auth:api')
->only(['run', 'delete', 'deleteAll']);
}
}
/**
* Returns paginated list of speedtests
*
* @return JsonResponse
*/
public function index()
{
$data = Speedtest::orderBy('created_at', 'desc')
->paginate();
return response()->json([
'method' => 'index of speedtests',
'data' => $data,
], 200);
}
/**
* Returns speedtest going back 'x' days
*
* @param int $days
* @return JsonResponse
*/
public function time($days)
{
$rule = [
'days' => ['required', 'integer'],
];
$validator = Validator::make(['days' => $days], $rule);
if ($validator->fails()) {
return response()->json([
'method' => 'get speedtests in last x days',
'error' => $validator->errors(),
], 422);
}
$ttl = Carbon::now()->addDays(1);
$data = Cache::remember('speedtest-days-' . $days, $ttl, function () use ($days) {
$showFailed = (bool)SettingsHelper::get('show_failed_tests_on_graph')->value;
if ($showFailed === true) {
return Speedtest::where('created_at', '>=', Carbon::now()->subDays($days))
->orderBy('created_at', 'asc')
->get();
}
return Speedtest::where('created_at', '>=', Carbon::now()->subDays($days))
->where('failed', false)
->orderBy('created_at', 'asc')
->get();
});
return response()->json([
'method' => 'get speedtests in last x days',
'days' => $days,
'data' => $data
], 200);
}
/**
* Returns speedtest failure rate going back 'x' days
*
* @param int $days
* @return JsonResponse
*/
public function fail($days)
{
$rule = [
'days' => ['required', 'integer'],
];
$validator = Validator::make(['days' => $days], $rule);
if ($validator->fails()) {
return response()->json([
'method' => 'get speedtests in last x days',
'error' => $validator->errors(),
], 422);
}
$data = SpeedtestHelper::failureRate($days);
return response()->json([
'method' => 'get speedtests in last x days',
'days' => $days,
'data' => $data
], 200);
}
/**
* Return latest speedtest
*
* @return JsonResponse
*/
public function latest()
{
$data = SpeedtestHelper::latest();
$response = [
'method' => 'get latest speedtest',
'data' => $data,
];
if (SettingsHelper::get('show_average')) {
$avg = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload'))
->where('failed', false)
->first()
->toArray();
$response['average'] = $avg;
}
if (SettingsHelper::get('show_max')) {
$max = Speedtest::select(DB::raw('MAX(ping) as ping, MAX(download) as download, MAX(upload) as upload'))
->where('failed', false)
->first()
->toArray();
$response['maximum'] = $max;
}
if (SettingsHelper::get('show_min')) {
$min = Speedtest::select(DB::raw('MIN(ping) as ping, MIN(download) as download, MIN(upload) as upload'))
->where('failed', false)
->first()
->toArray();
$response['minimum'] = $min;
}
if ($data) {
return response()->json($response, 200);
} else {
return response()->json([
'method' => 'get latest speedtest',
'error' => 'no speedtests have been run'
], 404);
}
}
/**
* Queue a new speedtest
*
* @return JsonResponse
*/
public function run()
{
try {
SettingsHelper::loadIntegrationConfig();
$data = SpeedtestJob::dispatch(false, config('integrations'));
return response()->json([
'method' => 'run speedtest',
'data' => 'a new speedtest has been added to the queue'
], 200);
} catch (Exception $e) {
return response()->json([
'method' => 'run speedtest',
'error' => $e
], 500);
}
}
/**
* Delete all speedtests from db
*
* @return JsonResponse
*/
public function deleteAll()
{
$ret = SpeedtestHelper::deleteAll();
if ($ret['success']) {
return response()->json([
'method' => 'delete all speedtests from the database',
'success' => true
], 200);
}
return response()->json([
'method' => 'delete all speedtests from the database',
'success' => false,
'error' => $ret['msg'],
], 500);
}
/**
* Delete a specific speedtest from the database
*
* @param Speedtest $speedtest
* @return JsonResponse
*/
public function delete(Speedtest $speedtest)
{
$speedtest->delete();
Cache::flush();
return response()->json([
'method' => 'delete a speedtest from the database',
'success' => true,
], 200);
}
}

View File

@@ -2,7 +2,7 @@
namespace App\Http\Middleware;
use App\Models\Auth\LoginSession;
use App\Auth\LoginSession;
use Closure;
use Exception;

Some files were not shown because too many files have changed in this diff Show More