mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 12:32:29 +00:00
gst/librfb/gstrfbsrc.c: Add password property (write only)
Original commit message from CVS: * gst/librfb/gstrfbsrc.c: Add password property (write only) * gst/librfb/rfbdecoder.c: Read the reason on failure Use the password property for authentication * gst/librfb/rfbdecoder.h: Add defines for version checking
This commit is contained in:
parent
416a4f18cf
commit
a458032e6e
4 changed files with 65 additions and 11 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2007-09-19 Thijs Vermeir <thijsvermeir@gmail.com>
|
||||
|
||||
* gst/librfb/gstrfbsrc.c:
|
||||
Add password property (write only)
|
||||
* gst/librfb/rfbdecoder.c:
|
||||
Read the reason on failure
|
||||
Use the password property for authentication
|
||||
* gst/librfb/rfbdecoder.h:
|
||||
Add defines for version checking
|
||||
|
||||
2007-09-19 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* ext/directfb/dfbvideosink.c: (gst_dfbvideosink_surface_destroy),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <2007> Thijs Vermeir <thijsvermeir@gmail.com>
|
||||
* Copyright (C) <2006> Andre Moreira Magalhaes <andre.magalhaes@indt.org.br>
|
||||
* Copyright (C) <2004> David A. Schleef <ds@schleef.org>
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
|
@ -36,6 +37,7 @@ enum
|
|||
ARG_HOST,
|
||||
ARG_PORT,
|
||||
ARG_VERSION,
|
||||
ARG_PASSWORD,
|
||||
};
|
||||
|
||||
#define RGB332_R(x) ((((x)&0x07) * 0x124)>>3)
|
||||
|
@ -50,7 +52,8 @@ GST_ELEMENT_DETAILS ("Rfb source",
|
|||
"Source/Video",
|
||||
"Creates a rfb video stream",
|
||||
"David A. Schleef <ds@schleef.org>, "
|
||||
"Andre Moreira Magalhaes <andre.magalhaes@indt.org.br");
|
||||
"Andre Moreira Magalhaes <andre.magalhaes@indt.org.br>, "
|
||||
"Thijs Vermeir <thijsvermeir@gmail.com>");
|
||||
|
||||
static GstStaticPadTemplate gst_rfb_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
|
@ -120,6 +123,9 @@ gst_rfb_src_class_init (GstRfbSrcClass * klass)
|
|||
g_object_class_install_property (gobject_class, ARG_VERSION,
|
||||
g_param_spec_string ("version", "RFB protocol version",
|
||||
"RFB protocol version", "3.3", G_PARAM_READWRITE));
|
||||
g_object_class_install_property (gobject_class, ARG_PASSWORD,
|
||||
g_param_spec_string ("password", "Password for authentication",
|
||||
"Password for authentication", "", G_PARAM_WRITABLE));
|
||||
|
||||
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_rfb_src_start);
|
||||
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_rfb_src_stop);
|
||||
|
@ -142,6 +148,9 @@ gst_rfb_src_init (GstRfbSrc * src, GstRfbSrcClass * klass)
|
|||
src->port = 5900;
|
||||
src->version_major = 3;
|
||||
src->version_minor = 3;
|
||||
|
||||
src->decoder = rfb_decoder_new ();
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -213,6 +222,10 @@ gst_rfb_src_set_property (GObject * object, guint prop_id,
|
|||
case ARG_VERSION:
|
||||
gst_rfb_property_set_version (src, g_strdup (g_value_get_string (value)));
|
||||
break;
|
||||
case ARG_PASSWORD:
|
||||
g_free (src->decoder->password);
|
||||
src->decoder->password = g_strdup (g_value_get_string (value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -250,7 +263,7 @@ gst_rfb_src_start (GstBaseSrc * bsrc)
|
|||
RfbDecoder *decoder;
|
||||
GstCaps *caps;
|
||||
|
||||
decoder = rfb_decoder_new ();
|
||||
decoder = src->decoder;
|
||||
|
||||
GST_DEBUG_OBJECT (src, "connecting to host %s on port %d",
|
||||
src->host, src->port);
|
||||
|
|
|
@ -60,6 +60,8 @@ rfb_decoder_new (void)
|
|||
decoder->fd = -1;
|
||||
decoder->bytestream = rfb_bytestream_new ();
|
||||
|
||||
decoder->password = NULL;
|
||||
|
||||
return decoder;
|
||||
}
|
||||
|
||||
|
@ -263,8 +265,17 @@ rfb_decoder_state_wait_for_protocol_version (RfbDecoder * decoder)
|
|||
static gboolean
|
||||
rfb_decoder_state_reason (RfbDecoder * decoder)
|
||||
{
|
||||
/* \TODO Read the reason from the server why he quits */
|
||||
return TRUE;
|
||||
RfbBuffer *buffer;
|
||||
gint reason_length;
|
||||
|
||||
rfb_bytestream_read (decoder->bytestream, &buffer, 4);
|
||||
reason_length = RFB_GET_UINT32 (buffer->data);
|
||||
rfb_buffer_free (buffer);
|
||||
rfb_bytestream_read (decoder->bytestream, &buffer, reason_length);
|
||||
GST_WARNING ("Reason by server: %s", buffer->data);
|
||||
rfb_buffer_free (buffer);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -280,7 +291,7 @@ rfb_decoder_state_wait_for_security (RfbDecoder * decoder)
|
|||
* connection has failed and is followed by a string giving the reason, as described
|
||||
* above.
|
||||
*/
|
||||
if (decoder->protocol_major == 3 && decoder->protocol_minor == 3) {
|
||||
if (IS_VERSION_3_3 (decoder)) {
|
||||
ret = rfb_bytestream_read (decoder->bytestream, &buffer, 4);
|
||||
g_return_val_if_fail (ret == 4, FALSE);
|
||||
|
||||
|
@ -296,8 +307,11 @@ rfb_decoder_state_wait_for_security (RfbDecoder * decoder)
|
|||
switch (decoder->security_type) {
|
||||
case SECURITY_NONE:
|
||||
GST_DEBUG ("Security type is None");
|
||||
/* \TODO version 3.8 goes to the security result */
|
||||
decoder->state = rfb_decoder_state_send_client_initialisation;
|
||||
if (IS_VERSION_3_8 (decoder)) {
|
||||
decoder->state = rfb_decoder_state_security_result;
|
||||
} else {
|
||||
decoder->state = rfb_decoder_state_send_client_initialisation;
|
||||
}
|
||||
break;
|
||||
case SECURITY_VNC:
|
||||
/**
|
||||
|
@ -305,18 +319,25 @@ rfb_decoder_state_wait_for_security (RfbDecoder * decoder)
|
|||
* server sends a random 16-byte challenge
|
||||
*/
|
||||
GST_DEBUG ("Security type is VNC Authentication");
|
||||
/* VNC Authentication can't be used if the password is not set */
|
||||
if (!decoder->password) {
|
||||
GST_WARNING
|
||||
("VNC Authentication can't be used if the password is not set");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = rfb_bytestream_read (decoder->bytestream, &buffer, 16);
|
||||
g_return_val_if_fail (ret == 16, FALSE);
|
||||
vncEncryptBytes ((unsigned char *) buffer->data, "testtest");
|
||||
vncEncryptBytes ((unsigned char *) buffer->data, decoder->password);
|
||||
rfb_decoder_send (decoder, buffer->data, 16);
|
||||
rfb_buffer_free (buffer);
|
||||
|
||||
GST_DEBUG ("Encrypted challenge send to server");
|
||||
|
||||
decoder->state = rfb_decoder_state_security_result;
|
||||
break;
|
||||
default:
|
||||
GST_INFO ("Security type is not known");
|
||||
GST_WARNING ("Security type is not known");
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -336,8 +357,11 @@ rfb_decoder_state_security_result (RfbDecoder * decoder)
|
|||
ret = rfb_bytestream_read (decoder->bytestream, &buffer, 4);
|
||||
g_return_val_if_fail (ret == 4, FALSE);
|
||||
if (RFB_GET_UINT32 (buffer->data) != 0) {
|
||||
GST_INFO ("Security handshaking failed");
|
||||
/* \TODO version 3.8 gives a reason why it failed */
|
||||
GST_WARNING ("Security handshaking failed");
|
||||
if (IS_VERSION_3_8 (decoder)) {
|
||||
decoder->state = rfb_decoder_state_reason;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@ enum {
|
|||
SECURITY_VNC,
|
||||
};
|
||||
|
||||
#define IS_VERSION(x, ma, mi) ((x->protocol_major == ma) && (x->protocol_minor == mi))
|
||||
#define IS_VERSION_3_3(x) IS_VERSION(x, 3, 3)
|
||||
#define IS_VERSION_3_7(x) IS_VERSION(x, 3, 7)
|
||||
#define IS_VERSION_3_8(x) IS_VERSION(x, 3, 8)
|
||||
|
||||
typedef struct _RfbDecoder RfbDecoder;
|
||||
|
||||
struct _RfbDecoder
|
||||
|
@ -41,6 +46,8 @@ struct _RfbDecoder
|
|||
guint protocol_minor;
|
||||
guint security_type;
|
||||
|
||||
gchar *password;
|
||||
|
||||
guint width;
|
||||
guint height;
|
||||
guint bpp;
|
||||
|
|
Loading…
Reference in a new issue