1. added multipath protocol and schema suport

2. added SCTP protocol and schema support
3. added set of NAS models support (Asustor, ReadyNAS, Drobo, QNAP, WD, Synology, Terramaster)
4. moved to fc00::/7 private segment
5. added Windows, MacOS and Linux UI for peers edit and current status
This commit is contained in:
vadym 2022-10-27 22:03:37 +03:00
parent cfa293d189
commit d8a4000141
198 changed files with 8589 additions and 697 deletions

View file

@ -0,0 +1,14 @@
location = /mesh {
return 301 /mesh/;
}
location ~ ^/mesh/ {
rewrite ^/mesh/(.*) /$1 break;
proxy_pass http://127.0.0.1:19019;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For-Addr $server_addr;
proxy_set_header X-Forwarded-For-Port $server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Original-URI $request_uri;
}

View file

@ -0,0 +1,5 @@
[mesh]
title="HTTP"
desc="RiV Mesh Web interface"
port_forward="no"
dst.ports="19019/tcp"

View file

@ -0,0 +1,11 @@
{
".url": {
"org.mesh": {
"type": "url",
"title": "RiV Mesh",
"desc": "ipv6 mesh network",
"icon": "mesh-{0}.png",
"url": "/webman/3rdparty/mesh/login.html"
}
}
}

View file

@ -0,0 +1,18 @@
<html>
<head>
<script type="text/javascript" src="/scripts/ext-3/adapter/ext/ext-base.js?v=1401997094"></script>
<script type="text/javascript" src="/scripts/ext-3/ext-all.js?v=1401997094"></script>
<script type="text/javascript" src="/webman/dsmtoken.cgi"></script>
</head>
<body>
<script>
Ext.onReady(function () {
if (Ext.isEmpty(SYNO.SDS.Session)) {
window.location.assign("/webman");
} else {
window.location.assign(Ext.urlAppend(window.location.origin + "/mesh/"));
}
});
</script>
</body>
</html>

View file

@ -0,0 +1,7 @@
#!/bin/sh
echo vendor=Synology
echo vendorOperatingSystemName=DSM
. /etc.defaults/VERSION
echo firmwareVersion="${productversion}-${buildnumber}"
echo $(cat /etc/avahi/services/dsminfo.service | grep model | sed -e 's/<[^>]*>//g;s/^ *//')
echo $(cat /etc/avahi/services/dsminfo.service | grep serial | sed -e 's/<[^>]*>//g;s/^ *//')

View file

@ -0,0 +1,22 @@
#!/bin/sh
export CONTENT_LENGTH=$HTTP_CONTENT_LENGTH
export CONTENT_TYPE=$HTTP_CONTENT_TYPE
IFS=';'
for x in $HTTP_COOKIE
do
case $x in
*EdSynoToken*)
eval $x
;;
esac
done
[ -z $QUERY_STRING ] && export QUERY_STRING=SynoToken=$EdSynoToken || export QUERY_STRING="$QUERY_STRING&SynoToken=$EdSynoToken"
[ ! -z $HTTP_X_REAL_IP ] && export REMOTE_ADDR=$HTTP_X_REAL_IP
[ ! -z $HTTP_X_FORWARDED_FOR_ADDR ] && export SERVER_ADDR=$HTTP_X_FORWARDED_FOR_ADDR
[ ! -z $HTTP_X_FORWARDED_FOR_PORT ] && export SERVER_PORT=$HTTP_X_FORWARDED_FOR_PORT
#exit with zero status on auth success and 1 on error
[ ! -z $(/usr/syno/synoman/webman/modules/authenticate.cgi) ]
exit $?

View file

@ -0,0 +1,10 @@
#!/bin/sh
log_exit(){
echo $2
exit $1
}
rm "$ED_APP_ROOT/bin/mesh
rm -rf "$ED_APP_ROOT/www"
rm -rf "$ED_APP_ROOT/ui"

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

View file

@ -0,0 +1,81 @@
var ed = {
partnerId: 1126,
brand: 'RiV Mesh',
applicationName: 'RiV Mesh Synology DSM App',
nasOSName: 'Synology DSM',
nasVisitEDWebsiteLogin: "https://github.com/RiV-chain/RiV-mesh",
nasVisitEDWebsiteSignup: "https://github.com/RiV-chain/RiV-mesh",
nasVisitEDWebsiteLoggedin: "https://github.com/RiV-chain/RiV-mesh",
getCookie: function (name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
},
setCookie: function (key, value, expires) {
if(expires) {
var d = new Date();
d.setTime(d.getTime() + (30 * 60 * 1000));
expires = "; expires=" + d.toUTCString();
} else {
expires = "";
}
document.cookie = key + "=" + value + expires + "; path=/";
},
getNasAuthUrl: function () {
ed.setCookie('EdSynoToken', "");
var url = ed.getCookie('origin');
if (url === undefined) {
url = window.location.protocol + "//" + window.location.hostname + ":" + 5000;
}
return url;
}
};
$(function () {
function params(obj) {
if (typeof obj === 'string') {
if (obj[0] === '?') {
obj = obj.substring(1);
}
var result = {};
obj = obj.split("&");
obj.forEach(function (pair) {
pair = pair.split("=");
var key = decodeURIComponent(pair[0]);
var value = decodeURIComponent(pair[1]);
// If first entry with this name
if (typeof result[key] === "undefined") {
result[key] = value;
// If second entry with this name
} else if (typeof result[key] === "string") {
result[key] = [result[key], value];
// If third or later entry with this name
} else {
result[key].push(value);
}
});
return result;
} else {
return Object.keys(obj).map(function (key) {
return encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]);
}).join('&');
}
};
//Hide URL parameters
var query = params(window.location.search.substring(1));
var refresh = false;
for (var k in query) {
if (k === 'SynoToken') {
ed.setCookie('EdSynoToken', query[k]);
refresh = true;
delete query[k];
} else if (k === 'origin') {
ed.setCookie('origin', query[k]);
refresh = true;
delete query[k];
}
}
query = $.param(query);
if (refresh)
window.location.replace(window.location.origin + window.location.pathname + window.location.hash + ((query === "") ? "" : ("?" + query)));
});

