adulau / Forban

Forban is a p2p application for link-local and local area networks. Forban works independently from the Internet and uses only the local area capabilities to announce, discover, search or share files. Forban relies on HTTP and it is "opportunistic".
http://www.foo.be/forban/
134 stars 24 forks source link

Problems running forban on Piratebox-Openwrt #6

Closed MaStr closed 12 years ago

MaStr commented 12 years ago

Hi Alexandre, I'm currently packing the forban package for Pirateboxes on OpenWRT. On my prototype I'm running Forban located at the piratebox-folder /opt/piratebox/forban

Python is, piratebox typically, installed under /usr/local/

So the libs are located at /usr/local/lib

Fine. At first I had to slowdown your startUp because these multiple python threads pushes the MR3020 into a reboot :( That wasn't this big.

Now I'm encountering a problem, which I can't solve (I don't have python skills :( ). At first, I'running Forban in "shared" mode.

On startup I'm getting the following Messages:

forban_announce is starting with pid: (pid) Traceback (most recent call last): File "/opt/piratebox/forban/bin/forban_announce.py", line 66, in import announce File "/opt/piratebox/forban/lib/announce.py", line 29., in import hmac EOFError: EOF read where object expected ... forban_share has the same issues with hmac

I think, it can't load the libary hmac. hmac exists in /usr/local/lib/python2.6 Copieng it stupidly over (for testing purpose) doesn't fix it either.

Another python script is running fine without modifications (droopy and shoutbox-service).

Any ideas?

Thank you kind regards Matthias

MaStr commented 12 years ago

removing the bytecode-version of hmac removes this problem.

But after starting forban_share MR3020 starts to reboot again :(

MaStr commented 12 years ago

Disabled Watchdog.. seems to run.

adulau commented 12 years ago

Hi Matthias,

Thanks for the tests. When you said that you disabled the watchdog? which watchdog did you disable?

HMAC has been introduced in version 2.2 of Python that should work.

Let me know if I need to update the start-up scripts.

Thanks again.

MaStr commented 12 years ago

Hi, the problem is the openwrt internal watchdog, which I stopped with /etc/init.d/watchdog stop

I can't find any documentation about it, but I believe it is checking systemload and initiates a reboot if the system answers slowly. The initial start of forban causes python to create bytecode... and this create a lot of I/O on the USB device... yeah it was a way to heavy ;) - nevermind.

I'll add the stop and restart (after forban loaded correctly) to the openwrt-init.d file.

I just entered the next problem:

Traceback (most recent call last): File "/opt/piratebox/forban/bin/forban_share.py", line 73, in import cherrypy File "/opt/piratebox/forban/lib/ext/cherrypy/init.py", line 62, in <modul$ from cherrypy._cpcompat import urljoin as _urljoin, urlencode as _urlencode File "/opt/piratebox/forban/lib/ext/cherrypy/_cpcompat.py", line 208, in <mod$ from http.cookies import SimpleCookie, CookieError ImportError: No module named http.cookies

MaStr commented 12 years ago

HMAC has been introduced in version 2.2 of Python that should work.

yes, that is right. The problem was the rebooting MR3020 while creating the bytecode file

MaStr commented 12 years ago

Hi Alexandre, got it running on the MR3020! Had to install python-openssl , libopenssl and pyopenssl and fix LD_LIBARY_PATH . Ok, no big deal after I got this error.

Well, I need you help in the configuration of forban. There is no correct "forbanctl stop" command, because there is no regular shutdown on routers. I want to move in front of every start the forban/var folder to /var (which is in memory) and point the "share" option to /var/forban With this, the pid files are removed with power off.

Then I want to create a static link in /var/share/Piratebox to /mnt/usb/PirateBox/Shared (where uploaded files are stored) ... I doesn't follow symlinks :( Is it possible to implement this? (If not, there is another way to solve this)

Another question: I link the shoutbox relevant file to forban share and create a link (same name as in share) pointing from opportunistic-folder to the origin shoutbox file. What will happen if the file changes?

adulau commented 12 years ago

Hi Matthias,

Excellent news.

Regarding the specific structure of the OpenWRT, I could make the following in the startup script of Forban:

If I understand correctly, the /var/ is on RAM. You want to have the share directory in the RAM where there is a symbolic link pointing to the PirateBox shared directory (on Flash) where all the files are shared. It seems quite ok to do. Usually symbolic links are followed.

The index is built at a regular interval from the shared directory. If you change it, the index will change and then the other Forban will get the new index and then reconcile the files. Even if you just change a symbolic links. I need to reproduce it to see if there is a particular issue on that.

Another question regarding the interface binding, are you still interested in it? If yes, I'll commit also some code doing this (but it's less portable than before).

Thank you for your work

MaStr commented 12 years ago

Hi Alexandre, the interface-binding isn't very important. I thought it would be necessary, after I saw a view thing in the last day, It's no "need to have"-feature. I'll comment this on the issue, if I tested my assumption is right (Get the IPv6 Link to a remote forban client and access it directly).

Back to the directory structure: Its currently like this:

root@piratebox:/opt/piratebox/forban/var/share# ls -la drwxr-xr-x 4 root root 1024 Jan 1 00:59 . drwxr-xr-x 5 root root 1024 Jan 1 00:58 .. lrwxrwxrwx 1 root root 25 Jan 1 00:59 PirateBox_Share -> /mnt/usb/PirateBox/Shared drwxr-xr-x 2 root root 1024 Jan 1 01:02 Test drwxr-xr-x 4 root root 1024 Jan 1 01:39 forban

And PirateBox_Share don't show up :(

I won't write something depends on a "System detection", which wouldn't be a direct system-dependency. If possible, I would add a few more options to the config file, where I can define it the other way around if needed.

Thank you for your help Matthias

adulau commented 12 years ago

I just checked the code and the default behavior of the Python os.walk function (used to build the index) is to not follow symbolic links.

In lib/index.py, you could give a try by doing the following:

 def build (self):
        self.index = ""
        for root, dirs, files in os.walk(self.sharedir, topdown=True):

and replace it with

 def build (self):
        self.index = ""
        for root, dirs, files in os.walk(self.sharedir, topdown=True, followlinks=True):

Let me know if this works for you Following symbolic links is not always the best thing to do (especially for security reason). But if this works, I could create a specific directory filter for the PirateBox case.

Thank you.

MaStr commented 12 years ago

Great. With this option it works!

The forban_share thread is taken around 10% cpu time. Is this normal? Is that a result of building the index of the shared folder? Can this intervall be modified (to save cpu)?

adulau commented 12 years ago

Super. I'll commit an option to add the followlinks similar based on your tests on the current HEAD for the PirateBox.

Yes the index rebuild depends of the announce interval (announceinterval = 15 is the default config). Now, thinking of it, it might make sense to separate the announce interval from the index building (especially for low-end hardware). So I could check for a multiplicative factor between the announce and the index rebuild. It will be another commit.

Anyway, thank you very much for your effort.

MaStr commented 12 years ago

Thank you. Announce interval of 60 seconds with rebuild factor 5 ( every 5 Minutes) is quite well for the tiny boxes.