server and client rec

This commit is contained in:
Sibesh Kar
2019-08-06 17:56:10 +05:30
parent ce80fa1753
commit a91646069e
12 changed files with 34 additions and 19 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -79,32 +79,43 @@ func (vp *VncProxy) newServerConnHandler(cfg *server.ServerConfig, sconn *server
return err return err
} }
//var rec_s *ServerRecorder var rec_s *ServerRecorder
var rec_p *ProtoRecorder var rec_c *ClientRecorder
//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 {
// logger.Errorf("Proxy.newServerConnHandler can't open ServerRecorder save path: %s", recServerPath)
// return err
// }
// sconn.Listeners.AddListener(rec_s)
recProtoFile := "proto.rbs"
recProtoPath := path.Join(recFolder, recProtoFile)
rec_p, err = NewProtoRecorder(recProtoPath)
if err != nil { if err != nil {
logger.Errorf("Proxy.newServerConnHandler can't open ProtoRecorder save path: %s", recProtoPath) logger.Errorf("Proxy.newServerConnHandler can't open ServerRecorder save path: %s", recServerPath)
return err return err
} }
sconn.Listeners.AddListener(rec_p) 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)
// 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 session.Status = SessionStatusInit
@@ -121,7 +132,8 @@ 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_p) cconn.Listeners.AddListener(rec_s)
cconn.Listeners.AddListener(rec_c)
} }
//creating cross-listeners between server and client parts to pass messages through the proxy: //creating cross-listeners between server and client parts to pass messages through the proxy:

View File

@@ -139,7 +139,6 @@ func (r *ServerRecorder) HandleRfbSegment(data *common.RfbSegment) error {
switch common.ServerMessageType(data.UpcomingObjectType) { switch common.ServerMessageType(data.UpcomingObjectType) {
case common.FramebufferUpdate: case common.FramebufferUpdate:
logger.Debugf("ServerRecorder.HandleRfbSegment: saving FramebufferUpdate segment") logger.Debugf("ServerRecorder.HandleRfbSegment: saving FramebufferUpdate segment")
//r.writeToDisk()
case common.SetColourMapEntries: case common.SetColourMapEntries:
case common.Bell: case common.Bell:
case common.ServerCutText: case common.ServerCutText:
@@ -168,6 +167,10 @@ func (r *ServerRecorder) HandleRfbSegment(data *common.RfbSegment) error {
clientMsg := data.Message.(*server.MsgSetPixelFormat) clientMsg := data.Message.(*server.MsgSetPixelFormat)
logger.Debugf("ServerRecorder.HandleRfbSegment: client message %v", *clientMsg) logger.Debugf("ServerRecorder.HandleRfbSegment: client message %v", *clientMsg)
r.serverInitMessage.PixelFormat = clientMsg.PF r.serverInitMessage.PixelFormat = clientMsg.PF
case common.KeyEventMsgType:
r.writeToDisk()
case common.PointerEventMsgType:
r.writeToDisk()
default: default:
//return errors.New("unknown client message type:" + string(data.UpcomingObjectType)) //return errors.New("unknown client message type:" + string(data.UpcomingObjectType))
} }