Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webssh
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑天保
webssh
Commits
3f3d061d
Commit
3f3d061d
authored
Mar 21, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored
parent
75361d87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
main.py
main.py
+21
-15
No files found.
main.py
View file @
3f3d061d
...
...
@@ -202,9 +202,11 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
ssh
.
_system_host_keys
=
self
.
settings
[
'system_host_keys'
]
ssh
.
_host_keys
=
self
.
settings
[
'host_keys'
]
ssh
.
set_missing_host_key_policy
(
self
.
settings
[
'policy'
])
args
=
self
.
get_args
()
dst_addr
=
(
args
[
0
],
args
[
1
])
logging
.
info
(
'Connecting to {}:{}'
.
format
(
*
dst_addr
))
try
:
ssh
.
connect
(
*
args
,
timeout
=
6
)
except
socket
.
error
:
...
...
@@ -213,6 +215,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
raise
ValueError
(
'Authentication failed.'
)
except
paramiko
.
BadHostKeyException
:
raise
ValueError
(
'Bad host key.'
)
chan
=
ssh
.
invoke_shell
(
term
=
'xterm'
)
chan
.
setblocking
(
0
)
worker
=
Worker
(
ssh
,
chan
,
dst_addr
)
...
...
@@ -313,8 +316,7 @@ def get_policy_class(policy):
return
cls
def
main
():
parse_command_line
()
def
get_application_settings
():
base_dir
=
os
.
path
.
dirname
(
__file__
)
filename
=
os
.
path
.
join
(
base_dir
,
'known_hosts'
)
host_keys
=
get_host_keys
(
filename
)
...
...
@@ -332,25 +334,29 @@ def main():
if
not
host_keys
and
not
system_host_keys
:
raise
ValueError
(
'Empty known_hosts with reject policy?'
)
settings
=
{
'template_path'
:
os
.
path
.
join
(
base_dir
,
'templates'
),
'static_path'
:
os
.
path
.
join
(
base_dir
,
'static'
),
'cookie_secret'
:
uuid
.
uuid4
()
.
hex
,
'xsrf_cookies'
:
True
}
settings
=
dict
(
template_path
=
os
.
path
.
join
(
base_dir
,
'templates'
),
static_path
=
os
.
path
.
join
(
base_dir
,
'static'
),
cookie_secret
=
uuid
.
uuid4
()
.
hex
,
xsrf_cookies
=
True
,
host_keys
=
host_keys
,
system_host_keys
=
system_host_keys
,
policy
=
policy_class
(),
debug
=
options
.
debug
)
return
settings
def
main
():
parse_command_line
()
settings
=
get_application_settings
()
handlers
=
[
(
r'/'
,
IndexHandler
),
(
r'/ws'
,
WsockHandler
)
]
settings
.
update
(
debug
=
options
.
debug
,
host_keys
=
host_keys
,
system_host_keys
=
system_host_keys
,
policy
=
policy_class
()
)
app
=
tornado
.
web
.
Application
(
handlers
,
**
settings
)
app
.
listen
(
options
.
port
,
options
.
address
)
logging
.
info
(
'Listening on {}:{}'
.
format
(
options
.
address
,
options
.
port
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment