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.

No Comments

SSH Security with Fail2Ban on Gentoo

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.

2 Comments

Voice chat in Facebook Chat???

So was looking through the debug logs for Facebook chat and stumbled upon this:

"enableVC":false

in all the users properties. Does VC stand for voice chat? Lets wait and see 🙂

Edit: It gets even better. There’s lots of “POPOUT_TYPE_VIDEOCHAT” and “if (this.inVideoChat)” messages in the source code in the Facebook Javascript.

1 Comment

Gzip Encoding

On PHP pages that I get control over, one of the first things I do is add Gzip encoding. This compresses the text on the page for browsers that can handle it, and really reduces network traffic, speeding up page load/download times on dial-up (well, and broadband) connections significantly.

On PHP this is really easy, its just one line of code at the top of the page:

ob_start('ob_gzhandler');

But until now, I had trouble finding out how to do this for .NET sites. All I could find was that you can enable it server-wide on IIS but now I found this handy bit of code that can go at the top of your .NET pages.

string AcceptEncoding = HttpContext.Current.Request.Headers["Accept-Encoding"];
if (!string.IsNullOrEmpty(AcceptEncoding) && AcceptEncoding.Contains("gzip"))
{
    HttpContext.Current.Response.AppendHeader("Content-Encoding", "gzip");
    HttpContext.Current.Response.AppendHeader("Vary", "Content-Encoding");
    HttpContext.Current.Response.Filter = new System.IO.Compression.GZipStream(HttpContext.Current.Response.Filter, System.IO.Compression.CompressionMode.Compress);
}

And that’s it. Tasty Gzip encoding for all. The next step is testing it, which I use the mod_gzip_test site for. You can see an example of the changes we made to gameplayer.co.nz (a .net site) here

1 Comment

Reversing Skype

So there’s a few things that the Skype API’s don’t provide which I needed in the Pidgin/Adium/libpurple plugins. Thought I’d document them here in case other people want to do the same.

One of the first hurdles I ran into was that on OSX, you need to link with the Skype.Framework bundle to access the Skype API commands. Unfortunately, linking with non-GPL libraries is forbidden in the GPL so I set out to work out how and what it does to ‘talk’ to Skype. Turns out that OSX has a few different ways of “inter-process communication”, but there was only one way that used Carbon as well as Cocoa… Long story short, I managed to work out that it was a CFNotificationCenter which was used to send/receive messages. So I created a debug function to see what the key/value pairs that Skype.Framework sent to Skype and managed to work it all out. It turned out that this reverse-engineering proved helpful for the Skype4Py team, who used it to get Skype4Py working on OSX. You too can use my GPL’d version of the framework at http://code.google.com/p/skype4pidgin/source/browse/trunk/skype_messaging_carbon2.c

The next problem was that I wanted to send/receive typing notifications, but the Skype API didn’t provide any way of doing this. In the end, I created an API app2app stream, called “libpurple_typing” which sends datagrams of “PURPLE_TYPING”, “PURPLE_NOT_TYPING” and “PURPLE_TYPED”, which directly relate to the libpurple typing notifications.  I haven’t seen any other Skype API wrappers (Trillian/Miranda/Fring) doing anything like this, but if I’m wrong let me know and I’ll get the plugin working with them.  Maybe all us 3rd parties can get together some day and agree on a common way of sending typing states. 🙂

Last thing I’ve managed to do was get avatars on platforms (Linux and until recently, OSX) that didn’t support the “GET AVATAR” api command.  Originally it was to get avatars for the SkypeNet (no-skype-needed) version of the plugin.  Turns out they were all stored in user{number}.dbb files, which are apparently Kazaa storage blobs.  Some kind of database that noone’s been able to work out.  From the looks of things now, Skype for Windows uses a SQLlite db for storage so this method won’t work there, but the way to find the avatar, is to loop through all the user*.dbb files and find the Skype username of the avatar in the file.  Then just skip ahead to a 0xFF,0xD8 block (header for a JPEG) and grab all the data up until 0xFF,0xD9.  If you hit 0x6C,0x33,0x33,0x6C (db entry boundary), you’ve gone too far.

I guess the rest of the features that Skype don’t provide that I’m working on would be:

  • Sending a file without using the Skype-provided file picker
  • Accepting/rejecting a file without opening Skype
  • Automatic authorization of the plugin with Skype

All the above features should allow the plugin to work without a Skype GUI using something like Finch, since these days not everyone has flash graphics stuff 🙂

Anyways.   I hope that’s useful to other developers out there.  I had fun doing it 🙂

1 Comment

Where’s the Skype plugin?

So you may be wondering why it’s taken so long for a Skype plugin update for Linux and Windows.  I mean, you probably don’t actually wonder these things since no one reads this blog, but meh 😉

The Adium plugin has been having several updates latetly while the Pidgin plugin gets none.  What gives?  Well, probably the most important thing is that the Adium plugin was sucking CPU power due to a bug in Skype 2.7/2.8 for Mac.  The second reason, was that Adium people were unable to set their status to away or DND or invisible etc… which I can imagine would be quite annoying.  I’m not a mac user myself, so it doesn’t really bother me so much.

