Translate

Friday, June 5, 2015

Monitoring localhost to localhost Restful calls in Windows 7 (Monitor Windows 7 localhost traffic in wireshark)

Easy way: Force all localhost traffic thru your network card.

If you run route print you would see something like this


































Here 10.118.183.252 is my local ipv4 address. As you can see any request to that ipaddress is short circuited by the operating system. It doesn't go thru my network card. To see the local host traffic in wireshark you need to perform these two steps

1>Modify routes to send all traffic for local ip address thru your default gateway (in this case 10.118.183.253)

route delete 10.118.183.252
route ADD 10.118.183.252  MASK 255.255.255.255 10.118.183.253

(This change is temporary. These changes will be lost when you restart your machine. to make these chages persistent use route -p instead of route)

2>Instead of localhost use your local ipaddress in all urls.


There you are all set!



An Alternative way


1>  Install microsoft loopback adapter.


2>Make sure you can ping loop back adapter by its static ip address. Otherwise further steps would fail.























After successfully completing this step, restart the machine.

2>Install Wireshark. (with winpcap, when prompted)
 If wireshark is already installed, reinstall after restart. Otherwise Wireshark won't see this new network interface.

3>Install rawcap

4>Start rawcap by double clicking it. Select the  Loop back adapter when prompted.


5>After you have captured all the traffic you need, stop rawcap by pressing ctrl+c.

6>Now doubleclick and open dumpfile.pcap.

I tested this for tomcat and IIS. 

Monday, June 1, 2015

Extjs dropdownlist

You could extend Ext.form.ComboBox to create a dropdownlist. In the example below all I have set is editable:false. That is enough to make it a dropdownlist.


The dropdownlist control


Ext.define('DropDownList', {
    extend: 'Ext.form.ComboBox',
    editable: false,

    alias: 'widget.dropdownlist',
    initComponent: function() {
        this.callParent([arguments]);
    },
    onRender: function() {
        this.callParent();

    }
});





The app.js that uses this control


var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data: [{
        "abbr": "AL",
        "name": "Alabama"    }, {
        "abbr": "AK",
        "name": "Alaska"    }, {
        "abbr": "AZ",
        "name": "Arizona"    }]
});




Ext.application({

    name: 'MyApp',
    launch: function () {


        Ext.create('Ext.form.Panel', {

            items: [
                {
                    xtype: 'dropdownlist',
                    hideLabel: false,
                    title: 'ComboBox Test',
                    fieldLabel: 'Choose State',
                    store: states,
                    displayField: 'name',
                    valueField: 'abbr',
                    renderTo: Ext.getBody()
                }
            ]

        });
    }
});

Extjs Hello World application (Begginers introduction to extjs)

Show Hello World Alert

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/4.2.1/ext-all.js"></script>
<script type="text/javascript">

    Ext.application({
        name: 'MyApp',

        launch: function () {
            alert("Hello World");

        }
    });
</script>

</body>
</html>


Show Hello World HTML


<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/4.2.1/ext-all.js"></script>
<script type="text/javascript">
var myComponent=Ext.create('Ext.Component',{
    html: 'HelloWorld'});

Ext.application({
    name: 'MyApp',

    launch: function () {
        Ext.create('Ext.container.Viewport', {
            items: [
                    myComponent            ]
        });
    }
});
</script> </body> </html>
The above code can also be written in a short hand way using xtype (preferred way)

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/4.2.1/ext-all.js"></script>
<script type="text/javascript">
Ext.application({
    name: 'MyApp',
    launch: function () {
        Ext.create('Ext.container.Viewport', {
            items: [
                {
                    xtype: 'component',
                    html: 'HelloWorld'                }
            ]
        });
    }
});
</script> </body> </html>