Skip to content

Commit 9538a73

Browse files
author
Vadym Vikulin
authored
Merge pull request #62 from RiV-chain/RCL-56
RCL-56 IPv6 multicasting fix for Android 11 and above
2 parents 3ec7952 + d4dfaa9 commit 9538a73

File tree

18 files changed

+183
-179
lines changed

18 files changed

+183
-179
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Lint
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/setup-go@v3
18+
- uses: actions/setup-go@v5
1919
with:
2020
go-version: 1.19
2121
# - uses: actions/checkout@v3
@@ -34,31 +34,31 @@ jobs:
3434

3535
steps:
3636
- name: Checkout repository
37-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
3838

3939
- name: Initialize CodeQL
40-
uses: github/codeql-action/init@v2
40+
uses: github/codeql-action/init@v3
4141
with:
4242
languages: go
4343

4444
- name: Autobuild
45-
uses: github/codeql-action/autobuild@v2
45+
uses: github/codeql-action/autobuild@v3
4646

4747
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@v2
48+
uses: github/codeql-action/analyze@v3
4949

5050
build-linux:
5151
strategy:
5252
fail-fast: false
5353
matrix:
54-
goversion: ["1.18", "1.19"]
54+
goversion: ["1.21", "1.22"]
5555

5656
name: Build & Test (Linux, Go ${{ matrix.goversion }})
5757
needs: [lint]
5858

5959
runs-on: ubuntu-latest
6060
steps:
61-
- uses: actions/checkout@v3
61+
- uses: actions/checkout@v4
6262

6363
- name: Install webkit2gtk-4.0
6464
uses: awalsh128/cache-apt-pkgs-action@latest
@@ -67,7 +67,7 @@ jobs:
6767
version: 1.0
6868

6969
- name: Set up Go
70-
uses: actions/setup-go@v3
70+
uses: actions/setup-go@v5
7171
with:
7272
go-version: ${{ matrix.goversion }}
7373

@@ -81,17 +81,17 @@ jobs:
8181
strategy:
8282
fail-fast: false
8383
matrix:
84-
goversion: ["1.19"]
84+
goversion: ["1.22"]
8585

8686
name: Build & Test (Windows, Go ${{ matrix.goversion }})
8787
needs: [lint]
8888

8989
runs-on: windows-latest
9090
steps:
91-
- uses: actions/checkout@v3
91+
- uses: actions/checkout@v4
9292

9393
- name: Set up Go
94-
uses: actions/setup-go@v3
94+
uses: actions/setup-go@v5
9595
with:
9696
go-version: ${{ matrix.goversion }}
9797

@@ -105,17 +105,17 @@ jobs:
105105
strategy:
106106
fail-fast: false
107107
matrix:
108-
goversion: ["1.19"]
108+
goversion: ["1.22"]
109109

110110
name: Build & Test (macOS, Go ${{ matrix.goversion }})
111111
needs: [lint]
112112

113113
runs-on: macos-latest
114114
steps:
115-
- uses: actions/checkout@v3
115+
- uses: actions/checkout@v4
116116

117117
- name: Set up Go
118-
uses: actions/setup-go@v3
118+
uses: actions/setup-go@v5
119119
with:
120120
go-version: ${{ matrix.goversion }}
121121

.github/workflows/pkg.yml

Lines changed: 27 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -3,135 +3,36 @@ name: Packages
33
on:
44
workflow_dispatch:
55

6-
concurrency:
7-
group: ${{ github.workflow }}-${{ github.ref }}
8-
cancel-in-progress: true
9-
106
jobs:
11-
build-packages-debian:
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
pkgarch: ["amd64", "i386", "mips", "mipsel", "armhf", "armel", "arm64"]
167

17-
name: Package (Debian, ${{ matrix.pkgarch }})
8+
build-libs-android:
189

