This is a migrated thread and some comments may be shown as answers.

Set clientIP for geolocation testing (GeoIP)

2 Answers 721 Views
Extensions and Customization
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 24 Sep 2015, 05:33 PM

I needed an easy way to change the clientIP of a request without having to set a custom break-point and add a header every time or use a proxy service - so I extended Fiddler with a custom rule and I thought I'd share that here for anyone else looking for something similar. I had a few locations that I specifically needed, so I created those as menu items in addition to adding a custom field.

Open your CustomRules.js for modification - 

Under class Handlers add:

// Set clientIP
// Modify the country names and IP address as appropriate, or simply use Custom and set the array value to 0

RulesString("&Set clientIP", true)
RulesStringValue(0,"Country Name 1", "0.0.0.0")
RulesStringValue(1,"Country Name 2", "127.0.0.1")
RulesStringValue(2,"Country Name 3", "​192.168.1.1")
RulesStringValue(3,"&Custom...", "%CUSTOM%")
public static var sClientIP: String = null;

 /* -- end class handlers --*/

 

Under  OnBeforeRequest(oSession: Session) add:

// Set clientIP
if (null != sClientIP) {

    oSession.oRequest["clientIP"] = sClientIP; 
}​

Save the file and the new option will be added to your Rules menu - you can switch IP addresses with a click, and simply refresh the browser to effectively request the page with the assigned IP address.

2 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 24 Sep 2015, 06:29 PM
Thanks, Pete!

To be clear, what this rule does is send a custom header named ClientIP with the specified value; your server might use this instead of the client's actual IP address. Some servers instead respect an X-Forwarded-For header instead.

If the web page uses the HTML5 GeoLocation API, you should have a look at the AnyWhere ​extension for Fiddler. If you need true geolocation, you can use the GeoEdge menu in Fiddler.

Regards,
Eric Lawrence
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Pete
Top achievements
Rank 1
answered on 24 Sep 2015, 06:51 PM

Thanks Eric! It's probably worth mentioning the tests were conducted on an internal (staging) web server, so you're right - millage may vary. :-)

Aside - I found the documentation on custom rules to be very clear and helpful. I was pleasantly surprised how easy it was to extend the functionality and add a sub menu! It's been my experience that most dev documentation either makes a lot of assumptions or is completely inaccurate, so kudos for that! :)

Tags
Extensions and Customization
Asked by
Pete
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
Pete
Top achievements
Rank 1
Share this question
or