From dca4fdd6895704f9e4c5787d04a1484a2a178f03 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Tue, 13 Dec 2022 17:07:34 +0200 Subject: [PATCH 01/19] Moved UI resources to Wwwroot in embedded golang webserver RIVM-23 --- cmd/mesh/main.go | 4 ++-- contrib/deb/generate-gui.sh | 2 +- contrib/macos/create-pkg-gui.sh | 2 +- contrib/macos/mesh.plist | 6 ++++++ contrib/msi/build-msi-gui.sh | 8 ++++---- contrib/systemd/mesh.service | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cmd/mesh/main.go b/cmd/mesh/main.go index 008e0245..ca79e91f 100644 --- a/cmd/mesh/main.go +++ b/cmd/mesh/main.go @@ -294,10 +294,10 @@ func run(args yggArgs, ctx context.Context) { return } //override httpaddress and wwwroot parameters in cfg - if len(args.httpaddress) > 0 { + if len(cfg.HttpAddress) == 0 { cfg.HttpAddress = args.httpaddress } - if len(args.wwwroot) > 0 { + if len(cfg.WwwRoot) == 0 { cfg.WwwRoot = args.wwwroot } diff --git a/contrib/deb/generate-gui.sh b/contrib/deb/generate-gui.sh index f87a7e91..a262dbfd 100755 --- a/contrib/deb/generate-gui.sh +++ b/contrib/deb/generate-gui.sh @@ -57,7 +57,7 @@ cat > /tmp/$PKGNAME/usr/share/applications/riv.desktop << EOF Name=RiV mesh GenericName=Mesh 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 Type=Application Icon=riv diff --git a/contrib/macos/create-pkg-gui.sh b/contrib/macos/create-pkg-gui.sh index df6181f7..10be6cef 100644 --- a/contrib/macos/create-pkg-gui.sh +++ b/contrib/macos/create-pkg-gui.sh @@ -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 #!/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 # Create the postinstall script diff --git a/contrib/macos/mesh.plist b/contrib/macos/mesh.plist index fb9bb01d..86461721 100644 --- a/contrib/macos/mesh.plist +++ b/contrib/macos/mesh.plist @@ -9,6 +9,12 @@ /Applications/RiV-mesh.app/Contents/MacOS/mesh -useconffile /etc/mesh.conf + -logto + /var/log/mesh.log + -httpaddress + http://localhost:19019 + -wwwroot + /Applications/RiV-mesh.app/Contents/Resources/ui KeepAlive diff --git a/contrib/msi/build-msi-gui.sh b/contrib/msi/build-msi-gui.sh index 1ff27896..c7595aa7 100644 --- a/contrib/msi/build-msi-gui.sh +++ b/contrib/msi/build-msi-gui.sh @@ -220,7 +220,7 @@ cat > wix.xml << EOF Name="Mesh" Start="auto" 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]\\RiV-mesh\\ui"' Vital="yes" /> wix.xml << EOF @@ -325,7 +325,7 @@ cat > wix.xml << EOF Description="RiV-mesh is IoT E2E encrypted network" Directory="DesktopFolder" Target="[MeshInstallFolder]mesh-ui.exe" - Arguments="ui\index.html" + Arguments="http://localhost:19019" WorkingDirectory="MeshInstallFolder"/> wix.xml << EOF Key="Software\Microsoft\Windows\CurrentVersion\Run" Name="RiV-mesh client" Type="string" - Value='"[MeshInstallFolder]mesh-ui.exe" "[MeshInstallFolder]ui\index.html"' /> + Value='"[MeshInstallFolder]mesh-ui.exe" "http://localhost:19019"' /> ASSISTANCE_START_VIA_REGISTRY diff --git a/contrib/systemd/mesh.service b/contrib/systemd/mesh.service index 6cf5962f..ea58cf14 100644 --- a/contrib/systemd/mesh.service +++ b/contrib/systemd/mesh.service @@ -12,7 +12,7 @@ ProtectSystem=true SyslogIdentifier=mesh CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE 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" ExecReload=/bin/kill -HUP $MAINPID Restart=always TimeoutStopSec=5 From 2003d1ca03d964f526e8922303556c05ea3b0352 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Tue, 13 Dec 2022 17:30:11 +0200 Subject: [PATCH 02/19] Fix RIVM-23 --- contrib/msi/build-msi-gui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/msi/build-msi-gui.sh b/contrib/msi/build-msi-gui.sh index c7595aa7..f570aa88 100644 --- a/contrib/msi/build-msi-gui.sh +++ b/contrib/msi/build-msi-gui.sh @@ -220,7 +220,7 @@ cat > wix.xml << EOF Name="Mesh" Start="auto" Type="ownProcess" - Arguments='-useconffile "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf" -logto "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.log" -httpaddress "http://localhost:19019" -wwwroot "[MeshInstallFolder]\\RiV-mesh\\ui"' + Arguments='-useconffile "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf" -logto "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.log" -httpaddress "http://localhost:19019" -wwwroot "[MeshInstallFolder]\\ui"' Vital="yes" /> Date: Tue, 13 Dec 2022 17:38:45 +0200 Subject: [PATCH 03/19] Fix RIVM-23 --- src/admin/admin.go | 55 +++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/src/admin/admin.go b/src/admin/admin.go index 6cfb3201..dd174398 100644 --- a/src/admin/admin.go +++ b/src/admin/admin.go @@ -5,14 +5,17 @@ import ( "errors" "fmt" "net" - "net/url" "net/http" + "net/url" "os" "sort" + "archive/zip" "strings" "time" + "github.com/remyoudompheng/go-misc/zipfs" + "github.com/RiV-chain/RiV-mesh/src/config" "github.com/RiV-chain/RiV-mesh/src/core" ) @@ -203,26 +206,26 @@ func (a *AdminSocket) SetupAdminHandlers() { return res, nil }, ) - _ = a.AddHandler("addPeers", "Add peers to this node", []string{"uri", "[interface]"}, func(in json.RawMessage) (interface{}, error) { - req := &AddPeersRequest{} - res := &AddPeersResponse{} + _ = a.AddHandler("addPeers", "Add peers to this node", []string{"uri", "[interface]"}, func(in json.RawMessage) (interface{}, error) { + req := &AddPeersRequest{} + 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 { - return nil, err - } + if err := json.Unmarshal(in, &req); err != nil { + return nil, err + } - if err := a.addPeersHandler(req, res); err != nil { - return nil, err - } - return res, nil - }) - _ = a.AddHandler("removePeers", "Remove all peers from this node", []string{}, func(in json.RawMessage) (interface{}, error) { - a.core.RemovePeers() - res := &AddPeersResponse{} - return res, nil - }) + if err := a.addPeersHandler(req, res); err != nil { + return nil, err + } + return res, nil + }) + _ = a.AddHandler("removePeers", "Remove all peers from this node", []string{}, func(in json.RawMessage) (interface{}, error) { + a.core.RemovePeers() + res := &AddPeersResponse{} + return res, nil + }) //_ = a.AddHandler("getNodeInfo", []string{"key"}, t.proto.nodeinfo.nodeInfoAdminHandler) //_ = a.AddHandler("debug_remoteGetSelf", []string{"key"}, t.proto.getSelfHandler) @@ -232,16 +235,16 @@ func (a *AdminSocket) SetupAdminHandlers() { // Start runs http server 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) if err != nil { a.log.Errorln("An error occurred parsing http address:", err) 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) }) - 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") req := &GetSelfRequest{} res := &GetSelfResponse{} @@ -254,7 +257,7 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) { } fmt.Fprintf(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") req := &GetPeersRequest{} res := &GetPeersResponse{} @@ -268,7 +271,13 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) { } fmt.Fprintf(w, string(b[:])) }) - http.Handle("/", http.FileServer(http.Dir(nc.WwwRoot))) + fs := http.Dir(nc.WwwRoot) + pak, err := zip.OpenReader(nc.WwwRoot) + if err == nil { + fs = zipfs.NewZipFS(&pak.Reader) + defer pak.Close() + } + http.Handle("/", http.FileServer(fs)) l, e := net.Listen("tcp4", u.Host) if e != nil { a.log.Errorln("%s\n", e) From 1c9fd3253330a4d1d37fd84e2213b26b73612c57 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Tue, 13 Dec 2022 17:38:52 +0200 Subject: [PATCH 04/19] Fix RIVM-23 --- contrib/systemd/mesh.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/systemd/mesh.service b/contrib/systemd/mesh.service index ea58cf14..f6c2557e 100644 --- a/contrib/systemd/mesh.service +++ b/contrib/systemd/mesh.service @@ -12,7 +12,7 @@ ProtectSystem=true SyslogIdentifier=mesh CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE ExecStartPre=+-/sbin/modprobe tun -ExecStart=/usr/bin/mesh -useconffile /etc/mesh.conf -logto /var/log/mesh.log -httpaddress "http://localhost:19019" -wwwroot "/usr/share/riv" +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 Restart=always TimeoutStopSec=5 From 12c3103039758a24c2a4473a74e1c9559a6804d7 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Tue, 13 Dec 2022 17:40:34 +0200 Subject: [PATCH 05/19] Revert "Fix RIVM-23" This reverts commit f25344829658b9634f3f984e68450cafccd8c823. --- src/admin/admin.go | 55 +++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/src/admin/admin.go b/src/admin/admin.go index dd174398..6cfb3201 100644 --- a/src/admin/admin.go +++ b/src/admin/admin.go @@ -5,17 +5,14 @@ import ( "errors" "fmt" "net" - "net/http" "net/url" + "net/http" "os" "sort" - "archive/zip" "strings" "time" - "github.com/remyoudompheng/go-misc/zipfs" - "github.com/RiV-chain/RiV-mesh/src/config" "github.com/RiV-chain/RiV-mesh/src/core" ) @@ -206,26 +203,26 @@ func (a *AdminSocket) SetupAdminHandlers() { return res, nil }, ) - _ = a.AddHandler("addPeers", "Add peers to this node", []string{"uri", "[interface]"}, func(in json.RawMessage) (interface{}, error) { - req := &AddPeersRequest{} - res := &AddPeersResponse{} + _ = a.AddHandler("addPeers", "Add peers to this node", []string{"uri", "[interface]"}, func(in json.RawMessage) (interface{}, error) { + req := &AddPeersRequest{} + 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 { - return nil, err - } + if err := json.Unmarshal(in, &req); err != nil { + return nil, err + } - if err := a.addPeersHandler(req, res); err != nil { - return nil, err - } - return res, nil - }) - _ = a.AddHandler("removePeers", "Remove all peers from this node", []string{}, func(in json.RawMessage) (interface{}, error) { - a.core.RemovePeers() - res := &AddPeersResponse{} - return res, nil - }) + if err := a.addPeersHandler(req, res); err != nil { + return nil, err + } + return res, nil + }) + _ = a.AddHandler("removePeers", "Remove all peers from this node", []string{}, func(in json.RawMessage) (interface{}, error) { + a.core.RemovePeers() + res := &AddPeersResponse{} + return res, nil + }) //_ = a.AddHandler("getNodeInfo", []string{"key"}, t.proto.nodeinfo.nodeInfoAdminHandler) //_ = a.AddHandler("debug_remoteGetSelf", []string{"key"}, t.proto.getSelfHandler) @@ -235,16 +232,16 @@ func (a *AdminSocket) SetupAdminHandlers() { // Start runs http server 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) if err != nil { a.log.Errorln("An error occurred parsing http address:", err) 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) }) - 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") req := &GetSelfRequest{} res := &GetSelfResponse{} @@ -257,7 +254,7 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) { } fmt.Fprintf(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") req := &GetPeersRequest{} res := &GetPeersResponse{} @@ -271,13 +268,7 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) { } fmt.Fprintf(w, string(b[:])) }) - fs := http.Dir(nc.WwwRoot) - pak, err := zip.OpenReader(nc.WwwRoot) - if err == nil { - fs = zipfs.NewZipFS(&pak.Reader) - defer pak.Close() - } - http.Handle("/", http.FileServer(fs)) + http.Handle("/", http.FileServer(http.Dir(nc.WwwRoot))) l, e := net.Listen("tcp4", u.Host) if e != nil { a.log.Errorln("%s\n", e) From 166360ecced8cfdbefa6afd8f141511c795d0339 Mon Sep 17 00:00:00 2001 From: vadym Date: Tue, 13 Dec 2022 19:19:07 +0200 Subject: [PATCH 06/19] fixed app service enable in RNV NAS --- contrib/ui/nas-netgear-os6/package/DEBIAN/postinst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/ui/nas-netgear-os6/package/DEBIAN/postinst b/contrib/ui/nas-netgear-os6/package/DEBIAN/postinst index 37ab51c3..d56dc904 100755 --- a/contrib/ui/nas-netgear-os6/package/DEBIAN/postinst +++ b/contrib/ui/nas-netgear-os6/package/DEBIAN/postinst @@ -54,8 +54,8 @@ fi chmod 755 /etc/mesh.conf if command -v systemctl >/dev/null; then systemctl daemon-reload || echo -n "daemon not reloaded!" - systemctl enable mesh || echo -n "systemctl enable failed!" - systemctl restart mesh || echo -n "systemctl restart failed!" + systemctl enable fvapp-mesh || echo -n "systemctl enable failed!" + systemctl restart fvapp-mesh || echo -n "systemctl restart failed!" fi exit 0 From 726b76dd0c467609d118c669cc38daf781844338 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Tue, 13 Dec 2022 19:24:43 +0200 Subject: [PATCH 07/19] Zipped ui fo Windows RIVM-23 --- contrib/msi/build-msi-gui.sh | 52 ++++++----------------------- go.mod | 4 ++- go.sum | 4 +++ src/admin/admin.go | 64 ++++++++++++++++++++++-------------- 4 files changed, 57 insertions(+), 67 deletions(-) diff --git a/contrib/msi/build-msi-gui.sh b/contrib/msi/build-msi-gui.sh index f570aa88..047d78ae 100644 --- a/contrib/msi/build-msi-gui.sh +++ b/contrib/msi/build-msi-gui.sh @@ -52,8 +52,6 @@ PKGNAME=$(sh contrib/semver/name.sh) PKGVERSION=$(sh contrib/msi/msversion.sh --bare) PKGVERSIONMS=$(echo $PKGVERSION | tr - .) PKGUIFOLDER=contrib/ui/mesh-ui/ui/ -PKGWEBVIEWRESOURCESFOLDER="${PKGUIFOLDER}assets/" -PKGFONTSRESOURCESFOLDER="${PKGUIFOLDER}webfonts/" PKGLICENSEFILE=LICENSE.rtf @@ -112,6 +110,9 @@ else exit 1 fi +PKG_UI_ASSETS_ZIP=$(pwd)/ui +( cd "$PKGUIFOLDER" && zip -q -r "$PKG_UI_ASSETS_ZIP" * ) + if [ $PKGNAME != "master" ]; then PKGDISPLAYNAME="RiV-mesh Network (${PKGNAME} branch)" else @@ -155,49 +156,10 @@ cat > wix.xml << EOF - - - - - - - - - - - - - - - - - - - wix.xml << EOF Name="Mesh" Start="auto" Type="ownProcess" - Arguments='-useconffile "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf" -logto "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.log" -httpaddress "http://localhost:19019" -wwwroot "[MeshInstallFolder]\\ui"' + Arguments='-useconffile "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf" -logto "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.log" -httpaddress "http://localhost:19019" -wwwroot "[MeshInstallFolder]ui.zip"' Vital="yes" /> wix.xml << EOF DiskId="1" Source="${PKGWEBVIEWFILELOADER}" /> + + diff --git a/go.mod b/go.mod index 6b5c8383..2ca37c24 100644 --- a/go.mod +++ b/go.mod @@ -21,6 +21,8 @@ require ( golang.zx2c4.com/wireguard/windows v0.4.12 ) +require gerace.dev/zipfs v0.2.0 // indirect + require ( github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 // indirect github.com/dustin/go-humanize v1.0.0 // indirect @@ -33,11 +35,11 @@ require ( github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect github.com/go-stack/stack v1.8.0 // 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/mattn/go-colorable v0.1.8 // indirect github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // 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/multierr v1.6.0 // indirect go.uber.org/zap v1.19.1 // indirect diff --git a/go.sum b/go.sum index 4c41cad8..8e39951c 100644 --- a/go.sum +++ b/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/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= 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.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.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.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 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= 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/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/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/src/admin/admin.go b/src/admin/admin.go index 6cfb3201..6d708398 100644 --- a/src/admin/admin.go +++ b/src/admin/admin.go @@ -5,14 +5,17 @@ import ( "errors" "fmt" "net" - "net/url" "net/http" + "net/url" "os" "sort" + "archive/zip" "strings" "time" + "gerace.dev/zipfs" + "github.com/RiV-chain/RiV-mesh/src/config" "github.com/RiV-chain/RiV-mesh/src/core" ) @@ -203,26 +206,26 @@ func (a *AdminSocket) SetupAdminHandlers() { return res, nil }, ) - _ = a.AddHandler("addPeers", "Add peers to this node", []string{"uri", "[interface]"}, func(in json.RawMessage) (interface{}, error) { - req := &AddPeersRequest{} - res := &AddPeersResponse{} + _ = a.AddHandler("addPeers", "Add peers to this node", []string{"uri", "[interface]"}, func(in json.RawMessage) (interface{}, error) { + req := &AddPeersRequest{} + 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 { - return nil, err - } + if err := json.Unmarshal(in, &req); err != nil { + return nil, err + } - if err := a.addPeersHandler(req, res); err != nil { - return nil, err - } - return res, nil - }) - _ = a.AddHandler("removePeers", "Remove all peers from this node", []string{}, func(in json.RawMessage) (interface{}, error) { - a.core.RemovePeers() - res := &AddPeersResponse{} - return res, nil - }) + if err := a.addPeersHandler(req, res); err != nil { + return nil, err + } + return res, nil + }) + _ = a.AddHandler("removePeers", "Remove all peers from this node", []string{}, func(in json.RawMessage) (interface{}, error) { + a.core.RemovePeers() + res := &AddPeersResponse{} + return res, nil + }) //_ = a.AddHandler("getNodeInfo", []string{"key"}, t.proto.nodeinfo.nodeInfoAdminHandler) //_ = a.AddHandler("debug_remoteGetSelf", []string{"key"}, t.proto.getSelfHandler) @@ -232,16 +235,16 @@ func (a *AdminSocket) SetupAdminHandlers() { // Start runs http server 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) if err != nil { a.log.Errorln("An error occurred parsing http address:", err) 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) }) - 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") req := &GetSelfRequest{} res := &GetSelfResponse{} @@ -254,7 +257,7 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) { } fmt.Fprintf(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") req := &GetPeersRequest{} res := &GetPeersResponse{} @@ -268,12 +271,25 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) { } fmt.Fprintf(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) if e != nil { a.log.Errorln("%s\n", e) } 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() { a.log.Errorln(http.Serve(l, nil)) From 0864834e36ad0e802ef07f3a9529a7d534b2a2fa Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Tue, 13 Dec 2022 19:49:05 +0200 Subject: [PATCH 08/19] 7Zipped ui fo Windows RIVM-23 --- contrib/msi/build-msi-gui.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/msi/build-msi-gui.sh b/contrib/msi/build-msi-gui.sh index 047d78ae..c699b6bb 100644 --- a/contrib/msi/build-msi-gui.sh +++ b/contrib/msi/build-msi-gui.sh @@ -110,8 +110,9 @@ else exit 1 fi -PKG_UI_ASSETS_ZIP=$(pwd)/ui -( cd "$PKGUIFOLDER" && zip -q -r "$PKG_UI_ASSETS_ZIP" * ) +PKG_UI_ASSETS_ZIP=$(pwd)/ui.zip +7z a "$PKG_UI_ASSETS_ZIP" +( cd "$PKGUIFOLDER" && 7z a "$PKG_UI_ASSETS_ZIP" * ) if [ $PKGNAME != "master" ]; then PKGDISPLAYNAME="RiV-mesh Network (${PKGNAME} branch)" From 78960c0b1d92c0dd1978107f23f9557fb44f6ef1 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Tue, 13 Dec 2022 19:49:31 +0200 Subject: [PATCH 09/19] 7Zipped ui fo Windows RIVM-23 --- contrib/msi/build-msi-gui.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/contrib/msi/build-msi-gui.sh b/contrib/msi/build-msi-gui.sh index c699b6bb..63a071a5 100644 --- a/contrib/msi/build-msi-gui.sh +++ b/contrib/msi/build-msi-gui.sh @@ -111,7 +111,6 @@ else fi PKG_UI_ASSETS_ZIP=$(pwd)/ui.zip -7z a "$PKG_UI_ASSETS_ZIP" ( cd "$PKGUIFOLDER" && 7z a "$PKG_UI_ASSETS_ZIP" * ) if [ $PKGNAME != "master" ]; then From 3ca22a96aac468665f388fa5813c57d02c4a1fd3 Mon Sep 17 00:00:00 2001 From: vadym Date: Tue, 13 Dec 2022 19:56:40 +0200 Subject: [PATCH 10/19] Removed unnecessary components --- contrib/msi/build-msi-gui.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/contrib/msi/build-msi-gui.sh b/contrib/msi/build-msi-gui.sh index 63a071a5..805d7d6b 100644 --- a/contrib/msi/build-msi-gui.sh +++ b/contrib/msi/build-msi-gui.sh @@ -244,9 +244,6 @@ cat > wix.xml << EOF - - - From 60202a2d98913629fb57af8873641154ac5ed1af Mon Sep 17 00:00:00 2001 From: vadym Date: Tue, 13 Dec 2022 20:04:40 +0200 Subject: [PATCH 11/19] Changed to a relative path for ui.zip fix due to wix.xml /c/path issue --- contrib/msi/build-msi-gui.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/msi/build-msi-gui.sh b/contrib/msi/build-msi-gui.sh index 805d7d6b..66b9825d 100644 --- a/contrib/msi/build-msi-gui.sh +++ b/contrib/msi/build-msi-gui.sh @@ -112,6 +112,7 @@ 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 PKGDISPLAYNAME="RiV-mesh Network (${PKGNAME} branch)" @@ -236,7 +237,7 @@ cat > wix.xml << EOF DiskId="1" Source="updateconfig.bat" KeyPath="yes"/> - + From ae954bad3567e8a86d802749b5a0ebcfcf70b7af Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Sun, 11 Dec 2022 19:14:48 +0200 Subject: [PATCH 12/19] Linter errors fixes --- src/admin/addpeers.go | 12 +++++------- src/admin/admin.go | 4 ++-- src/core/link_mpath.go | 12 +++++++----- src/core/link_sctp_linux.go | 27 +++++++++++++++++++-------- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/admin/addpeers.go b/src/admin/addpeers.go index 0f184277..c61d07bc 100644 --- a/src/admin/addpeers.go +++ b/src/admin/addpeers.go @@ -1,14 +1,12 @@ package admin import ( - "fmt" - ) type AddPeersRequest struct { - Uri string `json:"uri"` - Intf string `json:"intf"` + Uri string `json:"uri"` + Intf string `json:"intf"` } type AddPeersResponse struct { @@ -17,12 +15,12 @@ type AddPeersResponse struct { func (a *AdminSocket) addPeersHandler(req *AddPeersRequest, res *AddPeersResponse) error { // Set sane defaults - err:=a.core.AddPeer(req.Uri, req.Intf) + err := a.core.AddPeer(req.Uri, req.Intf) if err != nil { - fmt.Println("adding peer error %s", err) + fmt.Printf("adding peer error %s\n", err) return err } else { - fmt.Println("added peer %s", req.Uri) + fmt.Printf("added peer %s\n", req.Uri) res.List = append(res.List, req.Uri) } diff --git a/src/admin/admin.go b/src/admin/admin.go index 6d708398..8ec9f2ca 100644 --- a/src/admin/admin.go +++ b/src/admin/admin.go @@ -255,7 +255,7 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) { if err != nil { 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) { w.Header().Add("Content-Type", "application/json") @@ -269,7 +269,7 @@ func (a *AdminSocket) StartHttpServer(nc *config.NodeConfig) { if err != nil { http.Error(w, err.Error(), 503) } - fmt.Fprintf(w, string(b[:])) + fmt.Fprint(w, string(b[:])) }) var docFs = "" pakReader, err := zip.OpenReader(nc.WwwRoot) diff --git a/src/core/link_mpath.go b/src/core/link_mpath.go index 3b394381..086048d1 100644 --- a/src/core/link_mpath.go +++ b/src/core/link_mpath.go @@ -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) { - hostport := url.Host - if sintf != "" { - if host, port, err := net.SplitHostPort(hostport); err == nil { - hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port) + /* + hostport := url.Host + if sintf != "" { + if host, port, err := net.SplitHostPort(hostport); err == nil { + hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port) + } } - } + */ _, cancel := context.WithCancel(l.core.ctx) listener, err := l.listenFor(url, sintf) if err != nil { diff --git a/src/core/link_sctp_linux.go b/src/core/link_sctp_linux.go index d26743aa..f0b13a66 100644 --- a/src/core/link_sctp_linux.go +++ b/src/core/link_sctp_linux.go @@ -55,6 +55,9 @@ func (l *linkSCTP) dial(url *url.URL, options linkOptions, sintf string) error { return err } err = conn.(*sctp.SCTPConn).Connect(raddress) + if err != nil { + return err + } //conn.(*sctp.SCTPConn).SetWriteBuffer(324288) //conn.(*sctp.SCTPConn).SetReadBuffer(324288) //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("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{ url: url, 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) { //_, cancel := context.WithCancel(l.core.ctx) - hostport := url.Host - if sintf != "" { - if host, port, err := net.SplitHostPort(hostport); err == nil { - hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port) + /* + hostport := url.Host + if sintf != "" { + if host, port, err := net.SplitHostPort(hostport); err == nil { + hostport = fmt.Sprintf("[%s%%%s]:%s", host, sintf, port) + } } - } + */ addr := l.getAddress(url.Host) 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() 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{ Listener: listener, closed: make(chan struct{}), @@ -155,7 +166,7 @@ func (l *linkSCTP) getAddr() *net.TCPAddr { return addr } -//SCTP infrastructure +// SCTP infrastructure func (l *linkSCTP) getAddress(host string) *sctp.SCTPAddr { //sctp supports multihoming but current implementation reuires only one path From a24fde3081ca2d0acee2a7ff899af4831b4ab4e7 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Sun, 11 Dec 2022 19:35:49 +0200 Subject: [PATCH 13/19] Linter errors fixes --- src/core/core.go | 1 - src/core/link_mpath.go | 2 ++ src/core/link_mpath_linux.go | 1 + src/core/link_sctp_linux.go | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/core.go b/src/core/core.go index 58b383d9..67a4fb55 100644 --- a/src/core/core.go +++ b/src/core/core.go @@ -20,7 +20,6 @@ import ( // The Core object represents the Mesh node. You should create a Core // object for each Mesh node you plan to run. type Core struct { - // 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 // guarantee that it will be covered by the mutex diff --git a/src/core/link_mpath.go b/src/core/link_mpath.go index 086048d1..40923425 100644 --- a/src/core/link_mpath.go +++ b/src/core/link_mpath.go @@ -108,6 +108,8 @@ func (l *linkMPATH) handler(dial *linkDial, name string, info linkInfo, conn net } // Returns the address of the listener. +// +//nolint:unused func (l *linkMPATH) getAddr() *net.TCPAddr { // 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 diff --git a/src/core/link_mpath_linux.go b/src/core/link_mpath_linux.go index 29f43b54..cc950aae 100644 --- a/src/core/link_mpath_linux.go +++ b/src/core/link_mpath_linux.go @@ -31,6 +31,7 @@ func (t *linkMPATH) tcpContext(network, address string, c syscall.RawConn) error return nil } +//nolint:unused func (t *linkMPATH) getControl(sintf string) func(string, string, syscall.RawConn) error { return func(network, address string, c syscall.RawConn) error { var err error diff --git a/src/core/link_sctp_linux.go b/src/core/link_sctp_linux.go index f0b13a66..4f934ecf 100644 --- a/src/core/link_sctp_linux.go +++ b/src/core/link_sctp_linux.go @@ -153,6 +153,8 @@ func (l *linkSCTP) handler(dial *linkDial, name string, info linkInfo, conn net. } // Returns the address of the listener. +// +//nolint:unused func (l *linkSCTP) getAddr() *net.TCPAddr { // 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 From 8975868eb8669d24753d37181c73fbfa1b6018a2 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Sun, 11 Dec 2022 20:06:29 +0200 Subject: [PATCH 14/19] Travis install webkit2gtk-4.0 --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c99ac06..fa24bfb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,12 @@ jobs: steps: - 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 uses: actions/setup-go@v3 with: From 3e24187cd19cdfce5c1154a5149fca493a86a47c Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Sun, 11 Dec 2022 20:08:32 +0200 Subject: [PATCH 15/19] Travis install webkit2gtk-4.0 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa24bfb9..ae981785 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: - uses: actions/checkout@v3 - name: Install webkit2gtk-4.0 - - uses: awalsh128/cache-apt-pkgs-action@latest + uses: awalsh128/cache-apt-pkgs-action@latest with: packages: libwebkit2gtk-4.0-dev version: 1.0 From 17a5ef2d39f94bd4b59ff86b2563c474029a1a32 Mon Sep 17 00:00:00 2001 From: vadym Date: Tue, 13 Dec 2022 21:09:28 +0200 Subject: [PATCH 16/19] go mod tidy fix --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 2ca37c24..dae581ec 100644 --- a/go.mod +++ b/go.mod @@ -21,10 +21,10 @@ require ( golang.zx2c4.com/wireguard/windows v0.4.12 ) -require gerace.dev/zipfs v0.2.0 // indirect +require gerace.dev/zipfs v0.2.0 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/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect github.com/getlantern/ema v0.0.0-20190620044903-5943d28f40e4 // indirect From 9f01db2cc70c9f391084b85b9d4e7693983f50be Mon Sep 17 00:00:00 2001 From: vadym Date: Tue, 13 Dec 2022 22:05:29 +0200 Subject: [PATCH 17/19] Added postinstall script for RNV NAS builds --- contrib/nas/nas-netgear-os6.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/nas/nas-netgear-os6.sh b/contrib/nas/nas-netgear-os6.sh index b6b220b3..db1017fe 100644 --- a/contrib/nas/nas-netgear-os6.sh +++ b/contrib/nas/nas-netgear-os6.sh @@ -67,6 +67,9 @@ echo "coping ui package..." cp contrib/ui/nas-netgear-os6/package/apps /tmp/$PKGNAME/ -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 Please see https://github.com/RiV-chain/RiV-mesh/ EOF From 316a202c8fc9c6383521221b665762e40d7045bd Mon Sep 17 00:00:00 2001 From: vadym Date: Tue, 13 Dec 2022 22:37:24 +0200 Subject: [PATCH 18/19] reverced eye icon state --- contrib/ui/mesh-ui/ui/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/ui/mesh-ui/ui/index.html b/contrib/ui/mesh-ui/ui/index.html index 1da3059b..1cc6d5c7 100755 --- a/contrib/ui/mesh-ui/ui/index.html +++ b/contrib/ui/mesh-ui/ui/index.html @@ -237,13 +237,13 @@ } function togglePrivKeyVisibility() { - if (this.classList.contains("fa-eye-slash")) { - this.classList.remove("fa-eye-slash"); - this.classList.add("fa-eye"); - document.getElementById("priv_key_visible").innerHTML = document.getElementById("priv_key").innerHTML; - } else { + if (this.classList.contains("fa-eye")) { this.classList.remove("fa-eye"); 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 = "••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••"; } } @@ -459,7 +459,7 @@
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- +
From 2cc402237e458feea914d009fdc9e1db1e9eced6 Mon Sep 17 00:00:00 2001 From: vadym Date: Tue, 13 Dec 2022 23:05:19 +0200 Subject: [PATCH 19/19] go code autoformat --- src/admin/getdht.go | 1 - src/admin/getpaths.go | 1 - src/admin/getpeers.go | 1 - src/admin/getsessions.go | 1 - src/core/link_tcp.go | 1 - src/core/proto.go | 1 - src/multicast/multicast_darwin.go | 1 - src/multicast/multicast_unix.go | 8 ++++---- src/tun/tun.go | 4 ++-- src/tun/tun_windows.go | 4 ++-- 10 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/admin/getdht.go b/src/admin/getdht.go index 71248a2f..bf9e97bb 100644 --- a/src/admin/getdht.go +++ b/src/admin/getdht.go @@ -5,7 +5,6 @@ import ( "net" "sort" "strings" - //"github.com/RiV-chain/RiV-mesh/src/address" ) diff --git a/src/admin/getpaths.go b/src/admin/getpaths.go index 45760db5..fe845685 100644 --- a/src/admin/getpaths.go +++ b/src/admin/getpaths.go @@ -5,7 +5,6 @@ import ( "net" "sort" "strings" - //"github.com/RiV-chain/RiV-mesh/src/address" ) diff --git a/src/admin/getpeers.go b/src/admin/getpeers.go index fc2426e4..6c8691c8 100644 --- a/src/admin/getpeers.go +++ b/src/admin/getpeers.go @@ -4,7 +4,6 @@ import ( "encoding/hex" "net" "sort" - //"github.com/RiV-chain/RiV-mesh/src/address" ) diff --git a/src/admin/getsessions.go b/src/admin/getsessions.go index a5ae0d1b..07babca5 100644 --- a/src/admin/getsessions.go +++ b/src/admin/getsessions.go @@ -5,7 +5,6 @@ import ( "net" "sort" "strings" - //"github.com/RiV-chain/RiV-mesh/src/address" ) diff --git a/src/core/link_tcp.go b/src/core/link_tcp.go index 74f72e00..714ea9d9 100644 --- a/src/core/link_tcp.go +++ b/src/core/link_tcp.go @@ -186,7 +186,6 @@ func (l *linkTCP) dialerFor(dst *net.TCPAddr, sintf string) (*net.Dialer, error) return dialer, nil } - func tcpIDFor(local net.Addr, remoteAddr *net.TCPAddr) string { if localAddr, ok := local.(*net.TCPAddr); ok && localAddr.IP.Equal(remoteAddr.IP) { // Nodes running on the same host — include both the IP and port. diff --git a/src/core/proto.go b/src/core/proto.go index 76ad4b25..5694c339 100644 --- a/src/core/proto.go +++ b/src/core/proto.go @@ -11,7 +11,6 @@ import ( iwt "github.com/Arceliar/ironwood/types" "github.com/Arceliar/phony" - //"github.com/RiV-chain/RiV-mesh/src/address" ) diff --git a/src/multicast/multicast_darwin.go b/src/multicast/multicast_darwin.go index 7c2579d4..22cf3998 100644 --- a/src/multicast/multicast_darwin.go +++ b/src/multicast/multicast_darwin.go @@ -4,7 +4,6 @@ package multicast - import ( "syscall" diff --git a/src/multicast/multicast_unix.go b/src/multicast/multicast_unix.go index 60477740..4247d7d1 100644 --- a/src/multicast/multicast_unix.go +++ b/src/multicast/multicast_unix.go @@ -20,10 +20,10 @@ func (m *Multicast) multicastReuse(network string, address string, c syscall.Raw var reuseaddr error control = c.Control(func(fd uintptr) { - // Previously we used SO_REUSEPORT here, but that meant that machines running - // 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 - // instead. + // Previously we used SO_REUSEPORT here, but that meant that machines running + // 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 + // instead. 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) } diff --git a/src/tun/tun.go b/src/tun/tun.go index dc572b6e..92451e0d 100644 --- a/src/tun/tun.go +++ b/src/tun/tun.go @@ -94,8 +94,8 @@ func MaximumMTU() uint64 { func New(core *core.Core, log core.Logger, opts ...SetupOption) (*TunAdapter, error) { tun := &TunAdapter{ core: core, - rwc: ipv6rwc.NewReadWriteCloser(core), - log: log, + rwc: ipv6rwc.NewReadWriteCloser(core), + log: log, } for _, opt := range opts { tun._applyOption(opt) diff --git a/src/tun/tun_windows.go b/src/tun/tun_windows.go index 11726375..7ffa8721 100644 --- a/src/tun/tun_windows.go +++ b/src/tun/tun_windows.go @@ -6,9 +6,9 @@ package tun import ( "bytes" "errors" - "time" "log" "net" + "time" "github.com/RiV-chain/RiV-mesh/src/defaults" "golang.org/x/sys/windows" @@ -43,7 +43,7 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { if i > 8 { return err } else { - time.Sleep(time.Duration(2 * i) * time.Second) + time.Sleep(time.Duration(2*i) * time.Second) } } else { break