Something I'd like to write...

Posted by: theory

Something I'd like to write... - 02/03/2002 17:41

Here's something I'd like to write, but I don't have the h4x0ring skillz:

A program that reads /proc/net/tcp, pulls out the remote ip addresses, converts them from hex to dec, and displays them.

It'd be nice to have something like this built into hijack, and I was thinking about downloading Marks path file and doing it myself but a) I ran into troubles reading from /proc/net/tcp b) I don't know how to format using C. And finally c) I don't know how to write a HEX->DEC converter.

Can anyone offer any assistance?

Thanks
theory
Posted by: kimbotha

Re: Something I'd like to write... - 02/03/2002 18:56

Is this something you want to write just to have written it...? or do you have some use for it...? Currently you can see the IP address of the empeg in the about screen under the player menus... scroll down and it will give you the serial number of the player and its current IP address...

Cheers

Kim
(can't remember the exact menu items as my empeg is not in front of me...)
Posted by: theory

Re: Something I'd like to write... - 03/03/2002 00:30

I already knew that you could find out what the ip address of the empeg is. I'd like to find out what the ip addresses are of the machines that are connected to it. i.e. people streaming, browsing and ftping into it.
Posted by: TheAmigo

Re: Something I'd like to write... - 03/03/2002 02:47

Give this a try.

It reads from /proc/net/tcp and reformats to decimal numbers.

If you run it without any args, it prints the current status and exits.

The way it's intended to be run is by specifying the name of a fifo as its only arg. Before you run it, do this:

mkfifo /tmp/netstat
(or wherever you want)
then run: hex2dec /tmp/netstat
it will sit waiting for someone to read from /tmp/netstat. When you do, it will convert the current contents of /proc/net/tcp and display them, then it goes back to waiting for another read request. This way, you just background the prog and then you can browse to your empeg at: http://empeg/tmp/netstat and hit refresh in your browser to get an update.

Everytime I click refresh, I see another connection get used... seems a bit odd, I'm not sure what's wrong. So if I click refresh 30 times, the empeg has 30 network connections in use.

When I finish a bit of cleanup, I'll release the source... nothing fancy, just a quick hack without any comments.
Posted by: mlord

Re: Something I'd like to write... - 04/03/2002 20:20

Mmm.. I wonder if somebody could go and hack that into the XML homepage package from Charcoal-whatssissname?

-ml
Posted by: charcoalgray99

Re: Something I'd like to write... - 04/03/2002 20:39

I'd rather have a separate XML for system information. I think that would be a much cleaner solution. Displayserver had a sysinfo page which showed things like temp, serial number, ac/dc power, process table, netstat. I'd like to be able to have all of that info, and format it with my stylesheet.

Tom
Posted by: mlord

Re: Something I'd like to write... - 04/03/2002 20:40

Well, it's all under /proc ... somewhere.
Posted by: charcoalgray99

Re: Something I'd like to write... - 04/03/2002 20:44

I didn't think it was possible to grab the /proc info from javascript, or is it?

Tom
Posted by: mlord

Re: Something I'd like to write... - 04/03/2002 20:50

I dunno. It just looks like a bunch of files to any web browser.
Posted by: charcoalgray99

Re: Something I'd like to write... - 04/03/2002 20:57

Well, I'd like to include system info in my XML package. I'm sure other people would find the feature useful also. But without an XML/XSLT output, I don't have a way to format it to look pretty.

Tom
Posted by: theory

Re: Something I'd like to write... - 04/03/2002 20:59

That's a great idea. pull it using javascript. you'd probably have to load it into a separate frame or something, but that's easily doable.
Posted by: charcoalgray99

Re: Something I'd like to write... - 04/03/2002 21:49

Hmm, I spent some time on google and couldn't find an example that did anything like this. Can anyone help here?

Tom
Posted by: TheAmigo

Re: Something I'd like to write... - 04/03/2002 22:00

I don't know javascript. Is it complete enough of a language to do the hex to decimal conversion and text formatting? If so, then it sounds like a good plan. It'd be much more user friendly if you could just have a local .js file do the conversion and display rather than needed another prog running on the empeg.

If anyone wants to do it in JS (or anything else), here's my C source for the above prog. Feel free to copy any code that would be useful.
Posted by: theory

Re: Something I'd like to write... - 04/03/2002 22:16

I'm pretty sure it's doable. I know javascript can convert hex to decimal. and I remember doing x-frame scripting, but it was so long ago I forgot how to do it.