View file

@ -0,0 +1,5 @@
{
"port-config": {
"protocol-file": "mesh.sc"
}
}

View file

@ -0,0 +1,17 @@
#!/bin/bash
DEBUG=true
SH="$(readlink /proc/$$/exe)"
if $DEBUG ; then
echo "" > /tmp/mesh.log
exec 2>>/tmp/mesh.log
SH="$SH -x"
set -x
fi
BASE="/var/packages/mesh/target"
LOG_FILE="$BASE/var/log/mesh.log"
ln -sf $LOG_FILE $BASE/www/log
ln -sf $BASE/dsm.mesh.conf /etc/nginx/conf.d/dsm.mesh.conf
nginx -s reload
exit 0

View file

@ -0,0 +1,8 @@
#!/bin/sh
rm -f /var/run/mesh.pid
LOG_SYMLINK=/var/log/mesh.log
[ -L $LOG_SYMLINK ] && rm -f $LOG_SYMLINK
rm -f /etc/nginx/conf.d/dsm.mesh.conf
exit 0

View file

@ -0,0 +1,3 @@
#!/bin/sh
exit 0

View file

@ -0,0 +1,3 @@
#!/bin/sh
exit 0

View file

@ -0,0 +1,3 @@
#!/bin/sh
exit 0

View file

@ -0,0 +1,3 @@
#!/bin/sh
exit 0

View file

@ -0,0 +1,120 @@
#!/bin/sh
BASE="/var/packages/mesh/target"
CONFIG_DIR="/var/packages/mesh/etc"
config_file="$CONFIG_DIR/mesh.conf"
LOG_FILE="$BASE/var/log/mesh.log"
export LD_LIBRARY_PATH="$BASE/lib"
cd /
set_proxy()
{
if [ -f /etc/proxy.conf ]; then
. /etc/proxy.conf
if [ "$proxy_enabled" = "yes" ]; then
export http_proxy="$https_host":"$https_port"
fi
fi
}
start_service ()
{
set_proxy
if [ -f $config_file ]; then
mkdir -p /var/backups
echo "Backing up configuration file to /var/backups/mesh.conf.`date +%Y%m%d`"
cp $config_file /var/backups/mesh.conf.`date +%Y%m%d`
echo "Normalising and updating /etc/mesh.conf"
${BASE}/bin/mesh -useconf -normaliseconf < /var/backups/mesh.conf.`date +%Y%m%d` > $config_file
else
echo "Generating initial configuration file $config_file"
echo "Please familiarise yourself with this file before starting RiV-mesh"
sh -c "umask 0027 && ${BASE}/bin/mesh -genconf > '$config_file'"
fi
# Create the necessary file structure for /dev/net/tun
if ( [ ! -c /dev/net/tun ] ); then
if ( [ ! -d /dev/net ] ); then
mkdir -m 755 /dev/net
fi
mknod /dev/net/tun c 10 200
chmod 0755 /dev/net/tun
fi
# Load the tun module if not already loaded
if ( !(lsmod | grep -q "^tun\s") ); then
insmod /lib/modules/tun.ko
fi
#workaround for bin error:
#Not multicasting on eth0 due to error: listen tcp [xxxx]:0: bind: cannot assign requested address
sysctl net.ipv6.ip_nonlocal_bind=1
# Launch the mesh in the background.
${BASE}/bin/mesh -useconffile "$config_file" \
-httpaddress "http://localhost:19019" \
-wwwroot "$BASE/www" \
-logto "$BASE/var/log/mesh.log" &
return $?
}
stop_service ()
{
pid=`pidof -s mesh`
if [ -z "$pid" ]; then
echo "mesh was not running"
exit 0
fi
kill "$pid"
}
status_service ()
{
pid=`pidof -s mesh`
if [[ ! -z "${pid}" ]] && [ -d /proc/${pid} ]; then
return 0
fi
if [[ ! -z "${pid}" ]]; then
return 1
fi
return 3
}
case $1 in
start)
start_service
echo "Running RiV Mesh"
exit 0
;;
stop)
stop_service
echo "Stopped RiV Mesh"
exit 0
;;
status)
status_service
sts=$?
if [ $sts -eq 0 ]; then
echo "RiV Mesh is running"
else
echo "RiV Mesh is not running"
fi
exit $sts
;;
log)
if [ -f $LOG_FILE ];
then
echo $LOG_FILE
fi
exit 0
;;
*)
exit 1
;;
esac