kwent / syno

Simple Node.js wrapper and CLI for Synology DSM REST API 5.x and 6.x.
http://kwent.github.io/syno
MIT License
316 stars 51 forks source link

Different behaviour between Ubuntu and Raspbian #50

Closed Tom-Hirschberger closed 4 years ago

Tom-Hirschberger commented 4 years ago

Hi, i am currently working on a project to create an smart mirror based on https://github.com/MichMich/MagicMirror. I want to develop an module which displays the live streams of my cams configured in the Surveillance Station. The plan is to use your lib to access the DSM but i do not get it work. To make sure the electron browser is not the problem i installed the lib with command line tool and tried the basic command of the readme. The curious thing is that the command "syno -u http://USER:PASS@IP:5000 dsm getInfo" works perfectly on my Ubuntu but not on the Raspbian system.

Raspbian:

[ERROR] : Error: No such account or incorrect password
    at Request._callback (/usr/local/lib/node_modules/syno/dist/syno.js:79:33)
    at Request.self.callback (/usr/local/lib/node_modules/syno/node_modules/request/request.js:185:22)
    at Request.emit (events.js:310:20)
    at Request.<anonymous> (/usr/local/lib/node_modules/syno/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:310:20)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/syno/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:416:28)
    at IncomingMessage.emit (events.js:322:22)
    at endReadableNT (_stream_readable.js:1187:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 400
}

Ubuntu:

{"codepage":"ger","model":"DS216","ram":512,"serial":"XXX","temperature":40,"temperature_warn":false,"time":"Tue Apr 14 11:42:14 2020","uptime":13181841,"version":"24922","version_string":"DSM 6.2.2-24922 Update 4"}

Both systems use Node version: v12.16.2

Tom-Hirschberger commented 4 years ago

I added an dummy account and used the debug flag to provide some more information: Ubuntu:

syno -d -u http://dummy:dummy123@synology:5000 fs getInfo
[DEBUG] : Params URL detected : http://dummy:dummy123@synology:5000.
[DEBUG] : DSM Connection URL configured : http://dummy:dummy123@synology:5000
[DEBUG] : Account: dummy
[DEBUG] : Password: dummy123
[DEBUG] : Host: synology
[DEBUG] : Port: 5000
[DEBUG] : API: 6.2.2
[DEBUG] : Ignore certificate errors: false
[DEBUG] : DSM File Station API command selected
[DEBUG] : Method name configured : getInfo
REQUEST {
  rejectUnauthorized: true,
  json: true,
  url: 'http://synology:5000/webapi/auth.cgi',
  qs: {
    api: 'SYNO.API.Auth',
    version: 3,
    method: 'login',
    account: 'dummy',
    passwd: 'dummy123',
    session: 'FileStation',
    format: 'sid'
  },
  callback: [Function]
}
REQUEST make request http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid
REQUEST onRequestResponse http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid 200 {
  server: 'nginx',
  date: 'Tue, 14 Apr 2020 10:13:17 GMT',
  'content-type': 'text/plain; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
  'set-cookie': [
    'id=DLXa9pF0vSVQE15B0NON812300;expires=Tue, 21-Apr-2020 10:13:17 GMT;path=/',
    'smid=HH7y6gEKeBpX3JwJCUh5j5e8QJVvdRqXsgq6FWMRqyIdx0hozDjzL_Pg26LxweL7c7uYSUufgbcItNYVCx-IXQ;expires=Wed, 14-Apr-2021 10:13:17 GMT;path=/;HttpOnly'
  ]
}
REQUEST reading response's body
REQUEST finish init function http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid
REQUEST response end http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid 200 {
  server: 'nginx',
  date: 'Tue, 14 Apr 2020 10:13:17 GMT',
  'content-type': 'text/plain; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
  'set-cookie': [
    'id=DLXa9pF0vSVQE15B0NON812300;expires=Tue, 21-Apr-2020 10:13:17 GMT;path=/',
    'smid=HH7y6gEKeBpX3JwJCUh5j5e8QJVvdRqXsgq6FWMRqyIdx0hozDjzL_Pg26LxweL7c7uYSUufgbcItNYVCx-IXQ;expires=Wed, 14-Apr-2021 10:13:17 GMT;path=/;HttpOnly'
  ]
}
REQUEST end event http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid
REQUEST has body http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid 61
REQUEST emitting complete http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid
REQUEST {
  rejectUnauthorized: true,
  json: true,
  url: 'http://synology:5000/webapi/entry.cgi',
  qs: {
    api: 'SYNO.FileStation.Info',
    version: '2',
    method: 'get',
    _sid: 'DLXa9pF0vSVQE15B0NON812300'
  },
  callback: [Function]
}
REQUEST make request http://synology:5000/webapi/entry.cgi?api=SYNO.FileStation.Info&version=2&method=get&_sid=DLXa9pF0vSVQE15B0NON812300
REQUEST onRequestResponse http://synology:5000/webapi/entry.cgi?api=SYNO.FileStation.Info&version=2&method=get&_sid=DLXa9pF0vSVQE15B0NON812300 200 {
  server: 'nginx',
  date: 'Tue, 14 Apr 2020 10:13:18 GMT',
  'content-type': 'application/json; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
  pragma: 'no-cache',
  expires: '0'
}
REQUEST reading response's body
REQUEST finish init function http://synology:5000/webapi/entry.cgi?api=SYNO.FileStation.Info&version=2&method=get&_sid=DLXa9pF0vSVQE15B0NON812300
REQUEST response end http://synology:5000/webapi/entry.cgi?api=SYNO.FileStation.Info&version=2&method=get&_sid=DLXa9pF0vSVQE15B0NON812300 200 {
  server: 'nginx',
  date: 'Tue, 14 Apr 2020 10:13:18 GMT',
  'content-type': 'application/json; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
  pragma: 'no-cache',
  expires: '0'
}
REQUEST end event http://synology:5000/webapi/entry.cgi?api=SYNO.FileStation.Info&version=2&method=get&_sid=DLXa9pF0vSVQE15B0NON812300
REQUEST has body http://synology:5000/webapi/entry.cgi?api=SYNO.FileStation.Info&version=2&method=get&_sid=DLXa9pF0vSVQE15B0NON812300 348
REQUEST emitting complete http://synology:5000/webapi/entry.cgi?api=SYNO.FileStation.Info&version=2&method=get&_sid=DLXa9pF0vSVQE15B0NON812300
{"enable_list_usergrp":false,"hostname":"DS216","is_manager":true,"items":[{"gid":100},{"gid":101}],"support_file_request":true,"support_sharing":true,"support_vfs":true,"support_virtual":{"enable_iso_mount":true,"enable_remote_mount":true},"support_virtual_protocol":["cifs","nfs","iso"],"system_codepage":"ger","uid":1029}
REQUEST {
  rejectUnauthorized: true,
  json: true,
  url: 'http://synology:5000/webapi/auth.cgi',
  qs: { api: 'SYNO.API.Auth', version: 3, method: 'logout', session: null },
  callback: [Function]
}

