Skip to content

Commit 1d79689

Browse files
authored
Merge pull request #48 from RiV-chain/qnap_nas
QNAP NAS RIVM-90
2 parents a57d2f0 + fbfad9b commit 1d79689

File tree

11 files changed

+53
-49
lines changed

11 files changed

+53
-49
lines changed

cmd/mesh/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func run(args rivArgs, sigCh chan os.Signal) {
276276
})
277277
}
278278
if n.multicast, err = multicast.New(n.core, logger, options...); err != nil {
279-
panic(err)
279+
fmt.Println("Multicast module fail:", err)
280280
}
281281
}
282282

contrib/nas/nas-qnap.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ if [ $PKGBRANCH = "master" ]; then
2222
PKGREPLACES=mesh-develop
2323
fi
2424

25-
if [ $PKGARCH = "x86-64" ]; then GOOS=linux GOARCH=amd64 ./build
25+
if [ $PKGARCH = "x86_64" ]; then GOOS=linux GOARCH=amd64 ./build
2626
elif [ $PKGARCH = "arm-x31" ]; then GOOS=linux GOARCH=arm GOARM=7 ./build
27+
elif [ $PKGARCH = "arm-x41" ]; then GOOS=linux GOARCH=arm GOARM=7 ./build
28+
elif [ $PKGARCH = "x86" ]; then GOOS=linux GOARCH=386 ./build
29+
elif [ $PKGARCH = "arm_64" ]; then GOOS=linux GOARCH=arm64 ./build
30+
elif [ $PKGARCH = "arm-x09" ]; then GOOS=linux GOARCH=arm GOARM=5 ./build
31+
elif [ $PKGARCH = "arm-x19" ]; then GOOS=linux GOARCH=arm GOARM=5 ./build
2732
else
28-
echo "Specify PKGARCH=x86-64 or arm-x31"
33+
echo "Specify PKGARCH=x86_64, x86, arm-64, arm-x09, arm-x19, arm-x31 or arm-x41"
2934
exit 1
3035
fi
3136

@@ -61,10 +66,11 @@ QPKG_AUTHOR="Riv Chain ltd"
6166
QPKG_SUMMARY="RiV-mesh is an implementation of a fully end-to-end encrypted IPv6 network."
6267
QPKG_RC_NUM="198"
6368
QPKG_SERVICE_PROGRAM="mesh.sh"
64-
QPKG_WEBUI="/mesh"
65-
QPKG_WEB_PORT=
69+
QPKG_WEBUI="/mesh/"
6670
QPKG_LICENSE="LGPLv3"
6771
QDK_BUILD_ARCH="$PKGARCH"
72+
QPKG_DESKTOP_APP="1"
73+
QPKG_WEB_PORT=-1
6874
EOF
6975

7076
touch /tmp/$PKGFOLDER/mesh/qdk.conf

contrib/nas/nas-westerndigital-os5.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ rm -rf /tmp/$PKGFOLDER
3434
mkdir -p /tmp/$PKGFOLDER/bin/
3535
mkdir -p /tmp/$PKGFOLDER/tmp/
3636
mkdir -p /tmp/$PKGFOLDER/lib/
37+
mkdir -p /tmp/$PKGFOLDER/ui/
3738
mkdir -p /tmp/$PKGFOLDER/var/log/
3839
mkdir -p /tmp/$PKGFOLDER/var/lib/mesh
3940

@@ -45,7 +46,7 @@ cp -r -n contrib/ui/mesh-ui/ui/* /tmp/$PKGFOLDER/www/
4546

4647
for resolution in 256x256; do
4748
echo "Converting icon for: $resolution"
48-
convert -colorspace sRGB ./riv.png -resize $resolution PNG32:/tmp/$PKGFOLDER/www/mesh.png && \
49+
convert -colorspace sRGB ./riv.png -resize $resolution PNG32:/tmp/$PKGFOLDER/ui/mesh.png && \
4950
chmod 644 /tmp/$PKGFOLDER/www/mesh.png
5051
done
5152

@@ -83,10 +84,12 @@ chmod +x /tmp/$PKGFOLDER/*.sh
8384
curent_dir=$(pwd)
8485
echo "current folder=$curent_dir"
8586

86-
cd /tmp/$PKGFOLDER/ && MyCloudOS5_mksapkg -E -s -m WDMyCloudEX4100
87+
cd /tmp/$PKGFOLDER/ && MyCloudOS5_mksapkg -E -s -m WDMyCloudEX4100 && MyCloudOS5_mksapkg -E -s -m WDMyCloudMirror
8788

8889
cp /tmp/WDMyCloudEX4100_mesh_$PKGVERSION.bin* "$curent_dir"
8990

91+
cp /tmp/WDMyCloudMirror_mesh_$PKGVERSION.bin* "$curent_dir"
92+
9093
rm -rf /tmp/$PKGFOLDER
9194

9295
cd "$curent_dir"
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
RedirectMatch 301 ^/mesh$ /mesh/
2-
LoadModule proxy_http_module modules/mod_proxy_http.so
3-
4-
<Location /mesh/>
5-
ProxyPreserveHost On
6-
ProxyPass "http://127.0.0.1:19019/"
7-
ProxyPassReverse "http://127.0.0.1:19019/"
8-
</Location>
1+
RewriteRule "^/mesh/(.*)$" "http://127.0.0.1:19019/$1" [QSD,P]

contrib/ui/nas-qnap/au/var/lib/mesh/hooks/webauth

100644100755
File mode changed.

contrib/ui/nas-qnap/au/var/lib/mesh/pre_upgrade.sh

100644100755
File mode changed.

contrib/ui/nas-qnap/au/www/assets/properties.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var ed = {
1+
var $ = id => document.getElementById(id)
2+
3+
var riv = {
24
partnerId: 1222,
35
brand: 'RiV Mesh',
46
applicationName: "RiV Mesh QNAP NAS OS App",
@@ -12,9 +14,9 @@ var ed = {
1214
}
1315
};
1416

15-
$(function () {
17+
function handleToken() {
1618

17-
ed.nasLoginCall = function (nasLoginSuccess, nasLoginFailure) {
19+
riv.nasLoginCall = function (nasLoginSuccess, nasLoginFailure) {
1820
/* encode function start */
1921
var ezEncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2022

