Search in sources :

Example 16 with PipelineImpl

use of streamer.PipelineImpl in project cloudstack by apache.

the class ClientX224ConnectionRequestPDU method main.

/**
     * Example.
     *
     * @see http://msdn.microsoft.com/en-us/library/cc240842.aspx
     * @see http://msdn.microsoft.com/en-us/library/cc240500.aspx
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    String cookie = "eltons";
    byte[] packet = new byte[] { // TPKT Header: version = 3
    0x03, // TPKT Header: Reserved = 0
    0x00, // TPKT Header: Packet length - high part
    0x00, // TPKT Header: Packet length - low part (total = 44 bytes)
    0x2c, // X.224: Length indicator (39 bytes)
    0x27, // X.224: Type (high nibble) = 0xe = CR TPDU;
    (byte) 0xe0, // X.224: Destination reference = 0
    0x00, // X.224: Destination reference = 0
    0x00, // X.224: Source reference = 0
    0x00, // X.224: Source reference = 0
    0x00, // X.224: Class and options = 0
    0x00, // "Cookie: mstshash=eltons"
    'C', // "Cookie: mstshash=eltons"
    'o', // "Cookie: mstshash=eltons"
    'o', // "Cookie: mstshash=eltons"
    'k', // "Cookie: mstshash=eltons"
    'i', // "Cookie: mstshash=eltons"
    'e', // "Cookie: mstshash=eltons"
    ':', // "Cookie: mstshash=eltons"
    ' ', // "Cookie: mstshash=eltons"
    'm', // "Cookie: mstshash=eltons"
    's', // "Cookie: mstshash=eltons"
    't', // "Cookie: mstshash=eltons"
    's', // "Cookie: mstshash=eltons"
    'h', // "Cookie: mstshash=eltons"
    'a', // "Cookie: mstshash=eltons"
    's', // "Cookie: mstshash=eltons"
    'h', // "Cookie: mstshash=eltons"
    '=', // "Cookie: mstshash=eltons"
    'e', // "Cookie: mstshash=eltons"
    'l', // "Cookie: mstshash=eltons"
    't', // "Cookie: mstshash=eltons"
    'o', // "Cookie: mstshash=eltons"
    'n', // "Cookie: mstshash=eltons"
    's', // -Cookie terminator sequence
    '\r', // -Cookie terminator sequence
    '\n', // RDP_NEG_REQ::type (TYPE_RDP_NEG_REQ)
    0x01, // RDP_NEG_REQ::flags (0)
    0x00, // RDP_NEG_REQ::length (8 bytes)
    0x08, // RDP_NEG_REQ::length (8 bytes)
    0x00, // RDP_NEG_REQ: Requested protocols
    0x01, // RDP_NEG_REQ: Requested protocols
    0x00, // RDP_NEG_REQ: Requested protocols
    0x00, // RDP_NEG_REQ: Requested protocols
    0x00 };
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }));
    Element cr = new ClientX224ConnectionRequestPDU("cr", cookie, RdpConstants.RDP_NEG_REQ_PROTOCOL_SSL);
    Element tpkt = new ClientTpkt("tpkt");
    Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(packet));
    Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }));
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, cr, tpkt, sink, mainSink);
    pipeline.link("source", "cr", "mainSink");
    pipeline.link("cr >" + OTOUT, "tpkt", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) Pipeline(streamer.Pipeline)

Example 17 with PipelineImpl

use of streamer.PipelineImpl in project cloudstack by apache.

the class ClientMCSAttachUserRequest method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    /* @formatter:off */
    byte[] packet = new byte[] { //  TPKT Header (length = 8 bytes)
    0x03, //  TPKT Header (length = 8 bytes)
    0x00, //  TPKT Header (length = 8 bytes)
    0x00, //  TPKT Header (length = 8 bytes)
    0x08, //  X.224 Data TPDU
    0x02, //  X.224 Data TPDU
    (byte) 0xf0, //  X.224 Data TPDU
    (byte) 0x80, // PER encoded (ALIGNED variant of BASIC-PER) PDU contents:
    0x28 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }));
    Element todo = new ClientMCSAttachUserRequest("TODO");
    Element x224 = new ClientX224DataPDU("x224");
    Element tpkt = new ClientTpkt("tpkt");
    Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(packet));
    Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }));
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, todo, x224, tpkt, sink, mainSink);
    pipeline.link("source", "TODO", "mainSink");
    pipeline.link("TODO >" + OTOUT, "x224", "tpkt", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) Pipeline(streamer.Pipeline)

