Possibility of adding perl to dd-wrt

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2, 3  Next
Author Message
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2026
Location: Sol System > Earth > USA > Arkansas

PostPosted: Sun May 17, 2009 23:30    Post subject: Possibility of adding perl to dd-wrt Reply with quote
I was looking at the thread relating to blocking ads coming through on a local network (Thread here.) It discusses the possibility of rerouting add sites to another computer running pixelserv. Looking through the pixelserv website, it seems to require perl. It also had links elsewhere to which I ran upon something labeled "microperl". It has a site here.

Anyone think they could use the microperl page to add perl scripting to dd-wrt?

_________________
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.
Sponsor
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Mon May 18, 2009 0:45    Post subject: Reply with quote
There's optware packages for it and I've heard of people running it but they had trouble with missing perl modules.
_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2026
Location: Sol System > Earth > USA > Arkansas

PostPosted: Mon May 18, 2009 1:16    Post subject: Reply with quote
What kind of modules are missing?

Essentially the reason I am asking this, I want to know how hard it would be to get pixelserv running on DDWRT. I know it requires changing default admin page to something other than port 80. Once that is done, starting up pixelserv should be relatively simple, as long as some basic perl is in place to run it properly.

I guess I am trying to determine if it would run as a basic experiment.

_________________
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.
blueman2
DD-WRT User


Joined: 24 Nov 2008
Posts: 62

PostPosted: Mon May 18, 2009 1:30    Post subject: Reply with quote
I installed PERL on my ASUS WL-520GU. The reason was that I wanted to run HottProxy on my router. Never got it to run however. Could never resolve all of the needed components.
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 151

PostPosted: Thu Sep 10, 2009 23:29    Post subject: Reply with quote
Apologies for digging up old thread, but the broken images in Internet Explorer when adblocking have irked me for years (Firefox with adblock much better!).

So I have patched together a simple c program based on the public domain server.c in

http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#simpleserver

which sends the pixelserver string in response to any request

It compiles fine with dd-wrt toolchain to a 10k binary

Code:
export PATH=/opt/4.1.0-uclibc-0.9.28/bin/:$PATH
mipsel-linux-uclibc-gcc -Os -Wall -D_GNU_SOURCE pixelserv.c -o pixelserv
mipsel-linux-uclibc-strip -s pixelserv


Copied to dd-wrt (latest BS Mega on wrt54g-tm, web admin on http port 80 disabled) it runs fine, daemonizes and only outputs to syslog (by design)

Code:
Sep 11 01:03:33 DD-WRT daemon.warn pixerlserv[6691]: socket: Address family not supported by protocol
Sep 11 01:03:33 DD-WRT daemon.notice pixerlserv[6691]: waiting for connections on port 80


Then any attempt to connect to the router IP i.e.

http:/192.168.1.1/anything

gets a blank page with a 1*1 Gif

Re the warning - presumably the second socket in the linked list it tries worked? I'm sure that could be fixed - there's also a half second sleep before closing the connection that I don't think should be necessary.

Source and dd-wrt binary attached any use?

[Note also compiles and runs on Ubuntu X64 and Windows XP Cygwin-1.7]


Last edited by mstombs on Mon Sep 14, 2009 21:29; edited 1 time in total
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Fri Sep 11, 2009 0:18    Post subject: Reply with quote
Good show!

With this script you can start it and it will move the normal webserver away from 80 which is mandatory.

Code:
#!/bin/sh
if [ `nvram get http_lanport` -eq 80 ] ; then
  nvram set http_lanport=88
  commit
  stopservice httpd
  startservice httpd
fi
pixelserv

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2026
Location: Sol System > Earth > USA > Arkansas

PostPosted: Fri Sep 11, 2009 4:00    Post subject: Reply with quote
Interesting show. I may try to implement this in the near future.
_________________
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.
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 151

PostPosted: Fri Sep 11, 2009 7:09    Post subject: Reply with quote
frater wrote:
With this script you can start it and it will move the normal webserver away from 80 which is mandatory.


Easiest is just to disable web administration via http, https uses port 443.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Fri Sep 11, 2009 12:07    Post subject: Reply with quote
mstombs wrote:
Easiest is just to disable web administration via http, https uses port 443.

Whatever suits your needs. There's no place in the webgui to do this and one may prefer to use http. I'm using remote http through my reverse-proxy.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 151

PostPosted: Fri Sep 11, 2009 20:43    Post subject: Reply with quote
I've fixed the warning message by restricting the program to try only IPV4 connections, and made a couple of other changes to try to avoid the need for a usleep - found a way to close the connection without sending a RST.

Also put a copy of the binary temporarily on my ISP website so interested users can:-

Code:
root@DD-WRT:/tmp/var# wget -P /var http://www.mstombs.talktalk.net/dd-wrt/pixelserv


revised source and binary attached



pixelserv7d.zip
 Description:
revised

Download
 Filename:  pixelserv7d.zip
 Filesize:  5.26 KB
 Downloaded:  1892 Time(s)

mstombs
DD-WRT User


Joined: 31 Oct 2007
Posts: 151

PostPosted: Wed Nov 04, 2009 22:37    Post subject: Reply with quote
OK this is open message to frater - I know this is too late, and I see you have the other version now working fine via xinetd, but here is an attempt to satisfy your original requirements:-

