Sign up here and you can log into the forum!

Webend remote view

Feature requests / enhancements discussion regarding the web interface

Re: Webend remote view   

Postby recliq » Wed Jan 16, 2013 8:00 am

Can't find any free-time lately, if you manage to find a version that compiles and runs on current lifes please let me know. :mrgreen:
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: Webend remote view   

Postby PaulF » Wed Jan 16, 2013 11:39 am

Maybe directvnc would work to show the screen. You would have to install VNC on the the PC, though.

http://packages.debian.org/squeeze/directvnc

Edit: OOPs further reading and this is client not the server
User avatar
PaulF
Developer
 
Posts: 427
Joined: Sat May 08, 2010 8:34 pm
Location: Oregon

Re: Webend remote view   

Postby Darren » Thu Jan 17, 2013 2:53 am

mad_ady wrote:By the way - what was your project about? Anything interesting for the community?

I'm working on an alternate gui, you might say. Based largely on javascript, it currently runs only on 1.02, but if 1.05 is capable then that would be ideal. At over 5,000 lines of code (!) its finally getting to a point where the features are coming together in the way I imagined, but there are still some large changes and additions to make before its ready for release. Beta testers, anyone? :-)
Darren
DLX'er
 
Posts: 69
Joined: Sat Jun 19, 2010 3:35 pm

Re: Webend remote view   

Postby mad_ady » Thu Jan 17, 2013 4:04 am

And is this GUI intended to run on a PC/tablet/phone? Or are you coding a replacement for DMAOSD (but if you were, you wouldn't need screenshot ability)? :P
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Webend remote view   

Postby recliq » Thu Jan 17, 2013 4:12 am

Darren wrote:Beta testers, anyone? :-)

sure! PM me.
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: Webend remote view   

Postby Darren » Thu Jan 17, 2013 4:58 am

This gui runs directly on the wdtv, and it depends on the wdtvext for its js engine. It leaves the original gui basically untouched, and it acts as an alternate one, and is accessed as an item on the home menu. And... I just wanted a native screenshot ability :-)

@recliq
Thanks! I'll PM you...
Darren
DLX'er
 
Posts: 69
Joined: Sat Jun 19, 2010 3:35 pm

Re: Webend remote view   

Postby mad_ady » Fri Dec 26, 2014 8:35 am

I'm not sorry to revive this ~2 year old thread because I've been recently working on this left-over problem and built the webend app.bin that would show these screenshots (currently only for 1.02, based on Darren's code). It works reasonably well, except that after a number of queries it stops getting new images and most likely you need a reboot to continue. I decided to have a look at what's going on behind the scenes, and this is what happens (I made very small changes to darren's script):

Code: Select all
root@Deneb:/root# /apps/webscreenshot/bin/screenshot.nanox.sh L /tmp/www-tmp
Screen update: Timeout
root@Deneb:/root# netstat -tpan | grep 3490 | grep CLOSE_WAIT | wc -l
332
root@Deneb:/root# netstat -tpan | grep 3490 | grep CLOSE_WAIT | head
tcp        2      0 127.0.0.1:3490          127.0.0.1:38705         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:54475         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:55989         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:38674         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:35851         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:38626         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:38615         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:39878         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:35822         CLOSE_WAIT  3212/dmaosd     
tcp        2      0 127.0.0.1:3490          127.0.0.1:55943         CLOSE_WAIT  3212/dmaosd


As you can see, when nc is closed or after generating the image, the actual socket to wdtvext/dmaosd is not closed and resources are not released. This builds up in time and cause a denial of service - you can't get any more connections on port 3490. The problem is, the CLOSE_WAIT state doesn't have a timeout timer and such connections should be terminated by the remote end (dmaosd in our case).

http://stackoverflow.com/questions/15912370/how-do-i-remove-a-close-wait-socket-connection

Now, we can't easily change wdtvext nor dmaosd, but, maybe we can hack around it... :D
According to the TCP state diagram: http://en.wikipedia.org/wiki/File:Tcp_state_diagram.png once a socket is in CLOSE_WAIT state it needs to send a FIN packet back to the source to signal that it has released its end. I'm thinking of spoofing a FIN packet from (with the first line in the output as example) 127.0.0.1:3490 to 127.0.0.1:38705 so that the kernel "thinks" the connection has closed and has reason to migrate from CLOSE_WAIT to LAST_ACK. Then the source process (netcat) should send back the last ack, but even if it doesn't do this, quoting from the great book RFC793:

Case 2: TCP receives a FIN from the network

If an unsolicited FIN arrives from the network, the receiving TCP
can ACK it and tell the user that the connection is closing. The
user will respond with a CLOSE, upon which the TCP can send a FIN to
the other TCP after sending any remaining data. The TCP then waits
until its own FIN is acknowledged whereupon it deletes the
connection. If an ACK is not forthcoming, after the user timeout
the connection is aborted and the user is told.


so, it should free the socket after a timeout.

Now, the challenge remains to spoof such a packet (should be possible with tools such as hping3), but, spoof it in such a way that it is considered a valid packet by the TCP stack. This means that we need to get correct sequence/ack numbers in that packet. And I have no idea how to find out which are the last seen syn/ack numbers for that connection (these are tcp stack internals that are probably not exposed in /proc by default).

So, I'm here listening for ideas - no matter how crazy... How do we clear those sockets without restarting dmaosd?

By the way, here's how the app.bin will look like (I'll release it once support for 1.05 is done - hopefuly next week):

Image
Image

Edit: cutter sounds like a tool for the job... Will see if it works when I compile it: http://www.digitage.co.uk/digitage/software/linux-security/cutter
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Webend remote view   

Postby kroetkroet » Fri Dec 26, 2014 11:33 am

W.A.U.W.! Well done Mad_ady!
WDLXTV-fan! - In case you need further assistance: read our WIKI, search our Forum and most of all: donate 'something' to b-rad for his great efforts!!!
User avatar
kroetkroet
Beta Tester
 
Posts: 1004
Joined: Mon Apr 05, 2010 11:53 pm

Re: Webend remote view   

Postby mad_ady » Sat Dec 27, 2014 12:17 am

If cutter doesn't 'cut' it, I have another wild idea - rebuild the screenshot script like a server which opens only one connection to dmaosd and keeps reusing it. It should solve the CLOSE_WAIT problem, but complicates the script (especially on concurrent access). We'll see...
The good news is that preliminary tests for the screenshot method (the printscreen you were testing kroetkroet) show that it is quite fast. The screendump is done in ~0.5s and conversion to jpg takes ~1s. So, 1.05, 1.06 and SMP users should benefit from it in the future.
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Previous

Return to Webend Web Interface

Who is online

Users browsing this forum: No registered users and 1 guest