From 0e1fae92cf127a350d11b72e3ed8524064d5879a Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Fri, 9 Dec 2022 20:51:28 +0200 Subject: [PATCH 01/25] Fix cd --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index 4e899c83..02b7bd38 100755 --- a/build +++ b/build @@ -42,7 +42,7 @@ buildbin() { local CMD=$(realpath $1) echo "Building: $CMD for $GOOS-$GOARCH" - (cd $TARGET_PATH && go build $ARGS -ldflags "${LDFLAGS}${LDFLAGS2}" -gcflags "$GCFLAGS" $CMD) + (cd "$TARGET_PATH" && go build $ARGS -ldflags "${LDFLAGS}${LDFLAGS2}" -gcflags "$GCFLAGS" $CMD) if [ $UPX ]; then upx --brute $CMD From 0cd4b8a640d3cdf838aa9aa5321ca9a38cdb57f8 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Fri, 9 Dec 2022 21:27:30 +0200 Subject: [PATCH 02/25] quoted paths --- build | 4 ++-- contrib/deb/generate.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build b/build index 02b7bd38..1da3af43 100755 --- a/build +++ b/build @@ -42,10 +42,10 @@ buildbin() { local CMD=$(realpath $1) echo "Building: $CMD for $GOOS-$GOARCH" - (cd "$TARGET_PATH" && go build $ARGS -ldflags "${LDFLAGS}${LDFLAGS2}" -gcflags "$GCFLAGS" $CMD) + (cd "$TARGET_PATH" && go build $ARGS -ldflags "${LDFLAGS}${LDFLAGS2}" -gcflags "$GCFLAGS" "$CMD") if [ $UPX ]; then - upx --brute $CMD + upx --brute "$CMD" fi } diff --git a/contrib/deb/generate.sh b/contrib/deb/generate.sh index 30622c19..0244484d 100644 --- a/contrib/deb/generate.sh +++ b/contrib/deb/generate.sh @@ -4,13 +4,13 @@ # mesh and enables it in systemd. You can give it the PKGARCH= argument # i.e. PKGARCH=i386 sh contrib/deb/generate.sh -if [ `pwd` != `git rev-parse --show-toplevel` ] +if [ $(pwd) != $(git rev-parse --show-toplevel) ] then echo "You should run this script from the top-level directory of the git repo" exit 1 fi -PKGBRANCH=$(basename `git name-rev --name-only HEAD`) +PKGBRANCH=$(basename $(git name-rev --name-only HEAD)) PKG=$(sh contrib/semver/name.sh) PKGVERSION=$(sh contrib/semver/version.sh --bare) PKGARCH=${PKGARCH-amd64} @@ -113,7 +113,7 @@ EOF cp mesh /tmp/$PKGNAME/usr/bin/ cp meshctl /tmp/$PKGNAME/usr/bin/ ln -s /usr/bin/meshctl /tmp/$PKGNAME/usr/local/bin/meshctl -if [ $LOGLEVEL = "DEBUG" ]; then cp contrib/systemd/mesh-debug.service /tmp/$PKGNAME/etc/systemd/system/mesh.service +if [ "$LOGLEVEL" = "DEBUG" ]; then cp contrib/systemd/mesh-debug.service /tmp/$PKGNAME/etc/systemd/system/mesh.service else cp contrib/systemd/mesh.service /tmp/$PKGNAME/etc/systemd/system/ fi From 7d7db5731908085ff5209983fa255c94cbaee75c Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Fri, 9 Dec 2022 21:29:53 +0200 Subject: [PATCH 03/25] quoted paths --- contrib/deb/generate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/deb/generate.sh b/contrib/deb/generate.sh index 0244484d..ed8f86fe 100644 --- a/contrib/deb/generate.sh +++ b/contrib/deb/generate.sh @@ -4,13 +4,13 @@ # mesh and enables it in systemd. You can give it the PKGARCH= argument # i.e. PKGARCH=i386 sh contrib/deb/generate.sh -if [ $(pwd) != $(git rev-parse --show-toplevel) ] +if [ "$(pwd)" != "$(git rev-parse --show-toplevel)" ] then echo "You should run this script from the top-level directory of the git repo" exit 1 fi -PKGBRANCH=$(basename $(git name-rev --name-only HEAD)) +PKGBRANCH=$(basename "$(git name-rev --name-only HEAD)") PKG=$(sh contrib/semver/name.sh) PKGVERSION=$(sh contrib/semver/version.sh --bare) PKGARCH=${PKGARCH-amd64} From 70d32441c0a8242f2282b574694ee53c4e6267ca Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Sat, 10 Dec 2022 11:10:59 +0200 Subject: [PATCH 04/25] Added mest-ui start options and ability to enable debug console --- build | 4 ---- contrib/ui/mesh-ui/webview.go | 23 +++++++++++++++++++++++ contrib/ui/mesh-ui/webview_other.go | 3 +++ contrib/ui/mesh-ui/webview_windows.go | 16 ++++++++++++++++ go.mod | 1 + go.sum | 2 ++ 6 files changed, 45 insertions(+), 4 deletions(-) diff --git a/build b/build index 1da3af43..10e9c7b6 100755 --- a/build +++ b/build @@ -58,10 +58,6 @@ build_meshctl() { } build_mesh_ui() { - #only UI should be built with windowsgui flag - if [ "$GOOS" == "windows" ]; then - LDFLAGS2=" -H windowsgui" - fi buildbin ./contrib/ui/mesh-ui } diff --git a/contrib/ui/mesh-ui/webview.go b/contrib/ui/mesh-ui/webview.go index 001aade6..e3cd0927 100755 --- a/contrib/ui/mesh-ui/webview.go +++ b/contrib/ui/mesh-ui/webview.go @@ -18,9 +18,32 @@ import ( "github.com/webview/webview" "github.com/RiV-chain/RiV-mesh/src/admin" + "github.com/docopt/docopt-go" ) +var confui struct { + Console bool `docopt:"-c,--console"` +} + func main() { + usage := `Graphical interface for RiV mesh. + +Usage: + mesh-ui + mesh-ui -c | --console + mesh-ui -h | --help + mesh-ui -v | --version + +Options: + -c --console Show debug console window. + -h --help Show this screen. + -v --version Show version.` + + opts, _ := docopt.ParseArgs(usage, os.Args[1:], "0.0.1") + opts.Bind(&confui) + if !confui.Console { + Console(false) + } debug := true w := webview.New(debug) defer w.Destroy() diff --git a/contrib/ui/mesh-ui/webview_other.go b/contrib/ui/mesh-ui/webview_other.go index 782e0954..099b4f84 100644 --- a/contrib/ui/mesh-ui/webview_other.go +++ b/contrib/ui/mesh-ui/webview_other.go @@ -30,3 +30,6 @@ func run_command_with_arg(command string, arg string) []byte { } return out } + +func Console(show bool) { +} diff --git a/contrib/ui/mesh-ui/webview_windows.go b/contrib/ui/mesh-ui/webview_windows.go index 2b0fd730..4682ca6a 100755 --- a/contrib/ui/mesh-ui/webview_windows.go +++ b/contrib/ui/mesh-ui/webview_windows.go @@ -33,3 +33,19 @@ func run_command_with_arg(command string, arg string) []byte { } return out } + +func Console(show bool) { + var getWin = syscall.NewLazyDLL("kernel32.dll").NewProc("GetConsoleWindow") + var showWin = syscall.NewLazyDLL("user32.dll").NewProc("ShowWindow") + hwnd, _, _ := getWin.Call() + if hwnd == 0 { + return + } + if show { + var SW_RESTORE uintptr = 9 + showWin.Call(hwnd, SW_RESTORE) + } else { + var SW_HIDE uintptr = 0 + showWin.Call(hwnd, SW_HIDE) + } +} diff --git a/go.mod b/go.mod index ef843c08..ee1d4d0d 100644 --- a/go.mod +++ b/go.mod @@ -23,6 +23,7 @@ require ( ) require ( + github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 // indirect 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 diff --git a/go.sum b/go.sum index 30f678f1..4c41cad8 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/cheggaaa/pb/v3 v3.0.8/go.mod h1:UICbiLec/XO6Hw6k+BHEtHeQFzzBH4i2/qk/o github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ= +github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= From 16582494af22fd366682f6352100afffa0609f1e Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Sat, 10 Dec 2022 14:36:42 +0200 Subject: [PATCH 05/25] Fixed tabs, formatted index.html and fixed markup issues --- contrib/ui/mesh-ui/ui/index.html | 1323 ++++++++++++++++++------------ 1 file changed, 797 insertions(+), 526 deletions(-) diff --git a/contrib/ui/mesh-ui/ui/index.html b/contrib/ui/mesh-ui/ui/index.html index 4d0265fb..760e08ef 100755 --- a/contrib/ui/mesh-ui/ui/index.html +++ b/contrib/ui/mesh-ui/ui/index.html @@ -1,34 +1,35 @@ - - - - + - RiV-mesh - - + + + + + RiV-mesh + + -
-
- -
- - - +
+ - -
-
- -
- - - + +
+ +
+ + + + From 8da27aad4fcd3c7aca3764ebe9533a2370995125 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Sat, 10 Dec 2022 15:12:38 +0200 Subject: [PATCH 06/25] Remove interface name from multicast peer string showing on edit form RIVM-14 --- contrib/ui/mesh-ui/ui/index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/ui/mesh-ui/ui/index.html b/contrib/ui/mesh-ui/ui/index.html index 760e08ef..f1a4c3a8 100755 --- a/contrib/ui/mesh-ui/ui/index.html +++ b/contrib/ui/mesh-ui/ui/index.html @@ -13,6 +13,10 @@ function setFieldValue(id, value) { //console.log(`setFieldValue(${id}, ${value})`); + if(id === 'peers') { + const reg =/%[^\]]*/gm; + value = value.replace(reg,""); + } var field = document.getElementById(id); field.innerHTML = value; } @@ -973,4 +977,4 @@
- + \ No newline at end of file From d6eceef4e3ecc09b774f2ff73e63439775f620d1 Mon Sep 17 00:00:00 2001 From: Mihail Slobodyanuk Date: Sun, 11 Dec 2022 12:37:47 +0200 Subject: [PATCH 07/25] Added footer with service and UI version RIVM-15 --- contrib/ui/mesh-ui/ui/index.html | 17 +++++++++++++---- contrib/ui/mesh-ui/webview.go | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/contrib/ui/mesh-ui/ui/index.html b/contrib/ui/mesh-ui/ui/index.html index f1a4c3a8..08a04873 100755 --- a/contrib/ui/mesh-ui/ui/index.html +++ b/contrib/ui/mesh-ui/ui/index.html @@ -273,7 +273,6 @@ .column { max-height: 350px; - display: flex; flex-direction: column; justify-content: space-between; @@ -321,11 +320,15 @@ img { display: block; } + + html, body { + height: 100vh; + } -
+
-
+ -