Raspbian:

syno -d -u http://dummy:dummy123@synology:5000 fs getInfo
[DEBUG] : Params URL detected : http://dummy:dummy123@synology:5000.
[DEBUG] : DSM Connection URL configured : http://dummy:dummy123@synology:5000
[DEBUG] : Account: dummy
[DEBUG] : Password: dummy123
[DEBUG] : Host: synology
[DEBUG] : Port: 5000
[DEBUG] : API: 6.2.2
[DEBUG] : Ignore certificate errors: false
[DEBUG] : DSM File Station API command selected
[DEBUG] : Method name configured : getInfo
REQUEST {
  rejectUnauthorized: true,
  json: true,
  url: 'http://synology:5000/webapi/auth.cgi',
  qs: {
    api: 'SYNO.API.Auth',
    version: 3,
    method: 'login',
    account: 'dummy',
    passwd: 'dummy123',
    session: 'FileStation',
    format: 'sid'
  },
  callback: [Function]
}
REQUEST make request http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid
REQUEST onRequestResponse http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid 200 {
  server: 'nginx',
  date: 'Tue, 14 Apr 2020 10:15:43 GMT',
  'content-type': 'text/plain; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'
}
REQUEST reading response's body
REQUEST finish init function http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid
REQUEST response end http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid 200 {
  server: 'nginx',
  date: 'Tue, 14 Apr 2020 10:15:43 GMT',
  'content-type': 'text/plain; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'
}
REQUEST end event http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid
REQUEST has body http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid 39
REQUEST emitting complete http://synology:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=dummy&passwd=dummy123&session=FileStation&format=sid
[ERROR] : Error: No such account or incorrect password
    at Request._callback (/usr/local/lib/node_modules/syno/dist/syno.js:79:33)
    at Request.self.callback (/usr/local/lib/node_modules/syno/node_modules/request/request.js:185:22)
    at Request.emit (events.js:310:20)
    at Request.<anonymous> (/usr/local/lib/node_modules/syno/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:310:20)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/syno/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:416:28)
    at IncomingMessage.emit (events.js:322:22)
    at endReadableNT (_stream_readable.js:1187:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 400
}
REQUEST {
  rejectUnauthorized: true,
  json: true,
  url: 'http://synology:5000/webapi/auth.cgi',
  qs: { api: 'SYNO.API.Auth', version: 3, method: 'logout', session: null },
  callback: [Function]
}
Tom-Hirschberger commented 4 years ago

Sorry, it looks like the DSM still blocked the IP of my Pi although i deactivated the security feature. Pi to the Whitelist and everything works fine.