Latest 0.1.0
Homepage https://github.com/Thomaslegravier/SynologySwift
License MIT
Platforms ios 9.0, osx 10.10, watchos 2.0, tvos 9.0, requires ARC
Authors

Platform

CocoaPods compatible
Carthage compatible
Swift Package Manager compatible

Twitter

Swift library for accessing Synology NAS and use DiskStation APIs.

Tools :

  • Resolve NAS host/ip base on QuickConnectId
  • List available APIs
  • Login with encryption

Installation

Swift 5

With Cocoapods:

pod 'SynologySwift'

With Carthage:

github "Thomaslegravier/SynologySwift"

Usage

import SynologySwift

Resolve DS reachable interface for a specific QuickConnectId :

SynologySwift.resolveURL(quickConnectId: "your-quick-id") { (result) in
    switch result {
    case .success(let data):
        let dsPort = data.port
        let dsHost = data.host
    case .failure(let error): break
    }
}

List available APIs on your DS :

SynologySwift.resolveAvailableAPIs { (result) in
    switch result {
    case .success(let data):
        for service in data.apiList! {
            let serviceName = service.key        // Example : SYNO.API.Auth
            let servicePath = service.value.path // Example : auth.cgi
        }
    case .failure(let error): break
    }
}

Auth connection with encryption :

SynologySwift.login(quickConnectid: "your-quick-id", sessionType: "DownloadStation", login: "login", password: "password", useDefaultCacheApis: false) { (result) in
    switch result {
    case .success(let data):
        let accountName = data.account // Account name
        let sessionId = data.sid       // Sid param for futher connected calls
    case .failure(let error): break
    }
}
/* NB : Set 'useDefaultCacheApis' for faster login. If true, we use default auth and encryption APIs paths, instead fetch all available APIs on your DS. Use at your own risk. */

Get info for a specific service

let dlService = SynologySwift.serviceInfos(serviceName: "SYNO.DownloadStation.Info")
let path = dlService.path

Logout :

let dsAuthInfos = SynologySwiftAuth.DSAuthInfos(sid: "XXXXXXXXX", account: "account-name", dsInfos: SynologySwiftURLResolver.DSInfos(quickId: "your-quick-id", host: "XXXXXXX", port: 5000))
SynologySwift.logout(dsAuthInfos: dsAuthInfos, sessionType: "DownloadStation") { (result) in
    switch result {
    case .success(_):         print("Success logout")
    case .failure(let error): print(error)
    }
}
/* NB : Use auth infos from your last login session to perform logout. */

Details

Login helper:

  • Resolve automatically your DS host base on the quickConnectId
  • List available APIs on your DS
  • Fetch encryption details
  • Login with your account informations.
  • Get specific service info path
  • Logout from a specific session

Your login and password are encrypted and not stored.

Credits

  • Thanks to @Frizlab fro RSA/AES encryption part.
  • Thanks to @soyersoyer for SwCrypt implementation RSA part

Latest podspec

{
    "name": "SynologySwift",
    "version": "0.1.0",
    "summary": "Swift library for accessing Synology NAS and use DiskStation APIs",
    "description": "Swift library for accessing Synology NAS. Resolve host/iP of your NAS with a QuickConnectId and connect by APIs throught encryption service.",
    "homepage": "https://github.com/Thomaslegravier/SynologySwift",
    "license": "MIT",
    "authors": {
        "Thomas Le Gravier": "[email protected]"
    },
    "social_media_url": "https://twitter.com/lebasalte",
    "requires_arc": true,
    "swift_versions": "5.0",
    "source": {
        "git": "https://github.com/Thomaslegravier/SynologySwift.git",
        "tag": "0.1.0"
    },
    "source_files": "Sources/SynologySwift/**/*.swift",
    "platforms": {
        "ios": "9.0",
        "osx": "10.10",
        "watchos": "2.0",
        "tvos": "9.0"
    }
}

Pin It on Pinterest

Share This