Changeset 173
- Timestamp:
- 02/23/06 18:37:19 (2 years ago)
- Files:
-
- feedtree/trunk/build.xml (modified) (1 diff)
- feedtree/trunk/src/net/feedtree/core/client/Client.java (modified) (4 diffs)
- feedtree/trunk/src/net/feedtree/proxyapp/WebProxyClient.java (modified) (4 diffs)
- feedtree/trunk/src/net/feedtree/proxyapp/gui/AppControl.java (modified) (4 diffs)
- feedtree/trunk/src/net/feedtree/publisher/Publisher.java (modified) (3 diffs)
- feedtree/trunk/src/net/feedtree/util/NAT.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
feedtree/trunk/build.xml
r166 r173 72 72 description="compile the source " > 73 73 74 <!-- Compile the java code from ${src} into ${build} -->75 74 <javac 76 srcdir="${src}" 77 destdir="${build}" 78 classpathref="project.classpath" 79 debuglevel="lines,vars,source" 80 debug="true" 81 > 82 </javac> 75 srcdir="${src}" 76 destdir="${build}" 77 classpathref="project.classpath" 78 debuglevel="lines,vars,source" 79 debug="true" 80 > 81 <exclude name="net/feedtree/report/*.java"/> 82 </javac> 83 83 </target> 84 84 feedtree/trunk/src/net/feedtree/core/client/Client.java
r101 r173 238 238 } 239 239 240 public static Node start_node(int port, String bootHost, int bootPort, boolean waitForReady) { 240 public static Node start_node( 241 InetAddress localHost, int port, 242 String bootHost, int bootPort, 243 boolean waitForReady) 244 { 241 245 Node node = null; 242 246 … … 275 279 attempts --; 276 280 277 Logger.global.fine("[Creating new node on port " + port + "]"); 281 Logger.global.fine("[Creating new node on " 282 + localHost + " port " + port + "]"); 278 283 279 284 if (bootHost != "") { … … 296 301 297 302 InetAddress natAddr = NAT.findNatAddress( 298 port, bootSocketList, pastryEnv);303 localHost, port, bootSocketList, pastryEnv); 299 304 g_localNodeAddress = null; 300 305 if (natAddr != null) … … 310 315 factory.getNodeHandle(bootSocketList[0]), 311 316 g_localNodeAddress); 317 } catch (java.net.BindException exc) { 318 Logger.global.severe("error: couldn't bind to requested address (already in use?)"); 319 status.notifyStatus(ClientStatus.STATUS_ERROR, 320 "The address " + localHost.getHostAddress() + ":" 321 + port + " couldn't be used. Is the proxy already running?"); 322 return null; 312 323 } catch (java.io.StreamCorruptedException exc) { 313 324 Logger.global.severe("Stream corruption error while finding bootstrap. Sleeping and trying again."); feedtree/trunk/src/net/feedtree/proxyapp/WebProxyClient.java
r160 r173 1345 1345 "Starting up"); 1346 1346 1347 InetAddress myHost = null; 1348 try { 1349 myHost = InetAddress.getLocalHost(); 1350 } catch (UnknownHostException exc) { 1351 // pass ... hopefully the user will specify it 1352 } 1347 1353 int myPort = Client.PASTRY_PORT; 1348 1354 int bsPort = Client.PASTRY_PORT; … … 1364 1370 if (args[i].equals("--port") || args[i].equals("-p")) { 1365 1371 myPort = to_int(args[++i]); 1372 } else if (args[i].equals("--local-ip") || args[i].equals("-I")) { 1373 String hostSpec = args[++i]; 1374 try { 1375 myHost = InetAddress.getByName(hostSpec); 1376 } catch (UnknownHostException exc) { 1377 System.out.println("error: address could not be resolved: " + hostSpec); 1378 System.exit(1); 1379 } 1366 1380 } else if (args[i].equals("--verbose") || args[i].equals("-v")) { 1367 1381 verbosity++; … … 1449 1463 + " (default: "+Client.PASTRY_PORT+")\n" 1450 1464 + "\n" 1465 + " -I/--local-ip <address>\n" 1466 + " local IP address for FeedTree node (optional)\n" 1467 + " (use this only if you need to select among multiple network \n" 1468 + " interfaces; if behind a NAT, put your internal NAT IP here,\n" 1469 + " not your public IP)\n" 1470 + " (guessed default: "+myHost.getHostAddress()+")\n" 1471 + "\n" 1451 1472 + " -w/--web-port <port>\n" 1452 1473 + " port on localhost for web-based status page\n" … … 1546 1567 } 1547 1568 1569 if (myHost == null) { 1570 System.out.println("error: could not automatically detect local host address; consider using --local-ip flag"); 1571 System.exit(1); 1572 } 1573 1548 1574 // Start the node 1549 Node node = Client.start_node(myPort, bs, bsPort, true); 1550 1551 if (node == null) { return; } 1575 Node node = Client.start_node(myHost, myPort, bs, bsPort, true); 1576 1577 if (node == null) { 1578 System.out.println("error: problem starting node (run with --max-verbose for more information)"); 1579 System.exit(1); 1580 } 1552 1581 1553 1582 Client.clientStatus().notifyStatus(ClientStatus.STATUS_STARTING, feedtree/trunk/src/net/feedtree/proxyapp/gui/AppControl.java
r136 r173 5 5 import java.util.logging.*; 6 6 import java.util.prefs.*; 7 import java.net.*; 7 8 8 9 import net.feedtree.proxyapp.*; … … 21 22 22 23 public static final String PR_PASTRY_PORT = "port"; 24 public static final String PR_LOCAL_IP = "local-ip"; 23 25 public static final String PR_BOOTSTRAP = "bootstrap"; 24 26 public static final String PR_PUBLIC = "public"; … … 258 260 WebProxyClient.DEFAULT_BOOTSTRAP_HOST + ":" + Client.PASTRY_PORT); 259 261 262 InetAddress myHost = null; 263 String localIP = prefs.get(PR_LOCAL_IP, ""); 264 if (localIP.equals("")) { 265 try { 266 myHost = InetAddress.getLocalHost(); 267 } catch (UnknownHostException exc) { 268 Client.clientStatus().notifyStatus( 269 Client.ClientStatus.STATUS_ERROR, 270 "Could not detect local IP. Please configure one in the preferences panel and re-start the proxy."); 271 } 272 } else { 273 try { 274 myHost = InetAddress.getByName(localIP); 275 } catch (UnknownHostException exc) { 276 Client.clientStatus().notifyStatus( 277 Client.ClientStatus.STATUS_ERROR, 278 "Could not parse local IP: " + localIP + ". Please alter the value in the preferences panel and re-start the proxy."); 279 } 280 } 281 260 282 String bs; int bsPort; 261 283 try { … … 343 365 344 366 // Start the node 345 Node node = Client.start_node(my Port, bs, bsPort, true);367 Node node = Client.start_node(myHost, myPort, bs, bsPort, true); 346 368 347 369 // communicate with AppGUI feedtree/trunk/src/net/feedtree/publisher/Publisher.java
r160 r173 83 83 public static final String PROP_HEARTBEAT_INTERVAL = "heartbeat_interval_sec"; 84 84 85 /// Local hostname or IP on which to start the FeedTree node (default: auto-detected) 86 /// \note If your publisher host has multiple network interfaces, this 87 /// will allow you to control which one is used for the Pastry node 88 /// \note If you run behind a NAT and choose to specify this, use your 89 /// local address, not your public address; the public address will be 90 /// detected at run-time 91 public static final String PROP_LOCAL_IP = "node_local_ip"; 92 85 93 /// Port on which to start the FeedTree node (default: 29690) 86 94 /// \note If the Publisher runs behind a NAT, this port must be … … 776 784 } 777 785 786 InetAddress myHost = null; 787 788 String localIP = g_config.optString(PROP_LOCAL_IP,""); 789 if (localIP.equals("")) { 790 try { 791 myHost = InetAddress.getLocalHost(); 792 } catch (UnknownHostException exc) { 793 Logger.global.severe("error: could not automatically detect IP address; add a " + PROP_LOCAL_IP + " property to your config file"); 794 System.exit(1); 795 } 796 } else { 797 try { 798 myHost = InetAddress.getByName(localIP); 799 } catch (UnknownHostException exc) { 800 Logger.global.severe("error: could not parse/resolve specified IP address: " + localIP); 801 System.exit(1); 802 } 803 } 804 805 778 806 int myPort = g_config.optInt(PROP_PASTRY_PORT, Client.PASTRY_PORT); 779 807 int bsPort = g_config.optInt(PROP_BOOTSTRAP_PORT, Client.PASTRY_PORT); … … 849 877 // Start the publisher node and application. 850 878 851 Node node = Client.start_node(my Port, bs, bsPort, true);879 Node node = Client.start_node(myHost, myPort, bs, bsPort, true); 852 880 853 881 Publisher appl = new Publisher(node, myPort, webPort, feeds, privateKey); feedtree/trunk/src/net/feedtree/util/NAT.java
r106 r173 3 3 import java.lang.*; 4 4 import java.net.*; 5 import java.io.*; 5 6 import java.util.Random; 6 7 import java.util.logging.*; … … 29 30 protected static Random random = new Random(); 30 31 31 public static InetAddress findNatAddress(int port, InetSocketAddress[] addresses, Environment env) 32 throws Exception 32 public static InetAddress findNatAddress( 33 InetAddress localHost, int port, 34 InetSocketAddress[] addresses, Environment env) 35 throws UnknownHostException, StreamCorruptedException, IOException 33 36 { 34 InetAddress localHost = InetAddress.getLocalHost(); 37 Logger.global.info("Finding public address for IP: " + localHost.getHostAddress()); 38 35 39 InetSocketAddress localSocket = new InetSocketAddress(localHost, port); 36 40 int speedup = 4;