@@ -78,17 +80,19 @@ $(function () {
7880

7981
var d = new Date();
8082
d.setTime(d.getTime() + (30 * 60 * 1000));
81-
document.cookie = "qnapuser=" + encodeURIComponent($('#nasInputUser').val()) + "; expires=" + d.toUTCString() + "; path=/";
82-
document.cookie = "qnappwd=" + encodeURIComponent(ezEncode(utf16to8($('#nasInputPassword').val()))) + "; expires=" + d.toUTCString() + "; path=/";
83-
$.ajax({url: "rest/info"}).done(function (response) {
84-
window.location.reload();
85-
checkError(response);
86-
}).fail(function () {
87-
ed.nasLogoutCall();
88-
nasLoginFailure();
83+
document.cookie = "qnapuser=" + encodeURIComponent($('username').value) + "; expires=" + d.toUTCString() + "; path=/";
84+
document.cookie = "qnappwd=" + encodeURIComponent(ezEncode(utf16to8($('password').value))) + "; expires=" + d.toUTCString() + "; path=/";
85+
fetch('api/self').then(function (response) {
86+
if (response.status === 200) {
87+
window.location.reload();
88+
checkError(response);
89+
} else {
90+
riv.nasLogoutCall();
91+
nasLoginFailure();
92+
}
8993
});
9094
};
91-
ed.nasLogoutCall = function() {
95+
riv.nasLogoutCall = function() {
9296
document.cookie = "qnapuser=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
9397
document.cookie = "qnappwd=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
9498
};
@@ -98,7 +102,9 @@ $(function () {
98102
));
99103
return matches ? decodeURIComponent(matches[1]) : undefined;
100104
}
101-
ed.getNasUser = function() {
105+
riv.getNasUser = function() {
102106
return getCookie('qnapuser');
103107
};
104-
});
108+
};
109+
110+
window.onload = handleToken;

contrib/ui/nas-qnap/package/package_routines

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ QPKG_NAME="mesh"
55
CONF=/etc/config/mesh.conf
66

77
PKG_PRE_REMOVE="{
8+
grep -v 'apache-mesh.conf' /etc/app_proxy.conf > /tmp/app_proxy.conf
9+
mv -f /tmp/app_proxy.conf /etc/app_proxy.conf
10+
/usr/local/apache/bin/apache_proxy -k graceful -f /etc/apache-sys-proxy.conf
11+
/usr/local/apache/bin/apache_proxy -k graceful -f /etc/apache-sys-proxy-ssl.conf
12+
813
killall -q mesh
914
rm -rf /share/Web/$QPKG_NAME
10-
[ -L /var/log/mesh.log ] && rm -f /var/log/mesh.log
15+
[ -L $SYS_QPKG_DIR/var/log/mesh.log ] && rm -f $SYS_QPKG_DIR/var/log/mesh.log
1116
}"
1217

1318
PKG_MAIN_REMOVE="{

contrib/ui/nas-qnap/package/shared/mesh.sh

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,14 @@ start_service ()
6262

6363
#. /etc/init.d/vpn_common.sh && load_kernel_modules
6464

65-
if [ ! -f '/etc/config/apache/extra/apache-mesh.conf' ] ; then
66-
ln -sf $QPKG_DIR/apache-mesh.conf /etc/config/apache/extra/
67-
apache_reload=1
68-
fi
69-
70-
if ! grep '/etc/config/apache/extra/apache-mesh.conf' /etc/config/apache/apache.conf ; then
71-
echo 'Include /etc/config/apache/extra/apache-mesh.conf' >> /etc/config/apache/apache.conf
72-
apache_reload=1
65+
if ! grep 'apache-mesh.conf' /etc/app_proxy.conf ; then
66+
echo "Include ${QPKG_DIR}/apache-mesh.conf" >> /etc/app_proxy.conf
7367
fi
7468

75-
if [ -n "$apache_reload" ] ; then
76-
/usr/local/apache/bin/apachectl -k graceful
77-
fi
69+
70+
/usr/local/apache/bin/apache_proxy -k graceful -f /etc/apache-sys-proxy.conf
71+
/usr/local/apache/bin/apache_proxy -k graceful -f /etc/apache-sys-proxy-ssl.conf
72+
7873

7974
# Launch the mesh in the background.
8075
${QPKG_DIR}/bin/mesh -useconffile "$CONF" \
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
RedirectMatch 301 ^/mesh$ /mesh/
2-
LoadModule proxy_http_module modules/mod_proxy_http.so
3-
4-
<Location /mesh/>
5-
ProxyPreserveHost On
6-
ProxyPass "http://127.0.0.1:19019/"
7-
ProxyPassReverse "http://127.0.0.1:19019/"
8-
</Location>
2+
Alias "/mesh/mesh.png" "/var/www/mesh_app/mesh.png"
3+
RewriteCond %{REQUEST_URI} !mesh.png
4+
RewriteRule "^/mesh/(.*)$" "http://127.0.0.1:19019/$1" [P]

0 commit comments

Comments
 (0)