Example 18 with PipelineImpl

use of streamer.PipelineImpl in project cloudstack by apache.

the class ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs method main.

/**
     * Example.
     *
     * @see http://msdn.microsoft.com/en-us/library/cc240834.aspx
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    /* @formatter:off */
    byte[] clientRequestPacket = new byte[] { //  TPKT Header (length = 12 bytes)
    0x03, //  TPKT Header (length = 12 bytes)
    0x00, //  TPKT Header (length = 12 bytes)
    0x00, //  TPKT Header (length = 12 bytes)
    0x0c, //  X.224 Data TPDU
    0x02, //  X.224 Data TPDU
    (byte) 0xf0, //  X.224 Data TPDU
    (byte) 0x80, // PER encoded (ALIGNED variant of BASIC-PER) PDU contents:
    0x38, 0x00, 0x03, 0x03, (byte) 0xef };
    byte[] serverResponsePacket = new byte[] { // MCS Channel Confirm
    (byte) 0x3e, // result: rt-successful (0)
    (byte) 0x00, // Initiator: 1007 (6+1001)
    (byte) 0x00, (byte) 0x06, // Requested channel
    (byte) 0x03, (byte) 0xef, // Actual channel
    (byte) 0x03, (byte) 0xef };
    /* @formatter:on */
    RdpState rdpState = new RdpState();
    rdpState.serverUserChannelId = 1004;
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(serverResponsePacket, new byte[] { 1, 2, 3 }));
    Element todo = new ClientMCSChannelJoinRequestServerMCSChannelConfirmPDUs("channels", new int[] { 1007 }, rdpState);
    Element x224 = new ClientX224DataPDU("x224");
    Element tpkt = new ClientTpkt("tpkt");
    Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers(clientRequestPacket));
    Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }));
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, todo, x224, tpkt, sink, mainSink);
    pipeline.link("source", "channels", "mainSink");
    pipeline.link("channels >" + OTOUT, "x224", "tpkt", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) Pipeline(streamer.Pipeline)

Example 19 with PipelineImpl

use of streamer.PipelineImpl in project cloudstack by apache.

