Skip to content

Commit 983dfdb

Browse files
Merge pull request #770 from yggdrasil-network/develop
Version 0.3.16
2 parents d367254 + ac37591 commit 983dfdb

39 files changed

+1308
-1086
lines changed

.circleci/config.yml

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version: 2.1
55
jobs:
66
lint:
77
docker:
8-
- image: circleci/golang:1.14.1
8+
- image: circleci/golang:1.16
99

1010
steps:
1111
- checkout
@@ -18,7 +18,7 @@ jobs:
1818
1919
build-linux:
2020
docker:
21-
- image: circleci/golang:1.14.1
21+
- image: circleci/golang:1.16
2222

2323
steps:
2424
- checkout
@@ -119,11 +119,11 @@ jobs:
119119
echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
120120
121121
- run:
122-
name: Install Go 1.14.1
122+
name: Install Go 1.16
123123
command: |
124124
cd /tmp
125-
curl -LO https://dl.google.com/go/go1.14.1.darwin-amd64.pkg
126-
sudo installer -pkg /tmp/go1.14.1.darwin-amd64.pkg -target /
125+
curl -LO https://dl.google.com/go/go1.16.darwin-amd64.pkg
126+
sudo installer -pkg /tmp/go1.16.darwin-amd64.pkg -target /
127127
128128
#- run:
129129
# name: Install Gomobile
@@ -157,9 +157,46 @@ jobs:
157157
paths:
158158
- upload
159159

160+
build-windows:
161+
docker:
162+
- image: circleci/golang:1.16
163+
164+
steps:
165+
- checkout
166+
167+
- run:
168+
name: Create artifact upload directory and set variables
169+
command: |
170+
mkdir /tmp/upload
171+
echo 'export CINAME=$(sh contrib/semver/name.sh)' >> $BASH_ENV
172+
echo 'export CIVERSION=$(sh contrib/semver/version.sh --bare)' >> $BASH_ENV
173+
git config --global user.email "$(git log --format='%ae' HEAD -1)";
174+
git config --global user.name "$(git log --format='%an' HEAD -1)";
175+
176+
- run:
177+
name: Install tools
178+
command: |
179+
sudo apt-get update
180+
sudo apt-get -y install msitools wixl
181+
182+
- run:
183+
name: Build for Windows
184+
command: |
185+
rm -f {yggdrasil,yggdrasilctl}
186+
GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-amd64.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-amd64.exe;
187+
GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-i386.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-i386.exe;
188+
bash contrib/msi/build-msi.sh x64
189+
bash contrib/msi/build-msi.sh x86
190+
mv *.msi /tmp/upload
191+
192+
- persist_to_workspace:
193+
root: /tmp
194+
paths:
195+
- upload
196+
160197
build-other:
161198
docker:
162-
- image: circleci/golang:1.14.1
199+
- image: circleci/golang:1.16
163200

164201
steps:
165202
- checkout
@@ -187,13 +224,6 @@ jobs:
187224
GOOS=freebsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-amd64 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-freebsd-amd64;
188225
GOOS=freebsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-i386 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-freebsd-i386;
189226
190-
- run:
191-
name: Build for Windows
192-
command: |
193-
rm -f {yggdrasil,yggdrasilctl}
194-
GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-amd64.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-amd64.exe;
195-
GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-i386.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-i386.exe;
196-
197227
- persist_to_workspace:
198228
root: /tmp
199229
paths:
@@ -215,17 +245,13 @@ workflows:
215245
build:
216246
jobs:
217247
- lint
218-
- build-linux:
219-
requires:
220-
- lint
221-
- build-macos:
222-
requires:
223-
- lint
224-
- build-other:
225-
requires:
226-
- lint
248+
- build-linux
249+
- build-macos
250+
- build-windows
251+
- build-other
227252
- upload:
228253
requires:
229254
- build-linux
230255
- build-macos
256+
- build-windows
231257
- build-other

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2525
- in case of vulnerabilities.
2626
-->
2727

