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
ed12adcb
Commit
ed12adcb
authored
Oct 16, 2018
by
广宏伟
Browse files
Options
Browse Files
Download
Plain Diff
Merged in dev (pull request #116)
[Update] 修改命令过滤
parents
e463ae37
eeeca2d8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
models.py
coco/models.py
+6
-1
No files found.
coco/models.py
View file @
ed12adcb
...
...
@@ -236,17 +236,21 @@ class BaseServer:
def
s_filter_cmd_filter
(
self
,
data
):
if
self
.
_in_input_state
:
return
data
if
not
self
.
_input
:
return
data
for
rule
in
self
.
_cmd_filter_rules
:
action
,
cmd
=
rule
.
match
(
self
.
_input
)
if
action
==
rule
.
ALLOW
:
break
elif
action
==
rule
.
DENY
:
data
=
char
.
CLEAR_LINE_CHAR
+
b
'
\r
\n
'
data
=
char
.
CLEAR_LINE_CHAR
+
b
'
\r
'
msg
=
_
(
"Command `{}` is forbidden ........"
)
.
format
(
cmd
)
msg
=
wr
(
warning
(
msg
.
encode
()),
before
=
1
,
after
=
1
)
self
.
output_data
.
append
(
msg
)
self
.
session
.
send_to_clients
(
msg
)
self
.
session
.
put_command
(
self
.
_input
,
msg
.
decode
())
self
.
session
.
put_replay
(
msg
)
self
.
input_data
.
clean
()
break
return
data
...
...
@@ -328,6 +332,7 @@ class BaseServer:
return
self
.
_cmd_parser
.
parse_output
(
self
.
output_data
)
def
_parse_input
(
self
):
print
(
"Parse input: {}"
.
format
(
self
.
input_data
))
if
not
self
.
input_data
:
return
return
self
.
_cmd_parser
.
parse_input
(
self
.
input_data
)
...
...
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