Archive for March, 2009

Editdns.pl – EditDNS Record Management Script

Tuesday, March 31st, 2009

Over the last couple of years, I’ve used a few more or less popular free DNS hosting services, and my best experience so far has been with EditDNS.net — mostly because their service really puts you in control of your domains and records. I started using them when I needed to set up SPF records (which are technically TXT records in a specific format) for a domain, and I discovered TXT records were not supported by most DNS hosting services — EditDNS being one of the few exceptions.

However, a couple days ago I encountered a problem. I wanted to set up a round robin DNS configuration for a domain with two IP addresses, one of them being a dynamic IP (that changed once every month or two). One of the key objectives was that the DNS records should be updated automatically when the IP changed. An obvious solution would be to use DynDNS records (supported by EditDNS), but I quickly learned that it’s not possible to set up two records with the same name (which is the basis for a round robin configuration) and make only one of them DynDNS ready. The system considered both records dynamic and wouldn’t just update one, keeping the other one intact. So, bummer. My next idea was to use the EditDNS API to simply delete the old record and create a new one with the new IP address, but this turned out to be impossible too, as the delete function is not yet implemented in the API. Bummer again.

But there are no unsolvable problems, just unwritten Perl scripts. I ended up putting together a simple script that uses LWP::UserAgent to log in to the EditDNS website and add new records or delete existing ones. The script is flexible enough for general use, so I’m making it available — if any fellow EditDNS users are reading this, maybe you’ll find it useful too.

Postfix and Google’s SMTP Server

Tuesday, March 24th, 2009

I was recently configuring my local Postfix e-mail server to relay messages destined for Gmail accounts through Google’s SMTP server. The setup is actually pretty simple, and there are numerous good articles on this subject available on the Intertubes, to name a few:

The above sources will give you a detailed description of what you need to do (including creating a certificate, in case you don’t have one already), I’m just going to list the essential parts here. As a prerequisite, you need a Gmail account, as Google’s SMTP server requires you to authorize before allowing you to relay anything.

Note: My e-mail server is running FreeBSD, so if you’re on a different operating system, the location of Postfix configuration files will probably be different — you might have /etc/postfix instead of /usr/local/etc/postfix.

To tell Postfix to relay all messages destined for *@gmail.com through Google’s SMTP server, put this into /usr/local/etc/postfix/transport:

gmail.com smtp:[smtp.gmail.com]:587

Then, create the /usr/local/etc/postfix/sasl_passwd file, telling Postfix to authorize with your Gmail login credentials when connecting to Google’s SMTP server:

[smtp.gmail.com]:587 username@gmail.com:password

Finally, put the following into /usr/local/etc/postfix/main.cf:

transport_maps = hash:/usr/local/etc/postfix/transport smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/usr/local/etc/postfix/sasl_passwd smtp_sasl_mechanism_filter = plain, login smtp_sasl_security_options = noanonymous smtp_use_tls = yes

The transport and sasl_passwd files need to be hashed with postmap:

# postmap transport && postmap sasl_passwd

That’s it for the configuration. Restart Postfix to make the changes effective (again, the command below is for FreeBSD):

# /usr/local/etc/rc.d/postfix restart

That’s it — you can now test it by sending something to your Gmail account.

It’s working? Grrreat. However, you might notice that there’s one fundamental problem with this solution — any message transmitted this way has it’s original “from” address replaced with your Gmail account’s address, making it look as if it was actually sent from Gmail.

Luckily, as I found out, the “from” address will be left intact if it is listed as one of the “other addresses” assigned to your Gmail account. So, you just need to log in to your account, go to Settings → Accounts, and use the “Add another email address” option to add any addresses that you want to relay mail for.

ImgAreaSelect 0.7

Thursday, March 19th, 2009

Yesterday I released the new version of the imgAreaSelect jQuery plugin. The most significant addition in this release is support for resize handles on the selection area (enabled with an option), as requested by a few people. I’ve also managed to find a workaround for the annoying bug in Opera that prevented the move/resize cursors from being displayed properly.

While working on this version, I began planning the next one, and I’m probably going to rewrite and reorganize some parts of the code. The plugin has grown bigger than I imagined (both in features and code size), so a little restructuring certainly won’t hurt.