From acb750ea5ef76be0ed1f1c2388c89a3dfc6a5449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A5=E4=B8=8B=E9=83=A8=20=E8=A9=A9?= Date: Mon, 27 Dec 2021 00:47:56 +0800 Subject: [PATCH] Update publish.yml Update publish.yml Update publish.yml Update go.yml --- .github/workflows/go.yml | 4 ++-- .github/workflows/publish.yml | 38 +++++++++++++++++------------------ .gitignore | 1 + device/peer.go | 16 ++------------- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1fe8504..689000c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,7 +19,7 @@ jobs: echo "deb [trusted=yes] https://packagecloud.io/fdio/release/ubuntu focal main" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list > /dev/null curl -L https://packagecloud.io/fdio/release/gpgkey | sudo apt-key add - sudo apt-get -y update - sudo apt-get install -y vpp vpp-plugin-core python3-vpp-api vpp-dbg vpp-dev libmemif libmemif-dev + sudo apt-get install -y libmemif libmemif-dev sudo apt-get install -y wireguard-tools upx-ucl - name: Build x86_64 @@ -77,7 +77,7 @@ jobs: add-apt-repository ppa:longsleep/golang-backports apt-get -y update - apt-get install -y vpp vpp-plugin-core python3-vpp-api vpp-dbg vpp-dev libmemif libmemif-dev || true + apt-get install -y libmemif libmemif-dev || true apt-get install -y wireguard-tools golang-go build-essential git run: | make all static diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5d4e6be..1545a35 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,7 +21,7 @@ jobs: echo "deb [trusted=yes] https://packagecloud.io/fdio/release/ubuntu focal main" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list > /dev/null curl -L https://packagecloud.io/fdio/release/gpgkey | sudo apt-key add - sudo apt-get -y update - sudo apt-get install -y vpp vpp-plugin-core python3-vpp-api vpp-dbg vpp-dev libmemif libmemif-dev + sudo apt-get install -y libmemif libmemif-dev sudo apt-get install -y wireguard-tools upx-ucl - name: Build x86_64 @@ -38,6 +38,7 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: etherguard-go + overwrite: true asset_name: etherguard-go-x86_64 tag: ${{ github.ref }} @@ -46,7 +47,8 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: etherguard-go-vpp - asset_name: etherguard-go-x86_64 + overwrite: true + asset_name: etherguard-go-vpp-x86_64 tag: ${{ github.ref }} - name: Upload x86_64 static build @@ -54,6 +56,7 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: etherguard-go-static + overwrite: true asset_name: etherguard-go-static-x86_64 tag: ${{ github.ref }} @@ -74,24 +77,16 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} file: etherguard-go asset_name: etherguard-go-mipsle + overwrite: true tag: ${{ github.ref }} - - - name: Upload mipsle dynamic vpp build - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: etherguard-go-vpp - asset_name: etherguard-go-mipsle - tag: ${{ github.ref }} - - - name: Upload mipsle static build uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: etherguard-go-static asset_name: etherguard-go-static-mipsle + overwrite: true tag: ${{ github.ref }} multi-arch: @@ -128,7 +123,7 @@ jobs: add-apt-repository ppa:longsleep/golang-backports apt-get -y update - apt-get install -y vpp vpp-plugin-core python3-vpp-api vpp-dbg vpp-dev libmemif libmemif-dev || true + apt-get install -y libmemif libmemif-dev || true apt-get install -y wireguard-tools golang-go build-essential git run: | make all static @@ -152,8 +147,9 @@ jobs: uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: artifacts/${{ martix.arch }}/etherguard-go - asset_name: etherguard-go-${{ martix.arch }} + file: artifacts/${{ matrix.arch }}/etherguard-go + asset_name: etherguard-go-${{ matrix.arch }} + overwrite: true tag: ${{ github.ref }} - name: Upload ${{ matrix.arch }} dynamic vpp build @@ -161,14 +157,16 @@ jobs: uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: artifacts/${{ martix.arch }}/etherguard-go - asset_name: etherguard-go-${{ martix.arch }} + file: artifacts/${{ matrix.arch }}/etherguard-go + asset_name: etherguard-go-vpp-${{ matrix.arch }} + overwrite: true tag: ${{ github.ref }} - name: Upload ${{ matrix.arch }} static build uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: artifacts/${{ martix.arch }}/etherguard-go-static - asset_name: etherguard-go-static-${{ martix.arch }} - tag: ${{ github.ref }} \ No newline at end of file + file: artifacts/${{ matrix.arch }}/etherguard-go-static + asset_name: etherguard-go-static-${{ matrix.arch }} + overwrite: true + tag: ${{ github.ref }} diff --git a/.gitignore b/.gitignore index d28577c..783e4f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ etherguard-go etherguard-go-vpp +etherguard-go-static vendor .ipynb_checkpoints \ No newline at end of file diff --git a/device/peer.go b/device/peer.go index e7a9a51..0c34795 100644 --- a/device/peer.go +++ b/device/peer.go @@ -11,7 +11,6 @@ import ( "errors" "fmt" "io/ioutil" - "math" "net" "sort" "sync" @@ -187,19 +186,8 @@ func (f *filterwindow) Push(e float64) float64 { f.value = e return f.value } - pivot := ((elemlen + 1) / 2) - 1 - left := window[:pivot+1] - right := window[pivot:] - lm := f.filter(left, 1) - rm := f.filter(right, 2) - pv := window[pivot] - ldiff := math.Abs(lm - pv) - rdiff := math.Abs(rm - pv) - if ldiff < rdiff { - f.value = lm - } else { - f.value = rm - } + f.value = f.filter(window, 2) + return f.value }