Add --config option and update config files

- Added --config FILE option to specify custom config file path
- Removed [wssht] section from wsssh.conf.example (legacy)
- Created separate wsssht.conf.example with wssht-specific options
- Updated man page with new --config option and mode options
- Updated usage message to include all new options
- Config file validation: errors if specified file doesn't exist
parent 2ed32275
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
# service = ssh # service = ssh
[wsssh] [wsssh]
# WebSocket SSH Daemon domain (used for hostname parsing) # WebSocket SSH Daemon domain (legacy, used for hostname parsing in wsssh)
domain = example.com domain = example.com
# Transport types for data channel (comma-separated or 'any') # Transport types for data channel (comma-separated or 'any')
......
# WebSocket SSH Tunnel (wsssht) Configuration Example # WebSocket SSH Tunnel (wsssht) Configuration Example
# #
# This is an example configuration file for wsssht. # This is an example configuration file for wsssht.
# Copy this file to ~/.config/wsssh/wssht.conf # Copy this file to ~/.config/wsssh/wsssht.conf and modify the settings as needed.
# and modify the settings as needed.
# #
# Configuration options: # Configuration options:
# wssshd-host: Default wssshd server hostname
# wssshd-port: Default wssshd server port [wssht]
# clientid: Default client ID for the tunnel # wssshd server hostname
# tunnel-port: Default local tunnel port (0 = auto-assign) wssshd-host = mbetter.nexlab.net
# tunnel-host: Local IP address to bind tunnel to (default: 127.0.0.1)
# tunnel: Default transport for data channel (comma-separated or 'any', or 'websocket') # Client ID for the tunnel
# tunnel-control: Default transport for control channel (comma-separated or 'any', or 'websocket') clientid = myclient
# service: Default service type (default: ssh)
# interval: Connection retry interval in seconds (default: 5) # Operating mode: interactive, silent, bridge, script
mode = interactive
wssshd-host=mbetter.nexlab.net
wssshd-port=9898 # Enable daemon mode (true/false)
clientid=myclient daemon = false
tunnel-port=0
tunnel-host=127.0.0.1 # Transport types for data channel (comma-separated or 'any')
tunnel=websocket # Available transports: websocket
tunnel-control=websocket tunnel = any
service=ssh
interval=5 # Transport types for control channel (comma-separated or 'any')
\ No newline at end of file # Only transports with is_relay=true can be used for control
tunnel-control = any
# Service type (default: ssh)
service = ssh
# Local tunnel host (default: 127.0.0.1)
tunnel-host = 127.0.0.1
# Connection retry interval in seconds (default: 5)
interval = 5
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
wsssht \- WebSocket SSH Tunnel Setup Tool wsssht \- WebSocket SSH Tunnel Setup Tool
.SH SYNOPSIS .SH SYNOPSIS
.B wsssht .B wsssht
[\fB\-\-config\fR \fIFILE\fR]
[\fB\-\-clientid\fR \fIID\fR] [\fB\-\-clientid\fR \fIID\fR]
[\fB\-\-tunnel\-port\fR \fIPORT\fR] [\fB\-\-tunnel\-port\fR \fIPORT\fR]
[\fB\-\-tunnel\-host\fR \fIHOST\fR] [\fB\-\-tunnel\-host\fR \fIHOST\fR]
...@@ -13,6 +14,11 @@ wsssht \- WebSocket SSH Tunnel Setup Tool ...@@ -13,6 +14,11 @@ wsssht \- WebSocket SSH Tunnel Setup Tool
[\fB\-\-tunnel\fR \fITRANSPORT\fR] [\fB\-\-tunnel\fR \fITRANSPORT\fR]
[\fB\-\-tunnel\-control\fR \fITYPES\fR] [\fB\-\-tunnel\-control\fR \fITYPES\fR]
[\fB\-\-service\fR \fISERVICE\fR] [\fB\-\-service\fR \fISERVICE\fR]
[\fB\-\-mode\fR \fIMODE\fR]
[\fB\-\-silent\fR]
[\fB\-\-bridge\fR]
[\fB\-\-script\fR]
[\fB\-\-daemon\fR]
[\fB\-\-help\fR] [\fB\-\-help\fR]
[\fIservice://\fR]\fIclientid\fR[\fI@wssshd-host\fR][\fI:wssshd-port\fR] [\fIservice://\fR]\fIclientid\fR[\fI@wssshd-host\fR][\fI:wssshd-port\fR]
.SH DESCRIPTION .SH DESCRIPTION
...@@ -27,6 +33,9 @@ and ...@@ -27,6 +33,9 @@ and
does not fork and execute external commands. Instead, it sets up the tunnel and displays connection instructions for manual use. does not fork and execute external commands. Instead, it sets up the tunnel and displays connection instructions for manual use.
.SH OPTIONS .SH OPTIONS
.TP .TP
.BR \-\-config " \fIFILE\fR"
Use custom config file (takes precedence over default)
.TP
.BR \-\-clientid " \fIID\fR" .BR \-\-clientid " \fIID\fR"
Specify the client ID for the tunnel (default: from config) Specify the client ID for the tunnel (default: from config)
.TP .TP
...@@ -57,6 +66,21 @@ Transport types for control channel (comma\-separated or 'any', default: any) ...@@ -57,6 +66,21 @@ Transport types for control channel (comma\-separated or 'any', default: any)
.BR \-\-service " \fISERVICE\fR" .BR \-\-service " \fISERVICE\fR"
Service type (default: ssh) Service type (default: ssh)
.TP .TP
.BR \-\-mode " \fIMODE\fR"
Operating mode: interactive, silent, bridge, script (default: interactive)
.TP
.BR \-\-silent
Shortcut for --mode silent
.TP
.BR \-\-bridge
Shortcut for --mode bridge
.TP
.BR \-\-script
Shortcut for --mode script
.TP
.BR \-\-daemon
Enable daemon mode for lazy initialization
.TP
.BR \-\-help .BR \-\-help
Display help message and exit Display help message and exit
.SH CONNECTION STRING FORMAT .SH CONNECTION STRING FORMAT
......
...@@ -52,6 +52,14 @@ extern volatile sig_atomic_t sigint_received; ...@@ -52,6 +52,14 @@ extern volatile sig_atomic_t sigint_received;
// SSL mutex for thread-safe SSL operations // SSL mutex for thread-safe SSL operations
extern pthread_mutex_t ssl_mutex; extern pthread_mutex_t ssl_mutex;
// Operating modes
typedef enum {
MODE_INTERACTIVE = 0, // Default: current functionality
MODE_SILENT, // Same as interactive but no output
MODE_BRIDGE, // JSON stdin/stdout bridge
MODE_SCRIPT // JSON protocol for scripting
} wsssh_mode_t;
// Config structures // Config structures
typedef struct { typedef struct {
char *local_port; char *local_port;
...@@ -65,6 +73,8 @@ typedef struct { ...@@ -65,6 +73,8 @@ typedef struct {
char *tunnel; // Transport types for data channel (comma-separated or "any") char *tunnel; // Transport types for data channel (comma-separated or "any")
char *tunnel_control; // Transport types for control channel (comma-separated or "any") char *tunnel_control; // Transport types for control channel (comma-separated or "any")
char *service; // Service type (default: "ssh") char *service; // Service type (default: "ssh")
wsssh_mode_t mode; // Operating mode
int daemon; // Daemon mode: lazy initialization
} wsssh_config_t; } wsssh_config_t;
typedef struct { typedef struct {
......
No preview for this file type
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment