I would report this as a bug.
You are correct, $ip appears to be returning the most recent internal call to /localinfo [-h|-u], the -h or -u variation is chosen based on your setting in Options > Connect > Local > 'Lookup method' > ( ) Normal / (x) Server
$ip is being set as a global value instead of a server-specific value associated with $cid. I would move this as a Bug Report, expecting that $scid(N).ip or $scon(N).ip returns the value retrieved from that given connection instance.