Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wg-gen-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
wg-gen-web
Commits
0e3aef75
Commit
0e3aef75
authored
Mar 6, 2020
by
vx3r
Browse files
Options
Downloads
Patches
Plain Diff
version link commit / download server wg conf
parent
89850210
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+2
-2
2 additions, 2 deletions
.gitlab-ci.yml
api/api.go
+35
-0
35 additions, 0 deletions
api/api.go
ui/src/App.vue
+11
-1
11 additions, 1 deletion
ui/src/App.vue
ui/src/components/Server.vue
+23
-27
23 additions, 27 deletions
ui/src/components/Server.vue
with
71 additions
and
30 deletions
.gitlab-ci.yml
+
2
−
2
View file @
0e3aef75
...
...
@@ -7,7 +7,7 @@ build-back:
stage
:
build artifacts
image
:
golang:latest
script
:
-
GOOS=linux GOARCH=amd64 go build -ldflags="-X 'gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util.Version=${CI_COMMIT_
SHORT_
SHA}'" -o ${CI_PROJECT_NAME}-linux-amd64
-
GOOS=linux GOARCH=amd64 go build -ldflags="-X 'gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util.Version=${CI_COMMIT_SHA}'" -o ${CI_PROJECT_NAME}-linux-amd64
artifacts
:
paths
:
-
${CI_PROJECT_NAME}-linux-amd64
...
...
@@ -29,7 +29,7 @@ build:
image
:
docker:latest
script
:
-
docker info
-
docker build --build-arg COMMIT=${CI_COMMIT_
SHORT_
SHA} --network br_docker --tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA} .
-
docker build --build-arg COMMIT=${CI_COMMIT_SHA} --network br_docker --tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA} .
push
:
stage
:
push docker hub
...
...
This diff is collapsed.
Click to expand it.
api/api.go
+
35
−
0
View file @
0e3aef75
...
...
@@ -6,6 +6,7 @@ import (
"github.com/skip2/go-qrcode"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/core"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/model"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/template"
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/util"
"net/http"
)
...
...
@@ -28,6 +29,7 @@ func ApplyRoutes(r *gin.Engine) {
{
server
.
GET
(
""
,
readServer
)
server
.
PATCH
(
""
,
updateServer
)
server
.
GET
(
"/config"
,
configServer
)
server
.
GET
(
"/version"
,
version
)
}
}
...
...
@@ -203,6 +205,39 @@ func updateServer(c *gin.Context) {
c
.
JSON
(
http
.
StatusOK
,
client
)
}
func
configServer
(
c
*
gin
.
Context
)
{
clients
,
err
:=
core
.
ReadClients
()
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
"err"
:
err
,
})
.
Error
(
"failed to read clients"
)
c
.
AbortWithStatus
(
http
.
StatusUnprocessableEntity
)
return
}
server
,
err
:=
core
.
ReadServer
()
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
"err"
:
err
,
})
.
Error
(
"failed to read server"
)
c
.
AbortWithStatus
(
http
.
StatusUnprocessableEntity
)
return
}
configData
,
err
:=
template
.
DumpServerWg
(
clients
,
server
)
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
"err"
:
err
,
})
.
Error
(
"failed to dump wg config"
)
c
.
AbortWithStatus
(
http
.
StatusUnprocessableEntity
)
return
}
// return config as txt file
c
.
Header
(
"Content-Disposition"
,
"attachment; filename=wg0.conf"
)
c
.
Data
(
http
.
StatusOK
,
"application/config"
,
configData
)
}
func
version
(
c
*
gin
.
Context
)
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"version"
:
util
.
Version
,
...
...
This diff is collapsed.
Click to expand it.
ui/src/App.vue
+
11
−
1
View file @
0e3aef75
...
...
@@ -28,7 +28,17 @@
</v-content>
<v-footer
app
>
<span>
License
<a
class=
"pr-1 pl-1"
href=
"http://www.wtfpl.net/"
target=
"_blank"
>
WTFPL
</a>
©
{{
new
Date
().
getFullYear
()
}}
Created with
</span><v-icon
class=
"pr-1 pl-1"
>
mdi-heart
</v-icon><span>
by
</span><a
class=
"pr-1 pl-1"
href=
"mailto:vx3r@127-0-0-1.fr"
>
vx3r
</a><v-spacer></v-spacer><span>
Version:
{{
version
}}
</span>
<small>
Copyright
©
{{
new
Date
().
getFullYear
()
}}
, Wg Gen Web.
</small>
<small>
This work is licensed under a
<a
class=
"pr-1 pl-1"
href=
"http://www.wtfpl.net/"
target=
"_blank"
>
WTFPL License.
</a></small>
<v-spacer></v-spacer>
<small>
Created with
</small>
<v-icon
class=
"pr-1 pl-1"
>
mdi-heart
</v-icon><span>
by
</span><a
class=
"pr-1 pl-1"
href=
"mailto:vx3r@127-0-0-1.fr"
>
vx3r
</a>
<v-spacer></v-spacer>
<a
:href=
"'https://github.com/vx3r/wg-gen-web/commit/' + version"
><kbd>
Version:
{{
version
.
substring
(
0
,
7
)
}}
</kbd></a>
</v-footer>
</v-app>
...
...
This diff is collapsed.
Click to expand it.
ui/src/components/Server.vue
+
23
−
27
View file @
0e3aef75
...
...
@@ -7,14 +7,6 @@
<v-list-item-content>
<v-list-item-title
class=
"headline"
>
Server's interface configuration
</v-list-item-title>
</v-list-item-content>
<v-btn
class=
"ma-2"
color=
"warning"
@
click=
"updateServer"
>
Update server configuration
<v-icon
right
dark
>
mdi-update
</v-icon>
</v-btn>
</v-list-item>
<div
class=
"d-flex flex-no-wrap justify-space-between"
>
<v-col
cols=
"12"
>
...
...
@@ -67,14 +59,6 @@
<v-list-item-content>
<v-list-item-title
class=
"headline"
>
Client's global configuration
</v-list-item-title>
</v-list-item-content>
<v-btn
class=
"ma-2"
color=
"warning"
@
click=
"updateServer"
>
Update server configuration
<v-icon
right
dark
>
mdi-update
</v-icon>
</v-btn>
</v-list-item>
<div
class=
"d-flex flex-no-wrap justify-space-between"
>
<v-col
cols=
"12"
>
...
...
@@ -130,14 +114,6 @@
<v-list-item-content>
<v-list-item-title
class=
"headline"
>
Interface configuration hooks
</v-list-item-title>
</v-list-item-content>
<v-btn
class=
"ma-2"
color=
"warning"
@
click=
"updateServer"
>
Update server configuration
<v-icon
right
dark
>
mdi-update
</v-icon>
</v-btn>
</v-list-item>
<div
class=
"d-flex flex-no-wrap justify-space-between"
>
<v-col
cols=
"12"
>
...
...
@@ -162,13 +138,32 @@
</v-card>
</v-col>
</v-row>
<v-row>
<v-divider
dark
/>
<v-btn
class=
"ma-2"
color=
"success"
:href=
"`${apiBaseUrl}/server/config`"
>
Download server configuration
<v-icon
right
dark
>
mdi-cloud-download-outline
</v-icon>
</v-btn>
<v-spacer></v-spacer>
<v-btn
class=
"ma-2"
color=
"warning"
@
click=
"updateServer"
>
Update server configuration
<v-icon
right
dark
>
mdi-update
</v-icon>
</v-btn>
<v-divider
dark
/>
</v-row>
<Notification
v-bind:notification=
"notification"
/>
</v-container>
</template>
<
script
>
import
{
ApiService
}
from
"
../services/ApiService
"
;
import
{
API_BASE_URL
,
ApiService
}
from
"
../services/ApiService
"
;
import
Notification
from
'
../components/Notification
'
export
default
{
...
...
@@ -181,6 +176,7 @@
data
:
()
=>
({
api
:
null
,
server
:
null
,
apiBaseUrl
:
API_BASE_URL
,
notification
:
{
show
:
false
,
color
:
''
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment