private DatagramSocket createOrGetRelaySocket(SocketAddress originalSocketAddress){
  if (!proxySocketsByOriginalAddress.containsKey(originalSocketAddress)) {
    try {
      DatagramSocket relaySocket=new DatagramSocket(new InetSocketAddress(getLoopbackAddress(),0));
      logger.debug("Mapping peer {} to relay socket {}",originalSocketAddress,relaySocket.getLocalSocketAddress());
      proxySocketsByOriginalAddress.put(originalSocketAddress,relaySocket);
      readSocket(threadPoolExecutor,relaySocket,null);
    }
 catch (    SocketException e) {
      throw new RuntimeException(e);
    }
  }
  return proxySocketsByOriginalAddress.get(originalSocketAddress);
}

private DatagramSocket createOrGetRelaySocket ( SocketAddress originalSocketAddress ) { if ( ! proxySocketsByOriginalAddress . containsKey ( originalSocketAddress ) ) { try { DatagramSocket relaySocket = new DatagramSocket ( new InetSocketAddress ( getLoopbackAddress ( ) , 0 ) ) ; logger . debug ( "Mapping peer {} to relay socket {}" , originalSocketAddress , relaySocket . getLocalSocketAddress ( ) ) ; proxySocketsByOriginalAddress . put ( originalSocketAddress , relaySocket ) ; readSocket ( threadPoolExecutor , relaySocket , null ) ; } catch ( SocketException e ) { throw new RuntimeException ( e ) ; } } return proxySocketsByOriginalAddress . get ( originalSocketAddress ) ; }
opens a local udp socket that serves as a proxy for a peer to fa . in other words , instead of connecting to peer x directly , a local port is opened which represents that peer . fa will then data to this port , thinking it ' s peer x . all data received on that port is then forwarded to the original peer and any data received on the public udp socket is forwarded through its peer socket .
