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
7bfaf0b0
Commit
7bfaf0b0
authored
May 28, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
[Update] Merge
parents
7ce5483d
e4da494d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
15 deletions
+21
-15
app.py
coco/app.py
+5
-1
httpd.py
coco/httpd.py
+11
-9
logger.py
coco/logger.py
+2
-0
tasks.py
coco/tasks.py
+1
-3
requirements.txt
requirements/requirements.txt
+2
-2
No files found.
coco/app.py
View file @
7bfaf0b0
...
...
@@ -9,6 +9,8 @@ import threading
import
socket
import
json
import
signal
import
eventlet
from
eventlet.debug
import
hub_prevent_multiple_readers
from
jms.service
import
AppService
...
...
@@ -20,8 +22,10 @@ from .tasks import TaskHandler
from
.recorder
import
ReplayRecorder
,
CommandRecorder
from
.utils
import
get_logger
,
register_app
,
register_service
eventlet
.
monkey_patch
()
hub_prevent_multiple_readers
(
False
)
__version__
=
'1.3.
0
'
__version__
=
'1.3.
1
'
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
logger
=
get_logger
(
__file__
)
...
...
coco/httpd.py
View file @
7bfaf0b0
...
...
@@ -4,7 +4,6 @@
import
os
import
socket
import
uuid
import
eventlet
from
flask_socketio
import
SocketIO
,
Namespace
,
join_room
from
flask
import
Flask
,
request
,
current_app
,
redirect
...
...
@@ -14,11 +13,8 @@ from .utils import get_logger
from
.ctx
import
current_app
,
app_service
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
logger
=
get_logger
(
__file__
)
eventlet
.
monkey_patch
()
class
BaseNamespace
(
Namespace
):
current_user
=
None
...
...
@@ -172,7 +168,7 @@ class ProxyNamespace(BaseNamespace):
room
=
self
.
new_room
()
self
.
emit
(
'room'
,
{
'room'
:
room
[
"id"
],
'secret'
:
secret
})
if
not
token
or
not
secret
:
logger
.
debug
(
"Token or secret is None
"
)
logger
.
debug
(
"Token or secret is None
: {}"
.
format
(
token
,
secret
)
)
self
.
emit
(
'data'
,
{
'data'
:
"
\n
Operation not permitted!"
,
'room'
:
room
[
"id"
]})
self
.
emit
(
'disconnect'
)
...
...
@@ -230,6 +226,9 @@ class ProxyNamespace(BaseNamespace):
del
self
.
connections
[
request
.
sid
][
room_id
]
del
room
def
on_ping
(
self
):
self
.
emit
(
'pong'
)
class
HttpServer
:
# prepare may be rewrite it
...
...
@@ -241,8 +240,10 @@ class HttpServer:
init_kwargs
=
dict
(
async_mode
=
"eventlet"
,
# async_mode="threading",
ping_timeout
=
20
,
ping_interval
=
10
# ping_timeout=20,
# ping_interval=10,
# engineio_logger=True,
# logger=True
)
def
__init__
(
self
):
...
...
@@ -267,7 +268,7 @@ class HttpServer:
def
run
(
self
):
host
=
self
.
flask_app
.
config
[
"BIND_HOST"
]
port
=
self
.
flask_app
.
config
[
"HTTPD_PORT"
]
print
(
'Starting websock server at {}:{}'
.
format
(
host
,
port
))
print
(
'Starting websock
et
server at {}:{}'
.
format
(
host
,
port
))
self
.
socket_io
.
init_app
(
self
.
flask_app
,
**
self
.
init_kwargs
...
...
@@ -275,4 +276,5 @@ class HttpServer:
self
.
socket_io
.
run
(
self
.
flask_app
,
port
=
port
,
host
=
host
,
debug
=
False
)
def
shutdown
(
self
):
self
.
socket_io
.
server
.
close
()
self
.
socket_io
.
stop
()
pass
coco/logger.py
View file @
7bfaf0b0
...
...
@@ -49,6 +49,8 @@ def create_logger(app):
'coco'
:
main_setting
,
'paramiko'
:
main_setting
,
'jms'
:
main_setting
,
# 'socket.io': main_setting,
# 'engineio': main_setting,
}
)
...
...
coco/tasks.py
View file @
7bfaf0b0
...
...
@@ -9,9 +9,7 @@ logger = get_logger(__file__)
class
TaskHandler
:
routes
=
None
def
init
(
self
):
def
__init__
(
self
):
self
.
routes
=
{
'kill_session'
:
self
.
handle_kill_session
}
...
...
requirements/requirements.txt
View file @
7bfaf0b0
...
...
@@ -12,7 +12,7 @@ cryptography==2.1.4
docutils==0.14
dotmap==1.2.20
elasticsearch==6.1.1
Flask==
0.12
.2
Flask==
1.0
.2
Flask-SocketIO==2.9.2
idna==2.6
itsdangerous==0.24
...
...
@@ -40,5 +40,5 @@ six==1.11.0
tornado==4.5.2
urllib3==1.22
wcwidth==0.1.7
Werkzeug==0.12.2
eventlet==0.22.1
Werkzeug==0.14.1
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