Setting up Mac OS X 10.7 Lion to transparent proxy

This is an amazingly difficult thing to find instructions on the internet for. I hope this helps someone, apologies if the “code” tags aren’t too clear. I think that’s the style.

You will need:
To be able to configure the gateway router on either the target box or on your DHCP server.
To be comfortable with the command line (no, seriously)
SquidMan 3.1

Method:
Initially you might think that OSX Server will be necessary but probably isn’t. Apache doesn’t seem suited to transparent proxying and it seems to make doing your own configuration harder too with Lion.

Install SquidMan, then go into the template tab and look for
http_port %PORT%. Underneath that line, add
http_port 3129 transparent

I run the main port as 3128. I think that’s about all I tweaked.

You’ll want to test this works (at least for proxying) set your web proxy to localhost:3128 in internet settings/advanced/proxies and apply the changes. If you can still browse the web, great. If not, check your logs (Squidman offers a window to browse them, or you can tail them in ~/Library/Logs/squid/…)
OK, so now we need to be able to forward traffic that’s not meant for us, you might already do this if you use your Mac as your firewall/router, but I only have one interface on my Mini so I had to configure this:
sysctl -w net.inet.ip.forwarding=1
Now that you can route packets, set a machine to use this one as your gateway.
Check that machine can still access the internet, if not, tcpdump on the box you are configuring for proxy and see if you see the packets arriving and leaving. If it is all working, you can move onto forcing the proxy.
Here’s the big difference for Lion. Lion uses pf rather than ipfw. Yay for upgraded BSD.
Edit /etc/pf.anchors/com.apple and add to the end:

anchor "910.Custom/*"
load anchor "910.Custom" from "/etc/pf.anchors/910.custom"

Create /etc/pf.anchors/910.custom:
rdr pass on en0 inet proto tcp from 192.168.1.0/24 to any port www -> 127.0.0.1 port 3129
replace en0 with your internet ethernet interface (the one packets from your LAN come in on and 192.168.1.0/24 with your home network.
OK. Now all you need to do is start it:
sudo pfctl -vvv -f /etc/pf.conf -E
the -E tells it to enable pf.
Now you should see squid log entries when you view pages on the machine you set the gateway for.
Now to make it permanent. Before this point, we could reboot and it would all go away :)
edit /etc/sysctl.conf and add
net.inet.ip.forwarding=1
The last thing to do is to set squid and pfctl to run on startup:
Edit /Library/LaunchDaemons/com.mac.adg.SquidMan.plist and ensure the following two keys and values are set:
<key>Disabled</key>
<false/>
<key>RunAtLoad</key>
<true/>

Edit /System/Library/LaunchDaemons/com.apple.pfctl.plist and ensure the above two keys and values are also set (don’t duplicate keys).. then you’ll need to find this bit:
<key>ProgramArguments</key>
<array>
<string>pfctl</string>
<string>-f</string>
<string>/etc/pf.conf</string>
</array>

And make it like this:
<key>ProgramArguments</key>
<array>
<string>pfctl</string>
<string>-f</string>
<string>/etc/pf.conf</string>
<string>-E</string>
</array>

The -E means enable.

A lament for the lost art of error messages

Once upon a time, programmers cared about the people who ran their programs. They would try to help users when things went wrong by giving some context and explanation to why something went wrong.

I’ve just tried to install func from source on debian squeeze and it reeks of “Today’s Programmer” whose agile methodology means nothing helpful is offered, you should read the source to understand it.

1) The wiki install instructions say, “The root level makefile” – what the one in the docs folder? Fortunately if you’ve used python setup.py before, or can intuit –help then you’re not too stalled.

2) The bdist_dumb produces /usr/local/ prefixed paths (but puts things in dist-packages)
3) The install –prefix=/usr puts things in site-packages.
4) The init script is hard coded for /usr/bin (sorry, bdist_dumb, this will need editing)
5) If you persevered with /usr/local installed, you’ll have no modules. Func won’t find them.
6) IT WON’T TELL YOU WHY (possibly because it hasn’t discovered the logger.py)
7) IT WON’T EVEN TELL YOU IF YOU RUN IT IN FOREGROUND
8) Wiki does get quite specific about modules being under a specific tree though, soo…
9) site-packages isn’t in the sys.path on debian.
9.1) IT WON’T TELL YOU THIS IS THE PROBLEM
10) adding site-packages to PYTHONPATH before starting makes it load, but the same no-modules and no func.log
Finally, moving the files to dist-packages fixes it all up and everything works.
No wonder no-one seems to persevere long enough to package it.
I’m not going to package it out of sheer frustration.

Func isn’t alone, but it’s really great at the art of I’ll throw you a stack trace, then you can read the code and determine why it failed. Chef is similar.

What happened to I tried to object.method with arguments foo, bar and I got the error BLEH.
Maybe include a stack trace after that, but jeez, your users shouldn’t have to be programmers intimately familiar with coding for your chosen language and the vagaries therein.

