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 @@
# service = ssh
[wsssh]
# WebSocket SSH Daemon domain (used for hostname parsing)
# WebSocket SSH Daemon domain (legacy, used for hostname parsing in wsssh)
domain = example.com
# Transport types for data channel (comma-separated or 'any')
......
# WebSocket SSH Tunnel (wsssht) Configuration Example
#
# This is an example configuration file for wsssht.
# Copy this file to ~/.config/wsssh/wssht.conf
# and modify the settings as needed.
# Copy this file to ~/.config/wsssh/wsssht.conf and modify the settings as needed.
#
# Configuration options:
# wssshd-host: Default wssshd server hostname
# wssshd-port: Default wssshd server port
# clientid: Default client ID for the tunnel
# tunnel-port: Default local tunnel port (0 = auto-assign)
# 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')
# tunnel-control: Default transport for control channel (comma-separated or 'any', or 'websocket')
# service: Default service type (default: ssh)
# interval: Connection retry interval in seconds (default: 5)
wssshd-host=mbetter.nexlab.net
wssshd-port=9898
clientid=myclient
tunnel-port=0
tunnel-host=127.0.0.1
tunnel=websocket
tunnel-control=websocket
service=ssh
interval=5
\ No newline at end of file
[wssht]
# wssshd server hostname
wssshd-host = mbetter.nexlab.net
# Client ID for the tunnel
clientid = myclient
# Operating mode: interactive, silent, bridge, script
mode = interactive
# Enable daemon mode (true/false)
daemon = false
# Transport types for data channel (comma-separated or 'any')
# Available transports: websocket
tunnel = any
# Transport types for control channel (comma-separated or 'any')
# 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 @@
wsssht \- WebSocket SSH Tunnel Setup Tool
.SH SYNOPSIS
.B wsssht
[\fB\-\-config\fR \fIFILE\fR]
[\fB\-\-clientid\fR \fIID\fR]
[\fB\-\-tunnel\-port\fR \fIPORT\fR]
[\fB\-\-tunnel\-host\fR \fIHOST\fR]
......@@ -13,6 +14,11 @@ wsssht \- WebSocket SSH Tunnel Setup Tool
[\fB\-\-tunnel\fR \fITRANSPORT\fR]
[\fB\-\-tunnel\-control\fR \fITYPES\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]
[\fIservice://\fR]\fIclientid\fR[\fI@wssshd-host\fR][\fI:wssshd-port\fR]
.SH DESCRIPTION
......@@ -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.
.SH OPTIONS
.TP
.BR \-\-config " \fIFILE\fR"
Use custom config file (takes precedence over default)
.TP
.BR \-\-clientid " \fIID\fR"
Specify the client ID for the tunnel (default: from config)
.TP
......@@ -57,6 +66,21 @@ Transport types for control channel (comma\-separated or 'any', default: any)
.BR \-\-service " \fISERVICE\fR"
Service type (default: ssh)
.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
Display help message and exit
.SH CONNECTION STRING FORMAT
......
......@@ -52,6 +52,14 @@ extern volatile sig_atomic_t sigint_received;
// SSL mutex for thread-safe SSL operations
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
typedef struct {
char *local_port;
......@@ -65,6 +73,8 @@ typedef struct {
char *tunnel; // Transport types for data channel (comma-separated or "any")
char *tunnel_control; // Transport types for control channel (comma-separated or "any")
char *service; // Service type (default: "ssh")
wsssh_mode_t mode; // Operating mode
int daemon; // Daemon mode: lazy initialization
} wsssh_config_t;
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