Skip to content

Commit c102311

Browse files
authored
Merge pull request #66 from RiV-chain/RIVM-143
RIVM-143 Upgrade anet library to remove Android version parameter in native code
2 parents d59ec30 + 89031f3 commit c102311

File tree

12 files changed

+8
-37
lines changed

12 files changed

+8
-37
lines changed

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())

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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func New(core *core.Core, log *log.Logger, opts ...SetupOption) (*Multicast, err
6666
_listeners: make(map[int]*listenerInfo),
6767
_interfaces: make(map[int]*interfaceInfo),
6868
}
69-
m.SetOsVersion()
7069
m.config._interfaces = map[MulticastInterface]struct{}{}
7170
m.config._groupAddr = GroupAddress("[ff02::114]:9001")
7271
for _, opt := range opts {
@@ -180,8 +179,7 @@ func (m *Multicast) _getAllowedInterfaces() map[int]*interfaceInfo {
180179
// Ask the system for network interfaces
181180
allifaces, err := anet.Interfaces()
182181
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
182+
m.log.Debugf("Failed to get interfaces: %s", err)
185183
return nil
186184
}
187185
// Work out which interfaces to announce on

src/multicast/multicast_android.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ import (
88
"os"
99
"syscall"
1010

11-
"github.com/wlynxg/anet"
1211
"golang.org/x/sys/unix"
1312
)
1413

15-
func (m *Multicast) SetOsVersion() {
16-
anet.SetAndroidVersion(m.core.OsVersion)
17-
}
18-
1914
func (m *Multicast) _multicastStarted() {
2015

2116
}

src/multicast/multicast_darwin.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import (
1010
"golang.org/x/sys/unix"
1111
)
1212

13-
func (m *Multicast) SetOsVersion() {
14-
15-
}
16-
1713
func (m *Multicast) _multicastStarted() {
1814

1915
}

src/multicast/multicast_darwin_cgo.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ import (
3030
"golang.org/x/sys/unix"
3131
)
3232

33-
func (m *Multicast) SetOsVersion() {
34-
35-
}
36-
3733
func (m *Multicast) _multicastStarted() {
3834
if !m._isOpen {
3935
return

src/multicast/multicast_other.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ package multicast
55

66
import "syscall"
77

8-
func (m *Multicast) SetOsVersion() {
9-
10-
}
11-
128
func (m *Multicast) _multicastStarted() {
139

1410
}

0 commit comments

Comments
 (0)