Changeset ee63f3b


Ignore:
Timestamp:
Aug 16, 2012 7:02:38 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
e015216
Parents:
a900511
Message:

minor NTCP cleanup

Location:
router/java/src/net/i2p/router/transport/ntcp
Files:
3 edited

Legend:

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

    ra900511 ree63f3b  
    2222 */
    2323public class NTCPAddress {
    24     private int _port;
    25     private String _host;
     24    private final int _port;
     25    private final String _host;
    2626    //private InetAddress _addr;
    2727    /** Port number used in RouterAddress definitions */
     
    3434        if (host != null)
    3535            _host = host.trim();
     36        else
     37            _host = null;
    3638        _port = port;
    3739    }
    3840   
     41    /*
    3942    public NTCPAddress() {
    4043        _host = null;
     
    4346    }
    4447   
    45     /*
    4648    public NTCPAddress(InetAddress addr, int port) {
    4749        if (addr != null)
     
    5961        }
    6062        String host = addr.getOption(PROP_HOST);
     63        int iport = -1;
    6164        if (host == null) {
    6265            _host = null;
    63             _port = -1;
    6466        } else {
    6567            _host = host.trim();
     
    6769            if ( (port != null) && (port.trim().length() > 0) && !("null".equals(port)) ) {
    6870                try {
    69                     _port = Integer.parseInt(port.trim());
     71                    iport = Integer.parseInt(port.trim());
    7072                } catch (NumberFormatException nfe) {
    7173                    Log log = I2PAppContext.getGlobalContext().logManager().getLog(NTCPAddress.class);
    7274                    log.error("Invalid port [" + port + "]", nfe);
    73                     _port = -1;
    7475                }
    75             } else {
    76                 _port = -1;
    7776            }
    7877        }
     78        _port = iport;
    7979    }
    8080   
     
    9898   
    9999    public String getHost() { return _host; }
    100     public void setHost(String host) { _host = host; }
     100    //public void setHost(String host) { _host = host; }
    101101    //public InetAddress getAddress() { return _addr; }
    102102    //public void setAddress(InetAddress addr) { _addr = addr; }
    103103    public int getPort() { return _port; }
    104     public void setPort(int port) { _port = port; }
     104    //public void setPort(int port) { _port = port; }
    105105   
    106106    public boolean isPubliclyRoutable() {
     
    132132    @Override
    133133    public int hashCode() {
    134         int rv = 0;
    135         rv += _port;
     134        int rv = _port;
    136135        //if (_addr != null)
    137136        //    rv += _addr.getHostAddress().hashCode();
    138137        //else
    139             if (_host != null) rv += _host.trim().hashCode();
     138            if (_host != null) rv ^= _host.hashCode();
    140139        return rv;
    141140    }
  • router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java

    ra900511 ree63f3b  
    7777    private final NTCPTransport _transport;
    7878    private final boolean _isInbound;
    79     private boolean _closed;
     79    private volatile boolean _closed;
    8080    private NTCPAddress _remAddr;
    8181    private RouterIdentity _remotePeer;
  • router/java/src/net/i2p/router/transport/ntcp/Reader.java

    ra900511 ree63f3b  
    7979   
    8080    private class Runner implements Runnable {
    81         private boolean _stop;
     81        private volatile boolean _stop;
    8282
    8383        public Runner() {}
Note: See TracChangeset for help on using the changeset viewer.