Source code for GLI web UI?

Just got my MT300N today, I really like the web UI from GLI and wonder where I can find the source? I would like to add some changes of my own because it is much nicer than LuCI.

Thanks

EDIT: I did some editing directly on the device: screenshot attached

 

 

Nice work.

You can get the source of HTML, css and pictures directly from your router.

For the CGI part, we discussed and discussed and still cannot make it opensource. Is just opening the api OK?

Well,

More than modifying the UI, what I would really like is to build my own openwrt but still have the GLI UI that it ships with.

Since it’s not a kernel module, could I simply install the binary package?

An API to extend it would be useful.

Am I right in assuming that if I build OpenWRT from your patched github it won’t have the GLI UI only the standard Openwrt one?

Good job with the router by the way, the MT300N is a fantastic little device!

Yes. It is possible to install as binary package via opkg. The github doesn’t have your GUI.

The only problem, our package requires a lot of dependencies and install some default settings. We hardcore these settings in our firmware. So it is easy. But if use as a general package, a lot of test needs to be done.

I will publish the api on the docs.

Where can I find this? I’m really interested, because I want to be able to turn on and off the openvpn client by using a custom javascript.

You can find it in here.

2 Likes

Thank you! Where do I get the Authorisation Token?

But I was actually thinking about the cgi-bin api like
/cgi-bin/openvpn_cgi?action=get_client_ovpn
Most of it I can actually get from the source html files, but I don’t know how to log in there.

/router/login returns the token :slight_smile:

Yes, thank you. I got the token, but I can only login using the cookie:

curl “http://192.168.8.1/cgi-bin/login_cgi?action=checklogin” -H “Cookie: CGISID=PIXPetfRuQ1RpqFFWSqzWin8bADzR3vxCicRLrw78wPzW”

How do I log in with the token?

Once you have the cookie and the token you put those in the other REST API commands to get info.

For example:

curl -H "Authorization: oHfwGccgiJlHR5wGrchGw1M83ROmFvBP" \
       --cookie "QSESSIONID=9177564b1203c30000" 192.168.8.1/api/client/list

{
    "clients": [
        {
            "name": "yao-PC",
            "ip": "192.168.8.202",
            "mac": "00:E0:4C:16:0C:33",
            "remote": false,
            "blocked": false,
            "type": "2G"
        },
        {
            "name": "DESKTOP-IJLUEM3",
            "ip": "192.168.8.201",
            "mac": "1C:1B:0D:CD:5B:6F",
            "remote": true,
            "blocked": false,
            "type": "LAN"
        },
        {
            "name": "*",
            "ip": "192.168.17.85",
            "mac": "00:0E:C6:D0:7C:6D",
            "remote": false,
            "blocked": false,
            "type": "2G"
        }
    ],
    "code": 0
}


Sorry, this is not working for me. This is what I do:

curl -d "action=login&password=password&code=" "http://192.168.8.1/cgi-bin/login_cgi" -c D:\cookie.txt
{
        "success":      true,
        "token":        "uOlugdLdJyHdSfHS7WFavgOQ2A5WqI6U"
}

Then I get a CGI Session ID in my cookie and with this I can check my login status (no token needed):

curl "http://192.168.8.1/cgi-bin/login_cgi?action=checklogin" -H "Cookie: CGISID=8Bgei9PMtcldnZHSFAGOjDqjd18J7bFeEOlPZ1AqcMvwI"
{
        "logged":       true,
        "code_entered": true,
        "new_password": false,
        "language_set": false,
        "flash_ready":  true,
        "via_wifi":     true
}

But when I try to get the list of ovpn configs for example I get an empty result:

curl -H "Cookie: CGISID=8Bgei9PMtcldnZHSFAGOjDqjd18J7bFeEOlPZ1AqcMvwI" 192.168.8.1/cgi-bin/openvpn_cgi?action=get_client_ovpn

Also the /api/client/list is not working, but probably because I only have the CGISID?

What model are you using? Can you use v3.x which has very different api but well structured.

MT300A

It is working now. I had to add the token as

-H "X-CSRF-TOKEN: LYh7vfP4aXygh1WaU3AOOSd8HLj28DBT"

Now it is working fine.

So I will probably start from the beginning with V3, but for now I stay with this.

Thank you all very much!

So I updated to V3 firmware recently and now I’m wondering, how can I enable an ovpn connection through the api? I can get all the information but I feel there is missing a /api/ovpn/client/connect

API path: /api/ovpn/client/set

There are three parameters.

  • enableovpn: Enable or Disable vpn
  • force_client: Deprecated
  • ovpnclientid: Which server

Thank you!
Any reason why “/api/ovpn/client/set” is not in the API docs?

And another question. If I understand it correctly, I choose a Ovpn Configuration with ovpnclientid, which can have more than one server from which the default one will be chosen.
Can I choose a ovpn file directly?

Not update yet.

You can call api/ovpn/client/list to list all available clientid.

Thank you for your quick reply!

I know, but a clientid can have multiple servers. How can I connect to a specific server whick is not the default one?

If I use /api/ovpn/client/set I can only set the ovpnclientid which connects to the default server of that clientid, but I want to choose the server first.

can you point where is the exact path of this files? thanks

I am a user interface designer, so I am always thinking about how to make things more intuitive for the novice — so I wanted to submit a pull request for some minor english language improvements to the GUI, but could not find the repository:

  1. For the sake of clarity, I recommend that the phrase “Last Update” should be changed to “Installed Version” because “Last Update” could be misunderstood, especially if the user’s native language is not english. (Although it would be obvious to the technician, we want to avoid any potential for confusing the user.)

  2. Installed version number does not appear when using Safari 15.6.1

  3. The upgrade panel now shows a snapshot version, but there is no way to install it via the GUI. Therefore, I might also suggest that “Current Version” should be changed to “Current stable version” and beta or snapshot builds should be displayed on a separate line.

Upgrade

For example, the ‘Microsoft AutoUpdate’ tool (for “Edge” & “Office” software) provides a selection of 3 update channels, with beta or snapshot builds as an option, and the possibility of reverting to stable builds:
Update Channel