mirror of
https://github.com/amitbet/vncproxy.git
synced 2025-08-27 17:48:37 +00:00
cleaning up some old comments
This commit is contained in:
parent
680859b0ad
commit
fa61227d89
@ -232,15 +232,6 @@ func (*ServerCutTextMessage) Read(conn common.IClientConn, r *common.RfbReadHelp
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//var textLength uint32
|
||||
// if err := binary.Read(r, binary.BigEndian, &textLength); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// textBytes := make([]uint8, textLength)
|
||||
// if err := binary.Read(r, binary.BigEndian, &textBytes); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
return &ServerCutTextMessage{string(textBytes)}, nil
|
||||
}
|
||||
|
@ -19,14 +19,6 @@ const (
|
||||
SegmentConnectionClosed
|
||||
)
|
||||
|
||||
// type ListenerType int
|
||||
|
||||
// const (
|
||||
// ListenerTypeRawBytes ListenerType = iota
|
||||
// ListenerTypeParsedBytes
|
||||
// ListenerTypeClientMessages
|
||||
// )
|
||||
|
||||
type SegmentType int
|
||||
|
||||
func (seg SegmentType) String() string {
|
||||
@ -190,7 +182,6 @@ func (r *RfbReadHelper) ReadTightData(dataSize int) ([]byte, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//byte[] zlibData = new byte[zlibDataLen];
|
||||
//rfb.readFully(zlibData);
|
||||
|
||||
return r.ReadBytes(zlibDataLen)
|
||||
}
|
||||
|
@ -16,19 +16,3 @@ type Rectangle struct {
|
||||
func (r *Rectangle) String() string {
|
||||
return fmt.Sprintf("(%d,%d) (width: %d, height: %d), Enc= %d", r.X, r.Y, r.Width, r.Height, r.Enc.Type())
|
||||
}
|
||||
|
||||
// PixelFormat describes the way a pixel is formatted for a VNC connection.
|
||||
//
|
||||
// See RFC 6143 Section 7.4 for information on each of the fields.
|
||||
// type PixelFormat struct {
|
||||
// BPP uint8
|
||||
// Depth uint8
|
||||
// BigEndian bool
|
||||
// TrueColor bool
|
||||
// RedMax uint16
|
||||
// GreenMax uint16
|
||||
// BlueMax uint16
|
||||
// RedShift uint8
|
||||
// GreenShift uint8
|
||||
// BlueShift uint8
|
||||
// }
|
||||
|
@ -11,13 +11,9 @@ type IClientConn interface {
|
||||
}
|
||||
|
||||
type ServerMessage interface {
|
||||
// The type of the message that is sent down on the wire.
|
||||
Type() uint8
|
||||
String() string
|
||||
CopyTo(r io.Reader, w io.Writer, c IClientConn) error
|
||||
// Read reads the contents of the message from the reader. At the point
|
||||
// this is called, the message type has already been read from the reader.
|
||||
// This should return a new ServerMessage that is the appropriate type.
|
||||
Read(IClientConn, *RfbReadHelper) (ServerMessage, error)
|
||||
}
|
||||
type ServerMessageType int8
|
||||
|
@ -10,7 +10,6 @@ type CoRREEncoding struct {
|
||||
numSubRects uint32
|
||||
backgroundColor []byte
|
||||
subRectData []byte
|
||||
//Colors []Color
|
||||
}
|
||||
|
||||
func (z *CoRREEncoding) Type() int32 {
|
||||
|
@ -47,16 +47,14 @@ func (z *HextileEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectan
|
||||
|
||||
//handle Hextile Subrect(tx, ty, tw, th):
|
||||
subencoding, err := r.ReadUint8()
|
||||
//logger.Debugf("hextile reader tile: (%d,%d) subenc=%d\n", ty, tx, subencoding)
|
||||
|
||||
if err != nil {
|
||||
logger.Errorf("HextileEncoding.Read: error in hextile reader: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if (subencoding & HextileRaw) != 0 {
|
||||
//ReadRawRect(c, rect, r)
|
||||
r.ReadBytes(tw * th * bytesPerPixel)
|
||||
//logger.Debug("hextile reader: HextileRaw\n")
|
||||
continue
|
||||
}
|
||||
if (subencoding & HextileBackgroundSpecified) != 0 {
|
||||
@ -78,16 +76,9 @@ func (z *HextileEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectan
|
||||
if (subencoding & HextileSubrectsColoured) != 0 {
|
||||
bufsize += int(nSubrects) * int(bytesPerPixel)
|
||||
}
|
||||
//byte[] buf = new byte[bufsize];
|
||||
r.ReadBytes(bufsize)
|
||||
}
|
||||
}
|
||||
|
||||
// len, _ := readUint32(c.c)
|
||||
// _, err := readBytes(c.c, int(len))
|
||||
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
return z, nil
|
||||
}
|
||||
|
@ -7,10 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// RawEncoding is raw pixel data sent by the server.
|
||||
//
|
||||
// See RFC 6143 Section 7.7.1
|
||||
type RawEncoding struct {
|
||||
//Colors []Color
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
@ -21,17 +18,9 @@ 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.Encoding, error) {
|
||||
//conn := &DataSource{conn: conn.c, PixelFormat: conn.PixelFormat}
|
||||
//conn := common.RfbReadHelper{Reader:r}
|
||||
|
||||
bytesPerPixel := int(pixelFmt.BPP / 8)
|
||||
//pixelBytes := make([]uint8, bytesPerPixel)
|
||||
|
||||
// var byteOrder binary.ByteOrder = binary.LittleEndian
|
||||
// if conn.PixelFormat.BigEndian {
|
||||
// byteOrder = binary.BigEndian
|
||||
// }
|
||||
|
||||
//colors := make([]vnc.Color, int(rect.Height)*int(rect.Width))
|
||||
bytes := &bytes.Buffer{}
|
||||
for y := uint16(0); y < rect.Height; y++ {
|
||||
for x := uint16(0); x < rect.Width; x++ {
|
||||
@ -39,24 +28,6 @@ func (*RawEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r
|
||||
StoreBytes(bytes, bts)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// var rawPixel uint32
|
||||
// if conn.PixelFormat.BPP == 8 {
|
||||
// rawPixel = uint32(pixelBytes[0])
|
||||
// } else if conn.PixelFormat.BPP == 16 {
|
||||
// rawPixel = uint32(byteOrder.Uint16(pixelBytes))
|
||||
// } else if conn.PixelFormat.BPP == 32 {
|
||||
// rawPixel = byteOrder.Uint32(pixelBytes)
|
||||
// }
|
||||
|
||||
// color := &colors[int(y)*int(rect.Width)+int(x)]
|
||||
// if conn.PixelFormat.TrueColor {
|
||||
// color.R = uint16((rawPixel >> conn.PixelFormat.RedShift) & uint32(conn.PixelFormat.RedMax))
|
||||
// color.G = uint16((rawPixel >> conn.PixelFormat.GreenShift) & uint32(conn.PixelFormat.GreenMax))
|
||||
// color.B = uint16((rawPixel >> conn.PixelFormat.BlueShift) & uint32(conn.PixelFormat.BlueMax))
|
||||
// } else {
|
||||
// *color = conn.ColorMap[rawPixel]
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package encodings
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"vncproxy/common"
|
||||
"vncproxy/logger"
|
||||
@ -24,41 +23,11 @@ const (
|
||||
|
||||
type TightEncoding struct {
|
||||
bytes []byte
|
||||
//output io.Writer
|
||||
//logger common.Logger
|
||||
}
|
||||
|
||||
// func (t *TightEncoding) SetOutput(output io.Writer) {
|
||||
// t.output = output
|
||||
// }
|
||||
|
||||
func (*TightEncoding) Type() int32 { return int32(common.EncTight) }
|
||||
|
||||
// func ReadAndRecBytes(conn io.Reader, rec io.Writer, count int) ([]byte, error) {
|
||||
// buf, err := readBytes(conn, count)
|
||||
// rec.Write(buf)
|
||||
// return buf, err
|
||||
// }
|
||||
// func ReadAndRecUint8(conn io.Reader, rec io.Writer) (uint8, error) {
|
||||
// myUint, err := readUint8(conn)
|
||||
// buf := make([]byte, 1)
|
||||
// buf[0] = byte(myUint) // cast int8 to byte
|
||||
// rec.Write(buf)
|
||||
// return myUint, err
|
||||
// }
|
||||
|
||||
// func ReadAndRecUint16(conn io.Reader, rec io.Writer) (uint16, error) {
|
||||
// myUint, err := readUint16(conn)
|
||||
// buf := make([]byte, 2)
|
||||
// //buf[0] = byte(myUint) // cast int8 to byte
|
||||
// //var i int16 = 41
|
||||
// //b := make([]byte, 2)
|
||||
// binary.LittleEndian.PutUint16(buf, uint16(myUint))
|
||||
|
||||
// rec.Write(buf)
|
||||
// return myUint, err
|
||||
// }
|
||||
|
||||
func calcTightBytePerPixel(pf *common.PixelFormat) int {
|
||||
bytesPerPixel := int(pf.BPP / 8)
|
||||
|
||||
@ -84,39 +53,34 @@ func StoreBytes(bytes *bytes.Buffer, data []byte) {
|
||||
|
||||
func (t *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.Encoding, error) {
|
||||
bytesPixel := calcTightBytePerPixel(pixelFmt)
|
||||
//conn := common.RfbReadHelper{Reader:reader}
|
||||
//conn := &DataSource{conn: conn.c, PixelFormat: conn.PixelFormat}
|
||||
|
||||
r.StartByteCollection()
|
||||
defer func() {
|
||||
t.bytes = r.EndByteCollection()
|
||||
}()
|
||||
//var subencoding uint8
|
||||
|
||||
compctl, err := r.ReadUint8()
|
||||
//binary.Write(bytes, binary.BigEndian, compctl)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("error in handling tight encoding: %v\n", err)
|
||||
logger.Debugf("error in handling tight encoding: %v\n", err)
|
||||
return nil, err
|
||||
}
|
||||
fmt.Printf("bytesPixel= %d, subencoding= %d\n", bytesPixel, compctl)
|
||||
logger.Debugf("bytesPixel= %d, subencoding= %d\n", bytesPixel, compctl)
|
||||
|
||||
//move it to position (remove zlib flush commands)
|
||||
compType := compctl >> 4 & 0x0F
|
||||
|
||||
fmt.Printf("afterSHL:%d\n", compType)
|
||||
logger.Debugf("afterSHL:%d\n", compType)
|
||||
switch compType {
|
||||
case TightFill:
|
||||
fmt.Printf("reading fill size=%d\n", bytesPixel)
|
||||
logger.Debugf("reading fill size=%d\n", bytesPixel)
|
||||
//read color
|
||||
_, err := r.ReadBytes(int(bytesPixel))
|
||||
if err != nil {
|
||||
fmt.Printf("error in handling tight encoding: %v\n", err)
|
||||
logger.Debugf("error in handling tight encoding: %v\n", err)
|
||||
return nil, err
|
||||
}
|
||||
//StoreBytes(bytes, bts)
|
||||
|
||||
//byt, _ := r.ReadBytes(3)
|
||||
//fmt.Printf(">>>>>>>>>TightFillBytes=%v", byt)
|
||||
return t, nil
|
||||
case TightJpeg:
|
||||
if pixelFmt.BPP == 8 {
|
||||
@ -124,67 +88,60 @@ func (t *TightEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangl
|
||||
}
|
||||
|
||||
len, err := r.ReadCompactLen()
|
||||
//binary.Write(bytes, binary.BigEndian, len)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Printf("reading jpeg, size=%d\n", len)
|
||||
logger.Debugf("reading jpeg, size=%d\n", len)
|
||||
_, err = r.ReadBytes(len)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//StoreBytes(bytes, bts)
|
||||
|
||||
return t, nil
|
||||
default:
|
||||
|
||||
if compType > TightJpeg {
|
||||
fmt.Println("Compression control byte is incorrect!")
|
||||
logger.Debug("Compression control byte is incorrect!")
|
||||
}
|
||||
|
||||
handleTightFilters(compctl, pixelFmt, rect, r)
|
||||
//t.bytes = bytes.Bytes()
|
||||
|
||||
return t, nil
|
||||
}
|
||||
}
|
||||
|
||||
func handleTightFilters(subencoding uint8, pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) {
|
||||
//conn := common.RfbReadHelper{Reader:reader}
|
||||
var FILTER_ID_MASK uint8 = 0x40
|
||||
//var STREAM_ID_MASK uint8 = 0x30
|
||||
|
||||
//decoderId := (subencoding & STREAM_ID_MASK) >> 4
|
||||
var FILTER_ID_MASK uint8 = 0x40
|
||||
|
||||
var filterid uint8
|
||||
var err error
|
||||
|
||||
if (subencoding & FILTER_ID_MASK) > 0 { // filter byte presence
|
||||
filterid, err = r.ReadUint8()
|
||||
//binary.Write(bytes, binary.BigEndian, filterid)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("error in handling tight encoding, reading filterid: %v\n", err)
|
||||
logger.Debugf("error in handling tight encoding, reading filterid: %v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("read filter: %d\n", filterid)
|
||||
logger.Debugf("read filter: %d\n", filterid)
|
||||
}
|
||||
|
||||
//var numColors uint8
|
||||
bytesPixel := calcTightBytePerPixel(pixelFmt)
|
||||
|
||||
fmt.Printf("filter: %d\n", filterid)
|
||||
// if rfb.rec != null {
|
||||
// rfb.rec.writeByte(filter_id)
|
||||
// }
|
||||
logger.Debugf("filter: %d\n", filterid)
|
||||
|
||||
lengthCurrentbpp := int(bytesPixel) * int(rect.Width) * int(rect.Height)
|
||||
|
||||
switch filterid {
|
||||
case TightFilterPalette: //PALETTE_FILTER
|
||||
|
||||
colorCount, err := r.ReadUint8()
|
||||
//binary.Write(bytes, binary.BigEndian, colorCount)
|
||||
paletteSize := colorCount + 1 // add one more
|
||||
fmt.Printf("----PALETTE_FILTER: paletteSize=%d bytesPixel=%d\n", paletteSize, bytesPixel)
|
||||
logger.Debugf("----PALETTE_FILTER: paletteSize=%d bytesPixel=%d\n", paletteSize, bytesPixel)
|
||||
//complete palette
|
||||
_, err = r.ReadBytes(int(paletteSize) * bytesPixel)
|
||||
//StoreBytes(bytes, bts)
|
||||
|
||||
var dataLength int
|
||||
if paletteSize == 2 {
|
||||
@ -194,179 +151,31 @@ func handleTightFilters(subencoding uint8, pixelFmt *common.PixelFormat, rect *c
|
||||
}
|
||||
_, err = r.ReadTightData(dataLength)
|
||||
if err != nil {
|
||||
fmt.Printf("error in handling tight encoding, Reading Palette: %v\n", err)
|
||||
logger.Debugf("error in handling tight encoding, Reading Palette: %v\n", err)
|
||||
return
|
||||
}
|
||||
//StoreBytes(bytes, bts)
|
||||
|
||||
case TightFilterGradient: //GRADIENT_FILTER
|
||||
fmt.Printf("----GRADIENT_FILTER: bytesPixel=%d\n", bytesPixel)
|
||||
//useGradient = true
|
||||
fmt.Printf("usegrad: %d\n", filterid)
|
||||
logger.Debugf("----GRADIENT_FILTER: bytesPixel=%d\n", bytesPixel)
|
||||
logger.Debugf("usegrad: %d\n", filterid)
|
||||
_, err := r.ReadTightData(lengthCurrentbpp)
|
||||
if err != nil {
|
||||
fmt.Printf("error in handling tight encoding, Reading GRADIENT_FILTER: %v\n", err)
|
||||
logger.Debugf("error in handling tight encoding, Reading GRADIENT_FILTER: %v\n", err)
|
||||
return
|
||||
}
|
||||
//StoreBytes(bytes, bts)
|
||||
|
||||
case TightFilterCopy: //BASIC_FILTER
|
||||
fmt.Printf("----BASIC_FILTER: bytesPixel=%d\n", bytesPixel)
|
||||
logger.Debugf("----BASIC_FILTER: bytesPixel=%d\n", bytesPixel)
|
||||
_, err := r.ReadTightData(lengthCurrentbpp)
|
||||
if err != nil {
|
||||
fmt.Printf("error in handling tight encoding, Reading BASIC_FILTER: %v\n", err)
|
||||
logger.Debugf("error in handling tight encoding, Reading BASIC_FILTER: %v\n", err)
|
||||
return
|
||||
}
|
||||
//StoreBytes(bytes, bts)
|
||||
|
||||
default:
|
||||
fmt.Printf("Bad tight filter id: %d\n", filterid)
|
||||
logger.Debugf("Bad tight filter id: %d\n", filterid)
|
||||
return
|
||||
}
|
||||
|
||||
////////////
|
||||
|
||||
// if numColors == 0 && bytesPixel == 4 {
|
||||
// rowSize1 *= 3
|
||||
// }
|
||||
// rowSize := (int(rect.Width)*bitsPixel + 7) / 8
|
||||
// dataSize := int(rect.Height) * rowSize
|
||||
|
||||
// dataSize1 := rect.Height * rowSize1
|
||||
// fmt.Printf("datasize: %d, origDatasize: %d", dataSize, dataSize1)
|
||||
// // Read, optionally uncompress and decode data.
|
||||
// if int(dataSize1) < TightMinToCompress {
|
||||
// // Data size is small - not compressed with zlib.
|
||||
// if numColors != 0 {
|
||||
// // Indexed colors.
|
||||
// //indexedData := make([]byte, dataSize)
|
||||
// readBytes(conn.c, int(dataSize1))
|
||||
// //readFully(indexedData);
|
||||
// // if (rfb.rec != null) {
|
||||
// // rfb.rec.write(indexedData);
|
||||
// // }
|
||||
// // if (numColors == 2) {
|
||||
// // // Two colors.
|
||||
// // if (bytesPixel == 1) {
|
||||
// // decodeMonoData(x, y, w, h, indexedData, palette8);
|
||||
// // } else {
|
||||
// // decodeMonoData(x, y, w, h, indexedData, palette24);
|
||||
// // }
|
||||
// // } else {
|
||||
// // // 3..255 colors (assuming bytesPixel == 4).
|
||||
// // int i = 0;
|
||||
// // for (int dy = y; dy < y + h; dy++) {
|
||||
// // for (int dx = x; dx < x + w; dx++) {
|
||||
// // pixels24[dy * rfb.framebufferWidth + dx] = palette24[indexedData[i++] & 0xFF];
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// } else if useGradient {
|
||||
// // "Gradient"-processed data
|
||||
// //buf := make ( []byte,w * h * 3);
|
||||
// dataByteCount := int(3) * int(rect.Width) * int(rect.Height)
|
||||
// readBytes(conn.c, dataByteCount)
|
||||
// // rfb.readFully(buf);
|
||||
// // if (rfb.rec != null) {
|
||||
// // rfb.rec.write(buf);
|
||||
// // }
|
||||
// // decodeGradientData(x, y, w, h, buf);
|
||||
// } else {
|
||||
// // Raw truecolor data.
|
||||
// dataByteCount := int(bytesPixel) * int(rect.Width) * int(rect.Height)
|
||||
// readBytes(conn.c, dataByteCount)
|
||||
|
||||
// // if (bytesPixel == 1) {
|
||||
// // for (int dy = y; dy < y + h; dy++) {
|
||||
|
||||
// // rfb.readFully(pixels8, dy * rfb.framebufferWidth + x, w);
|
||||
// // if (rfb.rec != null) {
|
||||
// // rfb.rec.write(pixels8, dy * rfb.framebufferWidth + x, w);
|
||||
// // }
|
||||
// // }
|
||||
// // } else {
|
||||
// // byte[] buf = new byte[w * 3];
|
||||
// // int i, offset;
|
||||
// // for (int dy = y; dy < y + h; dy++) {
|
||||
// // rfb.readFully(buf);
|
||||
// // if (rfb.rec != null) {
|
||||
// // rfb.rec.write(buf);
|
||||
// // }
|
||||
// // offset = dy * rfb.framebufferWidth + x;
|
||||
// // for (i = 0; i < w; i++) {
|
||||
// // pixels24[offset + i] = (buf[i * 3] & 0xFF) << 16 | (buf[i * 3 + 1] & 0xFF) << 8 | (buf[i * 3 + 2] & 0xFF);
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
// } else {
|
||||
// // Data was compressed with zlib.
|
||||
// zlibDataLen, err := readCompactLen(conn.c)
|
||||
// fmt.Printf("compactlen=%d\n", zlibDataLen)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// //byte[] zlibData = new byte[zlibDataLen];
|
||||
// //rfb.readFully(zlibData);
|
||||
// readBytes(conn.c, zlibDataLen)
|
||||
|
||||
// // if (rfb.rec != null) {
|
||||
// // rfb.rec.write(zlibData);
|
||||
// // }
|
||||
// // int stream_id = comp_ctl & 0x03;
|
||||
// // if (tightInflaters[stream_id] == null) {
|
||||
// // tightInflaters[stream_id] = new Inflater();
|
||||
// // }
|
||||
// // Inflater myInflater = tightInflaters[stream_id];
|
||||
// // myInflater.setInput(zlibData);
|
||||
// // byte[] buf = new byte[dataSize];
|
||||
// // myInflater.inflate(buf);
|
||||
// // if (rfb.rec != null && !rfb.recordFromBeginning) {
|
||||
// // rfb.recordCompressedData(buf);
|
||||
// // }
|
||||
|
||||
// // if (numColors != 0) {
|
||||
// // // Indexed colors.
|
||||
// // if (numColors == 2) {
|
||||
// // // Two colors.
|
||||
// // if (bytesPixel == 1) {
|
||||
// // decodeMonoData(x, y, w, h, buf, palette8);
|
||||
// // } else {
|
||||
// // decodeMonoData(x, y, w, h, buf, palette24);
|
||||
// // }
|
||||
// // } else {
|
||||
// // // More than two colors (assuming bytesPixel == 4).
|
||||
// // int i = 0;
|
||||
// // for (int dy = y; dy < y + h; dy++) {
|
||||
// // for (int dx = x; dx < x + w; dx++) {
|
||||
// // pixels24[dy * rfb.framebufferWidth + dx] = palette24[buf[i++] & 0xFF];
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// // } else if (useGradient) {
|
||||
// // // Compressed "Gradient"-filtered data (assuming bytesPixel == 4).
|
||||
// // decodeGradientData(x, y, w, h, buf);
|
||||
// // } else {
|
||||
// // // Compressed truecolor data.
|
||||
// // if (bytesPixel == 1) {
|
||||
// // int destOffset = y * rfb.framebufferWidth + x;
|
||||
// // for (int dy = 0; dy < h; dy++) {
|
||||
// // System.arraycopy(buf, dy * w, pixels8, destOffset, w);
|
||||
// // destOffset += rfb.framebufferWidth;
|
||||
// // }
|
||||
// // } else {
|
||||
// // int srcOffset = 0;
|
||||
// // int destOffset, i;
|
||||
// // for (int dy = 0; dy < h; dy++) {
|
||||
// // myInflater.inflate(buf);
|
||||
// // destOffset = (y + dy) * rfb.framebufferWidth + x;
|
||||
// // for (i = 0; i < w; i++) {
|
||||
// // pixels24[destOffset + i] = (buf[srcOffset] & 0xFF) << 16 | (buf[srcOffset + 1] & 0xFF) << 8
|
||||
// // | (buf[srcOffset + 2] & 0xFF);
|
||||
// // srcOffset += 3;
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
)
|
||||
|
||||
type ZLibEncoding struct {
|
||||
//Colors []Color
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
)
|
||||
|
||||
type ZRLEEncoding struct {
|
||||
//Colors []Color
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
@ -21,9 +20,7 @@ func (z *ZRLEEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
}
|
||||
|
||||
func (z *ZRLEEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.Encoding, error) {
|
||||
//conn := common.RfbReadHelper{Reader: r}
|
||||
//conn := &DataSource{conn: conn.c, PixelFormat: conn.PixelFormat}
|
||||
//bytesPerPixel := c.PixelFormat.BPP / 8
|
||||
|
||||
bytes := &bytes.Buffer{}
|
||||
len, err := r.ReadUint32()
|
||||
if err != nil {
|
||||
|
@ -134,12 +134,6 @@ func TestServer(t *testing.T) {
|
||||
go server.WsServe(url, cfg)
|
||||
go server.TcpServe(":5904", cfg)
|
||||
|
||||
// fbs, err := loadFbsFile("/Users/amitbet/vncRec/recording.rbs", cfg)
|
||||
// if err != nil {
|
||||
// logger.Error("TestServer.NewConnHandler: Error in loading FBS: ", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// Process messages coming in on the ClientMessage channel.
|
||||
|
||||
for {
|
||||
|
@ -36,36 +36,3 @@ func (cc *ClientUpdater) Consume(seg *common.RfbSegment) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ServerUpdater struct {
|
||||
conn *server.ServerConn
|
||||
Name string
|
||||
}
|
||||
|
||||
// Consume receives vnc-client-bound messages (Server messages) and updates the server part of the proxy
|
||||
func (p *ServerUpdater) Consume(seg *common.RfbSegment) error {
|
||||
|
||||
logger.Debugf("ServerUpdater.Consume ("+p.Name+"): got segment type=%s bytes: %v", seg.SegmentType, seg.Bytes)
|
||||
switch seg.SegmentType {
|
||||
case common.SegmentMessageSeparator:
|
||||
case common.SegmentRectSeparator:
|
||||
case common.SegmentBytes:
|
||||
// _, err := p.Writer.Write(seg.Bytes)
|
||||
// if (err != nil) {
|
||||
// logger.Errorf("WriteTo.Consume ("+p.Name+" SegmentBytes): problem writing to port: %s", err)
|
||||
// }
|
||||
// return err
|
||||
case common.SegmentFullyParsedClientMessage:
|
||||
|
||||
// clientMsg := seg.Message.(common.ClientMessage)
|
||||
// logger.Debugf("WriteTo.Consume ("+p.Name+"): got ClientMessage type=%s", clientMsg.Type())
|
||||
// err := clientMsg.Write(p.Writer)
|
||||
// if err != nil {
|
||||
// logger.Errorf("WriteTo.Consume ("+p.Name+" SegmentFullyParsedClientMessage): problem writing to port: %s", err)
|
||||
// }
|
||||
// return err
|
||||
default:
|
||||
//return errors.New("WriteTo.Consume: undefined RfbSegment type")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -13,13 +13,13 @@ type WriteTo struct {
|
||||
|
||||
func (p *WriteTo) Consume(seg *common.RfbSegment) error {
|
||||
|
||||
logger.Debugf("WriteTo.Consume ("+p.Name+"): got segment type=%s bytes: %v", seg.SegmentType, seg.Bytes)
|
||||
logger.Debugf("WriteTo.Consume ("+p.Name+"): got segment type=%s", seg.SegmentType)
|
||||
switch seg.SegmentType {
|
||||
case common.SegmentMessageSeparator:
|
||||
case common.SegmentRectSeparator:
|
||||
case common.SegmentBytes:
|
||||
_, err := p.Writer.Write(seg.Bytes)
|
||||
if (err != nil) {
|
||||
if err != nil {
|
||||
logger.Errorf("WriteTo.Consume ("+p.Name+" SegmentBytes): problem writing to port: %s", err)
|
||||
}
|
||||
return err
|
||||
@ -28,7 +28,7 @@ func (p *WriteTo) Consume(seg *common.RfbSegment) error {
|
||||
clientMsg := seg.Message.(common.ClientMessage)
|
||||
logger.Debugf("WriteTo.Consume ("+p.Name+"): got ClientMessage type=%s", clientMsg.Type())
|
||||
err := clientMsg.Write(p.Writer)
|
||||
if (err != nil) {
|
||||
if err != nil {
|
||||
logger.Errorf("WriteTo.Consume ("+p.Name+" SegmentFullyParsedClientMessage): problem writing to port: %s", err)
|
||||
}
|
||||
return err
|
||||
@ -37,25 +37,3 @@ func (p *WriteTo) Consume(seg *common.RfbSegment) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
// type SendToClientMessageChan struct {
|
||||
// Channel chan *common.ClientMessage
|
||||
// }
|
||||
|
||||
// func (p *SendToClientMessageChan) Consume(seg *common.RfbSegment) error {
|
||||
// switch seg.SegmentType {
|
||||
// case common.SegmentMessageSeparator:
|
||||
// case common.SegmentRectSeparator:
|
||||
// case common.SegmentBytes:
|
||||
// case common.SegmentFullyParsedClientMessage:
|
||||
// p.Channel <- seg.Message.(*common.ClientMessage)
|
||||
// //_, err := p.Writer.Write(seg.Bytes)
|
||||
// //return err
|
||||
|
||||
// default:
|
||||
// //return errors.New("undefined RfbSegment type")
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
Loading…
Reference in New Issue
Block a user