the class VncMessageHandler method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    Element source = new MockSource("source") {

        {
            // Split messages at random boundaries to check "pushback" logic
            bufs = ByteBuffer.convertByteArraysToByteBuffers(new byte[] { // Message type: server bell
            RfbConstants.SERVER_BELL, // Message type: clipboard text
            RfbConstants.SERVER_CUT_TEXT, // Padding
            0, 0, 0, // Length (test)
            0, 0, 0, 4 }, new byte[] { // Clipboard text
            't', 'e', 's', 't', // Message type: frame buffer update
            RfbConstants.SERVER_FRAMEBUFFER_UPDATE, // Padding
            0, // Number of rectangles
            0, 3 }, new byte[] { // x, y, width, height: 0x0@4x4
            0, 0, 0, 0, 0, 4, 0, 4, // Encoding: desktop size
            (byte) ((RfbConstants.ENCODING_DESKTOP_SIZE >> 24) & 0xff), (byte) ((RfbConstants.ENCODING_DESKTOP_SIZE >> 16) & 0xff), (byte) ((RfbConstants.ENCODING_DESKTOP_SIZE >> 8) & 0xff), (byte) ((RfbConstants.ENCODING_DESKTOP_SIZE >> 0) & 0xff) }, new byte[] { // x, y, width, height: 0x0@4x4
            0, 0, 0, 0, 0, 4, 0, 4, // Encoding: raw rect
            (byte) ((RfbConstants.ENCODING_RAW >> 24) & 0xff), (byte) ((RfbConstants.ENCODING_RAW >> 16) & 0xff), (byte) ((RfbConstants.ENCODING_RAW >> 8) & 0xff), (byte) ((RfbConstants.ENCODING_RAW >> 0) & 0xff), // Raw pixel data 4x4x1 bpp
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, new byte[] { 11, 12, 13, 14, 15, 16, // x, y, width, height: 0x0@2x2
            0, 0, 0, 0, 0, 2, 0, 2, // Encoding: copy rect
            (byte) ((RfbConstants.ENCODING_COPY_RECT >> 24) & 0xff), (byte) ((RfbConstants.ENCODING_COPY_RECT >> 16) & 0xff), (byte) ((RfbConstants.ENCODING_COPY_RECT >> 8) & 0xff), (byte) ((RfbConstants.ENCODING_COPY_RECT >> 0) & 0xff), // srcX, srcY: 2x2
            0, 2, 0, 2 });
        }
    };
    ScreenDescription screen = new ScreenDescription() {

        {
            bytesPerPixel = 1;
        }
    };
    final Element handler = new VncMessageHandler("handler", screen);
    ByteBuffer[] emptyBuf = ByteBuffer.convertByteArraysToByteBuffers(new byte[] {});
    Element fburSink = new MockSink("fbur", ByteBuffer.convertByteArraysToByteBuffers(new byte[] {}, new byte[] {}));
    Element bellSink = new MockSink("bell", emptyBuf);
    Element clipboardSink = new MockSink("clipboard", emptyBuf);
    Element desktopSizeChangeSink = new MockSink("desktop_size", emptyBuf);
    Element pixelsSink = new MockSink("pixels", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }));
    Element copyRectSink = new MockSink("copy_rect", emptyBuf);
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(source, handler);
    pipeline.add(fburSink, bellSink, clipboardSink, desktopSizeChangeSink, pixelsSink, copyRectSink);
    pipeline.link("handler >" + FRAME_BUFFER_UPDATE_REQUEST_ADAPTER_PAD, "fbur");
    pipeline.link("handler >" + SERVER_BELL_ADAPTER_PAD, "bell");
    pipeline.link("handler >" + SERVER_CLIPBOARD_ADAPTER_PAD, "clipboard");
    pipeline.link("handler >" + PIXEL_ADAPTER_PAD, "pixels");
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) ScreenDescription(common.ScreenDescription) ByteBuffer(streamer.ByteBuffer) Pipeline(streamer.Pipeline)

Example 20 with PipelineImpl

use of streamer.PipelineImpl in project cloudstack by apache.

the class Vnc33Authentication method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    final String password = "test";
    Element source = new MockSource("source") {

        {
            bufs = ByteBuffer.convertByteArraysToByteBuffers(// Request authentication and send 16 byte challenge
            new byte[] { 0, 0, 0, RfbConstants.VNC_AUTH, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, // Respond to challenge with AUTH_OK
            new byte[] { 0, 0, 0, RfbConstants.VNC_AUTH_OK });
        }
    };
    Element mainSink = new FakeSink("mainSink");
    final Vnc33Authentication auth = new Vnc33Authentication("auth", password);
    Element initSink = new MockSink("initSink") {

        {
            // Expect encoded password
            bufs = new ByteBuffer[] { auth.encodePassword(new ByteBuffer(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }), password) };
        }
    };
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(source, auth, mainSink);
    pipeline.add(initSink);
    pipeline.link("auth >otout", "initSink");
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) FakeSink(streamer.debug.FakeSink) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) ByteBuffer(streamer.ByteBuffer) Pipeline(streamer.Pipeline)

Aggregations

Pipeline (streamer.Pipeline)32 PipelineImpl (streamer.PipelineImpl)32 Element (streamer.Element)28 MockSource (streamer.debug.MockSource)25 MockSink (streamer.debug.MockSink)24 BaseElement (streamer.BaseElement)14 ByteBuffer (streamer.ByteBuffer)7 ScreenDescription (common.ScreenDescription)6 FakeSink (streamer.debug.FakeSink)3 InetSocketAddress (java.net.InetSocketAddress)2 SSLState (streamer.ssl.SSLState)2 RdpBufferedImageCanvas (com.cloud.consoleproxy.rdp.RdpBufferedImageCanvas)1 BufferedImageCanvas (common.BufferedImageCanvas)1 SizeChangeListener (common.SizeChangeListener)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 RdpClient (rdpclient.RdpClient)1 ServerBitmapUpdate (rdpclient.rdp.ServerBitmapUpdate)1