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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
wg-gen-web
Commits
260f7333
Commit
260f7333
authored
5 years ago
by
Stephen Boyle
Browse files
Options
Downloads
Patches
Plain Diff
default client allowed ips in server config
parent
eecea63d
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
core/server.go
+4
-0
4 additions, 0 deletions
core/server.go
model/server.go
+7
-0
7 additions, 0 deletions
model/server.go
ui/src/components/Clients.vue
+1
-1
1 addition, 1 deletion
ui/src/components/Clients.vue
ui/src/components/Server.vue
+32
-0
32 additions, 0 deletions
ui/src/components/Server.vue
with
44 additions
and
1 deletion
core/server.go
+
4
−
0
View file @
260f7333
...
...
@@ -36,6 +36,10 @@ func ReadServer() (*model.Server, error) {
server
.
Dns
=
append
(
server
.
Dns
,
"fd9f::10:0:0:2"
)
server
.
Dns
=
append
(
server
.
Dns
,
"10.0.0.2"
)
server
.
AllowedIPs
=
make
([]
string
,
0
)
server
.
AllowedIPs
=
append
(
server
.
AllowedIPs
,
"0.0.0.0/0"
)
server
.
AllowedIPs
=
append
(
server
.
AllowedIPs
,
"::/0"
)
server
.
PersistentKeepalive
=
16
server
.
Mtu
=
0
server
.
PreUp
=
"echo WireGuard PreUp"
...
...
This diff is collapsed.
Click to expand it.
model/server.go
+
7
−
0
View file @
260f7333
...
...
@@ -16,6 +16,7 @@ type Server struct {
Endpoint
string
`json:"endpoint"`
PersistentKeepalive
int
`json:"persistentKeepalive"`
Dns
[]
string
`json:"dns"`
AllowedIPs
[]
string
`json:"allowedips"`
PreUp
string
`json:"preUp"`
PostUp
string
`json:"postUp"`
PreDown
string
`json:"preDown"`
...
...
@@ -59,6 +60,12 @@ func (a Server) IsValid() []error {
errs
=
append
(
errs
,
fmt
.
Errorf
(
"dns %s is invalid"
,
dns
))
}
}
// check if the allowedIPs are valid
for
_
,
allowedIP
:=
range
a
.
AllowedIPs
{
if
!
util
.
IsValidCidr
(
allowedIP
)
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"allowedIP %s is invalid"
,
allowedIP
))
}
}
return
errs
}
This diff is collapsed.
Click to expand it.
ui/src/components/Clients.vue
+
1
−
1
View file @
260f7333
...
...
@@ -382,7 +382,7 @@
name
:
""
,
email
:
""
,
enable
:
true
,
allowedIPs
:
[
"
0.0.0.0/0
"
,
"
::/0
"
]
,
allowedIPs
:
this
.
server
.
allowedips
,
address
:
this
.
server
.
address
,
}
},
...
...
This diff is collapsed.
Click to expand it.
ui/src/components/Server.vue
+
32
−
0
View file @
260f7333
...
...
@@ -85,6 +85,26 @@
</v-chip>
</
template
>
</v-combobox>
<v-combobox
v-model=
"server.allowedips"
chips
hint=
"Write IPv4 or IPv6 address and hit enter"
label=
"Default Allowed IPs for clients"
multiple
dark
>
<
template
v-slot:selection=
"{ attrs, item, select, selected }"
>
<v-chip
v-bind=
"attrs"
:input-value=
"selected"
close
@
click=
"select"
@
click:close=
"server.allowedips.splice(server.allowedips.indexOf(item), 1)"
>
<strong>
{{
item
}}
</strong>
</v-chip>
</
template
>
</v-combobox>
<v-text-field
type=
"number"
v-model=
"server.mtu"
...
...
@@ -218,6 +238,18 @@
}
}
// check client AllowedIPs
if
(
this
.
server
.
allowedips
.
length
<
1
)
{
this
.
notify
(
'
error
'
,
'
Please provide at least one valid CIDR address for client allowed IPs
'
);
return
;
}
for
(
let
i
=
0
;
i
<
this
.
server
.
allowedips
.
length
;
i
++
){
if
(
this
.
$isCidr
(
this
.
server
.
allowedips
[
i
])
===
0
)
{
this
.
notify
(
'
error
'
,
'
Invalid CIDR detected, please correct before submitting
'
);
return
}
}
this
.
api
.
patch
(
'
/server
'
,
this
.
server
).
then
((
res
)
=>
{
this
.
notify
(
'
success
'
,
"
Server successfully updated
"
);
this
.
server
=
res
;
...
...
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