Skip to content

Commit

Permalink
Configure package to use UI from macOS client
Browse files Browse the repository at this point in the history
  • Loading branch information
NAStools committed Nov 30, 2016
1 parent dff338a commit 1a24759
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 2 deletions.
2 changes: 2 additions & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
debian/readynas/config.xml apps/nastools-zerotier-one
debian/readynas/fvapp-nastools-zerotier-one.service apps/nastools-zerotier-one
debian/readynas/logo.png apps/nastools-zerotier-one
debian/readynas/https.conf apps/nastools-zerotier-one
debian/readynas/authtoken apps/nastools-zerotier-one/cgi
zerotier-one apps/nastools-zerotier-one/sbin
ext/installfiles/mac/ui/*.html apps/nastools-zerotier-one/var/ui
ext/installfiles/mac/ui/*.js apps/nastools-zerotier-one/var/ui
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From: NAStools <[email protected]>
Date: Tue, 29 Nov 2016 17:41:16 -0800
Subject: Allow automatic retrieval of authtoken from CGI

---
ext/installfiles/mac/ui/main.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ext/installfiles/mac/ui/main.js b/ext/installfiles/mac/ui/main.js
index a164712..08d716f 100644
--- a/ext/installfiles/mac/ui/main.js
+++ b/ext/installfiles/mac/ui/main.js
@@ -42,7 +42,13 @@ function getUrlParameter(parameter)

var ztAuthToken = getUrlParameter('authToken');
if ((!ztAuthToken)||(ztAuthToken.length <= 0)) {
- ztAuthToken = prompt('No authToken specified in URL. Enter token from\nauthtoken.secret to authorize.');
+ xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("GET", "/apps/nastools-zerotier-one/cgi/authtoken", false);
+ xmlhttp.send();
+ ztAuthToken = xmlhttp.responseText;
+ if ((!ztAuthToken)||(ztAuthToken.length <= 0)) {
+ ztAuthToken = prompt('No authToken specified in URL. Enter token from\nauthtoken.secret to authorize.');
+ }
}

React.render(
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0001-Update-platformDefaultHomePath-for-ReadyNAS-OS.patch
0002-Allow-automatic-retrieval-of-authtoken-from-CGI.patch
17 changes: 17 additions & 0 deletions debian/readynas/authtoken.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>

int main() {
FILE *f;
char c;

f=fopen("/apps/nastools-zerotier-one/var/authtoken.secret","rt");

printf("Content-Type: text/plain\n\n");

while ((c=fgetc(f))!=EOF)
printf("%c", c);

fclose(f);
return 0;
}
4 changes: 2 additions & 2 deletions debian/readynas/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<Name>ZeroTier One NT</Name>
<Author>NAStools</Author>
<RequireReboot>0</RequireReboot>
<LaunchURL/>
<LaunchURL>https://localhost/apps/nastools-zerotier-one/ui/</LaunchURL>
<InfoURL>https://github.com/nastools/zerotierone</InfoURL>
<DebianPackage>nastools-zerotier-one</DebianPackage>
<Description lang="en-us">ZeroTier network virtualization service (CLI only)</Description>
<Description lang="en-us">ZeroTier network virtualization service</Description>
<ServiceName>fvapp-nastools-zerotier-one.service</ServiceName>
<ConfigURL/>
</Application>
21 changes: 21 additions & 0 deletions debian/readynas/https.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<IfModule !mod_proxy.c>
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
</IfModule>
<IfModule !mod_proxy_http.c>
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
</IfModule>

ScriptAlias /apps/nastools-zerotier-one/cgi /apps/nastools-zerotier-one/cgi

<Location /apps/nastools-zerotier-one>
Include "/etc/frontview/apache/Admin_Auth.conf"
</Location>

<IfModule mod_proxy.c>
<IfModule mod_proxy_http.c>
<Location /apps/nastools-zerotier-one/ui/>
ProxyPass http://localhost:9993/
ProxyPassReverse http://localhost:9993/
</Location>
</IfModule>
</IfModule>
8 changes: 8 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
%:
dh $@

override_dh_auto_build:
make ZT_USE_MINIUPNPC=1 -j$(nproc)
gcc $$(pwd)/debian/readynas/authtoken.c -o $$(pwd)/debian/readynas/authtoken
chmod u+s $$(pwd)/debian/readynas/authtoken

override_dh_fixperms:
dh_fixperms -Xauthtoken

override_dh_auto_install:

0 comments on commit 1a24759

Please sign in to comment.