The main reason I haven’t put out a Pidgin plugin yet, is I’m mostly waiting for Pidgin 2.6 to come out.  The special, magical thing about Pidgin 2.6 is that it has hooks in it to let people make voice and video calls.  The Skype plugin’s taking advantage of this to use the new “media” menu to make/accept/hang up voice calls… which has several obvious benefits.

Other than that, new features that I’m holding out on are

  • ‘Missed’ messages fetching (eg, if you get a message in Skype while Pidgin was closed/crashed)
  • New chat message handling which should decrease CPU load
  • Better chat handling (easier to add to buddy list, can “get info” on a buddy from the chat window)
  • Probably more, but I can’t remember them 🙂

The other effects of the new features is to get the plugin to work better with the no-Skype-needed version of the plugin.  More about that in another blog post 🙂

So thats it really.  I’m kinda waiting, kinda thinking I should make one last release before Pidgin 2.6…. I’ll think about it some more.  If you want, you can always compile from source or you can ask me nicely and I’ll load up a new dll/so/something 🙂

7 Comments

Pidgin-FacebookChat v1.50

So I’ve just put out an update for Pidgin-FacebookChat, the Facebook chat plugin for Pidgin and thought I should do a bit more of a writeup than what’s in the changelog.

One of the more important features is that there should be a much lower bandwidth usage for some people.  Unfortunately, the plugin was getting into a rapid loop in the fetch-message routine which would cause the www.facebook.com/home.php page to be downloaded lots and lots (and lots) of times in quick succession.  I’m not 100% sure of the reason behind this, but it seemed to be worse the closer you are to the Facebook servers.

To try and work around this, I’ve added in a 1 second delay to the re-request of messages, as well as instead of grabbing the data that was needed from the /home.php page, grabbing it from the smaller “pop-out chat” window.  So there’s now less stuff to download, and download less frequently.  I hope that fixes it 🙁  I’m genuinely sorry to those people who ended up having to pay for extra bandwidth charges 🙁

On a more positive note, there’s another minor feature in the plugin that wasn’t in the changelog: the plugin now sends the “Accept-Language” HTTP header.  Thats the techy way of saying that you should now be receiving error messages from the Facebook servers in the same language that you look at Pidgin in.   While most of the pidgin-facebookchat plugin hasn’t been translated (unlike the Skype plugin), the error messages from the Facebook servers would appear to be in your language.  From the looks of it, Facebook were doing an IP address detection to work out what country you were in, and giving error messages in the language of that country.  Great 99% of the time, but really hard to use when you’re, say, on a trip overseas in a country that you can’t read the language of.

The other feature in this version of the plugin is to be able to force yourself to be in the ‘idle’ state on Facebook chat.  Previously, you had to configure your Pidgin to report your idle status after 5 minutes but now there’s an “idle” status type in the selection.  This should help with people who set their status to something other than “online” in Pidgin, no more messages from people who think you’re ignoring them.  To be honest, I didn’t actually get much of a chance to test this feature, so let me know you’re success stories with it.

So go download the plugin, and let me know what you think 🙂

No Comments

Skype 2.8 beta 2 for Mac Released

So as my first “real” post, I thought I’d say that Skype have released an update to Skype 2.8 beta 2.  The interesting bit is here where they’ve reported on all the errors that were fixed including an important one that I reported “Skype API: implemented: get chat x dialog_partner”.  One little line of bugfix caused a lot of relief for me.  A little side story:

For a while, the Skype plugin for Adium had been generating a lot of console log messages.  This was something I knew, but what I didn’t know was that it was eating up CPU cycles and causing incomming messages to be missed.  It turns out that this was why I couldn’t keep my loaned macbook on my lap for too long: the CPU temp was getting up to 90 degrees Celsius causing large red welts on my legs!

So, longish story short, I reluctantly rewrote the messaging (well the chat) part of the plugin to work out who incoming messages were from.  The one line of code which called “get chat x dialog_partner” had to be replaced with hundreds of lines of callbacks and other code.  Gah!

So yeah.  If you’ve got an old version of the Adium plugin, rejoyce:  Skype have fixed their bug, but in the end, if you’ve got a newer/newest version of the plugin you should be happy that you’ve got a lot better code because of it 🙂

No Comments

New Blog

So hi everyone.  I’ve always had a few ideas that I’ve wanted to tell the world about and have started up this blog.

In case you didn’t already know, I’m Eion, also known online as BigBrownChunx.  For my day-job, I work on popular NZ websites such as MyJobSpace (myjobspace.co.nz), DineOut (www.dineout.co.nz) and Vorb (www.vorb.org.nz).  But by-night, I work on the Facebook plugin for Pidgin and the Skype plugin for Pidgin as well as helping out my fiancé on her gardening website at www.littlesliceofeden.co.nz

Anyway, I hope to be like every other whimsical blog-poster out there and post two or three times a week.  Here’s hoping I can keep it up 🙂

No Comments