diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml new file mode 100644 index 0000000000..5d98b4df33 --- /dev/null +++ b/.github/workflows/build-packages.yml @@ -0,0 +1,90 @@ +name: Build packages +# Big chunk of the build process logic is in the mage build targets +on: + workflow_call: + push: + branches: [master] + tags: + +# Mage's `GenerateEnvFile` talks to GH API to setup tags, versions, etc. +env: + GITHUB_OWNER: mysteriumnetwork + GITHUB_REPO: node + GITHUB_SNAPSHOT_REPO: node-builds + GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build-packages: + runs-on: ubuntu-latest + + strategy: + max-parallel: 4 + matrix: + platform: + - PackageLinuxRaspberryImage + - PackageLinuxAmd64 + - PackageLinuxArm + - PackageLinuxDebianAmd64 + - PackageLinuxDebianArm64 + - PackageLinuxDebianArm + - PackageMacOSAmd64 + - PackageMacOSArm64 + - PackageWindowsAmd64 + - PackageAndroid + - PackageAndroidProvider + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.21.x' + - name: Generate Env + run: go run mage.go -v GenerateEnvFile + + - name: Setup FPM + run: | + sudo apt-get install ruby-dev build-essential + sudo gem i fpm -f + + - name: Build package + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: | + source build/env.sh + # Following line ensures that s3 bucket name won't overlap with the old CI's target + # Should be removed when the old CI is disabled + export BUILD_NUMBER=$BUILD_NUMBER"-ghactions" + go run mage.go -v ${{ matrix.platform }} + + build-swagger: + runs-on: ubuntu-latest + needs: [build-packages] + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.21.x' + - name: Generate Env + run: go run mage.go -v GenerateEnvFile + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build docker + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + run: | + source build/env.sh + # Following line ensures that s3 bucket name won't overlap with the old CI's target + # Should be removed when the old CI is disabled + export BUILD_NUMBER=$BUILD_NUMBER"-ghactions" + go run mage.go -v PackageDockerSwaggerRedoc diff --git a/.github/workflows/mobile-release.yml b/.github/workflows/mobile-release.yml new file mode 100644 index 0000000000..c4bd0888a0 --- /dev/null +++ b/.github/workflows/mobile-release.yml @@ -0,0 +1,132 @@ +name: Mobile-release + +on: + release: + types: [released] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Get Release + run: | + echo $RELEASE_VERSION + echo ${{ env.RELEASE_VERSION }} + + - name: Checkout tools repo + uses: actions/checkout@v4 + with: + repository: mysteriumnetwork/mysterium-mobile-provider + ref: 'master' + path: mobile-app + token: ${{ secrets.REPO_TOKEN }} + + - name: Update version + run: | + APP_VERSION=$(echo "$(grep "versionName" "./mobile-app/android/app/build.gradle.kts" | awk -F '"' '{print $2}')" + 0.1 | bc) + sed -i -E "/versionName\s*=\s*\"[0-9]+\.[0-9]+\"/s/\"[0-9]+\.[0-9]+\"/\"$APP_VERSION\"/" "./mobile-app/android/app/build.gradle.kts" + sed -i -E "/node\s*=\s*\"[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?\"/s/\"[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?\"/\"${{ env.RELEASE_VERSION }}\"/" "./mobile-app/android/gradle/libs.versions.toml" + + - name: Pushes to another repository + id: push_directory + uses: cpina/github-action-push-to-another-repository@main + env: + API_TOKEN_GITHUB: ${{ secrets.REPO_TOKEN }} + with: + source-directory: mobile-app + destination-github-username: 'mysteriumnetwork' + destination-repository-name: 'mysterium-mobile-provider' + user-email: core-services@mysterium.network + commit-message: Create release version ${{ env.RELEASE_VERSION }} + target-branch: master + + - name: Send pull-request + env: + GH_TOKEN: ${{ secrets.REPO_TOKEN }} + run: | + LATEST_TAG=$(git describe --tags --always --abbrev=0) + REPOSITORY="mysteriumTeam/mysterium-mobile-provider" + FOLDER="bin/$REPOSITORY" + BRANCH_NAME="release-$LATEST_TAG" + + # Clone the remote repository and change working directory to the + # folder it was cloned to. + git clone \ + --depth=1 \ + --branch=bitrise \ + https://mpolubotko:${{ secrets.REPO_TOKEN }}@github.com/$REPOSITORY \ + $FOLDER + + cd $FOLDER + + # Setup the committers identity. + git config user.email "core-services@mysterium.network" + git config user.name "MysteriumTeam" + + # Create a new feature branch for the changes. + git checkout -b $BRANCH_NAME + + # Update the script files to the latest version. + cp -R ../../../mobile-app/android android + + # Commit the changes and push the feature branch to origin + git add . + git commit -m "update files for new release version $LATEST_TAG" + git push origin $BRANCH_NAME + + # Store the PAT in a file that can be accessed by the + # GitHub CLI. + echo "${{ secrets.REPO_TOKEN }}" > token.txt + + # Authorize GitHub CLI for the current repository and + # create a pull-request containing the updates. + PR_URL=$(gh pr create \ + --body "" \ + --title "Release $LATEST_TAG" \ + --head "$BRANCH_NAME" \ + --base "master" \ + | sed -n 's#https://github\.com/[^/]\+/[^/]\+/\pull/\([0-9]\+\).*#\1#p') + echo "PR_NUMBER=$PR_URL" >> $GITHUB_ENV + + - name: Approve Pull Request + env: + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} + REPO_OWNER: "MysteriumTeam" + REPO_NAME: "mysterium-mobile-provider" + PR_NUMBER: ${{ env.PR_NUMBER }} + run: | + response=$(curl -s -o /dev/null -w "%{http_code}" -L -X PUT \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/merge \ + -d '{"commit_title":"Release v${{ env.RELEASE_VERSION }}","commit_message":"${{ env.RELEASE_VERSION }}"}') + + # Check HTTP response + if [ "$response" == "204" ] || [ "$response" == "200" ] || [ "$response" == "201" ]; then + echo "PR was approved successfully" + else + echo "Couldn't approved PR, HTTP-status: $response" + exit 1 + fi + + - name: "Call Bitrise API" + uses: indiesdev/curl@v1.1 + with: + url: https://api.bitrise.io/v0.1/apps/${{ secrets.BITRISE_APP_ID }}/builds + method: "POST" + id: api + accept: 200, 201 + headers: '{ "accept": "application/json", "Authorization": "${{ secrets.BITRISE_TOKEN }}", "Content-Type": "application/json" }' + body: '{ "hook_info": {"type": "bitrise"}, "build_params": {"branch":"master", "workflow_id":"build"}}' + timeout: 10000 + log-response: true + + - name: "Bitrise response" + run: echo ${{ steps.api.outputs.response }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 23994bd768..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Released - -on: - release: - types: [released] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Get Release - run: | - echo $RELEASE_VERSION - echo ${{ env.RELEASE_VERSION }} - - - name: Checkout tools repo - uses: actions/checkout@v4 - with: - repository: mysteriumnetwork/mysterium-mobile-provider - ref: 'master' - path: mobile-app - token: ${{ secrets.REPO_TOKEN }} - - - name: Update version - run: | - APP_VERSION=$(echo "$(grep "versionName" "./mobile-app/android/app/build.gradle.kts" | awk -F '"' '{print $2}')" + 0.1 | bc) - sed -i -E "/versionName\s*=\s*\"[0-9]+\.[0-9]+\"/s/\"[0-9]+\.[0-9]+\"/\"$APP_VERSION\"/" "./mobile-app/android/app/build.gradle.kts" - sed -i -E "/node\s*=\s*\"[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?\"/s/\"[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?\"/\"${{ env.RELEASE_VERSION }}\"/" "./mobile-app/android/gradle/libs.versions.toml" - - - name: Pushes to another repository - id: push_directory - uses: cpina/github-action-push-to-another-repository@main - env: - API_TOKEN_GITHUB: ${{ secrets.REPO_TOKEN }} - with: - source-directory: mobile-app - destination-github-username: 'mysteriumnetwork' - destination-repository-name: 'mysterium-mobile-provider' - user-email: core-services@mysterium.network - commit-message: Create release version ${{ env.RELEASE_VERSION }} - target-branch: master - - - name: "Call Bitrise API" - uses: indiesdev/curl@v1.1 - with: - url: https://api.bitrise.io/v0.1/apps/${{ secrets.BITRISE_APP_ID }}/builds - method: "POST" - id: api - accept: 200, 201 - headers: '{ "accept": "application/json", "Authorization": "${{ secrets.BITRISE_TOKEN }}", "Content-Type": "application/json" }' - body: '{ "hook_info": {"type": "bitrise"}, "build_params": {"branch":"master", "workflow_id":"build"}}' - timeout: 10000 - log-response: true - - - name: "Bitrise response" - run: echo ${{ steps.api.outputs.response }} diff --git a/.github/workflows/tests-and-linters.yml b/.github/workflows/tests-and-linters.yml new file mode 100644 index 0000000000..b3ff7ad3a7 --- /dev/null +++ b/.github/workflows/tests-and-linters.yml @@ -0,0 +1,60 @@ +name: Tests +on: + pull_request: + +env: + GOFLAGS: "-count=1" + +jobs: + unit-tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.21.x' + + - name: Install protoc + run: sudo apt install -y protobuf-compiler + + - name: Unit tests and linters + run: | + go run mage.go -v Generate + go run mage.go -v Check + go run mage.go -v TestWithCoverage + + - name: Upload codecov report + uses: codecov/codecov-action@v4 + with: + file: ./coverage.txt + token: ${{ secrets.CODECOV_TOKEN }} + + e2e-tests: + runs-on: ubuntu-latest + needs: unit-tests + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.21.x' + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: E2E basic test + run: go run mage.go -v TestE2EBasic + + - name: E2E NAT test + run: go run mage.go -v TestE2ENAT + + verify-build: + needs: [unit-tests, e2e-tests] + uses: ./.github/workflows/build-packages.yml + secrets: inherit diff --git a/README.md b/README.md index f28eef6526..e835864f08 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ Currently node supports WireGuard as its underlying VPN transport. - [Latest release](https://github.com/mysteriumnetwork/node/releases/latest) - [Snapshot builds](https://github.com/mysteriumnetwork/node-builds/releases) - bleeding edge, use at your own risk - [Documentation](https://docs.mysterium.network/) -- [Installation guide](https://docs.mysterium.network/for-node-runners/linux-guide) +- [Help Center](https://help.mystnodes.com/) +- [Installation guide](https://help.mystnodes.com/en/?q=installation) ## Installation options @@ -49,7 +50,7 @@ Installation script tested on these OSes so far: _Raspbian 10_, _Debian 9_, _Deb Our docker images can be found in [Docker hub](https://hub.docker.com/r/mysteriumnetwork/myst). -To run a node in a docker container you will need [docker](https://www.docker.com/). On Linux, to manage docker as a non-root user (execute commands without `sudo`), follow [postinstall guide](https://docs.docker.com/install/linux/linux-postinstall/). +To run a node in a docker container you will need [docker](https://www.docker.com/). On Linux, to manage docker as a non-root user (execute commands without `sudo`), follow [postinstall guide](https://help.mystnodes.com/en/articles/3777670-running-a-node-as-docker-image-on-linux-host/). You should be able to run a node on any OS that supports docker. We have tested it on these OSes so far: - Debian 9 - Debian 10 @@ -74,8 +75,8 @@ docker logs -f myst ### Further information -More installation options are described in the [installation guide](https://docs.mysterium.network/for-node-runners/). -For possible issues while running a node refer to our [Troubleshooting guide](https://docs.mysterium.network/troubleshooting/). +More installation options are described in the [installation guides](https://help.mystnodes.com/en/?q=installation). +For possible issues while running a node refer to our [Troubleshooting guides](https://help.mystnodes.com/en/collections/1992526-troubleshooting-mystnodes-help-center). ## Built With diff --git a/core/shaper/shaper_linux.go b/core/shaper/shaper_linux.go index 1a9e323598..582333ddc2 100644 --- a/core/shaper/shaper_linux.go +++ b/core/shaper/shaper_linux.go @@ -31,7 +31,22 @@ type linuxShaper struct { listenTopic string } -func create(listener eventListener) *linuxShaper { +type linuxShaperNoop struct{} + +func (s *linuxShaperNoop) Start(interfaceName string) error { + return nil +} + +func (s *linuxShaperNoop) Clear(interfaceName string) { + return +} + +func create(listener eventListener) Shaper { + // return a noop filter if userspace flag is set + if config.GetBool(config.FlagUserspace) { + return &linuxShaperNoop{} + } + ws := wondershaper.New() ws.Stdout = log.Logger ws.Stderr = log.Logger @@ -48,12 +63,12 @@ func (s *linuxShaper) Start(interfaceName string) error { s.ws.Clear(interfaceName) if config.GetBool(config.FlagShaperEnabled) { - err := s.ws.LimitDownlink(interfaceName, int(config.GetUInt64(config.FlagShaperBandwidth))) + err := s.ws.LimitDownlink(interfaceName, int(config.GetUInt64(config.FlagShaperBandwidth))*8) if err != nil { log.Error().Err(err).Msg("Could not limit download speed") return err } - err = s.ws.LimitUplink(interfaceName, int(config.GetUInt64(config.FlagShaperBandwidth))) + err = s.ws.LimitUplink(interfaceName, int(config.GetUInt64(config.FlagShaperBandwidth))*8) if err != nil { log.Error().Err(err).Msg("Could not limit upload speed") return err diff --git a/go.mod b/go.mod index 3b019a2eb7..b214d1c893 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( github.com/mysteriumnetwork/EventBus v0.0.0-20220415063055-d22cb121672c github.com/mysteriumnetwork/feedback v1.3.2 github.com/mysteriumnetwork/go-ci v0.0.0-20220711082519-1245471bae0d - github.com/mysteriumnetwork/go-dvpn-web/v2 v2.14.3 + github.com/mysteriumnetwork/go-dvpn-web/v2 v2.15.0 github.com/mysteriumnetwork/go-openvpn v0.0.23 github.com/mysteriumnetwork/go-rest v0.3.1 github.com/mysteriumnetwork/go-wondershaper v1.0.1 @@ -270,5 +270,5 @@ require ( replace ( golang.zx2c4.com/wireguard => github.com/mysteriumnetwork/wireguard-go v0.0.0-20231211132832-8f7bf3c68307 - gvisor.dev/gvisor => github.com/mysteriumnetwork/gvisor v0.0.0-20231116101341-753b6ae8ddcb + gvisor.dev/gvisor => github.com/mysteriumnetwork/gvisor v0.0.0-20240206094932-ff91e662b9e8 ) diff --git a/go.sum b/go.sum index aef97811ee..f58fa31ffe 100644 --- a/go.sum +++ b/go.sum @@ -854,8 +854,8 @@ github.com/mysteriumnetwork/feedback v1.3.2/go.mod h1:g8PD0Gl5UVIFt3N159ohJUmBnG github.com/mysteriumnetwork/go-ci v0.0.0-20200121125840-b99aac3d815c/go.mod h1:GlJmsQDFyRmV9psEs/Mt/humLALu8xmZ7blXQ6Rc9Rs= github.com/mysteriumnetwork/go-ci v0.0.0-20220711082519-1245471bae0d h1:IejX10D2zdFwidh09Gy7L37BHfvc2ckgLrHXadLvzTA= github.com/mysteriumnetwork/go-ci v0.0.0-20220711082519-1245471bae0d/go.mod h1:FdrIqN3Z27igwo8A4aKZcmds7q894iGcdUIPz0+vOXY= -github.com/mysteriumnetwork/go-dvpn-web/v2 v2.14.3 h1:vK7BeQyeN1w3lbCmCYOCGNZ7lMDDL2TvCYyYTogsP7k= -github.com/mysteriumnetwork/go-dvpn-web/v2 v2.14.3/go.mod h1:rFTH4Hfx0pdZUTrJtzy3Yaz0mHTaur7+TezbvWA/8C8= +github.com/mysteriumnetwork/go-dvpn-web/v2 v2.15.0 h1:GT07vEfmbylXKdnpBT6TrRcR9N7D4ddpKsnt8li5ukQ= +github.com/mysteriumnetwork/go-dvpn-web/v2 v2.15.0/go.mod h1:rFTH4Hfx0pdZUTrJtzy3Yaz0mHTaur7+TezbvWA/8C8= github.com/mysteriumnetwork/go-openvpn v0.0.23 h1:6BKoTwU9CpJL/Na9M9a0uaelAaVIo/XZPDpElfzFjxM= github.com/mysteriumnetwork/go-openvpn v0.0.23/go.mod h1:YDjnxC/3sGNecq/f6GM0BGz7nnGPTPIGtQjHaoLf8UE= github.com/mysteriumnetwork/go-rest v0.3.1 h1:zWyeW08ZVm9pWfjBrnq6SYZxoqc8kqzkr3eAbgZqr50= @@ -867,6 +867,8 @@ github.com/mysteriumnetwork/gowinlog v0.0.0-20220318151501-96eedb692646/go.mod h github.com/mysteriumnetwork/gvisor v0.0.0-20231116101341-753b6ae8ddcb h1:m4CwpzAoDZ0eAwwTVsTakcObaS9IyoPrl01pxlBmMoU= github.com/mysteriumnetwork/gvisor v0.0.0-20231116101341-753b6ae8ddcb/go.mod h1:exVfPZjgc0vGqFDB0Un4K0f4RBdf6Xi/dsojN2P6PAU= github.com/mysteriumnetwork/logger v0.0.9/go.mod h1:JBQaYFRlv3xj4GbVPEFQcAqB7tHTNbvqL3/C3ywKQSM= +github.com/mysteriumnetwork/gvisor v0.0.0-20240206094932-ff91e662b9e8 h1:suXQZZ29eOeiqnp0YCujb1cmTq3Xl59Q0gANMgW3tNc= +github.com/mysteriumnetwork/gvisor v0.0.0-20240206094932-ff91e662b9e8/go.mod h1:exVfPZjgc0vGqFDB0Un4K0f4RBdf6Xi/dsojN2P6PAU= github.com/mysteriumnetwork/metrics v0.0.19 h1:sqmUVStDWQOSUUxKTrEnxOZs6dy9nKrlICKBrzTbKSI= github.com/mysteriumnetwork/metrics v0.0.19/go.mod h1:QQHdm9M0p42hESbtM0dxyeooH66QTGtXAArz8qsi4Ds= github.com/mysteriumnetwork/payments v1.0.1-0.20231124140312-2092954a0c54 h1:mqdzogdLpkgAgP3svQxnxo4AbRSLNH9x51gGQKaXl1Y=