changed Yggdrasil to RiV-mesh

added webview GUI
This commit is contained in:
vadym 2021-09-13 12:10:02 +03:00
parent 3613614b41
commit b5ee2aa023
75 changed files with 1066 additions and 471 deletions

View file

@ -1,6 +1,6 @@
/*
This file generates crypto keys for [ansible-yggdrasil](https://github.com/jcgruenhage/ansible-yggdrasil/)
This file generates crypto keys for [ansible-mesh](https://github.com/jcgruenhage/ansible-mesh/)
*/
package main
@ -14,7 +14,7 @@ import (
"os"
"github.com/cheggaaa/pb/v3"
"github.com/yggdrasil-network/yggdrasil-go/src/address"
"github.com/RiV-chain/RiV-mesh/src/address"
)
var numHosts = flag.Int("hosts", 1, "number of host vars to generate")
@ -57,8 +57,8 @@ func main() {
return
}
defer file.Close()
file.WriteString(fmt.Sprintf("yggdrasil_public_key: %v\n", hex.EncodeToString(keys[i].pub)))
file.WriteString("yggdrasil_private_key: \"{{ vault_yggdrasil_private_key }}\"\n")
file.WriteString(fmt.Sprintf("mesh_public_key: %v\n", hex.EncodeToString(keys[i].pub)))
file.WriteString("mesh_private_key: \"{{ vault_mesh_private_key }}\"\n")
file.WriteString(fmt.Sprintf("ansible_host: %v\n", keys[i].ip))
file, err = os.Create(fmt.Sprintf("host_vars/%x/vault", i))
@ -66,7 +66,7 @@ func main() {
return
}
defer file.Close()
file.WriteString(fmt.Sprintf("vault_yggdrasil_private_key: %v\n", hex.EncodeToString(keys[i].priv)))
file.WriteString(fmt.Sprintf("vault_mesh_private_key: %v\n", hex.EncodeToString(keys[i].priv)))
bar.Increment()
}
bar.Finish()

View file

