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
17077009
Commit
17077009
authored
Apr 29, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改一些
parent
30550fd4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
23 deletions
+21
-23
parser.go
pkg/proxy/parser.go
+5
-1
session.go
pkg/sshd/handler/session.go
+16
-22
No files found.
pkg/proxy/parser.go
View file @
17077009
...
...
@@ -2,14 +2,16 @@ package proxy
import
(
"bytes"
"cocogo/pkg/logger"
"fmt"
"sync"
"cocogo/pkg/logger"
)
type
ParseRule
func
([]
byte
)
bool
var
(
// Todo: Vim过滤依然存在问题
vimEnterMark
=
[]
byte
(
"
\x1b
[?25l
\x1b
[37;1H
\x1b
[1m"
)
vimExitMark
=
[]
byte
(
"
\x1b
[37;1H
\x1b
[K
\x1b
"
)
...
...
@@ -41,6 +43,8 @@ type Parser struct {
once
sync
.
Once
}
// Todo: parseMultipleInput 依然存在问题
// parseInputState 切换用户输入状态
func
(
p
*
Parser
)
parseInputState
(
b
[]
byte
)
{
if
p
.
inVimState
||
p
.
zmodemState
!=
""
{
...
...
pkg/sshd/handler/session.go
View file @
17077009
package
handler
import
(
"cocogo/pkg/proxy"
//"cocogo/pkg/proxybak"
//"cocogo/pkg/proxybak"
"context"
//"context"
//"strconv"
"fmt"
//"encoding/json"
//"fmt"
"io"
"strconv"
"strings"
//"strings"
//"strconv"
"sync"
//"time"
"github.com/ibuler/ssh"
//"github.com/olekukonko/tablewriter"
...
...
@@ -29,9 +19,9 @@ import (
"cocogo/pkg/cctx"
"cocogo/pkg/logger"
"cocogo/pkg/model"
"cocogo/pkg/proxy"
"cocogo/pkg/sdk"
"cocogo/pkg/service"
//"cocogo/pkg/proxy"
//"cocogo/pkg/transport"
//"cocogo/pkg/userhome"
)
...
...
@@ -81,33 +71,33 @@ func (i *InteractiveHandler) preDispatch() {
})
}
func
(
i
*
InteractiveHandler
)
watchWinSizeChange
(
winCh
<-
chan
ssh
.
Window
)
{
ctx
,
cancelFunc
:=
context
.
WithCancel
(
i
.
sess
.
Context
())
defer
cancelFunc
()
func
(
i
*
InteractiveHandler
)
watchWinSizeChange
(
winCh
<-
chan
ssh
.
Window
,
done
<-
chan
struct
{})
{
for
{
select
{
case
<-
ctx
.
Done
()
:
logger
.
Info
(
"Ctx
done"
)
case
<-
done
:
logger
.
Debug
(
"Interactive handler watch win size
done"
)
return
case
win
,
ok
:=
<-
winCh
:
if
!
ok
{
return
}
logger
.
Info
(
"Term change:"
,
win
)
logger
.
Debugf
(
"Term change: %d*%d"
,
win
.
Height
,
win
.
Width
)
_
=
i
.
term
.
SetSize
(
win
.
Width
,
win
.
Height
)
}
}
}
func
(
i
*
InteractiveHandler
)
Dispatch
(
ctx
c
ontext
.
Context
)
{
func
(
i
*
InteractiveHandler
)
Dispatch
(
ctx
c
ctx
.
Context
)
{
i
.
preDispatch
()
_
,
winCh
,
_
:=
i
.
sess
.
Pty
()
for
{
go
i
.
watchWinSizeChange
(
winCh
)
doneChan
:=
make
(
chan
struct
{}
)
go
i
.
watchWinSizeChange
(
winCh
,
doneChan
)
line
,
err
:=
i
.
term
.
ReadLine
()
close
(
doneChan
)
if
err
!=
nil
{
logger
.
Error
(
"Read
Line done
"
,
err
)
logger
.
Error
(
"Read
line from user err:
"
,
err
)
break
}
...
...
@@ -330,7 +320,11 @@ func (i *InteractiveHandler) searchNodeAssets(num int) (assets []sdk.Asset) {
}
func
(
i
*
InteractiveHandler
)
Proxy
(
ctx
context
.
Context
)
{
p
:=
proxy
.
ProxyServer
{
Session
:
i
.
sess
,
Asset
:
i
.
assetSelect
,
SystemUser
:
i
.
systemUserSelect
}
p
:=
proxy
.
ProxyServer
{
Session
:
i
.
sess
,
Asset
:
i
.
assetSelect
,
SystemUser
:
i
.
systemUserSelect
,
}
p
.
Proxy
(
ctx
)
}
...
...
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