Skip to content

Commit ecd11fd

Browse files
authored
Merge pull request #69 from RiV-chain/develop
IPv6 multicast fix for Android 11+
2 parents efd8e24 + 68ac22b commit ecd11fd

File tree

16 files changed

+43
-51
lines changed

16 files changed

+43
-51
lines changed

.github/workflows/pkg.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ jobs:
88
build-libs-android:
99

1010
name: Build libs (Android)
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-22.04
1212

1313
steps:
1414
- name: Checkout repository
1515
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
fetch-tags: true
1619

1720
- name: 🐼 Setup go1.22+
1821
uses: actions/setup-go@v5
@@ -24,6 +27,12 @@ jobs:
2427
go install golang.org/x/mobile/cmd/gomobile@latest
2528
gomobile init
2629
./contrib/mobile/build -a
30+
31+
- name: Get version
32+
id: get_version
33+
run: |
34+
PKGVERSION=$(sh -c './contrib/semver/version.sh --bare')
35+
echo "PKGVERSION=$PKGVERSION" >> $GITHUB_ENV
2736
2837
- name: Upload .aar files
2938
uses: actions/upload-artifact@v4
@@ -35,4 +44,15 @@ jobs:
3544
uses: actions/upload-artifact@v4
3645
with:
3746
name: jar-files
38-
path: '**/*.jar'
47+
path: '**/*.jar'
48+
49+
- name: Publish aar library to Maven repo
50+
uses: RiV-chain/copy-local-file-maven-action@main
51+
with:
52+
artifact_repo: RiV-chain/artifact
53+
artifact_path: mesh.aar
54+
artifact_source_path: mesh-sources.jar
55+
gh_pat: ${{ secrets.MAVEN_PAT }}
56+
artifact_id: mesh
57+
group_id: org.rivchain
58+
version: ${{ env.PKGVERSION }}

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# RiV-mesh first self arranging mesh network with link aggregation.
22

3-
## Why fork?
4-
RiV-mesh is fork of Yggdrasil which is great project. Yggdrasil uses a custom admin TCP protocol istead of REST. Second reason: Yggdrasil uses deprecated 200::/7 IPv6 address pool which can be assigned for some network in future, unlike this fc00::/7 is safe and has been taken for RiV-mesh. So far RiV-mesh can be easy switched to Yggdrasil network address space with NetworkDomain.Prefix 2 in mesh.conf configuration file.
5-
63
## Introduction
74

85
RiV-mesh is an implementation of a fully end-to-end encrypted IPv6

contrib/mobile/mobile.go

Lines changed: 3 additions & 4 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(osVersion int) error {
39-
return m.StartJSON([]byte("{}"), osVersion)
38+
func (m *Mesh) StartAutoconfigure() error {
39+
return m.StartJSON([]byte("{}"))
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, osVersion int) error {
44+
func (m *Mesh) StartJSON(configjson []byte) error {
4545
logger := log.New(m.log, "", 0)
4646
logger.EnableLevel("error")
4747
logger.EnableLevel("warn")
@@ -80,7 +80,6 @@ func (m *Mesh) StartJSON(configjson []byte, osVersion int) error {
8080
if err != nil {
8181
panic(err)
8282
}
83-
m.core.OsVersion = uint(osVersion)
8483
}
8584

8685
// Setup the multicast module.

contrib/mobile/mobile_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "testing"
44

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

contrib/msi/msversion.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
# Get the last tag
4-
TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" 2>/dev/null)
4+
TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" 2>/dev/null)
55

66
# Did getting the tag succeed?
77
if [ $? != 0 ] || [ -z "$TAG" ]; then
@@ -17,6 +17,6 @@ if [ $? != 0 ] || [ -z "$BRANCH" ]; then
1717
BRANCH="master"
1818
fi
1919

20-
STAG=$(echo $TAG | sed 's/v//' | sed 's/[^0123456789.].//')
20+
STAG=$(echo $TAG | sed 's/^v//' | sed 's/[^0123456789.].//')
2121

2222
printf '%s' "$STAG"

contrib/semver/version.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
case "$*" in
44
*--bare*)
55
# Remove the "v" prefix
6-
git describe --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" --abbrev=7 | cut -c 2-
6+
git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | sed 's/^v//'
77
;;
88
*)
9-
git describe --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" --abbrev=7
9+
git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"
1010
;;
1111
esac

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +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
28+
github.com/wlynxg/anet v0.0.4
2929
golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15
3030
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224
3131
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +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=
80+
github.com/wlynxg/anet v0.0.4 h1:0de1OFQxnNqAu+x2FAKKCVIrnfGKQbs7FQz++tB0+Uw=
81+
github.com/wlynxg/anet v0.0.4/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
8282
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
8383
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
8484
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=

src/core/core.go

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

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

src/multicast/multicast.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010
"net"
1111
"net/url"
12-
"strconv"
1312
"time"
1413

1514
"github.com/wlynxg/anet"
@@ -66,7 +65,6 @@ func New(core *core.Core, log *log.Logger, opts ...SetupOption) (*Multicast, err
6665
_listeners: make(map[int]*listenerInfo),
6766
_interfaces: make(map[int]*interfaceInfo),
6867
}
69-
m.SetOsVersion()
7068
m.config._interfaces = map[MulticastInterface]struct{}{}
7169
m.config._groupAddr = GroupAddress("[ff02::114]:9001")
7270
for _, opt := range opts {
@@ -180,8 +178,7 @@ func (m *Multicast) _getAllowedInterfaces() map[int]*interfaceInfo {
180178
// Ask the system for network interfaces
181179
allifaces, err := anet.Interfaces()
182180
if err != nil {
183-
// Don't panic, since this may be from e.g. too many open files (from too much connection spam)
184-
// TODO? log something
181+
m.log.Debugf("Failed to get interfaces: %s", err)
185182
return nil
186183
}
187184
// Work out which interfaces to announce on
@@ -408,11 +405,16 @@ func (m *Multicast) listen() {
408405
phony.Block(m, func() {
409406
interfaces = m._interfaces
410407
})
411-
zone, err := strconv.Atoi(from.Zone)
412-
if err != nil {
413-
continue
408+
var inter interfaceInfo
409+
var ok = false
410+
for _, info := range interfaces {
411+
if info.iface.Name == from.Zone {
412+
inter = *info
413+
ok = true
414+
}
414415
}
415-
if info, ok := interfaces[zone]; ok && info.listen {
416+
info := inter
417+
if ok && info.listen {
416418
addr.Zone = ""
417419
pin := fmt.Sprintf("/?key=%s&priority=%d", hex.EncodeToString(key), info.priority)
418420
u, err := url.Parse("tls://" + addr.String() + pin)

0 commit comments

Comments
 (0)