mirror of
https://github.com/amitbet/vncproxy.git
synced 2026-07-14 22:14:39 +00:00
Compare commits
1 Commits
1.01
...
test_novnc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2e945c2d7 |
6
build.sh
6
build.sh
@@ -2,7 +2,7 @@
|
||||
sum="sha1sum"
|
||||
|
||||
# VERSION=`date -u +%Y%m%d`
|
||||
VERSION="v1.01"
|
||||
VERSION="v1.0"
|
||||
LDFLAGS="-X main.VERSION=$VERSION -s -w"
|
||||
GCFLAGS=""
|
||||
|
||||
@@ -24,8 +24,8 @@ fi
|
||||
|
||||
|
||||
|
||||
OSES=( linux darwin windows )
|
||||
ARCHS=(amd64 386 )
|
||||
OSES=(linux darwin windows freebsd)
|
||||
ARCHS=(amd64 386)
|
||||
for os in ${OSES[@]}; do
|
||||
for arch in ${ARCHS[@]}; do
|
||||
suffix=""
|
||||
|
||||
@@ -17,8 +17,7 @@ const (
|
||||
KeyEventMsgType
|
||||
PointerEventMsgType
|
||||
ClientCutTextMsgType
|
||||
ClientFenceMsgType = 248
|
||||
QEMUExtendedKeyEventMsgType = 255
|
||||
ClientFenceMsgType = 248
|
||||
)
|
||||
|
||||
// Color represents a single color in a color map.
|
||||
@@ -48,8 +47,6 @@ func (cmt ClientMessageType) String() string {
|
||||
return "FramebufferUpdateRequest"
|
||||
case KeyEventMsgType:
|
||||
return "KeyEvent"
|
||||
case QEMUExtendedKeyEventMsgType:
|
||||
return "QEMUExtendedKeyEvent"
|
||||
case PointerEventMsgType:
|
||||
return "PointerEvent"
|
||||
case ClientCutTextMsgType:
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"io"
|
||||
"math"
|
||||
"vncproxy/common"
|
||||
"vncproxy/logger"
|
||||
)
|
||||
|
||||
type EncCursorPseudo struct {
|
||||
@@ -21,6 +22,8 @@ func (pe *EncCursorPseudo) Read(pf *common.PixelFormat, rect *common.Rectangle,
|
||||
}
|
||||
|
||||
bytesPixel := int(pf.BPP / 8) //calcTightBytePerPixel(pf)
|
||||
logger.Infof("EncCursorPseudo bytesPerPixel= %d", bytesPixel)
|
||||
|
||||
r.ReadBytes(int(rect.Width*rect.Height) * bytesPixel)
|
||||
mask := ((rect.Width + 7) / 8) * rect.Height
|
||||
r.ReadBytes(int(math.Floor(float64(mask))))
|
||||
|
||||
@@ -155,7 +155,7 @@ func handleTightFilters(subencoding uint8, pixelFmt *common.PixelFormat, rect *c
|
||||
if paletteSize == 2 {
|
||||
dataLength = int(rect.Height) * ((int(rect.Width) + 7) / 8)
|
||||
} else {
|
||||
dataLength = int(rect.Width) * int(rect.Height)
|
||||
dataLength = int(rect.Width * rect.Height)
|
||||
}
|
||||
_, err = r.ReadTightData(dataLength)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,7 +2,7 @@ package logger
|
||||
|
||||
import "fmt"
|
||||
|
||||
var simpleLogger = SimpleLogger{LogLevelDebug}
|
||||
var simpleLogger = SimpleLogger{LogLevelInfo}
|
||||
|
||||
type Logger interface {
|
||||
Debug(v ...interface{})
|
||||
|
||||
@@ -6,15 +6,15 @@ func TestProxy(t *testing.T) {
|
||||
//create default session if required
|
||||
|
||||
proxy := &VncProxy{
|
||||
WsListeningUrl: "http://localhost:7777/", // empty = not listening on ws
|
||||
RecordingDir: "/Users/amitbet/vncRec", // empty = no recording
|
||||
TcpListeningUrl: ":5904",
|
||||
WsListeningUrl: "http://localhost:8183/", // empty = not listening on ws
|
||||
RecordingDir: "", //"/Users/amitbet/vncRec", // empty = no recording
|
||||
TcpListeningUrl: ":5905",
|
||||
//recordingDir: "C:\\vncRec", // empty = no recording
|
||||
ProxyVncPassword: "1234", //empty = no auth
|
||||
ProxyVncPassword: "", //empty = no auth
|
||||
SingleSession: &VncSession{
|
||||
TargetHostname: "localhost",
|
||||
TargetPort: "5903",
|
||||
TargetPassword: "Ch_#!T@8",
|
||||
TargetHostname: "192.168.1.101",
|
||||
TargetPort: "5900",
|
||||
TargetPassword: "ancient1", //"Ch_#!T@8", //
|
||||
ID: "dummySession",
|
||||
Status: SessionStatusInit,
|
||||
Type: SessionTypeRecordingProxy,
|
||||
|
||||
@@ -81,9 +81,9 @@ func main() {
|
||||
encs := []common.IEncoding{
|
||||
&encodings.TightEncoding{},
|
||||
//&encodings.TightPngEncoding{},
|
||||
//&encodings.RREEncoding{},
|
||||
//&encodings.ZLibEncoding{},
|
||||
//&encodings.ZRLEEncoding{},
|
||||
//rre := encodings.RREEncoding{},
|
||||
//zlib := encodings.ZLibEncoding{},
|
||||
//zrle := encodings.ZRLEEncoding{},
|
||||
//&encodings.CopyRectEncoding{},
|
||||
//coRRE := encodings.CoRREEncoding{},
|
||||
//hextile := encodings.HextileEncoding{},
|
||||
|
||||
@@ -38,7 +38,7 @@ func NewRecorder(saveFilePath string) (*Recorder, error) {
|
||||
|
||||
rec.maxWriteSize = 65535
|
||||
|
||||
rec.writer, err = os.OpenFile(saveFilePath, os.O_RDWR|os.O_CREATE, 0644)
|
||||
rec.writer, err = os.OpenFile(saveFilePath, os.O_RDWR|os.O_CREATE, 0755)
|
||||
if err != nil {
|
||||
logger.Errorf("unable to open file: %s, error: %v", saveFilePath, err)
|
||||
return nil, err
|
||||
|
||||
@@ -165,36 +165,6 @@ func (msg *MsgKeyEvent) Write(c io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MsgKeyEvent holds the wire format message.
|
||||
type MsgQEMUExtKeyEvent struct {
|
||||
SubmessageType uint8 // submessage type
|
||||
DownFlag uint16 // down-flag
|
||||
KeySym Key // key symbol
|
||||
KeyCode uint32 // scan code
|
||||
}
|
||||
|
||||
func (*MsgQEMUExtKeyEvent) Type() common.ClientMessageType {
|
||||
return common.QEMUExtendedKeyEventMsgType
|
||||
}
|
||||
|
||||
func (*MsgQEMUExtKeyEvent) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
msg := MsgKeyEvent{}
|
||||
if err := binary.Read(c, binary.BigEndian, &msg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &msg, nil
|
||||
}
|
||||
|
||||
func (msg *MsgQEMUExtKeyEvent) Write(c io.Writer) error {
|
||||
if err := binary.Write(c, binary.BigEndian, msg.Type()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := binary.Write(c, binary.BigEndian, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PointerEventMessage holds the wire format message.
|
||||
type MsgPointerEvent struct {
|
||||
Mask uint8 // button-mask
|
||||
|
||||
@@ -182,13 +182,59 @@ func (c *ServerConn) handle() error {
|
||||
switch parsedMsg.Type() {
|
||||
case common.SetPixelFormatMsgType:
|
||||
// update pixel format
|
||||
logger.Debugf("ClientUpdater.Consume: updating pixel format")
|
||||
logger.Debugf("IServerConn.Handle: updating pixel format")
|
||||
pixFmtMsg := parsedMsg.(*MsgSetPixelFormat)
|
||||
c.SetPixelFormat(&pixFmtMsg.PF)
|
||||
if pixFmtMsg.PF.TrueColor != 0 {
|
||||
c.SetColorMap(&common.ColorMap{})
|
||||
}
|
||||
|
||||
case common.FramebufferUpdateRequestMsgType:
|
||||
//logger.Infof("IServerConn.Handle: msgBuff update request")
|
||||
//updMsg := parsedMsg.(*MsgFramebufferUpdateRequest)
|
||||
//updMsg.Inc = 1
|
||||
case common.SetEncodingsMsgType:
|
||||
encMsg := parsedMsg.(*MsgSetEncodings)
|
||||
// for i, enc := range encMsg.Encodings {
|
||||
// if enc > common.EncJPEGQualityLevelPseudo1 && enc < common.EncJPEGQualityLevelPseudo10 { //common.EncCursorPseudo
|
||||
// //encMsg.EncNum--
|
||||
// //encMsg.Encodings = append(encMsg.Encodings[:i], encMsg.Encodings[i+1:]...)
|
||||
// encMsg.Encodings[i] = encMsg.Encodings[len(encMsg.Encodings)-1]
|
||||
// encMsg.Encodings[len(encMsg.Encodings)-1] = common.EncJPEGQualityLevelPseudo9
|
||||
// break
|
||||
// }
|
||||
// // if enc == common.EncCompressionLevel3 {
|
||||
// // encMsg.Encodings[i] = common.EncJPEGQualityLevelPseudo9
|
||||
// // }
|
||||
// // if enc == common.EncJPEGQualityLevelPseudo7 {
|
||||
// // encMsg.Encodings[i] = common.EncJPEGQualityLevelPseudo9
|
||||
// // }
|
||||
// }
|
||||
|
||||
encMsg.Encodings = []common.EncodingType{
|
||||
common.EncDesktopSizePseudo,
|
||||
common.EncExtendedDesktopSizePseudo,
|
||||
common.EncLastRectPseudo,
|
||||
common.EncContinuousUpdatesPseudo,
|
||||
common.EncCursorPseudo,
|
||||
common.EncFencePseudo,
|
||||
common.EncHextile,
|
||||
common.EncCopyRect,
|
||||
common.EncTight,
|
||||
common.EncZRLE,
|
||||
common.EncRRE,
|
||||
common.EncRaw,
|
||||
common.EncCompressionLevel2,
|
||||
common.EncJPEGQualityLevelPseudo1,
|
||||
common.EncQEMUExtendedKeyEventPseudo,
|
||||
common.EncTightPng,
|
||||
common.EncXvpPseudo,
|
||||
}
|
||||
encMsg.EncNum = uint16(len(encMsg.Encodings))
|
||||
|
||||
//bad: EncCopyRect EncTight EncTightPng EncHextile EncRRE EncRaw EncJPEGQualityLevelPseudo7 EncCompressionLevel3 EncDesktopSizePseudo EncLastRectPseudo EncCursorPseudo EncQEMUExtendedKeyEventPseudo EncExtendedDesktopSizePseudo EncXvpPseudo EncFencePseudo EncContinuousUpdatesPseudo
|
||||
}
|
||||
|
||||
////////
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user