@tehw0lf/n8n-nodes-unix-socket-bridge 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -51,6 +51,7 @@ Create a configuration file for your commands (e.g., `system-monitor.json`):
51
51
  {
52
52
  "name": "System Monitor",
53
53
  "socket_path": "/tmp/system.sock",
54
+ "allowed_executable_dirs": ["/usr/bin/", "/bin/", "/usr/local/bin/"],
54
55
  "commands": {
55
56
  "uptime": {
56
57
  "description": "Get system uptime",
@@ -70,7 +71,7 @@ Create a configuration file for your commands (e.g., `system-monitor.json`):
70
71
 
71
72
  Start the server:
72
73
  ```bash
73
- python3 socket-server.py system-monitor.json
74
+ python3 /usr/local/bin/unix-socket-server system-monitor.json
74
75
  ```
75
76
 
76
77
  ### 2. Use in n8n
@@ -95,11 +96,18 @@ For servers with authentication enabled:
95
96
  - The node automatically handles authentication with the server
96
97
  - Leave empty for servers without authentication
97
98
 
99
+ See `examples/playerctl-secure.json` for a complete authentication configuration example.
100
+
98
101
  ### Advanced Options
99
102
  - **Max Response Size**: Limit response size for memory safety (default: 1MB)
100
103
  - **Include Metadata**: Include execution metadata in responses
101
104
  - **Timeout**: Connection timeout in milliseconds (default: 5000ms)
102
105
 
106
+ ### Server Configuration Requirements
107
+ All server configurations must include:
108
+ - **`allowed_executable_dirs`**: Security allowlist of directories containing executables
109
+ - **`commands`**: Dictionary of available commands with descriptions and executables
110
+
103
111
  ### Operation Modes
104
112
 
105
113
  #### With Auto-Discovery
@@ -130,6 +138,7 @@ Control media players (using playerctl):
130
138
  {
131
139
  "name": "Media Control",
132
140
  "socket_path": "/tmp/playerctl.sock",
141
+ "allowed_executable_dirs": ["/usr/bin/", "/bin/", "/usr/local/bin/"],
133
142
  "commands": {
134
143
  "play-pause": {
135
144
  "description": "Toggle play/pause",
@@ -153,6 +162,7 @@ Integrate Docker operations:
153
162
  {
154
163
  "name": "Docker Control",
155
164
  "socket_path": "/tmp/docker.sock",
165
+ "allowed_executable_dirs": ["/usr/bin/", "/bin/", "/usr/local/bin/"],
156
166
  "commands": {
157
167
  "list": {
158
168
  "description": "List containers",
@@ -180,6 +190,7 @@ Run any custom script or command:
180
190
  {
181
191
  "name": "Custom Scripts",
182
192
  "socket_path": "/tmp/scripts.sock",
193
+ "allowed_executable_dirs": ["/usr/bin/", "/bin/", "/usr/local/bin/"],
183
194
  "commands": {
184
195
  "backup": {
185
196
  "description": "Run backup script",
@@ -214,22 +225,47 @@ Get the server from the [main repository](https://github.com/tehw0lf/n8n-nodes-u
214
225
 
215
226
  ## Production Setup
216
227
 
217
- For production use, run the socket server as a systemd service with authentication:
228
+ ### User Services (Recommended)
229
+
230
+ For production use, run socket servers as user systemd services. This provides better security and access to user sessions:
231
+
232
+ ```bash
233
+ # Install the user service template
234
+ sudo cp systemd/socket-bridge-user@.service /etc/systemd/user/
235
+ sudo systemctl daemon-reload
236
+
237
+ # Create user configuration directory
238
+ mkdir -p ~/.config/socket-bridge
239
+
240
+ # Copy your configuration (e.g., playerctl.json)
241
+ cp your-config.json ~/.config/socket-bridge/
242
+
243
+ # Enable and start the service
244
+ systemctl --user enable socket-bridge-user@your-config.service
245
+ systemctl --user start socket-bridge-user@your-config.service
246
+
247
+ # Check status
248
+ systemctl --user status socket-bridge-user@your-config.service
249
+ ```
250
+
251
+ ### System Services (Alternative)
252
+
253
+ For system-wide services, ensure proper user configuration for DBUS access:
218
254
 
219
255
  ```ini
220
256
  [Unit]
221
- Description=Unix Socket Bridge
257
+ Description=Unix Socket Bridge - Your Service
222
258
  After=network.target
223
259
 
224
260
  [Service]
225
261
  Type=simple
226
- ExecStart=/usr/bin/python3 /usr/local/bin/socket-server.py /etc/socket-bridge/config.json
262
+ ExecStart=/usr/bin/python3 /usr/local/bin/unix-socket-server /etc/socket-bridge/config.json
227
263
  Restart=always
228
- User=www-data
264
+ User=your-username
265
+ Environment=XDG_RUNTIME_DIR=/run/user/1000
266
+ Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
229
267
  Environment=AUTH_ENABLED=true
230
268
  Environment=AUTH_TOKEN_HASH=your-hashed-token-here
231
- Environment=AUTH_MAX_ATTEMPTS=5
232
- Environment=AUTH_WINDOW_SECONDS=60
233
269
 
234
270
  [Install]
235
271
  WantedBy=multi-user.target
@@ -239,6 +275,10 @@ WantedBy=multi-user.target
239
275
 
240
276
  Generate a secure token hash:
241
277
  ```bash
278
+ # Use the included generator (recommended)
279
+ python3 server/generate-token-hash.py
280
+
281
+ # Or manually generate
242
282
  echo -n "your-secret-token" | sha256sum
243
283
  ```
244
284
 
@@ -251,9 +291,9 @@ Use the hash in your systemd service and the plaintext token in your n8n node co
251
291
  - Check n8n logs for any errors
252
292
 
253
293
  ### Commands not showing in dropdown?
254
- - Verify the socket server is running: `ps aux | grep socket-server`
294
+ - Verify the socket server is running: `ps aux | grep unix-socket-server`
255
295
  - Check if the socket file exists: `ls -la /tmp/*.sock`
256
- - Test the connection with the CLI client
296
+ - Test the connection: `unix-socket-client /tmp/your-socket.sock ping`
257
297
 
258
298
  ### Connection errors?
259
299
  - Check socket file permissions
@@ -9,7 +9,7 @@ import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodeProp
9
9
  * @example
10
10
  * // Basic usage with auto-discovery
11
11
  * const node = new UnixSocketBridge();
12
- * // Configure socket path: /tmp/playerctl.sock
12
+ * // Configure socket path: /tmp/socket-bridge/playerctl.sock
13
13
  * // Enable auto-discovery to see available commands
14
14
  * // Select command from dropdown and execute
15
15
  *
@@ -46,7 +46,7 @@ function hashToken(token) {
46
46
  * @example
47
47
  * // Basic usage with auto-discovery
48
48
  * const node = new UnixSocketBridge();
49
- * // Configure socket path: /tmp/playerctl.sock
49
+ * // Configure socket path: /tmp/socket-bridge/playerctl.sock
50
50
  * // Enable auto-discovery to see available commands
51
51
  * // Select command from dropdown and execute
52
52
  *
@@ -84,8 +84,8 @@ class UnixSocketBridge {
84
84
  displayName: "Socket Path",
85
85
  name: "socketPath",
86
86
  type: "string",
87
- default: "/tmp/socket.sock",
88
- placeholder: "/tmp/socket.sock",
87
+ default: "/tmp/socket-bridge/service.sock",
88
+ placeholder: "/tmp/socket-bridge/service.sock",
89
89
  description: "Path to the Unix domain socket file",
90
90
  required: true,
91
91
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tehw0lf/n8n-nodes-unix-socket-bridge",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Generic Unix domain socket communication with configurable server support for n8n",
5
5
  "main": "index.js",
6
6
  "scripts": {