Posts

Showing posts from February, 2017

Proxy ASP.NET HTTP Handler

From time to time you may need to have a simple proxy to overcome limitations introduced by your intranet security settings. As a solution, you can create a simple HTTP handler that will route all requests through the server, like: http://server/proxy.ashx?get=http://target.com/feed.xml To have this running, just create a file called get.ashx in your www root, make sure you assign an AppPool running .NET 4.0+, and you are good to go: <%@ WebHandler Language="C#" Class="ProxyHandler" %> using System; using System.IO; using System.Net; using System.Web; public class ProxyHandler : IHttpHandler {     public void ProcessRequest(HttpContext context)     {         string urlString = context.Server.UrlDecode(context.Request["url"]);         Uri url;         if (!Uri.TryCreate(urlString, UriKind.Absolute, out url))         {             context.Response.Write("URL query parameter can not be parsed");             return;         }         We

FancyBox onCleanup not working

Today faced a bug on my pet project where part of the form was not sent to server, thus breaking save record functionality. After an hour of investigation traced issue back to FancyBox not firing onCleanup where I bring inputs back from FancyBox to the form they belong: $.fancybox({     content: $("#RecordAttributes"),     onCleanup: function () {         $("#RecordAttributes").appendTo(SvgEditor.Form);         $("#RecordAttributes").hide();     } }); Tried to yield plugin some time before sending form, just in case it intends to call onCleanup asynchronously - nothing helped. Last resort was to jump to FancyBox sources to immediately realize that API canged and now the callback is called beforeClose. Adopting the change sorted an issue: $.fancybox({     content: $("#RecordAttributes"),     beforeClose: function () {         ...     } }); So now my users are happy and me earned some sleep. Cheers

Blocking access to IP using iptables on Android

Long time since I last posted anything here. The shift of topic would is another kind of surprise 😎 So moving to subject of this post. Today I got an application on my Android phone which was using IP geolocation to determine where I am and block some features based on the IP address. Lets refer it as NastyApp going forward. The most obvious solution would be to use proxy/VPN to mask my location, but that would require me to remember run VPN each time I need an application. So going the hard way from here... Step 1. Determine which IP needs to be blocked There is a couple of application in the market to track where application is going. After playing with those I found NoRoot Firewall to be a perfect fit: you just enable it and all the traffic becomes routed through virtual VPN and intercepted by application. At this point I allowed all the destination IPs for NastyApp and started disabling those 1 by one and checking application until it finally failed to track a IP locatio