Diving into Synology QuickConnect and creating a JavaScript library

7/04/2017 04:27:00 PM


Two years back I created a Chrome extension that would allow me to quickly monitor my Synology NAS CPU usage and memory since I was having strange CPU usage spikes.
But after I fixed the problem on my NAS I stopped updating the extension itself and off course things tend to change in that amount of time. Last week I decided I would dive into it again and add support for QuickConnect!

So what is QuickConnect? In simple terms it means you simply go to one static URL which is formed like "[unique_id].quickconnect.to" and it will redirect you to the IP-address of your NAS or tunnel you through the Synology servers without having to open any ports on your router. Synology uses this option in all of it's apps because it really adds to the usability and speeds up logging in. So I figured, why not add that to my extension!

Well.... that is easier said than done, there is not really any public API that you can access and certainly no documentation. But luckily there is always your browsers developer tools to see what is going on under the hood!

So I opened Chrome, went to my own QuickConnect URL (which I will not be posting here for obvious reasons ;-) ) and looked at my developer tools and found the following:


The first call that happens is to Serv.php which basically accepts a QuickConnect ID and spews back all the possible addresses it can think of where the NAS for that account is located. Below is an example of the JSON (I marked all important fields and removed my own IP's there):

 
[  
   {  
      "server":{  
         "external":{  
            "ip":"[IP5 ADDRESS]",
            "ipv6":"[IP6 ADDRESS]"
         },
         "version":"15132",
         "ipv6_tunnel":[  

         ],
         "serverID":"00550318",
         "ddns":"NULL",
         "fqdn":"NULL",
         "udp_punch_port":59854,
         "interface":[  
            {  
               "mask":"255.255.255.0",
               "name":"eth0",
               "ip":"[LOCAL IP5 ADDRESS]",
               "ipv6":[  
                  {  
                     "address":"[LOCAL IP6 ADDRESS]",
                     "scope":"global",
                     "prefix_length":64,
                     "addr_type":0
                  },
                  {  
                     "address":"[LOCAL IP6 ADDRESS]",
                     "scope":"link",
                     "prefix_length":64,
                     "addr_type":32
                  }
               ]
            }
         ],
         "gateway":"192.168.0.1",
         "tcp_punch_port":0,
         "ds_state":"CONNECTED"
      },
      "command":"get_server_info",
      "version":1,
      "service":{  
         "ext_port":[HTTPS PORT],
         "pingpong_desc":[  

         ],
         "pingpong":"DISCONNECTED",
         "port":[HTTPS PORT]
      },
      "errno":0,
      "env":{  
         "control_host":"ukc.quickconnect.to",
         "relay_region":"uk"
      }
   },
   {  
      "errno":4,
      "command":"get_server_info",
      "version":1,
      "errinfo":"GetServInfo.lua:103"
   }
]

So basically with this service you have all you need to connect to a NAS server, but as I mentioned earlier this service spews out all "POSSIBLE" locations, so it doesn't mean that they all work.

All that is left is just sending out a simple ping and see if you get a pong back! I can go more into detail on how this all works, but all my source files are available on what I have done with this:

 - A JS library: https://github.com/taurgis/js-quickconnectid
 - A NPM package: https://github.com/taurgis/npm-quickconnectid 

And the JavaScript library is used in my Chrome plugin which can be found here: https://github.com/taurgis/SynologyStatus.

I hope this post helped answer some questions you were looking for!

You Might Also Like

0 reacties