Categories
Gadgets IT

Synology DSM remote access slowness fix (SSL certificate)

It has been quite some time since I started using Synology as my NAS (thanks JeromeH for the suggestion!) – it has been great its software is one of a kind. Recently I experienced a problem – although the remote access using ssh tunneling / VPN is very safe, it is not very user friendly, especially for connecting from a non-rooted Android Synology apps.

Eventually I decided to give a go of just exposing the Synology NAS ports to the web making the connection as secure as possible in process.

  1. tried Synology QuickConnect – but dropped it pretty quickly a) awfully slow 2) everything is proxied over Synology servers, explains the slowness and cannot call it very secure neither
  2. DDNS with port forwarding of HTTPS ports and default (self signed) SSL certificate (443 for PhotoStation and 5001 for the rest of DSM) – very slow, very unstable, I read about the possible reasons why and understood that getting an SSL certificate for the DDNS would probably resolve the issue as apparently lot of time is spent just negotiating exceptions around the self-signed certificate etc.
  3. DDNS with port forwarding and SSL certificate, this setup was a wee more complex and expensive, but the result is really usable compared to 1 and 2:
    • had to get a SSL supporting DDNS provider, went with noip.com since it is well supported on DDNS supporting routers and since I was already using it with the free account that has to be confirmed every month which is a bit irritating anyway 🙂
    • bought a domain for this purpose (any domain provider will do), set it to be managed by noip.com DNS servers
    • bought a managed DNS service for my domain from noip.com, set up the subdomains including the one to be used for Synology remote access
    • set up DDNS ip address renewal to the new subdomains, check that it works
    • bought a RapidSSL from noip.com for the subdomain to be used for Synology remote access – there is a procedure to confirm the SSL certificate, easiest if you already point your MX records to a mailserver and can control forwarding of wildcard e-mails arriving as part of the process is to receive an email sent to the subdomain admin user
    • make sure to use the intended ports in DSM – 5001 for https (Control Panel -> Network -> DSM settings) and 443 for PhotoStation (default) – they can be forwarded by the router to different external ports
      • note – the PhotoStation is a special beast not really integrated well with DSM, it seems it ignores port settings pretty much so just assume it runs on port 443, use that with forwarding for most reliable connection
    • enter the hostname and external DSM https port in Control Panel -> External Access -> Advanced section of the DSM
    • import the SSL certificate associated with the hostname in Control Panel -> Security -> Certificate
Categories
IT

Set Windows 10 background slideshow script in Powershell

I have set with every installation of Windows 10 with my profile a slideshow to change picture from a folder every X minutes. However recently I noticed that this resets from time to time and goes to one picture / slideshow over only some of the pictures that Windows has decided to keep in it’s cloud cache.

Thinking it should be easy I looked around for solutions but found out it is not that trivial (doh it is after all Microsoft 🙂 ). Finally seem to have something workable in Powershell below which you can add to startup (%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup) e.g. by using a batch file that runs the poweshell script:

@rem save as a *.cmd file (add shortcut to it in startup)
@echo off
powershell .\set-slideshow.ps1
# to use this, need to create a good slideshow setup from a folder then copy the files from $dest to $source
$source = "$env:userprofile\Install\MySoft\pws\slideshow"
$dest = "$env:appdata\Microsoft\Windows\Themes"

$id = get-random
$code = @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Threading;
namespace Wallpaper {

   public class Setter$id {
      public const int SetDesktopWallpaper = 20;
      public const int UpdateIniFile = 0x01;
      public const int SendWinIniChange = 0x02;

      [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
      private static extern int SystemParametersInfo (int uAction, int uParam, string lpvPara, int fuWinIni);

      public static void SetWallpaper (string path) {
         SystemParametersInfo(SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange);
      }

      public static void SetSlideshow (string path) {
         RegistryKey keyz = Registry.CurrentUser.OpenSubKey("Control Panel\\Personalization\\Desktop Slideshow", true);
		 //enable shuffle
		 keyz.SetValue(@"LastTickHigh", 0);
 		 keyz.SetValue(@"LastTickLow", 0);
		 //set to 10 minutes shuffle slideshow
		 keyz.SetValue(@"Interval", 600000);
		 keyz.SetValue(@"Shuffle", 1);
		 keyz.Close();
		 
         keyz = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
         //"Fit" style
         keyz.SetValue(@"WallpaperStyle", "10");
         keyz.SetValue(@"TileWallpaper", "0");
		 keyz.Close();
         SystemParametersInfo(SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange);
		 //Thread.Sleep(20000);
      }
	  
   }
}
"@

Copy-item -Path "$source\*" -Destination $dest -Force
# don't know how and why but setting it to empty string makes shuffle working (nonexist.jpg attempt does not although it does set to a color background)
#[Wallpaper.Setter]::SetWallpaper("c:\nonexist.jpg")
Add-Type -TypeDefinition $code -Language CSharp
Invoke-Expression "[Wallpaper.Setter$id]::SetWallpaper('')"
Invoke-Expression "[Wallpaper.Setter$id]::SetSlideshow('$dest\TranscodedWallpaper')"
#Stop-process -name explorer
Categories
Funny General IT

My birthday song #1 – Champaign – How ‘Bout Us

http://geboortedaghit.nl/ddmmyyyy
Interesting concept, you fill in your birthdate, replace ddmmyyyy with your birtdate e.g. http://geboortedaghit.nl/01071978 for July 1st 1978.
What you get as a result is #1 song at that time in charts (not sure which).
This is what I got (never heard it before to be honest). Note the number 22 appear in second 29 🙂
Champaign – How ‘Bout Us

Categories
IT Semantics

EU Open Data Portal

Good to see something you have invested your time in come alive.
http://open-data.europa.eu/

Categories
IT

RoboForm -> 1password

I am leaving RoboForm for 1password
The RoboForm guys can blame no support for Android in offline mode 🙂
I gave them one month to fix it, so my conscience is fine

Categories
IT

Using Linux command line arguments containing spaces in a variable

Last days had some trouble with space characters used in file names and the consequences of passing parameters using those file names to Linux programs.
Consider the following example:
test1.sh:
cmdline="-DMyTest=\"1 2 3\" -some \"./Arguments.test\" -testpath=\"/my test\" \"my test\""
echo ----------------------------------------------
./test2.sh $cmdline
echo ----------------------------------------------
./test2.sh -DMyTest="1 2 3" -some "./Arguments.test" -testpath="/my test" "my test"

test2.sh:
echo Using '"$@"';
for p in "$@";
do
echo "[$p]";
done

Calling test1.sh, the result is:
----------------------------------------------
Using "$@"
[-DMyTest="1]
[2]
[3"]
[-some]
["./Arguments.test"]
[-testpath="/my]
[test"]
["my]
[test"]
----------------------------------------------
Using "$@"
[-DMyTest=1 2 3]
[-some]
[./Arguments.test]
[-testpath=/my test]
[my test]

– where the first part is an issue as it does not read my arguments as expected.
The solution was very simple, in the first call use
eval ./test2.sh $cmdline
instead. Although the solution is really simple, it was difficult to Google anything useful thus this post.
Finally found a hint in http://www.linuxjournal.com/content/bash-preserving-whitespace-using-set-and-eval

P.S. If you need to call a Linux shell command using Java – Runtime.exec() method, use an array as the input and DON’T try to wrap every argument in spaces. It works on Windows but not Linux.