mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Merge branch 'develop' into mesh-ui_emb_ctl
This commit is contained in:
commit
90a2f61e59
19 changed files with 945 additions and 602 deletions
|
@ -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
|
||||
|
|
|
@ -47,11 +47,16 @@ cp meshctl pkgbuild/root/usr/local/bin
|
|||
cp mesh pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS
|
||||
cp mesh-ui pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS
|
||||
cp riv.icns pkgbuild/root/Applications/RiV-mesh.app/Contents/Resources
|
||||
cp contrib/ui/mesh-ui/ui/index.html pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS
|
||||
cp -r contrib/ui/mesh-ui/ui/assets pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS
|
||||
cp -r contrib/ui/mesh-ui/ui/webfonts pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS
|
||||
cp -r contrib/ui/mesh-ui/ui pkgbuild/root/Applications/RiV-mesh.app/Contents/Resources
|
||||
cp contrib/macos/mesh.plist pkgbuild/root/Library/LaunchDaemons
|
||||
|
||||
# Create open script
|
||||
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
|
||||
EOF
|
||||
|
||||
# Create the postinstall script
|
||||
cat > pkgbuild/scripts/postinstall << EOF
|
||||
#!/bin/sh
|
||||
|
@ -82,7 +87,7 @@ chmod 755 pkgbuild/scripts/postinstall
|
|||
chmod 755 pkgbuild/root/usr/local/bin/meshctl
|
||||
chmod 755 pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS/mesh
|
||||
chmod 755 pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS/mesh-ui
|
||||
chmod 755 pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS/index.html
|
||||
chmod 755 pkgbuild/root/Applications/RiV-mesh.app/Contents/MacOS/open-mesh-ui
|
||||
|
||||
# Work out metadata for the package info
|
||||
PKGNAME=$(sh contrib/semver/name.sh)
|
||||
|
@ -115,13 +120,9 @@ cat > pkgbuild/root/Applications/RiV-mesh.app/Contents/Info.plist << EOF
|
|||
<key>CFBundleShortVersionString</key>
|
||||
<string>${PKGVERSION}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>mesh-ui</string>
|
||||
<string>open-mesh-ui</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.github.RiV-mesh.pkg</string>
|
||||
<key>StandardOutPath</key>
|
||||
<string>/tmp/mesh-ui.stdout.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/tmp/mesh-ui.stderr.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
|
|
@ -47,13 +47,17 @@ func (m *Mesh) StartJSON(configjson []byte) error {
|
|||
if err := json.Unmarshal(configjson, &m.config); err != nil {
|
||||
return err
|
||||
}
|
||||
// Setup the Yggdrasil node itself.
|
||||
// Setup the Mesh node itself.
|
||||
{
|
||||
sk, err := hex.DecodeString(m.config.PrivateKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
options := []core.SetupOption{}
|
||||
options := []core.SetupOption{
|
||||
core.NodeInfo(m.config.NodeInfo),
|
||||
core.NodeInfoPrivacy(m.config.NodeInfoPrivacy),
|
||||
core.NetworkDomain(m.config.NetworkDomain),
|
||||
}
|
||||
for _, peer := range m.config.Peers {
|
||||
options = append(options, core.Peer{URI: peer})
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
case "$*" in
|
||||
*--bare*)
|
||||
# Remove the "v" prefix
|
||||
git describe --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" | cut -c 2-
|
||||
git describe --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" --abbrev=7 | cut -c 2-
|
||||
;;
|
||||
*)
|
||||
git describe --tags --match="v[0-9]*\.[0-9]*\.[0-9]*"
|
||||
git describe --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" --abbrev=7
|
||||
;;
|
||||
esac
|
||||
|
|
File diff suppressed because it is too large
Load diff
63
contrib/ui/mesh-ui/webview.go
Executable file → Normal file
63
contrib/ui/mesh-ui/webview.go
Executable file → Normal file
|
@ -21,9 +21,35 @@ import (
|
|||
|
||||
"github.com/RiV-chain/RiV-mesh/src/admin"
|
||||
"github.com/RiV-chain/RiV-mesh/src/defaults"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
var usage = `Graphical interface for RiV mesh.
|
||||
|
||||
Usage:
|
||||
mesh-ui [<index>] [-c]
|
||||
mesh-ui -h | --help
|
||||
mesh-ui -v | --version
|
||||
|
||||
Options:
|
||||
<index> Index file name [default: index.html].
|
||||
-c --console Show debug console window.
|
||||
-h --help Show this screen.
|
||||
-v --version Show version.`
|
||||
|
||||
var confui struct {
|
||||
IndexHtml string `docopt:"<index>"`
|
||||
Console bool `docopt:"-c,--console"`
|
||||
}
|
||||
|
||||
var uiVersion = "0.0.1"
|
||||
|
||||
func main() {
|
||||
opts, _ := docopt.ParseArgs(usage, os.Args[1:], uiVersion)
|
||||
opts.Bind(&confui)
|
||||
if !confui.Console {
|
||||
Console(false)
|
||||
}
|
||||
debug := true
|
||||
w := webview.New(debug)
|
||||
defer w.Destroy()
|
||||
|
@ -67,18 +93,32 @@ func main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
var path string
|
||||
|
||||
if len(os.Args) > 1 {
|
||||
path, err = filepath.Abs(filepath.Dir(os.Args[1]))
|
||||
} else {
|
||||
path, err = filepath.Abs(filepath.Dir(os.Args[0]))
|
||||
if confui.IndexHtml == "" {
|
||||
confui.IndexHtml = "index.html"
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
//Check is it URL already
|
||||
indexUrl, err := url.ParseRequestURI(confui.IndexHtml)
|
||||
if err != nil || len(indexUrl.Scheme) < 2 { // handling no scheme at all and windows c:\ as scheme detection
|
||||
confui.IndexHtml, err = filepath.Abs(confui.IndexHtml)
|
||||
if err != nil {
|
||||
panic(errors.New("Index file not found: " + err.Error()))
|
||||
}
|
||||
if stat, err := os.Stat(confui.IndexHtml); err != nil {
|
||||
panic(errors.New(fmt.Sprintf("Index file %v not found or permissians denied: %v", confui.IndexHtml, err.Error())))
|
||||
} else if stat.IsDir() {
|
||||
panic(errors.New(fmt.Sprintf("Index file %v not found", confui.IndexHtml)))
|
||||
}
|
||||
path_prefix := ""
|
||||
if indexUrl != nil && len(indexUrl.Scheme) == 1 {
|
||||
path_prefix = "/"
|
||||
}
|
||||
indexUrl, err = url.ParseRequestURI("file://" + path_prefix + strings.ReplaceAll(confui.IndexHtml, "\\", "/"))
|
||||
if err != nil {
|
||||
panic(errors.New("Index file URL parse error: " + err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
log.Println(path)
|
||||
w.Bind("onLoad", func() {
|
||||
log.Println("page loaded")
|
||||
go run(w)
|
||||
|
@ -105,10 +145,8 @@ func main() {
|
|||
w.Bind("ping", func(peer_list string) {
|
||||
go ping(w, peer_list)
|
||||
})
|
||||
//dat, err := ioutil.ReadFile(path+"/index.html")
|
||||
//w.Navigate("data:text/html,"+url.QueryEscape(string(dat)))
|
||||
//w.Navigate("data:text/html,"+"<html>"+path+"</html>")
|
||||
w.Navigate("file://" + path + "/index.html")
|
||||
log.Printf("Opening: %v", indexUrl)
|
||||
w.Navigate(indexUrl.String())
|
||||
w.Run()
|
||||
}
|
||||
|
||||
|
@ -179,6 +217,7 @@ func get_self(w webview.WebView) {
|
|||
go setFieldValue(w, "ipv6", res.IPAddress)
|
||||
go setFieldValue(w, "pub_key", res.PublicKey)
|
||||
go setFieldValue(w, "priv_key", res.PrivateKey)
|
||||
go setFieldValue(w, "version", fmt.Sprintf("v%v/%v", res.BuildVersion, uiVersion))
|
||||
//found subnet
|
||||
fmt.Printf("Subnet: %s\n", res.Subnet)
|
||||
go setFieldValue(w, "subnet", res.Subnet)
|
||||
|
|
7
contrib/ui/mesh-ui/webview_other.go
Normal file
7
contrib/ui/mesh-ui/webview_other.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package main
|
||||
|
||||
func Console(show bool) {
|
||||
}
|
24
contrib/ui/mesh-ui/webview_windows.go
Executable file
24
contrib/ui/mesh-ui/webview_windows.go
Executable file
|
@ -0,0 +1,24 @@
|
|||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue