add security handler info to connection

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
Василий Толстов 2017-07-05 16:08:27 +03:00
parent f77f8cec13
commit 88b99c68a5
4 changed files with 30 additions and 1 deletions

View File

@ -165,6 +165,17 @@ func (c *ClientConn) SetHeight(height uint16) {
c.fbHeight = height
}
// SecurityHandler returns security handler
func (c *ClientConn) SecurityHandler() SecurityHandler {
return c.securityHandler
}
// SetSecurityHandler sets security handler
func (c *ClientConn) SetSecurityHandler(sechandler SecurityHandler) error {
c.securityHandler = sechandler
return nil
}
// The ClientConn type holds client connection information
type ClientConn struct {
c net.Conn
@ -186,6 +197,8 @@ type ClientConn struct {
// directly. Instead, SetEncodings() should be used.
encodings []Encoding
securityHandler SecurityHandler
// Height of the frame buffer in pixels, sent from the server.
fbHeight uint16

View File

@ -26,4 +26,6 @@ type Conn interface {
Flush() error
Wait()
SetProtoVersion(string)
SetSecurityHandler(SecurityHandler) error
SecurityHandler() SecurityHandler
}

View File

@ -165,7 +165,7 @@ func (*DefaultClientSecurityHandler) Handle(c Conn) error {
}
return fmt.Errorf("%s", reasonText)
}
c.SetSecurityHandler(secType)
return nil
}
@ -227,6 +227,7 @@ func (*DefaultServerSecurityHandler) Handle(c Conn) error {
}
return authErr
}
c.SetSecurityHandler(sType)
return nil
}

View File

@ -120,6 +120,17 @@ func (c *ServerConn) Protocol() string {
return c.protocol
}
// SecurityHandler returns security handler
func (c *ServerConn) SecurityHandler() SecurityHandler {
return c.securityHandler
}
// SetSecurityHandler sets security handler
func (c *ServerConn) SetSecurityHandler(sechandler SecurityHandler) error {
c.securityHandler = sechandler
return nil
}
// SetWidth sets framebuffer width
func (c *ServerConn) SetWidth(w uint16) {
// TODO send desktopsize pseudo encoding
@ -152,6 +163,8 @@ type ServerConn struct {
// directly. Instead, SetEncodings() should be used.
encodings []Encoding
securityHandler SecurityHandler
// Height of the frame buffer in pixels, sent to the client.
fbHeight uint16