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
058cf57f
Commit
058cf57f
authored
Nov 20, 2019
by
Eric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stash
parent
ec5f6f4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
16 deletions
+17
-16
newcommandparser.go
pkg/proxy/newcommandparser.go
+14
-11
parser.go
pkg/proxy/parser.go
+3
-5
No files found.
pkg/proxy/newcommandparser.go
View file @
058cf57f
...
@@ -8,8 +8,8 @@ import (
...
@@ -8,8 +8,8 @@ import (
)
)
type
commandInput
struct
{
type
commandInput
struct
{
readFromUserInput
bytes
.
Buffer
readFromUserInput
*
bytes
.
Buffer
readFromServerInput
bytes
.
Buffer
readFromServerInput
*
bytes
.
Buffer
isUserSideValid
bool
isUserSideValid
bool
isServerSideValid
bool
isServerSideValid
bool
...
@@ -24,16 +24,18 @@ func (c *commandInput) readFromServer(p []byte) {
...
@@ -24,16 +24,18 @@ func (c *commandInput) readFromServer(p []byte) {
}
}
func
(
c
*
commandInput
)
Parse
()
string
{
func
(
c
*
commandInput
)
Parse
()
string
{
lines
,
ok
:=
utils
.
ParseTerminalData
(
c
.
readFromUserInput
.
Bytes
(
))
lines
,
ok
:=
utils
.
ParseTerminalData
(
[]
byte
(
c
.
readFromUserInput
.
String
()
))
if
ok
{
if
ok
{
fmt
.
Println
(
"readFromUserInput lines: "
,
lines
)
fmt
.
Println
(
"readFromUserInput lines: "
,
lines
)
c
.
readFromUserInput
.
Reset
()
c
.
readFromUserInput
.
Reset
()
c
.
readFromServerInput
.
Reset
()
c
.
readFromServerInput
.
Reset
()
return
strings
.
Join
(
lines
,
"
\r\n
"
)
result
:=
strings
.
Join
(
lines
,
"
\r\n
"
)
fmt
.
Println
(
"readFromUserInput result: "
,
result
,
len
(
result
))
return
result
}
}
lines
,
_
=
utils
.
ParseTerminalData
(
c
.
readFromServerInput
.
Bytes
(
))
lines
,
_
=
utils
.
ParseTerminalData
(
[]
byte
(
c
.
readFromServerInput
.
String
()
))
fmt
.
Println
(
"readFromServerInput lines: "
,
lines
)
fmt
.
Println
(
"readFromServerInput lines: "
,
lines
)
c
.
readFromUserInput
.
Reset
()
c
.
readFromUserInput
.
Reset
()
c
.
readFromServerInput
.
Reset
()
c
.
readFromServerInput
.
Reset
()
...
@@ -41,9 +43,7 @@ func (c *commandInput) Parse() string {
...
@@ -41,9 +43,7 @@ func (c *commandInput) Parse() string {
}
}
type
commandOut
struct
{
type
commandOut
struct
{
readFromServerOut
bytes
.
Buffer
readFromServerOut
*
bytes
.
Buffer
isUserSideValid
bool
isServerSideValid
bool
}
}
func
(
c
*
commandOut
)
readFromServer
(
p
[]
byte
)
{
func
(
c
*
commandOut
)
readFromServer
(
p
[]
byte
)
{
...
@@ -51,8 +51,11 @@ func (c *commandOut) readFromServer(p []byte) {
...
@@ -51,8 +51,11 @@ func (c *commandOut) readFromServer(p []byte) {
}
}
func
(
c
*
commandOut
)
Parse
()
string
{
func
(
c
*
commandOut
)
Parse
()
string
{
lines
,
_
:=
utils
.
ParseTerminalData
(
c
.
readFromServerOut
.
Bytes
(
))
lines
,
_
:=
utils
.
ParseTerminalData
(
[]
byte
(
c
.
readFromServerOut
.
String
()
))
c
.
readFromServerOut
.
Reset
()
c
.
readFromServerOut
.
Reset
()
fmt
.
Println
(
"commandOut: "
,
lines
)
result
:=
strings
.
Join
(
lines
,
"
\r\n
"
)
return
strings
.
Join
(
lines
,
"
\r\n
"
)
fmt
.
Println
(
"commandOut: "
,
result
)
return
result
}
}
pkg/proxy/parser.go
View file @
058cf57f
...
@@ -71,15 +71,13 @@ func (p *Parser) initial() {
...
@@ -71,15 +71,13 @@ func (p *Parser) initial() {
//p.cmdInputParser = NewCmdParser(p.id, CommandInputParserName)
//p.cmdInputParser = NewCmdParser(p.id, CommandInputParserName)
//p.cmdOutputParser = NewCmdParser(p.id, CommandOutputParserName)
//p.cmdOutputParser = NewCmdParser(p.id, CommandOutputParserName)
p
.
cmdInputParser
=
&
commandInput
{
p
.
cmdInputParser
=
&
commandInput
{
readFromUserInput
:
bytes
.
Buffer
{},
readFromUserInput
:
&
bytes
.
Buffer
{},
readFromServerInput
:
bytes
.
Buffer
{},
readFromServerInput
:
&
bytes
.
Buffer
{},
isUserSideValid
:
false
,
isUserSideValid
:
false
,
isServerSideValid
:
false
,
isServerSideValid
:
false
,
}
}
p
.
cmdOutputParser
=
&
commandOut
{
p
.
cmdOutputParser
=
&
commandOut
{
readFromServerOut
:
bytes
.
Buffer
{},
readFromServerOut
:
&
bytes
.
Buffer
{},
isUserSideValid
:
false
,
isServerSideValid
:
false
,
}
}
p
.
closed
=
make
(
chan
struct
{})
p
.
closed
=
make
(
chan
struct
{})
p
.
cmdRecordChan
=
make
(
chan
[
2
]
string
,
1024
)
p
.
cmdRecordChan
=
make
(
chan
[
2
]
string
,
1024
)
...
...
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