refactor ipaddr discovery