10+
name: Build libs (Android)
1911
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v3
22-
with:
23-
fetch-depth: 0
24-
25-
- name: Set up Go
26-
uses: actions/setup-go@v3
27-
with:
28-
go-version: 1.19
29-
30-
- name: Build package
31-
env:
32-
PKGARCH: ${{ matrix.pkgarch }}
33-
run: sh contrib/deb/generate.sh
34-
35-
- name: Upload artifacts
36-
uses: actions/upload-artifact@v3
37-
with:
38-
name: Debian package (${{ matrix.pkgarch }})
39-
path: "*.deb"
40-
if-no-files-found: error
41-
42-
build-packages-macos:
43-
strategy:
44-
fail-fast: false
45-
matrix:
46-
pkgarch: ["amd64", "arm64"]
47-
48-
name: Package (macOS, ${{ matrix.pkgarch }})
49-
50-
runs-on: macos-latest
51-
steps:
52-
- uses: actions/checkout@v3
53-
with:
54-
fetch-depth: 0
55-
56-
- name: Set up Go
57-
uses: actions/setup-go@v3
58-
with:
59-
go-version: 1.19
60-
61-
- name: Build package
62-
env:
63-
PKGARCH: ${{ matrix.pkgarch }}
64-
run: sh contrib/macos/create-pkg.sh
65-
66-
- name: Upload artifacts
67-
uses: actions/upload-artifact@v3
68-
with:
69-
name: macOS package (${{ matrix.pkgarch }})
70-
path: "*.pkg"
71-
if-no-files-found: error
72-
73-
build-packages-windows:
74-
strategy:
75-
fail-fast: false
76-
matrix:
77-
pkgarch: ["x64", "x86", "arm", "arm64"]
7812

79-
name: Package (Windows, ${{ matrix.pkgarch }})
80-
81-
runs-on: windows-latest
8213
steps:
83-
- uses: actions/checkout@v3
84-
with:
85-
fetch-depth: 0
86-
87-
- name: Set up Go
88-
uses: actions/setup-go@v3
89-
with:
90-
go-version: 1.19
91-
92-
- name: Build package
93-
run: sh contrib/msi/build-msi.sh ${{ matrix.pkgarch }}
94-
95-
- name: Upload artifacts
96-
uses: actions/upload-artifact@v3
97-
with:
98-
name: Windows package (${{ matrix.pkgarch }})
99-
path: "*.msi"
100-
if-no-files-found: error
101-
102-
build-packages-router:
103-
strategy:
104-
fail-fast: false
105-
matrix:
106-
pkgarch: ["edgerouter-x", "edgerouter-lite", "vyos-amd64", "vyos-i386"]
107-
108-
name: Package (Router, ${{ matrix.pkgarch }})
109-
110-
runs-on: ubuntu-latest
111-
steps:
112-
- uses: actions/checkout@v3
113-
with:
114-
fetch-depth: 0
115-
path: yggdrasil
116-
117-
- uses: actions/checkout@v3
118-
with:
119-
repository: neilalexander/vyatta-yggdrasil
120-
path: vyatta-yggdrasil
121-
122-
- name: Set up Go
123-
uses: actions/setup-go@v3
124-
with:
125-
go-version: 1.19
126-
127-
- name: Build package
128-
env:
129-
BUILDDIR_YGG: /home/runner/work/yggdrasil-go/yggdrasil-go/yggdrasil
130-
run: cd /home/runner/work/yggdrasil-go/yggdrasil-go/vyatta-yggdrasil && ./build-${{ matrix.pkgarch }}
131-
132-
- name: Upload artifacts
133-
uses: actions/upload-artifact@v3
134-
with:
135-
name: Router package (${{ matrix.pkgarch }})
136-
path: "/home/runner/work/yggdrasil-go/yggdrasil-go/vyatta-yggdrasil/*.deb"
137-
if-no-files-found: error
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: 🐼 Setup go1.22+
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '>=1.22'
21+
22+
- name: Run build command
23+
run: |
24+
go install golang.org/x/mobile/cmd/gomobile@latest
25+
gomobile init
26+
./contrib/mobile/build -a
27+
28+
- name: Upload .aar files
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: aar-files
32+
path: '**/*.aar'
33+
34+
- name: Upload .jar files
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: jar-files
38+
path: '**/*.jar'

contrib/mobile/build

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ set -ef
77
PKGSRC=${PKGSRC:-github.com/RiV-chain/RiV-mesh/src/version}
88
PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
99
PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
10-
1110
LDFLAGS="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER"
1211
ARGS="-v"
1312

@@ -46,7 +45,7 @@ if [ $ANDROID ]; then
4645
echo "Building aar for Android"
4746
go get golang.org/x/mobile/bind
4847
gomobile bind \
49-
-target android -tags mobile -o mesh.aar \
48+
-androidapi 21 -target android -tags mobile -o mesh.aar \
5049
-ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
5150
./contrib/mobile ./src/config;
5251
fi

contrib/mobile/mobile.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ type Mesh struct {
3535
}
3636

