FrameBuffer proto working

This commit is contained in:
Sibesh Kar 2019-07-14 14:38:30 +05:30
parent 038d72a911
commit f0ae005ead
12 changed files with 459 additions and 69 deletions

View File

@ -6,3 +6,4 @@ run_rec:
clear: clear:
rm -rf bin/recordings/* rm -rf bin/recordings/*
rm -rf output.txt

Binary file not shown.

Binary file not shown.

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"io" "io"
"strings" "strings"
"github.com/amitbet/vncproxy/common" "github.com/amitbet/vncproxy/common"
"github.com/amitbet/vncproxy/encodings" "github.com/amitbet/vncproxy/encodings"
"github.com/amitbet/vncproxy/logger" "github.com/amitbet/vncproxy/logger"

View File

@ -28,6 +28,7 @@ type InitMsg struct {
SecType uint32 `protobuf:"varint,5,opt,name=SecType,json=secType,proto3" json:"SecType,omitempty"` SecType uint32 `protobuf:"varint,5,opt,name=SecType,json=secType,proto3" json:"SecType,omitempty"`
StartTime uint32 `protobuf:"varint,6,opt,name=StartTime,json=startTime,proto3" json:"StartTime,omitempty"` StartTime uint32 `protobuf:"varint,6,opt,name=StartTime,json=startTime,proto3" json:"StartTime,omitempty"`
DesktopName string `protobuf:"bytes,7,opt,name=DesktopName,json=desktopName,proto3" json:"DesktopName,omitempty"` DesktopName string `protobuf:"bytes,7,opt,name=DesktopName,json=desktopName,proto3" json:"DesktopName,omitempty"`
PixelFormat string `protobuf:"bytes,8,opt,name=PixelFormat,json=pixelFormat,proto3" json:"PixelFormat,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -107,6 +108,13 @@ func (m *InitMsg) GetDesktopName() string {
return "" return ""
} }
func (m *InitMsg) GetPixelFormat() string {
if m != nil {
return m.PixelFormat
}
return ""
}
type PointerEvent struct { type PointerEvent struct {
Mask uint32 `protobuf:"varint,1,opt,name=Mask,json=mask,proto3" json:"Mask,omitempty"` Mask uint32 `protobuf:"varint,1,opt,name=Mask,json=mask,proto3" json:"Mask,omitempty"`
X uint32 `protobuf:"varint,2,opt,name=X,json=x,proto3" json:"X,omitempty"` X uint32 `protobuf:"varint,2,opt,name=X,json=x,proto3" json:"X,omitempty"`
@ -272,11 +280,249 @@ func (m *FbsSegment) GetTimestamp() uint32 {
return 0 return 0
} }
type PixelFormat struct {
BPP uint32 `protobuf:"varint,1,opt,name=BPP,json=bPP,proto3" json:"BPP,omitempty"`
Depth uint32 `protobuf:"varint,2,opt,name=Depth,json=depth,proto3" json:"Depth,omitempty"`
BigEndian uint32 `protobuf:"varint,3,opt,name=BigEndian,json=bigEndian,proto3" json:"BigEndian,omitempty"`
TrueColor uint32 `protobuf:"varint,4,opt,name=TrueColor,json=trueColor,proto3" json:"TrueColor,omitempty"`
RedMax uint32 `protobuf:"varint,5,opt,name=RedMax,json=redMax,proto3" json:"RedMax,omitempty"`
GreenMax uint32 `protobuf:"varint,6,opt,name=GreenMax,json=greenMax,proto3" json:"GreenMax,omitempty"`
BlueMax uint32 `protobuf:"varint,7,opt,name=BlueMax,json=blueMax,proto3" json:"BlueMax,omitempty"`
RedShift uint32 `protobuf:"varint,8,opt,name=RedShift,json=redShift,proto3" json:"RedShift,omitempty"`
GreenShift uint32 `protobuf:"varint,9,opt,name=GreenShift,json=greenShift,proto3" json:"GreenShift,omitempty"`
BlueShift uint32 `protobuf:"varint,10,opt,name=BlueShift,json=blueShift,proto3" json:"BlueShift,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PixelFormat) Reset() { *m = PixelFormat{} }
func (m *PixelFormat) String() string { return proto.CompactTextString(m) }
func (*PixelFormat) ProtoMessage() {}
func (*PixelFormat) Descriptor() ([]byte, []int) {
return fileDescriptor_ca53982754088a9d, []int{4}
}
func (m *PixelFormat) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PixelFormat.Unmarshal(m, b)
}
func (m *PixelFormat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PixelFormat.Marshal(b, m, deterministic)
}
func (m *PixelFormat) XXX_Merge(src proto.Message) {
xxx_messageInfo_PixelFormat.Merge(m, src)
}
func (m *PixelFormat) XXX_Size() int {
return xxx_messageInfo_PixelFormat.Size(m)
}
func (m *PixelFormat) XXX_DiscardUnknown() {
xxx_messageInfo_PixelFormat.DiscardUnknown(m)
}
var xxx_messageInfo_PixelFormat proto.InternalMessageInfo
func (m *PixelFormat) GetBPP() uint32 {
if m != nil {
return m.BPP
}
return 0
}
func (m *PixelFormat) GetDepth() uint32 {
if m != nil {
return m.Depth
}
return 0
}
func (m *PixelFormat) GetBigEndian() uint32 {
if m != nil {
return m.BigEndian
}
return 0
}
func (m *PixelFormat) GetTrueColor() uint32 {
if m != nil {
return m.TrueColor
}
return 0
}
func (m *PixelFormat) GetRedMax() uint32 {
if m != nil {
return m.RedMax
}
return 0
}
func (m *PixelFormat) GetGreenMax() uint32 {
if m != nil {
return m.GreenMax
}
return 0
}
func (m *PixelFormat) GetBlueMax() uint32 {
if m != nil {
return m.BlueMax
}
return 0
}
func (m *PixelFormat) GetRedShift() uint32 {
if m != nil {
return m.RedShift
}
return 0
}
func (m *PixelFormat) GetGreenShift() uint32 {
if m != nil {
return m.GreenShift
}
return 0
}
func (m *PixelFormat) GetBlueShift() uint32 {
if m != nil {
return m.BlueShift
}
return 0
}
type Rectangle struct {
X uint32 `protobuf:"varint,1,opt,name=X,json=x,proto3" json:"X,omitempty"`
Y uint32 `protobuf:"varint,2,opt,name=Y,json=y,proto3" json:"Y,omitempty"`
Width uint32 `protobuf:"varint,3,opt,name=Width,json=width,proto3" json:"Width,omitempty"`
Height uint32 `protobuf:"varint,4,opt,name=Height,json=height,proto3" json:"Height,omitempty"`
Enc uint32 `protobuf:"varint,5,opt,name=Enc,json=enc,proto3" json:"Enc,omitempty"`
Bytes []byte `protobuf:"bytes,6,opt,name=Bytes,json=bytes,proto3" json:"Bytes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Rectangle) Reset() { *m = Rectangle{} }
func (m *Rectangle) String() string { return proto.CompactTextString(m) }
func (*Rectangle) ProtoMessage() {}
func (*Rectangle) Descriptor() ([]byte, []int) {
return fileDescriptor_ca53982754088a9d, []int{5}
}
func (m *Rectangle) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Rectangle.Unmarshal(m, b)
}
func (m *Rectangle) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Rectangle.Marshal(b, m, deterministic)
}
func (m *Rectangle) XXX_Merge(src proto.Message) {
xxx_messageInfo_Rectangle.Merge(m, src)
}
func (m *Rectangle) XXX_Size() int {
return xxx_messageInfo_Rectangle.Size(m)
}
func (m *Rectangle) XXX_DiscardUnknown() {
xxx_messageInfo_Rectangle.DiscardUnknown(m)
}
var xxx_messageInfo_Rectangle proto.InternalMessageInfo
func (m *Rectangle) GetX() uint32 {
if m != nil {
return m.X
}
return 0
}
func (m *Rectangle) GetY() uint32 {
if m != nil {
return m.Y
}
return 0
}
func (m *Rectangle) GetWidth() uint32 {
if m != nil {
return m.Width
}
return 0
}
func (m *Rectangle) GetHeight() uint32 {
if m != nil {
return m.Height
}
return 0
}
func (m *Rectangle) GetEnc() uint32 {
if m != nil {
return m.Enc
}
return 0
}
func (m *Rectangle) GetBytes() []byte {
if m != nil {
return m.Bytes
}
return nil
}
type FramebufferUpdate struct {
Rectangles []*Rectangle `protobuf:"bytes,1,rep,name=rectangles,proto3" json:"rectangles,omitempty"`
Timestamp uint32 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *FramebufferUpdate) Reset() { *m = FramebufferUpdate{} }
func (m *FramebufferUpdate) String() string { return proto.CompactTextString(m) }
func (*FramebufferUpdate) ProtoMessage() {}
func (*FramebufferUpdate) Descriptor() ([]byte, []int) {
return fileDescriptor_ca53982754088a9d, []int{6}
}
func (m *FramebufferUpdate) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FramebufferUpdate.Unmarshal(m, b)
}
func (m *FramebufferUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_FramebufferUpdate.Marshal(b, m, deterministic)
}
func (m *FramebufferUpdate) XXX_Merge(src proto.Message) {
xxx_messageInfo_FramebufferUpdate.Merge(m, src)
}
func (m *FramebufferUpdate) XXX_Size() int {
return xxx_messageInfo_FramebufferUpdate.Size(m)
}
func (m *FramebufferUpdate) XXX_DiscardUnknown() {
xxx_messageInfo_FramebufferUpdate.DiscardUnknown(m)
}
var xxx_messageInfo_FramebufferUpdate proto.InternalMessageInfo
func (m *FramebufferUpdate) GetRectangles() []*Rectangle {
if m != nil {
return m.Rectangles
}
return nil
}
func (m *FramebufferUpdate) GetTimestamp() uint32 {
if m != nil {
return m.Timestamp
}
return 0
}
type Demonstration struct { type Demonstration struct {
Initmsg *InitMsg `protobuf:"bytes,1,opt,name=initmsg,proto3" json:"initmsg,omitempty"` Initmsg *InitMsg `protobuf:"bytes,1,opt,name=initmsg,proto3" json:"initmsg,omitempty"`
Segments []*FbsSegment `protobuf:"bytes,2,rep,name=segments,proto3" json:"segments,omitempty"` Fbupdates []*FramebufferUpdate `protobuf:"bytes,2,rep,name=fbupdates,proto3" json:"fbupdates,omitempty"`
Pointerevents []*PointerEvent `protobuf:"bytes,3,rep,name=pointerevents,proto3" json:"pointerevents,omitempty"` Segments []*FbsSegment `protobuf:"bytes,3,rep,name=segments,proto3" json:"segments,omitempty"`
Keyevents []*KeyEvent `protobuf:"bytes,4,rep,name=keyevents,proto3" json:"keyevents,omitempty"` Pointerevents []*PointerEvent `protobuf:"bytes,4,rep,name=pointerevents,proto3" json:"pointerevents,omitempty"`
Keyevents []*KeyEvent `protobuf:"bytes,5,rep,name=keyevents,proto3" json:"keyevents,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -286,7 +532,7 @@ func (m *Demonstration) Reset() { *m = Demonstration{} }
func (m *Demonstration) String() string { return proto.CompactTextString(m) } func (m *Demonstration) String() string { return proto.CompactTextString(m) }
func (*Demonstration) ProtoMessage() {} func (*Demonstration) ProtoMessage() {}
func (*Demonstration) Descriptor() ([]byte, []int) { func (*Demonstration) Descriptor() ([]byte, []int) {
return fileDescriptor_ca53982754088a9d, []int{4} return fileDescriptor_ca53982754088a9d, []int{7}
} }
func (m *Demonstration) XXX_Unmarshal(b []byte) error { func (m *Demonstration) XXX_Unmarshal(b []byte) error {
@ -314,6 +560,13 @@ func (m *Demonstration) GetInitmsg() *InitMsg {
return nil return nil
} }
func (m *Demonstration) GetFbupdates() []*FramebufferUpdate {
if m != nil {
return m.Fbupdates
}
return nil
}
func (m *Demonstration) GetSegments() []*FbsSegment { func (m *Demonstration) GetSegments() []*FbsSegment {
if m != nil { if m != nil {
return m.Segments return m.Segments
@ -340,37 +593,56 @@ func init() {
proto.RegisterType((*PointerEvent)(nil), "proto.PointerEvent") proto.RegisterType((*PointerEvent)(nil), "proto.PointerEvent")
proto.RegisterType((*KeyEvent)(nil), "proto.KeyEvent") proto.RegisterType((*KeyEvent)(nil), "proto.KeyEvent")
proto.RegisterType((*FbsSegment)(nil), "proto.FbsSegment") proto.RegisterType((*FbsSegment)(nil), "proto.FbsSegment")
proto.RegisterType((*PixelFormat)(nil), "proto.PixelFormat")
proto.RegisterType((*Rectangle)(nil), "proto.Rectangle")
proto.RegisterType((*FramebufferUpdate)(nil), "proto.FramebufferUpdate")
proto.RegisterType((*Demonstration)(nil), "proto.Demonstration") proto.RegisterType((*Demonstration)(nil), "proto.Demonstration")
} }
func init() { proto.RegisterFile("demo.proto", fileDescriptor_ca53982754088a9d) } func init() { proto.RegisterFile("demo.proto", fileDescriptor_ca53982754088a9d) }
var fileDescriptor_ca53982754088a9d = []byte{ var fileDescriptor_ca53982754088a9d = []byte{
// 408 bytes of a gzipped FileDescriptorProto // 663 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0x4f, 0x8b, 0xdb, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x4d, 0x6b, 0xdb, 0x5a,
0x10, 0xc5, 0x51, 0x9c, 0xac, 0xe3, 0x49, 0xdc, 0x3f, 0x6a, 0x0f, 0xa2, 0x94, 0x12, 0x72, 0xca, 0x10, 0x45, 0x96, 0x25, 0x4b, 0xe3, 0xf8, 0xbd, 0xe4, 0xbe, 0x10, 0xc4, 0xe3, 0xf1, 0x08, 0x5e,
0x65, 0xf7, 0xb0, 0x3d, 0xf5, 0x56, 0x96, 0x34, 0x6c, 0x59, 0x76, 0x29, 0xca, 0xd2, 0x3f, 0xd0, 0x79, 0x93, 0x50, 0x52, 0x28, 0x74, 0x57, 0x5c, 0xc7, 0x4d, 0x09, 0x09, 0xe6, 0x3a, 0xfd, 0x82,
0x8b, 0x5d, 0x8f, 0xbd, 0xc2, 0x48, 0x32, 0x92, 0xd8, 0xad, 0xbf, 0x66, 0x2f, 0xfd, 0x3a, 0xc5, 0x6e, 0x24, 0x6b, 0x24, 0x0b, 0x5b, 0x57, 0xe2, 0xde, 0xeb, 0x24, 0x5e, 0xf4, 0x0f, 0xf4, 0x1f,
0xb2, 0x1c, 0x37, 0x39, 0x99, 0x99, 0x37, 0xef, 0xe7, 0xa7, 0x19, 0x80, 0x02, 0xa5, 0xbe, 0x68, 0xf4,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00, 0x00,
} }

View File

@ -9,6 +9,7 @@ message InitMsg {
uint32 SecType = 5; uint32 SecType = 5;
uint32 StartTime = 6; uint32 StartTime = 6;
string DesktopName = 7; string DesktopName = 7;
string PixelFormat = 8;
} }
message PointerEvent { message PointerEvent {
@ -30,9 +31,37 @@ message FbsSegment{
uint32 timestamp = 2; uint32 timestamp = 2;
} }
message PixelFormat{
uint32 BPP = 1;
uint32 Depth = 2;
uint32 BigEndian = 3;
uint32 TrueColor = 4;
uint32 RedMax = 5;
uint32 GreenMax = 6;
uint32 BlueMax = 7;
uint32 RedShift = 8;
uint32 GreenShift = 9;
uint32 BlueShift = 10;
}
message Rectangle {
uint32 X = 1;
uint32 Y = 2;
uint32 Width = 3;
uint32 Height = 4;
uint32 Enc = 5;
bytes Bytes = 6;
}
message FramebufferUpdate{
repeated Rectangle rectangles = 1;
uint32 timestamp = 2;
}
message Demonstration { message Demonstration {
InitMsg initmsg = 1; InitMsg initmsg = 1;
repeated FbsSegment segments = 2; repeated FramebufferUpdate fbupdates = 2;
repeated PointerEvent pointerevents = 3; repeated FbsSegment segments = 3;
repeated KeyEvent keyevents = 4; repeated PointerEvent pointerevents = 4;
repeated KeyEvent keyevents = 5;
} }

View File

@ -43,11 +43,45 @@ func listPeople(w io.Writer, demo *pb.Demonstration) {
fmt.Printf("DesktopName: %v \n", demo.Initmsg.GetDesktopName()) fmt.Printf("DesktopName: %v \n", demo.Initmsg.GetDesktopName())
// for _, p := range demo.Segments { // for _, p := range demo.Segments {
// writePerson(w, p) // writeSegment(w, p)
// } // }
// for _, k := range demo.Keyevents {
// writeKeyEvent(w, k)
// }
// for _, p := range demo.Pointerevents {
// writePointerEvent(w, p)
// }
for _, p := range demo.Fbupdates {
fmt.Print(p)
}
} }
func writePerson(w io.Writer, p *pb.FbsSegment) { func writeSegment(w io.Writer, p *pb.FbsSegment) {
fmt.Printf("Length: %v Timestamp: %v \n", len(p.GetBytes()), p.GetTimestamp()) fmt.Printf("Length: %v Timestamp: %v \n", len(p.GetBytes()), p.GetTimestamp())
} }
func writeFbupdate(w io.Writer, p *pb.FramebufferUpdate) {
for _, r := range p.Rectangles {
fmt.Printf("(%d,%d) (width: %d, height: %d), Enc= %d \n", r.X, r.Y, r.Width, r.Height, r.Enc)
}
}
func writeKeyEvent(w io.Writer, p *pb.KeyEvent) {
fmt.Printf(" KeyEvent : Down : %v, Key: %v) \n", p.GetDown(), p.GetKey())
}
func writePointerEvent(w io.Writer, p *pb.PointerEvent) {
fmt.Printf(" PointerEvent : X : %v, Y: %v , Mask: %v \n", p.GetX(), p.GetY(), p.GetMask())
}

View File

@ -2,6 +2,7 @@ package vnc_rec
import ( import (
"bytes" "bytes"
"encoding/binary"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
@ -20,6 +21,9 @@ type ProtoRecorder struct {
writer *os.File writer *os.File
demonstration *pb.Demonstration demonstration *pb.Demonstration
//logger common.Logger //logger common.Logger
Rectbuffer bytes.Buffer
FramebufferUpdate *pb.FramebufferUpdate
Rect *pb.Rectangle
startTime int startTime int
buffer bytes.Buffer buffer bytes.Buffer
serverInitMessage *common.ServerInit serverInitMessage *common.ServerInit
@ -149,6 +153,39 @@ func (r *ProtoRecorder) HandleRfbSegment(data *common.RfbSegment) error {
switch common.ServerMessageType(data.UpcomingObjectType) { switch common.ServerMessageType(data.UpcomingObjectType) {
case common.FramebufferUpdate: case common.FramebufferUpdate:
logger.Debugf("ProtoRecorder.HandleRfbSegment: saving FramebufferUpdate segment") logger.Debugf("ProtoRecorder.HandleRfbSegment: saving FramebufferUpdate segment")
//FBUpdate := data.Message.(*server.FramebufferUpdate)
if len(r.FramebufferUpdate.GetRectangles()) != 0 {
logger.Debugf("[IMP STUFF] Nil not found, now appending")
r.demonstration.Fbupdates = append(r.demonstration.Fbupdates, r.FramebufferUpdate)
}
logger.Debugf("[IMPORTANT] This FrameBufferUpdate is: %v", data.Bytes)
logger.Debugf("The FrameBuffer is: %v", r.FramebufferUpdate)
//r.FramebufferUpdate.Reset()
r.FramebufferUpdate = &pb.FramebufferUpdate{
Timestamp: timeSinceStart,
}
// FBUpdateProto := &pb.FramebufferUpdate{}
// for _, rect := range FBUpdate.Rects {
// RectProto := &pb.Rectangle{
// X: uint32(rect.X),
// Y: uint32(rect.Y),
// Width: uint32(rect.Width),
// Height: uint32(rect.Height),
// Enc: uint32(rect.Enc.Type()),
// }
// FBUpdateProto.Rectangles = append(FBUpdateProto.Rectangles, RectProto)
// }
// r.demonstration.Fbupdates = append(r.demonstration.Fbupdates, FBUpdateProto)
//r.writeToDisk() //r.writeToDisk()
case common.SetColourMapEntries: case common.SetColourMapEntries:
case common.Bell: case common.Bell:
@ -160,18 +197,45 @@ func (r *ProtoRecorder) HandleRfbSegment(data *common.RfbSegment) error {
r.writeToDisk() r.writeToDisk()
case common.SegmentRectSeparator: case common.SegmentRectSeparator:
logger.Debugf("ProtoRecorder.HandleRfbSegment: writing rect") logger.Debugf("ProtoRecorder.HandleRfbSegment: writing rect")
//r.Rect.Reset()
//r.writeToDisk() //r.writeToDisk()
case common.SegmentBytes: case common.SegmentBytes:
logger.Debug("ProtoRecorder.HandleRfbSegment: writing bytes, len:", len(data.Bytes)) logger.Debug("ProtoRecorder.HandleRfbSegment: writing bytes, len:", len(data.Bytes))
// if r.buffer.Len()+len(data.Bytes) > r.maxWriteSize-4 { // if r.buffer.Len()+len(data.Bytes) > r.maxWriteSize-4 {
// r.writeToDisk() // r.writeToDisk()
// } // }
segment := &pb.FbsSegment{
if len(data.Bytes) > 4 {
idx := r.Rectbuffer.Len() - 16
p := make([]byte, idx)
r.Rectbuffer.Read(p)
main := make([]byte, 16)
r.Rectbuffer.Read(main)
r.Rect = &pb.Rectangle{
X: uint32(binary.BigEndian.Uint16(main[:2])),
Y: uint32(binary.BigEndian.Uint16(main[2:4])),
Width: uint32(binary.BigEndian.Uint16(main[4:6])),
Height: uint32(binary.BigEndian.Uint16(main[6:8])),
Enc: binary.BigEndian.Uint32(main[8:12]),
Bytes: data.Bytes, Bytes: data.Bytes,
Timestamp: timeSinceStart, }
logger.Debugf("Received Main Pixel Buffer Content %v \n", r.Rect)
r.FramebufferUpdate.Rectangles = append(r.FramebufferUpdate.Rectangles, r.Rect)
r.Rectbuffer.Reset()
} else if len(data.Bytes) <= 4 {
logger.Debugf("Received Extra Short byte content %v , %v \n", len(data.Bytes), data.Bytes)
r.Rectbuffer.Write(data.Bytes)
// r.Rectbuffer = append(r.Rectbuffer, data.Bytes...)
//logger.Debugf("Rectbuffer currently is, %v", r.Rectbuffer)
} }
r.demonstration.Segments = append(r.demonstration.Segments, segment) // segment := &pb.FbsSegment{
// Bytes: data.Bytes,
// Timestamp: timeSinceStart,
// }
// r.demonstration.Segments = append(r.demonstration.Segments, segment)
//_, err := r.buffer.Write(data.Bytes) //_, err := r.buffer.Write(data.Bytes)
//return err //return err
case common.SegmentServerInitMessage: case common.SegmentServerInitMessage:
@ -186,17 +250,18 @@ func (r *ProtoRecorder) HandleRfbSegment(data *common.RfbSegment) error {
r.serverInitMessage.PixelFormat = clientMsg.PF r.serverInitMessage.PixelFormat = clientMsg.PF
case common.KeyEventMsgType: case common.KeyEventMsgType:
clientMsg := data.Message.(*server.MsgKeyEvent) clientMsg := data.Message.(*server.MsgKeyEvent)
logger.Debug("Recorder.HandleRfbSegment: writing bytes for KeyEventMsgType, len:", *clientMsg)
//clientMsg.Write(r.writer) //clientMsg.Write(r.writer)
keyevent := &pb.KeyEvent{ keyevent := &pb.KeyEvent{
Down: uint32(clientMsg.Down), Down: uint32(clientMsg.Down),
Key: uint32(clientMsg.Key), Key: uint32(clientMsg.Key),
Timestamp: timeSinceStart, Timestamp: timeSinceStart,
} }
logger.Debug("ProtoRecorder.HandleRfbSegment: writing bytes for KeyEventMsgType, len:", *keyevent)
r.demonstration.Keyevents = append(r.demonstration.Keyevents, keyevent) r.demonstration.Keyevents = append(r.demonstration.Keyevents, keyevent)
case common.PointerEventMsgType: case common.PointerEventMsgType:
clientMsg := data.Message.(*server.MsgPointerEvent) clientMsg := data.Message.(*server.MsgPointerEvent)
logger.Debug("Recorder.HandleRfbSegment: writing bytes for PointerEventMsgType, len:", *clientMsg)
//clientMsg.Write(r.writer) //clientMsg.Write(r.writer)
pointerevent := &pb.PointerEvent{ pointerevent := &pb.PointerEvent{
Mask: uint32(clientMsg.Mask), Mask: uint32(clientMsg.Mask),
@ -204,6 +269,7 @@ func (r *ProtoRecorder) HandleRfbSegment(data *common.RfbSegment) error {
Y: uint32(clientMsg.Y), Y: uint32(clientMsg.Y),
Timestamp: timeSinceStart, Timestamp: timeSinceStart,
} }
logger.Debug("ProtoRecorder.HandleRfbSegment: writing bytes for PointerEventMsgType, len:", *pointerevent)
r.demonstration.Pointerevents = append(r.demonstration.Pointerevents, pointerevent) r.demonstration.Pointerevents = append(r.demonstration.Pointerevents, pointerevent)
default: default:

View File

@ -79,33 +79,22 @@ func (vp *VncProxy) newServerConnHandler(cfg *server.ServerConfig, sconn *server
return err return err
} }
var rec_s *ServerRecorder //var rec_s *ServerRecorder
var rec_c *ClientRecorder
var rec_p *ProtoRecorder var rec_p *ProtoRecorder
if session.Type == SessionTypeRecordingProxy { if session.Type == SessionTypeRecordingProxy {
timeCurrent := strconv.FormatInt(time.Now().Unix(), 10) timeCurrent := strconv.FormatInt(time.Now().Unix(), 10)
recFolder := path.Join(vp.RecordingDir, "recording_"+timeCurrent) recFolder := path.Join(vp.RecordingDir, "recording_"+timeCurrent)
os.MkdirAll(recFolder, os.ModePerm) os.MkdirAll(recFolder, os.ModePerm)
recServerFile := "server.rbs" // recServerFile := "server.rbs"
recServerPath := path.Join(recFolder, recServerFile) // recServerPath := path.Join(recFolder, recServerFile)
rec_s, err = NewServerRecorder(recServerPath) // rec_s, err = NewServerRecorder(recServerPath)
if err != nil { // if err != nil {
logger.Errorf("Proxy.newServerConnHandler can't open ServerRecorder save path: %s", recServerPath) // logger.Errorf("Proxy.newServerConnHandler can't open ServerRecorder save path: %s", recServerPath)
return err // return err
} // }
sconn.Listeners.AddListener(rec_s) // sconn.Listeners.AddListener(rec_s)
recClientFile := "client.rbs"
recClientPath := path.Join(recFolder, recClientFile)
rec_c, err = NewClientRecorder(recClientPath)
if err != nil {
logger.Errorf("Proxy.newServerConnHandler can't open ClientRecorder save path: %s", recClientPath)
return err
}
sconn.Listeners.AddListener(rec_c)
recProtoFile := "proto.rbs" recProtoFile := "proto.rbs"
recProtoPath := path.Join(recFolder, recProtoFile) recProtoPath := path.Join(recFolder, recProtoFile)
@ -132,8 +121,6 @@ func (vp *VncProxy) newServerConnHandler(cfg *server.ServerConfig, sconn *server
return err return err
} }
if session.Type == SessionTypeRecordingProxy { if session.Type == SessionTypeRecordingProxy {
cconn.Listeners.AddListener(rec_s)
cconn.Listeners.AddListener(rec_c)
cconn.Listeners.AddListener(rec_p) cconn.Listeners.AddListener(rec_p)
} }