Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
int7 committed Oct 12, 2023
1 parent ea97129 commit db4cfea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
49 changes: 25 additions & 24 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,34 +593,35 @@ func (svr *Service) HandleSSHListener(listener net.Listener) {
ss.Run()

go func() {
pxyCfg := <-pxyPayloadCh

ctx := context.Background()

vs, err := NewVirtualService(
ctx,
v1.ClientCommonConfig{},
*svr.cfg,
svr.rc,
pxyCfg,
ss,
replyCh,
)
if err != nil {
log.Error("new virtual service error: %v", err)
ss.Close()
return
}
for {
pxyCfg := <-pxyPayloadCh

ctx := context.Background()

vs, err := NewVirtualService(
ctx,
v1.ClientCommonConfig{},
*svr.cfg,
svr.rc,
pxyCfg,
ss,
replyCh,
)
if err != nil {
log.Error("new virtual service error: %v", err)
ss.Close()
return
}

err = vs.Run(ctx)
if err != nil {
log.Error("proxy run error: %v", err)
vs.Close()
return
err = vs.Run(ctx)
if err != nil {
log.Error("proxy run error: %v", err)
vs.Close()
return
}
}
}()
}

}

func (svr *Service) HandleQUICListener(l *quic.Listener) {
Expand Down
9 changes: 3 additions & 6 deletions server/ssh_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ type SSHService struct {
addrPayloadCh chan SSHCmdPayload
extraPayloadCh chan SSHExtraPayload

// 拼装成 frpc 的 proxy pattern
// !!! 外面传入
proxyPayloadCh chan v1.ProxyConfigurer
replyCh chan interface{}

Expand Down Expand Up @@ -190,7 +188,7 @@ func (ss *SSHService) loopParseCmdPayload() {
}

func (ss *SSHService) loopSendHeartbeat(ch ssh.Channel) {
tk := time.NewTicker(time.Second * 10)
tk := time.NewTicker(time.Second * 60)
defer tk.Stop()

for {
Expand Down Expand Up @@ -318,12 +316,12 @@ func (ss *SSHService) loopGenerateProxy() {
}
}()

wg.Wait()

if atomic.LoadInt32(&ss.exit) == 1 {
return
}

wg.Wait()

// TODO 判断是什么类型的服务,然后赋值
ss.proxyPayloadCh <- &v1.TCPProxyConfig{
ProxyBaseConfig: v1.ProxyBaseConfig{
Expand Down Expand Up @@ -368,7 +366,6 @@ func parseSSHExtraMessage(s string) (p SSHExtraPayload, err error) {
Port: uint32(port),
}
case "http":
default:
}

return p, nil
Expand Down

0 comments on commit db4cfea

Please sign in to comment.