@ -1,7 +1,7 @@
# Last Modified: Fri Oct 30 11:33:31 2020
#include <tunables/global>
/usr/bin/yggdrasil {
/usr/bin/mesh {
#include <abstractions/base>
#include <abstractions/nameservice>
@ -12,6 +12,6 @@
/proc/sys/net/core/somaxconn r,
/sys/kernel/mm/transparent_hugepage/hpage_pmd_size r,
/etc/yggdrasil.conf rw,
/run/yggdrasil.sock rw,
/etc/mesh.conf rw,
/run/mesh.sock rw,
}

View file

@ -1,9 +1,9 @@
#!/bin/sh
CONFFILE="/etc/yggdrasil.conf"
CONFFILE="/etc/mesh.conf"
genconf() {
/usr/bin/yggdrasil -genconf > "$1"
/usr/bin/mesh -genconf > "$1"
return $?
}
@ -33,8 +33,8 @@ start() {
fi
fi
printf 'Starting yggdrasil: '
if start-stop-daemon -S -q -b -x /usr/bin/yggdrasil \
printf 'Starting mesh: '
if start-stop-daemon -S -q -b -x /usr/bin/mesh \
-- -useconffile "$CONFFILE"; then
echo "OK"
else
@ -43,8 +43,8 @@ start() {
}
stop() {
printf "Stopping yggdrasil: "
if start-stop-daemon -K -q -x /usr/bin/yggdrasil; then
printf "Stopping mesh: "
if start-stop-daemon -K -q -x /usr/bin/mesh; then
echo "OK"
else
echo "FAIL"
@ -52,8 +52,8 @@ stop() {
}
reload() {
printf "Reloading yggdrasil: "
if start-stop-daemon -K -q -s HUP -x /usr/bin/yggdrasil; then
printf "Reloading mesh: "
if start-stop-daemon -K -q -s HUP -x /usr/bin/mesh; then
echo "OK"
else
echo "FAIL"

68
contrib/deb/generate.sh Normal file → Executable file
View file

@ -1,7 +1,7 @@
#!/bin/sh
# This is a lazy script to create a .deb for Debian/Ubuntu. It installs
# yggdrasil and enables it in systemd. You can give it the PKGARCH= argument
# 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` ]
@ -15,10 +15,10 @@ PKGNAME=$(sh contrib/semver/name.sh)
PKGVERSION=$(sh contrib/semver/version.sh --bare)
PKGARCH=${PKGARCH-amd64}
PKGFILE=$PKGNAME-$PKGVERSION-$PKGARCH.deb
PKGREPLACES=yggdrasil
PKGREPLACES=mesh
if [ $PKGBRANCH = "master" ]; then
PKGREPLACES=yggdrasil-develop
PKGREPLACES=mesh-develop
fi
if [ $PKGARCH = "amd64" ]; then GOARCH=amd64 GOOS=linux ./build
@ -41,7 +41,7 @@ mkdir -p /tmp/$PKGNAME/usr/bin/
mkdir -p /tmp/$PKGNAME/etc/systemd/system/
cat > /tmp/$PKGNAME/debian/changelog << EOF
Please see https://github.com/yggdrasil-network/yggdrasil-go/
Please see https://github.com/RiV-chain/RiV-mesh/
EOF
echo 9 > /tmp/$PKGNAME/debian/compat
cat > /tmp/$PKGNAME/debian/control << EOF
@ -53,69 +53,71 @@ Architecture: $PKGARCH
Replaces: $PKGREPLACES
Conflicts: $PKGREPLACES
Maintainer: Neil Alexander <neilalexander@users.noreply.github.com>
Description: Yggdrasil Network
Yggdrasil is an early-stage implementation of a fully end-to-end encrypted IPv6
Description: RiV-mesh Network
RiV-mesh is an early-stage implementation of a fully end-to-end encrypted IPv6
network. It is lightweight, self-arranging, supported on multiple platforms and
allows pretty much any IPv6-capable application to communicate securely with
other Yggdrasil nodes.
other RiV-mesh nodes.
EOF
cat > /tmp/$PKGNAME/debian/copyright << EOF
Please see https://github.com/yggdrasil-network/yggdrasil-go/
Please see https://github.com/RiV-chain/RiV-mesh/
EOF
cat > /tmp/$PKGNAME/debian/docs << EOF
Please see https://github.com/yggdrasil-network/yggdrasil-go/
Please see https://github.com/RiV-chain/RiV-mesh/
EOF
cat > /tmp/$PKGNAME/debian/install << EOF
usr/bin/yggdrasil usr/bin
usr/bin/yggdrasilctl usr/bin
usr/bin/mesh usr/bin
usr/bin/meshctl usr/bin
usr/bin/mesh-ui usr/bin
etc/systemd/system/*.service etc/systemd/system
EOF
cat > /tmp/$PKGNAME/debian/postinst << EOF
#!/bin/sh
if ! getent group yggdrasil 2>&1 > /dev/null; then
groupadd --system --force yggdrasil || echo "Failed to create group 'yggdrasil' - please create it manually and reinstall"
if ! getent group mesh 2>&1 > /dev/null; then
groupadd --system --force mesh || echo "Failed to create group 'mesh' - please create it manually and reinstall"
fi
if [ -f /etc/yggdrasil.conf ];
if [ -f /etc/mesh.conf ];
then
mkdir -p /var/backups
echo "Backing up configuration file to /var/backups/yggdrasil.conf.`date +%Y%m%d`"
cp /etc/yggdrasil.conf /var/backups/yggdrasil.conf.`date +%Y%m%d`
echo "Normalising and updating /etc/yggdrasil.conf"
/usr/bin/yggdrasil -useconf -normaliseconf < /var/backups/yggdrasil.conf.`date +%Y%m%d` > /etc/yggdrasil.conf
chgrp yggdrasil /etc/yggdrasil.conf
echo "Backing up configuration file to /var/backups/mesh.conf.`date +%Y%m%d`"
cp /etc/mesh.conf /var/backups/mesh.conf.`date +%Y%m%d`
echo "Normalising and updating /etc/mesh.conf"
/usr/bin/mesh -useconf -normaliseconf < /var/backups/mesh.conf.`date +%Y%m%d` > /etc/mesh.conf
chgrp mesh /etc/mesh.conf
if command -v systemctl >/dev/null; then
systemctl daemon-reload >/dev/null || true
systemctl enable yggdrasil || true
systemctl start yggdrasil || true
systemctl enable mesh || true
systemctl start mesh || true
fi
else
echo "Generating initial configuration file /etc/yggdrasil.conf"
echo "Please familiarise yourself with this file before starting Yggdrasil"
sh -c 'umask 0027 && /usr/bin/yggdrasil -genconf > /etc/yggdrasil.conf'
chgrp yggdrasil /etc/yggdrasil.conf
echo "Generating initial configuration file /etc/mesh.conf"
echo "Please familiarise yourself with this file before starting Mesh"
sh -c 'umask 0027 && /usr/bin/mesh -genconf > /etc/mesh.conf'
chgrp mesh /etc/mesh.conf
fi
EOF
cat > /tmp/$PKGNAME/debian/prerm << EOF
#!/bin/sh
if command -v systemctl >/dev/null; then
if systemctl is-active --quiet yggdrasil; then
systemctl stop yggdrasil || true
if systemctl is-active --quiet mesh; then
systemctl stop mesh || true
fi
systemctl disable yggdrasil || true
systemctl disable mesh || true
fi
EOF
cp yggdrasil /tmp/$PKGNAME/usr/bin/
cp yggdrasilctl /tmp/$PKGNAME/usr/bin/
cp mesh /tmp/$PKGNAME/usr/bin/
cp meshctl /tmp/$PKGNAME/usr/bin/
cp mesh-ui /tmp/$PKGNAME/usr/bin/
cp contrib/systemd/*.service /tmp/$PKGNAME/etc/systemd/system/
tar -czvf /tmp/$PKGNAME/data.tar.gz -C /tmp/$PKGNAME/ \
usr/bin/yggdrasil usr/bin/yggdrasilctl \
etc/systemd/system/yggdrasil.service \
etc/systemd/system/yggdrasil-default-config.service
usr/bin/mesh usr/bin/meshctl usr/bin/mesh-ui \
etc/systemd/system/mesh.service \
etc/systemd/system/mesh-default-config.service
tar -czvf /tmp/$PKGNAME/control.tar.gz -C /tmp/$PKGNAME/debian .
echo 2.0 > /tmp/$PKGNAME/debian-binary

View file

@ -9,17 +9,17 @@ RUN apk add git && ./build && go build -o /src/genkeys cmd/genkeys/main.go
FROM docker.io/alpine
COPY --from=builder /src/yggdrasil /usr/bin/yggdrasil
COPY --from=builder /src/yggdrasilctl /usr/bin/yggdrasilctl
COPY --from=builder /src/mesh /usr/bin/mesh
COPY --from=builder /src/meshctl /usr/bin/meshctl
COPY --from=builder /src/genkeys /usr/bin/genkeys
COPY contrib/docker/entrypoint.sh /usr/bin/entrypoint.sh
# RUN addgroup -g 1000 -S yggdrasil-network \
# && adduser -u 1000 -S -g 1000 --home /etc/yggdrasil-network yggdrasil-network
# RUN addgroup -g 1000 -S RiV-chain \
# && adduser -u 1000 -S -g 1000 --home /etc/RiV-chain RiV-chain
#
# USER yggdrasil-network
# USER RiV-chain
# TODO: Make running unprivileged work
VOLUME [ "/etc/yggdrasil-network" ]
VOLUME [ "/etc/RiV-chain" ]
ENTRYPOINT [ "/usr/bin/entrypoint.sh" ]

View file

@ -2,12 +2,12 @@
set -e
CONF_DIR="/etc/yggdrasil-network"
CONF_DIR="/etc/RiV-chain"
if [ ! -f "$CONF_DIR/config.conf" ]; then
echo "generate $CONF_DIR/config.conf"
yggdrasil --genconf > "$CONF_DIR/config.conf"
mesh --genconf > "$CONF_DIR/config.conf"
fi
yggdrasil --useconf < "$CONF_DIR/config.conf"
mesh --useconf < "$CONF_DIR/config.conf"
exit $?

72
contrib/freebsd/mesh Normal file
View file

@ -0,0 +1,72 @@
#!/bin/sh
#
# Put the mesh and meshctl binaries into /usr/local/bin
# Then copy this script into /etc/rc.d/mesh
# Finally, run:
# 1. chmod +x /etc/rc.d/mesh /usr/local/bin/{mesh,meshctl}
# 2. echo "mesh_enable=yes" >> /etc/rc.d
# 3. service mesh start
#
# PROVIDE: mesh
# REQUIRE: networking
# KEYWORD:
. /etc/rc.subr
name="mesh"
rcvar="mesh_enable"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
pidfile="/var/run/mesh/${name}.pid"
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -f ${mesh_command}"
mesh_start()
{
test ! -x /usr/local/bin/mesh && (
logger -s -t mesh "Warning: /usr/local/bin/mesh is missing or not executable"
logger -s -t mesh "Copy the mesh binary into /usr/local/bin and then chmod +x /usr/local/bin/mesh"
return 1
)
test ! -f /etc/mesh.conf && (
logger -s -t mesh "Generating new configuration file into /etc/mesh.conf"
/usr/local/bin/mesh -genconf > /etc/mesh.conf
)
tap_path="$(cat /etc/mesh.conf | egrep -o '/dev/tap[0-9]{1,2}$')"
tap_name="$(echo -n ${tap_path} | tr -d '/dev/')"
/sbin/ifconfig ${tap_name} >/dev/null 2>&1 || (
logger -s -t mesh "Creating ${tap_name} adapter"
/sbin/ifconfig ${tap_name} create || logger -s -t mesh "Failed to create ${tap_name} adapter"
)
test ! -d /var/run/mesh && mkdir -p /var/run/mesh
logger -s -t mesh "Starting mesh"
${command} ${command_args} /usr/local/bin/mesh -useconffile /etc/mesh.conf \
1>/var/log/mesh.stdout.log \
2>/var/log/mesh.stderr.log &
}
mesh_stop()
{
logger -s -t mesh "Stopping mesh"
test -f /var/run/mesh/${name}.pid && kill -TERM $(cat /var/run/mesh/${name}.pid)
tap_path="$(cat /etc/mesh.conf | grep /dev/tap | egrep -o '/dev/.*$')"
tap_name="$(echo -n ${tap_path} | tr -d '/dev/')"
/sbin/ifconfig ${tap_name} >/dev/null 2>&1 && (
logger -s -t mesh "Destroying ${tap_name} adapter"
/sbin/ifconfig ${tap_name} destroy || logger -s -t mesh "Failed to destroy ${tap_name} adapter"
)
}
load_rc_config $name
: ${mesh_enable:=no}
run_rc_command "$1"

View file

@ -1,72 +0,0 @@
#!/bin/sh
#
# Put the yggdrasil and yggdrasilctl binaries into /usr/local/bin
# Then copy this script into /etc/rc.d/yggdrasil
# Finally, run:
# 1. chmod +x /etc/rc.d/yggdrasil /usr/local/bin/{yggdrasil,yggdrasilctl}
# 2. echo "yggdrasil_enable=yes" >> /etc/rc.d
# 3. service yggdrasil start
#
# PROVIDE: yggdrasil
# REQUIRE: networking
# KEYWORD:
. /etc/rc.subr
name="yggdrasil"
rcvar="yggdrasil_enable"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
pidfile="/var/run/yggdrasil/${name}.pid"
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -f ${yggdrasil_command}"
yggdrasil_start()
{
test ! -x /usr/local/bin/yggdrasil && (
logger -s -t yggdrasil "Warning: /usr/local/bin/yggdrasil is missing or not executable"
logger -s -t yggdrasil "Copy the yggdrasil binary into /usr/local/bin and then chmod +x /usr/local/bin/yggdrasil"
return 1
)
test ! -f /etc/yggdrasil.conf && (
logger -s -t yggdrasil "Generating new configuration file into /etc/yggdrasil.conf"
/usr/local/bin/yggdrasil -genconf > /etc/yggdrasil.conf
)
tap_path="$(cat /etc/yggdrasil.conf | egrep -o '/dev/tap[0-9]{1,2}$')"
tap_name="$(echo -n ${tap_path} | tr -d '/dev/')"
/sbin/ifconfig ${tap_name} >/dev/null 2>&1 || (
logger -s -t yggdrasil "Creating ${tap_name} adapter"
/sbin/ifconfig ${tap_name} create || logger -s -t yggdrasil "Failed to create ${tap_name} adapter"
)
test ! -d /var/run/yggdrasil && mkdir -p /var/run/yggdrasil
logger -s -t yggdrasil "Starting yggdrasil"
${command} ${command_args} /usr/local/bin/yggdrasil -useconffile /etc/yggdrasil.conf \
1>/var/log/yggdrasil.stdout.log \
2>/var/log/yggdrasil.stderr.log &
}
yggdrasil_stop()
{
logger -s -t yggdrasil "Stopping yggdrasil"
test -f /var/run/yggdrasil/${name}.pid && kill -TERM $(cat /var/run/yggdrasil/${name}.pid)
tap_path="$(cat /etc/yggdrasil.conf | grep /dev/tap | egrep -o '/dev/.*$')"
tap_name="$(echo -n ${tap_path} | tr -d '/dev/')"
/sbin/ifconfig ${tap_name} >/dev/null 2>&1 && (
logger -s -t yggdrasil "Destroying ${tap_name} adapter"
/sbin/ifconfig ${tap_name} destroy || logger -s -t yggdrasil "Failed to destroy ${tap_name} adapter"
)
}
load_rc_config $name
: ${yggdrasil_enable:=no}
run_rc_command "$1"

View file

@ -17,10 +17,10 @@ command -v mkbom >/dev/null 2>&1 || (
# Check if we can find the files we need - they should
# exist if you are running this script from the root of
# the yggdrasil-go repo and you have ran ./build
test -f yggdrasil || (echo "yggdrasil binary not found"; exit 1)
test -f yggdrasilctl || (echo "yggdrasilctl binary not found"; exit 1)
test -f contrib/macos/yggdrasil.plist || (echo "contrib/macos/yggdrasil.plist not found"; exit 1)
# the RiV-mesh repo and you have ran ./build
test -f mesh || (echo "mesh binary not found"; exit 1)
test -f meshctl || (echo "meshctl binary not found"; exit 1)
test -f contrib/macos/mesh.plist || (echo "contrib/macos/mesh.plist not found"; exit 1)
test -f contrib/semver/version.sh || (echo "contrib/semver/version.sh not found"; exit 1)
# Delete the pkgbuild folder if it already exists
@ -34,37 +34,37 @@ mkdir -p pkgbuild/root/usr/local/bin
mkdir -p pkgbuild/root/Library/LaunchDaemons
# Copy package contents into the pkgbuild root
cp yggdrasil pkgbuild/root/usr/local/bin
cp yggdrasilctl pkgbuild/root/usr/local/bin
cp contrib/macos/yggdrasil.plist pkgbuild/root/Library/LaunchDaemons
cp mesh pkgbuild/root/usr/local/bin
cp meshctl pkgbuild/root/usr/local/bin
cp contrib/macos/mesh.plist pkgbuild/root/Library/LaunchDaemons
# Create the postinstall script
cat > pkgbuild/scripts/postinstall << EOF
#!/bin/sh
# Normalise the config if it exists, generate it if it doesn't
if [ -f /etc/yggdrasil.conf ];
if [ -f /etc/mesh.conf ];
then
mkdir -p /Library/Preferences/Yggdrasil
echo "Backing up configuration file to /Library/Preferences/Yggdrasil/yggdrasil.conf.`date +%Y%m%d`"
cp /etc/yggdrasil.conf /Library/Preferences/Yggdrasil/yggdrasil.conf.`date +%Y%m%d`
echo "Normalising /etc/yggdrasil.conf"
/usr/local/bin/yggdrasil -useconffile /Library/Preferences/Yggdrasil/yggdrasil.conf.`date +%Y%m%d` -normaliseconf > /etc/yggdrasil.conf
mkdir -p /Library/Preferences/Mesh
echo "Backing up configuration file to /Library/Preferences/Mesh/mesh.conf.`date +%Y%m%d`"
cp /etc/mesh.conf /Library/Preferences/Mesh/mesh.conf.`date +%Y%m%d`
echo "Normalising /etc/mesh.conf"
/usr/local/bin/mesh -useconffile /Library/Preferences/Mesh/mesh.conf.`date +%Y%m%d` -normaliseconf > /etc/mesh.conf
else
/usr/local/bin/yggdrasil -genconf > /etc/yggdrasil.conf
/usr/local/bin/mesh -genconf > /etc/mesh.conf
fi
# Unload existing Yggdrasil launchd service, if possible
test -f /Library/LaunchDaemons/yggdrasil.plist && (launchctl unload /Library/LaunchDaemons/yggdrasil.plist || true)
# Unload existing Mesh launchd service, if possible
test -f /Library/LaunchDaemons/mesh.plist && (launchctl unload /Library/LaunchDaemons/mesh.plist || true)
# Load Yggdrasil launchd service and start Yggdrasil
launchctl load /Library/LaunchDaemons/yggdrasil.plist
# Load Mesh launchd service and start Mesh
launchctl load /Library/LaunchDaemons/mesh.plist
EOF
# Set execution permissions
chmod +x pkgbuild/scripts/postinstall
chmod +x pkgbuild/root/usr/local/bin/yggdrasil
chmod +x pkgbuild/root/usr/local/bin/yggdrasilctl
chmod +x pkgbuild/root/usr/local/bin/mesh
chmod +x pkgbuild/root/usr/local/bin/meshctl
# Pack payload and scripts
( cd pkgbuild/scripts && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > pkgbuild/flat/base.pkg/Scripts
@ -78,7 +78,7 @@ PAYLOADSIZE=$(( $(wc -c pkgbuild/flat/base.pkg/Payload | awk '{ print $1 }') / 1
# Create the PackageInfo file
cat > pkgbuild/flat/base.pkg/PackageInfo << EOF
<pkg-info format-version="2" identifier="io.github.yggdrasil-network.pkg" version="${PKGVERSION}" install-location="/" auth="root">
<pkg-info format-version="2" identifier="io.github.RiV-chain.pkg" version="${PKGVERSION}" install-location="/" auth="root">
<payload installKBytes="${PAYLOADSIZE}" numberOfFiles="3"/>
<scripts>
<postinstall file="./postinstall"/>
@ -93,7 +93,7 @@ EOF
cat > pkgbuild/flat/Distribution << EOF
<?xml version="1.0" encoding="utf-8"?>
<installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.3" authoringToolBuild="174">
<title>Yggdrasil (${PKGNAME}-${PKGVERSION})</title>
<title>Mesh (${PKGNAME}-${PKGVERSION})</title>
<options customize="never" allow-external-scripts="no"/>
<domains enable_anywhere="true"/>
<installation-check script="pm_install_check();"/>
@ -101,7 +101,7 @@ cat > pkgbuild/flat/Distribution << EOF
function pm_install_check() {
if(!(system.compareVersions(system.version.ProductVersion,'10.10') >= 0)) {
my.result.title = 'Failure';
my.result.message = 'You need at least Mac OS X 10.10 to install Yggdrasil.';
my.result.message = 'You need at least Mac OS X 10.10 to install Mesh.';
my.result.type = 'Fatal';
return false;
}
@ -112,9 +112,9 @@ cat > pkgbuild/flat/Distribution << EOF
<line choice="choice1"/>
</choices-outline>
<choice id="choice1" title="base">
<pkg-ref id="io.github.yggdrasil-network.pkg"/>
<pkg-ref id="io.github.RiV-chain.pkg"/>
</choice>
<pkg-ref id="io.github.yggdrasil-network.pkg" installKBytes="${PAYLOADSIZE}" version="${VERSION}" auth="Root">#base.pkg</pkg-ref>
<pkg-ref id="io.github.RiV-chain.pkg" installKBytes="${PAYLOADSIZE}" version="${VERSION}" auth="Root">#base.pkg</pkg-ref>
</installer-script>
EOF

View file

@ -3,12 +3,12 @@
<plist version="1.0">
<dict>
<key>Label</key>
<string>yggdrasil</string>
<string>mesh</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>/usr/local/bin/yggdrasil -useconffile /etc/yggdrasil.conf</string>
<string>/usr/local/bin/mesh -useconffile /etc/mesh.conf</string>
</array>
<key>KeepAlive</key>
<true/>
@ -17,8 +17,8 @@
<key>ProcessType</key>
<string>Interactive</string>
<key>StandardOutPath</key>
<string>/tmp/yggdrasil.stdout.log</string>
<string>/tmp/mesh.stdout.log</string>
<key>StandardErrorPath</key>
<string>/tmp/yggdrasil.stderr.log</string>
<string>/tmp/mesh.stderr.log</string>
</dict>
</plist>

View file

@ -0,0 +1,12 @@
.PHONY: all
all: util mesh-brute-multi-curve25519 mesh-brute-multi-ed25519
util: util.c
gcc -Wall -std=c89 -O3 -c -o util.o util.c
mesh-brute-multi-ed25519: mesh-brute-multi-ed25519.c util.o
gcc -Wall -std=c89 -O3 -o mesh-brute-multi-ed25519 -lsodium mesh-brute-multi-ed25519.c util.o
mesh-brute-multi-curve25519: mesh-brute-multi-curve25519.c util.o
gcc -Wall -std=c89 -O3 -o mesh-brute-multi-curve25519 -lsodium mesh-brute-multi-curve25519.c util.o

View file

@ -1,4 +1,4 @@
# yggdrasil-brute-simple
# mesh-brute-simple
Simple program for finding curve25519 and ed25519 public keys whose sha512 hash has many leading ones.
Because ed25519 private keys consist of a seed that is hashed to find the secret part of the keypair,

View file

@ -13,7 +13,7 @@ if besthash:
besthash = hash
*/
#include "yggdrasil-brute.h"
#include "mesh-brute.h"
void seed(unsigned char sk[32]) {
@ -43,7 +43,7 @@ int main(int argc, char **argv) {
int where;
if (argc != 2) {
fprintf(stderr, "usage: ./yggdrasil-brute-multi-curve25519 <seconds>\n");
fprintf(stderr, "usage: ./mesh-brute-multi-curve25519 <seconds>\n");
return 1;
}
@ -57,7 +57,7 @@ int main(int argc, char **argv) {
requestedtime = atoi(argv[1]);
if (requestedtime < 0) requestedtime = 0;
fprintf(stderr, "Searching for yggdrasil curve25519 keys (this will take slightly longer than %ld seconds)\n", requestedtime);
fprintf(stderr, "Searching for mesh curve25519 keys (this will take slightly longer than %ld seconds)\n", requestedtime);
sodium_memzero(bestsklist, NUMKEYS * 32);
sodium_memzero(bestpklist, NUMKEYS * 32);

View file

@ -20,7 +20,7 @@ if besthash:
besthash = hash
*/
#include "yggdrasil-brute.h"
#include "mesh-brute.h"
int main(int argc, char **argv) {
@ -41,7 +41,7 @@ int main(int argc, char **argv) {
int where;
if (argc != 2) {
fprintf(stderr, "usage: ./yggdrasil-brute-multi-curve25519 <seconds>\n");
fprintf(stderr, "usage: ./mesh-brute-multi-curve25519 <seconds>\n");
return 1;
}
@ -55,7 +55,7 @@ int main(int argc, char **argv) {
requestedtime = atoi(argv[1]);
if (requestedtime < 0) requestedtime = 0;
fprintf(stderr, "Searching for yggdrasil ed25519 keys (this will take slightly longer than %ld seconds)\n", requestedtime);
fprintf(stderr, "Searching for mesh ed25519 keys (this will take slightly longer than %ld seconds)\n", requestedtime);
sodium_memzero(bestsklist, NUMKEYS * 64);
sodium_memzero(besthashlist, NUMKEYS * 64);

View file

@ -1,4 +1,4 @@
#include "yggdrasil-brute.h"
#include "mesh-brute.h"
int find_where(unsigned char hash[64], unsigned char besthashlist[NUMKEYS][64]) {
/* Where to insert hash into sorted hashlist */
@ -28,7 +28,7 @@ void insert_32(unsigned char itemlist[NUMKEYS][32], unsigned char item[32], int
}
void make_addr(unsigned char addr[32], unsigned char hash[64]) {
/* Public key hash to yggdrasil ipv6 address */
/* Public key hash to mesh ipv6 address */
int i;
int offset;
unsigned char mask;

120
contrib/msi/build-msi.sh Normal file → Executable file
View file

@ -1,6 +1,6 @@
#!/bin/sh
# This script generates an MSI file for Yggdrasil for a given architecture. It
# This script generates an MSI file for Mesh for a given architecture. It
# needs to run on Windows within MSYS2 and Go 1.13 or later must be installed on
# the system and within the PATH. This is ran currently by Appveyor (see
# appveyor.yml in the repository root) for both x86 and x64.
@ -47,20 +47,20 @@ then
)
fi
# Build Yggdrasil!
[ "${PKGARCH}" == "x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./build
[ "${PKGARCH}" == "x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=0 ./build
# Build Mesh!
[ "${PKGARCH}" == "x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ LDFLAGS="-H windowsgui" ./build
[ "${PKGARCH}" == "x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ LDFLAGS="-H windowsgui" ./build
[ "${PKGARCH}" == "arm" ] && GOOS=windows GOARCH=arm CGO_ENABLED=0 ./build
#[ "${PKGARCH}" == "arm64" ] && GOOS=windows GOARCH=arm64 CGO_ENABLED=0 ./build
# Create the postinstall script
cat > updateconfig.bat << EOF
if not exist %ALLUSERSPROFILE%\\Yggdrasil (
mkdir %ALLUSERSPROFILE%\\Yggdrasil
if not exist %ALLUSERSPROFILE%\\RiV-mesh (
mkdir %ALLUSERSPROFILE%\\RiV-mesh
)
if not exist %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf (
if exist yggdrasil.exe (
yggdrasil.exe -genconf > %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf
if not exist %ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf (
if exist mesh.exe (
mesh.exe -genconf > %ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf
)
)
EOF
@ -69,6 +69,9 @@ EOF
PKGNAME=$(sh contrib/semver/name.sh)
PKGVERSION=$(sh contrib/msi/msversion.sh --bare)
PKGVERSIONMS=$(echo $PKGVERSION | tr - .)
PKGINDEXFILE=contrib/ui/mesh-ui/index.html
PKGLICENSEFILE=LICENSE.rtf
[ "${PKGARCH}" == "x64" ] && \
PKGGUID="77757838-1a23-40a5-a720-c3b43e0260cc" PKGINSTFOLDER="ProgramFiles64Folder" || \
PKGGUID="54a3294e-a441-4322-aefb-3bb40dd022bb" PKGINSTFOLDER="ProgramFilesFolder"
@ -81,8 +84,12 @@ then
fi
if [ $PKGARCH = "x64" ]; then
PKGWINTUNDLL=wintun/bin/amd64/wintun.dll
PKGWEBVIEWFILE=contrib/ui/mesh-ui/dll/x64/webview.dll
PKGWEBVIEWFILELOADER=contrib/ui/mesh-ui/dll/x64/WebView2Loader.dll
elif [ $PKGARCH = "x86" ]; then
PKGWINTUNDLL=wintun/bin/x86/wintun.dll
PKGWEBVIEWFILE=contrib/ui/mesh-ui/dll/x86/webview.dll
PKGWEBVIEWFILELOADER=contrib/ui/mesh-ui/dll/x86/WebView2Loader.dll
elif [ $PKGARCH = "arm" ]; then
PKGWINTUNDLL=wintun/bin/arm/wintun.dll
#elif [ $PKGARCH = "arm64" ]; then
@ -93,9 +100,9 @@ else
fi
if [ $PKGNAME != "master" ]; then
PKGDISPLAYNAME="Yggdrasil Network (${PKGNAME} branch)"
PKGDISPLAYNAME="RiV-mesh Network (${PKGNAME} branch)"
else
PKGDISPLAYNAME="Yggdrasil Network"
PKGDISPLAYNAME="RiV-mesh Network"
fi
# Generate the wix.xml file
@ -109,14 +116,14 @@ cat > wix.xml << EOF
Language="1033"
Codepage="1252"
Version="${PKGVERSIONMS}"
Manufacturer="github.com/yggdrasil-network">
Manufacturer="github.com/RiV-chain">
<Package
Id="*"
Keywords="Installer"
Description="Yggdrasil Network Installer"
Comments="Yggdrasil Network standalone router for Windows."
Manufacturer="github.com/yggdrasil-network"
Description="RiV-mesh Network Installer"
Comments="RiV-mesh Network standalone router for Windows."
Manufacturer="github.com/RiV-chain"
InstallerVersion="200"
InstallScope="perMachine"
Languages="1033"
@ -134,14 +141,13 @@ cat > wix.xml << EOF
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="${PKGINSTFOLDER}" Name="PFiles">
<Directory Id="YggdrasilInstallFolder" Name="Yggdrasil">
<Directory Id="MeshInstallFolder" Name="RiV-mesh">
<Component Id="MainExecutable" Guid="c2119231-2aa3-4962-867a-9759c87beb24">
<File
Id="Yggdrasil"
Name="yggdrasil.exe"
Id="Mesh"
Name="mesh.exe"
DiskId="1"
Source="yggdrasil.exe"
Source="mesh.exe"
KeyPath="yes" />
<File
@ -151,21 +157,21 @@ cat > wix.xml << EOF
Source="${PKGWINTUNDLL}" />
<ServiceInstall
Id="ServiceInstaller"
Id="MeshServiceInstaller"
Account="LocalSystem"
Description="Yggdrasil Network router process"
DisplayName="Yggdrasil Service"
Description="RiV-mesh Network router process"
DisplayName="RiV-mesh Service"
ErrorControl="normal"
LoadOrderGroup="NetworkProvider"
Name="Yggdrasil"
Name="Mesh"
Start="auto"
Type="ownProcess"
Arguments='-useconffile "%ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf" -logto "%ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.log"'
Arguments='-useconffile "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.conf" -logto "%ALLUSERSPROFILE%\\RiV-mesh\\mesh.log"'
Vital="yes" />
<ServiceControl
Id="ServiceControl"
Name="yggdrasil"
Id="MeshServiceControl"
Name="Mesh"
Start="install"
Stop="both"
Remove="uninstall" />
@ -173,13 +179,42 @@ cat > wix.xml << EOF
<Component Id="CtrlExecutable" Guid="a916b730-974d-42a1-b687-d9d504cbb86a">
<File
Id="Yggdrasilctl"
Name="yggdrasilctl.exe"
Id="Meshctl"
Name="meshctl.exe"
DiskId="1"
Source="yggdrasilctl.exe"
Source="meshctl.exe"
KeyPath="yes"/>
</Component>
<Component Id="UIExecutable" Guid="ef9f30e0-8274-4526-835b-51bc09b5b1b7">
<File
Id="MeshUI"
Name="mesh-ui.exe"
DiskId="1"
Source="mesh-ui.exe"
KeyPath="yes" />
<File
Id="WebViewHtmlFile"
Name="index.html"
DiskId="1"
Source="${PKGINDEXFILE}" />
<File
Id="WebViewDllFile"
Name="webview.dll"
DiskId="1"
Source="${PKGWEBVIEWFILE}" />
<File
Id="WebViewLoaderFile"
Name="WebView2Loader.dll"
DiskId="1"
Source="${PKGWEBVIEWFILELOADER}" />
</Component>
<Component Id="ConfigScript" Guid="64a3733b-c98a-4732-85f3-20cd7da1a785">
<File
Id="Configbat"
@ -192,20 +227,39 @@ cat > wix.xml << EOF
</Directory>
</Directory>
<Feature Id="YggdrasilFeature" Title="Yggdrasil" Level="1">
<Feature Id="MeshFeature" Title="Mesh" Level="1">
<ComponentRef Id="MainExecutable" />
<ComponentRef Id="UIExecutable" />
<ComponentRef Id="CtrlExecutable" />
<ComponentRef Id="ConfigScript" />
</Feature>
<CustomAction
Id="UpdateGenerateConfig"
Directory="YggdrasilInstallFolder"
Directory="MeshInstallFolder"
ExeCommand="cmd.exe /c updateconfig.bat"
Execute="deferred"
Return="check"
Impersonate="yes" />
<!-- Step 2: Add UI to your installer / Step 4: Trigger the custom action -->
<UI>
<UIRef Id="WixUI_Minimal" />
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<WixVariable Id="WixUILicenseRtf" Value="LICENSE.rtf" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch RiV-mesh" />
<!-- Step 3: Include the custom action -->
<Property Id="WixShellExecTarget" Value="[#MeshUI]" />
<CustomAction Id="LaunchApplication"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
<InstallExecuteSequence>
<Custom
Action="UpdateGenerateConfig"
@ -222,4 +276,4 @@ EOF
CANDLEFLAGS="-nologo"
LIGHTFLAGS="-nologo -spdb -sice:ICE71 -sice:ICE61"
wixbin/candle $CANDLEFLAGS -out ${PKGNAME}-${PKGVERSION}-${PKGARCH}.wixobj -arch ${PKGARCH} wix.xml && \
wixbin/light $LIGHTFLAGS -ext WixUtilExtension.dll -out ${PKGNAME}-${PKGVERSION}-${PKGARCH}.msi ${PKGNAME}-${PKGVERSION}-${PKGARCH}.wixobj
wixbin/light $LIGHTFLAGS -ext WixUIExtension -ext WixUtilExtension -out ${PKGNAME}-${PKGVERSION}-${PKGARCH}.msi ${PKGNAME}-${PKGVERSION}-${PKGARCH}.wixobj

View file

@ -2,10 +2,10 @@
description="An experiment in scalable routing as an encrypted IPv6 overlay network."
CONFFILE="/etc/yggdrasil.conf"
CONFFILE="/etc/mesh.conf"
pidfile="/run/${RC_SVCNAME}.pid"
command="/usr/bin/yggdrasil"
command="/usr/bin/mesh"
extra_started_commands="reload"
depend() {
@ -36,8 +36,8 @@ start() {
--pidfile "${pidfile}" \
--make-pidfile \
--background \
--stdout /var/log/yggdrasil.stdout.log \
--stderr /var/log/yggdrasil.stderr.log \
--stdout /var/log/mesh.stdout.log \
--stderr /var/log/mesh.stderr.log \
--exec "${command}" -- -useconffile "${CONFFILE}"
eend $?
}

View file

@ -5,7 +5,7 @@ BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null)
# Complain if the git history is not available
if [ $? != 0 ] || [ -z "$BRANCH" ]; then
printf "yggdrasil"
printf "mesh"
exit 0
fi
@ -14,9 +14,9 @@ BRANCH=$(echo $BRANCH | tr -d "/")
# Check if the branch name is not master
if [ "$BRANCH" = "master" ]; then
printf "yggdrasil"
printf "mesh"
exit 0
fi
# If it is something other than master, append it
printf "yggdrasil-%s" "$BRANCH"
printf "mesh-%s" "$BRANCH"

View file

@ -0,0 +1,13 @@
[Unit]
Description=mesh default config generator
ConditionPathExists=|!/etc/mesh.conf
ConditionFileNotEmpty=|!/etc/mesh.conf
Wants=local-fs.target
After=local-fs.target
[Service]
Type=oneshot
Group=mesh
StandardOutput=file:/etc/mesh.conf
ExecStart=/usr/bin/mesh -genconf
ExecStartPost=/usr/bin/chmod 0640 /etc/mesh.conf

View file

@ -1,18 +1,18 @@
[Unit]
Description=yggdrasil
Description=mesh
Wants=network.target
Wants=yggdrasil-default-config.service
Wants=mesh-default-config.service
After=network.target
After=yggdrasil-default-config.service
After=mesh-default-config.service
[Service]
Group=yggdrasil
Group=mesh
ProtectHome=true
ProtectSystem=true
SyslogIdentifier=yggdrasil
SyslogIdentifier=mesh
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE
ExecStartPre=+-/sbin/modprobe tun
ExecStart=/usr/bin/yggdrasil -useconffile /etc/yggdrasil.conf
ExecStart=/usr/bin/mesh -useconffile /etc/mesh.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
TimeoutStopSec=5

View file

@ -1,13 +0,0 @@
[Unit]
Description=yggdrasil default config generator
ConditionPathExists=|!/etc/yggdrasil.conf
ConditionFileNotEmpty=|!/etc/yggdrasil.conf
Wants=local-fs.target
After=local-fs.target
[Service]
Type=oneshot
Group=yggdrasil
StandardOutput=file:/etc/yggdrasil.conf
ExecStart=/usr/bin/yggdrasil -genconf
ExecStartPost=/usr/bin/chmod 0640 /etc/yggdrasil.conf

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

217
contrib/ui/mesh-ui/index.html Executable file
View file

@ -0,0 +1,217 @@
<!DOCTYPE html>
<html class="is-clipped">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Yggdrasil</title>
<link rel="stylesheet" href="https://maxst.icons8.com/vue-static/landings/line-awesome/font-awesome-line-awesome/css/all.min.css" type="text/css">
<link rel="stylesheet" href="https://unpkg.com/bulmaswatch/slate/bulmaswatch.min.css" type="text/css">
<script>
function setFieldValue(id, value){
var field = document.getElementById(id);
field.innerHTML = value;
}
function openTab(element, tabName) {
// Declare all variables
var i, tabContent, tabLinks;
// Get all elements with class="content" and hide them
tabContent = document.getElementsByClassName("tab here");
for (i = 0; i < tabContent.length; i++) {
tabContent[i].className = "tab here is-hidden";
}
// Get all elements with class="tab" and remove the class "is-active"
tabLinks = document.getElementsByClassName("tab is-active");
for (i = 0; i < tabLinks.length; i++) {
tabLinks[i].className = "tab";
}
// Show the current tab, and add an "is-active" class to the button that opened the tab
document.getElementById(tabName).className = "tab here";
element.parentElement.className = "tab is-active";
refreshRecordsList();
}
function copy2clipboard(text){
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
// Ensure it has a small width and height. Setting to 1px / 1em
// doesn't work as this gives a negative w/h on some browsers.
textArea.style.width = '2em';
textArea.style.height = '2em';
// We don't need padding, reducing the size if it does flash render.
textArea.style.padding = 0;
// Clean up any borders.
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
// Avoid flash of the white box if rendered for any reason.
textArea.style.background = 'transparent';
textArea.value = text;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
document.body.removeChild(textArea);
showInfo('value copied successfully!');
}
function showInfo(text) {
var info = document.getElementById("notification_info");
var message = document.getElementById("info_text");
message.innerHTML = text;
info.className = "notification is-primary";
var button = document.getElementById("info_close");
button.onclick = function() {
message.value = "";
info.className = "notification is-primary is-hidden";
};
setTimeout(button.onclick, 2000);
}
</script>
<style>
.container-ip {
display: flex;
border: 1px solid #5d656d;
border-radius: 4px;
margin:10px;
}
.push-right {
margin-left: auto;
}
.item {
padding: 10px;
/*border: 1px solid #5d656d;*/
}
.column {
max-height: 350px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.over {
max-height: 150px;
overflow: auto;
}
</style>
</head>
<body onload="onLoad();">
<div style="padding:3px; max-height: 250px;">
<!-- Tabs -->
<div class="tabs is-centered is-boxed">
<ul>
<li class="tab is-active">
<a onclick="openTab(this, 'my_node');">
<span class="icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1em" height="1em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 42 42"><path d="M18.5 35.5l-8 2c-.48.04-1 .52-1 1v1c0 .5.47 1 1 1h20c.43 0 1-.41 1-1v-1c-.02-.52-.55-.98-1-1l-8-2h-4zm19-1c2.59 0 3-.529 3-3v-26c0-2.391-.55-3-3-3h-34c-2.43 0-3 .54-3 3v26c0 2.51.529 3 3 3h34zm-2-27v22h-30v-22h30z" fill="white"/></svg>
</span>
<span>My Node</span>
</a>
</li>
<li class="tab">
<a onclick="openTab(this, 'keys');">
<span class="icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1em" height="1em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><g fill="none" stroke="white" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M5 15v15h22V15zm4 0C9 9 9 5 16 5s7 4 7 10m-7 5v3"/><circle cx="16" cy="24" r="1"/></g></svg>
</span>
<span>Keys</span>
</a>
</li>
<li class="tab">
<a onclick="openTab(this, 'about');">
<span class="icon">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="1em" height="1em" style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 48 48"><path fill="#2196F3" d="M37 40H11l-6 6V12c0-3.3 2.7-6 6-6h26c3.3 0 6 2.7 6 6v22c0 3.3-2.7 6-6 6z"/><g fill="#fff"><path d="M22 20h4v11h-4z"/><circle cx="24" cy="15" r="2"/></g></svg>
</span>
<span>About</span>
</a>
</li>
</ul>
</div>
<div class="tab here " id="my_node">
<div class="column">
<div class="container-ip">
<div class="item">IPv6</div>
<div id="ipv6" class="item push-right">N/A</div>
<div class="item">
<a class="fas fa-copy" onclick="copy2clipboard(document.getElementById('ipv6').innerHTML);"/></a>
</div>
</div>
<div class="container-ip">
<div class="item">Subnet</div>
<div id="subnet" class="item push-right">N/A</div>
<div class="item">
<a class="fas fa-copy" onclick="copy2clipboard(document.getElementById('subnet').innerHTML);"></a>
</div>
</div>
<div class="container-ip">
<div class="item">Peers</div>
<div id="peers" class="item over">
</div>
<div class="item push-right">
<a class="fas fa-edit"></a>
</div>
</div>
</div>
</div>
<div class="tab here is-hidden" id="keys">
</div>
</div>
</div>
<div style="margin-left: 100px; margin-right: 100px;">
<div class="notification is-primary is-hidden" id="notification_info">
<button class="delete" id="info_close"></button>
<p id="info_text"></p>
</div>
</div>
<!--div style="width: 100%; padding: 20px; box-sizing: border-box;">
<div class="buttons">
<a class="button">Save</a>
</div>
</div-->
</body>
</html>

121
contrib/ui/mesh-ui/webview.go Executable file
View file

@ -0,0 +1,121 @@
package main
import (
"github.com/webview/webview"
"path/filepath"
"io/ioutil"
"net/url"
"runtime"
"strings"
"os/exec"
"log"
"os"
"fmt"
)
func main() {
debug := true
w := webview.New(debug)
defer w.Destroy()
w.SetTitle("RiV-mesh")
w.SetSize(465, 410, webview.HintNone)
path, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
log.Println(path)
w.Bind("onLoad", func() {
log.Println("page loaded")
go run(w)
})
dat, err := ioutil.ReadFile(path+"/index.html")
w.Navigate("data:text/html,"+url.QueryEscape(string(dat)))
w.Run()
}
func run(w webview.WebView){
if runtime.GOOS == "windows" {
program_path := "programfiles"
path, exists := os.LookupEnv(program_path)
if exists {
fmt.Println("Program path: %s", path)
riv_ctrl_path := fmt.Sprintf("%s\\RiV-mesh\\meshctl.exe", path)
get_self(w, riv_ctrl_path)
get_peers(w, riv_ctrl_path)
} else {
fmt.Println("could not find Program Files path")
}
} else {
riv_ctrl_path := fmt.Sprintf("meshctl")
get_self(w, riv_ctrl_path)
get_peers(w, riv_ctrl_path)
}
}
func run_command(riv_ctrl_path string, command string) []string{
cmd := exec.Command(riv_ctrl_path, command)
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err)
return nil
}
lines := strings.Split(string(out), "\n")
return lines
}
func get_self(w webview.WebView, riv_ctrl_path string){
lines := run_command(riv_ctrl_path, "getSelf")
m := make(map[string]string)
for _, s := range lines {
p := strings.SplitN(s, ":", 2)
if len(p)>1 {
m[p[0]]=strings.TrimSpace(p[1])
}
}
if val, ok := m["IPv6 address"]; ok {
//found ipv6
fmt.Printf("IPv6: %s\n", val)
go setFieldValue(w, "ipv6", val)
}
if val, ok := m["IPv6 subnet"]; ok {
//found subnet
fmt.Printf("Subnet: %s\n", val)
go setFieldValue(w, "subnet", val)
}
}
func get_peers(w webview.WebView, riv_ctrl_path string){
lines := run_command(riv_ctrl_path, "getPeers")
lines = lines[1:] /*remove first element which is a header*/
var m []string
r:=""
for _, s := range lines {
p := strings.SplitN(s, " ", -1)
if len(p)>1 {
for _, t := range p {
if len(strings.TrimSpace(t))>0 {
r=strings.TrimSpace(t)
}
}
index_p := strings.Index(r, "%")
index_b := strings.Index(r, "]")
if index_p>0 && index_b>0 {
r = r[:index_p]+r[index_b:]
}
m=append(m, r)
}
}
for k := range m { // Loop
fmt.Println(k)
}
inner_html := strings.Join(m[:], "<br>")
go setFieldValue(w, "peers", inner_html)
}
func setFieldValue(p webview.WebView, id string, value string) {
p.Dispatch(func() {
p.Eval("setFieldValue('"+id+"','"+value+"');")
})
}

View file

@ -1,12 +0,0 @@
.PHONY: all
all: util yggdrasil-brute-multi-curve25519 yggdrasil-brute-multi-ed25519
util: util.c
gcc -Wall -std=c89 -O3 -c -o util.o util.c
yggdrasil-brute-multi-ed25519: yggdrasil-brute-multi-ed25519.c util.o
gcc -Wall -std=c89 -O3 -o yggdrasil-brute-multi-ed25519 -lsodium yggdrasil-brute-multi-ed25519.c util.o
yggdrasil-brute-multi-curve25519: yggdrasil-brute-multi-curve25519.c util.o
gcc -Wall -std=c89 -O3 -o yggdrasil-brute-multi-curve25519 -lsodium yggdrasil-brute-multi-curve25519.c util.o