Commit 92bed400 authored by nextime's avatar nextime

Add --config option support to wssshd.py

- Add --config command line option to specify configuration file path
- Update config loading logic to use specified config file
- Maintain backward compatibility with default /etc/wssshd.conf
- Support for custom configuration file locations
parent 66f67695
......@@ -522,8 +522,24 @@ async def cleanup_task():
cleanup_expired_clients()
async def main():
parser = argparse.ArgumentParser(description='WebSocket SSH Daemon (wssshd)')
parser.add_argument('--config', help='Configuration file path (default: /etc/wssshd.conf)')
parser.add_argument('--host', help='WebSocket server host')
parser.add_argument('--port', type=int, help='WebSocket server port')
parser.add_argument('--domain', help='Base domain name')
parser.add_argument('--password', help='Registration password')
parser.add_argument('--web-host', help='Web interface host (optional)')
parser.add_argument('--web-port', type=int, help='Web interface port (optional)')
parser.add_argument('--web-https', action='store_true', help='Enable HTTPS for web interface')
parser.add_argument('--debug', action='store_true', help='Enable debug output')
# Parse just the config argument first to determine config file location
temp_parser = argparse.ArgumentParser(add_help=False)
temp_parser.add_argument('--config')
temp_args, remaining = temp_parser.parse_known_args()
config = configparser.ConfigParser()
config_path = '/etc/wssshd.conf'
config_path = temp_args.config or '/etc/wssshd.conf'
defaults = {}
if os.path.exists(config_path):
config.read(config_path)
......@@ -543,17 +559,7 @@ async def main():
if 'web-https' in section:
defaults['web_https'] = section.getboolean('web-https', False)
parser = argparse.ArgumentParser(description='WebSocket SSH Daemon (wssshd)')
parser.set_defaults(**defaults)
parser.add_argument('--host', help='WebSocket server host')
parser.add_argument('--port', type=int, help='WebSocket server port')
parser.add_argument('--domain', help='Base domain name')
parser.add_argument('--password', help='Registration password')
parser.add_argument('--web-host', help='Web interface host (optional)')
parser.add_argument('--web-port', type=int, help='Web interface port (optional)')
parser.add_argument('--web-https', action='store_true', help='Enable HTTPS for web interface')
parser.add_argument('--debug', action='store_true', help='Enable debug output')
global args
args = parser.parse_args()
......@@ -561,6 +567,7 @@ async def main():
if 'web_https' in defaults and not any(arg.startswith('--web-https') for arg in sys.argv):
args.web_https = defaults['web_https']
# Check required arguments
if not args.host:
parser.error('--host is required')
......
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