Refactor lua_ip one more time.

Suggested by:	clock via irc