Ejemplo n.º 1
0
 /** @since 0.9.9 moved from constructor */
 private void buildAddresses(String destinations) {
   if (destinations == null) return;
   StringTokenizer tok = new StringTokenizer(destinations, ", ");
   synchronized (_addrs) {
     _addrs.clear();
     while (tok.hasMoreTokens()) {
       String destination = tok.nextToken();
       try {
         // Try to resolve here but only log if it doesn't.
         // Note that b32 _addrs will often not be resolvable at instantiation time.
         // We will try again to resolve in clientConnectionRun()
         I2PSocketAddress addr = new I2PSocketAddress(destination);
         _addrs.add(addr);
         if (addr.isUnresolved()) {
           String name = addr.getHostName();
           if (name.length() == 60 && name.endsWith(".b32.i2p"))
             l.log(
                 "Warning - Could not resolve "
                     + name
                     + ", perhaps it is not up, will retry when connecting.");
           else
             l.log(
                 "Warning - Could not resolve "
                     + name
                     + ", you must add it to your address book for it to work.");
         } else {
           dests.add(addr.getAddress());
         }
       } catch (IllegalArgumentException iae) {
         l.log("Bad destination " + destination + " - " + iae);
       }
     }
   }
 }
Ejemplo n.º 2
0
 protected void clientConnectionRun(Socket s) {
   I2PSocket i2ps = null;
   try {
     I2PSocketAddress addr = pickDestination();
     if (addr == null) throw new UnknownHostException("No valid destination configured");
     Destination clientDest = addr.getAddress();
     if (clientDest == null)
       throw new UnknownHostException("Could not resolve " + addr.getHostName());
     int port = addr.getPort();
     i2ps = createI2PSocket(clientDest, port);
     i2ps.setReadTimeout(readTimeout);
     new I2PTunnelRunner(s, i2ps, sockLock, null, mySockets);
   } catch (Exception ex) {
     if (_log.shouldLog(Log.INFO)) _log.info("Error connecting", ex);
     // l.log("Error connecting: " + ex.getMessage());
     closeSocket(s);
     if (i2ps != null) {
       synchronized (sockLock) {
         mySockets.remove(sockLock);
       }
     }
   }
 }