External IP in Title

randac56

Member
May 25, 2018
915
0
16
Hello Fellow ruTorrent Users.

I am using a RaspberryPi with rTorrent, ruTorrent and a VPN Connection. I was always wondering whether the VPN was working correctly. Of course there are Solutions like http://torguard.net/checkmytorrentipaddress.php but all i wanted is to have the external IP of the RaspberryPi visible.

Since i am no super programmer i came to this solution (maybe someone can implement a better idea)

I uploaded a simple php script called ip.php with the following content to a webserver where i can access it. The File only contains the following lines:
Code:
$client_ip = $_SERVER['REMOTE_ADDR'];
echo $client_ip;This php script just displays the IP-Number of the computer accessing the file.

Now i modified two files of the ruTorrent Source:
index.html was renamed index.php
the line <title></title> was changed to
Code:
<title>External IP: <?php echo file_get_contents('http://YOUR_SERVER_WITH_THE_FILE/ip.php'); ?></title>
The last change is a bit of a hack since i have no clue how to get PHP into JavaScript Files...
I changed the webui.js in the js Folder so that the title won't be changed by the JavaScript:
Code:
/*newTitle+="ruTorrent v"+self.version;
if(document.title!=newTitle)
document.title = newTitle;*/(just add /* and */)

Now whenever i access my RaspberryPI ruTorrent Interface i can see the External IP in the Title.

It actually works quite nice.
What do you think?
 

shwetha17

Member
May 24, 2018
785
0
16
Hi,

to be honest, I didn't test it, but sounds nice. Although I wonder if the title is *the* proper place. Alternatives would be the bar at the bottom.

As a technical question: wouldn't it be sufficient to replace YOUR_SERVER.... with localhost? Plus the question remains, where do you place the ip.php file? Obviously not in the ruTorrent-folder, right?

Anyway it sounds like a nice starting point. I personally would like to see it more bundled up with ruTorrent cause than an upgrade might not remove these changes. Any chances to transfer it as a plugin?

smiley.gif
 

Attachments

saroos1

Member
May 25, 2018
718
0
16
I also took an interest in this but definitely wanted to leave the titlebar as-is(I prefer to see the speed there). Rather I made a plugin to show in the log window upon connection. Bottom bar does also sound like a good option though. Another idea I have would be to keep a running log of connection history in a new tab. What do you guys think? I have attached the simple version for now.
 

shwetha17

Member
May 24, 2018
785
0
16
@AceP1983: Just to be sure: That's a plugin which could be placed in a plugin-folder and that's it?

Plus (just for understanding): shouldn't you try to get your ip-address from external? I mean, internal IP-address is 192.168.... but this doesn't mean I'm connected to the Internet. I wold be more interested in my external IP-address (see as well).

My ideas: running log non-stop and fill it? Not really what I'm interesting in, cause either running or not. The place with the log sounds nice. I personally would like to have some kind of update functionallity --- if the user request it. How this could be managed - no idea rolleyes.gif
 

Attachments

saroos1

Member
May 25, 2018
718
0
16
Yes this is a standalone plugin just like all others. Download it, unpack in the plugins folder and you're good to go.

This does retrieve the external/isp ip address not your lan address.

By running log I mean each time you log in or refresh it will add an entry to a new tab with, for example, external ip address, date and time, and maybe even browser info. You could select how many entries to keep in the log through settings very much like history plugin. And to update you would simply refresh.
 

shwetha17

Member
May 24, 2018
785
0
16
I've tried it and looks nice - but its not what I would would have expected from the title of this thread. It gives me the IP-address from where I'm connected - that is what you have described in your plugin description.

But I was looking more or less about the external IP address from the seedbox where ruTorrent is installed. Since icanhazip.com delivers that information on the fly, I'm curious how to add the response from this address to the log. Would you mind to give a helping hand, cause I'm not really familar with php.

P.S.: I've reread the beginning of the thread and I see now, that you nicely wrapped the first approach in a plugin. Perhaps its my expectation...
 

shwetha17

Member
May 24, 2018
785
0
16
Just a minor remark: Checking the error.log from my web-server I see that I have install a lang-dir cause it wants to access de.js. Which I don't see a big problem to provide, although the translated text is not THAT important. PLUS a iplog.css file is missing as well.

Doesn't sound big issues, but since the log-file of the web-server is filled I thought I note it.
 

randac56

Member
May 25, 2018
915
0
16
Well done saroos1!

You just need to change the line
Code:
$ip = $_SERVER['REMOTE_ADDR'];with this
Code:
$ip = file_get_contents('http://YOUR_SERVER_WITH_THE_FILE/ip.php');
For clarification:
if you put $_SERVER['REMOTE_ADDR'] in a PHP File it will return the IP Adress from the Remote Client that opens the file which contains this line. This is why you must place a simple PHP File onto ANOTHER Server - so the PHP Script can tell you how it sees you. (Hope this makes any sense...)

I can't provide public hosting for this file - but maybe someone here is willing to do so. Keep in mind: If this is public Plugin there is no way to estimate the page impressions generated by this script.

Another Solution would be if someone would program some funky CURL/GREP Script to get this Information from public websites like whatismyip.com or something like that.
 

saroos1

Member
May 25, 2018
718
0
16
Glad you like randa cool.gif

Regarding the web server errors mentioned by maria_BBB. This was a minor oversight on my part. You should remove the lines below from the file init.js as there is no need right now for lang or .css files.

Code:
plugin.loadLang();
plugin.loadMainCSS();
 

Attachments

shwetha17

Member
May 24, 2018
785
0
16
I have two comments:

1) The ip-address from sebman produced simply an error. Since I couldn't figure out how this should work, I simply applied the solution from Stackoverflow. And thx to sebman sample this worked. So, this is somehow resolved

2) I tried to be clever and want to display the internal and external IP-address. But somehow I cannot figure out how this should be done properly cause I get always an undefined. I'm not really an expert on PHP and therefore the question if somebody could correct my error. Would be great rolleyes.gif
 

Attachments

saroos1

Member
May 25, 2018
718
0
16
I see that I misunderstood what you were trying to achieve here. I have redesigned this to now show the external ip of the server in the bottom status bar instead of the log. Also when you mouse hover over the ip area it will show internal and external ip. Try it out and let me know what you guys think.

Code:
svn checkout https://github.com/AceP1983/ruTorrent-plugins/trunk/showip
 

shwetha17

Member
May 24, 2018
785
0
16
Hi,

unfortunately my time is/was limited. I now tested it and think its really fine. Looks really great. Thx

grin.gif
 

Attachments

lisas4567

Member
May 25, 2018
773
0
16
Hi. I really like this idea, but it doesnt achieve the required result. This pulls the external ip of the server, but if the torrent client is tunnelled through vpn service then it doesnt pull the vpn service ip. Is this something that can be done?

Actually, I quickly googled and solved this. I changed the first 2 x lines of your init.php file to;
$command="/sbin/ifconfig tun0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'";
$ip = exec ($command);

and now it pulls the tun0 interface ip in.