mirror of https://github.com/huashengdun/webssh
Merge 5dd6d8f292
into 1cf19c7186
commit
967cd83ead
|
@ -63,3 +63,4 @@ target/
|
||||||
|
|
||||||
# known_hosts file
|
# known_hosts file
|
||||||
known_hosts
|
known_hosts
|
||||||
|
.vscode/launch.json
|
||||||
|
|
|
@ -54,6 +54,9 @@ A simple web application to be used as an ssh client to connect to your ssh serv
|
||||||
# start a http server with specified listen address and listen port
|
# start a http server with specified listen address and listen port
|
||||||
wssh --address='2.2.2.2' --port=8000
|
wssh --address='2.2.2.2' --port=8000
|
||||||
|
|
||||||
|
# lock destination address and port
|
||||||
|
wssh --dstaddress='127.0.0.1' --dstport=22
|
||||||
|
|
||||||
# start a https server, certfile and keyfile must be passed
|
# start a https server, certfile and keyfile must be passed
|
||||||
wssh --certfile='/path/to/cert.crt' --keyfile='/path/to/cert.key'
|
wssh --certfile='/path/to/cert.crt' --keyfile='/path/to/cert.key'
|
||||||
|
|
||||||
|
|
|
@ -178,8 +178,7 @@ class PrivateKey(object):
|
||||||
logging.error(str(self.last_exception))
|
logging.error(str(self.last_exception))
|
||||||
msg = 'Invalid key'
|
msg = 'Invalid key'
|
||||||
if self.password:
|
if self.password:
|
||||||
msg += ' or wrong passphrase "{}" for decrypting it.'.format(
|
msg += ' or wrong passphrase for decrypting it.'
|
||||||
self.password)
|
|
||||||
raise InvalidValueError(msg)
|
raise InvalidValueError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -362,13 +361,17 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
|
||||||
return value, filename
|
return value, filename
|
||||||
|
|
||||||
def get_hostname(self):
|
def get_hostname(self):
|
||||||
value = self.get_value('hostname')
|
value = self.settings.get('dstaddress')
|
||||||
|
if not value:
|
||||||
|
value = self.get_value('hostname')
|
||||||
if not (is_valid_hostname(value) or is_valid_ip_address(value)):
|
if not (is_valid_hostname(value) or is_valid_ip_address(value)):
|
||||||
raise InvalidValueError('Invalid hostname: {}'.format(value))
|
raise InvalidValueError('Invalid hostname: {}'.format(value))
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def get_port(self):
|
def get_port(self):
|
||||||
value = self.get_argument('port', u'')
|
value = self.settings.get('dstport',u'')
|
||||||
|
if not value:
|
||||||
|
value = self.get_argument('port', u'')
|
||||||
if not value:
|
if not value:
|
||||||
return DEFAULT_PORT
|
return DEFAULT_PORT
|
||||||
|
|
||||||
|
@ -488,7 +491,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
self.render('index.html', debug=self.debug, font=self.font)
|
self.render('index.html', debug=self.debug, font=self.font, fixhost=self.settings.get('dstaddress'), fixport=self.settings.get('dstport'))
|
||||||
|
|
||||||
@tornado.gen.coroutine
|
@tornado.gen.coroutine
|
||||||
def post(self):
|
def post(self):
|
||||||
|
|
|
@ -18,7 +18,6 @@ def print_version(flag):
|
||||||
print(__version__)
|
print(__version__)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
define('address', default='', help='Listen address')
|
define('address', default='', help='Listen address')
|
||||||
define('port', type=int, default=8888, help='Listen port')
|
define('port', type=int, default=8888, help='Listen port')
|
||||||
define('ssladdress', default='', help='SSL listen address')
|
define('ssladdress', default='', help='SSL listen address')
|
||||||
|
@ -53,7 +52,8 @@ define('encoding', default='',
|
||||||
Example: --encoding='utf-8' to solve the problem with some switches&routers''')
|
Example: --encoding='utf-8' to solve the problem with some switches&routers''')
|
||||||
define('version', type=bool, help='Show version information',
|
define('version', type=bool, help='Show version information',
|
||||||
callback=print_version)
|
callback=print_version)
|
||||||
|
define('dstaddress', default='', help='Fix destination address')
|
||||||
|
define('dstport', default='', help='Fix destination port')
|
||||||
|
|
||||||
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
font_dirs = ['webssh', 'static', 'css', 'fonts']
|
font_dirs = ['webssh', 'static', 'css', 'fonts']
|
||||||
|
@ -79,13 +79,15 @@ def get_app_settings(options):
|
||||||
static_path=os.path.join(base_dir, 'webssh', 'static'),
|
static_path=os.path.join(base_dir, 'webssh', 'static'),
|
||||||
websocket_ping_interval=options.wpintvl,
|
websocket_ping_interval=options.wpintvl,
|
||||||
debug=options.debug,
|
debug=options.debug,
|
||||||
xsrf_cookies=options.xsrf,
|
xsrf_cookies=options.xsrf,
|
||||||
font=Font(
|
font=Font(
|
||||||
get_font_filename(options.font,
|
get_font_filename(options.font,
|
||||||
os.path.join(base_dir, *font_dirs)),
|
os.path.join(base_dir, *font_dirs)),
|
||||||
font_dirs[1:]
|
font_dirs[1:]
|
||||||
),
|
),
|
||||||
origin_policy=get_origin_setting(options)
|
origin_policy=get_origin_setting(options),
|
||||||
|
dstaddress=options.dstaddress,
|
||||||
|
dstport=options.dstport
|
||||||
)
|
)
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,13 @@
|
||||||
<div class="container form-container" style="display: none">
|
<div class="container form-container" style="display: none">
|
||||||
<form id="connect" action="" method="post" enctype="multipart/form-data"{% if debug %} novalidate{% end %}>
|
<form id="connect" action="" method="post" enctype="multipart/form-data"{% if debug %} novalidate{% end %}>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col" id="hostcol"{% if fixhost %} hidden{% end %}>
|
||||||
<label for="Hostname">Hostname</label>
|
<label for="Hostname">Hostname</label>
|
||||||
<input class="form-control" type="text" id="hostname" name="hostname" value="" required>
|
<input class="form-control" type="text" id="hostname" name="hostname" value="{{fixhost}}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" id="portcol"{% if fixport %} hidden{% end %}>
|
||||||
<label for="Port">Port</label>
|
<label for="Port">Port</label>
|
||||||
<input class="form-control" type="number" id="port" name="port" placeholder="22" value="" min=1 max=65535>
|
<input class="form-control" type="number" id="port" name="port" placeholder="22" value="{{fixport}}" min=1 max=65535>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
Loading…
Reference in New Issue