Stelios's Place

A place for thoughts and ideas

Lua Pagekite



   This is a software project I did a while back while I was looking for a way to remotely access a few embedded devices behind a firewall or a NAT modem. While searching with Google for a similar solution I stumbled upon PageKite project which was exactly what I was looking for. The only problem was that the original client/server was written in Python and the embedded device couldn't handle that. So, I ended up writing a simplified version of the client in Lua which I named it Lua-Pagekite. It uses the LuaSocket library and the SHAlib library from http://regex.info/blog/lua/sha1.

   I have been using it since and it works fine with PageKite version 0.4.6 running as a private Front-End server. Lua-Pagekite client has been tested with Lua 5.1.4 running on OpenWRT Backfire (10.03, r20728).

   At this point Lua-Pagekite can only handle GET and POST methods and the request serving capacity is limited. Never the less, if you need to remotely access a device behind a NAT/firewall you could give it a try.

   You can get the source code from GitHub: https://github.com/steliosm/lua-pagekite. The source code is released under the GPL license.

   For a quick start up, edit the config.cfg file with your own settings. In case you are running your own Front-End server, like I do in my case, you will need to edit the pk_site, pk_server, pk_port and pk_server_token fields. The proxy_web and proxy_web_port variables define the web server you would like to expose over the PageKite service. Usually this is the local web server running on port 80. Finally, you can leave the debug as a value 1 to get a debug output or set to to nil. The server_reconnect variable controls how the client will behave when the remote front-end closes the connection. The default is to try to reconnect again, so leave it is better to leave it to 1.


-- Pagekite Server
pk_site = 'your-site.pagekite.server'
pk_server = 'pagekite.server.ip.address'
pk_server_port = 80
pk_server_token = 'your-server-token'

-- Local Web Server configuration
proxy_web = "127.0.0.1"
proxy_web_port = 80

-- Various settings
debug = 1
server_reconnect = 1



Comments and suggestions are welcomed.


~steliosm

Search

Navigation

News


  • 5.07.2020
    Words & Letters: Connected smart wooden blocks toy. Have a look here.
  • 15.09.2017
    Cubee: An IOT desktop toy that displays the weather. More info here.
  • 04.10.2015
    A wooden treat dispenser your pet using a smart phone and blue-tooth. Have a look here.
  • 08.12.2013
    IKEA Strala Lamp modification! Use a PicAxe chip to add X-mas tunes and control the lamp from you PC through the USB. Have a look here.
  • 20.06.2013
    Little Bes: the lost rabbits - Mini old-school platform game! Have a look here.