My own box has some troubles with its DNS entries, this means that you can no longer reach the LibTre (treregex-0.7)...
I've set up an googlepage to store it in the mean time: easyerl.googlepages.com.
Why did I take some much time to fix it ? That's because I've left Paris to work in the South of France, exactly "sur la côté d'Azur".
I'll publish some other simple things in the near future... So you just need to subscribe to my Feed :).
Download libTre.
PS: Now if you read the mailing list you'll be able to retrieve the package...
Showing posts with label DNS. Show all posts
Showing posts with label DNS. Show all posts
Thursday, December 20, 2007
Saturday, June 9, 2007
Sorting Mx servers using their preference number...
Once you've retrieved your mx lists, you want to be kind enough to gently contact mx server in their prefered order...
In erlang, sorting a list is done with sort function like 'keysort'.
lists:keysort uses as first parameter, the nth element of the tuple to use in the sort, and as second parameter the tuple list you want to sort...
Once you've sorted your tuple list, you may want to remove the key you use to sort, lists:unzip remove this...
Finally, retrieving a mx list, sorting it, and directly using it can be done like this:
In erlang, sorting a list is done with sort function like 'keysort'.
SortedList = lists:keysort(1, List).
lists:keysort uses as first parameter, the nth element of the tuple to use in the sort, and as second parameter the tuple list you want to sort...
Once you've sorted your tuple list, you may want to remove the key you use to sort, lists:unzip remove this...
Finally, retrieving a mx list, sorting it, and directly using it can be done like this:
mxlist(Domain) ->
List = get_mx(Domain),
{_, Hosts} = lists:unzip( lists:keysort(1, List) ),
Hosts.
Thursday, June 7, 2007
Configuring your DNS server for inet_res.
When using inet_res, you must configure a DNS server to query, this could be done like this:
Once you've called your ?MODULE:init/1 you're able to use your ?MODULE:get_mx/1 function.
The result is a list of tuples, the first element is the server weight, the second the server name :p
-define(MASTER_DNS, {212,XX,XX,252}).
init() ->
inet_db:add_ns(?MASTER_DNS).
Once you've called your ?MODULE:init/1 you're able to use your ?MODULE:get_mx/1 function.
node> mail:init().
ok
node> mail:get_mx("yahoo.com").
[{1,"e.mx.mail.yahoo.com"},
{1,"a.mx.mail.yahoo.com"},
{1,"b.mx.mail.yahoo.com"},
{1,"c.mx.mail.yahoo.com"},
{1,"d.mx.mail.yahoo.com"},
{1,"f.mx.mail.yahoo.com"},
{1,"g.mx.mail.yahoo.com"}]
The result is a list of tuples, the first element is the server weight, the second the server name :p
Wednesday, June 6, 2007
Retrieve MX DNS record using erlang inet_res, it's easy !
Ever needed to retrieve some MX servers from any big domains out there ?
I'm pretty sure that you've asked yourself this question, right ?
It's EasyErl here, so let's go to the code directly:
Woh ! This wasn't too much difficult !
Okay, inet_res:getbyname isn't really well documented that's right, but Erlang comes with its source code, what's a better Erlang documentation than Erlang himself ?
The next time, I'll show you how you can easily sort the List by using unzip to obtain a correct list of MX servers... (where servers weight are correctly used)
I'm pretty sure that you've asked yourself this question, right ?
It's EasyErl here, so let's go to the code directly:
get_mx(Domain) ->
{ok, {hostent, Domain, _, _, _Len, List}} = inet_res:getbyname(Domain, mx),
List.
Woh ! This wasn't too much difficult !
Okay, inet_res:getbyname isn't really well documented that's right, but Erlang comes with its source code, what's a better Erlang documentation than Erlang himself ?
The next time, I'll show you how you can easily sort the List by using unzip to obtain a correct list of MX servers... (where servers weight are correctly used)
Subscribe to:
Posts (Atom)