As I read it, your question is way more general than your Javascript / WebRTC use case.
Who about something like: "Given a P2P network, and a central server that knows all connected peers, which is the best metric than can be used to pair them up?".
=> As good metric to pair two arbitrary nodes would be the hop-distance between them. The problem being that this value is not possible to compute (you can only guess which path the ISP routers will chose between the nodes).
How to approximate it then?
1. Use geographical distance as an approximation to hop distance
In that case, you are pretty much done. Use any "ip to latlng" service and you are done.
2. Try to guess the real hop distance by mapping the internet
I found a paper on that subject, that might be useful to you. You might as well dig a bit on their references to retrieve previous papers on the same subject:
Estimating Hop Distance Between Arbitrary Host Pairs
http://nowak.ece.wisc.edu/infocom09.pdf
Abstract — Establishing a clear and timely picture of Internet
topology is complicated by many factors including the vast size
and dynamic nature of the infrastructure. In this paper, we describe
a methodology for estimating an important characteristic
of Internet topology - the hop distance between arbitrary pairs
of end hosts. Our goal is to develop an approach to pairwise
hop distance estimation that is accurate, scalable, timely and
does not require a significant measurement infrastructure. Our
methodology is based on deploying a small set of landmark
nodes that use traceroute-like probes between each other to
establish a set of accurate pairwise hop distances. The landmark
nodes are also configured to collect source IP addresses and
TTL values from passively monitored network packet traffic.
We develop a novel multidimensional scaling algorithm that
can be applied to both the passive and active measurements to
generate pairwise hop distance estimates for all of the observed
source host addresses. The basic algorithm is then enhanced to
consider the autonomous system membership of source hosts via
BGP routing information. We investigate the capabilities of our
estimation algorithms using a set of synthetic network topologies.
The results show that our method can generate highly accurate
pairwise hop distance estimates over a range of network sizes
and configurations, and landmark infrastructure sizes.