28+
## [0.3.16] - 2021-03-18
29+
### Added
30+
- New simulation code under `cmd/yggdrasilsim` (work-in-progress)
31+
32+
### Changed
33+
- Multi-threading in the switch
34+
- Swich lookups happen independently for each (incoming) peer connection, instead of being funneled to a single dedicated switch worker
35+
- Packets are queued for each (outgoing) peer connection, instead of being handled by a single dedicated switch worker
36+
- Queue logic rewritten
37+
- Heap structure per peer that traffic is routed to, with one FIFO queue per traffic flow
38+
- The total size of each heap is configured automatically (we basically queue packets until we think we're blocked on a socket write)
39+
- When adding to a full heap, the oldest packet from the largest queue is dropped
40+
- Packets are popped from the queue in FIFO order (oldest packet from among all queues in the heap) to prevent packet reordering at the session level
41+
- Removed global `sync.Pool` of `[]byte`
42+
- Local `sync.Pool`s are used in the hot loops, but not exported, to avoid memory corruption if libraries are reused by other projects
43+
- This may increase allocations (and slightly reduce speed in CPU-bound benchmarks) when interacting with the tun/tap device, but traffic forwarded at the switch layer should be unaffected
44+
- Upgrade dependencies
45+
- Upgrade build to Go 1.16
46+
47+
### Fixed
48+
- Fixed a bug where the connection listener could exit prematurely due to resoruce exhaustion (if e.g. too many connections were opened)
49+
- Fixed DefaultIfName for OpenBSD (`/dev/tun0` -> `tun0`)
50+
- Fixed an issue where a peer could sometimes never be added to the switch
51+
- Fixed a goroutine leak that could occur if a peer with an open connection continued to spam additional connection attempts
52+
2853
## [0.3.15] - 2020-09-27
2954
### Added
3055
- Support for pinning remote public keys in peering strings has been added, e.g.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ You may also find other platform-specific wrappers, scripts or tools in the
4848
If you want to build from source, as opposed to installing one of the pre-built
4949
packages:
5050

51-
1. Install [Go](https://golang.org) (requires Go 1.13 or later)
51+
1. Install [Go](https://golang.org) (requires Go 1.16 or later)
5252
2. Clone this repository
5353
2. Run `./build`
5454

appveyor.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

cmd/yggdrasilsim/dial.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"sort"
6+
"time"
7+
8+
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
9+
)
10+
11+
func doListen(recvNode *simNode) {
12+
// TODO be able to stop the listeners somehow so they don't leak across different tests
13+
for {
14+
c, err := recvNode.listener.Accept()
15+
if err != nil {
16+
panic(err)
17+
}
18+
c.Close()
19+
}
20+
}
21+
22+
func dialTest(sendNode, recvNode *simNode) {
23+
if sendNode.id == recvNode.id {
24+
fmt.Println("Skipping dial to self")
25+
return
26+
}
27+
var mask crypto.NodeID
28+
for idx := range mask {
29+
mask[idx] = 0xff
30+
}
31+
for {
32+
c, err := sendNode.dialer.DialByNodeIDandMask(nil, &recvNode.nodeID, &mask)
33+
if c != nil {
34+
c.Close()
35+
return
36+
}
37+
if err != nil {
38+
fmt.Println("Dial failed:", err)
39+
}
40+
time.Sleep(time.Second)
41+
}
42+
}
43+
44+
func dialStore(store nodeStore) {
45+
var nodeIdxs []int
46+
for idx, n := range store {
47+
nodeIdxs = append(nodeIdxs, idx)
48+
go doListen(n)
49+
}
50+
sort.Slice(nodeIdxs, func(i, j int) bool {
51+
return nodeIdxs[i] < nodeIdxs[j]
52+
})
53+
for _, idx := range nodeIdxs {
54+
sendNode := store[idx]
55+
for _, jdx := range nodeIdxs {
56+
recvNode := store[jdx]
57+
fmt.Printf("Dialing from node %d to node %d / %d...\n", idx, jdx, len(store))
58+
dialTest(sendNode, recvNode)
59+
}
60+
}
61+
}

cmd/yggdrasilsim/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package main
2+
3+
func main() {
4+
store := makeStoreSquareGrid(4)
5+
dialStore(store)
6+
}

cmd/yggdrasilsim/node.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"io/ioutil"
5+
6+
"github.com/gologme/log"
7+
8+
"github.com/yggdrasil-network/yggdrasil-go/src/config"
9+
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
10+
"github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
11+
)
12+
13+
type simNode struct {
14+
core yggdrasil.Core
15+
id int
16+
nodeID crypto.NodeID
17+
dialer *yggdrasil.Dialer
18+
listener *yggdrasil.Listener
19+
}
20+
21+
func newNode(id int) *simNode {
22+
n := simNode{id: id}
23+
n.core.Start(config.GenerateConfig(), log.New(ioutil.Discard, "", 0))
24+
n.nodeID = *n.core.NodeID()
25+
n.dialer, _ = n.core.ConnDialer()
26+
n.listener, _ = n.core.ConnListen()
27+
return &n
28+
}

cmd/yggdrasilsim/store.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
type nodeStore map[int]*simNode
4+
5+
func makeStoreSingle() nodeStore {
6+
s := make(nodeStore)
7+
s[0] = newNode(0)
8+
return s
9+
}
10+
11+
func linkNodes(a *simNode, b *simNode) {
12+
la := a.core.NewSimlink()
13+
lb := b.core.NewSimlink()
14+
la.SetDestination(lb)
15+
lb.SetDestination(la)
16+
la.Start()
17+
lb.Start()
18+
}
19+
20+
func makeStoreSquareGrid(sideLength int) nodeStore {
21+
store := make(nodeStore)
22+
nNodes := sideLength * sideLength
23+
idxs := make([]int, 0, nNodes)
24+
// TODO shuffle nodeIDs
25+
for idx := 1; idx <= nNodes; idx++ {
26+
idxs = append(idxs, idx)
27+
}
28+
for _, idx := range idxs {
29+
n := newNode(idx)
30+
store[idx] = n
31+
}
32+
for idx := 0; idx < nNodes; idx++ {
33+
if (idx % sideLength) != 0 {
34+
linkNodes(store[idxs[idx]], store[idxs[idx-1]])
35+
}
36+
if idx >= sideLength {
37+
linkNodes(store[idxs[idx]], store[idxs[idx-sideLength]])
38+
}
39+
}
40+
return store
41+
}

contrib/apparmor/usr.bin.yggdrasil

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
# Last Modified: Tue Mar 10 16:38:14 2020
1+
# Last Modified: Fri Oct 30 11:33:31 2020
22
#include <tunables/global>
33

44
/usr/bin/yggdrasil {
55
#include <abstractions/base>
6+
#include <abstractions/nameservice>
67

78
capability net_admin,
89
capability net_raw,
910

10-
network inet stream,
11-
network inet dgram,
12-
network inet6 dgram,
13-
network inet6 stream,
14-
network netlink raw,
15-
16-
/lib/@{multiarch}/ld-*.so mr,
17-
/proc/sys/net/core/somaxconn r,
18-
owner /sys/kernel/mm/transparent_hugepage/hpage_pmd_size r,
1911
/dev/net/tun rw,
12+
/proc/sys/net/core/somaxconn r,
13+
/sys/kernel/mm/transparent_hugepage/hpage_pmd_size r,
2014

21-
/usr/bin/yggdrasil mr,
2215
/etc/yggdrasil.conf rw,
2316
/run/yggdrasil.sock rw,
24-
2517
}

contrib/deb/generate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ then
8383
echo "Backing up configuration file to /var/backups/yggdrasil.conf.`date +%Y%m%d`"
8484
cp /etc/yggdrasil.conf /var/backups/yggdrasil.conf.`date +%Y%m%d`
8585
echo "Normalising and updating /etc/yggdrasil.conf"
86-
/usr/bin/yggdrasil -useconffile /var/backups/yggdrasil.conf.`date +%Y%m%d` -normaliseconf > /etc/yggdrasil.conf
86+
/usr/bin/yggdrasil -useconf -normaliseconf < /var/backups/yggdrasil.conf.`date +%Y%m%d` > /etc/yggdrasil.conf
8787
chgrp yggdrasil /etc/yggdrasil.conf
8888
8989
if command -v systemctl >/dev/null; then
@@ -94,7 +94,7 @@ then
9494
else
9595
echo "Generating initial configuration file /etc/yggdrasil.conf"
9696
echo "Please familiarise yourself with this file before starting Yggdrasil"
97-
/usr/bin/yggdrasil -genconf > /etc/yggdrasil.conf
97+
sh -c 'umask 0027 && /usr/bin/yggdrasil -genconf > /etc/yggdrasil.conf'
9898
chgrp yggdrasil /etc/yggdrasil.conf
9999
fi
100100
EOF

0 commit comments

Comments
 (0)