Changeset 212981d


Ignore:
Timestamp:
Dec 15, 2011 11:36:32 PM (9 years ago)
Author:
dream <dream@…>
Branches:
master
Children:
5b05d86
Parents:
51e40030
Message:

Add hooks so the new PortMapper? lets i2p plugins not fail when the router console is not on port 7657. Also raise an exception when requesting unregistered ports so as to encourage swift adding of the registration hooks when those ports are taken.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/RouterConsoleRunner.java

    r51e40030 r212981d  
    1919import net.i2p.util.FileUtil;
    2020import net.i2p.util.I2PAppThread;
     21import net.i2p.util.PortMapper;
    2122import net.i2p.util.SecureDirectory;
    2223import net.i2p.util.SecureFileOutputStream;
     
    208209            // add standard listeners
    209210            if (_listenPort != null) {
     211                Integer lport = Integer.parseInt(_listenPort);
    210212                StringTokenizer tok = new StringTokenizer(_listenHost, " ,");
    211213                while (tok.hasMoreTokens()) {
     
    216218                        //else
    217219                        //    _server.addListener(host + ':' + _listenPort);
    218                         Integer lport = Integer.parseInt(_listenPort);
    219220                        InetAddrPort iap = new InetAddrPort(host, lport);
    220221                        SocketListener lsnr = new SocketListener(iap);
     
    231232                    }
    232233                }
     234                // XXX: what if listenhosts do not include 127.0.0.1? (Should that ever even happen?)
     235                I2PAppContext.getGlobalContext().portMapper().register(PortMapper.SVC_CONSOLE,lport);
    233236            }
    234237
     
    268271                        }
    269272                    }
     273                    I2PAppContext.getGlobalContext().portMapper().register(PortMapper.SVC_HTTPS_CONSOLE,sslPort);
    270274                } else {
    271275                    System.err.println("Unable to create or access keystore for SSL: " + keyStore.getAbsolutePath());
  • apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java

    r51e40030 r212981d  
    1313import net.i2p.util.Log;
    1414import net.i2p.util.SecureDirectory;
     15import net.i2p.util.PortMapper;
    1516
    1617import org.mortbay.http.HttpContext;
     
    142143            HttpListener[] hl = s.getListeners();
    143144            for (int j = 0; j < hl.length; j++) {
    144                 if (hl[j].getPort() == 7657)
     145                if (hl[j].getPort() == I2PAppContext.getGlobalContext().portMapper().getPort(PortMapper.SVC_CONSOLE))
    145146                    return s;
    146147            }
  • core/java/src/net/i2p/util/PortMapper.java

    r51e40030 r212981d  
    5959     */
    6060    public int getPort(String service) {
    61         return getPort(service, -1);
     61        int port = getPort(service, -1);
     62        if(-1==port)
     63            throw new RuntimeException("No port registered for service "+service);
     64        return port;
    6265    }
    6366
Note: See TracChangeset for help on using the changeset viewer.