Changeset 1838ad4


Ignore:
Timestamp:
May 30, 2009 3:47:20 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2413bcd
Parents:
22609bb
Message:
  • UPnP:
    • Retry port forward if it fails
    • Make peers.jsp display faster
    • Lengthen POST timeout
    • More comments
Location:
router/java/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/UPnP.java

    r22609bb r1838ad4  
    264264        }
    265265       
    266         /** event callback */
     266        /** event callback - unused for now - how many devices support events? */
    267267        public void eventNotifyReceived(String uuid, long seq, String varName, String value) {
    268                 _log.error("Event: " + uuid + ' ' + seq + ' ' + varName + '=' + value);
     268                if (_log.shouldLog(Log.WARN))
     269                        _log.error("Event: " + uuid + ' ' + seq + ' ' + varName + '=' + value);
    269270        }
    270271
     
    305306         * @return the reported upstream bit rate in bits per second. -1 if it's not available. Blocking.
    306307         */
    307         public int getUpstramMaxBitRate() {
     308        public int getUpstreamMaxBitRate() {
    308309                if(!isNATPresent() || thinksWeAreDoubleNatted)
    309310                        return -1;
     
    362363***/
    363364       
    364         private String toString(String action, String Argument, Service serv) {
    365                 Action getIP = serv.getAction(action);
    366                 if(getIP == null || !getIP.postControlAction())
    367                         return null;
    368                
    369                 Argument ret = getIP.getOutputArgumentList().getArgument(Argument);
    370                 return ret.getValue();
     365        /**
     366         * A blocking toString(). That's interesting.
     367         * Cache the last ArgumentList to speed it up some.
     368         * Count on listSubServices() to call multiple combinations of arguments
     369         * so we don't get old data.
     370         */
     371        private String _lastAction;
     372        private Service _lastService;
     373        private ArgumentList _lastArgumentList;
     374        private Object toStringLock = new Object();
     375        private String toString(String action, String arg, Service serv) {
     376                synchronized(toStringLock) {
     377                        if ((!action.equals(_lastAction)) ||
     378                            (!serv.equals(_lastService)) ||
     379                            _lastArgumentList == null) {
     380                                Action getIP = serv.getAction(action);
     381                                if(getIP == null || !getIP.postControlAction()) {
     382                                        _lastAction = null;
     383                                        return null;
     384                                }
     385                                _lastAction = action;
     386                                _lastService = serv;
     387                                _lastArgumentList = getIP.getOutputArgumentList();
     388                        }
     389                        return _lastArgumentList.getArgument(arg).getValue();
     390                }
    371391        }
    372392       
     
    434454        }
    435455       
     456        /** warning - slow */
    436457        public String renderStatusHTML() {
    437458                final StringBuilder sb = new StringBuilder();
     
    455476                    sb.append("<br>The current external IP address is not available.");
    456477                int downstreamMaxBitRate = getDownstreamMaxBitRate();
    457                 int upstreamMaxBitRate = getUpstramMaxBitRate();
     478                int upstreamMaxBitRate = getUpstreamMaxBitRate();
    458479                if(downstreamMaxBitRate > 0)
    459                         sb.append("<br>UPnP reports the max downstream bit rate is : " + getDownstreamMaxBitRate()+ " bits/sec\n");
     480                        sb.append("<br>UPnP reports the max downstream bit rate is : " + downstreamMaxBitRate+ " bits/sec\n");
    460481                if(upstreamMaxBitRate > 0)
    461                         sb.append("<br>UPnP reports the max upstream bit rate is : " + getUpstramMaxBitRate()+ " bits/sec\n");
     482                        sb.append("<br>UPnP reports the max upstream bit rate is : " + upstreamMaxBitRate+ " bits/sec\n");
    462483                synchronized(lock) {
    463484                        if(portsToForward != null) {
     
    476497        }
    477498       
     499        /** blocking */
    478500        private boolean addMapping(String protocol, int port, String description, ForwardPort fp) {
    479501                if(isDisabled || !isNATPresent() || _router == null) {
     
    510532        }
    511533       
     534        /** blocking */
    512535        private boolean removeMapping(String protocol, int port, ForwardPort fp, boolean noLog) {
    513536                if(isDisabled || !isNATPresent())
     
    534557        }
    535558
     559        /** non-blocking */
    536560        public void onChangePublicPorts(Set<ForwardPort> ports, ForwardPortCallback cb) {
    537561                Set<ForwardPort> portsToDumpNow = null;
     
    556580                                // Ports in portsToForwardNow but not in ports we must dump
    557581                                for(ForwardPort port: ports) {
    558                                         if(portsToForward.contains(port)) {
     582                                        //if(portsToForward.contains(port)) {
     583                                        // If not in portsForwarded, it wasn't successful, try again
     584                                        if(portsForwarded.contains(port)) {
    559585                                                // We have forwarded it, and it should be forwarded, cool.
    560586                                        } else {
  • router/java/src/net/i2p/router/transport/UPnPManager.java

    r22609bb r1838ad4  
    7777    }
    7878   
    79     /** call when the ports might have changed */
     79    /**
     80     * Call when the ports might have changed
     81     * The transports can call this pretty quickly at startup,
     82     * which can have multiple UPnP threads running at once, but
     83     * that should be ok.
     84     */
    8085    public void update(Map<String, Integer> ports) {
    8186        if (_log.shouldLog(Log.DEBUG))
     
    98103            forwards.add(fp);
    99104        }
     105        // non-blocking
    100106        _upnp.onChangePublicPorts(forwards, _upnpCallback);
    101107    }
  • router/java/src/org/cybergarage/http/HTTPRequest.java

    r22609bb r1838ad4  
    387387                                // and who knows what else.
    388388                                // Set the timeout to be nice and short, the device should be local and fast.
    389                                 // If he can't get back to us in 2 seconds, forget it.
     389                                // Yeah, the UPnP standard is a minute or something, too bad.
     390                                // If he can't get back to us in a few seconds, forget it.
    390391                                // And set the soTimeout to 1 second (for reads).
    391392                                //postSocket = new Socket(host, port);
     
    393394                                postSocket.setSoTimeout(1000);
    394395                                SocketAddress sa = new InetSocketAddress(host, port);
    395                                 postSocket.connect(sa, 2000);
     396                                postSocket.connect(sa, 3000);
    396397                        }
    397398
Note: See TracChangeset for help on using the changeset viewer.