This is the first commit of "Don't use third-party "what is my IP" services (rebase)" #3461.
It is independent from the functionality in that pull and makes it easier to keep that it up to date. Also I think the code move makes sense, and it helps a little bit in reducing the size of main.cpp.