3737
// StartAutoconfigure starts a node with a randomly generated config
38-
func (m *Mesh) StartAutoconfigure() error {
39-
return m.StartJSON([]byte("{}"))
38+
func (m *Mesh) StartAutoconfigure(osVersion int) error {
39+
return m.StartJSON([]byte("{}"), osVersion)
4040
}
4141

4242
// StartJSON starts a node with the given JSON config. You can get JSON config
4343
// (rather than HJSON) by using the GenerateConfigJSON() function
44-
func (m *Mesh) StartJSON(configjson []byte) error {
44+
func (m *Mesh) StartJSON(configjson []byte, osVersion int) error {
4545
logger := log.New(m.log, "", 0)
4646
logger.EnableLevel("error")
4747
logger.EnableLevel("warn")
@@ -80,6 +80,7 @@ func (m *Mesh) StartJSON(configjson []byte) error {
8080
if err != nil {
8181
panic(err)
8282
}
83+
m.core.OsVersion = uint(osVersion)
8384
}
8485

8586
// Setup the multicast module.

contrib/mobile/mobile_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package mobile
22

33
import "testing"
44

5-
func TestStartYggdrasil(t *testing.T) {
5+
func TestStartMesh(t *testing.T) {
66
mesh := &Mesh{}
7-
if err := mesh.StartAutoconfigure(); err != nil {
7+
if err := mesh.StartAutoconfigure(14); err != nil {
88
t.Fatalf("Failed to start RiV-mesh: %s", err)
99
}
1010
t.Log("Address:", mesh.GetAddressString())

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ require gerace.dev/zipfs v0.2.0
2525
require (
2626
github.com/slonm/tableprinter v0.0.0-20230107100804-643098716018
2727
github.com/vorot93/golang-signals v0.0.0-20170221070717-d9e83421ce45
28+
github.com/wlynxg/anet v0.0.3
2829
golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15
2930
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224
3031
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f h1:p4VB7kIXpOQvV
7777
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
7878
github.com/vorot93/golang-signals v0.0.0-20170221070717-d9e83421ce45 h1:hB/hkjwf3BQnZE6Wk3SBwMJz0NqnGdwXoNzHVSYb0N0=
7979
github.com/vorot93/golang-signals v0.0.0-20170221070717-d9e83421ce45/go.mod h1:dfjQkJsG5auteUbnfLIcU72Y/z8tj7DuW9fik8f2Zn0=
80+
github.com/wlynxg/anet v0.0.3 h1:PvR53psxFXstc12jelG6f1Lv4MWqE0tI76/hHGjh9rg=
81+
github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
8082
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
8183
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
8284
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=

src/core/core.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Core struct {
4444
_allowedPublicKeys map[[32]byte]struct{} // configurable after startup
4545
networkdomain NetworkDomain // immutable after startup
4646
}
47+
OsVersion uint
4748
}
4849

4950
func New(secret ed25519.PrivateKey, logger Logger, opts ...SetupOption) (*Core, error) {

src/core/link_tcp.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"strings"
99
"time"
1010

11+
"github.com/wlynxg/anet"
12+
1113
"github.com/Arceliar/phony"
1214
)
1315

@@ -142,15 +144,28 @@ func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error)
142144
Control: l.tcpContext,
143145
}
144146
if sintf != "" {
145-
dialer.Control = l.getControl(sintf)
146-
ief, err := net.InterfaceByName(sintf)
147+
i, err := anet.Interfaces()
147148
if err != nil {
148-
return nil, fmt.Errorf("interface %q not found", sintf)
149+
return nil, fmt.Errorf("interfaces error: %w", err)
150+
}
151+
var ief net.Interface
152+
found := false
153+
for _, ie := range i {
154+
if ie.Name == sintf {
155+
ief = ie
156+
found = true
157+
break
158+
}
159+
}
160+
if !found {
161+
return nil, fmt.Errorf("interface %s not found", sintf)
149162
}
163+
dialer.Control = l.getControl(sintf)
164+
150165
if ief.Flags&net.FlagUp == 0 {
151166
return nil, fmt.Errorf("interface %q is not up", sintf)
152167
}
153-
addrs, err := ief.Addrs()
168+
addrs, err := anet.InterfaceAddrsByInterface(&ief)
154169
if err != nil {
155170
return nil, fmt.Errorf("interface %q addresses not available: %w", sintf, err)
156171
}

src/defaults/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
type MulticastInterfaceConfig = config.MulticastInterfaceConfig
1616
type NetworkDomainConfig = config.NetworkDomainConfig
1717

18-
var defaultConfig = "" // LDFLAGS='-X github.com/yggdrasil-network/yggdrasil-go/src/defaults.defaultConfig=/path/to/config
18+
var defaultConfig = "" // LDFLAGS='-X github.com/RiV-chain/RiV-mesh/src/defaults.defaultConfig=/path/to/config
1919

2020
type defaultParameters struct {
2121
//Default Http address

0 commit comments

Comments
 (0)