diff --git a/Dockerfile b/Dockerfile index 29a8405..04d7a4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,18 @@ -FROM golang:1.14.2-alpine3.11 AS backend-builder +FROM golang:1.14.2-buster AS backend-builder COPY . /app -#RUN apk --no-cache add build-base git gcc -RUN cd /app && env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags='-extldflags "-static" -s -w' -o openvpn-admin +RUN cd /app && env CGO_ENABLED=./1 GOOS=linux GOARCH=amd64 go build -ldflags='-linkmode external -extldflags "-static" -s -w' -o openvpn-admin FROM node:14.2-alpine3.11 AS frontend-builder COPY frontend/ /app RUN cd /app && npm install && npm run build -FROM golang:1.14.2-buster AS user-builder -RUN git clone https://github.com/pashcovich/openvpn-user /app && cd /app && env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags='-linkmode external -extldflags "-static" -s -w' -o openvpn-user - FROM alpine:3.13 WORKDIR /app COPY --from=backend-builder /app/openvpn-admin /app -COPY --from=user-builder /app/openvpn-user /usr/local/bin COPY --from=frontend-builder /app/static /app/static COPY client.conf.tpl /app/client.conf.tpl COPY ccd.tpl /app/ccd.tpl RUN apk add --update bash easy-rsa && \ ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \ + wget https://github.com/pashcovich/openvpn-user/releases/download/v1.0.3-rc.1/openvpn-user-linux-amd64.tar.gz -O - | tar xz -C /usr/local/bin && \ rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* diff --git a/Dockerfile.openvpn b/Dockerfile.openvpn index f0c5072..ee5f785 100644 --- a/Dockerfile.openvpn +++ b/Dockerfile.openvpn @@ -1,10 +1,7 @@ -FROM golang:1.14.2-buster AS user-builder -RUN git clone https://github.com/pashcovich/openvpn-user /app && cd /app && env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags='-linkmode external -extldflags "-static" -s -w' -o openvpn-user - FROM alpine:3.13 -COPY --from=user-builder /app/openvpn-user /usr/local/bin RUN apk add --update bash openvpn easy-rsa && \ ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \ + wget https://github.com/pashcovich/openvpn-user/releases/download/v1.0.3-rc.1/openvpn-user-linux-amd64.tar.gz -O - | tar xz -C /usr/local/bin && \ rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* -COPY .werffiles /etc/openvpn/setup +COPY setup/ /etc/openvpn/setup RUN chmod +x /etc/openvpn/setup/configure.sh diff --git a/build.sh b/build.sh index b17b614..ce6f2ff 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags='-extldflags "-static" -s -w' -o openvpn-admin +CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-linkmode external -extldflags -static -s -w" -o openvpn-admin diff --git a/client.conf.tpl b/client.conf.tpl index b5a8c6d..7f29c47 100644 --- a/client.conf.tpl +++ b/client.conf.tpl @@ -1,5 +1,5 @@ {{- range $server := .Hosts }} -remote {{ $server.Host }} {{ $server.Port }} tcp +remote {{ $server.Host }} {{ $server.Port }} {{ $server.Protocol }} {{- end }} verb 4 diff --git a/docker-compose-slave.yaml b/docker-compose-slave.yaml index e55a5f2..d1d00ae 100644 --- a/docker-compose-slave.yaml +++ b/docker-compose-slave.yaml @@ -22,7 +22,7 @@ services: build: context: . image: openvpn-admin:local - command: /app/openvpn-admin --debug --ovpn.network="172.16.100.0/22" --master.sync-token="TOKEN" --master.host="http://172.20.0.1:8080" --role="slave" --ovpn.host="127.0.0.1:7744" --ovpn.host="127.0.0.1:7778" --auth.password + command: /app/openvpn-admin --debug --ovpn.network="172.16.100.0/22" --master.sync-token="TOKEN" --master.host="http://172.20.0.1:8080" --role="slave" --ovpn.server="127.0.0.1:7744" --ovpn.server="127.0.0.1:7778" --auth.password environment: - OPVN_SLAVE=1 network_mode: service:openvpn diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 975817e..8a2d672 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -7838,6 +7838,11 @@ "vue-style-loader": "^4.1.0" } }, + "vue-notification": { + "version": "1.3.20", + "resolved": "https://registry.npmjs.org/vue-notification/-/vue-notification-1.3.20.tgz", + "integrity": "sha512-vPj67Ah72p8xvtyVE8emfadqVWguOScAjt6OJDEUdcW5hW189NsqvfkOrctxHUUO9UYl9cTbIkzAEcPnHu+zBQ==" + }, "vue-style-loader": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index ca0b2fa..0e04fe3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,7 +14,8 @@ "vue": "^2.6.12", "vue-clipboard2": "^0.2.1", "vue-cookies": "^1.7.4", - "vue-good-table": "^2.21.1" + "vue-good-table": "^2.21.1", + "vue-notification": "^1.3.20" }, "browserslist": [ "> 1%", diff --git a/frontend/src/main.js b/frontend/src/main.js index 15e9868..cbc2e12 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -3,12 +3,14 @@ import axios from 'axios'; import VueCookies from 'vue-cookies' import VueClipboard from 'vue-clipboard2' import VueGoodTablePlugin from 'vue-good-table' +import Notifications from 'vue-notification' import 'vue-good-table/dist/vue-good-table.css' Vue.use(VueClipboard) Vue.use(VueGoodTablePlugin) Vue.use(VueCookies) +Vue.use(Notifications) var axios_cfg = function(url, data='', type='form') { if (data == '') { @@ -182,6 +184,7 @@ new Vue({ axios.request(axios_cfg('api/user/revoke', data, 'form')) .then(function(response) { _this.getUserData(); + _this.$notify({title: 'User ' + _this.username + ' revoked!', type: 'warn'}) }); }) _this.$root.$on('u-unrevoke', function () { @@ -190,6 +193,7 @@ new Vue({ axios.request(axios_cfg('api/user/unrevoke', data, 'form')) .then(function(response) { _this.getUserData(); + _this.$notify({title: 'User ' + _this.username + ' unrevoked!', type: 'success'}) }); }) _this.$root.$on('u-show-config', function () { @@ -289,6 +293,15 @@ new Vue({ _this.rows = response.data; }); }, + + staticAddrCheckboxOnChange: function() { + var staticAddrInput = document.getElementById('static-address'); + var staticAddrEnable = document.getElementById('enable-static'); + + staticAddrInput.disabled = !staticAddrEnable.checked; + staticAddrInput.value == "dynamic" ? staticAddrInput.value = "" : staticAddrInput.value = "dynamic"; + }, + getServerRole: function() { var _this = this; axios.request(axios_cfg('api/server/role')) @@ -318,9 +331,12 @@ new Vue({ _this.u.newUserName = ''; _this.u.newUserPassword = ''; _this.getUserData(); + _this.$notify({title: 'New user ' + _this.username + ' created', type: 'success'}) }) .catch(function(error) { _this.u.newUserCreateError = error.response.data; + _this.$notify({title: 'New user ' + _this.username + ' creation failed.', type: 'error'}) + }); }, @@ -334,10 +350,12 @@ new Vue({ .then(function(response) { _this.u.ccdApplyStatus = 200; _this.u.ccdApplyStatusMessage = response.data; + _this.$notify({title: 'Ccd for user ' + _this.username + ' applied', type: 'success'}) }) .catch(function(error) { _this.u.ccdApplyStatus = error.response.status; _this.u.ccdApplyStatusMessage = error.response.data; + _this.$notify({title: 'Ccd for user ' + _this.username + ' apply failed ', type: 'error'}) }); }, @@ -354,13 +372,14 @@ new Vue({ .then(function(response) { _this.u.passwordChangeStatus = 200; _this.u.newPassword = ''; - _this.u.passwordChangeMessage = response.data.message; _this.getUserData(); _this.u.modalChangePasswordVisible = false; + _this.$notify({title: 'Password for user ' + _this.username + ' changed!', type: 'success'}) }) .catch(function(error) { _this.u.passwordChangeStatus = error.response.status; _this.u.passwordChangeMessage = error.response.data.message; + _this.$notify({title: 'Changing password for user ' + _this.username + ' failed!', type: 'error'}) }); }, } diff --git a/frontend/static/index.html b/frontend/static/index.html index 485469e..a317ed3 100644 --- a/frontend/static/index.html +++ b/frontend/static/index.html @@ -89,7 +89,7 @@ @@ -127,10 +127,10 @@
Static address:
- +
- +