OpenWrt Forum Archive

Topic: Android Client for retrieving client information off router

The content of this topic has been archived on 10 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have created a small android program that can query an openwrt router, retrieve a list of connected clients, and present the data in a somewhat useful way.  This is really my first android project, and, even worse still, my first Java program.

The android package can be downloaded from here

Instructions:
- Install the apk on your phone. (easy)
- Make sure your router has ncat installed (version for the nmap folks).
- Login to your router and run:

#Get scripts off the internet
wget https://github.com/flyer-explorer/OpenWRT-Client-List/blob/master/Openwrt-Scripts/serve-leases -O /etc/init.d/serve-leases
wget https://github.com/flyer-explorer/OpenWRT-Client-List/blob/master/Openwrt-Scripts/serve-leases.sh -O /usr/bin/serve-leases.sh

#get server-leases into sys-init for next boots
cd /etc/rd.d/
ln -sf ../init.d/server-leases S99server-leases

#create config file
echo "PORT=2000" > /etc/dhcp-clients.conf
echo "TRANSPORT=tcp >> /etc/dhcp-clients.conf"
echo "UDP_RATE=1 >> /etc/dhcp-clients.conf"
echo "LEASE_FILE=/tmp/dhcp.leases >> /etc/dhcp-clients.conf"

# Start server
/etc/init.d/serve-leases start

Screenshots

Main window
https://github.com/flyer-explorer/OpenWRT-Client-List/raw/6f717f907245aae9bb86dbd9355c0d2064848502/Screenshots/config.png

Selecting a host will show more detailed information
https://github.com/flyer-explorer/OpenWRT-Client-List/raw/6f717f907245aae9bb86dbd9355c0d2064848502/Screenshots/individual-host.png

Configuration window
https://github.com/flyer-explorer/OpenWRT-Client-List/raw/6f717f907245aae9bb86dbd9355c0d2064848502/Screenshots/config.png


Let me know if something is amiss.  The sources for everything is on my git hub https://github.com/flyer-explorer/OpenWRT-Client-List.

(Last edited by rumbit on 18 Mar 2012, 15:01)

Looks cool. Any screenshots of the app itself?

Nice work with this, thanks for sharing it! I'm in the process of testing it out and have the following notes in order to get it working:

1. The files downloaded are named "serve-lease" but command for creating the init script sym link says "server-lease." To fix this either update the "ln" command from:
ln -sf ../init.d/server-leases S99server-leases to:
ln -sf ../init.d/serve-leases S99serve-leases
or you can rename the files and code to all use the work "server" if you prefer.

2. The quotations are messed up on code for creating the config file. The last three lines have it at the end when it goes after the txt to echo as in line one.

3. The init script and /usr/bin script need to be allowed to be executed by running chmod as follows: (I know you know this but it wasn't included in the list.)  :-)

chmod u+x /etc/init.d/serve-leases
chmod u+x /usr/bin/serve-leases.sh

4. Lastly the stop script kills netcat which could be an issue if it's also running for other reasons. Maybe best to create and check for a pid file?

All in all nice work and thanks again. I like the simplicity and I'm sure this could easily be extended to show other info such as current bandwidth usage, the number of total tcp connections, etc..

The discussion might have continued from here.