complete aten hermon encoding

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
Василий Толстов 2017-07-04 14:24:41 +03:00
parent 2024b32082
commit a6abedbe53
9 changed files with 476 additions and 93 deletions

View File

@ -11,7 +11,7 @@ import (
var (
// DefaultClientHandlers represents default client handlers
DefaultClientHandlers = []ClientHandler{
DefaultClientHandlers = []Handler{
&DefaultClientVersionHandler{},
&DefaultClientSecurityHandler{},
&DefaultClientClientInitHandler{},
@ -126,7 +126,7 @@ func (c *ClientConn) PixelFormat() PixelFormat {
// SetDesktopName sets desktop name
func (c *ClientConn) SetDesktopName(name []byte) {
copy(c.desktopName, name)
c.desktopName = name
}
// SetPixelFormat sets pixel format
@ -232,7 +232,7 @@ func (*DefaultClientMessageHandler) Handle(c Conn) error {
defer c.Close()
serverMessages := make(map[ServerMessageType]ServerMessage)
for _, m := range cfg.ServerMessages {
for _, m := range cfg.Messages {
serverMessages[m.Type()] = m
}
@ -282,7 +282,7 @@ func (*DefaultClientMessageHandler) Handle(c Conn) error {
// A ClientConfig structure is used to configure a ClientConn. After
// one has been passed to initialize a connection, it must not be modified.
type ClientConfig struct {
Handlers []ClientHandler
Handlers []Handler
SecurityHandlers []SecurityHandler
Encodings []Encoding
PixelFormat PixelFormat
@ -290,7 +290,7 @@ type ClientConfig struct {
ClientMessageCh chan ClientMessage
ServerMessageCh chan ServerMessage
Exclusive bool
ServerMessages []ServerMessage
Messages []ServerMessage
QuitCh chan struct{}
ErrorCh chan error
quit chan struct{}

View File

@ -5,6 +5,11 @@ import (
"fmt"
)
const (
EncAtenHermonSubrect EncodingType = 0
EncAtenHermonRaw EncodingType = 1
)
type AtenHermon struct {
_ [4]byte
AtenLength uint32
@ -15,6 +20,14 @@ type AtenHermon struct {
Encodings []Encoding
}
type AtenHermonSubrect struct {
A uint16
B uint16
Y uint8
X uint8
Data []byte
}
func (*AtenHermon) Type() EncodingType { return EncAtenHermon }
func (enc *AtenHermon) Read(c Conn, rect *Rectangle) error {
@ -72,40 +85,21 @@ func (enc *AtenHermon) Read(c Conn, rect *Rectangle) error {
aten_length -= 10 // skip
for aten_length > 0 {
switch aten_type {
case 0: //subrects
var a uint16
var b uint16
var x uint8
var y uint8
if err := binary.Read(c, binary.BigEndian, &a); err != nil {
switch EncodingType(aten_type) {
case EncAtenHermonSubrect:
encSR := &AtenHermonSubrect{}
if err := encSR.Read(c, rect); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &b); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &y); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &x); err != nil {
return err
}
data := make([]byte, 16*16*uint32(c.PixelFormat().BPP))
if err := binary.Read(c, binary.BigEndian, &data); err != nil {
return err
}
aten_length -= 6 + (16 * 16 * uint32(c.PixelFormat().BPP))
panic("subrect!")
case 1: //raw
fmt.Printf("raw reader %d %s\n", aten_length, rect)
enc.Encodings = append(enc.Encodings, encSR)
aten_length -= 6 + (16 * 16 * uint32(c.PixelFormat().BPP/8))
case EncAtenHermonRaw:
encRaw := &RawEncoding{}
if err := encRaw.Read(c, rect); err != nil {
return err
}
enc.Encodings = append(enc.Encodings, encRaw)
aten_length = 0
//aten_length -= uint32(rect.Area()) * uint32(c.PixelFormat().BPP)
aten_length -= uint32(rect.Area()) * uint32(c.PixelFormat().BPP/8)
default:
return fmt.Errorf("unknown aten hermon type %d", aten_type)
@ -115,7 +109,6 @@ func (enc *AtenHermon) Read(c Conn, rect *Rectangle) error {
if aten_length < 0 {
return fmt.Errorf("aten_len dropped below zero")
}
fmt.Printf("aten hermon readed\n")
return nil
}
@ -152,7 +145,48 @@ func (enc *AtenHermon) Write(c Conn, rect *Rectangle) error {
return err
}
}
fmt.Printf("aten hermon writed\n")
return nil
}
func (enc *AtenHermonSubrect) Type() EncodingType {
return EncAtenHermonSubrect
}
func (enc *AtenHermonSubrect) Read(c Conn, rect *Rectangle) error {
if err := binary.Read(c, binary.BigEndian, &enc.A); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &enc.B); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &enc.Y); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &enc.X); err != nil {
return err
}
enc.Data = make([]byte, 16*16*uint32(c.PixelFormat().BPP/8))
if err := binary.Read(c, binary.BigEndian, &enc.Data); err != nil {
return err
}
return nil
}
func (enc *AtenHermonSubrect) Write(c Conn, rect *Rectangle) error {
if err := binary.Write(c, binary.BigEndian, enc.A); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, enc.B); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, enc.Y); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, enc.X); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, enc.Data); err != nil {
return err
}
return nil
}

View File

@ -5,32 +5,11 @@ import (
"fmt"
)
// ClientHandler represents client handler
type ClientHandler interface {
// Handler represents handler of handshake
type Handler interface {
Handle(Conn) error
}
// ClientMessage is the interface
type ClientMessage interface {
String() string
Type() ClientMessageType
Read(Conn) (ClientMessage, error)
Write(Conn) error
}
// ServerHandler represents server handler
type ServerHandler interface {
Handle(Conn) error
}
// ServerMessage is the interface
type ServerMessage interface {
String() string
Type() ServerMessageType
Read(Conn) (ServerMessage, error)
Write(Conn) error
}
// ProtoVersionLength protocol version length
const ProtoVersionLength = 12
@ -256,27 +235,28 @@ type DefaultClientServerInitHandler struct{}
// Handle provide default server init handler
func (*DefaultClientServerInitHandler) Handle(c Conn) error {
var err error
srvInit := ServerInit{}
if err := binary.Read(c, binary.BigEndian, &srvInit.FBWidth); err != nil {
if err = binary.Read(c, binary.BigEndian, &srvInit.FBWidth); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &srvInit.FBHeight); err != nil {
if err = binary.Read(c, binary.BigEndian, &srvInit.FBHeight); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &srvInit.PixelFormat); err != nil {
if err = binary.Read(c, binary.BigEndian, &srvInit.PixelFormat); err != nil {
return err
}
if err := binary.Read(c, binary.BigEndian, &srvInit.NameLength); err != nil {
if err = binary.Read(c, binary.BigEndian, &srvInit.NameLength); err != nil {
return err
}
srvInit.NameText = make([]byte, srvInit.NameLength)
if err := binary.Read(c, binary.BigEndian, &srvInit.NameText); err != nil {
if err = binary.Read(c, binary.BigEndian, &srvInit.NameText); err != nil {
return err
}
c.SetDesktopName(srvInit.NameText)
if c.Protocol() == "aten" {
if c.Protocol() == "aten1" {
c.SetWidth(800)
c.SetHeight(600)
c.SetPixelFormat(NewPixelFormatAten())
@ -285,7 +265,7 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error {
c.SetHeight(srvInit.FBHeight)
c.SetPixelFormat(srvInit.PixelFormat)
}
if c.Protocol() == "aten" {
if c.Protocol() == "aten1" {
ikvm := struct {
_ [8]byte
IKVMVideoEnable uint8
@ -293,9 +273,11 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error {
IKVMKickEnable uint8
VUSBEnable uint8
}{}
if err := binary.Read(c, binary.BigEndian, &ikvm); err != nil {
if err = binary.Read(c, binary.BigEndian, &ikvm); err != nil {
return err
}
}
/*
caps := struct {
ServerMessagesNum uint16
ClientMessagesNum uint16
@ -306,7 +288,7 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error {
return err
}
caps.ServerMessagesNum = uint16(2)
caps.ServerMessagesNum = uint16(1)
var item [16]byte
for i := uint16(0); i < caps.ServerMessagesNum; i++ {
if err := binary.Read(c, binary.BigEndian, &item); err != nil {
@ -315,7 +297,6 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error {
fmt.Printf("server message cap %s\n", item)
}
/*
for i := uint16(0); i < caps.ClientMessagesNum; i++ {
if err := binary.Read(c, binary.BigEndian, &item); err != nil {
return err
@ -328,12 +309,11 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error {
}
fmt.Printf("encoding cap %s\n", item)
}
*/
// var pad [1]byte
// if err := binary.Read(c, binary.BigEndian, &pad); err != nil {
// return err
// }
}
}*/
return nil
}

View File

@ -4,6 +4,7 @@ import (
"encoding/binary"
"fmt"
"image"
"strings"
)
//var _ draw.Drawer = (*ServerConn)(nil)
@ -174,7 +175,7 @@ func (rect *Rectangle) Read(c Conn) error {
case EncTightPng:
rect.Enc = &TightPngEncoding{}
case EncRaw:
if c.Protocol() == "aten" {
if strings.HasPrefix(c.Protocol(), "aten") {
rect.Enc = &AtenHermon{}
} else {
rect.Enc = &RawEncoding{}

View File

@ -25,7 +25,7 @@ var (
}
)
// ClientMessageType represents a Client-to-Server RFB message type.
// ClientMessageType represents RFB message type
type ClientMessageType uint8
//go:generate stringer -type=ClientMessageType
@ -41,12 +41,10 @@ const (
ClientCutTextMsgType
)
// ServerMessageType represents a Client-to-Server RFB message type.
// ServerMessageType represents RFB message type
type ServerMessageType uint8
//go:generate stringer -type=ServerMessageType
// Client-to-Server message types.
// Server-to-Client message types
const (
FramebufferUpdateMsgType ServerMessageType = iota
SetColorMapEntriesMsgType
@ -67,6 +65,20 @@ func (srvInit ServerInit) String() string {
return fmt.Sprintf("Width: %d, Height: %d, PixelFormat: %s, NameLength: %d, MameText: %s", srvInit.FBWidth, srvInit.FBHeight, srvInit.PixelFormat, srvInit.NameLength, srvInit.NameText)
}
type ClientMessage interface {
String() string
Type() ClientMessageType
Read(Conn) (ClientMessage, error)
Write(Conn) error
}
type ServerMessage interface {
String() string
Type() ServerMessageType
Read(Conn) (ServerMessage, error)
Write(Conn) error
}
// FramebufferUpdate holds a FramebufferUpdate wire format message.
type FramebufferUpdate struct {
_ [1]byte // pad
@ -79,7 +91,7 @@ func (msg *FramebufferUpdate) String() string {
return fmt.Sprintf("rects %d rectangle[]: { %v }", msg.NumRect, msg.Rects)
}
// Type return ServerMessageType
// Type return MessageType
func (*FramebufferUpdate) Type() ServerMessageType {
return FramebufferUpdateMsgType
}
@ -137,7 +149,7 @@ func (msg *ServerCutText) String() string {
return fmt.Sprintf("lenght: %d text: %s", msg.Length, msg.Text)
}
// Type returns ServerMessageType
// Type returns MessageType
func (*ServerCutText) Type() ServerMessageType {
return ServerCutTextMsgType
}
@ -193,7 +205,7 @@ func (*Bell) String() string {
return fmt.Sprintf("bell")
}
// Type returns ServerMessageType
// Type returns MessageType
func (*Bell) Type() ServerMessageType {
return BellMsgType
}
@ -224,7 +236,7 @@ func (msg *SetColorMapEntries) String() string {
return fmt.Sprintf("first color: %d, numcolors: %d, colors[]: { %v }", msg.FirstColor, msg.ColorsNum, msg.Colors)
}
// Type returns ServerMessageType
// Type returns MessageType
func (*SetColorMapEntries) Type() ServerMessageType {
return SetColorMapEntriesMsgType
}
@ -301,7 +313,7 @@ func (msg *SetPixelFormat) String() string {
return fmt.Sprintf("%s", msg.PF)
}
// Type returns ClientMessageType
// Type returns MessageType
func (*SetPixelFormat) Type() ClientMessageType {
return SetPixelFormatMsgType
}
@ -346,7 +358,7 @@ func (msg *SetEncodings) String() string {
return fmt.Sprintf("encnum: %d, encodings[]: { %v }", msg.EncNum, msg.Encodings)
}
// Type returns ClientMessageType
// Type returns MessageType
func (*SetEncodings) Type() ClientMessageType {
return SetEncodingsMsgType
}
@ -410,7 +422,7 @@ func (msg *FramebufferUpdateRequest) String() string {
return fmt.Sprintf("incremental: %d, x: %d, y: %d, width: %d, height: %d", msg.Inc, msg.X, msg.Y, msg.Width, msg.Height)
}
// Type returns ClientMessageType
// Type returns MessageType
func (*FramebufferUpdateRequest) Type() ClientMessageType {
return FramebufferUpdateRequestMsgType
}
@ -447,7 +459,7 @@ func (msg *KeyEvent) String() string {
return fmt.Sprintf("down: %d, key: %v", msg.Down, msg.Key)
}
// Type returns ClientMessageType
// Type returns MessageType
func (*KeyEvent) Type() ClientMessageType {
return KeyEventMsgType
}
@ -483,7 +495,7 @@ func (msg *PointerEvent) String() string {
return fmt.Sprintf("mask %d, x: %d, y: %d", msg.Mask, msg.X, msg.Y)
}
// Type returns ClientMessageType
// Type returns MessageType
func (*PointerEvent) Type() ClientMessageType {
return PointerEventMsgType
}
@ -520,7 +532,7 @@ func (msg *ClientCutText) String() string {
return fmt.Sprintf("length: %d, text: %s", msg.Length, msg.Text)
}
// Type returns ClientMessageType
// Type returns MessageType
func (*ClientCutText) Type() ClientMessageType {
return ClientCutTextMsgType
}

314
messages_aten.go Normal file
View File

@ -0,0 +1,314 @@
package vnc
import (
"encoding/binary"
"fmt"
)
// Aten IKVM server message types
const (
AteniKVMFrontGroundEventMsgType ServerMessageType = 4
AteniKVMKeepAliveEventMsgType ServerMessageType = 22
AteniKVMVideoGetInfoMsgType ServerMessageType = 51
AteniKVMMouseGetInfoMsgType ServerMessageType = 55
AteniKVMSessionMessageMsgType ServerMessageType = 57
AteniKVMGetViewerLangMsgType ServerMessageType = 60
)
// Aten IKVM client message types
const (
AteniKVMKeyEventMsgType ClientMessageType = 4
AteniKVMPointerEventMsgType ClientMessageType = 5
)
// AteniKVMKeyEvent holds the wire format message
type AteniKVMKeyEvent struct {
_ [1]byte // padding
Down uint8 // down-flag
_ [2]byte // padding
Key Key // key
_ [9]byte // padding
}
// AteniKVMPointerEvent holds the wire format message
type AteniKVMPointerEvent struct {
_ [1]byte // padding
Mask uint8 // mask
X uint16 // x
Y uint16 // y
_ [11]byte // padding
}
func (msg *AteniKVMPointerEvent) String() string {
return fmt.Sprintf("mask: %d, x:%d, y:%d", msg.Mask, msg.X, msg.Y)
}
func (msg *AteniKVMPointerEvent) Type() ClientMessageType {
return AteniKVMPointerEventMsgType
}
func (*AteniKVMPointerEvent) Read(c Conn) (ClientMessage, error) {
msg := AteniKVMPointerEvent{}
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
return nil, err
}
return &msg, nil
}
func (msg *AteniKVMPointerEvent) Write(c Conn) error {
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, msg); err != nil {
return err
}
return c.Flush()
}
func (msg *AteniKVMKeyEvent) String() string {
return fmt.Sprintf("down:%d, key:%s", msg.Down, msg.Key)
}
func (msg *AteniKVMKeyEvent) Type() ClientMessageType {
return AteniKVMKeyEventMsgType
}
func (*AteniKVMKeyEvent) Read(c Conn) (ClientMessage, error) {
msg := AteniKVMKeyEvent{}
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
return nil, err
}
return &msg, nil
}
func (msg *AteniKVMKeyEvent) Write(c Conn) error {
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, msg); err != nil {
return err
}
return c.Flush()
}
// AteniKVMFrontGroundEvent unknown aten ikvm message
type AteniKVMFrontGroundEvent struct {
_ [20]byte
}
// String return string representation
func (msg *AteniKVMFrontGroundEvent) String() string {
return fmt.Sprintf("%s", msg.Type())
}
// Type return ServerMessageType
func (*AteniKVMFrontGroundEvent) Type() ServerMessageType {
return AteniKVMFrontGroundEventMsgType
}
// Read unmarshal message from conn
func (*AteniKVMFrontGroundEvent) Read(c Conn) (ServerMessage, error) {
msg := &AteniKVMFrontGroundEvent{}
var pad [20]byte
if err := binary.Read(c, binary.BigEndian, &pad); err != nil {
return nil, err
}
return msg, nil
}
// Write marshal message to conn
func (msg *AteniKVMFrontGroundEvent) Write(c Conn) error {
var pad [20]byte
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, pad); err != nil {
return err
}
return c.Flush()
}
// AteniKVMKeepAliveEvent unknown aten ikvm message
type AteniKVMKeepAliveEvent struct {
_ [1]byte
}
// String return string representation
func (msg *AteniKVMKeepAliveEvent) String() string {
return fmt.Sprintf("%s", msg.Type())
}
// Type return ServerMessageType
func (*AteniKVMKeepAliveEvent) Type() ServerMessageType {
return AteniKVMKeepAliveEventMsgType
}
// Read unmarshal message from conn
func (*AteniKVMKeepAliveEvent) Read(c Conn) (ServerMessage, error) {
msg := &AteniKVMKeepAliveEvent{}
var pad [1]byte
if err := binary.Read(c, binary.BigEndian, &pad); err != nil {
return nil, err
}
return msg, nil
}
// Write marshal message to conn
func (msg *AteniKVMKeepAliveEvent) Write(c Conn) error {
var pad [1]byte
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, pad); err != nil {
return err
}
return c.Flush()
}
// AteniKVMVideoGetInfo unknown aten ikvm message
type AteniKVMVideoGetInfo struct {
_ [20]byte
}
// String return string representation
func (msg *AteniKVMVideoGetInfo) String() string {
return fmt.Sprintf("%s", msg.Type())
}
// Type return ServerMessageType
func (*AteniKVMVideoGetInfo) Type() ServerMessageType {
return AteniKVMVideoGetInfoMsgType
}
// Read unmarshal message from conn
func (*AteniKVMVideoGetInfo) Read(c Conn) (ServerMessage, error) {
msg := &AteniKVMVideoGetInfo{}
var pad [40]byte
if err := binary.Read(c, binary.BigEndian, &pad); err != nil {
return nil, err
}
return msg, nil
}
// Write marshal message to conn
func (msg *AteniKVMVideoGetInfo) Write(c Conn) error {
var pad [4]byte
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, pad); err != nil {
return err
}
return c.Flush()
}
// AteniKVMMouseGetInfo unknown aten ikvm message
type AteniKVMMouseGetInfo struct {
_ [2]byte
}
// String return string representation
func (msg *AteniKVMMouseGetInfo) String() string {
return fmt.Sprintf("%s", msg.Type())
}
// Type return ServerMessageType
func (*AteniKVMMouseGetInfo) Type() ServerMessageType {
return AteniKVMMouseGetInfoMsgType
}
// Read unmarshal message from conn
func (*AteniKVMMouseGetInfo) Read(c Conn) (ServerMessage, error) {
msg := &AteniKVMFrontGroundEvent{}
var pad [2]byte
if err := binary.Read(c, binary.BigEndian, &pad); err != nil {
return nil, err
}
return msg, nil
}
// Write marshal message to conn
func (msg *AteniKVMMouseGetInfo) Write(c Conn) error {
var pad [2]byte
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, pad); err != nil {
return err
}
return c.Flush()
}
// AteniKVMSessionMessage unknown aten ikvm message
type AteniKVMSessionMessage struct {
_ [264]byte
}
// String return string representation
func (msg *AteniKVMSessionMessage) String() string {
return fmt.Sprintf("%s", msg.Type())
}
// Type return ServerMessageType
func (*AteniKVMSessionMessage) Type() ServerMessageType {
return AteniKVMSessionMessageMsgType
}
// Read unmarshal message from conn
func (*AteniKVMSessionMessage) Read(c Conn) (ServerMessage, error) {
msg := &AteniKVMSessionMessage{}
var pad [264]byte
if err := binary.Read(c, binary.BigEndian, &pad); err != nil {
return nil, err
}
return msg, nil
}
// Write marshal message to conn
func (msg *AteniKVMSessionMessage) Write(c Conn) error {
var pad [264]byte
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, pad); err != nil {
return err
}
return nil
}
// AteniKVMGetViewerLang unknown aten ikvm message
type AteniKVMGetViewerLang struct {
_ [8]byte
}
// String return string representation
func (msg *AteniKVMGetViewerLang) String() string {
return fmt.Sprintf("%s", msg.Type())
}
// Type return ServerMessageType
func (*AteniKVMGetViewerLang) Type() ServerMessageType {
return AteniKVMGetViewerLangMsgType
}
// Read unmarshal message from conn
func (*AteniKVMGetViewerLang) Read(c Conn) (ServerMessage, error) {
msg := &AteniKVMGetViewerLang{}
var pad [8]byte
if err := binary.Read(c, binary.BigEndian, &pad); err != nil {
return nil, err
}
return msg, nil
}
// Write marshal message to conn
func (msg *AteniKVMGetViewerLang) Write(c Conn) error {
var pad [8]byte
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
return err
}
if err := binary.Write(c, binary.BigEndian, pad); err != nil {
return err
}
return c.Flush()
}

42
messagetype_string.go Normal file
View File

@ -0,0 +1,42 @@
// Code generated by "stringer -type=MessageType"; DO NOT EDIT.
package vnc
import "fmt"
const (
_MessageType_name_0 = "SetPixelFormatMsgTypeSetColorMapEntriesMsgTypeSetEncodingsMsgTypeFramebufferUpdateRequestMsgTypeKeyEventMsgTypePointerEventMsgTypeClientCutTextMsgType"
_MessageType_name_1 = "AteniKVMKeepAliveEventMsgType"
_MessageType_name_2 = "AteniKVMVideoGetInfoMsgType"
_MessageType_name_3 = "AteniKVMMouseGetInfoMsgType"
_MessageType_name_4 = "AteniKVMSessionMessageMsgType"
_MessageType_name_5 = "AteniKVMGetViewerLangMsgType"
)
var (
_MessageType_index_0 = [...]uint8{0, 21, 46, 65, 96, 111, 130, 150}
_MessageType_index_1 = [...]uint8{0, 29}
_MessageType_index_2 = [...]uint8{0, 27}
_MessageType_index_3 = [...]uint8{0, 27}
_MessageType_index_4 = [...]uint8{0, 29}
_MessageType_index_5 = [...]uint8{0, 28}
)
func (i MessageType) String() string {
switch {
case 0 <= i && i <= 6:
return _MessageType_name_0[_MessageType_index_0[i]:_MessageType_index_0[i+1]]
case i == 22:
return _MessageType_name_1
case i == 51:
return _MessageType_name_2
case i == 55:
return _MessageType_name_3
case i == 57:
return _MessageType_name_4
case i == 60:
return _MessageType_name_5
default:
return fmt.Sprintf("MessageType(%d)", i)
}
}

View File

@ -50,10 +50,10 @@ func (auth *ClientAuthATEN) Auth(c Conn) error {
}
*/
if ((nt&0xffff0ff0)>>0 == 0xaff90fb0) || (nt <= 0 || nt > 0x1000000) {
c.SetProtoVersion("aten")
c.SetProtoVersion("aten1")
var skip [20]byte
binary.Read(c, binary.BigEndian, &skip)
fmt.Printf("skip %v\n", skip)
//fmt.Printf("skip %v\n", skip)
}
username := make([]byte, definedAuthLen)

View File

@ -91,7 +91,7 @@ func (c *ServerConn) PixelFormat() PixelFormat {
// SetDesktopName sets connection desktop name
func (c *ServerConn) SetDesktopName(name []byte) {
copy(c.desktopName, name)
c.desktopName = name
}
// SetPixelFormat sets pixel format for server conn
@ -168,7 +168,7 @@ type ServerConn struct {
var (
// DefaultServerHandlers uses default handlers for hanshake
DefaultServerHandlers = []ServerHandler{
DefaultServerHandlers = []Handler{
&DefaultServerVersionHandler{},
&DefaultServerSecurityHandler{},
&DefaultServerClientInitHandler{},
@ -179,14 +179,14 @@ var (
// ServerConfig config struct
type ServerConfig struct {
Handlers []ServerHandler
Handlers []Handler
SecurityHandlers []SecurityHandler
Encodings []Encoding
PixelFormat PixelFormat
ColorMap ColorMap
ClientMessageCh chan ClientMessage
ServerMessageCh chan ServerMessage
ClientMessages []ClientMessage
Messages []ClientMessage
DesktopName []byte
Height uint16
Width uint16
@ -250,7 +250,7 @@ func (*DefaultServerMessageHandler) Handle(c Conn) error {
defer c.Close()
clientMessages := make(map[ClientMessageType]ClientMessage)
for _, m := range cfg.ClientMessages {
for _, m := range cfg.Messages {
clientMessages[m.Type()] = m
}
wg.Add(2)