Jump to content

Jack's IP Checker Script


Jack

Recommended Posts

This is a very simple script that checks your Ip address. Try it out biggrin.png

 

Edit: Updated Script! New Link! I also released the source below.

 

http://up.ht/1q2mtLB

 

 

0fb7e5d9ae85766081414ff63e0b897b.png

import java.awt.*;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

@ScriptManifest(author = "Jack", name = "Jack's IP Checker", version = 1.1, info = "Checks your IP", logo = "")
public class IPChecker extends Script {

	String ip = "";
	boolean error = false;
	boolean haveIp = false;

	private final Font myFont = new Font("Arial", 1, 16);

	public void onStart() {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(new URL("http://jackhallam.net/checkip.php").openStream()));
			ip = in.readLine().split("<")[0];
			in.close();
		} 
		catch (Exception e) {
			error = true;
		}
		if(ip.equals(""))
			error = true;
		haveIp = true;
	}

	public int onLoop() throws InterruptedException{
		return 1000;
	}

	public void onPaint(Graphics2D g){
		if(haveIp)
			if(error)
				drawStringWithStroke(g, "Error Finding IP Address", 10, 120, myFont);
			else
				drawStringWithStroke(g, "My IP Is: " + ip, 10, 120, myFont);
	}

	public void drawStringWithStroke(Graphics2D g, String s, int x, int y, Font f){
		if(f!=null)
			g.setFont(f);
		g.setColor(Color.BLACK);
		g.drawString(s, x+1, y);
		g.drawString(s, x-1, y);
		g.drawString(s, x, y+1);
		g.drawString(s, x, y-1);
		g.setColor(Color.WHITE);
		g.drawString(s, x, y);
	}
}
Edited by Jack
  • Like 4
Link to comment
Share on other sites

  On 6/22/2014 at 3:30 PM, ILikeTrains said:

Could you publish the source or do you want to keep it private? I have a version for OSB1, will be interesting to see the differences;

Decompile it..

It's not particularly hard anyway, all he is likely doing *dont quote me on this as he may be using a different method* is reading off a basic web page which just provides the ip, I've seen it before but can't remember the link..

Then he simply saves it in a variable and calls it in his paint to be displayed on the script

Link to comment
Share on other sites

  On 6/22/2014 at 10:10 PM, Bears said:

Decompile it..

It's not particularly hard anyway, all he is likely doing *dont quote me on this as he may be using a different method* is reading off a basic web page which just provides the ip, I've seen it before but can't remember the link..

Then he simply saves it in a variable and calls it in his paint to be displayed on the script

No but that would also work :P

Link to comment
Share on other sites

  On 6/23/2014 at 1:30 PM, Arctic said:

This doesn't show if a proxy is working.

Like someone said, it just shows your local IP.

Ok ill fix :) 

  On 6/22/2014 at 2:29 PM, Fantabulous said:

JUST WHAT I NEEDED wub.png

 

I believe it only shows your local IP, so not the IP your internet provider gives you

Ok im fixing now

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...