Posted: Sat Apr 24, 2010 2:08 Post subject: pixelserv without perl, without any jffs/cifs/usb free
Hi everyone...
Just wanted to share this info: If you are in my condition and use a dd-wrt mega build on a 8MB flash router without mmc mods or usb attached, you realized after enabling jffs, you have no space free to store stuff. Thats bad news if you want to run pixelserv on your router for adblocking, as that needs perl (optware install which you do not have the luxury of). Well don't fret: you can still create pixelserv binary on the fly and run it from a start script.
I did not create the ELF binary: I got this from the linksysinfo forum the source provided by mstombs
Okay, so here goes:
First, you need atleast 4k of nvram free (normally the router has 32k nvram to store variables)
Check with:
Code:
nvram show | grep ^size:
If you can spare 4k (keep atleast 1k cushion for other router functions like dhcp leases, etc)
Paste the lines from the atached custom.txt file your Administration->Commands->Save Custom area
If you already have a custom script, append the contents at the end: just make sure to take out any exit commands if there were any existing, and also the first line in the attached custom.txt file (#!/bin/sh)
Then in your startup, invoke the custom.sh:
Code:
while [ ! -e "/tmp/custom.sh" ]; do
sleep 1 # wait till /tmp/custom.sh gets generated
done
/tmp/custom.sh
logger "Redirecting httpd to port 81"
killall httpd
httpd -p 81 -h /www
logger "Starting pixelserv on port 80"
/tmp/pixelserv `nvram get lan_ipaddr` -p 80
If that was not obvious, it moves the httpd on your router to listen on port 81, so you'd still able to get to it with http://<router_ip>:81
Now you can run ad-blocking on your router (blocks ads from all computers in you lan, no need for Firefox/IE/Chrome plugins on each PC)
You can find several forum threads on how to do hosts based adblocking by downloading (wget) the hosts.txt from mvps.org and instructing dnsmasq to use the downloaded hosts in addition to your own hosts file. pixelserv will serve a 1x1 pixel transparent gif picture for your blocked ads.
Enjoy!
custom.txt
Description:
Open with any text editor and copy/paste the contents to the commands box, then [Save custom script]
Joined: 24 Feb 2009 Posts: 2026 Location: Sol System > Earth > USA > Arkansas
Posted: Sat Apr 24, 2010 6:25 Post subject:
Still a good post though autobot. It is nice to see some people thinking outside of the box even though it has been accomplished before. _________________ E3000 22200M KongVPN K26
WRT600n v1.1 refirb mega 18767 BS K24 NEWD2 [not used]
WRT54G v2 16214 BS K24 [access point]
Try Dropbox for syncing files - get 2.5gb online for free by signing up.
Read! Peacock thread
*PLEASE* upgrade PAST v24SP1 or no support.
Fantastic use of nvram and uucode gz! I must try on flash challenged wrt54gs5. I wonder why the ELF binary compresses so much, maybe there's more that can be stripped?
There's a dd-wrt thread with a version compiled using the dd-wrt toolchain here:-
There's been a patch to tomato httpd code to stop it binding to all IP addresses on port 80, which allows pixelserv to be be bound to a secondary IP address without moving the router GUI port, not sure if this can be incorporated in dd-wrt.
The pixelserv.c c-code is intended to be portable, I also test on latest Ubuntu 32 and 64bit, and XP with cygwin.
It appears that the router pixelserv binary is fairly router OS independent and the same binary works in both K24 and K26 builds - the library calls and links must be the same. But different toolchains do not produce binary identical images, and you are recommended to use the correct one for your firmware. The latest Tomato version uses a K26 tomato gcc 4.x toolchain published in git by user teddy_bear, it is based on OpenWRT build tools, and probably closer to Tornado's K26 dd-wrt toolchain than older Linksys/Tomato gcc 3.x version.
Thanks everyone for the kind words. And wow: My post evoked a response from mstombs himself... I am humbled :)
I had to put it in nvram as I had no other storage options available, and also I did not find a place from where I can wget it every time at router boot.
Do you mean nvram, optware or the c pixelserv binary? The latter likely to need to be recompiled with correct toolchain as was done for Atheros routers. There is some possibility of binaries from one router working on another - I have seen some mipsel binaries that work on both Ti AR7 ADSL routers and Broadcom Ethernet routers - things are clearly similar at the mips Linux uclibc level. But some Tomato binaries don't work from one version to another!
There are binaries for Tomato mips on github, and arm in the linksysinfo thread. Not tested recently on dd-wrt, would be best to use the correct firmware toolchain.
There are binaries for Tomato mips on github, and arm in the linksysinfo thread. Not tested recently on dd-wrt, would be best to use the correct firmware toolchain.
i was just interested to the "extract binary from nvram function" ... seems i cannot use jffs2 on my router (wdr3600 is also an atheros..) and i don't want to attach an usb drive