mirror of
https://github.com/amitbet/vncproxy.git
synced 2025-09-23 10:28:54 +00:00
added serverInit listening and recorder adaptation for being created outside of the client
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"net"
|
||||
"unicode"
|
||||
"vncproxy/common"
|
||||
"vncproxy/tee-listeners"
|
||||
)
|
||||
|
||||
// A ServerMessage implements a message sent from the server to the client.
|
||||
@@ -21,11 +20,11 @@ type ClientAuth interface {
|
||||
|
||||
// Handshake is called when the authentication handshake should be
|
||||
// performed, as part of the general RFB handshake. (see 7.2.1)
|
||||
Handshake(net.Conn) error
|
||||
Handshake(io.ReadWriteCloser) error
|
||||
}
|
||||
|
||||
type ClientConn struct {
|
||||
conn net.Conn
|
||||
conn io.ReadWriteCloser
|
||||
|
||||
//c net.Conn
|
||||
config *ClientConfig
|
||||
@@ -77,6 +76,7 @@ type ClientConfig struct {
|
||||
// This only needs to contain NEW server messages, and doesn't
|
||||
// need to explicitly contain the RFC-required messages.
|
||||
ServerMessages []common.ServerMessage
|
||||
Listener common.SegmentConsumer
|
||||
}
|
||||
|
||||
func Client(c net.Conn, cfg *ClientConfig) (*ClientConn, error) {
|
||||
@@ -438,6 +438,15 @@ FindAuth:
|
||||
}
|
||||
|
||||
c.DesktopName = string(nameBytes)
|
||||
srvInit := common.ServerInit{
|
||||
NameLength: nameLength,
|
||||
NameText: nameBytes,
|
||||
FBHeight: c.FrameBufferHeight,
|
||||
FBWidth: c.FrameBufferWidth,
|
||||
PixelFormat: c.PixelFormat,
|
||||
}
|
||||
rfbSeg := &common.RfbSegment{SegmentType: common.SegmentServerInitMessage, Message: &srvInit}
|
||||
c.config.Listener.Consume(rfbSeg)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -446,9 +455,8 @@ FindAuth:
|
||||
// proper channels for users of the client to read.
|
||||
func (c *ClientConn) mainLoop() {
|
||||
defer c.Close()
|
||||
rec := listeners.NewRecorder("/Users/amitbet/recording.rbs", c.DesktopName, c.FrameBufferWidth, c.FrameBufferHeight)
|
||||
|
||||
reader := &common.RfbReadHelper{Reader: c.conn, Listener: rec}
|
||||
reader := &common.RfbReadHelper{Reader: c.conn, Listener: c.config.Listener}
|
||||
// Build the map of available server messages
|
||||
typeMap := make(map[uint8]common.ServerMessage)
|
||||
|
||||
|
@@ -1,13 +1,11 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"crypto/des"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
)
|
||||
|
||||
|
||||
// ClientAuthNone is the "none" authentication. See 7.2.1
|
||||
type ClientAuthNone byte
|
||||
|
||||
@@ -15,7 +13,7 @@ func (*ClientAuthNone) SecurityType() uint8 {
|
||||
return 1
|
||||
}
|
||||
|
||||
func (*ClientAuthNone) Handshake(net.Conn) error {
|
||||
func (*ClientAuthNone) Handshake(closer io.ReadWriteCloser) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -28,7 +26,7 @@ func (p *PasswordAuth) SecurityType() uint8 {
|
||||
return 2
|
||||
}
|
||||
|
||||
func (p *PasswordAuth) Handshake(c net.Conn) error {
|
||||
func (p *PasswordAuth) Handshake(c io.ReadWriteCloser) error {
|
||||
randomValue := make([]uint8, 16)
|
||||
if err := binary.Read(c, binary.BigEndian, &randomValue); err != nil {
|
||||
return err
|
||||
@@ -36,7 +34,7 @@ func (p *PasswordAuth) Handshake(c net.Conn) error {
|
||||
|
||||
crypted, err := p.encrypt(p.Password, randomValue)
|
||||
|
||||
if (err != nil) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -87,7 +85,7 @@ func (p *PasswordAuth) reverseBits(b byte) byte {
|
||||
}
|
||||
|
||||
func (p *PasswordAuth) encrypt(key string, bytes []byte) ([]byte, error) {
|
||||
keyBytes := []byte{0,0,0,0,0,0,0,0}
|
||||
keyBytes := []byte{0, 0, 0, 0, 0, 0, 0, 0}
|
||||
|
||||
if len(key) > 8 {
|
||||
key = key[:8]
|
||||
|
Reference in New Issue
Block a user