Is there an API for getting the current IP address that you can use in Apex code? I didn't see anything in UserInfo, and I don't want to use the LoginHistory object at all for this.
You should be able to query
AuthSession record with a
SessionType of SubstituteUser is created when you log in as another user.