Changeset 07caf2e
- Timestamp:
- Jun 13, 2012 7:02:09 PM (9 years ago)
- Branches:
- master
- Children:
- ad1b356
- Parents:
- 6e52ae3
- Location:
- apps
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java
r6e52ae3 r07caf2e 47 47 import java.util.List; 48 48 import java.util.Locale; 49 import java.util.Map; 49 50 import java.util.Properties; 50 51 import java.util.Set; … … 331 332 * Sets the event "clientoptions_onResult" = "ok" after completion. 332 333 * 334 * Deprecated use setClientOptions() 335 * 333 336 * @param args each args[i] is a key=value pair to add to the options 334 337 * @param l logger to receive events and output … … 344 347 _clientOptions.setProperty(key, val); 345 348 } 349 } 350 notifyEvent("clientoptions_onResult", "ok"); 351 } 352 353 /** 354 * A more efficient runClientOptions() 355 * 356 * @param opts non-null 357 * @since 0.9.1 358 */ 359 public void setClientOptions(Properties opts) { 360 _clientOptions.clear(); 361 for (Map.Entry e : opts.entrySet()) { 362 String key = (String) e.getKey(); 363 String val = (String) e.getValue(); 364 _clientOptions.setProperty(key, val); 346 365 } 347 366 notifyEvent("clientoptions_onResult", "ok"); -
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java
r6e52ae3 r07caf2e 331 331 String userAgent = null; 332 332 String authorization = null; 333 int remotePort = 0; 333 334 while((line = reader.readLine(method)) != null) { 334 335 line = line.trim(); … … 487 488 host = getHostName(destination); 488 489 489 if(requestURI.getPort() >= 0) { 490 // TODO support I2P ports someday 491 //if (port >= 0) 492 // host = host + ':' + port; 490 int rPort = requestURI.getPort(); 491 if (rPort > 0) { 492 // Save it to put in the I2PSocketOptions, 493 // but strip it from the URL 494 remotePort = rPort; 493 495 if(_log.shouldLog(Log.WARN)) { 494 496 _log.warn(getPrefix(requestId) + "Removing port from [" + request + "]"); … … 501 503 break; 502 504 } 505 } else { 506 remotePort = 80; 503 507 } 504 508 … … 965 969 // dont want to hard link to here 966 970 //opts.setProperty("i2p.streaming.inactivityTimeoutAction", ""+1); 967 I2PSocket i2ps = createI2PSocket(clientDest, getDefaultOptions(opts)); 971 I2PSocketOptions sktOpts = getDefaultOptions(opts); 972 if (remotePort > 0) 973 sktOpts.setPort(remotePort); 974 I2PSocket i2ps = createI2PSocket(clientDest, sktOpts); 968 975 byte[] data = newRequest.toString().getBytes("ISO-8859-1"); 969 976 Runnable onTimeout = new OnTimeout(s, s.getOutputStream(), targetRequest, usingWWWProxy, currentProxy, requestId); -
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java
r6e52ae3 r07caf2e 78 78 79 79 private void setupI2PTunnelHTTPServer(String spoofHost) { 80 _spoofHost = spoofHost;80 _spoofHost = (spoofHost != null && spoofHost.trim().length() > 0) ? spoofHost.trim() : null; 81 81 getTunnel().getContext().statManager().createRateStat("i2ptunnel.httpserver.blockingHandleTime", "how long the blocking handle takes to complete", "I2PTunnel.HTTPServer", new long[] { 60*1000, 10*60*1000, 3*60*60*1000 }); 82 82 getTunnel().getContext().statManager().createRateStat("i2ptunnel.httpNullWorkaround", "How often an http server works around a streaming lib or i2ptunnel bug", "I2PTunnel.HTTPServer", new long[] { 60*1000, 10*60*1000 }); … … 97 97 @Override 98 98 protected void blockingHandle(I2PSocket socket) { 99 if (_log.shouldLog(Log.INFO)) 100 _log.info("Incoming connection to '" + toString() + "' port " + socket.getLocalPort() + 101 " from: " + socket.getPeerDestination().calculateHash() + " port " + socket.getPort()); 99 102 long afterAccept = getTunnel().getContext().clock().now(); 100 103 long afterSocket = -1; … … 116 119 addEntry(headers, DEST64_HEADER, socket.getPeerDestination().toBase64()); 117 120 118 if ( (_spoofHost != null) && (_spoofHost.trim().length() > 0) ) 119 setEntry(headers, "Host", _spoofHost); 121 // Port-specific spoofhost 122 Properties opts = getTunnel().getClientOptions(); 123 String spoofHost; 124 int ourPort = socket.getLocalPort(); 125 if (ourPort != 80 && ourPort > 0 && ourPort < 65535 && opts != null) { 126 String portSpoof = opts.getProperty("spoofedHost." + ourPort); 127 if (portSpoof != null) 128 spoofHost = portSpoof.trim(); 129 else 130 spoofHost = _spoofHost; 131 } else { 132 spoofHost = _spoofHost; 133 } 134 if (spoofHost != null) 135 setEntry(headers, "Host", spoofHost); 120 136 setEntry(headers, "Connection", "close"); 121 137 // we keep the enc sent by the browser before clobbering it, since it may have … … 135 151 // server, reads the response headers, rewriting to include Content-encoding: x-i2p-gzip 136 152 // if it was one of the Accept-encoding: values, and gzip the payload 137 Properties opts = getTunnel().getClientOptions();138 153 boolean allowGZIP = true; 139 154 if (opts != null) { -
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java
r6e52ae3 r07caf2e 112 112 @Override 113 113 protected void blockingHandle(I2PSocket socket) { 114 if (_log.shouldLog(Log.INFO)) 115 _log.info("Incoming connection to '" + toString() + "' port " + socket.getLocalPort() + 116 " from: " + socket.getPeerDestination().calculateHash() + " port " + socket.getPort()); 114 117 try { 115 118 String modifiedRegistration; -
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java
r6e52ae3 r07caf2e 409 409 protected void blockingHandle(I2PSocket socket) { 410 410 if (_log.shouldLog(Log.INFO)) 411 _log.info("Incoming connection to '" + toString() + "' from: " + socket.getPeerDestination().calculateHash().toBase64()); 411 _log.info("Incoming connection to '" + toString() + "' port " + socket.getLocalPort() + 412 " from: " + socket.getPeerDestination().calculateHash() + " port " + socket.getPort()); 412 413 long afterAccept = I2PAppContext.getGlobalContext().clock().now(); 413 414 long afterSocket = -1; -
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java
r6e52ae3 r07caf2e 5 5 import java.io.IOException; 6 6 import java.util.ArrayList; 7 import java.util.HashMap; 7 8 import java.util.Iterator; 8 9 import java.util.List; 10 import java.util.Map; 9 11 import java.util.Properties; 10 12 import java.util.Random; … … 386 388 387 389 private void setSessionOptions() { 388 List opts = new ArrayList(); 389 for (Iterator iter = _config.keySet().iterator(); iter.hasNext(); ) { 390 String key = (String)iter.next(); 391 String val = _config.getProperty(key); 390 Properties opts = new Properties(); 391 for (Map.Entry e : _config.entrySet()) { 392 String key = (String) e.getKey(); 392 393 if (key.startsWith("option.")) { 393 394 key = key.substring("option.".length()); 394 opts.add(key + "=" + val); 395 } 396 } 397 String args[] = new String[opts.size()]; 398 for (int i = 0; i < opts.size(); i++) 399 args[i] = (String)opts.get(i); 400 _tunnel.runClientOptions(args, this); 395 String val = (String) e.getValue(); 396 opts.setProperty(key, val); 397 } 398 } 399 _tunnel.setClientOptions(opts); 401 400 } 402 401 -
apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketEepGet.java
r6e52ae3 r07caf2e 144 144 props.setProperty(PROP_CONNECT_DELAY, CONNECT_DELAY); 145 145 I2PSocketOptions opts = _socketManager.buildOptions(props); 146 // TODO pull port out of URL 147 opts.setPort(80); 146 148 _socket = _socketManager.connect(dest, opts); 147 149 } else {
Note: See TracChangeset
for help on using the changeset viewer.