diff --git a/.github/workflows/1_dev.yml b/.github/workflows/1_dev.yml index bd650878..7b00d255 100644 --- a/.github/workflows/1_dev.yml +++ b/.github/workflows/1_dev.yml @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - uses: actions/setup-node@v1 with: - node-version: 12.18.2 + node-version: 16.14.0 - name: Set Version run: | @@ -63,7 +63,7 @@ jobs: arch: [386, amd64, arm-7, arm-6, arm64] include: - platform: darwin - arch: 386 + arch: arm64 - platform: darwin arch: amd64 - platform: windows @@ -92,7 +92,7 @@ jobs: echo "XGO_TAGS=netgo osusergo linux sqlite_omit_load_extension" >> $GITHUB_ENV shell: bash - - name: Set Darwin Build Flags + - name: Set MacOS (Darwin) Build Flags if: matrix.platform == 'darwin' run : | echo "XGO_TAGS=netgo osusergo darwin sqlite_omit_load_extension" >> $GITHUB_ENV @@ -112,7 +112,7 @@ jobs: COMMIT: ${{ github.sha }} with: xgo_version: latest - go_version: 1.15.x + go_version: 1.17.x dest: build prefix: statping targets: ${{ matrix.platform }}/${{ matrix.arch }} @@ -137,43 +137,22 @@ jobs: if: matrix.platform == 'windows' run: | cd build - mv statping-windows-4.0-${{ matrix.arch }}.exe statping.exe + mv statping-windows-${{ matrix.arch }}.exe statping.exe chmod +x statping.exe zip statping-windows-${{ matrix.arch }}.zip statping.exe rm -rf statping.exe echo "compressed=statping-windows-${{ matrix.arch }}.zip" >> $GITHUB_ENV - - name: Compress Darwin 32bit Builds - if: matrix.platform == 'darwin' && matrix.arch == '386' + - name: Compress MacOS (Darwin) Builds + if: matrix.platform == 'darwin' run: | cd build - ls >> $GITHUB_ENV -# mv statping-darwin-10.6-${{ matrix.arch }} statping -# chmod +x statping -# tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz * -# rm -rf statping -# echo "compressed=statping-darwin-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV - - - name: Compress Darwin 64bit Builds - if: matrix.platform == 'darwin' && matrix.arch == 'amd64' - run: | - cd build - mv statping-darwin-10.12-${{ matrix.arch }} statping + mv statping-darwin-${{ matrix.arch }} statping chmod +x statping - tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz statping + tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz * rm -rf statping echo "compressed=statping-darwin-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV -# - name: Compress Darwin arm64 Builds -# if: matrix.platform == 'darwin' && matrix.arch == 'arm64' -# run: | -# cd build -# mv statping-darwin-10.15-${{ matrix.arch }} statping -# chmod +x statping -# tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz statping -# rm -rf statping -# echo "compressed=statping-darwin-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV - - name: Upload Compiled Statping Binary uses: actions/upload-artifact@v1 with: @@ -207,10 +186,10 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - uses: actions/setup-node@v1 with: - node-version: 12.18.2 + node-version: 16.14.0 - name: Install Global Dependencies run: npm install -g yarn sass newman cross-env wait-on @sentry/cli @@ -218,7 +197,7 @@ jobs: - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash @@ -262,7 +241,7 @@ jobs: MOBILE_NUMBER: ${{ secrets.MOBILE_NUMBER }} PUSHOVER_TOKEN: ${{ secrets.PUSHOVER_TOKEN }} PUSHOVER_API: ${{ secrets.PUSHOVER_API }} - SLACK_URL: ${{ secrets.SLACK_URL }} + SLACK_URL: https://hooks.slack.com/services/TTJ1B90DP/RENU20O9M/9uI823SUnYBuGcxYlpSimD6H TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} TELEGRAM_CHANNEL: ${{ secrets.TELEGRAM_CHANNEL }} TWILIO_SID: ${{ secrets.TWILIO_SID }} @@ -277,12 +256,12 @@ jobs: SNS_REGION: ${{ secrets.SNS_REGION }} SNS_TOPIC: ${{ secrets.SNS_TOPIC }} - - name: Coveralls Testing Coverage - run: | - go get github.com/mattn/goveralls - goveralls -coverprofile=coverage.out -repotoken $COVERALLS - env: - COVERALLS: ${{ secrets.COVERALLS }} +# - name: Coveralls Testing Coverage +# run: | +# go get github.com/mattn/goveralls +# goveralls -coverprofile=coverage.out -repotoken $COVERALLS +# env: +# COVERALLS: ${{ secrets.COVERALLS }} test-postman-sqlite: needs: frontend @@ -291,12 +270,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash @@ -345,12 +324,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash @@ -402,12 +381,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash diff --git a/.github/workflows/2_unstable.yml b/.github/workflows/2_unstable.yml index a4150490..7fd72300 100644 --- a/.github/workflows/2_unstable.yml +++ b/.github/workflows/2_unstable.yml @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - uses: actions/setup-node@v1 with: - node-version: 12.18.2 + node-version: 16.14.0 - name: Set Version run: | @@ -55,13 +55,15 @@ jobs: path: ./source build: - needs: [frontend, test-postman-sqlite, test-postman-mysql, test-postman-postgres] + needs: frontend runs-on: ubuntu-latest strategy: matrix: platform: [linux] arch: [386, amd64, arm-7, arm-6, arm64] include: + - platform: darwin + arch: arm64 - platform: darwin arch: amd64 - platform: windows @@ -90,9 +92,10 @@ jobs: echo "XGO_TAGS=netgo osusergo linux sqlite_omit_load_extension" >> $GITHUB_ENV shell: bash - - name: Set Darwin Build Flags + - name: Set MacOS (Darwin) Build Flags if: matrix.platform == 'darwin' - run: echo "XGO_TAGS=netgo osusergo darwin sqlite_omit_load_extension" >> $GITHUB_ENV + run : | + echo "XGO_TAGS=netgo osusergo darwin sqlite_omit_load_extension" >> $GITHUB_ENV shell: bash - name: Set Windows Build Flags @@ -109,12 +112,12 @@ jobs: COMMIT: ${{ github.sha }} with: xgo_version: latest - go_version: 1.15.x + go_version: 1.17.x dest: build prefix: statping targets: ${{ matrix.platform }}/${{ matrix.arch }} - v: false - x: false + v: true + x: true pkg: cmd buildmode: pie tags: ${{ env.XGO_TAGS }} @@ -134,22 +137,22 @@ jobs: if: matrix.platform == 'windows' run: | cd build - mv statping-windows-4.0-${{ matrix.arch }}.exe statping.exe + mv statping-windows-${{ matrix.arch }}.exe statping.exe chmod +x statping.exe zip statping-windows-${{ matrix.arch }}.zip statping.exe rm -rf statping.exe echo "compressed=statping-windows-${{ matrix.arch }}.zip" >> $GITHUB_ENV - - name: Compress Darwin Builds + - name: Compress MacOS (Darwin) Builds if: matrix.platform == 'darwin' run: | cd build - mv statping-darwin-10.12-${{ matrix.arch }} statping + mv statping-darwin-${{ matrix.arch }} statping chmod +x statping - tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz statping + tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz * rm -rf statping echo "compressed=statping-darwin-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV - + - name: Upload Compiled Statping Binary uses: actions/upload-artifact@v1 with: @@ -168,7 +171,6 @@ jobs: prerelease: true files: build/${{ env.compressed }} - # test: # needs: frontend # runs-on: [self-hosted, linux, aboutcher-hosted] @@ -196,10 +198,10 @@ jobs: # - uses: actions/checkout@v2 # - uses: actions/setup-go@v2 # with: -# go-version: 1.15.x +# go-version: 1.17.x # - uses: actions/setup-node@v1 # with: -# node-version: 12.18.2 +# node-version: 16.14.0 # - name: Install Global Dependencies # run: npm install -g yarn sass newman cross-env wait-on @sentry/cli @@ -207,7 +209,7 @@ jobs: # - name: Setting ENV's # run: | # echo "$(go env GOPATH)/bin" >> $GITHUB_PATH -# echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH +# echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH # echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV # shell: bash @@ -280,12 +282,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash @@ -334,12 +336,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash @@ -391,12 +393,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash diff --git a/.github/workflows/3_stable.yml b/.github/workflows/3_stable.yml index 84b57059..c92e0963 100644 --- a/.github/workflows/3_stable.yml +++ b/.github/workflows/3_stable.yml @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - uses: actions/setup-node@v1 with: - node-version: 12.18.2 + node-version: 16.14.0 - name: Set Version run: | @@ -75,6 +75,8 @@ jobs: platform: [linux] arch: [386, amd64, arm-7, arm-6, arm64] include: + - platform: darwin + arch: arm64 - platform: darwin arch: amd64 - platform: windows @@ -110,7 +112,7 @@ jobs: echo "XGO_TAGS=netgo osusergo linux sqlite_omit_load_extension" >> $GITHUB_ENV shell: bash - - name: Set Darwin Build Flags + - name: Set MacOS (Darwin) Build Flags if: matrix.platform == 'darwin' run: echo "XGO_TAGS=netgo osusergo darwin sqlite_omit_load_extension" >> $GITHUB_ENV shell: bash @@ -129,7 +131,7 @@ jobs: COMMIT: ${{ github.sha }} with: xgo_version: latest - go_version: 1.15.x + go_version: 1.17.x dest: build prefix: statping targets: ${{ matrix.platform }}/${{ matrix.arch }} @@ -154,17 +156,17 @@ jobs: if: matrix.platform == 'windows' run: | cd build - mv statping-windows-4.0-${{ matrix.arch }}.exe statping.exe + mv statping-windows-${{ matrix.arch }}.exe statping.exe chmod +x statping.exe zip statping-windows-${{ matrix.arch }}.zip statping.exe rm -rf statping.exe echo "compressed=statping-windows-${{ matrix.arch }}.zip" >> $GITHUB_ENV - - name: Compress Darwin Builds + - name: Compress MacOS (Darwin) Builds if: matrix.platform == 'darwin' run: | cd build - mv statping-darwin-10.12-${{ matrix.arch }} statping + mv statping-darwin-${{ matrix.arch }} statping chmod +x statping tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz statping rm -rf statping @@ -219,10 +221,10 @@ jobs: # - uses: actions/checkout@v2 # - uses: actions/setup-go@v2 # with: -# go-version: 1.15.x +# go-version: 1.17.x # - uses: actions/setup-node@v1 # with: -# node-version: 12.18.2 +# node-version: 16.14.0 # # - name: Install Global Dependencies # run: npm install -g yarn sass newman cross-env wait-on @sentry/cli @@ -230,7 +232,7 @@ jobs: # - name: Setting ENV's # run: | # echo "$(go env GOPATH)/bin" >> $GITHUB_PATH -# echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH +# echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH # echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV # shell: bash # @@ -303,12 +305,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash @@ -357,12 +359,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash @@ -414,12 +416,12 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.x + go-version: 1.17.x - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 02777270..30cd68c1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -20,10 +20,10 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: '1.14.2' + go-version: '1.17.8' - uses: actions/setup-node@v1 with: - node-version: '12.18.2' + node-version: '16.14.0' - uses: actions/checkout@v2 - name: Add GOBIN to PATH @@ -86,7 +86,7 @@ jobs: go-version: 1.15.x - uses: actions/setup-node@v1 with: - node-version: 12.18.2 + node-version: 16.14.0 - uses: actions/checkout@v2 - name: Install Global Dependencies @@ -97,7 +97,7 @@ jobs: - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash @@ -140,7 +140,7 @@ jobs: - name: Setting ENV's run: | echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - echo "/opt/hostedtoolcache/node/12.18.2/x64/bin" >> $GITHUB_PATH + echo "/opt/hostedtoolcache/node/16.14.0/x64/bin" >> $GITHUB_PATH echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV shell: bash diff --git a/CHANGELOG.md b/CHANGELOG.md index b80f70fe..08a08ecc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# 0.90.80 (01-26-2022) +- Fixed permissions on /app directory - Thanks twouters + +# 0.90.79 (01-24-2022) +- Updated Russian Language - Thanks meatlayer +- Docker file fix for BASE_PATH and health checks - Thanks michaelkrieger +- Removed statping emailer notifier (not SMTP Mail) +- Fixes for notification failures (Issue statping#911) - Thanks glanchow +- Updated Home page uptime wording (24hr/7days) - Thanks Jonathanrbarney & thatInfrastructureGuy +- [GITHUB] Removed mailer tests + # 0.90.78 (09-15-2021) - HTTP Webhooks accept multiple HTTP Headers - Modified Telegram notifier to allow chat_ids diff --git a/Dockerfile b/Dockerfile index ca503f78..6997cc18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:12.18.2-alpine AS frontend +FROM node:16.14.0-alpine AS frontend LABEL maintainer="Statping-ng (https://github.com/statping-ng)" ARG BUILDPLATFORM WORKDIR /statping @@ -10,7 +10,7 @@ RUN yarn build && yarn cache clean # Statping Golang BACKEND building from source # Creates "/go/bin/statping" and "/usr/local/bin/sass" for copying -FROM golang:1.14-alpine AS backend +FROM golang:1.17-alpine AS backend LABEL maintainer="Statping-NG (https://github.com/statping-ng)" ARG VERSION ARG COMMIT @@ -60,9 +60,10 @@ ENV IS_DOCKER=true ENV SASS=/usr/local/bin/sassc ENV STATPING_DIR=/app ENV PORT=8080 +ENV BASE_PATH="" EXPOSE $PORT -HEALTHCHECK --interval=60s --timeout=10s --retries=3 CMD curl -s "http://localhost:$PORT/health" | jq -r -e ".online==true" +HEALTHCHECK --interval=60s --timeout=10s --retries=3 CMD if [ -z "$BASE_PATH" ]; then HEALTHPATH="/health"; else HEALTHPATH="/$BASE_PATH/health" ; fi && curl -s "http://localhost:80$HEALTHPATH" | jq -r -e ".online==true" CMD statping --port $PORT diff --git a/Makefile b/Makefile index dc155dcc..ef78a2c5 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,13 @@ COMMIT=$(shell git rev-parse HEAD) SIGN_KEY=B76D61FAA6DB759466E83D9964B9C6AAE2D55278 BINARY_NAME=statping GOBUILD=go build -a -GOVERSION=1.14.0 -NODE_VERSION=12.18.2 +GOVERSION=1.17.8 +NODE_VERSION=16.14.0 XGO=xgo -go $(GOVERSION) --dest=build BUILDVERSION=-ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT}" TRVIS_SECRET=O3/2KTOV8krv+yZ1EB/7D1RQRe6NdpFUEJNJkMS/ollYqmz3x2mCO7yIgIJKCKguLXZxjM6CxJcjlCrvUwibL+8BBp7xJe4XFIOrjkPvbbVPry4HkFZCf2GfcUK6o4AByQ+RYqsW2F17Fp9KLQ1rL3OT3eLTwCAGKx3tlY8y+an43zkmo5dN64V6sawx26fh6XTfww590ey+ltgQTjf8UPNup2wZmGvMo9Hwvh/bYR/47bR6PlBh6vhlKWyotKf2Fz1Bevbu0zc35pee5YlsrHR+oSF+/nNd/dOij34BhtqQikUR+zQVy9yty8SlmneVwD3yOENvlF+8roeKIXb6P6eZnSMHvelhWpAFTwDXq2N3d/FIgrQtLxsAFTI3nTHvZgs6OoTd6dA0wkhuIGLxaL3FOeztCdxP5J/CQ9GUcTvifh5ArGGwYxRxQU6rTgtebJcNtXFISP9CEUR6rwRtb6ax7h6f1SbjUGAdxt+r2LbEVEk4ZlwHvdJ2DtzJHT5DQtLrqq/CTUgJ8SJFMkrJMp/pPznKhzN4qvd8oQJXygSXX/gz92MvoX0xgpNeLsUdAn+PL9KketfR+QYosBz04d8k05E+aTqGaU7FUCHPTLwlOFvLD8Gbv0zsC/PWgSLXTBlcqLEz5PHwPVHTcVzspKj/IyYimXpCSbvu1YOIjyc= PUBLISH_BODY='{ "request": { "branch": "master", "message": "Homebrew update version v${VERSION}", "config": { "env": { "VERSION": "${VERSION}", "COMMIT": "$(TRAVIS_COMMIT)" } } } }' -TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master for Statping v${VERSION}", "config": { "merge_mode": "replace", "language": "go", "go": 1.14, "install": true, "sudo": "required", "services": ["docker"], "env": { "secure": "${TRVIS_SECRET}" }, "before_deploy": ["git config --local user.name \"hunterlong\"", "git config --local user.email \"info@socialeck.com\"", "git tag v$(VERSION) --force"], "deploy": [{ "provider": "releases", "api_key": "$$GITHUB_TOKEN", "file_glob": true, "file": "build/*", "skip_cleanup": true, "on": { "branch": "master" } }], "before_script": ["rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install stable", "nvm install 10.17.0", "nvm use 10.17.0 --default", "npm install -g sass yarn cross-env", "pip install --user awscli"], "script": ["make release"], "after_success": [], "after_deploy": ["make post-release"] } } }' +TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master for Statping v${VERSION}", "config": { "merge_mode": "replace", "language": "go", "go": 1.17, "install": true, "sudo": "required", "services": ["docker"], "env": { "secure": "${TRVIS_SECRET}" }, "before_deploy": ["git config --local user.name \"hunterlong\"", "git config --local user.email \"info@socialeck.com\"", "git tag v$(VERSION) --force"], "deploy": [{ "provider": "releases", "api_key": "$$GITHUB_TOKEN", "file_glob": true, "file": "build/*", "skip_cleanup": true, "on": { "branch": "master" } }], "before_script": ["rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install stable", "nvm install 16.14.0", "nvm use 16.14.0 --default", "npm install -g sass yarn cross-env", "pip install --user awscli"], "script": ["make release"], "after_success": [], "after_deploy": ["make post-release"] } } }' TEST_DIR=$(GOPATH)/src/github.com/statping-ng/statping-ng PATH:=$(GOPATH)/bin:$(PATH) OS = freebsd linux openbsd @@ -37,16 +37,16 @@ lint: goimports ./... up: - docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml up -d --remove-orphans + docker compose -f docker-compose.yml -f dev/docker-compose.full.yml up -d --remove-orphans make print_details down: - docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml down --volumes --remove-orphans + docker compose -f docker-compose.yml -f dev/docker-compose.full.yml down --volumes --remove-orphans lite: clean docker build -t statping-ng/statping-ng:dev -f dev/Dockerfile.dev . - docker-compose -f dev/docker-compose.lite.yml down - docker-compose -f dev/docker-compose.lite.yml up --remove-orphans + docker compose -f dev/docker-compose.lite.yml down + docker compose -f dev/docker-compose.lite.yml up --remove-orphans reup: down clean compose-build-full up @@ -94,37 +94,37 @@ go-run: go run ./cmd start: - docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml start + docker compose -f docker-compose.yml -f dev/docker-compose.full.yml start stop: - docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml stop + docker compose -f docker-compose.yml -f dev/docker-compose.full.yml stop logs: docker logs statping --follow db-up: - docker-compose -f dev/docker-compose.db.yml up -d --remove-orphans + docker compose -f dev/docker-compose.db.yml up -d --remove-orphans db-down: - docker-compose -f dev/docker-compose.db.yml down --volumes --remove-orphans + docker compose -f dev/docker-compose.db.yml down --volumes --remove-orphans console: docker exec -t -i statping /bin/sh -compose-build-full: - docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml build --parallel --build-arg VERSION=${VERSION} +compose-build-full: + docker compose -f docker-compose.yml -f dev/docker-compose.full.yml build --parallel --build-arg VERSION=${VERSION} -docker-latest: +docker-latest: docker build -t statping-ng/statping-ng:latest --build-arg VERSION=${VERSION} . docker-test: - docker-compose -f docker-compose.test.yml up --remove-orphans + docker compose -f docker-compose.test.yml up --remove-orphans modd: modd -f ./dev/modd.conf top: - docker-compose -f docker-compose.yml -f dev/docker-compose.full.yml top + docker compose -f docker-compose.yml -f dev/docker-compose.full.yml top frontend-build: @echo "Removing old frontend distributions..." @@ -382,7 +382,7 @@ delve: check: @echo "Checking the programs required for the build are installed..." - @echo "go: $(shell go version) - $(shell which go)" && go version >/dev/null 2>&1 || (echo "ERROR: go 1.14 is required."; exit 1) + @echo "go: $(shell go version) - $(shell which go)" && go version >/dev/null 2>&1 || (echo "ERROR: go 1.17 is required."; exit 1) @echo "node: $(shell node --version) - $(shell which node)" && node --version >/dev/null 2>&1 || (echo "ERROR: node 12.x is required."; exit 1) @echo "yarn: $(shell yarn --version) - $(shell which yarn)" && yarn --version >/dev/null 2>&1 || (echo "ERROR: yarn is required."; exit 1) @echo "All required programs are installed!" diff --git a/dev/docker-compose.full.m1.yml b/dev/docker-compose.full.m1.yml new file mode 100644 index 00000000..8f38b386 --- /dev/null +++ b/dev/docker-compose.full.m1.yml @@ -0,0 +1,275 @@ +version: '2.3' + + +############################################### +# Statping Full Stack +# +# Statping SQLIte => http://localhost:8080 +# Statping MySQL => http://localhost:8081 +# Statping Postgres => http://localhost:8082 +# Statping MariaDB => http://localhost:8083 +# +# Adminer => http://localhost:8282 +# Prometheus => http://localhost:7050 +# Grafana => http://localhost:3000 +# +# MySQL => http://localhost:3306 +# Postgres => http://localhost:5432 +# MariaDB => http://localhost:3307 +# +############################################### + +services: + + statping_sqlite: + container_name: statping_sqlite + platform: linux/amd64 + build: + context: ./ + restart: on-failure + volumes: + - ./dev/docker/statping/sqlite:/app + - ./dev/services.yml:/app/services.yml + environment: + DB_CONN: sqlite + API_SECRET: exampleapisecret + NAME: Statping + DOMAIN: http://localhost:8084 + DESCRIPTION: This is a dev environment on SQLite! + ADMIN_USER: admin + ADMIN_PASSWORD: admin + SAMPLE_DATA: 'false' + ports: + - 8084:8080 + networks: + - database + - frontend + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] + timeout: 2s + interval: 10s + retries: 20 + + statping_mysql: + container_name: statping_mysql + platform: linux/amd64 + build: + context: ./ + restart: on-failure + volumes: + - ./dev/docker/statping/mysql:/app + - ./dev/services.yml:/app/services.yml + environment: + DB_CONN: mysql + DB_HOST: mysql + DB_USER: root + DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 3306 + API_SECRET: exampleapisecret + NAME: Statping MySQL + DOMAIN: http://localhost:8081 + DESCRIPTION: This is a dev environment on MySQL! + ADMIN_USER: admin + ADMIN_PASSWORD: admin + SAMPLE_DATA: 'false' + ports: + - 8081:8080 + networks: + - database + - frontend + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] + timeout: 2s + interval: 10s + retries: 20 + depends_on: + mysql: + condition: service_healthy + + statping_postgres: + container_name: statping_postgres + platform: linux/amd64 + build: + context: ./ + restart: on-failure + volumes: + - ./dev/docker/statping/mysql:/app + - ./dev/services.yml:/app/services.yml + environment: + DB_CONN: postgres + DB_HOST: postgres + DB_USER: root + DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 5432 + API_SECRET: exampleapisecret + NAME: Statping Postgres + DOMAIN: http://localhost:8082 + DESCRIPTION: This is a dev environment on Postgres! + ADMIN_USER: admin + ADMIN_PASSWORD: admin + SAMPLE_DATA: 'false' + ports: + - 8082:8080 + networks: + - database + - frontend + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] + timeout: 2s + interval: 10s + retries: 20 + depends_on: + postgres: + condition: service_healthy + + statping_mariadb: + container_name: statping_mariadb + platform: linux/amd64 + build: + context: ./ + restart: on-failure + volumes: + - ./dev/docker/statping/mariadb:/app + - ./dev/services.yml:/app/services.yml + environment: + DB_CONN: mysql + DB_HOST: mariadb + DB_USER: root + DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 3306 + API_SECRET: exampleapisecret + NAME: Statping MariaDB + DOMAIN: http://localhost:8083 + DESCRIPTION: This is a dev environment on MariaDB! + ADMIN_USER: admin + ADMIN_PASSWORD: admin + SAMPLE_DATA: 'false' + ports: + - 8083:8080 + networks: + - database + - frontend + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] + timeout: 2s + interval: 10s + retries: 20 + depends_on: + mariadb: + condition: service_healthy + + postgres: + container_name: postgres + image: postgres + volumes: + - ./dev/docker/databases/postgres:/var/lib/postgresql/data + ports: + - 5432:5432 + environment: + POSTGRES_PASSWORD: password123 + POSTGRES_DB: statping + POSTGRES_USER: root + networks: + - database + healthcheck: + test: ["CMD-SHELL", "pg_isready -U root"] + interval: 15s + timeout: 10s + retries: 20 + + mysql: + container_name: mysql + image: mysql:5.7 + volumes: + - ./dev/docker/databases/mysql:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: password123 + MYSQL_DATABASE: statping + ports: + - 3306:3306 + networks: + - database + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + timeout: 20s + interval: 15s + retries: 30 + + mariadb: + container_name: mariadb + image: mariadb + volumes: + - ./dev/docker/databases/mariadb:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: password123 + MYSQL_DATABASE: statping + ports: + - 3307:3306 + networks: + - database + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + timeout: 20s + interval: 15s + retries: 30 + + adminer: + container_name: adminer + image: adminer + restart: always + networks: + - database + - frontend + ports: + - 8282:8080 + + prometheus: + container_name: prometheus + platform: linux/amd64 + image: prom/prometheus:v2.0.0 + restart: on-failure + volumes: + - ./dev/prometheus.yml:/etc/prometheus/prometheus.yml + - ./dev/docker/databases/prometheus:/prometheus + ports: + - 7050:9090 + networks: + - database + healthcheck: + test: "/bin/wget -q -Y off http://localhost:9090/status -O /dev/null > /dev/null 2>&1" + interval: 10s + timeout: 3s + + grafana: + container_name: grafana + image: grafana/grafana + restart: on-failure + ports: + - 3000:3000 + volumes: + - ./dev/docker/grafana:/var/lib/grafana + - ./dev/grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml + - ./dev/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml + - ./dev/grafana/statping_dashboard.json:/etc/grafana/provisioning/dashboards/statping_dashboard.json + environment: + - GF_USERS_ALLOW_SIGN_UP=false + - GF_AUTH_ANONYMOUS_ENABLED=true + depends_on: + prometheus: + condition: service_healthy + networks: + - frontend + - database + healthcheck: + test: "/usr/bin/wget -q -Y off http://localhost:3000/api/health -O /dev/null > /dev/null 2>&1" + interval: 10s + retries: 20 + +networks: + frontend: + database: diff --git a/dev/docker-compose.full.yml b/dev/docker-compose.full.yml index 740c75b8..fde6b0bb 100644 --- a/dev/docker-compose.full.yml +++ b/dev/docker-compose.full.yml @@ -24,11 +24,11 @@ services: statping_sqlite: container_name: statping_sqlite build: - context: ../ + context: ./ restart: on-failure volumes: - - ./docker/statping/sqlite:/app - - ./services.yml:/app/services.yml + - ./dev/docker/statping/sqlite:/app + - ./dev/services.yml:/app/services.yml environment: DB_CONN: sqlite API_SECRET: exampleapisecret @@ -39,7 +39,7 @@ services: ADMIN_PASSWORD: admin SAMPLE_DATA: 'false' ports: - - 8080:8080 + - 8084:8080 networks: - database - frontend @@ -52,11 +52,11 @@ services: statping_mysql: container_name: statping_mysql build: - context: ../ + context: ./ restart: on-failure volumes: - - ./docker/statping/mysql:/app - - ./services.yml:/app/services.yml + - ./dev/docker/statping/mysql:/app + - ./dev/services.yml:/app/services.yml environment: DB_CONN: mysql DB_HOST: mysql @@ -88,11 +88,11 @@ services: statping_postgres: container_name: statping_postgres build: - context: ../ + context: ./ restart: on-failure volumes: - - ./docker/statping/mysql:/app - - ./services.yml:/app/services.yml + - ./dev/docker/statping/mysql:/app + - ./dev/services.yml:/app/services.yml environment: DB_CONN: postgres DB_HOST: postgres @@ -124,11 +124,11 @@ services: statping_mariadb: container_name: statping_mariadb build: - context: ../ + context: ./ restart: on-failure volumes: - - ./docker/statping/mariadb:/app - - ./services.yml:/app/services.yml + - ./dev/docker/statping/mariadb:/app + - ./dev/services.yml:/app/services.yml environment: DB_CONN: mysql DB_HOST: mariadb @@ -161,7 +161,7 @@ services: container_name: postgres image: postgres volumes: - - ./docker/databases/postgres:/var/lib/postgresql/data + - ./dev/docker/databases/postgres:/var/lib/postgresql/data ports: - 5432:5432 environment: @@ -180,7 +180,7 @@ services: container_name: mysql image: mysql:5.7 volumes: - - ./docker/databases/mysql:/var/lib/mysql + - ./dev/docker/databases/mysql:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: password123 @@ -201,7 +201,7 @@ services: container_name: mariadb image: mariadb volumes: - - ./docker/databases/mariadb:/var/lib/mysql + - ./dev/docker/databases/mariadb:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: password123 @@ -233,8 +233,8 @@ services: image: prom/prometheus:v2.0.0 restart: on-failure volumes: - - ./prometheus.yml:/etc/prometheus/prometheus.yml - - ./docker/databases/prometheus:/prometheus + - ./dev/prometheus.yml:/etc/prometheus/prometheus.yml + - ./dev/docker/databases/prometheus:/prometheus ports: - 7050:9090 networks: @@ -251,10 +251,10 @@ services: ports: - 3000:3000 volumes: - - ./docker/grafana:/var/lib/grafana - - ./grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml - - ./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml - - ./grafana/statping_dashboard.json:/etc/grafana/provisioning/dashboards/statping_dashboard.json + - ./dev/docker/grafana:/var/lib/grafana + - ./dev/grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml + - ./dev/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml + - ./dev/grafana/statping_dashboard.json:/etc/grafana/provisioning/dashboards/statping_dashboard.json environment: - GF_USERS_ALLOW_SIGN_UP=false - GF_AUTH_ANONYMOUS_ENABLED=true diff --git a/dev/postman.json b/dev/postman.json index 7e11d3fb..cd061232 100644 --- a/dev/postman.json +++ b/dev/postman.json @@ -4205,7 +4205,7 @@ "", "pm.test(\"View All Notifiers\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.length).to.eql(14);", + " pm.expect(jsonData.length).to.eql(13);", "});" ], "type": "text/javascript" diff --git a/frontend/src/API.js b/frontend/src/API.js index 3e62d295..d6e8bad5 100644 --- a/frontend/src/API.js +++ b/frontend/src/API.js @@ -7,8 +7,8 @@ const tokenKey = "statping_auth"; class Api { constructor() { - this.version = "0.90.74"; - this.commit = "df8e1f73d9f7fdf218bc5c26130d7d8a6af6719a"; + this.version = "0.91.0"; + this.commit = "b7ecf0c31b0c75c394061d2f6457a925e4440f1e"; } async oauth() { @@ -275,7 +275,7 @@ class Api { } async github_release() { - return fetch('https://api.github.com/repos/statping/statping/releases/latest').then(response => response.json()) + return fetch('https://api.github.com/repos/statping-ng/statping-ng/releases/latest').then(response => response.json()) } async allActions(...all) { diff --git a/frontend/src/components/Service/ServiceTopStats.vue b/frontend/src/components/Service/ServiceTopStats.vue index 9104b549..0a9a48ef 100644 --- a/frontend/src/components/Service/ServiceTopStats.vue +++ b/frontend/src/components/Service/ServiceTopStats.vue @@ -6,11 +6,11 @@
{{service.online_24_hours}} % - {{$t('last_uptime', [24, $tc('hour', 24)])}} + {{$t('last_uptime')}} 24 {{$tc('hour', 24)}}
{{service.online_7_days}} % - {{$t('last_uptime', [7, $tc('day', 7)])}} + {{$t('last_uptime')}} 7 {{$tc('day', 7)}}
diff --git a/frontend/src/forms/CoreSettings.vue b/frontend/src/forms/CoreSettings.vue index f5f2a71d..ac09e3de 100644 --- a/frontend/src/forms/CoreSettings.vue +++ b/frontend/src/forms/CoreSettings.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/pages/Logs.vue b/frontend/src/pages/Logs.vue index 293f84df..e5536823 100644 --- a/frontend/src/pages/Logs.vue +++ b/frontend/src/pages/Logs.vue @@ -61,7 +61,7 @@ export default { const ts = data.match(/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1]) (2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]/gm) return { time: ts[0], - message: data.split(ts+": ")[1] + message: data.split(ts+": ")[1] || '' } }, cleanLog(l) { diff --git a/frontend/src/pages/Settings.vue b/frontend/src/pages/Settings.vue index bbfc073e..77494623 100644 --- a/frontend/src/pages/Settings.vue +++ b/frontend/src/pages/Settings.vue @@ -46,7 +46,7 @@ -
Statping {{$t('links')}}
+
Statping-ng {{$t('links')}}
Statping-ng @@ -68,7 +68,7 @@ {{$t('repo')}} - Statping v{{core.version}}
+ Statping-ng v{{core.version}}
{{core.commit.slice(0,8)}}
diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 8a3ee963..4887eb6c 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,13 +1,13 @@ module.exports = { - baseUrl: '/', + publicPath: '/', assetsDir: 'assets', filenameHashing: false, - productionTip: process.env.NODE_ENV !== 'production', - devtools: process.env.NODE_ENV !== 'production', - performance: process.env.NODE_ENV !== 'production', + // productionTip: process.env.NODE_ENV !== 'production', + // devtools: process.env.NODE_ENV !== 'production', + // performance: process.env.NODE_ENV !== 'production', devServer: { disableHostCheck: true, - proxyTable: { + proxy: { '/api': { logLevel: 'debug', target: 'http://0.0.0.0:8585', diff --git a/go.mod b/go.mod index 1ef350e1..4e2a4e4d 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/statping-ng/statping-ng -// +heroku goVersion go1.14 -go 1.14 +// +heroku goVersion go1.17 +go 1.17 require ( - github.com/GeertJohan/go.rice v1.0.0 + github.com/GeertJohan/go.rice v1.0.2 github.com/aws/aws-sdk-go v1.30.20 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/fatih/structs v1.1.0 @@ -12,8 +12,7 @@ require ( github.com/foomo/tlsconfig v0.0.0-20180418120404-b67861b076c9 github.com/getsentry/sentry-go v0.5.1 github.com/go-mail/mail v2.3.1+incompatible - github.com/golang/protobuf v1.4.2 // indirect - github.com/google/go-cmp v0.5.1 // indirect + github.com/go-ping/ping v1.1.0 github.com/gorilla/mux v1.7.4 github.com/hako/durafmt v0.0.0-20200605151348-3a43fc422dd9 github.com/jinzhu/gorm v1.9.12 @@ -24,19 +23,110 @@ require ( github.com/spf13/cobra v1.0.0 github.com/spf13/viper v1.6.3 github.com/statping-ng/emails v1.0.3 - github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.6.1 github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1 - go.uber.org/atomic v1.6.0 // indirect - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 - golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449 // indirect - golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d - golang.org/x/text v0.3.3 // indirect - golang.org/x/tools v0.0.0-20201012192620-5bd05386311b // indirect - google.golang.org/appengine v1.6.6 // indirect google.golang.org/grpc v1.28.1 - google.golang.org/protobuf v1.25.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/yaml.v2 v2.3.0 ) + +require ( + cloud.google.com/go v0.56.0 // indirect + github.com/Azure/azure-sdk-for-go v41.3.0+incompatible // indirect + github.com/Azure/go-autorest/autorest v0.10.0 // indirect + github.com/Azure/go-autorest/autorest/adal v0.8.3 // indirect + github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 // indirect + github.com/Azure/go-autorest/autorest/azure/cli v0.3.1 // indirect + github.com/Azure/go-autorest/autorest/date v0.2.0 // indirect + github.com/Azure/go-autorest/autorest/to v0.3.0 // indirect + github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect + github.com/Azure/go-autorest/logger v0.1.0 // indirect + github.com/Azure/go-autorest/tracing v0.5.0 // indirect + github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87 // indirect + github.com/akamai/AkamaiOPEN-edgegrid-golang v0.9.11 // indirect + github.com/aliyun/alibaba-cloud-sdk-go v1.61.131 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cenkalti/backoff/v4 v4.0.2 // indirect + github.com/cloudflare/cloudflare-go v0.11.6 // indirect + github.com/cpu/goacmedns v0.0.2 // indirect + github.com/daaku/go.zipexe v1.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dimchansky/utfbom v1.1.0 // indirect + github.com/dnsimple/dnsimple-go v0.60.0 // indirect + github.com/exoscale/egoscale v0.18.1 // indirect + github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/go-acme/lego/v3 v3.7.0 // indirect + github.com/go-errors/errors v1.0.2 // indirect + github.com/go-resty/resty/v2 v2.2.0 // indirect + github.com/go-sql-driver/mysql v1.5.0 // indirect + github.com/gofrs/uuid v3.2.0+incompatible // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.4.2 // indirect + github.com/google/go-querystring v1.0.0 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/googleapis/gax-go/v2 v2.0.5 // indirect + github.com/gophercloud/gophercloud v0.10.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.1 // indirect + github.com/hashicorp/go-retryablehttp v0.6.6 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jmespath/go-jmespath v0.3.0 // indirect + github.com/json-iterator/go v1.1.9 // indirect + github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b // indirect + github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect + github.com/labbsr0x/bindman-dns-webhook v1.0.2 // indirect + github.com/labbsr0x/goh v1.0.1 // indirect + github.com/lextoumbourou/goodhosts v2.1.0+incompatible // indirect + github.com/lib/pq v1.3.0 // indirect + github.com/linode/linodego v0.14.0 // indirect + github.com/liquidweb/liquidweb-go v1.6.1 // indirect + github.com/magiconair/properties v1.8.1 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/miekg/dns v1.1.29 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/mapstructure v1.2.2 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04 // indirect + github.com/nrdcg/auroradns v1.0.1 // indirect + github.com/nrdcg/dnspod-go v0.4.0 // indirect + github.com/nrdcg/goinwx v0.6.1 // indirect + github.com/nrdcg/namesilo v0.2.1 // indirect + github.com/oracle/oci-go-sdk v17.4.0+incompatible // indirect + github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014 // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible // indirect + github.com/pelletier/go-toml v1.7.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect + github.com/prometheus/common v0.6.0 // indirect + github.com/prometheus/procfs v0.0.3 // indirect + github.com/sacloud/libsacloud v1.36.1 // indirect + github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/cast v1.3.1 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.2.0 // indirect + github.com/timewasted/linode v0.0.0-20160829202747-37e84520dcf7 // indirect + github.com/transip/gotransip/v6 v6.0.2 // indirect + github.com/vultr/govultr v0.3.3 // indirect + go.opencensus.io v0.22.3 // indirect + go.uber.org/ratelimit v0.1.0 // indirect + golang.org/x/net v0.2.0 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/sys v0.2.0 // indirect + golang.org/x/text v0.4.0 // indirect + golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect + google.golang.org/api v0.21.0 // indirect + google.golang.org/appengine v1.6.6 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect + google.golang.org/protobuf v1.25.0 // indirect + gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect + gopkg.in/ini.v1 v1.55.0 // indirect + gopkg.in/ns1/ns1-go.v2 v2.3.0 // indirect + gopkg.in/square/go-jose.v2 v2.5.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +) diff --git a/go.sum b/go.sum index 231daf1e..dec75f9e 100755 --- a/go.sum +++ b/go.sum @@ -74,8 +74,9 @@ github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mo github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= -github.com/GeertJohan/go.rice v1.0.0 h1:KkI6O9uMaQU3VEKaj01ulavtF7o1fWT7+pk/4voiMLQ= github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= +github.com/GeertJohan/go.rice v1.0.2 h1:PtRw+Tg3oa3HYwiDBZyvOJ8LdIyf6lAovJJtr7YOAYk= +github.com/GeertJohan/go.rice v1.0.2/go.mod h1:af5vUNlDNkCjOZeSGFgIJxDje9qdjsO6hshx0gTmZt4= github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -174,8 +175,9 @@ github.com/foomo/simplecert v1.7.5/go.mod h1:RojYROT3nMm8GtJZAPUz0sM5YuSQ/6MIdZv github.com/foomo/tlsconfig v0.0.0-20180418120404-b67861b076c9 h1:RPOsDNbnDUFaSt/3bCxUsaGCJsKqA6dGubevl20nE9g= github.com/foomo/tlsconfig v0.0.0-20180418120404-b67861b076c9/go.mod h1:OdiGKKgTAfMv7x9Hh9qYFueue77tr09LUAxwy2+M8wY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/getsentry/sentry-go v0.5.1 h1:MIPe7ScHADsrK2vznqmhksIUFxq7m0JfTh+ZIMkI+VQ= github.com/getsentry/sentry-go v0.5.1/go.mod h1:B8H7x8TYDPkeWPRzGpIiFO97LZP6rL8A3hEt8lUItMw= @@ -198,6 +200,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-mail/mail v2.3.1+incompatible h1:UzNOn0k5lpfVtO31cK3hn6I4VEVGhe3lX8AJBAxXExM= github.com/go-mail/mail v2.3.1+incompatible/go.mod h1:VPWjmmNyRsWXQZHVHT3g0YbIINUkSmuKOiLIDkWbL6M= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= +github.com/go-ping/ping v1.1.0 h1:3MCGhVX4fyEUuhsfwPrsEdQw6xspHkv5zHsiSoDFZYw= +github.com/go-ping/ping v1.1.0/go.mod h1:xIFjORFzTxqIV/tDVGO4eDy/bLuSyawEeojSm3GfRGk= github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48/go.mod h1:dZGr0i9PLlaaTD4H/hoZIDjQ+r6xq8mgbRzHZf7f2J8= github.com/go-resty/resty/v2 v2.2.0 h1:vgZ1cdblp8Aw4jZj3ZsKh6yKAlMg3CHMrqFSFFd+jgY= github.com/go-resty/resty/v2 v2.2.0/go.mod h1:nYW/8rxqQCmI3bPz9Fsmjbr2FBjGuR2Mzt6kDh3zZ7w= @@ -264,8 +268,10 @@ github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -419,11 +425,11 @@ github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04/go.mod h1:5sN+Lt1CaY github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= +github.com/nkovacs/streamquote v1.0.0/go.mod h1:BN+NaZ2CmdKqUuTUXUEm9j95B2TRbpOWpxbJYzzgUsc= github.com/nrdcg/auroradns v1.0.1 h1:m/kBq83Xvy3cU261MOknd8BdnOk12q4lAWM+kOdsC2Y= github.com/nrdcg/auroradns v1.0.1/go.mod h1:y4pc0i9QXYlFCWrhWrUSIETnZgrf4KuwjDIWmmXo3JI= github.com/nrdcg/dnspod-go v0.4.0 h1:c/jn1mLZNKF3/osJ6mz3QPxTudvPArXTjpkmYj0uK6U= @@ -585,6 +591,7 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDf github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -620,8 +627,9 @@ golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200420201142-3c4aac89819a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -643,7 +651,6 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -653,8 +660,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449 h1:xUIPaMhvROX9dhPvRCenIJtU78+lbEenGbgqB5hfHCQ= golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180611182652-db08ff08e862/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -688,8 +695,12 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA= golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -703,8 +714,11 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180622082034-63fc586f45fe/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -743,14 +757,26 @@ golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c h1:UIcGWL6/wpCfyGuJnRFJRurA+yj8RrW7Q6x2YMCXt6c= golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -796,8 +822,8 @@ golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20201012192620-5bd05386311b h1:Imq6ZJ3mzzAkU1yzH1aHpiF3lTs3ySLzjH8SEfFdW0A= golang.org/x/tools v0.0.0-20201012192620-5bd05386311b/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/handlers/checkin.go b/handlers/checkin.go index 1badb57a..4b5cdbca 100644 --- a/handlers/checkin.go +++ b/handlers/checkin.go @@ -1,13 +1,14 @@ package handlers import ( + "net" + "net/http" + "github.com/gorilla/mux" "github.com/statping-ng/statping-ng/types/checkins" "github.com/statping-ng/statping-ng/types/errors" "github.com/statping-ng/statping-ng/types/services" "github.com/statping-ng/statping-ng/utils" - "net" - "net/http" ) func findCheckin(r *http.Request) (*checkins.Checkin, string, error) { @@ -23,8 +24,9 @@ func findCheckin(r *http.Request) (*checkins.Checkin, string, error) { return checkin, id, nil } -func apiAllCheckinsHandler(w http.ResponseWriter, r *http.Request) { - returnJson(checkins.All(), w, r) +func apiAllCheckinsHandler(r *http.Request) interface{} { + checkins := checkins.All() + return checkins } func apiCheckinHandler(w http.ResponseWriter, r *http.Request) { diff --git a/handlers/handlers.go b/handlers/handlers.go index 33346bac..b143fa5c 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -3,13 +3,13 @@ package handlers import ( "encoding/json" "fmt" - "github.com/statping-ng/statping-ng/types/errors" "html/template" "net/http" "path" "time" "github.com/statping-ng/statping-ng/source" + "github.com/statping-ng/statping-ng/types/errors" "github.com/statping-ng/statping-ng/utils" ) @@ -73,7 +73,11 @@ func IsReadAuthenticated(r *http.Request) bool { if ok := hasAuthorizationHeader(r); ok { return true } - return IsFullAuthenticated(r) + _, err := getJwtToken(r) + if err == nil { + return true + } + return false } // IsFullAuthenticated returns true if the HTTP request is authenticated. You can set the environment variable GO_ENV=test @@ -172,13 +176,24 @@ func ExecuteResponse(w http.ResponseWriter, r *http.Request, file string, data i if err != nil { log.Errorln(err) } - render, err := source.TmplBox.String(file) - if err != nil { - log.Errorln(err) - } - // render the page requested - if _, err := mainTemplate.Parse(render); err != nil { - log.Errorln(err) + + asset := file + if source.UsingAssets(utils.Directory) { + + asset = utils.Directory + "/assets/" + file + + if _, err := mainTemplate.ParseFiles(asset); err != nil { + log.Errorln(err) + } + } else { + render, err := source.TmplBox.String(asset) + if err != nil { + log.Errorln(err) + } + // render the page requested + if _, err := mainTemplate.Parse(render); err != nil { + log.Errorln(err) + } } // execute the template if err := mainTemplate.Execute(w, data); err != nil { diff --git a/handlers/notifications.go b/handlers/notifications.go index 9efe8586..43929b16 100644 --- a/handlers/notifications.go +++ b/handlers/notifications.go @@ -1,29 +1,29 @@ package handlers import ( + "net/http" + "sort" + "github.com/gorilla/mux" "github.com/statping-ng/statping-ng/types/errors" "github.com/statping-ng/statping-ng/types/failures" "github.com/statping-ng/statping-ng/types/notifications" "github.com/statping-ng/statping-ng/types/services" - "net/http" - "sort" ) -func apiNotifiersHandler(w http.ResponseWriter, r *http.Request) { +func apiAllNotifiersHandler(r *http.Request) interface{} { var notifs []notifications.Notification for _, n := range services.AllNotifiers() { notif := n.Select() no, err := notifications.Find(notif.Method) if err != nil { log.Error(err) - sendErrorJson(err, w, r) } notif.UpdateFields(no) notifs = append(notifs, *notif) } sort.Sort(notifications.NotificationOrder(notifs)) - returnJson(notifs, w, r) + return notifs } func apiNotifierGetHandler(w http.ResponseWriter, r *http.Request) { diff --git a/handlers/routes.go b/handlers/routes.go index 07fb2fc2..83447caa 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -1,13 +1,14 @@ package handlers import ( + "net/http" + "net/http/pprof" + "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/statping-ng/statping-ng/source" "github.com/statping-ng/statping-ng/types/core" "github.com/statping-ng/statping-ng/utils" - "net/http" - "net/http/pprof" _ "github.com/statping-ng/statping-ng/types/metrics" ) @@ -146,7 +147,7 @@ func Router() *mux.Router { api.Handle("/api/incidents/{id}/updates/{uid}", authenticated(apiDeleteIncidentUpdateHandler, false)).Methods("DELETE") // API USER Routes - api.Handle("/api/users", authenticated(apiAllUsersHandler, false)).Methods("GET") + api.Handle("/api/users", scoped(apiAllUsersHandler)).Methods("GET") api.Handle("/api/users", authenticated(apiCreateUsersHandler, false)).Methods("POST") api.Handle("/api/users/token", http.HandlerFunc(apiCheckUserTokenHandler)).Methods("POST") api.Handle("/api/users/{id}", authenticated(apiUserHandler, false)).Methods("GET") @@ -154,7 +155,7 @@ func Router() *mux.Router { api.Handle("/api/users/{id}", authenticated(apiUserDeleteHandler, false)).Methods("DELETE") // API NOTIFIER Routes - api.Handle("/api/notifiers", authenticated(apiNotifiersHandler, false)).Methods("GET") + api.Handle("/api/notifiers", scoped(apiAllNotifiersHandler)).Methods("GET") api.Handle("/api/notifier/{notifier}", authenticated(apiNotifierGetHandler, false)).Methods("GET") api.Handle("/api/notifier/{notifier}", authenticated(apiNotifierUpdateHandler, false)).Methods("POST") api.Handle("/api/notifier/{notifier}/test", authenticated(testNotificationHandler, false)).Methods("POST") @@ -167,7 +168,7 @@ func Router() *mux.Router { api.Handle("/api/messages/{id}", authenticated(apiMessageDeleteHandler, false)).Methods("DELETE") // API CHECKIN Routes - api.Handle("/api/checkins", authenticated(apiAllCheckinsHandler, false)).Methods("GET") + api.Handle("/api/checkins", scoped(apiAllCheckinsHandler)).Methods("GET") api.Handle("/api/checkins", authenticated(checkinCreateHandler, false)).Methods("POST") api.Handle("/api/checkins/{api}", authenticated(apiCheckinHandler, false)).Methods("GET") api.Handle("/api/checkins/{api}", authenticated(checkinDeleteHandler, false)).Methods("DELETE") diff --git a/handlers/users.go b/handlers/users.go index 3011d510..fc3d940b 100644 --- a/handlers/users.go +++ b/handlers/users.go @@ -2,11 +2,12 @@ package handlers import ( "fmt" + "net/http" + "github.com/gorilla/mux" "github.com/statping-ng/statping-ng/types/errors" "github.com/statping-ng/statping-ng/types/users" "github.com/statping-ng/statping-ng/utils" - "net/http" ) func findUser(r *http.Request) (*users.User, int64, error) { @@ -75,9 +76,9 @@ func apiUserDeleteHandler(w http.ResponseWriter, r *http.Request) { sendJsonAction(user, "delete", w, r) } -func apiAllUsersHandler(w http.ResponseWriter, r *http.Request) { +func apiAllUsersHandler(r *http.Request) interface{} { allUsers := users.All() - returnJson(allUsers, w, r) + return allUsers } func apiCheckUserTokenHandler(w http.ResponseWriter, r *http.Request) { diff --git a/notifiers/generate.go b/notifiers/generate.go index cfa4f7f2..babc067d 100644 --- a/notifiers/generate.go +++ b/notifiers/generate.go @@ -1,3 +1,4 @@ +//go:build ignore // +build ignore package main diff --git a/notifiers/notifiers.go b/notifiers/notifiers.go index 1ffc2848..fe740aed 100644 --- a/notifiers/notifiers.go +++ b/notifiers/notifiers.go @@ -36,7 +36,6 @@ func InitNotifiers() { Webhook, Mobile, Pushover, - statpingMailer, Gotify, AmazonSNS, ) diff --git a/notifiers/statping_emailer.go b/notifiers/statping_emailer.go deleted file mode 100644 index c6026c0e..00000000 --- a/notifiers/statping_emailer.go +++ /dev/null @@ -1,106 +0,0 @@ -package notifiers - -import ( - "bytes" - "encoding/json" - "github.com/statping-ng/statping-ng/types/core" - "github.com/statping-ng/statping-ng/types/failures" - "github.com/statping-ng/statping-ng/types/notifications" - "github.com/statping-ng/statping-ng/types/notifier" - "github.com/statping-ng/statping-ng/types/services" - "github.com/statping-ng/statping-ng/utils" - "time" -) - -var _ notifier.Notifier = (*statpingEmailer)(nil) - -const ( - statpingEmailerName = "statping_emailer" - statpingEmailerHost = "https://news.statping.com" -) - -type statpingEmailer struct { - *notifications.Notification -} - -func (s *statpingEmailer) Select() *notifications.Notification { - return s.Notification -} - -func (s *statpingEmailer) Valid(values notifications.Values) error { - return nil -} - -var statpingMailer = &statpingEmailer{¬ifications.Notification{ - Method: statpingEmailerName, - Title: "Email", - Description: "Send an email when a service becomes offline or back online using Statping's email service. You will need to verify your email address.", - Author: "Hunter Long", - AuthorUrl: "https://github.com/hunterlong", - Delay: time.Duration(10 * time.Second), - Icon: "fas envelope-square", - Limits: 60, - Form: []notifications.NotificationForm{{ - Type: "email", - Title: "Send to Email Address", - Placeholder: "info@statping.com", - DbField: "Host", - Required: true, - }}}, -} - -// Send will send a HTTP Post to the slack webhooker API. It accepts type: string -func (s *statpingEmailer) sendStatpingEmail(msg statpingMail) (string, error) { - data, _ := json.Marshal(msg) - resp, _, err := utils.HttpRequest(statpingEmailerHost+"/notifier", "POST", "application/json", nil, bytes.NewBuffer(data), time.Duration(10*time.Second), true, nil) - if err != nil { - return "", err - } - return string(resp), nil -} - -func (s *statpingEmailer) OnTest() (string, error) { - return "", nil -} - -type statpingMail struct { - Email string `json:"email"` - Core core.Core `json:"core,omitempty"` - Service services.Service `json:"service,omitempty"` - Failure failures.Failure `json:"failure,omitempty"` -} - -// OnFailure will trigger failing service -func (s *statpingEmailer) OnFailure(srv services.Service, f failures.Failure) (string, error) { - ee := statpingMail{ - Email: s.Host.String, - Core: *core.App, - Service: srv, - Failure: f, - } - return s.sendStatpingEmail(ee) -} - -// OnSuccess will trigger successful service -func (s *statpingEmailer) OnSuccess(srv services.Service) (string, error) { - ee := statpingMail{ - Email: s.Host.String, - Core: *core.App, - Service: srv, - Failure: failures.Failure{}, - } - return s.sendStatpingEmail(ee) -} - -// OnSave will trigger when this notifier is saved -func (s *statpingEmailer) OnSave() (string, error) { - ee := statpingMail{ - Email: s.Host.String, - Core: *core.App, - Service: services.Service{}, - Failure: failures.Failure{}, - } - out, err := s.sendStatpingEmail(ee) - log.Println("statping emailer response", out) - return out, err -} diff --git a/notifiers/statping_emailer_test.go b/notifiers/statping_emailer_test.go deleted file mode 100644 index 4c72b3f9..00000000 --- a/notifiers/statping_emailer_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package notifiers - -import ( - "github.com/statping-ng/statping-ng/database" - "github.com/statping-ng/statping-ng/types/core" - "github.com/statping-ng/statping-ng/types/failures" - "github.com/statping-ng/statping-ng/types/notifications" - "github.com/statping-ng/statping-ng/types/null" - "github.com/statping-ng/statping-ng/types/services" - "github.com/statping-ng/statping-ng/utils" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "testing" - "time" -) - -var ( - testEmail string -) - -func TestStatpingEmailerNotifier(t *testing.T) { - err := utils.InitLogs() - require.Nil(t, err) - - t.Parallel() - db, err := database.OpenTester() - require.Nil(t, err) - db.AutoMigrate(¬ifications.Notification{}) - notifications.SetDB(db) - core.Example() - - testEmail = utils.Params.GetString("TEST_EMAIL") - statpingMailer.Host = null.NewNullString(testEmail) - statpingMailer.Enabled = null.NewNullBool(true) - - if testEmail == "" { - t.Log("statping email notifier testing skipped, missing TEST_EMAIL environment variable") - t.SkipNow() - } - - t.Run("Load statping emailer", func(t *testing.T) { - statpingMailer.Host = null.NewNullString(testEmail) - statpingMailer.Delay = time.Duration(100 * time.Millisecond) - statpingMailer.Limits = 3 - Add(statpingMailer) - assert.Equal(t, "Hunter Long", statpingMailer.Author) - assert.Equal(t, testEmail, statpingMailer.Host.String) - }) - - t.Run("statping emailer Within Limits", func(t *testing.T) { - ok := statpingMailer.CanSend() - assert.True(t, ok) - }) - - t.Run("statping emailer OnSave", func(t *testing.T) { - _, err := statpingMailer.OnSave() - assert.Nil(t, err) - }) - - t.Run("statping emailer OnFailure", func(t *testing.T) { - _, err := statpingMailer.OnFailure(services.Example(false), failures.Example()) - assert.Nil(t, err) - }) - - t.Run("statping emailer OnSuccess", func(t *testing.T) { - _, err := statpingMailer.OnSuccess(services.Example(true)) - assert.Nil(t, err) - }) - -} diff --git a/source/source.go b/source/source.go index 20488908..3d36f3d9 100644 --- a/source/source.go +++ b/source/source.go @@ -30,6 +30,7 @@ var ( "scss/mobile.scss", "scss/variables.scss", "robots.txt", + "base.gohtml", } ) @@ -174,8 +175,8 @@ func DeleteAllAssets(folder string) error { // CopyAllToPublic will copy all the files in a rice box into a local folder func CopyAllToPublic(box *rice.Box) error { exclude := map[string]bool{ - "base.gohtml": true, - "index.html": true, + // "base.gohtml": true, + "index.html": true, } return box.Walk("/", func(path string, info os.FileInfo, err error) error { diff --git a/source/statping-ng.wiki b/source/statping-ng.wiki new file mode 160000 index 00000000..a42b2a64 --- /dev/null +++ b/source/statping-ng.wiki @@ -0,0 +1 @@ +Subproject commit a42b2a641164e4c714fc09d6e08fcd6f7d0e5fb4 diff --git a/types/services/notifications.go b/types/services/notifications.go index f8ee67b1..c8a71374 100644 --- a/types/services/notifications.go +++ b/types/services/notifications.go @@ -23,9 +23,12 @@ func sendSuccess(s *Service) { return } + s.notifyAfterCount = 0 + if s.prevOnline == s.Online { return } + s.prevOnline = true for _, n := range allNotifiers { notif := n.Select() @@ -42,9 +45,6 @@ func sendSuccess(s *Service) { notif.LastSent = utils.Now() } } - - s.prevOnline = true - s.notifyAfterCount++ } func sendFailure(s *Service, f *failures.Failure) { @@ -63,6 +63,8 @@ func sendFailure(s *Service, f *failures.Failure) { } } + s.prevOnline = false + for _, n := range allNotifiers { notif := n.Select() if notif.CanSend() { @@ -78,9 +80,6 @@ func sendFailure(s *Service, f *failures.Failure) { notif.LastSent = utils.Now() } } - - s.prevOnline = false - s.notifyAfterCount++ } func logMessage(method string, msg string, error error, onSuccesss bool, serviceId int64) { diff --git a/types/services/samples.go b/types/services/samples.go index 41541b26..c20ad9c2 100644 --- a/types/services/samples.go +++ b/types/services/samples.go @@ -159,7 +159,7 @@ func Samples() error { s6 := &Service{ Name: "Private Service", - Domain: "https://push.statping.com", + Domain: "https://example.org", Method: "GET", Interval: 30, Type: "http", diff --git a/utils/utils.go b/utils/utils.go index 794638f4..406a24d9 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -9,14 +9,15 @@ import ( "io/ioutil" "net" "net/http" - "net/url" "os" "os/exec" + "runtime" "strconv" "strings" "sync" "time" + "github.com/go-ping/ping" "github.com/statping-ng/statping-ng/types/metrics" ) @@ -79,7 +80,8 @@ func ToString(s interface{}) string { } // Command will run a terminal command with 'sh -c COMMAND' and return stdout and errOut as strings -// in, out, err := Command("sass assets/scss assets/css/base.css") +// +// in, out, err := Command("sass assets/scss assets/css/base.css") func Command(name string, args ...string) (string, string, error) { testCmd := exec.Command(name, args...) var stdout, stderr []byte @@ -215,17 +217,9 @@ func HttpRequest(endpoint, method string, contentType interface{}, headers []str Proxy: http.ProxyFromEnvironment, DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { // redirect all connections to host specified in url - addr = strings.Split(req.URL.Host, ":")[0] + addr[strings.LastIndex(addr, ":"):] return dialer.DialContext(ctx, network, addr) }, } - if Params.GetString("HTTP_PROXY") != "" { - proxyUrl, err := url.Parse(Params.GetString("HTTP_PROXY")) - if err != nil { - return nil, nil, err - } - transport.Proxy = http.ProxyURL(proxyUrl) - } if customTLS != nil { transport.TLSClientConfig.RootCAs = customTLS.RootCAs transport.TLSClientConfig.Certificates = customTLS.Certificates @@ -257,3 +251,31 @@ func HttpRequest(endpoint, method string, contentType interface{}, headers []str return contents, resp, err } + +func Ping(address string, secondsTimeout int) (int64, error) { + ping, err := ping.NewPinger(address) + + if err != nil { + return 0, err + } + + ping.Count = 1 + ping.Timeout = time.Second * time.Duration(secondsTimeout) + + if runtime.GOOS == "windows" { + ping.SetPrivileged(true) + } + + err = ping.Run() + if err != nil { + return 0, err + } + + stats := ping.Statistics() + + if stats.PacketsSent-stats.PacketsRecv != 0 { + return 0, errors.New("destination host unreachable") + } + + return stats.MinRtt.Microseconds(), nil +} diff --git a/utils/utils_custom.go b/utils/utils_custom.go index 90253d60..08fd9781 100644 --- a/utils/utils_custom.go +++ b/utils/utils_custom.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package utils @@ -22,42 +23,33 @@ func DirWritable(path string) (bool, error) { return false, errors.New("path isn't a directory") } - if info.Mode().Perm()&(1<<(uint(7))) == 0 { - return false, errors.New("write permission bit is not set on this file for user") - } - var stat syscall.Stat_t if err = syscall.Stat(path, &stat); err != nil { return false, errors.New("unable to get stat") } - if uint32(os.Geteuid()) != stat.Uid { - return false, errors.New("user doesn't have permission to write to this directory") - } - return true, nil -} - -func Ping(address string, secondsTimeout int) (int64, error) { - ping, err := exec.LookPath("ping") - if err != nil { - return 0, err - } - out, _, err := Command(ping, address, "-c", "1", "-W", strconv.Itoa(secondsTimeout)) - if err != nil { - return 0, err - } - if strings.Contains(out, "Unknown host") { - return 0, errors.New("unknown host") - } - if strings.Contains(out, "100.0% packet loss") { - return 0, errors.New("destination host unreachable") + if uint32(os.Geteuid()) == stat.Uid { + if info.Mode().Perm()&(1<<7) != 0 { + // owner matches and has write permissions + return true, nil + } else { + return false, errors.New("owner doesn't have write permissions for this path") + } } - r := regexp.MustCompile(`time=(.*) ms`) - strs := r.FindStringSubmatch(out) - if len(strs) < 2 { - return 0, errors.New("could not parse ping duration") + if uint32(os.Getegid()) == stat.Gid { + if info.Mode().Perm()&(1<<4) != 0 { + // group matches and has write permissions + return true, nil + } else { + return false, errors.New("group doesn't have write permissions for this path") + } } - f, _ := strconv.ParseFloat(strs[1], 64) - return int64(f * 1000), nil + + if info.Mode().Perm()&(1<<1) != 0 { + // all users have write permissions + return true, nil + } + + return false, errors.New("user doesn't have write permissions for this path") } diff --git a/utils/utils_test.go b/utils/utils_test.go index 99d4d7db..e1436f13 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -2,13 +2,14 @@ package utils import ( "fmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "net/http" "net/http/httptest" "os" "testing" "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestCreateLog(t *testing.T) { @@ -215,3 +216,10 @@ func TestPerlin(t *testing.T) { assert.NotZero(t, p.Noise1D(hi/500)) } } + +func TestPing(t *testing.T) { + duration, error := Ping("localhost", 1) + + assert.Nil(t, error) + assert.NotEqual(t, 0, duration) +} diff --git a/utils/utils_windows.go b/utils/utils_windows.go index ac1a7ece..3082b113 100644 --- a/utils/utils_windows.go +++ b/utils/utils_windows.go @@ -3,10 +3,6 @@ package utils import ( "errors" "os" - "os/exec" - "regexp" - "strconv" - "strings" ) func DirWritable(path string) (bool, error) { @@ -25,24 +21,3 @@ func DirWritable(path string) (bool, error) { return true, nil } - -func Ping(address string, secondsTimeout int) (int64, error) { - ping, err := exec.LookPath("ping") - if err != nil { - return 0, err - } - out, _, err := Command(ping, address, "-n", "1", "-w", strconv.Itoa(secondsTimeout*1000)) - if err != nil { - return 0, err - } - if strings.Contains(out, "Destination Host Unreachable") { - return 0, errors.New("destination host unreachable") - } - r := regexp.MustCompile(`Average = (.*)ms`) - strs := r.FindStringSubmatch(out) - if len(strs) < 2 { - return 0, errors.New("could not parse ping duration") - } - f, _ := strconv.ParseFloat(strs[1], 64) - return int64(f * 1000), nil -} diff --git a/version.txt b/version.txt index d070d29d..8f63f4f9 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.90.79 +0.91.0