I remember the last time I tried to debug a failing recipe in chef, this is a subclass of this, which is a subclass of that, which inherits from somewhere else completely, just to find the line of code that was being executed.

New Macs

I want to want a new Mac. They’re shiny, they’re faster, they’re more capable…I just can’t quite bring myself to do it:

I have a fat mac mini server. About twice the height of the current one. I thought about replacing it with the new Mini Server, but that hasn’t got the graphics punch – it has onboard Intel graphics. The one that has better graphics can’t fit two 750Gb drives into it…An upgrade would force me to compromise, and you don’t spend a couple of thousand dollars compromising.

I also have a previous gen Macbook Air. Faster processor, yes, but still unable to run it without sending the fans into craziness…Although the reviews have been on the model without the Radeon graphics, I’m not sure how that changes things. I think I’d rather have a dual core i7 instead of quad core and have a Radeon in there.

It doesn’t sound as though it would suddenly play portal at good speeds without going crazy nuts on the fans.

I dream of a macbook air form factor capable of playing games like portal without breaking a sweat.

AV for me

It seems straight forward to me. If you are a Conservative in a Labour area or a Liberal in most parts of the country, or a Labour voter in a Conservative or liberal stronghold, you’re picking the ‘least worst’ option in a first past the post in order to try to maximise your chances of not putting the incumbent back. You probably dont pick who you’d actually like to govern you.

Personally I’d appreciate the chance to show my first choice, even if it then ends up commuting to my least worst option after elimination.

Imagine the freedom when people in Labour strongholds are able to vote Conservative if they really want that, or Liberal if they really want that, with their second choice as the other, knowing that if their choice places third, it isn’t completely discounted and will support the stronger of the two.

Say for example you have a 41% Labour vote, a 39% Conservative and 18% Liberal with 2% other. Those two might boost the Labour and Liberal vote. 42% Labour and 19% Liberal… But then the Liberals would be split between Labour and Conservative. I don’t think we know how that would work, but the result would be one the majority of constituents would be happy with.

You don’t have to vote for every candidate and for me the end to ‘tactical’ voting and the freedom to openly express your political opinion without ‘letting the enemy in’ makes complete sense to me. The only reason you’d vote No to AV is if you believe your only mandate comes from tactical voting and I think it is telling that this scares the Tories most.

iOS + OSX = iX?

iTunes preview of some iOS apps today identifies “ix.Mac.MarketingName” as a compatible device with some software designed for iOS.
I wonder if this means that Lion will feature a Rosetta for ARM capable of running iOS .ipa apps on its launchpad view. Mac is reserved for Apple’s line of desktop and laptop computers and they’re currently Intel based. Apple have already made much of it being able to work with full screen apps and doing away with scroll bars, all these would be necessary to allow seamless integration of iOS apps. They’ll also have to support multitouch and be able to execute ARM targetted code. Look out for new iMacs with capacitive screens!

This will be very funky if it happens, particularly if it also brings data syncing. I’ve wanted that full screen iOS calendar on the Mac for ages!

I reckon the reason only certain apps work is that the app has to be built with a specific version of the toolchain to be compliant.

Load Rage

The single most irritating thing about subscribing to magazines and newspapers via an electronic device is the enforced wait at a loading screen. I can stand this for about ten seconds tops.

The best experience I’ve had for rich content news is the Sky news app. Granted it’s not really a newspaper, but it does provide the latest news on demand. The next best is probably The Daily and then The Times.

The worst is magazines like Wired and iGizmo where you are sat at a loading screen waiting for content and what does it do if you switch away to do something else while you wait? It pauses the download! How useless is that? Hey developers, this is what the background loading api was for! I think the developers expect you to start the download and then leave it running while you go make a cup of coffee or something.

The very best thing would be for my iPad to receive a notification (silently) at whatever time the content was published (assuming I subscribe) and for it to begin to download automatically while I sleep.

Another annoyance is when you are offline (wifi and 3G unavailable) it shouldn’t show ‘loading’ for the online content like videos. ‘unavailable offline’ would be much more useful.

I would subscribe to a paid news app in a flash if at 6 each morning it would download the top stories for offline viewing ready for my train commute. Someone petition Apple to add that capability!

News delivery is getting better, but it still has too many shortcomings. Once my free ride from The Times is up, I won’t be renewing.

iPad the second

It’s smaller.
It’s lighter.
It feels better in your hand.
It lasts as long.
It’s faster.
The graphics capabilities are better.
It has a gyroscope for more accurate orientation detection and tighter movement in games.
It has magnets built in to hold a cover in place.
It has cameras.
You can load all your iPhone apps and iPad apps on, and some may well ‘just work better’ (though that isn’t a guarantee).

I love that I was able to restore my new iPad from the backup of my old one and there were my apps as if I’d never used anything else.

