Friday, May 9, 2014

PirateBox Reloaded - Episode II

First of all thanks to all of you who gave feedback regarding the PirateBox for Android. The feedback was very useful and showed that there are problems when running the app on Android 4.x.
Meanwhile I've rooted my Galaxy Nexus (still on stock ROM) running 4.3, so I had the change for in depth testing. The result is version 0.4.0 of the app which includes a different handling of the dnsmasq process. I'll go a little into detail to describe the changes that have been made.

Those of  you not interested can jump directly to the end of this post where the download link is located. I've also added the questionnaire again. It would be really nice if you could provide feedback, it's  really useful.

Wrapping Dnsmasq

In previous version of the app the dnsmasq process was killed and restarted with the --address=/#/. This worked fine on Android 2.x devices but lead to a continuous restart of the AP (Access Point) on Android 4.x devices.
The new approach is different in the way that it does not kill the dnsmasq process but installs a wrapper script that is created before the AP stars and removed afterwards.
For this to work the app saves a copy of the file /system/bin/dnsmasq to /system/bin/dansmasq.pb.real. On start of the PirateBox service the wrapper script is created which overwrites the /system/bin/dnsmasq command. After the AP is started the original dnsmasq binary is restored.
The wrapper script looks like this:

#!/system/bin/sh
exec /system/bin/dnsmasq.pb.real --address=/#/192.168.43.1 $*

The wrapper calls the original dnsmasq binary which is now located at /system/bin/dnsmasq.pb.real with the --address and all other other parameters ($*) the system used to start dnsmasq.

If you look at the process list after starting the AP you should see that the backed up dnsmasq.pb.real is running instead of the real one (dnsmasq).
Here is the result of the ps | grep dnsmasq command:

shell@maguro:/ $ ps | grep dnsmasq
nobody    5088  121   928    496   ffffffff 00000000 S /system/bin/dnsmasq.pb.backup

New Preferences

The preference screen has two new additions. One is the IP address of the AP and the other is the option to restore the original dnsmasq binary.

New Preference Options
In previous versions the IP of the AP could determined after the AP was started and used to restart dnsmasq. This is no longer possible, because the wrapper script has to be created before the AP starts.

On Android most of the devices have the IP address 192.168.43.1 hard coded and I don't believe that there are a lot ROMs with different addresses. Should your AP start with a different IP address, you can still change this by using the new preference setting AP IP Number.

The second new preferences option is called Restore "dnsmasq" Binary. This will, as the name implies, try to restore the original dnsmasq binary. This should not be necessary to used, because the wrapper is removed and replaced by the original binary after the AP has been started. But in case thing do not work as desired when the device is used for standard tethering, this is the option to restore the binary.

Simple Widget

The new version also comes with a simple widget. It is not pretty ... but hey, I'm a developer not an artist ;)
Meanwhile I've updated the widget images in version 0.4.1, hope the widget is looking a bit better.

Below are the links to the app, the questionnaire and to the source code located at GitHub.
So I hope the new version is working better as the previous version and I'm looking forward for your feedback.



Source Code

The source code is now available on GitHub.

Download Links

Google Drive: PirateBox APKs

Questionnaire

The results can be viewed here, so you know on which configurations PirateBox is running.

2 comments:

  1. Any chance you could add the option to set what the upload limit is? also is it possible to have a little customization with the html pages such as banners/color scheme?

    ReplyDelete
    Replies
    1. All the files used by PirateBox are available inside the /data/data/de.fun2code.android.piratebox/files/piratebox directory.
      The maximum upload size can be configured inside the conf/server.xml file.

      It is also possible to tell PirateBox to use the SD card by ticking the "Content to SD" option inside the preferences. If you select that option the app will create a "piratebox" folder on the SD card and will use that instead of the files inside the /data/data/... directory.

      All the HTML/CSS files are located inside the "html" folder.

      Delete

Note: Only a member of this blog may post a comment.