DNS parsing and writing in javascript