Its Finally Here! XMPP for Facebook
Posted by Eion in Uncategorized on February 11th, 2010
There’s just been a blog post by the Facebook developers to say that they’re finally allowing XMPP on Facebook. Here’s the details:
- Create a new XMPP account in your favourite XMPP client, eg Adium or Pidgin
- Use your Facebook username in the ‘username’ field. If you don’t have a username get one at http://facebook.com/username
- Use ‘chat.facebook.com’ (without the quotes) in the ‘domain’ field
- Enter in your password
- Uncheck the Require SSL/TLS settings
- Check the ‘Allow plaintext auth over unencrypted streams’
You should be good to go
XMPP Facebook Chat
I get a lot of complaints from people who say that the Facebook Chat plugin for Pidgin is “flakey” and disconnects a lot. I’d just like to say, “Its not my fault!” ![]()
I was talking on the phone to someone at Facebook and asked them if they used my plugin. They said “no, I don’t use the public one its really buggy but I am beta testing our new interface internally which is a lot better.” Once he found out that I actually wrote the plugin, he did a bit of a turnaround and went on to explain that the server software isn’t really the greatest, that it puts a heavy load on their servers and that it was actually all their fault that my plugin was so bad
So, after a bit of snooping around, I discovered the details of the XMPP servers. You can even (almost) connect to them. For now, it looks like you have to be authorized in their beta programme (or probably just be working at Facebook) to be able to use it.
The XMPP server is running at chat.facebook.com:5222 and it uses DIGEST-MD5 for authentication as well as something called “X-FACEBOOK-PLATFORM” for SASL. In Pidgin you can set up the account by using your username, with the domain chat.facebook.com, disabling the “Require SSL/TLS” option in the advanced tab. Doesn’t look like its working with s2s yet, but hard to tell without being able to log in.
So give it a go, maybe your account slips through the cracks and you can log in. Will been keen to hear from anyone about their successes/failures with this.
Taming the GAM beast
One of the things I have to do in my day-job is manage our Google Ad Manager system, which we call GAM. One of the downsides of using GAM (actually a lot of different ad management systems) is their use of the javascript function document.write(), as well as their requirement to load in a big whomping load of javascript in the <head> of the page. One of the keys of website optimisation is to load all javascript at the end of your HTML page, so that the webpage renders as quickly as possible.
The way we can deal with this is overload the document.write() function to bend to our own wicked ways. Normally, you load the GAM code at the top of the page, but we’ll put it at the bottom and use a neat little function I wrote.
function insertAds(AdSlotName, width, height)
{
var slot = document.getElementById('my_ads_'+AdSlotName);
if (!slot)
return;
var oldwrite = document.write;
document.write = function(text){slot.innerHTML+=text};
GA_googleFillSlotWithSize("ca-pub-yournumhere", AdSlotName, width, height);
document.write = oldwrite;
}
Now we just slap in a <div> with our ad slots name, so we’ll replace
<script type="text/javascript">GA_googleFillSlotWithSize("ca-pub-yournumhere", "AdSlotName-760x120", 760, 120);</script>
with
<div id="my_ads_AdSlotName-760x120"> </div>
(which will render faster)
Then load in the ad at the bottom of the page:
<script type='text/javascript'><!--
insertAds("AdSlotName-760x120", 760, 120);
// --></script>
And there you have it. You can take out some more javascript from your <head> and speed things up a bit. My own speed tests showed between one-and-a-half to two seconds decrease in start-rendering time. Would be interested to hear your own findings.
Cross-Browser Gradient Backgrounds
Posted by Eion in Uncategorized, Web on September 20th, 2009
Recently, one of the websites I work on was given a makeover and I was asked to implement the design. One of the features it called for was rounded-cornered gradient backgrounds. Rather than turning the design down, I took up the challenge to try to implement it.
Looking around on the internet, there’s a little bit about how to go about that in a cross-browser way, but I thought I’d document it here.
The basic idea I took is to use an SVG as the background. Unfortunately, IE doesn’t support SVG’s and most of the browsers that do support them didn’t support them as backgrounds at time of writing. Fortunately, we can mess with CSS and HTML to display the SVG as an image behind the content, while at the same time providing a fallback for IE.
The basic idea, is to show the SVG after the content, then push it up behind the content with some absolute/relative positioning, so we write code similar to:
<div id="svg_outside">
<div id="svg_content"></div>
<div id="svg_background"></div>
</div>
Give the outside div a “position:relative” and the background div “position:absolute” and you’re all set. Put whatever you want for a background in the background div and your content in the content div (funnily enough).
While this doesn’t look nearly as clean as having just a single div with the background set to the svg, it does allow us a lot of flexibility to deal with IE. Since IE can’t natively handle SVG’s (yet), we can use a gradient filter on the background div. Alternatively, we could use some VML. You could even use a video as a background if you so felt like it
Check out http://eion.robbmob.com/svgdemo/ for an example.
There can be issues with the Adobe SVG plugin taking over sometimes.
Can’t be bothered writing about this any more, so I’m just gonna post it. Its been sitting in my drafts folder for long enough
Facebook Usernames
Facebook have recently posted on their blog that it is now possible to log into Facebook using your Facebook username.
I’ve just had a check and it’s possible to do the same with the Pidgin/Adium Facebook plugin. Not much of an issue if you’ve already got your account set up in Pidgin/Adium already, but hey, might save you a few keypresses next time you do set up an account
Pidgin with Video on Windows
Posted by Eion in Uncategorized on August 14th, 2009
I’ve been helping out Maiku (who’s the Google summer of code student who was tasked with getting voice/video working in Pidgin) to get pidgin-vv working on Windows. We’ve done lots of playing around for the last wee while, but we’ve finally managed to get it working on Windows. Just so you all believe me, here’s a teaser screencast video of me giving Maiku a call.
Cool huh! So far only XMPP (and Skype, kinda) are working but Maiku is hard at work to get all the other protocols working too. Yay!
Multiple logins with Skype 4.0
Over the last few hours, I’ve had a couple of people ask me about the new /secondary command-line flag that Skype 4.0 for Windows has now.
To be honest, I’d never heard of the flag, but it looks like it’s now possible to run more than one copy of Skype on Windows. Fantastic! A little more digging around and I found [https://developer.skype.com/jira/browse/SPA-597 this bug report] which also talks about /username and /password command-line options too. Neat!
So the question is this: “can I run more than one copy of Skype with the skype4pidgin plugin”. The answer up until now was “only on Linux”, and it would only really work if you ran both the dbus and X11 versions of the plugin. The answer now is “not yet”, since it’s going need a rewrite of things to be able to handle more than one Skype account through the plugin, as well as figuring out a way to target more than one copy of Skype running on Windows.
So I guess it’s just a big “watch this space” ![]()
Thanks for reading!
Groups in the Facebook plugin
Posted by Eion in Uncategorized on July 19th, 2009
For those people who upgraded to v1.60 of the pidgin-facebookchat plugin, you’ll probably notice that the Facebook groups have made their way into your Pidgin buddylist.
Oddly enough, this has spawned a looong thread of people who aren’t so happy with the new change. I thought it would be best to blog about why and what happened to get us to this stage and what we’re doing about it.
What happened is that we got reports of a major crash appearing whenever 32-bit (and Windows) users opened a conversation window or received a chat from someone. This was because our kludgy way of dealing with a limitation of timestamps from json-glib ended up overflowing. At the same time, we had been sitting on fixes for profile pictures/buddy icons, as well as status messages needing a new way to update.
The other issue was that I’ve been looking after my unwell fiancée all week, after several doctors trips, after-hours doctors trips and even a visit to the swine flu processing centre in Christchurch. So when I started getting email notifications of bug reports about the crashes, it was the final straw for me, and I hastily pushed out a new version…. completely forgetting that we had the new group/friend list’s code in there.
That said, we hadn’t had much feedback about the new groups stuff until now so we weren’t to know that everyone would hate it as much as they do.
So where to from here? Well, we want to come up with a solution that leaves everyone happy, while still allowing for using the new groups/friends list code. My idea is to have a toggle for the setting. Casey Ho, the other developer, says that I’m not allowed to offer that solution to people, as we’ll end up with an unstable situation. Instead, he’s adding support for hiding/showing different groups as well as the online/offline per-group setting that Facebook has. This should end up with the same result, just a different way of getting there.
So blame lies with me, I’m afraid, for all the groups mess. My apologies, but rest assured, we are working on ways to ‘fix the problem’ for you all
(Also, if you feel like making a donation to help pay for my fiancée’s medication so that we don’t have to keep going back to the doctors so that messes like this don’t happen in the future, I’m always grateful)
pidgin-facebookchat v1.51 important changes
By the time you read this, I’ll have come out with a new version of the pidgin-facebookchat plugin. There are some significant changes that downstream packagers will want to pay attention to.
The main one you’ll bump into, is that the plugin now uses the json-glib library. It’s included in svn if you don’t want to compile it yourself, but it’ll be good to make a package for your distro to include it, since not all distro’s have it. From now, we’ll be moving over the string-parsing code to use the new json-glib stuff. The buddy list has been the first thing ported over, and by the next version we’ll have moved all the code over to using it.
The other important change is that the plugin can use zlib for requesting compressed data from the Facebook servers. gzip content encoding is nothing new, but it was a P.I.T.A. to code up in C. To enable it, you’ll need to use the -DHAVE_ZLIB compiler flag. I’ve found that the data savings are around 75%, so you’ll make your fellow distro-users happy by enabling it.
SSH Security with Fail2Ban on Gentoo
Posted by Eion in Uncategorized on May 27th, 2009
I accidentally looked at my syslog messages on my home (Gentoo) Linux server and found that there were thousands of SSH connection attempts from all over the world: people trying to brute-force my root password. The worst bit was that it was filling up my logs and causing lots of things to die when the computer ran out of disk-space. It needed a bit of playing around to get this to stop, but in case you run across the same situation, I’ve documented what I did:
- Make sure you have the tcpd USE-flag on net-misc/openssh. If you don’t, the easiest way to add it is with the command
echo "net-misc/openssh tcpd" >> /etc/portage/package.use - Emerge fail2ban
- If you’re using syslog-ng, you need to configure it to log sshd logs to a different place (reduces load on the server) by adding the following lines to /etc/syslog-ng/syslog-ng.conf
filter f_sshd {match('^sshd\[[0-9]+\]:'); };
destination sshd { file("/var/log/sshd.log"); };
log { source(src); filter(f_sshd); destination(sshd); flags(final); } - Enable the ssh-tcpwrapper setting in /etc/fail2ban/jail.conf, checking that the logpath is pointing to your log file. It should end up looking something like
[ssh-tcpwrapper]
enabled = true
filter = sshd
action = hostsdeny
logpath = /var/log/sshd.log
- Set up the hosts allow/deny files (if you don’t have them) by pumping out the following commands to bash
touch /etc/hosts.allow
touch /etc/hosts.deny
chmod 644 /etc/hosts.allow
chmod 644 /etc/hosts.deny
- Reload syslog-ng
/etc/init.d/syslog-ng reload, restart openssh/etc/init.d/sshd restart, and start fail2ban/etc/init.d/fail2ban start && rc-update add fail2ban default
That should do it. I also recommend disabling the root account and disabling password authentication in your /etc/ssh/sshd_config file.