mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2024-11-08 01:04:43 +01:00
Log and send clipboard op ids
This commit is contained in:
parent
6e84e10317
commit
b2e878e79e
@ -292,7 +292,7 @@ void SConnection::clearBinaryClipboard()
|
||||
}
|
||||
|
||||
void SConnection::addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
const rdr::U32 len)
|
||||
const rdr::U32 len, const rdr::U32 id)
|
||||
{
|
||||
binaryClipboard_t bin;
|
||||
strncpy(bin.mime, mime, sizeof(bin.mime));
|
||||
@ -301,6 +301,8 @@ void SConnection::addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
bin.data.resize(len);
|
||||
memcpy(&bin.data[0], data, len);
|
||||
|
||||
bin.id = id;
|
||||
|
||||
binaryClipboard.push_back(bin);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ namespace rfb {
|
||||
|
||||
virtual void clearBinaryClipboard();
|
||||
virtual void addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
const rdr::U32 len);
|
||||
const rdr::U32 len, const rdr::U32 id);
|
||||
|
||||
virtual void supportsQEMUKeyEvent();
|
||||
|
||||
@ -193,6 +193,7 @@ namespace rfb {
|
||||
|
||||
struct binaryClipboard_t {
|
||||
char mime[32];
|
||||
rdr::U32 id;
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ void SMsgHandler::clearBinaryClipboard()
|
||||
}
|
||||
|
||||
void SMsgHandler::addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
const rdr::U32 len)
|
||||
const rdr::U32 len, const rdr::U32 id)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace rfb {
|
||||
virtual void handleClipboardAnnounceBinary(const unsigned num, const char mimes[][32]);
|
||||
virtual void clearBinaryClipboard();
|
||||
virtual void addBinaryClipboard(const char mime[], const rdr::U8 *data,
|
||||
const rdr::U32 len);
|
||||
const rdr::U32 len, const rdr::U32 id);
|
||||
|
||||
virtual void sendStats(const bool toClient = true) = 0;
|
||||
virtual void handleFrameStats(rdr::U32 all, rdr::U32 render) = 0;
|
||||
|
@ -276,7 +276,7 @@ void SMsgReader::readBinaryClipboard()
|
||||
|
||||
vlog.debug("Received binary clipboard, type %s, %u bytes", mime, len);
|
||||
|
||||
handler->addBinaryClipboard(mime, (rdr::U8 *) ca.buf, len);
|
||||
handler->addBinaryClipboard(mime, (rdr::U8 *) ca.buf, len, 0);
|
||||
valid++;
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,9 @@ void SMsgWriter::writeBinaryClipboard(const std::vector<SConnection::binaryClipb
|
||||
os->writeU8(b.size());
|
||||
rdr::U8 i;
|
||||
for (i = 0; i < b.size(); i++) {
|
||||
const rdr::U32 id = b[i].id;
|
||||
os->writeU32(id);
|
||||
|
||||
const rdr::U8 mimelen = strlen(b[i].mime);
|
||||
os->writeU8(mimelen);
|
||||
os->writeBytes(b[i].mime, mimelen);
|
||||
|
@ -367,17 +367,18 @@ char *percentEncode4(const uint16_t *str, const unsigned len) {
|
||||
}
|
||||
|
||||
static void cliplog(const char *str, const int len, const int origlen,
|
||||
const char *dir, const char *client) {
|
||||
const char *dir, const char *client, const unsigned id) {
|
||||
if (Server::DLP_ClipLog[0] == 'o')
|
||||
return;
|
||||
if (Server::DLP_ClipLog[0] == 'i') {
|
||||
vlog.info("DLP: client %s: %s %u (%u requested) clipboard bytes", client, dir, len, origlen);
|
||||
vlog.info("DLP: client %s: %s %u (%u requested) clipboard bytes, id %u", client, dir,
|
||||
len, origlen, id);
|
||||
} else {
|
||||
// URL-encode it
|
||||
char *enc = percentEncode(str, len);
|
||||
|
||||
vlog.info("DLP: client %s: %s %u (%u requested) clipboard bytes: '%s'",
|
||||
client, dir, len, origlen, enc);
|
||||
vlog.info("DLP: client %s: %s %u (%u requested) clipboard bytes, id %u: '%s'",
|
||||
client, dir, len, origlen, id, enc);
|
||||
free(enc);
|
||||
}
|
||||
}
|
||||
@ -439,7 +440,8 @@ void VNCSConnectionST::clearBinaryClipboardData()
|
||||
|
||||
void VNCSConnectionST::sendBinaryClipboardDataOrClose(const char* mime,
|
||||
const unsigned char *data,
|
||||
const unsigned len)
|
||||
const unsigned len,
|
||||
const unsigned id)
|
||||
{
|
||||
try {
|
||||
if (!(accessRights & AccessCutText)) return;
|
||||
@ -450,10 +452,11 @@ void VNCSConnectionST::sendBinaryClipboardDataOrClose(const char* mime,
|
||||
return;
|
||||
}
|
||||
|
||||
cliplog((const char *) data, len, len, "sent", sock->getPeerAddress());
|
||||
cliplog((const char *) data, len, len, "sent", sock->getPeerAddress(),
|
||||
id);
|
||||
if (state() != RFBSTATE_NORMAL) return;
|
||||
|
||||
addBinaryClipboard(mime, data, len);
|
||||
addBinaryClipboard(mime, data, len, id);
|
||||
binclipTimer.start(100);
|
||||
} catch(rdr::Exception& e) {
|
||||
close(e.str());
|
||||
@ -1049,6 +1052,14 @@ void VNCSConnectionST::handleClipboardAnnounceBinary(const unsigned num, const c
|
||||
if (!(accessRights & AccessCutText)) return;
|
||||
if (!rfb::Server::acceptCutText) return;
|
||||
server->handleClipboardAnnounceBinary(this, num, mimes);
|
||||
|
||||
const unsigned tolog = server->clipboardId++;
|
||||
|
||||
if (Server::DLP_ClipLog[0] == 'o')
|
||||
return;
|
||||
vlog.info("DLP: client %s: %s %u clipboard mimes, id %u",
|
||||
sock->getPeerAddress(), "received",
|
||||
num, tolog);
|
||||
}
|
||||
|
||||
// supportsLocalCursor() is called whenever the status of
|
||||
|
@ -80,7 +80,7 @@ namespace rfb {
|
||||
void announceClipboardOrClose(bool available);
|
||||
void clearBinaryClipboardData();
|
||||
void sendBinaryClipboardDataOrClose(const char* mime, const unsigned char *data,
|
||||
const unsigned len);
|
||||
const unsigned len, const unsigned id);
|
||||
void getBinaryClipboardData(const char* mime, const unsigned char **data,
|
||||
unsigned *len);
|
||||
|
||||
|
@ -131,7 +131,8 @@ VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
|
||||
renderedCursorInvalid(false),
|
||||
queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance),
|
||||
lastConnectionTime(0), disableclients(false),
|
||||
frameTimer(this), apimessager(NULL), trackingFrameStats(0)
|
||||
frameTimer(this), apimessager(NULL), trackingFrameStats(0),
|
||||
clipboardId(0)
|
||||
{
|
||||
lastUserInputTime = lastDisconnectTime = time(0);
|
||||
slog.debug("creating single-threaded server %s", name.buf);
|
||||
@ -539,8 +540,10 @@ void VNCServerST::sendBinaryClipboardData(const char* mime, const unsigned char
|
||||
std::list<VNCSConnectionST*>::iterator ci, ci_next;
|
||||
for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
|
||||
ci_next = ci; ci_next++;
|
||||
(*ci)->sendBinaryClipboardDataOrClose(mime, data, len);
|
||||
(*ci)->sendBinaryClipboardDataOrClose(mime, data, len, clipboardId);
|
||||
}
|
||||
|
||||
clipboardId++;
|
||||
}
|
||||
|
||||
void VNCServerST::getBinaryClipboardData(const char* mime, const unsigned char **data,
|
||||
|
@ -281,6 +281,8 @@ namespace rfb {
|
||||
} DLPRegion;
|
||||
|
||||
void translateDLPRegion(rdr::U16 &x1, rdr::U16 &y1, rdr::U16 &x2, rdr::U16 &y2) const;
|
||||
|
||||
rdr::U32 clipboardId;
|
||||
};
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user