Fix block extend feature. Thanks to: @doowb
add local IP detection helper