diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ec3692e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "axlicense.h": "c" + } +} \ No newline at end of file diff --git a/aarch64/app/Makefile b/aarch64/app/Makefile index 13dca69..cdb0dc1 100644 --- a/aarch64/app/Makefile +++ b/aarch64/app/Makefile @@ -1,5 +1,6 @@ #//Version=Native AXIS_USABLE_LIBS = UCLIBC GLIBC +include libs/*/makefile.info PROG = tailscale_vpn diff --git a/aarch64/app/Tailscale_VPN b/aarch64/app/Tailscale_VPN index d075003..7b5649a 100755 Binary files a/aarch64/app/Tailscale_VPN and b/aarch64/app/Tailscale_VPN differ diff --git a/aarch64/app/Tailscale_VPN_1_63_0_LICENSE.txt b/aarch64/app/Tailscale_VPN_1_63_0_LICENSE.txt new file mode 100644 index 0000000..9241b06 --- /dev/null +++ b/aarch64/app/Tailscale_VPN_1_63_0_LICENSE.txt @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2020 Tailscale & AUTHORS. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/aarch64/app/app.h b/aarch64/app/app.h index aa6fc52..d8390e2 100644 --- a/aarch64/app/app.h +++ b/aarch64/app/app.h @@ -1 +1,2 @@ -#define APP_NAME "tailscale_vpn" \ No newline at end of file +#define APP_NAME "tailscale_vpn" +#define APP_ID 414812 \ No newline at end of file diff --git a/aarch64/app/libs/axLicense/axLicense.c b/aarch64/app/libs/axLicense/axLicense.c new file mode 100644 index 0000000..bdd3e90 --- /dev/null +++ b/aarch64/app/libs/axLicense/axLicense.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include "../../app.h" + +gboolean axLicense_checkLicense1() +{ +//Verify license + const gchar* vmajor = NULL; + const gchar* vminor = NULL; + int version[2]; + gboolean license_ok = FALSE; + int license = 0; + + /* util-function for getting package.conf variables */ + //ax_package_get("APPID", &appid); + //ax_package_get("APPNAME", &appname); + ax_package_get("APPMAJORVERSION", &vmajor); + ax_package_get("APPMINORVERSION", &vminor); + + version[0] = atoi(vmajor); + version[1] = atoi(vminor); + + /* licensekey_verify: Return 1 on success, 0 on failure. */ + license = licensekey_verify(APP_NAME, APP_ID, version[0], version[1]); + + license_ok = (license) ? TRUE : FALSE; + + + return license_ok; +} diff --git a/aarch64/app/libs/axLicense/axLicense.h b/aarch64/app/libs/axLicense/axLicense.h new file mode 100644 index 0000000..43ae830 --- /dev/null +++ b/aarch64/app/libs/axLicense/axLicense.h @@ -0,0 +1,4 @@ +//Version=1.0 + +/*{"Name":"License Key Installed?","Show":true, "Description":"Checks if a license key has been installed and validated"}*/ +gboolean axLicense_checkLicense1(); diff --git a/aarch64/app/libs/axLicense/axLicense.md b/aarch64/app/libs/axLicense/axLicense.md new file mode 100644 index 0000000..c067cd0 --- /dev/null +++ b/aarch64/app/libs/axLicense/axLicense.md @@ -0,0 +1,70 @@ + +# axLicense +axLicense implements ACAPs licensing system but it works a little different from the original code. + +For security, `APP ID` is compiled into the ACAP rather than relying on the value in `package.conf` (you will still need to add your `APP ID` in `package.conf` for the system to accept the key upon installation) + +Remember to set your license in `package.conf` to `axis` for the licensing to work. Other values are `none` and `custom`. To get and APP ID for Axis License [create one here](https://www.axis.com/partner_pages/compatible_applications/) + +```c +/*app.h*/ +#define APP_NAME "newapp" +#define APP_ID 1 +#define APP_DEBUG 0 +``` + + +```c +#include +#include +#include +#include +#include +#include +#include +#include "app.h" +#include "./libs/axLicense/axLicense.h" +#include "./libs/axSystem/axSystem.h" + +//main function +int main() { + //Loop main (keeps the app running. without this part the app will start and stop right after) + GMainLoop *main_loop; + main_loop = g_main_loop_new(NULL, FALSE); + //LOG app name (list) + syslog(LOG_INFO, "Starting %s", APP_NAME); + + if(axLicense_checkLicense1()/*flowchartWindow44*/){ + axSystem_log1(log_info,"license ok");/*flowchartWindow45*/ + } + else{ + axSystem_log1(log_crit,"No license installed");/*flowchartWindow46*/ + } + + + //calling main loop + g_main_loop_run(main_loop); + return 0; + +} +``` + +### License Key Installed? (axLicense_checkLicense1) +Checks if a license key has been installed and validated +```c +gboolean axLicense_checkLicense1(); +``` + + +#### Usage +```c +if(axLicense_checkLicense1()){ + //license installed +} +``` + + +# Code Maintainer +Marco Parodi (mparodi@axis.com) + +Last updated 1/3/2020 \ No newline at end of file diff --git a/aarch64/app/libs/axLicense/makefile.info b/aarch64/app/libs/axLicense/makefile.info new file mode 100644 index 0000000..f15efc1 --- /dev/null +++ b/aarch64/app/libs/axLicense/makefile.info @@ -0,0 +1,3 @@ +PKGS += axpackage +SRCS += ./libs/axLicense/axLicense.c +LDLIBS += -Wl,-Bstatic,-llicensekey_stat,-Bdynamic,-llicensekey -ldl diff --git a/aarch64/app/main.c b/aarch64/app/main.c index 75e3552..2513816 100644 --- a/aarch64/app/main.c +++ b/aarch64/app/main.c @@ -6,6 +6,7 @@ #include #include #include +#include "./libs/axLicense/axLicense.h" #include "app.h" #define TAILSCALE_VPN "\ @@ -23,20 +24,26 @@ wait \n\ //****************/ /* main function */ //****************/ - int main() { /* Loop main (keeps the app running. without this part the app will start and stop right after) */ - GMainLoop *main_loop; - main_loop = g_main_loop_new(NULL, FALSE); + GMainLoop *main_loop; + main_loop = g_main_loop_new(NULL, FALSE); -/* LOG app name (appname) */ - syslog(LOG_INFO, "Starting %s", APP_NAME); - g_message("Starting %s",APP_NAME); + //check license + if (!axLicense_checkLicense1()){ + syslog(LOG_ERR,"License key not installed. Exiting"); + g_message("License key not installed. Exiting"); + return 0; + } - system(TAILSCALE_VPN); - -/* calling main loop */ - g_main_loop_run(main_loop); + /* LOG app name (appname) */ + syslog(LOG_INFO, "Starting %s", APP_NAME); + g_message("Starting %s",APP_NAME); + //run script + system(TAILSCALE_VPN); + + /* calling main loop */ + g_main_loop_run(main_loop); //exit return 0; diff --git a/aarch64/app/manifest.json b/aarch64/app/manifest.json index 32abb95..fe525c1 100644 --- a/aarch64/app/manifest.json +++ b/aarch64/app/manifest.json @@ -3,6 +3,7 @@ "acapPackageConf": { "setup": { "appName": "tailscale_vpn", + "appId":"414812", "friendlyName": "Tailscale VPN", "vendor": "Tailscale - Packaged by Mo3he", "embeddedSdkVersion": "3.0", @@ -10,6 +11,9 @@ "runMode": "once", "version": "1.63.0" }, + "copyProtection": { + "method": "axis" + }, "configuration": { "settingPage": "index.html" } diff --git a/aarch64/app/package.conf b/aarch64/app/package.conf index 3019d90..0f0e464 100644 --- a/aarch64/app/package.conf +++ b/aarch64/app/package.conf @@ -1,9 +1,9 @@ PACKAGENAME="Tailscale VPN" APPTYPE="aarch64" APPNAME="tailscale_vpn" -APPID="" +APPID="414812" LICENSENAME="Available" -LICENSEPAGE="none" +LICENSEPAGE="axis" VENDOR="Tailscale - Packaged by Mo3he" REQEMBDEVVERSION="3.0" APPMAJORVERSION="1" diff --git a/aarch64/app/package.conf.orig b/aarch64/app/package.conf.orig index 4b174ca..818dcf5 100644 --- a/aarch64/app/package.conf.orig +++ b/aarch64/app/package.conf.orig @@ -1,4 +1,5 @@ APPNAME="tailscale_vpn" +APPID="414812" PACKAGENAME="Tailscale VPN" VENDOR="Tailscale - Packaged by Mo3he" REQEMBDEVVERSION="3.0" @@ -7,4 +8,5 @@ STARTMODE="once" APPMAJORVERSION="1" APPMINORVERSION="63" APPMICROVERSION="0" +LICENSEPAGE="axis" SETTINGSPAGEFILE="index.html" diff --git a/aarch64/app/volume.txt b/aarch64/app/volume.txt new file mode 100644 index 0000000..6285ffc --- /dev/null +++ b/aarch64/app/volume.txt @@ -0,0 +1,5 @@ +#AARCH64 +sudo docker run --rm -v /mnt/c/Users/mparodi/Documents/mySharedApps/Axis_Cam_Tailscale/aarch64/app:/opt/app/Axis_Cam_Tailscale -it axisecp/acap-native-sdk:1.14-aarch64 + +#ARMV7HF +sudo docker run --rm -v /mnt/c/Users/mparodi/Documents/mySharedApps/Axis_Cam_Tailscale/arm/app:/opt/app/Axis_Cam_Tailscale -it axisecp/acap-native-sdk:1.14-armv7hf \ No newline at end of file diff --git a/arm/app/Makefile b/arm/app/Makefile index 13dca69..cdb0dc1 100644 --- a/arm/app/Makefile +++ b/arm/app/Makefile @@ -1,5 +1,6 @@ #//Version=Native AXIS_USABLE_LIBS = UCLIBC GLIBC +include libs/*/makefile.info PROG = tailscale_vpn diff --git a/arm/app/Tailscale_VPN b/arm/app/Tailscale_VPN index a5eea3a..212edfc 100755 Binary files a/arm/app/Tailscale_VPN and b/arm/app/Tailscale_VPN differ diff --git a/arm/app/Tailscale_VPN_1_63_0_LICENSE.txt b/arm/app/Tailscale_VPN_1_63_0_LICENSE.txt new file mode 100644 index 0000000..9241b06 --- /dev/null +++ b/arm/app/Tailscale_VPN_1_63_0_LICENSE.txt @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2020 Tailscale & AUTHORS. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/arm/app/app.h b/arm/app/app.h index aa6fc52..d8390e2 100644 --- a/arm/app/app.h +++ b/arm/app/app.h @@ -1 +1,2 @@ -#define APP_NAME "tailscale_vpn" \ No newline at end of file +#define APP_NAME "tailscale_vpn" +#define APP_ID 414812 \ No newline at end of file diff --git a/arm/app/libs/axLicense/axLicense.c b/arm/app/libs/axLicense/axLicense.c new file mode 100644 index 0000000..bdd3e90 --- /dev/null +++ b/arm/app/libs/axLicense/axLicense.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include "../../app.h" + +gboolean axLicense_checkLicense1() +{ +//Verify license + const gchar* vmajor = NULL; + const gchar* vminor = NULL; + int version[2]; + gboolean license_ok = FALSE; + int license = 0; + + /* util-function for getting package.conf variables */ + //ax_package_get("APPID", &appid); + //ax_package_get("APPNAME", &appname); + ax_package_get("APPMAJORVERSION", &vmajor); + ax_package_get("APPMINORVERSION", &vminor); + + version[0] = atoi(vmajor); + version[1] = atoi(vminor); + + /* licensekey_verify: Return 1 on success, 0 on failure. */ + license = licensekey_verify(APP_NAME, APP_ID, version[0], version[1]); + + license_ok = (license) ? TRUE : FALSE; + + + return license_ok; +} diff --git a/arm/app/libs/axLicense/axLicense.h b/arm/app/libs/axLicense/axLicense.h new file mode 100644 index 0000000..43ae830 --- /dev/null +++ b/arm/app/libs/axLicense/axLicense.h @@ -0,0 +1,4 @@ +//Version=1.0 + +/*{"Name":"License Key Installed?","Show":true, "Description":"Checks if a license key has been installed and validated"}*/ +gboolean axLicense_checkLicense1(); diff --git a/arm/app/libs/axLicense/axLicense.md b/arm/app/libs/axLicense/axLicense.md new file mode 100644 index 0000000..c067cd0 --- /dev/null +++ b/arm/app/libs/axLicense/axLicense.md @@ -0,0 +1,70 @@ + +# axLicense +axLicense implements ACAPs licensing system but it works a little different from the original code. + +For security, `APP ID` is compiled into the ACAP rather than relying on the value in `package.conf` (you will still need to add your `APP ID` in `package.conf` for the system to accept the key upon installation) + +Remember to set your license in `package.conf` to `axis` for the licensing to work. Other values are `none` and `custom`. To get and APP ID for Axis License [create one here](https://www.axis.com/partner_pages/compatible_applications/) + +```c +/*app.h*/ +#define APP_NAME "newapp" +#define APP_ID 1 +#define APP_DEBUG 0 +``` + + +```c +#include +#include +#include +#include +#include +#include +#include +#include "app.h" +#include "./libs/axLicense/axLicense.h" +#include "./libs/axSystem/axSystem.h" + +//main function +int main() { + //Loop main (keeps the app running. without this part the app will start and stop right after) + GMainLoop *main_loop; + main_loop = g_main_loop_new(NULL, FALSE); + //LOG app name (list) + syslog(LOG_INFO, "Starting %s", APP_NAME); + + if(axLicense_checkLicense1()/*flowchartWindow44*/){ + axSystem_log1(log_info,"license ok");/*flowchartWindow45*/ + } + else{ + axSystem_log1(log_crit,"No license installed");/*flowchartWindow46*/ + } + + + //calling main loop + g_main_loop_run(main_loop); + return 0; + +} +``` + +### License Key Installed? (axLicense_checkLicense1) +Checks if a license key has been installed and validated +```c +gboolean axLicense_checkLicense1(); +``` + + +#### Usage +```c +if(axLicense_checkLicense1()){ + //license installed +} +``` + + +# Code Maintainer +Marco Parodi (mparodi@axis.com) + +Last updated 1/3/2020 \ No newline at end of file diff --git a/arm/app/libs/axLicense/makefile.info b/arm/app/libs/axLicense/makefile.info new file mode 100644 index 0000000..f15efc1 --- /dev/null +++ b/arm/app/libs/axLicense/makefile.info @@ -0,0 +1,3 @@ +PKGS += axpackage +SRCS += ./libs/axLicense/axLicense.c +LDLIBS += -Wl,-Bstatic,-llicensekey_stat,-Bdynamic,-llicensekey -ldl diff --git a/arm/app/main.c b/arm/app/main.c index 75e3552..2513816 100644 --- a/arm/app/main.c +++ b/arm/app/main.c @@ -6,6 +6,7 @@ #include #include #include +#include "./libs/axLicense/axLicense.h" #include "app.h" #define TAILSCALE_VPN "\ @@ -23,20 +24,26 @@ wait \n\ //****************/ /* main function */ //****************/ - int main() { /* Loop main (keeps the app running. without this part the app will start and stop right after) */ - GMainLoop *main_loop; - main_loop = g_main_loop_new(NULL, FALSE); + GMainLoop *main_loop; + main_loop = g_main_loop_new(NULL, FALSE); -/* LOG app name (appname) */ - syslog(LOG_INFO, "Starting %s", APP_NAME); - g_message("Starting %s",APP_NAME); + //check license + if (!axLicense_checkLicense1()){ + syslog(LOG_ERR,"License key not installed. Exiting"); + g_message("License key not installed. Exiting"); + return 0; + } - system(TAILSCALE_VPN); - -/* calling main loop */ - g_main_loop_run(main_loop); + /* LOG app name (appname) */ + syslog(LOG_INFO, "Starting %s", APP_NAME); + g_message("Starting %s",APP_NAME); + //run script + system(TAILSCALE_VPN); + + /* calling main loop */ + g_main_loop_run(main_loop); //exit return 0; diff --git a/arm/app/manifest.json b/arm/app/manifest.json index 7726558..fe525c1 100644 --- a/arm/app/manifest.json +++ b/arm/app/manifest.json @@ -2,7 +2,8 @@ "schemaVersion": "1.6.0", "acapPackageConf": { "setup": { - "appName": "Tailscale_VPN", + "appName": "tailscale_vpn", + "appId":"414812", "friendlyName": "Tailscale VPN", "vendor": "Tailscale - Packaged by Mo3he", "embeddedSdkVersion": "3.0", @@ -10,6 +11,9 @@ "runMode": "once", "version": "1.63.0" }, + "copyProtection": { + "method": "axis" + }, "configuration": { "settingPage": "index.html" } diff --git a/arm/app/package.conf b/arm/app/package.conf index 3191451..efd576e 100644 --- a/arm/app/package.conf +++ b/arm/app/package.conf @@ -1,9 +1,9 @@ PACKAGENAME="Tailscale VPN" APPTYPE="armv7hf" -APPNAME="Tailscale_VPN" -APPID="" +APPNAME="tailscale_vpn" +APPID="414812" LICENSENAME="Available" -LICENSEPAGE="none" +LICENSEPAGE="axis" VENDOR="Tailscale - Packaged by Mo3he" REQEMBDEVVERSION="3.0" APPMAJORVERSION="1" diff --git a/arm/app/package.conf.orig b/arm/app/package.conf.orig index 7e083b9..818dcf5 100644 --- a/arm/app/package.conf.orig +++ b/arm/app/package.conf.orig @@ -1,4 +1,5 @@ -APPNAME="Tailscale_VPN" +APPNAME="tailscale_vpn" +APPID="414812" PACKAGENAME="Tailscale VPN" VENDOR="Tailscale - Packaged by Mo3he" REQEMBDEVVERSION="3.0" @@ -7,4 +8,5 @@ STARTMODE="once" APPMAJORVERSION="1" APPMINORVERSION="63" APPMICROVERSION="0" +LICENSEPAGE="axis" SETTINGSPAGEFILE="index.html" diff --git a/arm/app/volume.txt b/arm/app/volume.txt new file mode 100644 index 0000000..6285ffc --- /dev/null +++ b/arm/app/volume.txt @@ -0,0 +1,5 @@ +#AARCH64 +sudo docker run --rm -v /mnt/c/Users/mparodi/Documents/mySharedApps/Axis_Cam_Tailscale/aarch64/app:/opt/app/Axis_Cam_Tailscale -it axisecp/acap-native-sdk:1.14-aarch64 + +#ARMV7HF +sudo docker run --rm -v /mnt/c/Users/mparodi/Documents/mySharedApps/Axis_Cam_Tailscale/arm/app:/opt/app/Axis_Cam_Tailscale -it axisecp/acap-native-sdk:1.14-armv7hf \ No newline at end of file