mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Merge branch 'develop' of github.com:RiV-chain/RiV-mesh into develop
This commit is contained in:
commit
8e7ea86b42
28 changed files with 137 additions and 126 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -60,6 +60,12 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install webkit2gtk-4.0
|
||||||
|
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
with:
|
||||||
|
packages: libwebkit2gtk-4.0-dev
|
||||||
|
version: 1.0
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -294,10 +294,10 @@ func run(args yggArgs, ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//override httpaddress and wwwroot parameters in cfg
|
//override httpaddress and wwwroot parameters in cfg
|
||||||
if len(args.httpaddress) > 0 {
|
if len(cfg.HttpAddress) == 0 {
|
||||||
cfg.HttpAddress = args.httpaddress
|
cfg.HttpAddress = args.httpaddress
|
||||||
}
|
}
|
||||||
if len(args.wwwroot) > 0 {
|
if len(cfg.WwwRoot) == 0 {
|
||||||
cfg.WwwRoot = args.wwwroot
|
cfg.WwwRoot = args.wwwroot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ cat > /tmp/$PKGNAME/usr/share/applications/riv.desktop << EOF
|
||||||
Name=RiV mesh
|
Name=RiV mesh
|
||||||
GenericName=Mesh network
|
GenericName=Mesh network
|
||||||
Comment=RiV-mesh is an early-stage implementation of a fully end-to-end encrypted IPv6 network
|
Comment=RiV-mesh is an early-stage implementation of a fully end-to-end encrypted IPv6 network
|
||||||
Exec=sh -c "/usr/bin/mesh-ui /usr/share/riv/ui/index.html"
|
Exec=sh -c "/usr/bin/mesh-ui http://localhost:19019"
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Icon=riv
|
Icon=riv
|
||||||
|
|
|
@ -54,7 +54,7 @@ cp contrib/macos/mesh.plist pkgbuild/root/Library/LaunchDaemons
|
||||||
cat > pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS/open-mesh-ui << EOF
|
cat > pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS/open-mesh-ui << EOF
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
exec /Applications/RiV-mesh.app/Contents/MacOS/mesh-ui /Applications/RiV-mesh.app/Contents/Resources/ui/index.html 1>/tmp/mesh-ui.stdout.log 2>/tmp/mesh-ui.stderr.log
|
exec /Applications/RiV-mesh.app/Contents/MacOS/mesh-ui http://localhost:19019 1>/tmp/mesh-ui.stdout.log 2>/tmp/mesh-ui.stderr.log
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create the postinstall script
|
# Create the postinstall script
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
<string>/Applications/RiV-mesh.app/Contents/MacOS/mesh</string>
|
<string>/Applications/RiV-mesh.app/Contents/MacOS/mesh</string>
|
||||||
<string>-useconffile</string>
|
<string>-useconffile</string>
|
||||||
<string>/etc/mesh.conf</string>
|
<string>/etc/mesh.conf</string>
|
||||||
|
<string>-logto</string>
|
||||||
|
<string>/var/log/mesh.log</string>
|
||||||
|
<string>-httpaddress</string>
|
||||||
|
<string>http://localhost:19019</string>
|
||||||
|
<string>-wwwroot</string>
|
||||||
|
<string>/Applications/RiV-mesh.app/Contents/Resources/ui</string>
|
||||||
</array>
|
</array>
|
||||||
<key>KeepAlive</key>
|
<key>KeepAlive</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
|
|
@ -52,8 +52,6 @@ PKGNAME=$(sh contrib/semver/name.sh)
|
||||||
PKGVERSION=$(sh contrib/msi/msversion.sh --bare)
|
PKGVERSION=$(sh contrib/msi/msversion.sh --bare)
|
||||||
PKGVERSIONMS=$(echo $PKGVERSION | tr - .)
|
PKGVERSIONMS=$(echo $PKGVERSION | tr - .)
|
||||||
PKGUIFOLDER=contrib/ui/mesh-ui/ui/
|
PKGUIFOLDER=contrib/ui/mesh-ui/ui/
|
||||||
PKGWEBVIEWRESOURCESFOLDER="${PKGUIFOLDER}assets/"
|
|
||||||
PKGFONTSRESOURCESFOLDER="${PKGUIFOLDER}webfonts/"
|
|
||||||
|
|
||||||
PKGLICENSEFILE=LICENSE.rtf
|
PKGLICENSEFILE=LICENSE.rtf
|
||||||
|
|
||||||
|
@ -112,6 +110,10 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PKG_UI_ASSETS_ZIP=$(pwd)/ui.zip
|
||||||
|
( cd "$PKGUIFOLDER" && 7z a "$PKG_UI_ASSETS_ZIP" * )
|
||||||
|
PKG_UI_ASSETS_ZIP=ui.zip
|
||||||
|
|
||||||
if [ $PKGNAME != "master" ]; then
|
if [ $PKGNAME != "master" ]; then
|
||||||
PKGDISPLAYNAME="RiV-mesh Network (${PKGNAME} branch)"
|
PKGDISPLAYNAME="RiV-mesh Network (${PKGNAME} branch)"
|
||||||
else
|
else
|
||||||
|
@ -155,49 +157,10 @@ cat > wix.xml << EOF
|
||||||
<Icon Id="icon.ico" SourceFile="riv.ico"/>
|
<Icon Id="icon.ico" SourceFile="riv.ico"/>
|
||||||
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
|
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
|
||||||
|
|
||||||
<Property Id="SOURCEDIRECTORY" Value="${PKGUIFOLDER}" />
|
|
||||||
|
|
||||||
<Directory Id="TARGETDIR" Name="SourceDir">
|
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||||
<Directory Id="DesktopFolder" SourceName="Desktop"/>
|
<Directory Id="DesktopFolder" SourceName="Desktop"/>
|
||||||
<Directory Id="${PKGINSTFOLDER}" Name="PFiles">
|
<Directory Id="${PKGINSTFOLDER}" Name="PFiles">
|
||||||
<Directory Id="MeshInstallFolder" Name="RiV-mesh">
|
<Directory Id="MeshInstallFolder" Name="RiV-mesh">
|
||||||
<Directory Id="WebViewUIFolder" Name="ui" >
|
|
||||||
<Directory Id="AssetsFolder" Name="assets" >
|
|
||||||
<Component Id="AssetsResources" Guid="6e9af115-daa0-4aac-8e6a-5ba65e720a4d">
|
|
||||||
<File
|
|
||||||
Id="AllMinCssFile"
|
|
||||||
Name="all.min.css"
|
|
||||||
DiskId="1"
|
|
||||||
Source="${PKGWEBVIEWRESOURCESFOLDER}all.min.css" />
|
|
||||||
<File
|
|
||||||
Id="BulmaswatchCssFile"
|
|
||||||
Name="bulmaswatch.min.css"
|
|
||||||
DiskId="1"
|
|
||||||
Source="${PKGWEBVIEWRESOURCESFOLDER}bulmaswatch.min.css" />
|
|
||||||
<File
|
|
||||||
Id="BulmaswatchCssMapFile"
|
|
||||||
Name="bulmaswatch.min.css.map"
|
|
||||||
DiskId="1"
|
|
||||||
Source="${PKGWEBVIEWRESOURCESFOLDER}bulmaswatch.min.css.map" />
|
|
||||||
</Component>
|
|
||||||
</Directory>
|
|
||||||
<Directory Id="WebfontsFolder" Name="webfonts" >
|
|
||||||
<Component Id="FontsResources" Guid="4ffeb20b-61a8-4c7f-ba16-0d0c8e43b09a">
|
|
||||||
<File
|
|
||||||
Id="FontFile"
|
|
||||||
Name="fa-solid-900.woff2"
|
|
||||||
DiskId="1"
|
|
||||||
Source="${PKGFONTSRESOURCESFOLDER}fa-solid-900.woff2" />
|
|
||||||
</Component>
|
|
||||||
</Directory>
|
|
||||||
<Component Id="WebViewResources" Guid="a4a5a50a-a336-4789-bf61-ca76fe217e3f">
|
|
||||||
<File
|
|
||||||
Id="WebViewHtmlFile"
|
|
||||||
Name="index.html"
|
|
||||||
DiskId="1"
|
|
||||||
Source="${PKGUIFOLDER}index.html" />
|
|
||||||
</Component>
|
|
||||||
</Directory>
|
|
||||||
<Component Id="MainExecutable" Guid="c2119231-2aa3-4962-867a-9759c87beb24">
|
<Component Id="MainExecutable" Guid="c2119231-2aa3-4962-867a-9759c87beb24">
|
||||||
<File
|
<File
|
||||||
Id="Mesh"
|
Id="Mesh"
|
||||||
|
@ -220,7 +183,7 @@ cat > wix.xml << EOF
|
||||||
Name="Mesh"
|
Name="Mesh"
|
||||||
Start="auto"
|
Start="auto"
|
||||||
Type="ownProcess"
|
Type="ownProcess"
|
||||||
Arguments='-useconffile "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf" -logto "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.log"'
|
Arguments='-useconffile "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf" -logto "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.log" -httpaddress "http://localhost:19019" -wwwroot "[MeshInstallFolder]ui.zip"'
|
||||||
Vital="yes" />
|
Vital="yes" />
|
||||||
<ServiceControl
|
<ServiceControl
|
||||||
Id="MeshServiceControl"
|
Id="MeshServiceControl"
|
||||||
|
@ -258,6 +221,12 @@ cat > wix.xml << EOF
|
||||||
DiskId="1"
|
DiskId="1"
|
||||||
Source="${PKGWEBVIEWFILELOADER}" />
|
Source="${PKGWEBVIEWFILELOADER}" />
|
||||||
|
|
||||||
|
<File
|
||||||
|
Id="UiAssets"
|
||||||
|
Name="ui.zip"
|
||||||
|
DiskId="1"
|
||||||
|
Source="${PKG_UI_ASSETS_ZIP}" />
|
||||||
|
|
||||||
</Component>
|
</Component>
|
||||||
|
|
||||||
|
|
||||||
|
@ -268,7 +237,7 @@ cat > wix.xml << EOF
|
||||||
DiskId="1"
|
DiskId="1"
|
||||||
Source="updateconfig.bat"
|
Source="updateconfig.bat"
|
||||||
KeyPath="yes"/>
|
KeyPath="yes"/>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
||||||
</Directory>
|
</Directory>
|
||||||
</Directory>
|
</Directory>
|
||||||
|
@ -276,9 +245,6 @@ cat > wix.xml << EOF
|
||||||
|
|
||||||
<Feature Id="MeshFeature" Title="Mesh" Level="1">
|
<Feature Id="MeshFeature" Title="Mesh" Level="1">
|
||||||
<ComponentRef Id="MainExecutable" />
|
<ComponentRef Id="MainExecutable" />
|
||||||
<ComponentRef Id="WebViewResources" />
|
|
||||||
<ComponentRef Id="AssetsResources" />
|
|
||||||
<ComponentRef Id="FontsResources" />
|
|
||||||
<ComponentRef Id="UIExecutable" />
|
<ComponentRef Id="UIExecutable" />
|
||||||
<ComponentRef Id="CtrlExecutable" />
|
<ComponentRef Id="CtrlExecutable" />
|
||||||
<ComponentRef Id="cmpDesktopShortcut" />
|
<ComponentRef Id="cmpDesktopShortcut" />
|
||||||
|
@ -306,7 +272,7 @@ cat > wix.xml << EOF
|
||||||
<CustomAction Id="LaunchApplication"
|
<CustomAction Id="LaunchApplication"
|
||||||
FileKey="MeshUI"
|
FileKey="MeshUI"
|
||||||
Impersonate="yes"
|
Impersonate="yes"
|
||||||
ExeCommand='"[MeshInstallFolder]ui\index.html"'
|
ExeCommand='"http://localhost:19019"'
|
||||||
Return="asyncNoWait" />
|
Return="asyncNoWait" />
|
||||||
|
|
||||||
<!-- Step 3: Include the custom action -->
|
<!-- Step 3: Include the custom action -->
|
||||||
|
@ -325,7 +291,7 @@ cat > wix.xml << EOF
|
||||||
Description="RiV-mesh is IoT E2E encrypted network"
|
Description="RiV-mesh is IoT E2E encrypted network"
|
||||||
Directory="DesktopFolder"
|
Directory="DesktopFolder"
|
||||||
Target="[MeshInstallFolder]mesh-ui.exe"
|
Target="[MeshInstallFolder]mesh-ui.exe"
|
||||||
Arguments="ui\index.html"
|
Arguments="http://localhost:19019"
|
||||||
WorkingDirectory="MeshInstallFolder"/>
|
WorkingDirectory="MeshInstallFolder"/>
|
||||||
<RegistryValue Root="HKCU"
|
<RegistryValue Root="HKCU"
|
||||||
Key="Software\RiV-chain\RiV-mesh"
|
Key="Software\RiV-chain\RiV-mesh"
|
||||||
|
@ -337,7 +303,7 @@ cat > wix.xml << EOF
|
||||||
Key="Software\Microsoft\Windows\CurrentVersion\Run"
|
Key="Software\Microsoft\Windows\CurrentVersion\Run"
|
||||||
Name="RiV-mesh client"
|
Name="RiV-mesh client"
|
||||||
Type="string"
|
Type="string"
|
||||||
Value='"[MeshInstallFolder]mesh-ui.exe" "[MeshInstallFolder]ui\index.html"' />
|
Value='"[MeshInstallFolder]mesh-ui.exe" "http://localhost:19019"' />
|
||||||
<Condition>ASSISTANCE_START_VIA_REGISTRY</Condition>
|
<Condition>ASSISTANCE_START_VIA_REGISTRY</Condition>
|
||||||
</Component>
|
</Component>
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,9 @@ echo "coping ui package..."
|
||||||
cp contrib/ui/nas-netgear-os6/package/apps /tmp/$PKGNAME/ -r
|
cp contrib/ui/nas-netgear-os6/package/apps /tmp/$PKGNAME/ -r
|
||||||
cp contrib/ui/www/* /tmp/$PKGNAME/apps/mesh/www/ -r
|
cp contrib/ui/www/* /tmp/$PKGNAME/apps/mesh/www/ -r
|
||||||
|
|
||||||
|
echo "coping postinstall, postrm, prerm scripts"
|
||||||
|
cp contrib/ui/nas-netgear-os6/package/DEBIAN/* /tmp/$PKGNAME/DEBIAN/ -r
|
||||||
|
|
||||||
cat > /tmp/$PKGNAME/debian/changelog << EOF
|
cat > /tmp/$PKGNAME/debian/changelog << EOF
|
||||||
Please see https://github.com/RiV-chain/RiV-mesh/
|
Please see https://github.com/RiV-chain/RiV-mesh/
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -12,7 +12,7 @@ ProtectSystem=true
|
||||||
SyslogIdentifier=mesh
|
SyslogIdentifier=mesh
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE
|
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE
|
||||||
ExecStartPre=+-/sbin/modprobe tun
|
ExecStartPre=+-/sbin/modprobe tun
|
||||||
ExecStart=/usr/bin/mesh -useconffile /etc/mesh.conf
|
ExecStart=/usr/bin/mesh -useconffile /etc/mesh.conf -logto /var/log/mesh.log -httpaddress "http://localhost:19019" -wwwroot "/usr/share/riv/ui"
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
Restart=always
|
Restart=always
|
||||||
TimeoutStopSec=5
|
TimeoutStopSec=5
|
||||||
|
|
|
@ -237,13 +237,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePrivKeyVisibility() {
|
function togglePrivKeyVisibility() {
|
||||||
if (this.classList.contains("fa-eye-slash")) {
|
if (this.classList.contains("fa-eye")) {
|
||||||
this.classList.remove("fa-eye-slash");
|
|
||||||
this.classList.add("fa-eye");
|
|
||||||
document.getElementById("priv_key_visible").innerHTML = document.getElementById("priv_key").innerHTML;
|
|
||||||
} else {
|
|
||||||
this.classList.remove("fa-eye");
|
this.classList.remove("fa-eye");
|
||||||
this.classList.add("fa-eye-slash");
|
this.classList.add("fa-eye-slash");
|
||||||
|
document.getElementById("priv_key_visible").innerHTML = document.getElementById("priv_key").innerHTML;
|
||||||
|
} else {
|
||||||
|
this.classList.remove("fa-eye-slash");
|
||||||
|
this.classList.add("fa-eye");
|
||||||
document.getElementById("priv_key_visible").innerHTML = "••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••";
|
document.getElementById("priv_key_visible").innerHTML = "••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@
|
||||||
<div id="priv_key_visible" class="item push-right overflow-ellipsis">
|
<div id="priv_key_visible" class="item push-right overflow-ellipsis">
|
||||||
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••</div>
|
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<a class="fas fa-light fa-eye-slash" onclick="(togglePrivKeyVisibility.bind(this))()"></a>
|
<a class="fas fa-light fa-eye" onclick="(togglePrivKeyVisibility.bind(this))()"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<a class="fas fa-copy" onclick="copy2clipboard(document.getElementById('priv_key').innerHTML);"></a>
|
<a class="fas fa-copy" onclick="copy2clipboard(document.getElementById('priv_key').innerHTML);"></a>
|
||||||
|
|
|
@ -54,8 +54,8 @@ fi
|
||||||
chmod 755 /etc/mesh.conf
|
chmod 755 /etc/mesh.conf
|
||||||
if command -v systemctl >/dev/null; then
|
if command -v systemctl >/dev/null; then
|
||||||
systemctl daemon-reload || echo -n "daemon not reloaded!"
|
systemctl daemon-reload || echo -n "daemon not reloaded!"
|
||||||
systemctl enable mesh || echo -n "systemctl enable failed!"
|
systemctl enable fvapp-mesh || echo -n "systemctl enable failed!"
|
||||||
systemctl restart mesh || echo -n "systemctl restart failed!"
|
systemctl restart fvapp-mesh || echo -n "systemctl restart failed!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
6
go.mod
6
go.mod
|
@ -21,8 +21,10 @@ require (
|
||||||
golang.zx2c4.com/wireguard/windows v0.4.12
|
golang.zx2c4.com/wireguard/windows v0.4.12
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require gerace.dev/zipfs v0.2.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 // indirect
|
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
|
||||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
|
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
|
||||||
github.com/getlantern/ema v0.0.0-20190620044903-5943d28f40e4 // indirect
|
github.com/getlantern/ema v0.0.0-20190620044903-5943d28f40e4 // indirect
|
||||||
|
@ -33,11 +35,11 @@ require (
|
||||||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect
|
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect
|
||||||
github.com/go-stack/stack v1.8.0 // indirect
|
github.com/go-stack/stack v1.8.0 // indirect
|
||||||
github.com/google/uuid v1.1.2 // indirect
|
github.com/google/uuid v1.1.2 // indirect
|
||||||
github.com/webview/webview v0.0.0-20210330151455-f540d88dde4e
|
|
||||||
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.8 // indirect
|
github.com/mattn/go-colorable v0.1.8 // indirect
|
||||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
|
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
|
github.com/webview/webview v0.0.0-20210330151455-f540d88dde4e
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
go.uber.org/atomic v1.7.0 // indirect
|
||||||
go.uber.org/multierr v1.6.0 // indirect
|
go.uber.org/multierr v1.6.0 // indirect
|
||||||
go.uber.org/zap v1.19.1 // indirect
|
go.uber.org/zap v1.19.1 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -1,3 +1,5 @@
|
||||||
|
gerace.dev/zipfs v0.2.0 h1:3U1GsasLdxGVhf7lCYbccsH4mpuSpMpLOy37GmfT+KY=
|
||||||
|
gerace.dev/zipfs v0.2.0/go.mod h1:L6cxA6m8uVfWDawsBHnki/J6Gos5uSlu/6RJZhafrfQ=
|
||||||
github.com/Arceliar/ironwood v0.0.0-20221115123222-ec61cea2f439 h1:eOW6/XIs06TnUn9GPCnfv71CQZw8edP3u3mH3lZt6iM=
|
github.com/Arceliar/ironwood v0.0.0-20221115123222-ec61cea2f439 h1:eOW6/XIs06TnUn9GPCnfv71CQZw8edP3u3mH3lZt6iM=
|
||||||
github.com/Arceliar/ironwood v0.0.0-20221115123222-ec61cea2f439/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk=
|
github.com/Arceliar/ironwood v0.0.0-20221115123222-ec61cea2f439/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk=
|
||||||
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 h1:WndgpSW13S32VLQ3ugUxx2EnnWmgba1kCqPkd4Gk1yQ=
|
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 h1:WndgpSW13S32VLQ3ugUxx2EnnWmgba1kCqPkd4Gk1yQ=
|
||||||
|
@ -79,6 +81,7 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
|
@ -173,6 +176,7 @@ golang.zx2c4.com/wireguard/windows v0.4.12 h1:CUmbdWKVNzTSsVb4yUAiEwL3KsabdJkEPd
|
||||||
golang.zx2c4.com/wireguard/windows v0.4.12/go.mod h1:PW4y+d9oY83XU9rRwRwrJDwEMuhVjMxu2gfD1cfzS7w=
|
golang.zx2c4.com/wireguard/windows v0.4.12/go.mod h1:PW4y+d9oY83XU9rRwRwrJDwEMuhVjMxu2gfD1cfzS7w=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AddPeersRequest struct {
|
type AddPeersRequest struct {
|
||||||
Uri string `json:"uri"`
|
Uri string `json:"uri"`
|
||||||
Intf string `json:"intf"`
|
Intf string `json:"intf"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddPeersResponse struct {
|
type AddPeersResponse struct {
|
||||||
|
@ -17,12 +15,12 @@ type AddPeersResponse struct {
|
||||||
|
|
||||||
func (a *AdminSocket) addPeersHandler(req *AddPeersRequest, res *AddPeersResponse) error {
|
func (a *AdminSocket) addPeersHandler(req *AddPeersRequest, res *AddPeersResponse) error {
|
||||||
// Set sane defaults
|
// Set sane defaults
|
||||||
err:=a.core.AddPeer(req.Uri, req.Intf)
|
err := a.core.AddPeer(req.Uri, req.Intf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("adding peer error %s", err)
|
fmt.Printf("adding peer error %s\n", err)
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("added peer %s", req.Uri)
|
fmt.Printf("added peer %s\n", req.Uri)
|
||||||
res.List = append(res.List, req.Uri)
|
res.List = append(res.List, req.Uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,17 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"archive/zip"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gerace.dev/zipfs"
|
||||||
|
|
||||||
"github.com/RiV-chain/RiV-mesh/src/config"
|
"github.com/RiV-chain/RiV-mesh/src/config"
|
||||||
"github.com/RiV-chain/RiV-mesh/src/core"
|
"github.com/RiV-chain/RiV-mesh/src/core"
|
||||||
)
|
)
|
||||||
|
@ -203,26 +206,26 @@ func (a *AdminSocket) SetupAdminHandlers() {
|
||||||
return res, nil
|
return res, nil
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
_ = a.AddHandler("addPeers", "Add peers to this node", []string{"uri", "[interface]"}, func(in json.RawMessage) (interface{}, error) {
|
_ = a.AddHandler("addPeers", "Add peers to this node", []string{"uri", "[interface]"}, func(in json.RawMessage) (interface{}, error) {
|
||||||
req := &AddPeersRequest{}
|
req := &AddPeersRequest{}
|
||||||
res := &AddPeersResponse{}
|
res := &AddPeersResponse{}
|
||||||
|
|
||||||
fmt.Println("json addpeers request %s", string(in[:]))
|
fmt.Println("json addpeers request %s", string(in[:]))
|
||||||
|
|
||||||
if err := json.Unmarshal(in, &req); err != nil {
|
if err := json.Unmarshal(in, &req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.addPeersHandler(req, res); err != nil {
|
if err := a.addPeersHandler(req, res); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
})
|
})
|
||||||
_ = a.AddHandler("removePeers", "Remove all peers from this node", []string{}, func(in json.RawMessage) (interface{}, error) {
|
_ = a.AddHandler("removePeers", "Remove all peers from this node", []string{}, func(in json.RawMessage) (interface{}, error) {
|
||||||
a.core.RemovePeers()
|
a.core.RemovePeers()
|
||||||
res := &AddPeersResponse{}
|
res := &AddPeersResponse{}
|
||||||
return res, nil
|
return res, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
//_ = a.AddHandler("getNodeInfo", []string{"key"}, t.proto.nodeinfo.nodeInfoAdminHandler)
|
//_ = a.AddHandler("getNodeInfo", []string{"key"}, t.proto.nodeinfo.nodeInfoAdminHandler)
|
||||||
//_ = a.AddHandler("debug_remoteGetSelf", []string{"key"}, t.proto.getSelfHandler)
|
//_ = a.AddHandler("debug_remoteGetSelf", []string{"key"}, t.proto.getSelfHandler)
|
||||||
|
@ -232,16 +235,16 @@ func (a *AdminSocket) SetupAdminHandlers() {
|
||||||
|
|
||||||
// Start runs http server
|
// Start runs http server
|
||||||
func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) {
|
func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) {
|
||||||
if nc.HttpAddress != "none" && nc.HttpAddress != "" && nc.WwwRoot != "none" && nc.WwwRoot != ""{
|
if nc.HttpAddress != "none" && nc.HttpAddress != "" && nc.WwwRoot != "none" && nc.WwwRoot != "" {
|
||||||
u, err := url.Parse(nc.HttpAddress)
|
u, err := url.Parse(nc.HttpAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.log.Errorln("An error occurred parsing http address:", err)
|
a.log.Errorln("An error occurred parsing http address:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
http.HandleFunc("/api", func(w http.ResponseWriter, r *http.Request){
|
http.HandleFunc("/api", func(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "Following methods are allowed: getself, getpeers. litening"+u.Host)
|
fmt.Fprintf(w, "Following methods are allowed: getself, getpeers. litening"+u.Host)
|
||||||
})
|
})
|
||||||
http.HandleFunc("/api/getself", func(w http.ResponseWriter, r *http.Request){
|
http.HandleFunc("/api/getself", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
req := &GetSelfRequest{}
|
req := &GetSelfRequest{}
|
||||||
res := &GetSelfResponse{}
|
res := &GetSelfResponse{}
|
||||||
|
@ -252,9 +255,9 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 503)
|
http.Error(w, err.Error(), 503)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, string(b[:]))
|
fmt.Fprint(w, string(b[:]))
|
||||||
})
|
})
|
||||||
http.HandleFunc("/api/getpeers", func(w http.ResponseWriter, r *http.Request){
|
http.HandleFunc("/api/getpeers", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
req := &GetPeersRequest{}
|
req := &GetPeersRequest{}
|
||||||
res := &GetPeersResponse{}
|
res := &GetPeersResponse{}
|
||||||
|
@ -266,14 +269,27 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 503)
|
http.Error(w, err.Error(), 503)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, string(b[:]))
|
fmt.Fprint(w, string(b[:]))
|
||||||
})
|
})
|
||||||
http.Handle("/", http.FileServer(http.Dir(nc.WwwRoot)))
|
var docFs = ""
|
||||||
|
pakReader, err := zip.OpenReader(nc.WwwRoot)
|
||||||
|
if err == nil {
|
||||||
|
defer pakReader.Close()
|
||||||
|
fs, err := zipfs.NewZipFileSystem(&pakReader.Reader, zipfs.ServeIndexForMissing())
|
||||||
|
if err == nil {
|
||||||
|
http.Handle("/", http.FileServer(fs))
|
||||||
|
docFs = "zipfs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if docFs == "" {
|
||||||
|
http.Handle("/", http.FileServer(http.Dir(nc.WwwRoot)))
|
||||||
|
docFs = "local fs"
|
||||||
|
}
|
||||||
l, e := net.Listen("tcp4", u.Host)
|
l, e := net.Listen("tcp4", u.Host)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
a.log.Errorln("%s\n", e)
|
a.log.Errorln("%s\n", e)
|
||||||
} else {
|
} else {
|
||||||
a.log.Infof("Http server listening on %s\n", u.Host)
|
a.log.Infof("Http server is listening on %s and is supplied from %s %s\n", nc.HttpAddress, docFs, nc.WwwRoot)
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
a.log.Errorln(http.Serve(l, nil))
|
a.log.Errorln(http.Serve(l, nil))
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
//"github.com/RiV-chain/RiV-mesh/src/address"
|
//"github.com/RiV-chain/RiV-mesh/src/address"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
//"github.com/RiV-chain/RiV-mesh/src/address"
|
//"github.com/RiV-chain/RiV-mesh/src/address"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
//"github.com/RiV-chain/RiV-mesh/src/address"
|
//"github.com/RiV-chain/RiV-mesh/src/address"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
//"github.com/RiV-chain/RiV-mesh/src/address"
|
//"github.com/RiV-chain/RiV-mesh/src/address"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
// The Core object represents the Mesh node. You should create a Core
|
// The Core object represents the Mesh node. You should create a Core
|
||||||
// object for each Mesh node you plan to run.
|
// object for each Mesh node you plan to run.
|
||||||
type Core struct {
|
type Core struct {
|
||||||
|
|
||||||
// This is the main data structure that holds everything else for a node
|
// This is the main data structure that holds everything else for a node
|
||||||
// We're going to keep our own copy of the provided config - that way we can
|
// We're going to keep our own copy of the provided config - that way we can
|
||||||
// guarantee that it will be covered by the mutex
|
// guarantee that it will be covered by the mutex
|
||||||
|
|
|
@ -49,12 +49,14 @@ func (l *linkMPATH) dial(url *url.URL, options linkOptions, sintf string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *linkMPATH) listen(url *url.URL, sintf string) (*Listener, error) {
|
func (l *linkMPATH) listen(url *url.URL, sintf string) (*Listener, error) {
|
||||||
hostport := url.Host
|
/*
|
||||||
if sintf != "" {
|
hostport := url.Host
|
||||||
if host, port, err := net.SplitHostPort(hostport); err == nil {
|
if sintf != "" {
|
||||||
hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port)
|
if host, port, err := net.SplitHostPort(hostport); err == nil {
|
||||||
|
hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
_, cancel := context.WithCancel(l.core.ctx)
|
_, cancel := context.WithCancel(l.core.ctx)
|
||||||
listener, err := l.listenFor(url, sintf)
|
listener, err := l.listenFor(url, sintf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -106,6 +108,8 @@ func (l *linkMPATH) handler(dial *linkDial, name string, info linkInfo, conn net
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the address of the listener.
|
// Returns the address of the listener.
|
||||||
|
//
|
||||||
|
//nolint:unused
|
||||||
func (l *linkMPATH) getAddr() *net.TCPAddr {
|
func (l *linkMPATH) getAddr() *net.TCPAddr {
|
||||||
// TODO: Fix this, because this will currently only give a single address
|
// TODO: Fix this, because this will currently only give a single address
|
||||||
// to multicast.go, which obviously is not great, but right now multicast.go
|
// to multicast.go, which obviously is not great, but right now multicast.go
|
||||||
|
|
|
@ -31,6 +31,7 @@ func (t *linkMPATH) tcpContext(network, address string, c syscall.RawConn) error
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:unused
|
||||||
func (t *linkMPATH) getControl(sintf string) func(string, string, syscall.RawConn) error {
|
func (t *linkMPATH) getControl(sintf string) func(string, string, syscall.RawConn) error {
|
||||||
return func(network, address string, c syscall.RawConn) error {
|
return func(network, address string, c syscall.RawConn) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -55,6 +55,9 @@ func (l *linkSCTP) dial(url *url.URL, options linkOptions, sintf string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = conn.(*sctp.SCTPConn).Connect(raddress)
|
err = conn.(*sctp.SCTPConn).Connect(raddress)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
//conn.(*sctp.SCTPConn).SetWriteBuffer(324288)
|
//conn.(*sctp.SCTPConn).SetWriteBuffer(324288)
|
||||||
//conn.(*sctp.SCTPConn).SetReadBuffer(324288)
|
//conn.(*sctp.SCTPConn).SetReadBuffer(324288)
|
||||||
//wbuf, _ := conn.(*sctp.SCTPConn).GetWriteBuffer()
|
//wbuf, _ := conn.(*sctp.SCTPConn).GetWriteBuffer()
|
||||||
|
@ -62,7 +65,10 @@ func (l *linkSCTP) dial(url *url.URL, options linkOptions, sintf string) error {
|
||||||
|
|
||||||
//l.core.log.Printf("Read buffer %d", rbuf)
|
//l.core.log.Printf("Read buffer %d", rbuf)
|
||||||
//l.core.log.Printf("Write buffer %d", wbuf)
|
//l.core.log.Printf("Write buffer %d", wbuf)
|
||||||
conn.(*sctp.SCTPConn).SetEvents(sctp.SCTP_EVENT_DATA_IO)
|
err = conn.(*sctp.SCTPConn).SetEvents(sctp.SCTP_EVENT_DATA_IO)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
dial := &linkDial{
|
dial := &linkDial{
|
||||||
url: url,
|
url: url,
|
||||||
sintf: sintf,
|
sintf: sintf,
|
||||||
|
@ -72,12 +78,14 @@ func (l *linkSCTP) dial(url *url.URL, options linkOptions, sintf string) error {
|
||||||
|
|
||||||
func (l *linkSCTP) listen(url *url.URL, sintf string) (*Listener, error) {
|
func (l *linkSCTP) listen(url *url.URL, sintf string) (*Listener, error) {
|
||||||
//_, cancel := context.WithCancel(l.core.ctx)
|
//_, cancel := context.WithCancel(l.core.ctx)
|
||||||
hostport := url.Host
|
/*
|
||||||
if sintf != "" {
|
hostport := url.Host
|
||||||
if host, port, err := net.SplitHostPort(hostport); err == nil {
|
if sintf != "" {
|
||||||
hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port)
|
if host, port, err := net.SplitHostPort(hostport); err == nil {
|
||||||
|
hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
addr := l.getAddress(url.Host)
|
addr := l.getAddress(url.Host)
|
||||||
listener, err := sctp.NewSCTPListener(addr, sctp.InitMsg{NumOstreams: 2, MaxInstreams: 2, MaxAttempts: 2, MaxInitTimeout: 5}, sctp.OneToOne, false)
|
listener, err := sctp.NewSCTPListener(addr, sctp.InitMsg{NumOstreams: 2, MaxInstreams: 2, MaxAttempts: 2, MaxInitTimeout: 5}, sctp.OneToOne, false)
|
||||||
|
|
||||||
|
@ -85,7 +93,10 @@ func (l *linkSCTP) listen(url *url.URL, sintf string) (*Listener, error) {
|
||||||
//cancel()
|
//cancel()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
listener.SetEvents(sctp.SCTP_EVENT_DATA_IO)
|
err = listener.SetEvents(sctp.SCTP_EVENT_DATA_IO)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
entry := &Listener{
|
entry := &Listener{
|
||||||
Listener: listener,
|
Listener: listener,
|
||||||
closed: make(chan struct{}),
|
closed: make(chan struct{}),
|
||||||
|
@ -142,6 +153,8 @@ func (l *linkSCTP) handler(dial *linkDial, name string, info linkInfo, conn net.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the address of the listener.
|
// Returns the address of the listener.
|
||||||
|
//
|
||||||
|
//nolint:unused
|
||||||
func (l *linkSCTP) getAddr() *net.TCPAddr {
|
func (l *linkSCTP) getAddr() *net.TCPAddr {
|
||||||
// TODO: Fix this, because this will currently only give a single address
|
// TODO: Fix this, because this will currently only give a single address
|
||||||
// to multicast.go, which obviously is not great, but right now multicast.go
|
// to multicast.go, which obviously is not great, but right now multicast.go
|
||||||
|
@ -155,7 +168,7 @@ func (l *linkSCTP) getAddr() *net.TCPAddr {
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
||||||
//SCTP infrastructure
|
// SCTP infrastructure
|
||||||
func (l *linkSCTP) getAddress(host string) *sctp.SCTPAddr {
|
func (l *linkSCTP) getAddress(host string) *sctp.SCTPAddr {
|
||||||
|
|
||||||
//sctp supports multihoming but current implementation reuires only one path
|
//sctp supports multihoming but current implementation reuires only one path
|
||||||
|
|
|
@ -186,7 +186,6 @@ func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error)
|
||||||
return dialer, nil
|
return dialer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func tcpIDFor(local net.Addr, remoteAddr *net.TCPAddr) string {
|
func tcpIDFor(local net.Addr, remoteAddr *net.TCPAddr) string {
|
||||||
if localAddr, ok := local.(*net.TCPAddr); ok && localAddr.IP.Equal(remoteAddr.IP) {
|
if localAddr, ok := local.(*net.TCPAddr); ok && localAddr.IP.Equal(remoteAddr.IP) {
|
||||||
// Nodes running on the same host — include both the IP and port.
|
// Nodes running on the same host — include both the IP and port.
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
|
|
||||||
iwt "github.com/Arceliar/ironwood/types"
|
iwt "github.com/Arceliar/ironwood/types"
|
||||||
"github.com/Arceliar/phony"
|
"github.com/Arceliar/phony"
|
||||||
|
|
||||||
//"github.com/RiV-chain/RiV-mesh/src/address"
|
//"github.com/RiV-chain/RiV-mesh/src/address"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
package multicast
|
package multicast
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@ func (m *Multicast) multicastReuse(network string, address string, c syscall.Raw
|
||||||
var reuseaddr error
|
var reuseaddr error
|
||||||
|
|
||||||
control = c.Control(func(fd uintptr) {
|
control = c.Control(func(fd uintptr) {
|
||||||
// Previously we used SO_REUSEPORT here, but that meant that machines running
|
// Previously we used SO_REUSEPORT here, but that meant that machines running
|
||||||
// RiV-mesh nodes as different users would inevitably fail with EADDRINUSE.
|
// RiV-mesh nodes as different users would inevitably fail with EADDRINUSE.
|
||||||
// The behaviour for multicast is similar with both, so we'll use SO_REUSEADDR
|
// The behaviour for multicast is similar with both, so we'll use SO_REUSEADDR
|
||||||
// instead.
|
// instead.
|
||||||
if reuseaddr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1); reuseaddr != nil {
|
if reuseaddr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1); reuseaddr != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to set SO_REUSEADDR on socket: %s\n", reuseaddr)
|
fmt.Fprintf(os.Stderr, "Failed to set SO_REUSEADDR on socket: %s\n", reuseaddr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,8 @@ func MaximumMTU() uint64 {
|
||||||
func New(core *core.Core, log core.Logger, opts ...SetupOption) (*TunAdapter, error) {
|
func New(core *core.Core, log core.Logger, opts ...SetupOption) (*TunAdapter, error) {
|
||||||
tun := &TunAdapter{
|
tun := &TunAdapter{
|
||||||
core: core,
|
core: core,
|
||||||
rwc: ipv6rwc.NewReadWriteCloser(core),
|
rwc: ipv6rwc.NewReadWriteCloser(core),
|
||||||
log: log,
|
log: log,
|
||||||
}
|
}
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
tun._applyOption(opt)
|
tun._applyOption(opt)
|
||||||
|
|
|
@ -6,9 +6,9 @@ package tun
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/RiV-chain/RiV-mesh/src/defaults"
|
"github.com/RiV-chain/RiV-mesh/src/defaults"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
|
@ -43,7 +43,7 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
|
||||||
if i > 8 {
|
if i > 8 {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
time.Sleep(time.Duration(2 * i) * time.Second)
|
time.Sleep(time.Duration(2*i) * time.Second)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue