mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 14:45:07 +03:00
1. added multipath protocol and schema suport
2. added SCTP protocol and schema support 3. added set of NAS models support (Asustor, ReadyNAS, Drobo, QNAP, WD, Synology, Terramaster) 4. moved to fc00::/7 private segment 5. added Windows, MacOS and Linux UI for peers edit and current status
This commit is contained in:
parent
cfa293d189
commit
d8a4000141
198 changed files with 8589 additions and 697 deletions
|
@ -4,7 +4,7 @@ set -ef
|
|||
|
||||
[ ! -d contrib/mobile ] && (echo "Must run ./contrib/mobile/build [-i] [-a] from the repository top level folder"; exit 1)
|
||||
|
||||
PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/version}
|
||||
PKGSRC=${PKGSRC:-github.com/RiV-chain/RiV-mesh/src/version}
|
||||
PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
|
||||
PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
|
||||
|
||||
|
@ -37,7 +37,7 @@ if [ $IOS ]; then
|
|||
echo "Building framework for iOS"
|
||||
go get golang.org/x/mobile/bind
|
||||
gomobile bind \
|
||||
-target ios -tags mobile -o Yggdrasil.xcframework \
|
||||
-target ios -tags mobile -o Mesh.xcframework \
|
||||
-ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
|
||||
./contrib/mobile ./src/config;
|
||||
fi
|
||||
|
@ -46,7 +46,7 @@ if [ $ANDROID ]; then
|
|||
echo "Building aar for Android"
|
||||
go get golang.org/x/mobile/bind
|
||||
gomobile bind \
|
||||
-target android -tags mobile -o yggdrasil.aar \
|
||||
-target android -tags mobile -o mesh.aar \
|
||||
-ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
|
||||
./contrib/mobile ./src/config;
|
||||
fi
|
||||
|
|
|
@ -9,23 +9,23 @@ import (
|
|||
|
||||
"github.com/gologme/log"
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/address"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/config"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/core"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/ipv6rwc"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/multicast"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/version"
|
||||
"github.com/RiV-chain/RiV-mesh/src/address"
|
||||
"github.com/RiV-chain/RiV-mesh/src/config"
|
||||
"github.com/RiV-chain/RiV-mesh/src/core"
|
||||
"github.com/RiV-chain/RiV-mesh/src/defaults"
|
||||
"github.com/RiV-chain/RiV-mesh/src/ipv6rwc"
|
||||
"github.com/RiV-chain/RiV-mesh/src/multicast"
|
||||
"github.com/RiV-chain/RiV-mesh/src/version"
|
||||
|
||||
_ "golang.org/x/mobile/bind"
|
||||
)
|
||||
|
||||
// Yggdrasil mobile package is meant to "plug the gap" for mobile support, as
|
||||
// RiV-mesh mobile package is meant to "plug the gap" for mobile support, as
|
||||
// Gomobile will not create headers for Swift/Obj-C etc if they have complex
|
||||
// (non-native) types. Therefore for iOS we will expose some nice simple
|
||||
// functions. Note that in the case of iOS we handle reading/writing to/from TUN
|
||||
// in Swift therefore we use the "dummy" TUN interface instead.
|
||||
type Yggdrasil struct {
|
||||
type Mesh struct {
|
||||
core *core.Core
|
||||
iprwc *ipv6rwc.ReadWriteCloser
|
||||
config *config.NodeConfig
|
||||
|
@ -34,13 +34,13 @@ type Yggdrasil struct {
|
|||
}
|
||||
|
||||
// StartAutoconfigure starts a node with a randomly generated config
|
||||
func (m *Yggdrasil) StartAutoconfigure() error {
|
||||
func (m *Mesh) StartAutoconfigure() error {
|
||||
return m.StartJSON([]byte("{}"))
|
||||
}
|
||||
|
||||
// StartJSON starts a node with the given JSON config. You can get JSON config
|
||||
// (rather than HJSON) by using the GenerateConfigJSON() function
|
||||
func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
||||
func (m *Mesh) StartJSON(configjson []byte) error {
|
||||
logger := log.New(m.log, "", 0)
|
||||
logger.EnableLevel("error")
|
||||
logger.EnableLevel("warn")
|
||||
|
@ -83,10 +83,10 @@ func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
|||
options := []multicast.SetupOption{}
|
||||
for _, intf := range m.config.MulticastInterfaces {
|
||||
options = append(options, multicast.MulticastInterface{
|
||||
Regex: regexp.MustCompile(intf.Regex),
|
||||
Beacon: intf.Beacon,
|
||||
Listen: intf.Listen,
|
||||
Port: intf.Port,
|
||||
Regex: regexp.MustCompile(intf.Regex),
|
||||
Beacon: intf.Beacon,
|
||||
Listen: intf.Listen,
|
||||
Port: intf.Port,
|
||||
Priority: intf.Priority,
|
||||
})
|
||||
}
|
||||
|
@ -105,9 +105,9 @@ func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Send sends a packet to Yggdrasil. It should be a fully formed
|
||||
// Send sends a packet to Mesh. It should be a fully formed
|
||||
// IPv6 packet
|
||||
func (m *Yggdrasil) Send(p []byte) error {
|
||||
func (m *Mesh) Send(p []byte) error {
|
||||
if m.iprwc == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ func (m *Yggdrasil) Send(p []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Recv waits for and reads a packet coming from Yggdrasil. It
|
||||
// Recv waits for and reads a packet coming from Mesh. It
|
||||
// will be a fully formed IPv6 packet
|
||||
func (m *Yggdrasil) Recv() ([]byte, error) {
|
||||
func (m *Mesh) Recv() ([]byte, error) {
|
||||
if m.iprwc == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -126,11 +126,11 @@ func (m *Yggdrasil) Recv() ([]byte, error) {
|
|||
return buf[:n], nil
|
||||
}
|
||||
|
||||
// Stop the mobile Yggdrasil instance
|
||||
func (m *Yggdrasil) Stop() error {
|
||||
// Stop the mobile Mesh instance
|
||||
func (m *Mesh) Stop() error {
|
||||
logger := log.New(m.log, "", 0)
|
||||
logger.EnableLevel("info")
|
||||
logger.Infof("Stop the mobile Yggdrasil instance %s", "")
|
||||
logger.Infof("Stop the mobile Mesh instance %s", "")
|
||||
if err := m.multicast.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -149,28 +149,28 @@ func GenerateConfigJSON() []byte {
|
|||
}
|
||||
|
||||
// GetAddressString gets the node's IPv6 address
|
||||
func (m *Yggdrasil) GetAddressString() string {
|
||||
func (m *Mesh) GetAddressString() string {
|
||||
ip := m.core.Address()
|
||||
return ip.String()
|
||||
}
|
||||
|
||||
// GetSubnetString gets the node's IPv6 subnet in CIDR notation
|
||||
func (m *Yggdrasil) GetSubnetString() string {
|
||||
func (m *Mesh) GetSubnetString() string {
|
||||
subnet := m.core.Subnet()
|
||||
return subnet.String()
|
||||
}
|
||||
|
||||
// GetPublicKeyString gets the node's public key in hex form
|
||||
func (m *Yggdrasil) GetPublicKeyString() string {
|
||||
func (m *Mesh) GetPublicKeyString() string {
|
||||
return hex.EncodeToString(m.core.GetSelf().Key)
|
||||
}
|
||||
|
||||
// GetCoordsString gets the node's coordinates
|
||||
func (m *Yggdrasil) GetCoordsString() string {
|
||||
func (m *Mesh) GetCoordsString() string {
|
||||
return fmt.Sprintf("%v", m.core.GetSelf().Coords)
|
||||
}
|
||||
|
||||
func (m *Yggdrasil) GetPeersJSON() (result string) {
|
||||
func (m *Mesh) GetPeersJSON() (result string) {
|
||||
peers := []struct {
|
||||
core.PeerInfo
|
||||
IP string
|
||||
|
@ -193,7 +193,7 @@ func (m *Yggdrasil) GetPeersJSON() (result string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *Yggdrasil) GetDHTJSON() (result string) {
|
||||
func (m *Mesh) GetDHTJSON() (result string) {
|
||||
if res, err := json.Marshal(m.core.GetDHT()); err == nil {
|
||||
return string(res)
|
||||
} else {
|
||||
|
@ -202,7 +202,7 @@ func (m *Yggdrasil) GetDHTJSON() (result string) {
|
|||
}
|
||||
|
||||
// GetMTU returns the configured node MTU. This must be called AFTER Start.
|
||||
func (m *Yggdrasil) GetMTU() int {
|
||||
func (m *Mesh) GetMTU() int {
|
||||
return int(m.core.MTU())
|
||||
}
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ package mobile
|
|||
import "testing"
|
||||
|
||||
func TestStartYggdrasil(t *testing.T) {
|
||||
ygg := &Yggdrasil{}
|
||||
if err := ygg.StartAutoconfigure(); err != nil {
|
||||
t.Fatalf("Failed to start Yggdrasil: %s", err)
|
||||
ygg := &Mesh{}
|
||||
if err := mesh.StartAutoconfigure(); err != nil {
|
||||
t.Fatalf("Failed to start Mesh: %s", err)
|
||||
}
|
||||
t.Log("Address:", ygg.GetAddressString())
|
||||
t.Log("Subnet:", ygg.GetSubnetString())
|
||||
t.Log("Coords:", ygg.GetCoordsString())
|
||||
if err := ygg.Stop(); err != nil {
|
||||
t.Log("Address:", mesh.GetAddressString())
|
||||
t.Log("Subnet:", mesh.GetSubnetString())
|
||||
t.Log("Coords:", mesh.GetCoordsString())
|
||||
if err := mesh.Stop(); err != nil {
|
||||
t.Fatalf("Failed to stop Yggdrasil: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue