mzdrale / pyubee

Simple library for getting stats from Ubee routers.
GNU General Public License v3.0
2 stars 4 forks source link

UBC1301-AA00 support? #10

Open saicrazyfire opened 5 years ago

saicrazyfire commented 5 years ago

I have a modem provided by RCN with their 1 GBps package so they have provided me with a modem with DOCSIS 3.1 support. Any chance in supporting this device?

Model No.  : | UBC1301AA00 Specification Compliant  : | DOCSIS 3.1

http://www.ubeeinteractive.com/products/cable/voice-gateways/ubc1301-aa00-docsis-31-advanced-wireless-voice-gateway

StevenLooman commented 5 years ago

It's time to write a contributing-document. :)

The first steps is to discover the URLs your device uses. Lets assume the IP of your modem is 192.168.1.1, can you try this URL? http://192.168.1.1/RootDevice.xml Not all devices have this, but it is used for auto-detecting the type of the modem. If your device doesn't have this, don't worry. If it does, please add the file RootDevice.xml to this issue.

Then, the next step is to determine the URLs to:

You can get these by browsing to the web interface of your modem and copy them to this issue.

saicrazyfire commented 5 years ago

Sure, I'd love to help.

For this model, I was unable to find RootDevice.xml through URL manipulation. My router IP is 192.168.0.1, so I tried 192.168.0.1/RootDevice.xml as well as 192.168.0.1/htdocs/RootDevice.xml. I tried the latter since it looks like an apache directory and the "homepage" of the router is a php file.

Before login

Navigating to 192.168.0.1 shows me a general stats page, with a link to login

image

I click on "Please click here to login" and then get prompted for username and password. This is the standard basic auth you see in a lot of webpages. The URL for this login is http://192.168.0.1/htdocs/cm_info_status.php

Logout

image

Theres tabs up top, with one of them being logout. This link directly logs you out and the URL for it is http://192.168.0.1/htdocs/unauth.php

To view connected devices

Navigate to Gateway -> Mangement -> Client List

image

Direct URL to this page is: http://192.168.0.1/htdocs/rg_mgt_clientlist.php

In the Interfaces column, this is where you'll know how the device is connected. The various values I have are:

I assume wl1 and wl0 are the wireless access points, 2.4 GHz and 5 GHz (not sure which is which). I have an unmanaged switch connected to LAN3 so many devices will report connected to it. I also have a direct connection to my desktop to LAN4 so it shows up as LAN4 here.

URL Summary

I hope this helps

StevenLooman commented 5 years ago

Thank you for the information, this is already helpful. I need a little bit more. I've written a guide to help you get all the information we need: https://github.com/mzdrale/pyubee/blob/master/ADDING_NEW_MODELS.md

Can you follow this guide and provide the required information? Feel free to comment on the guide, this is just a first version.

mzdrale commented 5 years ago

Thanks @saicrazyfire for the information, but could you please go through ADDING NEW MODELS guide and provide the required information, as @StevenLooman requested in previous comment?

saicrazyfire commented 5 years ago

I tried to gather information but it seems like my model is quite different. I'll try my best to answer the questions in the Adding new models questionnaire.

My router IP is 192.168.0.1 in this context

Auto-detect the model

HTTP 404 error - page not found when navigating to 192.168.0.1/RootDevice.xml.

Log in

There is no < form > tag in the page source. The page actually is just a link, which calls htdocs/cm_info_status.php to login (see above pictures)

Log out

Logout link is http://192.168.0.1/htdocs/unauth.php

Check if we are logged in

Not sure what to get here. The HTML source for the login page does not have any < input > elements nor any class names

Get the connected devices via LAN

As stated above, the client list is located at this url http://192.168.0.1/htdocs/rg_mgt_clientlist.php

What is interesting is that the table is not filled out in HTML, but with a javascript function. There is a javascript variable within < script > tag that contains a JSON dictionary of all relevant details (e.g.

var rg_mgt_cpestatus_jason = ' ${JSON STRING HERE} '
var rg_mgt_cpestatus_obj = jQuery.parseJSON (rg_mgt_cpestatus_jason);
var rg_lan_dhcpinfo_json = ' ${JSON STRING HERE} '
var rg_lan_dhcpinfo_obj = jQuery.parseJSON(rg_lan_dhcpinfo_json);

Sample JSON for rg_mgt_cpestatus_jason and possibliy rg_lan_dhcpinfo_json as well

{
    "mgt_cpestatus_table": [{
        "Interface": "Eth-Switch LAN(1)",
        "Ethno": "0",
        "Status": "1"
    }, {
        "Interface": "Eth-Switch LAN(2)",
        "Ethno": "1",
        "Status": "1"
    }, {
        "Interface": "Eth-Switch LAN(3)",
        "Ethno": "2",
        "Status": "1"
    }, {
        "Interface": "Eth-Switch LAN(4)",
        "Ethno": "3",
        "Status": "1"
    }],
    "lan_dhcpinfo_table": [{
        "lan_dhcpinfo_hostname": "XXXXX",
        "lan_dhcpinfo_ip_address": "192.168.0.XX",
        "lan_dhcpinfo_mac_address": "XX:XX:XX:XX:XX:XX",
        "lan_dhcpinfo_expire_time": "",
        "lan_dhcpinfo_interface": "eth2"
    }, {
        "lan_dhcpinfo_hostname": "Unknown",
        "lan_dhcpinfo_ip_address": "192.168.0.XX",
        "lan_dhcpinfo_mac_address": "XX:XX:XX:XX:XX:XX",
        "lan_dhcpinfo_expire_time": "",
        "lan_dhcpinfo_interface": "eth2"
    }]
}

It then builds the table element with javascript


function ubee_jscript_generate_table_data(lan_dhcpinfo_list) {
        var html_string =  '<table ><thead><th colspan="4">Client List</th></thead>' ;
        html_string += '<tr><td class="level-2-table-header">Host Name</td><td class="level-2-table-header">IP Address</td><td class="level-2-table-header">MAC Address</td><td class="level-2-table-header">Interface</td></tr>' ;
        for (index=0; index < lan_dhcpinfo_list.length ; index++ ) {
            if (index%2==0) {
                html_string += '<tr >';
            } else {
                html_string += '<tr class=\"alt\" >';
            }
            html_string +=  '<td>'+ lan_dhcpinfo_list[index].lan_dhcpinfo_hostname +'</td>';
            html_string +=  '<td>'+ lan_dhcpinfo_list[index].lan_dhcpinfo_ip_address +'</td>';
            html_string +=  '<td>'+ lan_dhcpinfo_list[index].lan_dhcpinfo_mac_address +'</td>';
            if( lan_dhcpinfo_list[index].lan_dhcpinfo_interface == 'eth0' ){
                html_string +=  '<td>'+ 'Eth-Switch LAN(1)' +'</td>';
            } else if( lan_dhcpinfo_list[index].lan_dhcpinfo_interface == 'eth1' ){
                html_string +=  '<td>'+ 'Eth-Switch LAN(2)' +'</td>';
            } else if( lan_dhcpinfo_list[index].lan_dhcpinfo_interface == 'eth2' ){
                html_string +=  '<td>'+ 'Eth-Switch LAN(3)' +'</td>';
            } else if( lan_dhcpinfo_list[index].lan_dhcpinfo_interface == 'eth3' ){
                html_string +=  '<td>'+ 'Eth-Switch LAN(4)' +'</td>';
            } else {
                html_string +=  '<td>'+ lan_dhcpinfo_list[index].lan_dhcpinfo_interface +'</td>';
            }
            html_string += '</tr>' ;
        }
        html_string += '</table>' ;
        return(html_string) ;
    }

See above (the device would be in different Eth-Switch LAN(X) depending on Wifi vs LAN