Jakob Olsson e73db4e733 Revert "ws_ubusproxy: call a teardown function if client should be torn down (behavior change for lws 3.1.0)"
This reverts commit 6bc97e4f9b.
This issue was fixed by adding the correct callback flag for clientside connection closing (LWS_CALLBACK_CLOSED to LWS_CALLBACK_CLIENT_CLOSED)
2020-04-22 10:27:52 +02:00
2019-05-22 16:27:21 +02:00
2019-06-03 16:30:13 +02:00
2019-07-01 10:36:02 +02:00
2019-12-01 20:22:04 +01:00
2019-09-02 12:05:27 +02:00
2019-06-04 10:46:42 +02:00

OWSD web socket daemon

Overview

  • uses web sockets to accept RPC calls in JSON-RPC
  • intended as web back-end for JUCI Web UI on OpenWrt based platform
  • RPCs are routed to local IPC bus objects on ubus and/or D-Bus (beta)
  • supports receiving events in addition to issuing method calls
  • uses ubus session object to perform access control
  • JSON-RPC format is compatible with uhttpd-mod-ubus
  • basic HTTP file serving logic is available
  • powered by libwebsockets, libubox, libubus

Supported RPCs

  • "list"
  • "call"
  • "subscribe"
    • start listening for broadcast events by glob (wildcard) pattern
  • "subscribe-list"
    • list which events we are listening for
  • "unsubscribe"
    • stop listening

ubus support

  • methods on ubus objects can be called via the "call" rpc
  • events sent via ubus_send_event can be received
  • ACL checks are made prior to calling methods on ubus objects - the ubus session object is accessed to verify if session ID field has access
  • ACL checks are also made prior to notifying clients of events they are listening for - "owsd" is used as the scope to check for "read" permission on the event

ubus proxy support - networked ubus

  • using ubus proxy support, ubus objects can be proxied over the network across two hosts
  • with two hosts, client with ubus proxy support connects to remote server, and lists available objects
  • remotely available objects are created on the local client's ubus, calling methods of these (stub) objects results in RPC calls to the server's objects
  • see this screencast

D-Bus support (beta)

  • if both D-Bus and ubus support are enabled, D-Bus is searched first to find the object being called
  • when calling D-Bus methods, there are limitations with regard D-Bus argument types, since goal is to maintain syntax, RPC format and types and stay ubus compatible
    • the RPC format specifies object and method name, while D-Bus requires service, object, interface and method . For D-Bus object to be available via RPC:
      • service name must begin with compile-time specified prefix
      • the interface must be same as service name
      • and the object path must begin with same compile-time specified prefix
    • the argument types supported include integer, string, and array of int or string; support for some more complex types can be achieved, but full type support is not possible in the general case if keeping ubus compatibility and RPC format

SSL options

  • if SSL support is available at compile-time in libwebsockets, SSL can be used
  • server can be configured to allow all operations (skipping ubus session ACL checking) if clients provide a client certificate under CA trusted by server

Manual test run

If you run the owsd as RPC server to listen on some port (e.g. 1234)

owsd -p 1234

then it is easiest to test/connect with a tool like wscat:

wscat -c 'ws://127.0.0.1' -s ubus-json

The established web socket can be used to send RPCs in the JSON format.

Tests

In the test/ subdirectory, there is a very simple test runner made in nodejs. It is configured by editing parameters config.js, and running:

node client.js [session-id]

The config.js file specifies the text file containing test input and expected output. See existing text files for examples of RPC commands.

Other resources: libwebsockets documentation

https://libwebsockets.org/lws-api-doc-master/html/md_README.coding.html

Ubus Proxy Daemon

Overview

  • Automates detection of UBUS-X devices in the network
  • Depends on client events published on ubus and the method router.network hosts
  • Uses libubox and libubus.

Tests

In iopsysWRT, client events and router.network hosts are published by the questd daemon. In the res/ subdirectory are two scripts (clientsh and router.network) which will simulate the functionality of router.network hosts, allowing uproxyd to be used without questd on the system.

To test ubus-x, run clientsh in the background, place router.network in /usr/libexec/rpcd/ and issue /etc/init.d/rpcd restart. Rpcd should now publish the object router.network and owsd/uproxyd can be restarted through /etc/init.d/owsd restart. You should now be able to access remote objects through ubus.

Description
No description provided
Readme 955 KiB
Languages
C 88.2%
CMake 6.4%
JavaScript 3.4%
Shell 1.7%
HTML 0.3%