Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
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
koko
Commits
ac7356eb
Commit
ac7356eb
authored
May 22, 2019
by
Eric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] fix bugs
parent
66d9befb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
parser.go
pkg/proxy/parser.go
+9
-4
No files found.
pkg/proxy/parser.go
View file @
ac7356eb
...
@@ -58,7 +58,7 @@ type Parser struct {
...
@@ -58,7 +58,7 @@ type Parser struct {
cmdOutputParser
*
CmdParser
cmdOutputParser
*
CmdParser
cmdFilterRules
[]
model
.
SystemUserFilterRule
cmdFilterRules
[]
model
.
SystemUserFilterRule
closed
bool
closed
chan
struct
{}
}
}
func
(
p
*
Parser
)
initial
()
{
func
(
p
*
Parser
)
initial
()
{
...
@@ -72,6 +72,7 @@ func (p *Parser) initial() {
...
@@ -72,6 +72,7 @@ func (p *Parser) initial() {
p
.
cmdInputParser
=
NewCmdParser
()
p
.
cmdInputParser
=
NewCmdParser
()
p
.
cmdOutputParser
=
NewCmdParser
()
p
.
cmdOutputParser
=
NewCmdParser
()
p
.
closed
=
make
(
chan
struct
{})
p
.
userInputChan
=
make
(
chan
[]
byte
,
1024
)
p
.
userInputChan
=
make
(
chan
[]
byte
,
1024
)
p
.
userOutputChan
=
make
(
chan
[]
byte
,
1024
)
p
.
userOutputChan
=
make
(
chan
[]
byte
,
1024
)
p
.
srvInputChan
=
make
(
chan
[]
byte
,
1024
)
p
.
srvInputChan
=
make
(
chan
[]
byte
,
1024
)
...
@@ -85,6 +86,8 @@ func (p *Parser) Parse() {
...
@@ -85,6 +86,8 @@ func (p *Parser) Parse() {
}()
}()
for
{
for
{
select
{
select
{
case
<-
p
.
closed
:
return
case
b
,
ok
:=
<-
p
.
userInputChan
:
case
b
,
ok
:=
<-
p
.
userInputChan
:
if
!
ok
{
if
!
ok
{
return
return
...
@@ -224,7 +227,6 @@ func (p *Parser) SetCMDFilterRules(rules []model.SystemUserFilterRule) {
...
@@ -224,7 +227,6 @@ func (p *Parser) SetCMDFilterRules(rules []model.SystemUserFilterRule) {
}
}
func
(
p
*
Parser
)
IsCommandForbidden
()
(
string
,
bool
)
{
func
(
p
*
Parser
)
IsCommandForbidden
()
(
string
,
bool
)
{
fmt
.
Println
(
"Command is: "
,
p
.
command
)
for
_
,
rule
:=
range
p
.
cmdFilterRules
{
for
_
,
rule
:=
range
p
.
cmdFilterRules
{
allowed
,
cmd
:=
rule
.
Match
(
p
.
command
)
allowed
,
cmd
:=
rule
.
Match
(
p
.
command
)
switch
allowed
{
switch
allowed
{
...
@@ -246,13 +248,16 @@ func (p *Parser) IsRecvState() bool {
...
@@ -246,13 +248,16 @@ func (p *Parser) IsRecvState() bool {
}
}
func
(
p
*
Parser
)
Close
()
{
func
(
p
*
Parser
)
Close
()
{
if
p
.
closed
{
select
{
case
<-
p
.
closed
:
return
return
default
:
close
(
p
.
closed
)
}
}
close
(
p
.
userInputChan
)
close
(
p
.
userInputChan
)
close
(
p
.
userOutputChan
)
close
(
p
.
userOutputChan
)
close
(
p
.
srvInputChan
)
close
(
p
.
srvInputChan
)
close
(
p
.
srvOutputChan
)
close
(
p
.
srvOutputChan
)
close
(
p
.
cmdRecordChan
)
close
(
p
.
cmdRecordChan
)
p
.
closed
=
true
}
}
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