Quote:
I prefer it to be implemented in C which will give a compact fast binary. A version which does both (socket & stdin/stdout) would be even better...

* pixelserv
* -- run pixelserv on port 80 of all interfaces
* pixelserv 192.168.1.1
* -- run on port 80 of 192.168.1.1
* pixelserv -i
* -- run pixelserv in stdin/stdout


Despite adding this I've also taken out what I now consider to be unnecessary code and using Tornado's latest toolchain (only for Linux 2.6?, but works for me in 2.4) I find can use the common compile/link options to produce a 6kB binaries - build script enclosed

[edit] don't use this version, it is single threaded and can hang waiting for a browser to acknowledge receipt of a blank gif and stop working until restarted.

Also a 'feature' of the toolchain used is that "printf"s are stripped from code, so no identifying version no or messages!



pixelserv9.zip
 Description:
Sourcecode and binary

Download
 Filename:  pixelserv9.zip
 Filesize:  4.84 KB
 Downloaded:  1741 Time(s)



Last edited by mstombs on Fri Nov 19, 2010 0:12; edited 2 times in total
redhawk0
DD-WRT Guru


Joined: 04 Jan 2007
Posts: 11563
Location: Wherever the wind blows- North America

PostPosted: Thu Nov 05, 2009 0:24    Post subject: Reply with quote
This was added to the TRAC the other day

http://svn.dd-wrt.com:8000/dd-wrt/changeset/13160

redhawk

_________________
The only stupid question....is the unasked one.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Thu Nov 05, 2009 4:29    Post subject: Reply with quote
mstombs wrote:
OK this is open message to frater - I know this is too late, and I see you have the other version now working fine via xinetd, but here is an attempt to satisfy your original requirements:-

Quote:
I prefer it to be implemented in C which will give a compact fast binary. A version which does both (socket & stdin/stdout) would be even better...

* pixelserv
* -- run pixelserv on port 80 of all interfaces
* pixelserv 192.168.1.1
* -- run on port 80 of 192.168.1.1
* pixelserv -i
* -- run pixelserv in stdin/stdout


Despite adding this I've also taken out what I now consider to be unnecessary code and using Tornado's latest toolchain (only for Linux 2.6?, but works for me in 2.4) I find can use the common compile/link options to produce a 6kB binaries - build script enclosed

Hi...
Yes I did a request on linuxquestions.org. I haven't been programming in C for 20 years. I wasn't even using any library functions back then (not even printf). I'm now using a stdin/stdout only version.
You totally satisfied my requirements (besides speed Wink ).
I will propose your package to be included into optware.

I'm starting to like xinetd. My WD Worldbook is using it too for sshd and there it introduces an annoying wait, but I'm not noticing any downsides here....

Code:
# service pixelserv
xinetd manages port 80 on these IP's
 192.168.10.1:   /opt/bin/nc  -w 1 192.168.10.1 88
 169.254.255.1:  /opt/bin/nc  -w 1 192.168.10.1 88
 127.0.0.1:      /opt/bin/nc  -w 1 192.168.10.1 88
 10.63.63.1:     /opt/usr/sbin/pixelserv


So you are crosscompiling? You do know you can compile on the router itself?

redhwak0 wrote:
This was added to the TRAC the other day
http://svn.dd-wrt.com:8000/dd-wrt/changeset/13160

Yes, that was an old request of mine. We are not using perl for this one anymore....

http://svn.dd-wrt.com:8000/dd-wrt/ticket/1122

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
crashfly
DD-WRT Guru


Joined: 24 Feb 2009
Posts: 2026
Location: Sol System > Earth > USA > Arkansas

PostPosted: Thu Nov 05, 2009 6:36    Post subject: Reply with quote
Damn, I cannot believe someone actually dragged this old post up. Hah hah ... at least some people know how to ask the right questions.

@frater - I saw your 'optware' script frater. Since I now know it installs perl and pixelserv, I am going to consider using it on my router in the near future. I sort of have an attached usb hdd to my router, and honestly I am not really using it that much. At least your optware script will give it some "new" life. Laughing

_________________
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.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Thu Nov 05, 2009 7:29    Post subject: Reply with quote
crashfly wrote:
@frater - I saw your 'optware' script frater. Since I now know it installs perl and pixelserv, I am going to consider using it on my router in the near future.

You'll be surprised!

BTW. pixelserv is not dependent of perl anymore. I replaced it with a C-version. mstombs thought of that one. I had a problem with his version because it used all interfaces (just like DD-WRT's httpd Evil or Very Mad ) so I'm now using a pixelserv which uses stdin/stdout.

In the mean time mstombs updated his... so it could be used instead... I can't really decide what to do with it now...

@mstombs can't you think of something to make yours do something special? Wink

I will post mine... maybe you can see something which is not right....
http://pastebin.com/f2bad6d7e
BTW. It doesn't do anything with its stdin... Can this be a problem?


I've changed S45pixelserv so xinetd will use the -i parameter. This way it will work with both versions.... (binary has same name)

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
Goto page 1, 2, 3  Next Display posts from previous:    Page 1 of 3
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum