mirror of
https://github.com/amitbet/vncproxy.git
synced 2025-08-05 07:49:28 +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 {
|
type IEncoding interface {
|
||||||
// The number that uniquely identifies this encoding type.
|
// The number that uniquely identifies this encoding type.
|
||||||
Type() int32
|
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.
|
// Read reads the contents of the encoded pixel data from the reader.
|
||||||
// This should return a new IEncoding implementation that contains
|
// This should return a new IEncoding implementation that contains
|
||||||
// the proper data.
|
// the proper data.
|
||||||
|
@ -19,7 +19,7 @@ func (z *CopyRectEncoding) Type() int32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//WriteTo ..
|
//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)
|
binary.Write(w, binary.BigEndian, z.copyRectSrcX)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -31,6 +31,7 @@ func (z *CopyRectEncoding) WriteTo(w io.Writer) (n int64, err error) {
|
|||||||
return 4, nil
|
return 4, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (z *CopyRectEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
func (z *CopyRectEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||||
z.copyRectSrcX, _ = r.ReadUint16()
|
z.copyRectSrcX, _ = r.ReadUint16()
|
||||||
z.copyRectSrcY, _ = r.ReadUint16()
|
z.copyRectSrcY, _ = r.ReadUint16()
|
||||||
|
@ -6,16 +6,19 @@ import (
|
|||||||
"vncproxy/common"
|
"vncproxy/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//CoRREEncoding ..
|
||||||
type CoRREEncoding struct {
|
type CoRREEncoding struct {
|
||||||
numSubRects uint32
|
numSubRects uint32
|
||||||
backgroundColor []byte
|
backgroundColor []byte
|
||||||
subRectData []byte
|
subRectData []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (z *CoRREEncoding) Type() int32 {
|
func (z *CoRREEncoding) Type() int32 {
|
||||||
return 4
|
return 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WriteTo ...
|
||||||
func (z *CoRREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
func (z *CoRREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||||
binary.Write(w, binary.BigEndian, z.numSubRects)
|
binary.Write(w, binary.BigEndian, z.numSubRects)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,15 +6,21 @@ import (
|
|||||||
"vncproxy/common"
|
"vncproxy/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//EncCursorPseudo ...
|
||||||
type EncCursorPseudo struct {
|
type EncCursorPseudo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (pe *EncCursorPseudo) Type() int32 {
|
func (pe *EncCursorPseudo) Type() int32 {
|
||||||
return int32(common.EncCursorPseudo)
|
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
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (pe *EncCursorPseudo) Read(pf *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
func (pe *EncCursorPseudo) Read(pf *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||||
if rect.Width*rect.Height == 0 {
|
if rect.Width*rect.Height == 0 {
|
||||||
return pe, nil
|
return pe, nil
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"vncproxy/logger"
|
"vncproxy/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//Hextile ...
|
||||||
const (
|
const (
|
||||||
HextileRaw = 1
|
HextileRaw = 1
|
||||||
HextileBackgroundSpecified = 2
|
HextileBackgroundSpecified = 2
|
||||||
@ -14,17 +15,23 @@ const (
|
|||||||
HextileSubrectsColoured = 16
|
HextileSubrectsColoured = 16
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//HextileEncoding ...
|
||||||
type HextileEncoding struct {
|
type HextileEncoding struct {
|
||||||
//Colors []Color
|
//Colors []Color
|
||||||
bytes []byte
|
bytes []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (z *HextileEncoding) Type() int32 {
|
func (z *HextileEncoding) Type() int32 {
|
||||||
return 5
|
return 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WriteTo ...
|
||||||
func (z *HextileEncoding) WriteTo(w io.Writer) (n int, err error) {
|
func (z *HextileEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||||
return w.Write(z.bytes)
|
return w.Write(z.bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (z *HextileEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
func (z *HextileEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||||
bytesPerPixel := int(pixelFmt.BPP) / 8
|
bytesPerPixel := int(pixelFmt.BPP) / 8
|
||||||
|
|
||||||
|
@ -6,17 +6,23 @@ import (
|
|||||||
"vncproxy/logger"
|
"vncproxy/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//EncLedStatePseudo ...
|
||||||
type EncLedStatePseudo struct {
|
type EncLedStatePseudo struct {
|
||||||
LedState uint8
|
LedState uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (pe *EncLedStatePseudo) Type() int32 {
|
func (pe *EncLedStatePseudo) Type() int32 {
|
||||||
return int32(common.EncLedStatePseudo)
|
return int32(common.EncLedStatePseudo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WriteTo ...
|
||||||
func (pe *EncLedStatePseudo) WriteTo(w io.Writer) (n int, err error) {
|
func (pe *EncLedStatePseudo) WriteTo(w io.Writer) (n int, err error) {
|
||||||
w.Write([]byte{pe.LedState})
|
w.Write([]byte{pe.LedState})
|
||||||
return 1, nil
|
return 1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (pe *EncLedStatePseudo) Read(pf *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
func (pe *EncLedStatePseudo) Read(pf *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||||
if rect.Width*rect.Height == 0 {
|
if rect.Width*rect.Height == 0 {
|
||||||
return pe, nil
|
return pe, nil
|
||||||
|
@ -5,16 +5,22 @@ import (
|
|||||||
"vncproxy/common"
|
"vncproxy/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//PseudoEncoding ...
|
||||||
type PseudoEncoding struct {
|
type PseudoEncoding struct {
|
||||||
Typ int32
|
Typ int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (pe *PseudoEncoding) Type() int32 {
|
func (pe *PseudoEncoding) Type() int32 {
|
||||||
return pe.Typ
|
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
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (pe *PseudoEncoding) Read(*common.PixelFormat, *common.Rectangle, *common.RfbReadHelper) (common.IEncoding, error) {
|
func (pe *PseudoEncoding) Read(*common.PixelFormat, *common.Rectangle, *common.RfbReadHelper) (common.IEncoding, error) {
|
||||||
return pe, nil
|
return pe, nil
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,18 @@ type RawEncoding struct {
|
|||||||
bytes []byte
|
bytes []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*RawEncoding) Type() int32 {
|
//Type ...
|
||||||
|
func (z *RawEncoding) Type() int32 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WriteTo ...
|
||||||
func (z *RawEncoding) WriteTo(w io.Writer) (n int, err error) {
|
func (z *RawEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||||
return w.Write(z.bytes)
|
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)
|
bytesPerPixel := int(pixelFmt.BPP / 8)
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"vncproxy/common"
|
"vncproxy/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//RREEncoding ...
|
||||||
type RREEncoding struct {
|
type RREEncoding struct {
|
||||||
//Colors []Color
|
//Colors []Color
|
||||||
numSubRects uint32
|
numSubRects uint32
|
||||||
@ -13,6 +14,7 @@ type RREEncoding struct {
|
|||||||
subRectData []byte
|
subRectData []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WriteTo ...
|
||||||
func (z *RREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
func (z *RREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||||
binary.Write(w, binary.BigEndian, z.numSubRects)
|
binary.Write(w, binary.BigEndian, z.numSubRects)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -33,9 +35,12 @@ func (z *RREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
|||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (z *RREEncoding) Type() int32 {
|
func (z *RREEncoding) Type() int32 {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (z *RREEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
func (z *RREEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||||
bytesPerPixel := int(pixelFmt.BPP / 8)
|
bytesPerPixel := int(pixelFmt.BPP / 8)
|
||||||
numOfSubrectangles, err := r.ReadUint32()
|
numOfSubrectangles, err := r.ReadUint32()
|
||||||
|
@ -8,8 +8,10 @@ import (
|
|||||||
"vncproxy/logger"
|
"vncproxy/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//TightMinToCompress ....
|
||||||
var TightMinToCompress int = 12
|
var TightMinToCompress int = 12
|
||||||
|
|
||||||
|
//Tight ...
|
||||||
const (
|
const (
|
||||||
TightExplicitFilter = 0x04
|
TightExplicitFilter = 0x04
|
||||||
TightFill = 0x08
|
TightFill = 0x08
|
||||||
@ -21,11 +23,13 @@ const (
|
|||||||
TightFilterGradient = 0x02
|
TightFilterGradient = 0x02
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//TightEncoding ...
|
||||||
type TightEncoding struct {
|
type TightEncoding struct {
|
||||||
bytes []byte
|
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 {
|
func calcTightBytePerPixel(pf *common.PixelFormat) int {
|
||||||
bytesPerPixel := int(pf.BPP / 8)
|
bytesPerPixel := int(pf.BPP / 8)
|
||||||
@ -39,10 +43,12 @@ func calcTightBytePerPixel(pf *common.PixelFormat) int {
|
|||||||
return bytesPerPixelTight
|
return bytesPerPixelTight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WriteTo ...
|
||||||
func (z *TightEncoding) WriteTo(w io.Writer) (n int, err error) {
|
func (z *TightEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||||
return w.Write(z.bytes)
|
return w.Write(z.bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//StoreBytes ...
|
||||||
func StoreBytes(bytes *bytes.Buffer, data []byte) {
|
func StoreBytes(bytes *bytes.Buffer, data []byte) {
|
||||||
_, err := bytes.Write(data)
|
_, err := bytes.Write(data)
|
||||||
if err != nil {
|
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)
|
bytesPixel := calcTightBytePerPixel(pixelFmt)
|
||||||
|
|
||||||
r.StartByteCollection()
|
r.StartByteCollection()
|
||||||
defer func() {
|
defer func() {
|
||||||
t.bytes = r.EndByteCollection()
|
z.bytes = r.EndByteCollection()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
compctl, err := r.ReadUint8()
|
compctl, err := r.ReadUint8()
|
||||||
@ -80,7 +86,7 @@ func (t *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangl
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return t, nil
|
return z, nil
|
||||||
case TightJpeg:
|
case TightJpeg:
|
||||||
if pixelFmt.BPP == 8 {
|
if pixelFmt.BPP == 8 {
|
||||||
return nil, errors.New("Tight encoding: JPEG is not supported in 8 bpp mode")
|
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 nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return t, nil
|
return z, nil
|
||||||
default:
|
default:
|
||||||
|
|
||||||
if compType > TightJpeg {
|
if compType > TightJpeg {
|
||||||
@ -106,18 +112,18 @@ func (t *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangl
|
|||||||
|
|
||||||
handleTightFilters(compctl, pixelFmt, rect, r)
|
handleTightFilters(compctl, pixelFmt, rect, r)
|
||||||
|
|
||||||
return t, nil
|
return z, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleTightFilters(subencoding uint8, pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) {
|
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 filterid uint8
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if (subencoding & FILTER_ID_MASK) > 0 { // filter byte presence
|
if (subencoding & FilterIDMask) > 0 { // filter byte presence
|
||||||
filterid, err = r.ReadUint8()
|
filterid, err = r.ReadUint8()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -7,21 +7,25 @@ import (
|
|||||||
"vncproxy/logger"
|
"vncproxy/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//TightPngEncoding ...
|
||||||
type TightPngEncoding struct {
|
type TightPngEncoding struct {
|
||||||
bytes []byte
|
bytes []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WriteTo ...
|
||||||
func (z *TightPngEncoding) WriteTo(w io.Writer) (n int, err error) {
|
func (z *TightPngEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||||
return w.Write(z.bytes)
|
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)
|
bytesPixel := calcTightBytePerPixel(pixelFmt)
|
||||||
r.StartByteCollection()
|
r.StartByteCollection()
|
||||||
defer func() {
|
defer func() {
|
||||||
t.bytes = r.EndByteCollection()
|
z.bytes = r.EndByteCollection()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
//var subencoding uint8
|
//var subencoding uint8
|
||||||
@ -42,7 +46,7 @@ func (t *TightPngEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Recta
|
|||||||
_, err = r.ReadBytes(len)
|
_, err = r.ReadBytes(len)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return t, err
|
return z, err
|
||||||
}
|
}
|
||||||
|
|
||||||
case TightFill:
|
case TightFill:
|
||||||
@ -50,5 +54,5 @@ func (t *TightPngEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Recta
|
|||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown tight compression %d", compType)
|
return nil, fmt.Errorf("unknown tight compression %d", compType)
|
||||||
}
|
}
|
||||||
return t, nil
|
return z, nil
|
||||||
}
|
}
|
||||||
|
@ -7,18 +7,22 @@ import (
|
|||||||
"vncproxy/common"
|
"vncproxy/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//ZRLEEncoding ...
|
||||||
type ZRLEEncoding struct {
|
type ZRLEEncoding struct {
|
||||||
bytes []byte
|
bytes []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (z *ZRLEEncoding) Type() int32 {
|
func (z *ZRLEEncoding) Type() int32 {
|
||||||
return 16
|
return 16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WriteTo ...
|
||||||
func (z *ZRLEEncoding) WriteTo(w io.Writer) (n int, err error) {
|
func (z *ZRLEEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||||
return w.Write(z.bytes)
|
return w.Write(z.bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (z *ZRLEEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
func (z *ZRLEEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
|
||||||
|
|
||||||
bytes := &bytes.Buffer{}
|
bytes := &bytes.Buffer{}
|
||||||
|
@ -2,6 +2,7 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"vncproxy/common"
|
"vncproxy/common"
|
||||||
)
|
)
|
||||||
@ -21,10 +22,12 @@ type MsgSetPixelFormat struct {
|
|||||||
_ [3]byte // padding after pixel format
|
_ [3]byte // padding after pixel format
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*MsgSetPixelFormat) Type() common.ClientMessageType {
|
//Type ...
|
||||||
|
func (msg *MsgSetPixelFormat) Type() common.ClientMessageType {
|
||||||
return common.SetPixelFormatMsgType
|
return common.SetPixelFormatMsgType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Write ...
|
||||||
func (msg *MsgSetPixelFormat) Write(c io.Writer) error {
|
func (msg *MsgSetPixelFormat) Write(c io.Writer) error {
|
||||||
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -58,6 +61,7 @@ type MsgSetEncodings struct {
|
|||||||
Encodings []common.EncodingType
|
Encodings []common.EncodingType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (*MsgSetEncodings) Type() common.ClientMessageType {
|
func (*MsgSetEncodings) Type() common.ClientMessageType {
|
||||||
return common.SetEncodingsMsgType
|
return common.SetEncodingsMsgType
|
||||||
}
|
}
|
||||||
@ -114,10 +118,12 @@ type MsgFramebufferUpdateRequest struct {
|
|||||||
Width, Height uint16 // width, height
|
Width, Height uint16 // width, height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (*MsgFramebufferUpdateRequest) Type() common.ClientMessageType {
|
func (*MsgFramebufferUpdateRequest) Type() common.ClientMessageType {
|
||||||
return common.FramebufferUpdateRequestMsgType
|
return common.FramebufferUpdateRequestMsgType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (*MsgFramebufferUpdateRequest) Read(c io.Reader) (common.ClientMessage, error) {
|
func (*MsgFramebufferUpdateRequest) Read(c io.Reader) (common.ClientMessage, error) {
|
||||||
msg := MsgFramebufferUpdateRequest{}
|
msg := MsgFramebufferUpdateRequest{}
|
||||||
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
|
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
|
return &msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Write ...
|
||||||
func (msg *MsgFramebufferUpdateRequest) Write(c io.Writer) error {
|
func (msg *MsgFramebufferUpdateRequest) Write(c io.Writer) error {
|
||||||
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -143,6 +150,7 @@ type MsgKeyEvent struct {
|
|||||||
Key Key // key
|
Key Key // key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (*MsgKeyEvent) Type() common.ClientMessageType {
|
func (*MsgKeyEvent) Type() common.ClientMessageType {
|
||||||
return common.KeyEventMsgType
|
return common.KeyEventMsgType
|
||||||
}
|
}
|
||||||
@ -165,7 +173,7 @@ func (msg *MsgKeyEvent) Write(c io.Writer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgKeyEvent holds the wire format message.
|
// MsgQEMUExtKeyEvent holds the wire format message.
|
||||||
type MsgQEMUExtKeyEvent struct {
|
type MsgQEMUExtKeyEvent struct {
|
||||||
SubmessageType uint8 // submessage type
|
SubmessageType uint8 // submessage type
|
||||||
DownFlag uint16 // down-flag
|
DownFlag uint16 // down-flag
|
||||||
@ -173,10 +181,12 @@ type MsgQEMUExtKeyEvent struct {
|
|||||||
KeyCode uint32 // scan code
|
KeyCode uint32 // scan code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (*MsgQEMUExtKeyEvent) Type() common.ClientMessageType {
|
func (*MsgQEMUExtKeyEvent) Type() common.ClientMessageType {
|
||||||
return common.QEMUExtendedKeyEventMsgType
|
return common.QEMUExtendedKeyEventMsgType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (*MsgQEMUExtKeyEvent) Read(c io.Reader) (common.ClientMessage, error) {
|
func (*MsgQEMUExtKeyEvent) Read(c io.Reader) (common.ClientMessage, error) {
|
||||||
msg := MsgKeyEvent{}
|
msg := MsgKeyEvent{}
|
||||||
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
|
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
|
return &msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Write ...
|
||||||
func (msg *MsgQEMUExtKeyEvent) Write(c io.Writer) error {
|
func (msg *MsgQEMUExtKeyEvent) Write(c io.Writer) error {
|
||||||
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -195,16 +206,18 @@ func (msg *MsgQEMUExtKeyEvent) Write(c io.Writer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PointerEventMessage holds the wire format message.
|
// MsgPointerEvent holds the wire format message.
|
||||||
type MsgPointerEvent struct {
|
type MsgPointerEvent struct {
|
||||||
Mask uint8 // button-mask
|
Mask uint8 // button-mask
|
||||||
X, Y uint16 // x-, y-position
|
X, Y uint16 // x-, y-position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (*MsgPointerEvent) Type() common.ClientMessageType {
|
func (*MsgPointerEvent) Type() common.ClientMessageType {
|
||||||
return common.PointerEventMsgType
|
return common.PointerEventMsgType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (*MsgPointerEvent) Read(c io.Reader) (common.ClientMessage, error) {
|
func (*MsgPointerEvent) Read(c io.Reader) (common.ClientMessage, error) {
|
||||||
msg := MsgPointerEvent{}
|
msg := MsgPointerEvent{}
|
||||||
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
|
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
|
||||||
@ -223,13 +236,16 @@ func (msg *MsgPointerEvent) Write(c io.Writer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//MsgClientFence ...
|
||||||
type MsgClientFence struct {
|
type MsgClientFence struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (*MsgClientFence) Type() common.ClientMessageType {
|
func (*MsgClientFence) Type() common.ClientMessageType {
|
||||||
return common.ClientFenceMsgType
|
return common.ClientFenceMsgType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (cf *MsgClientFence) Read(c io.Reader) (common.ClientMessage, error) {
|
func (cf *MsgClientFence) Read(c io.Reader) (common.ClientMessage, error) {
|
||||||
bytes := make([]byte, 3)
|
bytes := make([]byte, 3)
|
||||||
c.Read(bytes)
|
c.Read(bytes)
|
||||||
@ -253,8 +269,9 @@ func (cf *MsgClientFence) Read(c io.Reader) (common.ClientMessage, error) {
|
|||||||
return cf, nil
|
return cf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msg *MsgClientFence) Write(c io.Writer) error {
|
//Write ...
|
||||||
panic("not implemented!")
|
func (cf *MsgClientFence) Write(c io.Writer) error {
|
||||||
|
return fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgClientCutText holds the wire format message, sans the text field.
|
// MsgClientCutText holds the wire format message, sans the text field.
|
||||||
@ -264,10 +281,12 @@ type MsgClientCutText struct {
|
|||||||
Text []byte
|
Text []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Type ...
|
||||||
func (*MsgClientCutText) Type() common.ClientMessageType {
|
func (*MsgClientCutText) Type() common.ClientMessageType {
|
||||||
return common.ClientCutTextMsgType
|
return common.ClientCutTextMsgType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Read ...
|
||||||
func (*MsgClientCutText) Read(c io.Reader) (common.ClientMessage, error) {
|
func (*MsgClientCutText) Read(c io.Reader) (common.ClientMessage, error) {
|
||||||
msg := MsgClientCutText{}
|
msg := MsgClientCutText{}
|
||||||
var pad [3]byte
|
var pad [3]byte
|
||||||
|
@ -9,14 +9,17 @@ import (
|
|||||||
"vncproxy/logger"
|
"vncproxy/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//ProtoVersionLength ...
|
||||||
const ProtoVersionLength = 12
|
const ProtoVersionLength = 12
|
||||||
|
|
||||||
|
//ProtoVersion ...
|
||||||
const (
|
const (
|
||||||
ProtoVersionUnknown = ""
|
ProtoVersionUnknown = ""
|
||||||
ProtoVersion33 = "RFB 003.003\n"
|
ProtoVersion33 = "RFB 003.003\n"
|
||||||
ProtoVersion38 = "RFB 003.008\n"
|
ProtoVersion38 = "RFB 003.008\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//ParseProtoVersion ...
|
||||||
func ParseProtoVersion(pv []byte) (uint, uint, error) {
|
func ParseProtoVersion(pv []byte) (uint, uint, error) {
|
||||||
var major, minor uint
|
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)
|
l, err := fmt.Sscanf(string(pv), "RFB %d.%d\n", &major, &minor)
|
||||||
if l != 2 {
|
if l != 2 {
|
||||||
return 0, 0, fmt.Errorf("error parsing ProtocolVersion.")
|
return 0, 0, fmt.Errorf("error parsing ProtocolVersion")
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
@ -35,6 +38,7 @@ func ParseProtoVersion(pv []byte) (uint, uint, error) {
|
|||||||
return major, minor, nil
|
return major, minor, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ServerVersionHandler ...
|
||||||
func ServerVersionHandler(cfg *ServerConfig, c *ServerConn) error {
|
func ServerVersionHandler(cfg *ServerConfig, c *ServerConn) error {
|
||||||
var version [ProtoVersionLength]byte
|
var version [ProtoVersionLength]byte
|
||||||
if err := binary.Write(c, binary.BigEndian, []byte(ProtoVersion38)); err != nil {
|
if err := binary.Write(c, binary.BigEndian, []byte(ProtoVersion38)); err != nil {
|
||||||
@ -143,7 +147,7 @@ func ServerServerInitHandler(cfg *ServerConfig, c *ServerConn) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := srvInit.PixelFormat.WriteTo(c); err != nil {
|
if _, err := srvInit.PixelFormat.WriteTo(c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := binary.Write(c, binary.BigEndian, srvInit.NameLength); err != nil {
|
if err := binary.Write(c, binary.BigEndian, srvInit.NameLength); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user