norm

norm

This user hasn't shared any profile information

Posts by norm

Using DNS whitelists in Postfix

0

Update 7/21/2011: I’ve tweaked my main.cf config more recently that provided better results. I will have a follow-up post with the changes and additions.

In an earlier post several years back, I wrote about using DNS blacklists (DNSBLs) in postfix to block unwanted spam from hitting my inbox, and in the last week I tweaked it a bit to include DNS whitelists (DNSWLs). I was discovering that some of the DNSBLs were blocking a small portion of legitimate email from coming through (eg. blocking entire IP ranges for webmail providers).

You need Postfix 2.8 or higher (I was on 2.3.3 so I had to download and compile the latest, 2.8.3), which has a new configuration parameter which added support for querying a DNSWL like a DNSBL:

permit_dnswl_client dnswl_domain=d.d.d.d

The relevant portion of my updated Postfix main.cf is below (note permit_dnswl_client is inserted before any of the reject_rbl* parameters). The DNSWL queries are processed first before the DNSBLs, so it should allow legitimate IPs through and reduce the amount of false positives vs just using the DNSBLs alone.

smtpd_recipient_restrictions =
        permit_mynetworks,
        reject_invalid_hostname,
        reject_non_fqdn_sender,
        reject_non_fqdn_recipient,
        reject_unknown_sender_domain,
        reject_unknown_recipient_domain,
        reject_unauth_destination,
        permit_dnswl_client list.dnswl.org,
        reject_rbl_client b.barracudacentral.org,
        reject_rbl_client zen.spamhaus.org,
        reject_rbl_client bl.spameatingmonkey.net,
        reject_rbl_client bl.spamcop.net,
        reject_rbl_client hostkarma.junkemailfilter.com=127.0.0.2,
        reject_rbl_client dnsbl.njabl.org,
        reject_rbl_client bl.tiopan.com,
        reject_rbl_client spamsources.fabel.dk,
        reject_rbl_client truncate.gbudb.net,
        reject_rbl_client ubl.unsubscore.com,
        reject_rbl_client aspews.ext.sorbs.net,
        reject_rbl_client dnsbl.sorbs.net,
        reject_rbl_client backscatter.spameatingmonkey.net,
        reject_rbl_client bl.spameatingmonkey.net,
        reject_rhsbl_sender fresh15.spameatingmonkey.net,
        reject_rhsbl_client fresh15.spameatingmonkey.net,
        reject_rhsbl_sender uribl.spameatingmonkey.net,
        reject_rhsbl_client uribl.spameatingmonkey.net,
        reject_rhsbl_sender urired.spameatingmonkey.net,
        reject_rhsbl_client urired.spameatingmonkey.net,
        reject_rbl_client dnsbl.inps.de,
        reject_rbl_client DDNSBL.InternetDefenseSystems.com,
        permit

After watching the logs for the last couple days, this setup seems to work quite well…only 1 piece of spam slipped through, and more importantly, no false positives! I should also note that I stopped using spamassassin a while back and just these settings in postfix seems to block almost all legitimate spam coming into my server while not generating false positives.

BTW, if you want to tail your maillog from the command line in realtime and see the rejects in a more readable format, this short one liner will work:

$ tail -f /var/log/maillog | sed -r -n 's/^.* blocked using ([^;]+).*; from=]+)>\s*to=]+)>.*$/\1 - \2 - \3/p'

it will output in the format DNSBL – FROM ADDRESS – TO ADDRESS

Updating iPhone apps to support Retina displays

0

The iPhone 4′s 640×960 display is night and day better than the previous generation’s 320×480 display. Supporting both is actually pretty straightforward.  The simplest thing is to do nothing: iOS 4 automagically up-sizes your image assets when running on a higher resolution display like the iPhone 4. It’ll look ok, but likely pixelated for the iPhone 4′s super sharp display.

To use higher res assets for iPhone 4, while keeping the lower res versions for earlier devices, simply add higher res images into your Xcode project with the following naming convention:

[ImageName]@2x.[filename_extension]

If you have an existing image named foobar.png that is 100×100, simply name the higher res 200×200 version as foobar@2x.png, add it to your project, and re-build. You don’t need to do anything else…when that app runs on an iPhone 4, if there is a @2x version of an image, that version will be loaded instead.

This document on the Apple Developer site summarizes it nicely & goes into more detail than I’ve covered here.

Resizing UILabel inside a UITable cell when doing a swipe delete gesture

0

When you do a right swipe gesture on a table cell in the iPhone’s Mail app, a delete button appears and the text reflows around the button, like so:

Swipe & Delete

I built a similar interface that looks and functions similarly. The only problem was that when you right swiped, the delete button would appear, but the text would not reflow. Looking at the API docs, I made sure that all the subviews were added to the UITableViewCell’s contentView. I found a post on Stack Overflow that mentioned setting the contentMode property to UIViewContentModeLeft, but that didn’t work for me.

After digging around some more, I discovered that the autoresizingMask property of UILabel defaults to UIViewAutoresizingNone. When i set autoresizingMask to UIViewAutoresizingFlexibleWidth in the two UILabels (subject & body preview), they now reflow automatically when the delete button appears.

Adding random contacts and email addresses to the iPhone simulator address book

0

I needed some test data in my iPhone simulator’s address book to test out some functionality in the Raptr iPhone app, but adding contacts one by one would have been onerous, especially since I wanted several hundred!

Thankfully, you can programmatically add contacts to the iPhone contacts so I came up with the following snippet for a quick and dirty way to add a bunch of random contacts with random email addresses:

ABAddressBookRef addressBook = ABAddressBookCreate();

// create 200 random contacts
for (int i = 0; i < 200; i++)
{
	// create an ABRecordRef
	ABRecordRef record = ABPersonCreate();

	ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABStringPropertyType);

	NSString *email = [NSString stringWithFormat:@"%i@%ifoo.com", i, i];
	ABMultiValueAddValueAndLabel(multi, email, kABHomeLabel, NULL);

	NSString *fname = [NSString stringWithFormat:@"Name %i", i];
	NSString *lname = [NSString stringWithFormat:@"Last %i", i];

	// add the first name
	ABRecordSetValue(record, kABPersonFirstNameProperty, fname, NULL);

	// add the last name
	ABRecordSetValue(record, kABPersonLastNameProperty, lname, NULL);

	// add the home email
	ABRecordSetValue(record, kABPersonEmailProperty, multi, NULL);

	// add the record
	ABAddressBookAddRecord(addressBook, record, NULL);
}

// save the address book
ABAddressBookSave(addressBook, NULL);

// release
CFRelease(addressBook);

Put this inside -viewDidLoad or -loadView, launch the simulator and you’re set: 200 random contacts added to the simulator’s Contacts app. Make sure you remove this code snippet after you’ve run it once or you’ll keep adding random contacts. If you ever want to clear out the contacts on the simulator just go to the menu: iPhone Simulator -> Reset Content and Settings…

Downloading earlier versions of iPhone OS

0

If you’re ever in need of downloading an earlier version on the iPhone OS, iClarified has a list of iPhone firmware files for download from Apple’s servers. This is great if say you need to downgrade your iPhone 3G from iOS 4 back to iOS 3.1.3.

Page 2 of 1612345...10...Last »
norm's RSS Feed
Go to Top