mirror of
https://github.com/amitbet/vncproxy.git
synced 2025-08-02 06:24:02 +00:00
Fix vscode go fmt warning
This commit is contained in:
parent
e464beb24e
commit
d9b834fb05
48
build
Executable file
48
build
Executable file
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
sum="sha1sum"
|
||||
|
||||
# VERSION=`date -u +%Y%m%d`
|
||||
VERSION="v1.02"
|
||||
LDFLAGS="-X main.VERSION=$VERSION -s -w"
|
||||
GCFLAGS=""
|
||||
|
||||
if ! hash sha1sum 2>/dev/null; then
|
||||
if ! hash shasum 2>/dev/null; then
|
||||
echo "I can't see 'sha1sum' or 'shasum'"
|
||||
echo "Please install one of them!"
|
||||
exit
|
||||
fi
|
||||
sum="shasum"
|
||||
fi
|
||||
|
||||
UPX=false
|
||||
if hash upx 2>/dev/null; then
|
||||
UPX=true
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
OSES=( linux darwin windows )
|
||||
ARCHS=(amd64 386 )
|
||||
for os in ${OSES[@]}; do
|
||||
for arch in ${ARCHS[@]}; do
|
||||
suffix=""
|
||||
if [ "$os" == "windows" ]
|
||||
then
|
||||
suffix=".exe"
|
||||
fi
|
||||
|
||||
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o ./dist/${os}_${arch}/recorder${suffix} ./recorder/cmd
|
||||
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o ./dist/${os}_${arch}/player${suffix} ./player/cmd
|
||||
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o ./dist/${os}_${arch}/proxy${suffix} ./proxy/cmd
|
||||
|
||||
if $UPX; then upx -9 client_${os}_${arch}${suffix} server_${os}_${arch}${suffix};fi
|
||||
# tar -zcf ./dist/vncproxy-${os}-${arch}-$VERSION.tar.gz ./dist/${os}_${arch}/proxy${suffix} ./dist/${os}_${arch}/player${suffix} ./dist/${os}_${arch}/recorder${suffix}
|
||||
cd dist/${os}_${arch}/
|
||||
zip -D -q -r ../vncproxy-${os}-${arch}-$VERSION.zip proxy${suffix} player${suffix} recorder${suffix}
|
||||
cd ../..
|
||||
$sum ./dist/vncproxy-${os}-${arch}-$VERSION.zip
|
||||
done
|
||||
done
|
@ -11,7 +11,8 @@ import (
|
||||
type IEncoding interface {
|
||||
// The number that uniquely identifies this encoding type.
|
||||
Type() int32
|
||||
WriteTo(w io.Writer) (n int64, err error)
|
||||
//WriteTo ...
|
||||
WriteTo(w io.Writer) (n int, err error)
|
||||
// Read reads the contents of the encoded pixel data from the reader.
|
||||
// This should return a new IEncoding implementation that contains
|
||||
// the proper data.
|
||||
|
@ -19,7 +19,7 @@ func (z *CopyRectEncoding) Type() int32 {
|
||||
}
|
||||
|
||||
//WriteTo ..
|
||||
func (z *CopyRectEncoding) WriteTo(w io.Writer) (n int64, err error) {
|
||||
func (z *CopyRectEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
binary.Write(w, binary.BigEndian, z.copyRectSrcX)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -31,6 +31,7 @@ func (z *CopyRectEncoding) WriteTo(w io.Writer) (n int64, err error) {
|
||||
return 4, nil
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (z *CopyRectEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
z.copyRectSrcX, _ = r.ReadUint16()
|
||||
z.copyRectSrcY, _ = r.ReadUint16()
|
||||
|
@ -6,16 +6,19 @@ import (
|
||||
"vncproxy/common"
|
||||
)
|
||||
|
||||
//CoRREEncoding ..
|
||||
type CoRREEncoding struct {
|
||||
numSubRects uint32
|
||||
backgroundColor []byte
|
||||
subRectData []byte
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (z *CoRREEncoding) Type() int32 {
|
||||
return 4
|
||||
}
|
||||
|
||||
//WriteTo ...
|
||||
func (z *CoRREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
binary.Write(w, binary.BigEndian, z.numSubRects)
|
||||
if err != nil {
|
||||
|
@ -6,15 +6,21 @@ import (
|
||||
"vncproxy/common"
|
||||
)
|
||||
|
||||
//EncCursorPseudo ...
|
||||
type EncCursorPseudo struct {
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (pe *EncCursorPseudo) Type() int32 {
|
||||
return int32(common.EncCursorPseudo)
|
||||
}
|
||||
func (z *EncCursorPseudo) WriteTo(w io.Writer) (n int, err error) {
|
||||
|
||||
//WriteTo ...
|
||||
func (pe *EncCursorPseudo) WriteTo(w io.Writer) (n int, err error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (pe *EncCursorPseudo) Read(pf *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
if rect.Width*rect.Height == 0 {
|
||||
return pe, nil
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"vncproxy/logger"
|
||||
)
|
||||
|
||||
//Hextile ...
|
||||
const (
|
||||
HextileRaw = 1
|
||||
HextileBackgroundSpecified = 2
|
||||
@ -14,17 +15,23 @@ const (
|
||||
HextileSubrectsColoured = 16
|
||||
)
|
||||
|
||||
//HextileEncoding ...
|
||||
type HextileEncoding struct {
|
||||
//Colors []Color
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (z *HextileEncoding) Type() int32 {
|
||||
return 5
|
||||
}
|
||||
|
||||
//WriteTo ...
|
||||
func (z *HextileEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return w.Write(z.bytes)
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (z *HextileEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
bytesPerPixel := int(pixelFmt.BPP) / 8
|
||||
|
||||
|
@ -6,17 +6,23 @@ import (
|
||||
"vncproxy/logger"
|
||||
)
|
||||
|
||||
//EncLedStatePseudo ...
|
||||
type EncLedStatePseudo struct {
|
||||
LedState uint8
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (pe *EncLedStatePseudo) Type() int32 {
|
||||
return int32(common.EncLedStatePseudo)
|
||||
}
|
||||
|
||||
//WriteTo ...
|
||||
func (pe *EncLedStatePseudo) WriteTo(w io.Writer) (n int, err error) {
|
||||
w.Write([]byte{pe.LedState})
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (pe *EncLedStatePseudo) Read(pf *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
if rect.Width*rect.Height == 0 {
|
||||
return pe, nil
|
||||
|
@ -5,16 +5,22 @@ import (
|
||||
"vncproxy/common"
|
||||
)
|
||||
|
||||
//PseudoEncoding ...
|
||||
type PseudoEncoding struct {
|
||||
Typ int32
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (pe *PseudoEncoding) Type() int32 {
|
||||
return pe.Typ
|
||||
}
|
||||
func (z *PseudoEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
|
||||
//WriteTo ...
|
||||
func (pe *PseudoEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (pe *PseudoEncoding) Read(*common.PixelFormat, *common.Rectangle, *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
return pe, nil
|
||||
}
|
||||
|
@ -11,13 +11,18 @@ type RawEncoding struct {
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
func (*RawEncoding) Type() int32 {
|
||||
//Type ...
|
||||
func (z *RawEncoding) Type() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
//WriteTo ...
|
||||
func (z *RawEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return w.Write(z.bytes)
|
||||
}
|
||||
func (*RawEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
|
||||
//Read ...
|
||||
func (z *RawEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
|
||||
bytesPerPixel := int(pixelFmt.BPP / 8)
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"vncproxy/common"
|
||||
)
|
||||
|
||||
//RREEncoding ...
|
||||
type RREEncoding struct {
|
||||
//Colors []Color
|
||||
numSubRects uint32
|
||||
@ -13,6 +14,7 @@ type RREEncoding struct {
|
||||
subRectData []byte
|
||||
}
|
||||
|
||||
//WriteTo ...
|
||||
func (z *RREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
binary.Write(w, binary.BigEndian, z.numSubRects)
|
||||
if err != nil {
|
||||
@ -33,9 +35,12 @@ func (z *RREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return b, nil
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (z *RREEncoding) Type() int32 {
|
||||
return 2
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (z *RREEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
bytesPerPixel := int(pixelFmt.BPP / 8)
|
||||
numOfSubrectangles, err := r.ReadUint32()
|
||||
|
@ -8,8 +8,10 @@ import (
|
||||
"vncproxy/logger"
|
||||
)
|
||||
|
||||
//TightMinToCompress ....
|
||||
var TightMinToCompress int = 12
|
||||
|
||||
//Tight ...
|
||||
const (
|
||||
TightExplicitFilter = 0x04
|
||||
TightFill = 0x08
|
||||
@ -21,11 +23,13 @@ const (
|
||||
TightFilterGradient = 0x02
|
||||
)
|
||||
|
||||
//TightEncoding ...
|
||||
type TightEncoding struct {
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
func (*TightEncoding) Type() int32 { return int32(common.EncTight) }
|
||||
//Type ...
|
||||
func (z *TightEncoding) Type() int32 { return int32(common.EncTight) }
|
||||
|
||||
func calcTightBytePerPixel(pf *common.PixelFormat) int {
|
||||
bytesPerPixel := int(pf.BPP / 8)
|
||||
@ -39,10 +43,12 @@ func calcTightBytePerPixel(pf *common.PixelFormat) int {
|
||||
return bytesPerPixelTight
|
||||
}
|
||||
|
||||
//WriteTo ...
|
||||
func (z *TightEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return w.Write(z.bytes)
|
||||
}
|
||||
|
||||
//StoreBytes ...
|
||||
func StoreBytes(bytes *bytes.Buffer, data []byte) {
|
||||
_, err := bytes.Write(data)
|
||||
if err != nil {
|
||||
@ -50,12 +56,12 @@ func StoreBytes(bytes *bytes.Buffer, data []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
func (z *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
bytesPixel := calcTightBytePerPixel(pixelFmt)
|
||||
|
||||
r.StartByteCollection()
|
||||
defer func() {
|
||||
t.bytes = r.EndByteCollection()
|
||||
z.bytes = r.EndByteCollection()
|
||||
}()
|
||||
|
||||
compctl, err := r.ReadUint8()
|
||||
@ -80,7 +86,7 @@ func (t *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangl
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return t, nil
|
||||
return z, nil
|
||||
case TightJpeg:
|
||||
if pixelFmt.BPP == 8 {
|
||||
return nil, errors.New("Tight encoding: JPEG is not supported in 8 bpp mode")
|
||||
@ -97,7 +103,7 @@ func (t *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangl
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return t, nil
|
||||
return z, nil
|
||||
default:
|
||||
|
||||
if compType > TightJpeg {
|
||||
@ -106,18 +112,18 @@ func (t *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangl
|
||||
|
||||
handleTightFilters(compctl, pixelFmt, rect, r)
|
||||
|
||||
return t, nil
|
||||
return z, nil
|
||||
}
|
||||
}
|
||||
|
||||
func handleTightFilters(subencoding uint8, pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) {
|
||||
|
||||
var FILTER_ID_MASK uint8 = 0x40
|
||||
var FilterIDMask uint8 = 0x40
|
||||
|
||||
var filterid uint8
|
||||
var err error
|
||||
|
||||
if (subencoding & FILTER_ID_MASK) > 0 { // filter byte presence
|
||||
if (subencoding & FilterIDMask) > 0 { // filter byte presence
|
||||
filterid, err = r.ReadUint8()
|
||||
|
||||
if err != nil {
|
||||
|
@ -7,21 +7,25 @@ import (
|
||||
"vncproxy/logger"
|
||||
)
|
||||
|
||||
//TightPngEncoding ...
|
||||
type TightPngEncoding struct {
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
//WriteTo ...
|
||||
func (z *TightPngEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return w.Write(z.bytes)
|
||||
}
|
||||
|
||||
func (*TightPngEncoding) Type() int32 { return int32(common.EncTightPng) }
|
||||
//Type ...
|
||||
func (z *TightPngEncoding) Type() int32 { return int32(common.EncTightPng) }
|
||||
|
||||
func (t *TightPngEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
//Read ...
|
||||
func (z *TightPngEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
bytesPixel := calcTightBytePerPixel(pixelFmt)
|
||||
r.StartByteCollection()
|
||||
defer func() {
|
||||
t.bytes = r.EndByteCollection()
|
||||
z.bytes = r.EndByteCollection()
|
||||
}()
|
||||
|
||||
//var subencoding uint8
|
||||
@ -42,7 +46,7 @@ func (t *TightPngEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Recta
|
||||
_, err = r.ReadBytes(len)
|
||||
|
||||
if err != nil {
|
||||
return t, err
|
||||
return z, err
|
||||
}
|
||||
|
||||
case TightFill:
|
||||
@ -50,5 +54,5 @@ func (t *TightPngEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Recta
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown tight compression %d", compType)
|
||||
}
|
||||
return t, nil
|
||||
return z, nil
|
||||
}
|
||||
|
@ -7,18 +7,22 @@ import (
|
||||
"vncproxy/common"
|
||||
)
|
||||
|
||||
//ZRLEEncoding ...
|
||||
type ZRLEEncoding struct {
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (z *ZRLEEncoding) Type() int32 {
|
||||
return 16
|
||||
}
|
||||
|
||||
//WriteTo ...
|
||||
func (z *ZRLEEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return w.Write(z.bytes)
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (z *ZRLEEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||
|
||||
bytes := &bytes.Buffer{}
|
||||
|
@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"vncproxy/common"
|
||||
)
|
||||
@ -21,10 +22,12 @@ type MsgSetPixelFormat struct {
|
||||
_ [3]byte // padding after pixel format
|
||||
}
|
||||
|
||||
func (*MsgSetPixelFormat) Type() common.ClientMessageType {
|
||||
//Type ...
|
||||
func (msg *MsgSetPixelFormat) Type() common.ClientMessageType {
|
||||
return common.SetPixelFormatMsgType
|
||||
}
|
||||
|
||||
//Write ...
|
||||
func (msg *MsgSetPixelFormat) Write(c io.Writer) error {
|
||||
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
||||
return err
|
||||
@ -58,6 +61,7 @@ type MsgSetEncodings struct {
|
||||
Encodings []common.EncodingType
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (*MsgSetEncodings) Type() common.ClientMessageType {
|
||||
return common.SetEncodingsMsgType
|
||||
}
|
||||
@ -114,10 +118,12 @@ type MsgFramebufferUpdateRequest struct {
|
||||
Width, Height uint16 // width, height
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (*MsgFramebufferUpdateRequest) Type() common.ClientMessageType {
|
||||
return common.FramebufferUpdateRequestMsgType
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (*MsgFramebufferUpdateRequest) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
msg := MsgFramebufferUpdateRequest{}
|
||||
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
|
||||
@ -126,6 +132,7 @@ func (*MsgFramebufferUpdateRequest) Read(c io.Reader) (common.ClientMessage, err
|
||||
return &msg, nil
|
||||
}
|
||||
|
||||
//Write ...
|
||||
func (msg *MsgFramebufferUpdateRequest) Write(c io.Writer) error {
|
||||
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
||||
return err
|
||||
@ -143,6 +150,7 @@ type MsgKeyEvent struct {
|
||||
Key Key // key
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (*MsgKeyEvent) Type() common.ClientMessageType {
|
||||
return common.KeyEventMsgType
|
||||
}
|
||||
@ -165,7 +173,7 @@ func (msg *MsgKeyEvent) Write(c io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MsgKeyEvent holds the wire format message.
|
||||
// MsgQEMUExtKeyEvent holds the wire format message.
|
||||
type MsgQEMUExtKeyEvent struct {
|
||||
SubmessageType uint8 // submessage type
|
||||
DownFlag uint16 // down-flag
|
||||
@ -173,10 +181,12 @@ type MsgQEMUExtKeyEvent struct {
|
||||
KeyCode uint32 // scan code
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (*MsgQEMUExtKeyEvent) Type() common.ClientMessageType {
|
||||
return common.QEMUExtendedKeyEventMsgType
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (*MsgQEMUExtKeyEvent) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
msg := MsgKeyEvent{}
|
||||
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
|
||||
@ -185,6 +195,7 @@ func (*MsgQEMUExtKeyEvent) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
return &msg, nil
|
||||
}
|
||||
|
||||
//Write ...
|
||||
func (msg *MsgQEMUExtKeyEvent) Write(c io.Writer) error {
|
||||
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
||||
return err
|
||||
@ -195,16 +206,18 @@ func (msg *MsgQEMUExtKeyEvent) Write(c io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// PointerEventMessage holds the wire format message.
|
||||
// MsgPointerEvent holds the wire format message.
|
||||
type MsgPointerEvent struct {
|
||||
Mask uint8 // button-mask
|
||||
X, Y uint16 // x-, y-position
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (*MsgPointerEvent) Type() common.ClientMessageType {
|
||||
return common.PointerEventMsgType
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (*MsgPointerEvent) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
msg := MsgPointerEvent{}
|
||||
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
|
||||
@ -223,13 +236,16 @@ func (msg *MsgPointerEvent) Write(c io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//MsgClientFence ...
|
||||
type MsgClientFence struct {
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (*MsgClientFence) Type() common.ClientMessageType {
|
||||
return common.ClientFenceMsgType
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (cf *MsgClientFence) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
bytes := make([]byte, 3)
|
||||
c.Read(bytes)
|
||||
@ -253,8 +269,9 @@ func (cf *MsgClientFence) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
return cf, nil
|
||||
}
|
||||
|
||||
func (msg *MsgClientFence) Write(c io.Writer) error {
|
||||
panic("not implemented!")
|
||||
//Write ...
|
||||
func (cf *MsgClientFence) Write(c io.Writer) error {
|
||||
return fmt.Errorf("not implemented")
|
||||
}
|
||||
|
||||
// MsgClientCutText holds the wire format message, sans the text field.
|
||||
@ -264,10 +281,12 @@ type MsgClientCutText struct {
|
||||
Text []byte
|
||||
}
|
||||
|
||||
//Type ...
|
||||
func (*MsgClientCutText) Type() common.ClientMessageType {
|
||||
return common.ClientCutTextMsgType
|
||||
}
|
||||
|
||||
//Read ...
|
||||
func (*MsgClientCutText) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
msg := MsgClientCutText{}
|
||||
var pad [3]byte
|
||||
|
@ -9,14 +9,17 @@ import (
|
||||
"vncproxy/logger"
|
||||
)
|
||||
|
||||
//ProtoVersionLength ...
|
||||
const ProtoVersionLength = 12
|
||||
|
||||
//ProtoVersion ...
|
||||
const (
|
||||
ProtoVersionUnknown = ""
|
||||
ProtoVersion33 = "RFB 003.003\n"
|
||||
ProtoVersion38 = "RFB 003.008\n"
|
||||
)
|
||||
|
||||
//ParseProtoVersion ...
|
||||
func ParseProtoVersion(pv []byte) (uint, uint, error) {
|
||||
var major, minor uint
|
||||
|
||||
@ -26,7 +29,7 @@ func ParseProtoVersion(pv []byte) (uint, uint, error) {
|
||||
|
||||
l, err := fmt.Sscanf(string(pv), "RFB %d.%d\n", &major, &minor)
|
||||
if l != 2 {
|
||||
return 0, 0, fmt.Errorf("error parsing ProtocolVersion.")
|
||||
return 0, 0, fmt.Errorf("error parsing ProtocolVersion")
|
||||
}
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
@ -35,6 +38,7 @@ func ParseProtoVersion(pv []byte) (uint, uint, error) {
|
||||
return major, minor, nil
|
||||
}
|
||||
|
||||
//ServerVersionHandler ...
|
||||
func ServerVersionHandler(cfg *ServerConfig, c *ServerConn) error {
|
||||
var version [ProtoVersionLength]byte
|
||||
if err := binary.Write(c, binary.BigEndian, []byte(ProtoVersion38)); err != nil {
|
||||
@ -143,7 +147,7 @@ func ServerServerInitHandler(cfg *ServerConfig, c *ServerConn) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := srvInit.PixelFormat.WriteTo(c); err != nil {
|
||||
if _, err := srvInit.PixelFormat.WriteTo(c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := binary.Write(c, binary.BigEndian, srvInit.NameLength); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user