mirror of
https://github.com/amitbet/vncproxy.git
synced 2025-09-03 22:24:25 +00:00
Merge 70a32ad4e0
into ea8f9b5109
This commit is contained in:
@@ -25,7 +25,7 @@ type VncProxy struct {
|
|||||||
sessionManager *SessionManager
|
sessionManager *SessionManager
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vp *VncProxy) createClientConnection(target string, vncPass string) (*client.ClientConn, error) {
|
func (vp *VncProxy) createClientConnection(target string, vncPass string, shared bool) (*client.ClientConn, error) {
|
||||||
var (
|
var (
|
||||||
nc net.Conn
|
nc net.Conn
|
||||||
err error
|
err error
|
||||||
@@ -48,7 +48,7 @@ func (vp *VncProxy) createClientConnection(target string, vncPass string) (*clie
|
|||||||
clientConn, err := client.NewClientConn(nc,
|
clientConn, err := client.NewClientConn(nc,
|
||||||
&client.ClientConfig{
|
&client.ClientConfig{
|
||||||
Auth: authArr,
|
Auth: authArr,
|
||||||
Exclusive: true,
|
Exclusive: !shared, // Use the shared flag from the client
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -100,7 +100,7 @@ func (vp *VncProxy) newServerConnHandler(cfg *server.ServerConfig, sconn *server
|
|||||||
target = session.TargetHostname + ":" + session.TargetPort
|
target = session.TargetHostname + ":" + session.TargetPort
|
||||||
}
|
}
|
||||||
|
|
||||||
cconn, err := vp.createClientConnection(target, session.TargetPassword)
|
cconn, err := vp.createClientConnection(target, session.TargetPassword, sconn.IsShared())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.Status = SessionStatusError
|
session.Status = SessionStatusError
|
||||||
logger.Errorf("Proxy.newServerConnHandler error creating connection: %s", err)
|
logger.Errorf("Proxy.newServerConnHandler error creating connection: %s", err)
|
||||||
|
@@ -346,10 +346,7 @@ func ServerClientInitHandler(cfg *ServerConfig, c *ServerConn) error {
|
|||||||
if err := binary.Read(c, binary.BigEndian, &shared); err != nil {
|
if err := binary.Read(c, binary.BigEndian, &shared); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
/* TODO
|
isShared := (shared & 1) != 0
|
||||||
if shared != 1 {
|
c.SetShared(isShared)
|
||||||
c.SetShared(false)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,9 @@ type ServerConn struct {
|
|||||||
// Width of the frame buffer in pixels, sent to the client.
|
// Width of the frame buffer in pixels, sent to the client.
|
||||||
fbWidth uint16
|
fbWidth uint16
|
||||||
|
|
||||||
|
// Flag indicating if the connection is shared with other clients
|
||||||
|
shared bool
|
||||||
|
|
||||||
// The pixel format associated with the connection. This shouldn't
|
// The pixel format associated with the connection. This shouldn't
|
||||||
// be modified. If you wish to set a new pixel format, use the
|
// be modified. If you wish to set a new pixel format, use the
|
||||||
// SetPixelFormat method.
|
// SetPixelFormat method.
|
||||||
@@ -147,6 +150,14 @@ func (c *ServerConn) SetHeight(h uint16) {
|
|||||||
c.fbHeight = h
|
c.fbHeight = h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ServerConn) SetShared(shared bool) {
|
||||||
|
c.shared = shared
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ServerConn) IsShared() bool {
|
||||||
|
return c.shared
|
||||||
|
}
|
||||||
|
|
||||||
func (c *ServerConn) handle() error {
|
func (c *ServerConn) handle() error {
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@@ -89,6 +89,11 @@ func attachNewServerConn(c io.ReadWriter, cfg *ServerConfig, sessionId string) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := ServerClientInitHandler(cfg, conn); err != nil {
|
||||||
|
conn.Close()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
//run the handler for this new incoming connection from a vnc-client
|
//run the handler for this new incoming connection from a vnc-client
|
||||||
//this is done before the init sequence to allow listening to server-init messages (and maybe even interception in the future)
|
//this is done before the init sequence to allow listening to server-init messages (and maybe even interception in the future)
|
||||||
err = cfg.NewConnHandler(cfg, conn)
|
err = cfg.NewConnHandler(cfg, conn)
|
||||||
@@ -97,10 +102,6 @@ func attachNewServerConn(c io.ReadWriter, cfg *ServerConfig, sessionId string) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ServerClientInitHandler(cfg, conn); err != nil {
|
|
||||||
conn.Close()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := ServerServerInitHandler(cfg, conn); err != nil {
|
if err := ServerServerInitHandler(cfg, conn); err != nil {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
Reference in New Issue
Block a user