diff --git a/pkg/gateway/domain.go b/pkg/gateway/domain.go index 185fd6a..475dbed 100644 --- a/pkg/gateway/domain.go +++ b/pkg/gateway/domain.go @@ -22,7 +22,6 @@ const ( ) type DomainGateway struct { - Domain *model.Domain DstAddr string // 10.0.0.1:3389 sshClient *gossh.Client @@ -92,25 +91,6 @@ func (d *DomainGateway) getAvailableGateway() bool { d.sshClient = sshClient return true } - if d.Domain == nil { - return false - } - for i := range d.Domain.Gateways { - gateway := d.Domain.Gateways[i] - if !gateway.Protocols.IsSupportProtocol("ssh") { - continue - } - logger.Info("Try ssh dial gateway ", gateway.Name) - sshClient, err := d.createGatewaySSHClient(&gateway) - if err != nil { - logger.Errorf("Failed ssh dial %s: %s", gateway.Name, err.Error()) - continue - } - logger.Infof("Dial gateway %s success", gateway.Name) - d.sshClient = sshClient - d.SelectedGateway = &gateway - return true - } return false } func (d *DomainGateway) createGatewaySSHClient(gateway *model.Gateway) (*gossh.Client, error) { diff --git a/pkg/jms-sdk-go/model/remote_app.go b/pkg/jms-sdk-go/model/remote_app.go index 8d65c8e..d2211da 100644 --- a/pkg/jms-sdk-go/model/remote_app.go +++ b/pkg/jms-sdk-go/model/remote_app.go @@ -1,11 +1,5 @@ package model -type RemoteAppParameter struct { - Parameters string `json:"parameters"` - Program string `json:"program"` - WorkingDirectory string `json:"working_directory"` -} - type Applet struct { Id string `json:"id"` Name string `json:"name"` @@ -16,7 +10,7 @@ type AppletOption struct { Applet Applet `json:"applet"` Host Asset `json:"host"` Account Account `json:"account"` - Gateway Gateway `json:"gateway"` + Gateway *Gateway `json:"gateway"` RemoteAppOption RemoteAppCommandOption `json:"remote_app_option"` } diff --git a/pkg/session/server.go b/pkg/session/server.go index 4c588cf..62678af 100644 --- a/pkg/session/server.go +++ b/pkg/session/server.go @@ -76,8 +76,8 @@ func (s *Server) CreatByToken(ctx *gin.Context, token string) (TunnelSession, er opts = append(opts, WithAppletOption(appletOpt)) logger.Infof("Connect applet(%s) use host(%s) account (%s)", connectToken.Asset.String(), appletOpt.Host.String(), appletOpt.Account.String()) - // 连接发布机,不需要网关 - opts = append(opts, WithGateway(nil)) + // 连接发布机,需要使用发布机的网关 + opts = append(opts, WithGateway(appletOptions.Gateway)) } return s.Create(ctx, opts...) } diff --git a/pkg/session/session.go b/pkg/session/session.go index ef0d392..f30b127 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -16,7 +16,6 @@ type TunnelSession struct { Platform *model.Platform `json:"platform"` RemoteApp *model.Applet `json:"remote_app"` Permission *model.Permission `json:"permission"` - Domain *model.Domain `json:"-"` Gateway *model.Gateway `json:"-"` TerminalConfig *model.TerminalConfig `json:"-"` ExpireInfo model.ExpireInfo `json:"expire_info"` diff --git a/pkg/tunnel/server.go b/pkg/tunnel/server.go index 47018a9..003f998 100644 --- a/pkg/tunnel/server.go +++ b/pkg/tunnel/server.go @@ -152,15 +152,11 @@ func (g *GuacamoleTunnelServer) Connect(ctx *gin.Context) { for argName, argValue := range info.ExtraConfig() { conf.SetParameter(argName, argValue) } - // 设置网域网关,替换本地。 兼容云平台同步 配置网域,但网关配置为空的情况 - if (tunnelSession.Domain != nil && len(tunnelSession.Domain.Gateways) != 0) || - tunnelSession.Gateway != nil { + if tunnelSession.Gateway != nil { dstAddr := net.JoinHostPort(conf.GetParameter(guacd.Hostname), conf.GetParameter(guacd.Port)) domainGateway := gateway.DomainGateway{ - Domain: tunnelSession.Domain, - DstAddr: dstAddr, - + DstAddr: dstAddr, SelectedGateway: tunnelSession.Gateway, } if err = domainGateway.Start(); err != nil {