syn

SynologySwift

Swift library for Synology DiskStation and use DSM APIs (login with encryption)

Showing:

Popularity

Downloads/wk

0

GitHub Stars

54

Maintenance

Last Commit

5mos ago

Contributors

5

Package

Dependencies

0

License

MIT

Categories

Readme

Platform

CocoaPods compatible Carthage compatible Swift Package Manager compatible

Twitter

SynologySwift

Swift library for Synology DiskStation and use DSM 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.
  • Support otp code login
  • 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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100