diff --git a/bin/recordings/recording_1565085991/client.rbs b/bin/recordings/recording_1565085991/client.rbs deleted file mode 100644 index 133da95..0000000 Binary files a/bin/recordings/recording_1565085991/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565085991/server.rbs b/bin/recordings/recording_1565085991/server.rbs deleted file mode 100644 index e3fb4c6..0000000 Binary files a/bin/recordings/recording_1565085991/server.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565086259/client.rbs b/bin/recordings/recording_1565086259/client.rbs deleted file mode 100644 index d05c1f7..0000000 Binary files a/bin/recordings/recording_1565086259/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565086259/server.rbs b/bin/recordings/recording_1565086259/server.rbs deleted file mode 100644 index 3651ab0..0000000 Binary files a/bin/recordings/recording_1565086259/server.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565086382/client.rbs b/bin/recordings/recording_1565086382/client.rbs deleted file mode 100644 index b810564..0000000 Binary files a/bin/recordings/recording_1565086382/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565086382/server.rbs b/bin/recordings/recording_1565086382/server.rbs deleted file mode 100644 index 2976a5c..0000000 Binary files a/bin/recordings/recording_1565086382/server.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565093465/client.rbs b/bin/recordings/recording_1565093465/client.rbs deleted file mode 100644 index 9fd9a52..0000000 Binary files a/bin/recordings/recording_1565093465/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565093465/server.rbs b/bin/recordings/recording_1565093465/server.rbs deleted file mode 100644 index 345361a..0000000 Binary files a/bin/recordings/recording_1565093465/server.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565196968/client.rbs b/bin/recordings/recording_1565196968/client.rbs deleted file mode 100644 index 280d872..0000000 Binary files a/bin/recordings/recording_1565196968/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565196968/server.rbs b/bin/recordings/recording_1565196968/server.rbs deleted file mode 100644 index 223edd9..0000000 Binary files a/bin/recordings/recording_1565196968/server.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565197944/client.rbs b/bin/recordings/recording_1565197944/client.rbs deleted file mode 100644 index c4b1d9e..0000000 Binary files a/bin/recordings/recording_1565197944/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565198023/client.rbs b/bin/recordings/recording_1565198023/client.rbs deleted file mode 100644 index 9595b39..0000000 Binary files a/bin/recordings/recording_1565198023/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565198225/client.rbs b/bin/recordings/recording_1565198225/client.rbs deleted file mode 100644 index 2449575..0000000 Binary files a/bin/recordings/recording_1565198225/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565198561/client.rbs b/bin/recordings/recording_1565198561/client.rbs deleted file mode 100644 index d87179e..0000000 Binary files a/bin/recordings/recording_1565198561/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565199074/client.rbs b/bin/recordings/recording_1565199074/client.rbs deleted file mode 100644 index bc61803..0000000 Binary files a/bin/recordings/recording_1565199074/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565199074/server.rbs b/bin/recordings/recording_1565199074/server.rbs deleted file mode 100644 index e69de29..0000000 diff --git a/bin/recordings/recording_1565199179/client.rbs b/bin/recordings/recording_1565199179/client.rbs deleted file mode 100644 index 92ab278..0000000 Binary files a/bin/recordings/recording_1565199179/client.rbs and /dev/null differ diff --git a/bin/recordings/recording_1565199179/server.rbs b/bin/recordings/recording_1565199179/server.rbs deleted file mode 100644 index e69de29..0000000 diff --git a/bin/recordings/recording_1565197944/server.rbs b/bin/recordings/recording_1565210999/client.rbs similarity index 100% rename from bin/recordings/recording_1565197944/server.rbs rename to bin/recordings/recording_1565210999/client.rbs diff --git a/bin/recordings/recording_1565198561/server.rbs b/bin/recordings/recording_1565210999/server.rbs similarity index 100% rename from bin/recordings/recording_1565198561/server.rbs rename to bin/recordings/recording_1565210999/server.rbs diff --git a/bin/recordings/recording_1565211076/client.rbs b/bin/recordings/recording_1565211076/client.rbs new file mode 100644 index 0000000..b6234c8 --- /dev/null +++ b/bin/recordings/recording_1565211076/client.rbs @@ -0,0 +1,27 @@ +W + FBS 001.000 RFB 003.003 + (0:TigerVNC (0f680132c2eb)B  (08@H F              | +z +y +w +v v  +v v v s p k h c W Q K G E C = 6 0 * (  +( ( ( ( ( ( ) + , , - - - - - / 0 1  +1 1 1 1 1 !1 " +1 "1 #1 #1 %0 &0 &. '+ ') '( (' )) *. +5 + +5 +5 ,5 ,1 .0 00 00 10 10 10 10 13 25 25 27 28 28 3: 3: 3 +: 4: 5: 59 78 88 87 87 87 87 96 96 96 96 96 95 :5 :5 <5 <5 <5 =5 = +5 =5 >5 >5 A3 A2 B2 B2 B2 C3 C3 C3 C3 D4 D +4 D +4 E4 F4 F4 H4 H5 H8 H; H> H? IB ID IG IH II JI KI KH KH KF LF M +F MF NF NC Q@ Q= Q: Q7 Q6 S +6 S6 T6 T8 W: W= W@ WE XH XK XN XQ XR YS Y +S ZS [S [S ]S ]S ]S ]S ]S ^Q ^O ^N ^N ^L _K _E _A `< `: `9 ` +9 a9 b9 b: d= d? dB eJ eO eS eU eW fX fY fY fZ f +Z hZ iZ iZ kY kU lQ lL lG lB l= m4 m, m+ m+ n ++ n+ o+ o+ r. s1 s5 s6 s8 s: t= t> t? t@ tB tC u +C uC vC vB xA x@ x@ x? x? y= y; y; y: z8 z +8 {8 |8 |8 8  8  9  :  : ɀ <  >  @  A с A  A  A  A  ?  9  6 Ʌ 3  0  .  -  -  -  - ш -  .  0  4 ً 6  9  9  :  :  :  :  :  9  8 ђ 8  8  7  7  7 ѓ 7  7  7  7  6  6 ٔ 6  6  6  6  6  6  6 ɗ 6  6  7 њ ;  ;  <  =  @ ɛ B  D  E  F  F  F  F ў D  B  ?  <  8 ١ 6  4  3  3 ɢ 3  3  3  3  3 ɣ 3  3  3  3  3  3  3  4  8  B  Z  o ٨ +  +  +  p  _ ѩ P  @  .  #   ɪ          ѫ      \ No newline at end of file diff --git a/bin/recordings/recording_1565211076/server.rbs b/bin/recordings/recording_1565211076/server.rbs new file mode 100644 index 0000000..c3a19fe Binary files /dev/null and b/bin/recordings/recording_1565211076/server.rbs differ diff --git a/bin/vnc_reader b/bin/vnc_reader index aac629a..db3538a 100755 Binary files a/bin/vnc_reader and b/bin/vnc_reader differ diff --git a/bin/vnc_recorder b/bin/vnc_recorder index e0c6c21..aae875b 100755 Binary files a/bin/vnc_recorder and b/bin/vnc_recorder differ diff --git a/proto/demo.pb.go b/proto/demo.pb.go index 588b0f8..41869b0 100644 --- a/proto/demo.pb.go +++ b/proto/demo.pb.go @@ -391,6 +391,45 @@ func (m *PixelFormat) GetBlueShift() uint32 { return 0 } +type MessageType struct { + Type uint32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MessageType) Reset() { *m = MessageType{} } +func (m *MessageType) String() string { return proto.CompactTextString(m) } +func (*MessageType) ProtoMessage() {} +func (*MessageType) Descriptor() ([]byte, []int) { + return fileDescriptor_ca53982754088a9d, []int{5} +} + +func (m *MessageType) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MessageType.Unmarshal(m, b) +} +func (m *MessageType) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MessageType.Marshal(b, m, deterministic) +} +func (m *MessageType) XXX_Merge(src proto.Message) { + xxx_messageInfo_MessageType.Merge(m, src) +} +func (m *MessageType) XXX_Size() int { + return xxx_messageInfo_MessageType.Size(m) +} +func (m *MessageType) XXX_DiscardUnknown() { + xxx_messageInfo_MessageType.DiscardUnknown(m) +} + +var xxx_messageInfo_MessageType proto.InternalMessageInfo + +func (m *MessageType) GetType() uint32 { + if m != nil { + return m.Type + } + 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"` @@ -407,7 +446,7 @@ 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} + return fileDescriptor_ca53982754088a9d, []int{6} } func (m *Rectangle) XXX_Unmarshal(b []byte) error { @@ -482,7 +521,7 @@ 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} + return fileDescriptor_ca53982754088a9d, []int{7} } func (m *FramebufferUpdate) XXX_Unmarshal(b []byte) error { @@ -532,7 +571,7 @@ func (m *Demonstration) Reset() { *m = Demonstration{} } func (m *Demonstration) String() string { return proto.CompactTextString(m) } func (*Demonstration) ProtoMessage() {} func (*Demonstration) Descriptor() ([]byte, []int) { - return fileDescriptor_ca53982754088a9d, []int{7} + return fileDescriptor_ca53982754088a9d, []int{8} } func (m *Demonstration) XXX_Unmarshal(b []byte) error { @@ -594,6 +633,7 @@ func init() { proto.RegisterType((*KeyEvent)(nil), "proto.KeyEvent") proto.RegisterType((*FbsSegment)(nil), "proto.FbsSegment") proto.RegisterType((*PixelFormat)(nil), "proto.PixelFormat") + proto.RegisterType((*MessageType)(nil), "proto.MessageType") proto.RegisterType((*Rectangle)(nil), "proto.Rectangle") proto.RegisterType((*FramebufferUpdate)(nil), "proto.FramebufferUpdate") proto.RegisterType((*Demonstration)(nil), "proto.Demonstration") @@ -602,47 +642,49 @@ func init() { func init() { proto.RegisterFile("demo.proto", fileDescriptor_ca53982754088a9d) } var fileDescriptor_ca53982754088a9d = []byte{ - // 669 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xcb, 0x6a, 0xdb, 0x40, - 0x14, 0x45, 0x96, 0x5f, 0xba, 0x8a, 0xdb, 0x64, 0x1a, 0x82, 0x28, 0xa5, 0x18, 0xaf, 0xbc, 0x49, - 0x28, 0x69, 0x29, 0x74, 0x57, 0x5c, 0xc7, 0x4d, 0x09, 0x09, 0x66, 0x9c, 0xbe, 0xa0, 0x1b, 0xc9, - 0xba, 0x92, 0x85, 0xad, 0x91, 0x98, 0x19, 0x27, 0xf1, 0xa2, 0x3f, 0x50, 0xe8, 0x07, 0xf4, 0x6f, - 0xcb, 0x3c, 0x24, 0xdb, 0xe9, 0xa2, 0x2b, 0x71, 0xee, 0x99, 0x7b, 0x38, 0xf7, 0x25, 0x80, 0x18, - 0xf3, 0xe2, 0xac, 0xe4, 0x85, 0x2c, 0x48, 0x4b, 0x7f, 0x06, 0xbf, 0x1b, 0xd0, 0xf9, 0xc4, 0x32, - 0x79, 0x2d, 0x52, 0xf2, 0x02, 0x3c, 0x9a, 0x44, 0x97, 0x18, 0xc6, 0xc8, 0x03, 0xa7, 0xef, 0x0c, - 0x3d, 0xea, 0xf1, 0x2a, 0x40, 0x5e, 0x02, 0xd0, 0x24, 0xfa, 0x82, 0x5c, 0x64, 0x05, 0x0b, 0x1a, - 0x9a, 0x06, 0x5e, 0x47, 0xc8, 0x73, 0xe8, 0x4e, 0x46, 0x97, 0x98, 0xa5, 0x0b, 0x19, 0xb8, 0x7d, - 0x67, 0xd8, 0xa3, 0xdd, 0xc4, 0x62, 0x12, 0x40, 0x67, 0x32, 0xfa, 0x9a, 0xc5, 0x72, 0x11, 0x34, - 0x35, 0xd5, 0x49, 0x0c, 0x54, 0xcc, 0x0c, 0xe7, 0xb7, 0x9b, 0x12, 0x83, 0x96, 0x61, 0x84, 0x81, - 0xca, 0xcd, 0x4c, 0x86, 0x5c, 0xde, 0x66, 0x39, 0x06, 0x6d, 0xcd, 0x79, 0xa2, 0x0a, 0x90, 0x3e, - 0xf8, 0x63, 0x14, 0x4b, 0x59, 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 0x4e, 0xc6, 0x32, 0x99, 0x8b, 0x54, 0x97, 0xeb, 0x9f, 0x3f, 0xb1, 0xf2, 0xf6, 0x37, - 0x41, 0x2b, 0x9a, 0xbc, 0x05, 0x2f, 0x89, 0xd6, 0xda, 0x97, 0x08, 0x1a, 0xda, 0x4a, 0x60, 0xdf, - 0xfe, 0x63, 0x9c, 0x6e, 0x9f, 0x92, 0x53, 0xe8, 0x0a, 0xb3, 0xb2, 0x22, 0x70, 0x75, 0xda, 0x51, - 0x95, 0x56, 0x2f, 0x33, 0xad, 0x9f, 0x90, 0x77, 0xd0, 0x2b, 0xcd, 0x49, 0xe2, 0x9d, 0xce, 0x69, - 0xea, 0x9c, 0x67, 0xd5, 0x29, 0xef, 0x9c, 0x2b, 0xdd, 0x7f, 0x49, 0x4e, 0xc1, 0x5b, 0xe2, 0xc6, - 0xa6, 0xb5, 0x74, 0xda, 0x53, 0x9b, 0x56, 0xdd, 0x21, 0xdd, 0xbe, 0x88, 0xda, 0x9a, 0x7a, 0xfd, - 0x37, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x19, 0x99, 0xbe, 0x28, 0x05, 0x00, 0x00, + // 692 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x5d, 0x6b, 0xdb, 0x4a, + 0x10, 0x45, 0x96, 0xbf, 0x34, 0x8a, 0xef, 0x4d, 0xf6, 0x86, 0x20, 0x2e, 0x97, 0x8b, 0xeb, 0x27, + 0xbf, 0x24, 0x94, 0xb4, 0x14, 0xfa, 0x56, 0x5c, 0xc7, 0x4d, 0x09, 0x0e, 0x66, 0x9d, 0x7e, 0x41, + 0x5f, 0x24, 0x6b, 0x24, 0x0b, 0x5b, 0x2b, 0xb1, 0xbb, 0x4e, 0xe2, 0x87, 0xfe, 0x81, 0x42, 0x7f, + 0x40, 0xff, 0x6d, 0xd9, 0x0f, 0xc9, 0x76, 0xfa, 0x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x73, 0xe8, 0x0a, + 0xe3, 0x6a, 0x11, 0xb8, 0xba, 0xec, 0xa4, 0x2a, 0xab, 0xfd, 0x4e, 0xeb, 0x27, 0xe4, 0x35, 0xf4, + 0x4a, 0x73, 0xb5, 0x78, 0xaf, 0x6b, 0x9a, 0xba, 0xe6, 0x9f, 0xea, 0xda, 0xf7, 0x2e, 0x9a, 0x1e, + 0xbe, 0x24, 0xe7, 0xe0, 0xad, 0x70, 0x6b, 0xcb, 0x5a, 0xba, 0xec, 0x6f, 0x5b, 0x56, 0x9d, 0x2a, + 0xdd, 0xbd, 0x88, 0xda, 0x1a, 0x7a, 0xf1, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x8a, 0x74, 0x30, + 0x4b, 0x05, 0x00, 0x00, } diff --git a/proto/demo.proto b/proto/demo.proto index e2f8c50..9558e55 100644 --- a/proto/demo.proto +++ b/proto/demo.proto @@ -44,6 +44,10 @@ message PixelFormat{ uint32 BlueShift = 10; } +message MessageType{ + uint32 type = 1; +} + message Rectangle { uint32 X = 1; uint32 Y = 2; diff --git a/vnc_read/main.go b/vnc_read/main.go index 518fb03..350cb98 100644 --- a/vnc_read/main.go +++ b/vnc_read/main.go @@ -3,11 +3,12 @@ package main import ( "fmt" "io" - "io/ioutil" "log" "os" + "time" - "github.com/golang/protobuf/proto" + "github.com/matttproud/golang_protobuf_extensions/pbutil" + "github.com/sibeshkar/vncproxy/logger" pb "github.com/sibeshkar/vncproxy/proto" ) @@ -18,18 +19,64 @@ func main() { } fname := os.Args[1] - // [START unmarshal_proto] - // Read the existing address book. - in, err := ioutil.ReadFile(fname) + reader, err := os.OpenFile(fname, os.O_RDWR, 0644) if err != nil { - log.Fatalln("Error reading file:", err) - } - demonstration := &pb.Demonstration{} - if err := proto.Unmarshal(in, demonstration); err != nil { - log.Fatalln("Failed to parse demonstration file:", err) + logger.Errorf("unable to open file: %s, error: %v", fname, err) + } - listPeople(os.Stdout, demonstration) + // [START unmarshal_proto] + // Read the existing address book. + // in, err := ioutil.ReadFile(fname) + // if err != nil { + // log.Fatalln("Error reading file:", err) + // } + // demonstration := &pb.Demonstration{} + // if err := proto.Unmarshal(in, demonstration); err != nil { + // log.Fatalln("Failed to parse demonstration file:", err) + // } + + // pf := &pb.PixelFormat{} + // pbutil.ReadDelimited(reader, pf) + + // fmt.Println(pf) + + initMsg := &pb.InitMsg{} + pbutil.ReadDelimited(reader, initMsg) + + fmt.Printf("FBHeight: %v \n", initMsg.GetFBHeight()) + fmt.Printf("FBWidth: %v \n", initMsg.GetFBWidth()) + fmt.Printf("RfbHeader: %v \n", initMsg.GetRfbHeader()) + fmt.Printf("RfbVersion: %v \n", initMsg.GetRfbVersion()) + fmt.Printf("SecType: %v \n", initMsg.GetSecType()) + fmt.Printf("StartTime: %v \n", initMsg.GetStartTime()) + fmt.Printf("DesktopName: %v \n", initMsg.GetDesktopName()) + fmt.Printf("PixelFormat: %v \n", initMsg.GetPixelFormat()) + + i := 0 + + for { + + // msgType := &pb.MessageType{} + // pbutil.ReadDelimited(reader, msgType) + // if msgType.GetType() == uint32(4) { + // keyEvent := &pb.KeyEvent{} + // pbutil.ReadDelimited(reader, keyEvent) + // fmt.Printf("Key event is %v", keyEvent) + + // } else if msgType.GetType() == uint32(5) { + // pointerEvent := &pb.PointerEvent{} + // pbutil.ReadDelimited(reader, pointerEvent) + // fmt.Println("Pointer event is ", pointerEvent) + + // } + fbupdate := &pb.FramebufferUpdate{} + pbutil.ReadDelimited(reader, fbupdate) + writeFbupdate(fbupdate, &i) + time.Sleep(1 * time.Second) + } + + //listPeople(os.Stdout, demonstration) } @@ -55,13 +102,13 @@ func listPeople(w io.Writer, demo *pb.Demonstration) { // writePointerEvent(w, p) // } - i := 0 + // i := 0 - for _, p := range demo.Fbupdates { - writeFbupdate(w, p, &i) - } + // for _, p := range demo.Fbupdates { + // writeFbupdate(w, p, &i) + // } - fmt.Println(i) + // fmt.Println(i) } @@ -70,7 +117,7 @@ func writeSegment(w io.Writer, p *pb.FbsSegment) { } -func writeFbupdate(w io.Writer, p *pb.FramebufferUpdate, i *int) { +func writeFbupdate(p *pb.FramebufferUpdate, i *int) { *i++ fmt.Printf("----------FRAMEBUFFERUPDATE NUMBER %v -------------- \n", *i) diff --git a/vnc_rec/custom-client-recorder.go b/vnc_rec/custom-client-recorder.go new file mode 100644 index 0000000..11f62ae --- /dev/null +++ b/vnc_rec/custom-client-recorder.go @@ -0,0 +1,224 @@ +package vnc_rec + +import ( + "bytes" + "os" + + "github.com/amitbet/vncproxy/common" + "github.com/amitbet/vncproxy/logger" + "github.com/amitbet/vncproxy/server" + "github.com/matttproud/golang_protobuf_extensions/pbutil" + pb "github.com/sibeshkar/vncproxy/proto" +) + +type CustomClientRecorder struct { + //common.BytesListener + RBSFileName string + writer *os.File + //logger common.Logger + Rectbuffer bytes.Buffer + FramebufferUpdate *pb.FramebufferUpdate + Rect *pb.Rectangle + startTime int + buffer bytes.Buffer + serverInitMessage *common.ServerInit + sessionStartWritten bool + segmentChan chan *common.RfbSegment + maxWriteSize int +} + +func NewCustomClientRecorder(saveFilePath string) (*CustomClientRecorder, error) { + //delete file if it exists + if _, err := os.Stat(saveFilePath); err == nil { + os.Remove(saveFilePath) + } + + rec := CustomClientRecorder{RBSFileName: saveFilePath, startTime: getNowMillisec()} + var err error + + rec.maxWriteSize = 65535 + + rec.writer, err = os.OpenFile(saveFilePath, os.O_RDWR|os.O_CREATE, 0644) + if err != nil { + logger.Errorf("unable to open file: %s, error: %v", saveFilePath, err) + return nil, err + } + + // rec.writer, err = os.OpenFile(saveFilePath, os.O_RDWR|os.O_CREATE, 0644) + // if err != nil { + // logger.Errorf("unable to open file: %s, error: %v", saveFilePath, err) + // return nil, err + // } + + //buffer the channel so we don't halt the proxying flow for slow writes when under pressure + rec.segmentChan = make(chan *common.RfbSegment, 100) + go func() { + for { + data := <-rec.segmentChan + rec.HandleRfbSegment(data) + } + }() + + return &rec, nil +} + +func (r *CustomClientRecorder) writeStartSession(initMsg *common.ServerInit) error { + r.sessionStartWritten = true + desktopName := string(initMsg.NameText) + framebufferWidth := initMsg.FBWidth + framebufferHeight := initMsg.FBHeight + // //write rfb header information (the only part done without the [size|data|timestamp] block wrapper) + // r.writer.WriteString("FBS 001.000\n") + // r.demonstration.Initmsg. + + // //push the version message into the buffer so it will be written in the first rbs block + // r.buffer.WriteString(versionMsg_3_3) + + // //push sec type and fb dimensions + // binary.Write(&r.buffer, binary.BigEndian, int32(SecTypeNone)) + // binary.Write(&r.buffer, binary.BigEndian, int16(framebufferWidth)) + // binary.Write(&r.buffer, binary.BigEndian, int16(framebufferHeight)) + + // buff := bytes.Buffer{} + // //binary.Write(&buff, binary.BigEndian, initMsg.FBWidth) + // //binary.Write(&buff, binary.BigEndian, initMsg.FBHeight) + // binary.Write(&buff, binary.BigEndian, initMsg.PixelFormat) + // buff.Write([]byte{0, 0, 0}) //padding + // r.buffer.Write(buff.Bytes()) + // //logger.Debugf(">>>>>>buffer for initMessage:%v ", buff.Bytes()) + + // //var fbsServerInitMsg = []byte{32, 24, 0, 1, 0, byte(0xFF), 0, byte(0xFF), 0, byte(0xFF), 16, 8, 0, 0, 0, 0} + // //r.buffer.Write(fbsServerInitMsg) + + // binary.Write(&r.buffer, binary.BigEndian, uint32(len(desktopName))) + + // r.buffer.WriteString(desktopName) + + pixel_format := &pb.PixelFormat{ + BPP: uint32(initMsg.PixelFormat.BPP), + Depth: uint32(initMsg.PixelFormat.Depth), + BigEndian: uint32(initMsg.PixelFormat.BigEndian), + TrueColor: uint32(initMsg.PixelFormat.TrueColor), + RedMax: uint32(initMsg.PixelFormat.RedMax), + GreenMax: uint32(initMsg.PixelFormat.GreenMax), + BlueMax: uint32(initMsg.PixelFormat.BlueMax), + RedShift: uint32(initMsg.PixelFormat.RedShift), + GreenShift: uint32(initMsg.PixelFormat.GreenShift), + BlueShift: uint32(initMsg.PixelFormat.BlueShift), + } + + initMsgProto := &pb.InitMsg{ + RfbHeader: "FBS 001.000", + RfbVersion: versionMsg_3_3, + FBHeight: uint32(framebufferHeight), + FBWidth: uint32(framebufferWidth), + SecType: uint32(SecTypeNone), + StartTime: uint32(r.startTime), + DesktopName: desktopName, + PixelFormat: pixel_format, + } + + pbutil.WriteDelimited(r.writer, initMsgProto) + //binary.Write(&r.buffer, binary.BigEndian, byte(0)) // add null termination for desktop string + + return nil +} + +func (r *CustomClientRecorder) Consume(data *common.RfbSegment) error { + //using async writes so if chan buffer overflows, proxy will not be affected + select { + case r.segmentChan <- data: + // default: + // logger.Error("error: CustomClientRecorder queue is full") + } + + return nil +} + +func (r *CustomClientRecorder) HandleRfbSegment(data *common.RfbSegment) error { + defer func() { + if r := recover(); r != nil { + logger.Error("Recovered in HandleRfbSegment: ", r) + } + }() + + timeSinceStart := uint32(getNowMillisec() - r.startTime) + + switch data.SegmentType { + case common.SegmentMessageStart: + if !r.sessionStartWritten { + logger.Debugf("CustomClientRecorder.HandleRfbSegment: writing start session segment: %v", r.serverInitMessage) + r.writeStartSession(r.serverInitMessage) + } + + switch common.ServerMessageType(data.UpcomingObjectType) { + case common.FramebufferUpdate: + logger.Debugf("CustomClientRecorder.HandleRfbSegment: saving FramebufferUpdate segment") + + case common.SetColourMapEntries: + case common.Bell: + case common.ServerCutText: + default: + logger.Warn("CustomClientRecorder.HandleRfbSegment: unknown message type:" + string(data.UpcomingObjectType)) + } + case common.SegmentConnectionClosed: + logger.Debugf("CustomClientRecorder.HandleRfbSegment: connection closed") + case common.SegmentRectSeparator: + logger.Debugf("CustomClientRecorder.HandleRfbSegment: writing rect") + //r.Rect.Reset() + //r.writeToDisk() + case common.SegmentBytes: + logger.Debug("CustomClientRecorder.HandleRfbSegment: writing bytes, len:", len(data.Bytes)) + // if r.buffer.Len()+len(data.Bytes) > r.maxWriteSize-4 { + // r.writeToDisk() + // } + case common.SegmentServerInitMessage: + r.serverInitMessage = data.Message.(*common.ServerInit) + case common.SegmentFullyParsedClientMessage: + clientMsg := data.Message.(common.ClientMessage) + + switch clientMsg.Type() { + case common.SetPixelFormatMsgType: + clientMsg := data.Message.(*server.MsgSetPixelFormat) + logger.Debugf("ClientRecorder.HandleRfbSegment: client message %v", *clientMsg) + r.serverInitMessage.PixelFormat = clientMsg.PF + case common.KeyEventMsgType: + clientMsg := data.Message.(*server.MsgKeyEvent) + //clientMsg.Write(r.writer) + keyevent := &pb.KeyEvent{ + Down: uint32(clientMsg.Down), + Key: uint32(clientMsg.Key), + Timestamp: timeSinceStart, + } + logger.Debug("CustomClientRecorder.HandleRfbSegment: writing bytes for KeyEventMsgType, len:", *keyevent) + + pbutil.WriteDelimited(r.writer, &pb.MessageType{Type: uint32(4)}) + pbutil.WriteDelimited(r.writer, keyevent) + //r.demonstration.Keyevents = append(r.demonstration.Keyevents, keyevent) + case common.PointerEventMsgType: + clientMsg := data.Message.(*server.MsgPointerEvent) + + //clientMsg.Write(r.writer) + pointerevent := &pb.PointerEvent{ + Mask: uint32(clientMsg.Mask), + X: uint32(clientMsg.X), + Y: uint32(clientMsg.Y), + Timestamp: timeSinceStart, + } + logger.Debug("CustomClientRecorder.HandleRfbSegment: writing bytes for PointerEventMsgType, len:", *pointerevent) + //r.demonstration.Pointerevents = append(r.demonstration.Pointerevents, pointerevent) + pbutil.WriteDelimited(r.writer, &pb.MessageType{Type: uint32(5)}) + pbutil.WriteDelimited(r.writer, pointerevent) + default: + //return errors.New("unknown client message type:" + string(data.UpcomingObjectType)) + } + + default: + //return errors.New("undefined RfbSegment type") + } + return nil +} + +func (r *CustomClientRecorder) Close() { + r.writer.Close() +} diff --git a/vnc_rec/custom-server-recorder.go b/vnc_rec/custom-server-recorder.go new file mode 100644 index 0000000..df62e2b --- /dev/null +++ b/vnc_rec/custom-server-recorder.go @@ -0,0 +1,332 @@ +package vnc_rec + +import ( + "bytes" + "encoding/binary" + "os" + + "github.com/amitbet/vncproxy/common" + "github.com/amitbet/vncproxy/logger" + "github.com/amitbet/vncproxy/server" + "github.com/matttproud/golang_protobuf_extensions/pbutil" + pb "github.com/sibeshkar/vncproxy/proto" +) + +type CustomServerRecorder struct { + //common.BytesListener + RBSFileName string + writer *os.File + //logger common.Logger + Rectbuffer bytes.Buffer + FramebufferUpdate *pb.FramebufferUpdate + Rect *pb.Rectangle + startTime int + buffer bytes.Buffer + serverInitMessage *common.ServerInit + sessionStartWritten bool + segmentChan chan *common.RfbSegment + maxWriteSize int +} + +func NewCustomServerRecorder(saveFilePath string) (*CustomServerRecorder, error) { + //delete file if it exists + if _, err := os.Stat(saveFilePath); err == nil { + os.Remove(saveFilePath) + } + + rec := CustomServerRecorder{RBSFileName: saveFilePath, startTime: getNowMillisec()} + var err error + + rec.maxWriteSize = 65535 + + rec.writer, err = os.OpenFile(saveFilePath, os.O_RDWR|os.O_CREATE, 0644) + if err != nil { + logger.Errorf("unable to open file: %s, error: %v", saveFilePath, err) + return nil, err + } + + // rec.writer, err = os.OpenFile(saveFilePath, os.O_RDWR|os.O_CREATE, 0644) + // if err != nil { + // logger.Errorf("unable to open file: %s, error: %v", saveFilePath, err) + // return nil, err + // } + + //buffer the channel so we don't halt the proxying flow for slow writes when under pressure + rec.segmentChan = make(chan *common.RfbSegment, 100) + go func() { + for { + data := <-rec.segmentChan + rec.HandleRfbSegment(data) + } + }() + + return &rec, nil +} + +func (r *CustomServerRecorder) writeStartSession(initMsg *common.ServerInit) error { + r.sessionStartWritten = true + desktopName := string(initMsg.NameText) + framebufferWidth := initMsg.FBWidth + framebufferHeight := initMsg.FBHeight + // //write rfb header information (the only part done without the [size|data|timestamp] block wrapper) + // r.writer.WriteString("FBS 001.000\n") + // r.demonstration.Initmsg. + + // //push the version message into the buffer so it will be written in the first rbs block + // r.buffer.WriteString(versionMsg_3_3) + + // //push sec type and fb dimensions + // binary.Write(&r.buffer, binary.BigEndian, int32(SecTypeNone)) + // binary.Write(&r.buffer, binary.BigEndian, int16(framebufferWidth)) + // binary.Write(&r.buffer, binary.BigEndian, int16(framebufferHeight)) + + // buff := bytes.Buffer{} + // //binary.Write(&buff, binary.BigEndian, initMsg.FBWidth) + // //binary.Write(&buff, binary.BigEndian, initMsg.FBHeight) + // binary.Write(&buff, binary.BigEndian, initMsg.PixelFormat) + // buff.Write([]byte{0, 0, 0}) //padding + // r.buffer.Write(buff.Bytes()) + // //logger.Debugf(">>>>>>buffer for initMessage:%v ", buff.Bytes()) + + // //var fbsServerInitMsg = []byte{32, 24, 0, 1, 0, byte(0xFF), 0, byte(0xFF), 0, byte(0xFF), 16, 8, 0, 0, 0, 0} + // //r.buffer.Write(fbsServerInitMsg) + + // binary.Write(&r.buffer, binary.BigEndian, uint32(len(desktopName))) + + // r.buffer.WriteString(desktopName) + + pixel_format := &pb.PixelFormat{ + BPP: uint32(initMsg.PixelFormat.BPP), + Depth: uint32(initMsg.PixelFormat.Depth), + BigEndian: uint32(initMsg.PixelFormat.BigEndian), + TrueColor: uint32(initMsg.PixelFormat.TrueColor), + RedMax: uint32(initMsg.PixelFormat.RedMax), + GreenMax: uint32(initMsg.PixelFormat.GreenMax), + BlueMax: uint32(initMsg.PixelFormat.BlueMax), + RedShift: uint32(initMsg.PixelFormat.RedShift), + GreenShift: uint32(initMsg.PixelFormat.GreenShift), + BlueShift: uint32(initMsg.PixelFormat.BlueShift), + } + + initMsgProto := &pb.InitMsg{ + RfbHeader: "FBS 001.000", + RfbVersion: versionMsg_3_3, + FBHeight: uint32(framebufferHeight), + FBWidth: uint32(framebufferWidth), + SecType: uint32(SecTypeNone), + StartTime: uint32(r.startTime), + DesktopName: desktopName, + PixelFormat: pixel_format, + } + + pbutil.WriteDelimited(r.writer, initMsgProto) + //binary.Write(&r.buffer, binary.BigEndian, byte(0)) // add null termination for desktop string + + return nil +} + +func (r *CustomServerRecorder) Consume(data *common.RfbSegment) error { + //using async writes so if chan buffer overflows, proxy will not be affected + select { + case r.segmentChan <- data: + // default: + // logger.Error("error: CustomServerRecorder queue is full") + } + + return nil +} + +func (r *CustomServerRecorder) HandleRfbSegment(data *common.RfbSegment) error { + defer func() { + if r := recover(); r != nil { + logger.Error("Recovered in HandleRfbSegment: ", r) + } + }() + + timeSinceStart := uint32(getNowMillisec() - r.startTime) + + switch data.SegmentType { + case common.SegmentMessageStart: + if !r.sessionStartWritten { + logger.Debugf("CustomServerRecorder.HandleRfbSegment: writing start session segment: %v", r.serverInitMessage) + r.writeStartSession(r.serverInitMessage) + } + + switch common.ServerMessageType(data.UpcomingObjectType) { + case common.FramebufferUpdate: + logger.Debugf("CustomServerRecorder.HandleRfbSegment: saving FramebufferUpdate segment") + //FBUpdate := data.Message.(*server.FramebufferUpdate) + if len(r.FramebufferUpdate.GetRectangles()) != 0 { + logger.Debugf("[IMP STUFF] Nil not found, now appending") + pbutil.WriteDelimited(r.writer, 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() + case common.SetColourMapEntries: + case common.Bell: + case common.ServerCutText: + default: + logger.Warn("CustomServerRecorder.HandleRfbSegment: unknown message type:" + string(data.UpcomingObjectType)) + } + case common.SegmentConnectionClosed: + logger.Debugf("CustomServerRecorder.HandleRfbSegment: connection closed") + case common.SegmentRectSeparator: + logger.Debugf("CustomServerRecorder.HandleRfbSegment: writing rect") + //r.Rect.Reset() + //r.writeToDisk() + case common.SegmentBytes: + logger.Debug("CustomServerRecorder.HandleRfbSegment: writing bytes, len:", len(data.Bytes)) + // if r.buffer.Len()+len(data.Bytes) > r.maxWriteSize-4 { + // r.writeToDisk() + // } + + 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, + } + //logger.Debugf("Received Main Pixel Buffer Content %v \n", r.Rect) + if r.Rect.GetEnc() <= 300 { + 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) + } + + // segment := &pb.FbsSegment{ + // Bytes: data.Bytes, + // Timestamp: timeSinceStart, + // } + + // r.demonstration.Segments = append(r.demonstration.Segments, segment) + //_, err := r.buffer.Write(data.Bytes) + //return err + case common.SegmentServerInitMessage: + r.serverInitMessage = data.Message.(*common.ServerInit) + case common.SegmentFullyParsedClientMessage: + clientMsg := data.Message.(common.ClientMessage) + + switch clientMsg.Type() { + case common.SetPixelFormatMsgType: + clientMsg := data.Message.(*server.MsgSetPixelFormat) + logger.Debugf("ClientRecorder.HandleRfbSegment: client message %v", *clientMsg) + r.serverInitMessage.PixelFormat = clientMsg.PF + case common.KeyEventMsgType: + clientMsg := data.Message.(*server.MsgKeyEvent) + //clientMsg.Write(r.writer) + keyevent := &pb.KeyEvent{ + Down: uint32(clientMsg.Down), + Key: uint32(clientMsg.Key), + Timestamp: timeSinceStart, + } + logger.Debug("CustomServerRecorder.HandleRfbSegment: writing bytes for KeyEventMsgType, len:", *keyevent) + + //r.demonstration.Keyevents = append(r.demonstration.Keyevents, keyevent) + case common.PointerEventMsgType: + clientMsg := data.Message.(*server.MsgPointerEvent) + + //clientMsg.Write(r.writer) + pointerevent := &pb.PointerEvent{ + Mask: uint32(clientMsg.Mask), + X: uint32(clientMsg.X), + Y: uint32(clientMsg.Y), + Timestamp: timeSinceStart, + } + logger.Debug("CustomServerRecorder.HandleRfbSegment: writing bytes for PointerEventMsgType, len:", *pointerevent) + //r.demonstration.Pointerevents = append(r.demonstration.Pointerevents, pointerevent) + + default: + //return errors.New("unknown client message type:" + string(data.UpcomingObjectType)) + } + + default: + //return errors.New("undefined RfbSegment type") + } + return nil +} + +// func (r *CustomServerRecorder) writeToDisk() error { + +// out, err := proto.Marshal(r.demonstration) +// if err != nil { +// log.Fatalln("Failed to encode address book:", err) +// } +// if err := ioutil.WriteFile(r.RBSFileName, out, 0644); err != nil { +// log.Fatalln("Failed to write address book:", err) +// } +// // timeSinceStart := getNowMillisec() - r.startTime +// // if r.buffer.Len() == 0 { +// // return nil +// // } + +// // //write buff length +// // bytesLen := r.buffer.Len() +// // binary.Write(r.writer, binary.BigEndian, uint32(bytesLen)) +// // paddedSize := (bytesLen + 3) & 0x7FFFFFFC +// // paddingSize := paddedSize - bytesLen + +// // //logger.Debugf("paddedSize=%d paddingSize=%d bytesLen=%d", paddedSize, paddingSize, bytesLen) +// // //write buffer padded to 32bit +// // _, err := r.buffer.WriteTo(r.writer) +// // padding := make([]byte, paddingSize) +// // //logger.Debugf("padding=%v ", padding) + +// // binary.Write(r.writer, binary.BigEndian, padding) + +// // //write timestamp +// // binary.Write(r.writer, binary.BigEndian, uint32(timeSinceStart)) +// // r.buffer.Reset() +// return err +// } + +// func (r *CustomServerRecorder) WriteUInt8(data uint8) error { +// buf := make([]byte, 1) +// buf[0] = byte(data) // cast int8 to byte +// return r.Write(buf) +// } + +func (r *CustomServerRecorder) Close() { + r.writer.Close() +} diff --git a/vnc_rec/proxy.go b/vnc_rec/proxy.go index 112b59f..9694529 100644 --- a/vnc_rec/proxy.go +++ b/vnc_rec/proxy.go @@ -79,43 +79,54 @@ func (vp *VncProxy) newServerConnHandler(cfg *server.ServerConfig, sconn *server return err } - var rec_s *ServerRecorder - var rec_c *ClientRecorder - //var rec_p *ProtoRecorder + // var rec_s *ServerRecorder + // var rec_c *ClientRecorder + var rec_c *CustomClientRecorder + var rec_s *CustomServerRecorder if session.Type == SessionTypeRecordingProxy { timeCurrent := strconv.FormatInt(time.Now().Unix(), 10) recFolder := path.Join(vp.RecordingDir, "recording_"+timeCurrent) os.MkdirAll(recFolder, os.ModePerm) - recServerFile := "server.rbs" - recServerPath := path.Join(recFolder, recServerFile) - rec_s, err = NewServerRecorder(recServerPath) + // recServerFile := "server.rbs" + // recServerPath := path.Join(recFolder, recServerFile) + // rec_s, err = NewServerRecorder(recServerPath) + // if err != nil { + // logger.Errorf("Proxy.newServerConnHandler can't open ServerRecorder save path: %s", recServerPath) + // return err + // } + + // 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 ServerRecorder save path: %s", recClientPath) + // return err + // } + + // sconn.Listeners.AddListener(rec_c) + + recCustomServerFile := "server.rbs" + recCustomServerPath := path.Join(recFolder, recCustomServerFile) + rec_s, err = NewCustomServerRecorder(recCustomServerPath) if err != nil { - logger.Errorf("Proxy.newServerConnHandler can't open ServerRecorder save path: %s", recServerPath) + logger.Errorf("Proxy.newServerConnHandler can't open CustomRecorder save path: %s", recCustomServerPath) return err } sconn.Listeners.AddListener(rec_s) - recClientFile := "client.rbs" - recClientPath := path.Join(recFolder, recClientFile) - rec_c, err = NewClientRecorder(recClientPath) + recCustomClientFile := "client.rbs" + recCustomClientPath := path.Join(recFolder, recCustomClientFile) + rec_c, err = NewCustomClientRecorder(recCustomClientPath) if err != nil { - logger.Errorf("Proxy.newServerConnHandler can't open ServerRecorder save path: %s", recClientPath) + logger.Errorf("Proxy.newServerConnHandler can't open CustomRecorder save path: %s", recCustomClientPath) return err } sconn.Listeners.AddListener(rec_c) - - // recProtoFile := "proto.rbs" - // recProtoPath := path.Join(recFolder, recProtoFile) - // rec_p, err = NewProtoRecorder(recProtoPath) - // if err != nil { - // logger.Errorf("Proxy.newServerConnHandler can't open ProtoRecorder save path: %s", recProtoPath) - // return err - // } - - // sconn.Listeners.AddListener(rec_p) } session.Status = SessionStatusInit @@ -132,7 +143,10 @@ func (vp *VncProxy) newServerConnHandler(cfg *server.ServerConfig, sconn *server return err } if session.Type == SessionTypeRecordingProxy { + //cconn.Listeners.AddListener(rec_c) cconn.Listeners.AddListener(rec_c) + cconn.Listeners.AddListener(rec_s) + //cconn.Listeners.AddListener(rec_s) } //creating cross-listeners between server and client parts to pass messages through the proxy: