Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hepto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
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
ACIDES
Hepto
Commits
3dbd7648
Commit
3dbd7648
authored
1 year ago
by
kaiyou
Browse files
Options
Downloads
Patches
Plain Diff
Fix the wireguard setup, add a /128 for every node instead of prefix
parent
7461adf7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#28884
passed
1 year ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wg/peer.go
+3
-1
3 additions, 1 deletion
wg/peer.go
wg/wireguard.go
+5
-4
5 additions, 4 deletions
wg/wireguard.go
with
8 additions
and
5 deletions
wg/peer.go
+
3
−
1
View file @
3dbd7648
...
...
@@ -21,9 +21,11 @@ func (w *Wireguard) peerToWgConfig(p Peer) (wgtypes.PeerConfig, error) {
return
wgtypes
.
PeerConfig
{},
err
}
overlay
:=
p
.
OverlayIP
()
// Add the peer itself as a /128 directly, so that the peer overlay ip is both
// accepted and added to the route table
allowed
:=
[]
net
.
IPNet
{{
IP
:
overlay
.
Addr
()
.
AsSlice
(),
Mask
:
net
.
CIDRMask
(
overlay
.
Bits
(),
overlay
.
Addr
()
.
BitLen
()),
Mask
:
net
.
CIDRMask
(
overlay
.
Addr
()
.
BitLen
(),
overlay
.
Addr
()
.
BitLen
()),
}}
for
_
,
route
:=
range
p
.
Routes
()
{
allowed
=
append
(
allowed
,
net
.
IPNet
{
...
...
This diff is collapsed.
Click to expand it.
wg/wireguard.go
+
5
−
4
View file @
3dbd7648
...
...
@@ -89,16 +89,17 @@ func (w *Wireguard) Update(peers []Peer, mtu int) error {
}
// Setup peers, add routes even before we configure keys, this is harmless
// and makes the code way simpler
peerConfigs
:=
make
(
[]
wgtypes
.
PeerConfig
,
len
(
peers
))
for
i
,
peer
:=
range
peers
{
peerConfigs
:=
[]
wgtypes
.
PeerConfig
{}
for
_
,
peer
:=
range
peers
{
config
,
err
:=
w
.
peerToWgConfig
(
peer
)
if
err
!=
nil
{
w
.
logger
.
Info
(
"invalid peer"
,
"name"
,
peer
.
Hostname
())
continue
}
w
.
logger
.
Info
(
"new peer"
,
"config"
,
config
)
for
_
,
route
:=
range
config
.
AllowedIPs
{
var
gw
net
.
IP
w
.
logger
.
Info
(
"
new
route"
,
"dest"
,
route
.
String
())
w
.
logger
.
Info
(
"
adding
route"
,
"dest"
,
route
.
String
())
scope
:=
netlink
.
SCOPE_LINK
// Convert back and forth net and netip, this is ugly but makes
// the code structure simpler
...
...
@@ -117,7 +118,7 @@ func (w *Wireguard) Update(peers []Peer, mtu int) error {
w
.
logger
.
Error
(
err
,
"could not add route"
,
"route"
,
route
)
}
}
peerConfigs
[
i
]
=
config
peerConfigs
=
append
(
peerConfigs
,
config
)
}
// Finally update the device crypto and peer list
err
=
w
.
client
.
ConfigureDevice
(
w
.
iface
,
wgtypes
.
Config
{
...
...
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