I rarely watched TV online when I was located in the UK, but now I've moved to Finland with appalling local TV choices it has become more common.
The biggest problem with trying to watch BBC's iPlayer, and similar services, is the location restrictions.
Not a huge problem though:
- Rent a virtual machine.
- Configure an OpenVPN server on it.
- Connect from $current-country to it.
The next part is the harder one - making your traffic pass over the VPN. If you were simple you'd just say "Send everything over the VPN". But that would slow down local traffic, so instead you have to use trickery.
My approach was just to run a series of routing additions, similar to this (except I did it in the openvpn configuration, via pushed-routes):
ip -4 route add .... dev tun0
This works, but it is a pain as you have to add more and more routes. The simpler solution which I switched to after a while was just configuring mitmproxy on the remote OpenVPN end-point, and then configuring that in the browser. With that in use all your traffic goes over the VPN link, if you enable the proxy in your browser, but nothing else will.
I've got a network device on-order, which will let me watch netflix, etc, from my TV, and I'm lead to believe this won't let you setup proxies, or similar, to avoid region-bypass.
It occurs to me that I can configure my router to give out bogus DNS responses - if the device asks for "iplayer.bbc.com" it can return 10.10.10.10 - which is the remote host running the proxy.
I imagine this will be nice and simple, and thought I was being clever:
- Remote OpenVPN server.
- MITM proxy on remote VPN-host
- Which is basically a transparent HTTP/HTTPS proxy.
- Route traffic to it via DNS.
- e.g. For any DNS request, if it ends in .co.uk return 10.10.10.10.
Because I can handle DNS-magic on the router I can essentially spoof my location for all the devices on the internal LAN, which is a good thing.
Anyway I was reasonably pleased with the idea of using DNS to route traffic over the VPN, in combination with a transparent proxy. I was even going to blog about it, and say "Hey! This is a cool idea I've never heard of before".
Instead I did a quick google(.fi) and discovered that there are companies offering this as a service. They don't mention the proxying bit, but it's clearly what they're doing - for example OverPlay's SmartDNS.
So in conclusion I can keep my current setup, or I can use the income I receive from DNS hosting to pay for SmartDNS, or other DNS-based location-fakers.
Regardless. DNS. VPN. Good combination. Try it if you get bored.
Tags: dns, location, mitmproxy
26 October 2015 21:50
Once upon a time I wrote a mail-client, which worked in the console directly via Maildir manipulation.
My mail client was written in C++, and used Lua for scripting unlike clients such as mutt, alpine, and similar alternatives which don't have complete scripting support.
I've pondered several times whether to restart this project, but I think it is the right thing to do.
The original lumail client has a rich API, but it is very ad-hoc and random. Functions were added where they seemed like a good idea, but with no real planning, and although there are grouped functions that operate similarly there isn't a lot of consistency. The implementation is clean in places, elegant in others, and horrid in yet more parts.
This time round everything is an object, accessible to Lua, with Lua, and for Lua. This time round all the drawing-magic
is will be written in Lua.
So to display a list of Maildirs I create a bunch of objects, one for each Maildir, and then the Lua function Maildir.to_string is called. That function looks like this:
-- This method returns the text which is displayed when a maildir is
-- to be show in maildir-mode.
local total = self:total_messages()
local unread = self:unread_messages()
local path = self:path()
local output = string.format( "[%05d / %05d] - %s", unread, total, path );
if ( unread > 0 ) then
output = "$[RED]" .. output
if ( string.find( output, "Automated." ) ) then
output = strip_colour( output )
output = "$[YELLOW]" .. output
The end result is something that looks like this:
[00001 / 00010 ] - Amazon.de
[00000 / 00023 ] - Automated.root
The formatting can thus be adjusted clearly, easily, and without hacking the core of the client. Providing I implement the apporpriate methods to the Maildir object.
It's still work in progress. You can view maildirs, view indexes, and view messages. You cannot reply, forward, or scroll properly. That said the hard part is done now, and I'm reasonably happy with it.
The sample configuration file is a bit verbose, but a good demonstration regardless.
See the code, if you wish, online here:
Tags: lua, lumail, lumail2