Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
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
ops
coco
Commits
c13956a4
Commit
c13956a4
authored
Sep 03, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'github/dev' into dev
parents
412b7f02
2df44d0b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
8 deletions
+14
-8
app.py
coco/app.py
+1
-0
connection.py
coco/connection.py
+5
-4
proxy.py
coco/proxy.py
+4
-2
conf_example.py
conf_example.py
+3
-0
rpm_requirements.txt
requirements/rpm_requirements.txt
+1
-2
No files found.
coco/app.py
View file @
c13956a4
...
@@ -54,6 +54,7 @@ class Coco:
...
@@ -54,6 +54,7 @@ class Coco:
'HEARTBEAT_INTERVAL'
:
5
,
'HEARTBEAT_INTERVAL'
:
5
,
'MAX_CONNECTIONS'
:
500
,
'MAX_CONNECTIONS'
:
500
,
'ADMINS'
:
''
,
'ADMINS'
:
''
,
'SSH_TIMEOUT'
:
15
,
'COMMAND_STORAGE'
:
{
'TYPE'
:
'server'
},
# server
'COMMAND_STORAGE'
:
{
'TYPE'
:
'server'
},
# server
'REPLAY_STORAGE'
:
{
'TYPE'
:
'server'
},
'REPLAY_STORAGE'
:
{
'TYPE'
:
'server'
},
}
}
...
...
coco/connection.py
View file @
c13956a4
...
@@ -10,11 +10,11 @@ import telnetlib
...
@@ -10,11 +10,11 @@ import telnetlib
import
paramiko
import
paramiko
from
paramiko.ssh_exception
import
SSHException
from
paramiko.ssh_exception
import
SSHException
from
.ctx
import
app_service
from
.ctx
import
app_service
,
current_app
from
.utils
import
get_logger
,
get_private_key_fingerprint
,
net_input
from
.utils
import
get_logger
,
get_private_key_fingerprint
,
net_input
logger
=
get_logger
(
__file__
)
logger
=
get_logger
(
__file__
)
TIMEOUT
=
10
BUF_SIZE
=
1024
BUF_SIZE
=
1024
MANUAL_LOGIN
=
'manual'
MANUAL_LOGIN
=
'manual'
AUTO_LOGIN
=
'auto'
AUTO_LOGIN
=
'auto'
...
@@ -46,7 +46,8 @@ class SSHConnection:
...
@@ -46,7 +46,8 @@ class SSHConnection:
ssh
.
connect
(
ssh
.
connect
(
asset
.
ip
,
port
=
asset
.
port
,
username
=
system_user
.
username
,
asset
.
ip
,
port
=
asset
.
port
,
username
=
system_user
.
username
,
password
=
system_user
.
password
,
pkey
=
system_user
.
private_key
,
password
=
system_user
.
password
,
pkey
=
system_user
.
private_key
,
timeout
=
TIMEOUT
,
compress
=
True
,
auth_timeout
=
TIMEOUT
,
timeout
=
current_app
.
config
[
'SSH_TIMEOUT'
],
compress
=
True
,
auth_timeout
=
current_app
.
config
[
'SSH_TIMEOUT'
],
look_for_keys
=
False
,
sock
=
sock
look_for_keys
=
False
,
sock
=
sock
)
)
except
(
paramiko
.
AuthenticationException
,
except
(
paramiko
.
AuthenticationException
,
...
@@ -111,7 +112,7 @@ class SSHConnection:
...
@@ -111,7 +112,7 @@ class SSHConnection:
username
=
gateway
.
username
,
username
=
gateway
.
username
,
password
=
gateway
.
password
,
password
=
gateway
.
password
,
pkey
=
gateway
.
private_key_obj
,
pkey
=
gateway
.
private_key_obj
,
timeout
=
TIMEOUT
)
timeout
=
current_app
.
config
[
'SSH_TIMEOUT'
]
)
except
(
paramiko
.
AuthenticationException
,
except
(
paramiko
.
AuthenticationException
,
paramiko
.
BadAuthenticationType
,
paramiko
.
BadAuthenticationType
,
SSHException
):
SSHException
):
...
...
coco/proxy.py
View file @
c13956a4
...
@@ -16,7 +16,6 @@ from .utils import wrap_with_line_feed as wr, wrap_with_warning as warning, \
...
@@ -16,7 +16,6 @@ from .utils import wrap_with_line_feed as wr, wrap_with_warning as warning, \
logger
=
get_logger
(
__file__
)
logger
=
get_logger
(
__file__
)
TIMEOUT
=
10
BUF_SIZE
=
4096
BUF_SIZE
=
4096
MANUAL_LOGIN
=
'manual'
MANUAL_LOGIN
=
'manual'
AUTO_LOGIN
=
'auto'
AUTO_LOGIN
=
'auto'
...
@@ -156,8 +155,11 @@ class ProxyServer:
...
@@ -156,8 +155,11 @@ class ProxyServer:
self
.
client
.
send
(
'Connecting to {}@{} {:.1f}'
.
format
(
self
.
client
.
send
(
'Connecting to {}@{} {:.1f}'
.
format
(
system_user
,
asset
,
delay
)
system_user
,
asset
,
delay
)
)
)
while
self
.
connecting
and
delay
<
TIMEOUT
:
while
self
.
connecting
and
delay
<
current_app
.
config
[
'SSH_TIMEOUT'
]:
if
0
<=
delay
<
10
:
self
.
client
.
send
(
'
\x08\x08\x08
{:.1f}'
.
format
(
delay
)
.
encode
())
self
.
client
.
send
(
'
\x08\x08\x08
{:.1f}'
.
format
(
delay
)
.
encode
())
else
:
self
.
client
.
send
(
'
\x08\x08\x08\x08
{:.1f}'
.
format
(
delay
)
.
encode
())
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
delay
+=
0.1
delay
+=
0.1
thread
=
threading
.
Thread
(
target
=
func
)
thread
=
threading
.
Thread
(
target
=
func
)
...
...
conf_example.py
View file @
c13956a4
...
@@ -66,5 +66,8 @@ class Config:
...
@@ -66,5 +66,8 @@ class Config:
"TYPE"
:
"server"
"TYPE"
:
"server"
}
}
# SSH connection timeout (default 15 seconds)
# SSH_TIMEOUT = 15
config
=
Config
()
config
=
Config
()
requirements/rpm_requirements.txt
View file @
c13956a4
libffi-devel sshpass
libffi-devel sshpass krb5-devel
\ No newline at end of file
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