I recommend it if you don’t have an iPad at the moment. If you already have an iPad, you might consider selling the old one and getting a subsidised iPad 2 on a data contract – 3 seem to have some good deals. It’s perfectly likely you could get 250 for the old one, pay 250 for a new one and only pay £240 more for the length of the contract than just getting the Data sim alone.

Faye

The Lion’s first roar

If you see me day to day the chances are you asked me what I thought the Apple ‘Back to the Mac’ announcement was. I wish I’d posted my answer here but I’ve been frantically busy lately. I told people who asked that I believed this next release, Lion, as revealed in the teaser image would be the last in the current 10.x releases of Mac OS X and because of that will likely begin the evolution toward a unification of OS X and iOS capabilities. I hoped that we’d see more multitouch, an app store, a dashboard home screen (mission control goes beyond what I imagined) and the ability to have universal apps for Mac and iOS – perhaps that bit will come later. Unified applications would allow developers to easily charge once for an application which is then portable to your mobile device when you leave your mac. Cloud storage APIs would then allow you to take your apps and data with you when you go, cacheing locally for when you’re not on the Internet and syncing back when you are in range once more.

I think the new MacBook Air is a great evolution of the product, now able to approach MacBook speeds in the 13″ version and with the same pixel count as the current MacBook Pro 15″. I’m now looking forward to the MacBook pro refresh which must surely include the option for a full 1080p screen. I would love to see some hybridisation so that the OS is on flash along with a block cache and there’s still room in the Pro for a proper hard drive. With it’s all SSD operation though, the Air will likely outperform most MacBooks – provided Apple have addressed the flash erase cycle speed issue. I expect that’s the purpose of the VLSI on the card with the memory chips.

I didn’t expect FaceTime on the Mac with this announcement but it is welcome and hopefully persuades more companies to con side the cost savings of a Mac vs all the additional conferencing hardware and software

The premium for this miniaturisation is much smaller than when the original air came out. Apple are showing how to cross pollinate from their mass market products and benefit from the cost savings.

eBooks – All this and less.

eBooks are “the next big thing” apparently, along with other ePublished items. I’ll believe it when I see it.

There are a couple of advantages of eBooks: You can get them anywhere you have internet access and they take no additional physical space once you have them. So that’s two advantages for you, and one for the publisher.

There are many disadvantages: You can’t share a purchased eBook (well, you can with Nook, for 14 days). You can’t pick them up at the library. You don’t have the physical connection to the book – the smell, the feel of the paper.

The publisher sees most of those disadvantages as advantages.

I started off feeling that eBooks were great. I bought @JocelynnDrake ‘s Dark Days books on iBooks and motored through them. I can’t seem to get enough of Mira and Daneus’ adventures. I ran out of novels (get a move on, Jocelynn! LOL) and decided to obtain the complete Sookie Stackhouse from Charlaine Harris. This time, however, because of the sheer number of books I bought a box-set from Amazon.

So, now I have two different supernatural series of books and one I can loan out the books for to friends and get them interested, the other sits on my iPad unused after I finished reading them. I paid less for the Amazon books, but they are giving me more pleasure because I can share my enjoyment with my friends. Social is not just about “friending” or “liking”.

I won’t be buying any more eBooks until they are at least as functional as real paper books, or priced for their limitations.

Oh, and how did I come to know I’d like Sookie’s adventures enough to buy a whole box set at once? A friend loaned me the first three books. What does that tell you, publishers?

Apple TV – one more thing?

I think Apple are keeping a trick up their sleeves with the Apple TV. In case you didn’t know, the new Apple TV is an 8GB iOS device with 720p TV output on HDMI. It has no touch interface however, and so there’s no access to the existing iTunes App store content – You can’t control an iPhone with an Apple Remote… But what’s to stop you controlling your AppleTV with an iPhone connected via Bluetooth or WiFi using the peer networking in iOS? More importantly, what’s to stop you using two or more?

Nintendo made a killing by making their game consoles with 4 ports to connect 4 controllers at a time, thus allowing the “party” genre to take off. The annoying thing with consoles has always been buying those extra controllers you require. What if your friends already own the controllers, and they already take them whereever they go? I’m talking about iPhones and iPod Touches.

Apple has a ready-made market out there for their stealth games console, they just need a classy “controller” universal iOS app for free and then start an AppleTV App market.

Games like Chopper 2 on iPad & iPhone, and Scrabble on iPad with Tile Rack on iPhone show how this idea can really work.

I think Monopoly is something which could also work well in this way. A controller in a person’s hand which can take care of the personal needs of the player (property management, buying/selling, chance/community chest display) as well as shaking the dice, while the main board is displayed on the large screen TV.

Card games, with the green baize on the TV and your hand on your iPhone/iPod Touch, a flick discarding the card onto the TV and a hit-me gesture pulling a card from the pack.

In the past, this would have required such expensive controllers, that noone’s done it. Now we carry them whereever we go.