Skip to content

Commit

Permalink
Merge branch 'release/v0.2.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
cad committed Apr 4, 2021
2 parents e824d5e + 21197c9 commit 04655f1
Show file tree
Hide file tree
Showing 44 changed files with 7,994 additions and 3,127 deletions.
49 changes: 32 additions & 17 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,40 @@ on:

jobs:
test:
name: Test
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.16'

- name: Set up Go
uses: actions/setup-go@v2-beta
with:
go-version: "^1.14.6"
id: go
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}

- name: Check out code
uses: actions/checkout@v2

- name: Install OpenVPN
run: sudo apt-get install -y openvpn
- name: Deps
run: |
sudo apt-get update -y
sudo apt install reprepro createrepo rsync openvpn -y
mkdir -p /tmp/protoc
pushd /tmp/protoc
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.15.7/protoc-3.15.7-linux-x86_64.zip
unzip protoc-3.15.7-linux-x86_64.zip
popd
sudo chmod +x /tmp/protoc/bin/protoc
sudo cp /tmp/protoc/bin/protoc /usr/bin/protoc
sudo cp -r /tmp/protoc/include/* /usr/local/include/
sudo chmod -R 777 /usr/local/include/google
sudo apt-get install autoconf automake libtool curl make g++ unzip -y
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
go install github.com/kevinburke/go-bindata/go-bindata@latest
go install github.com/goreleaser/nfpm/cmd/nfpm@latest
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Bundle
run: make bundle

- name: Test
run: make test
- name: Test
run: make test
23 changes: 12 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,37 @@ on:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.14.6'
go-version: '^1.16'

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}

- name: Repo Tools
- name: Deps
run: |
sudo apt-get update -y
sudo apt install reprepro createrepo rsync -y
sudo apt install reprepro createrepo rsync openvpn -y
mkdir -p /tmp/protoc
pushd /tmp/protoc
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/protoc-3.12.3-linux-x86_64.zip
unzip protoc-3.12.3-linux-x86_64.zip
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.15.7/protoc-3.15.7-linux-x86_64.zip
unzip protoc-3.15.7-linux-x86_64.zip
popd
sudo chmod +x /tmp/protoc/bin/protoc
sudo cp /tmp/protoc/bin/protoc /usr/bin/protoc
sudo cp -r /tmp/protoc/include/* /usr/local/include/
sudo chmod -R 777 /usr/local/include/google
sudo apt-get install autoconf automake libtool curl make g++ unzip -y
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go
go get github.com/kevinburke/go-bindata/...
go get github.com/goreleaser/nfpm/cmd/nfpm@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
go install github.com/kevinburke/go-bindata/go-bindata@latest
go install github.com/goreleaser/nfpm/cmd/nfpm@latest
- name: Dist
run: VERSION=${{ steps.get_version.outputs.VERSION }} make dist
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [v0.2.11]

- Make sure ovpmd listens on IPv4 interfaces [#108](https://github.com/cad/ovpm/issues/108)

## [v0.2.10](https://github.com/cad/ovpm/tree/v0.2.10)

- Fix ovpmd not starting error on Ubuntu. [#99](https://github.com/cad/ovpm/issues/99)
Expand Down
25 changes: 14 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ FROM fedora:latest
LABEL maintainer="Mustafa Arici ([email protected])"

# Deps
RUN rpm --import https://mirror.go-repo.io/fedora/RPM-GPG-KEY-GO-REPO
RUN curl -s https://mirror.go-repo.io/fedora/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
RUN yum -y install golang ruby ruby-devel gcc make redhat-rpm-config git rpm-build rpmdevtools createrepo reprepro npm
RUN gem install fpm
RUN dnf install -y git make yarnpkg nodejs protobuf-compiler protobuf-static openvpn golang
RUN go get golang.org/dl/go1.16.3
RUN $(go env GOPATH)/bin/go1.16.3 download

VOLUME /fs/src/github.com/cad/ovpm
RUN $(go env GOPATH)/bin/go1.16.3 install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
$(go env GOPATH)/bin/go1.16.3 install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && \
$(go env GOPATH)/bin/go1.16.3 install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest && \
$(go env GOPATH)/bin/go1.16.3 install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest && \
$(go env GOPATH)/bin/go1.16.3 install github.com/kevinburke/go-bindata/go-bindata@latest && \
$(go env GOPATH)/bin/go1.16.3 install github.com/goreleaser/nfpm/cmd/nfpm@latest

ENV DIR="/fs/src/github.com/cad/ovpm"
ENV RELEASEDIR=$DIR/release
ENV UNITDIR="/usr/lib/systemd/system/"
ENV GOPATH="/fs/"
RUN dnf install -y which iptables
RUN echo "alias go=$(go env GOPATH)/bin/go1.16.3" >> /root/.bashrc
RUN echo "export PATH=$PATH:$(go env GOPATH)/bin" >> /root/.bashrc

WORKDIR /fs/src/github.com/cad/ovpm
VOLUME /app

CMD ["./build.sh"]
WORKDIR /app
30 changes: 8 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
.PHONY: deps build test bundle-webui clean-bundle bundle-swagger proto bundle build
docker-build:
docker run --rm -i -t -e TRAVIS_GO_VERSION=$(TRAVIS_GO_VERSION) -e TRAVIS_BUILD_NUMBER=$(TRAVIS_BUILD_NUMBER) -e TRAVIS_TAG=$(TRAVIS_TAG) -v `pwd`:/fs/src/github.com/cad/ovpm -w /fs/src/github.com/cad/ovpm cadthecoder/ovpm-builder:latest
docker-build-shell:
docker run --rm -i -t -e TRAVIS_GO_VERSION=$(TRAVIS_GO_VERSION) -e TRAVIS_BUILD_NUMBER=$(TRAVIS_BUILD_NUMBER) -e TRAVIS_TAG=$(TRAVIS_TAG) -v `pwd`:/fs/src/github.com/cad/ovpm -w /fs/src/github.com/cad/ovpm cadthecoder/ovpm-builder:latest /bin/bash

development-deps:
# grpc related dependencies
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go/...

# static asset bundling
go get github.com/kevinburke/go-bindata/...

# for creating rpm, deb packages
go get github.com/goreleaser/nfpm/cmd/nfpm@latest

# webui related dependencies
pacman -Sy yarn

# Runs unit tests.
test:
go test -count=1 -race -coverprofile=coverage.txt -covermode=atomic .

proto:
protoc -I/usr/local/include -I api/pb/ -I/usr/local/include -I$(shell go list -m -f "{{.Dir}}" github.com/grpc-ecosystem/grpc-gateway)/third_party/googleapis api/pb/user.proto api/pb/vpn.proto api/pb/network.proto api/pb/auth.proto --grpc-gateway_out=logtostderr=true:api/pb
protoc -I/usr/local/include -I api/pb/ -I/usr/local/include -I$(shell go list -m -f "{{.Dir}}" github.com/grpc-ecosystem/grpc-gateway)/third_party/googleapis api/pb/user.proto api/pb/vpn.proto api/pb/network.proto api/pb/auth.proto --go_out=plugins=grpc:api/pb
protoc -I./api/pb/ -I/usr/local/include/ --go_opt=paths=source_relative --go_out=./api/pb user.proto vpn.proto network.proto auth.proto
protoc -I./api/pb/ -I/usr/local/include/ --go-grpc_opt=paths=source_relative --go-grpc_out=./api/pb user.proto vpn.proto network.proto auth.proto
protoc -I./api/pb/ -I/usr/local/include/ --grpc-gateway_out ./api/pb \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt paths=source_relative \
--grpc-gateway_opt generate_unbound_methods=true \
user.proto vpn.proto network.proto auth.proto

clean-bundle:
@echo Cleaning up bundle/
Expand All @@ -39,7 +25,7 @@ bundle-webui:
cp -r webui/ovpm/build/* bundle

bundle-swagger: proto
protoc -I/usr/local/include -I api/pb/ -I/usr/local/include -I$(shell go list -m -f "{{.Dir}}" github.com/grpc-ecosystem/grpc-gateway)/third_party/googleapis api/pb/user.proto api/pb/vpn.proto api/pb/network.proto api/pb/auth.proto --swagger_out=logtostderr=true:bundle
protoc -I./api/pb -I/usr/local/include/ --openapiv2_out=./api/pb --openapiv2_opt logtostderr=true user.proto vpn.proto network.proto auth.proto

bundle: clean-bundle bundle-webui bundle-swagger
go-bindata -pkg bundle -o bundle/bindata.go bundle/...
Expand Down
4 changes: 2 additions & 2 deletions api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"strings"

"github.com/sirupsen/logrus"
"github.com/cad/ovpm"
"github.com/cad/ovpm/permset"
"github.com/sirupsen/logrus"
gcontext "golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand All @@ -26,7 +26,7 @@ func authRequired(ctx gcontext.Context, req interface{}, handler grpc.UnaryHandl
return nil, grpc.Errorf(codes.Unauthenticated, "access denied")
}

// Set user's permissions according to it's criterias.
// Set user's permissions according to it's criteria.
var permissions permset.Permset
if user.IsAdmin() {
permissions = permset.New(ovpm.AdminPerms()...)
Expand Down
Loading

0 comments on commit 04655f1

Please sign in to comment.