Changeset 8fa7205


Ignore:
Timestamp:
Dec 23, 2011 9:41:58 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
bb7a88f
Parents:
36cb07b0
Message:

RouterInfo?, RouterAddress?: Optimizations and integrity checks

  • Remove synchronization
  • Do not allow contents to change after being set, throw IllegalStateException?
  • Do not copy contents out in getters
  • Make options final
  • Add getOption() and getOptionsMap() methods
Files:
13 edited

Legend:

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

    r36cb07b0 r8fa7205  
    377377            if (!((style.equals("SSU") && cost == 5) || (style.equals("NTCP") && cost == 10)))
    378378                buf.append('[').append(_("cost")).append('=').append("" + cost).append("] ");
    379             Properties p = new OrderedProperties();
    380             p.putAll(addr.getOptions());
    381             for (Map.Entry e : p.entrySet()) {
     379            Map p = addr.getOptionsMap();
     380            for (Map.Entry e : (Set<Map.Entry>) p.entrySet()) {
    382381                String name = (String) e.getKey();
    383382                String val = (String) e.getValue();
     
    388387        if (full) {
    389388            buf.append("<tr><td>" + _("Stats") + ": <br><code>");
    390             for (Iterator iter = info.getOptions().keySet().iterator(); iter.hasNext(); ) {
    391                 String key = (String)iter.next();
    392                 String val = info.getOption(key);
     389            Map p = info.getOptionsMap();
     390            for (Map.Entry e : (Set<Map.Entry>) p.entrySet()) {
     391                String key = (String) e.getKey();
     392                String val = (String) e.getValue();
    393393                buf.append(DataHelper.stripHTML(key)).append(" = ").append(DataHelper.stripHTML(val)).append("<br>\n");
    394394            }
     
    413413                rv |= NTCP;
    414414            } else if (style.equals("SSU")) {
    415                 if (addr.getOptions().getProperty("iport0") != null)
     415                if (addr.getOption("iport0") != null)
    416416                    rv |= SSUI;
    417417                else
  • core/java/src/net/i2p/data/DataHelper.java

    r36cb07b0 r8fa7205  
    119119        throws DataFormatException, IOException {
    120120        Properties props = new OrderedProperties();
     121        readProperties(rawStream, props);
     122        return props;
     123    }
     124
     125    /**
     126     *  Ditto, load into an existing properties
     127     *  @param props the Properties to load into
     128     *  @since 0.8.13
     129     */
     130    public static Properties readProperties(InputStream rawStream, Properties props)
     131        throws DataFormatException, IOException {
    121132        long size = readLong(rawStream, 2);
    122133        byte data[] = new byte[(int) size];
     
    12691280     *  How to spec as returning the same type as the param?
    12701281     *  DEPRECATED - Only used by RouterInfo.
     1282     *
     1283     *  @return a new list
    12711284     */
    12721285    public static List<? extends DataStructure> sortStructures(Collection<? extends DataStructure> dataStructures) {
  • core/java/src/net/i2p/data/DatabaseEntry.java

    r36cb07b0 r8fa7205  
    125125     * Configure the proof that the entity stands behind the info here
    126126     *
     127     * @throws IllegalStateException if already signed
    127128     */
    128129    public void setSignature(Signature signature) {
     130        if (_signature != null)
     131            throw new IllegalStateException();
    129132        _signature = signature;
    130133    }
     
    133136     * Sign the structure using the supplied signing key
    134137     *
     138     * @throws IllegalStateException if already signed
    135139     */
    136140    public void sign(SigningPrivateKey key) throws DataFormatException {
     141        if (_signature != null)
     142            throw new IllegalStateException();
    137143        byte[] bytes = getBytes();
    138144        if (bytes == null) throw new DataFormatException("Not enough data to sign");
  • core/java/src/net/i2p/data/RouterAddress.java

    r36cb07b0 r8fa7205  
    1313import java.io.InputStream;
    1414import java.io.OutputStream;
     15import java.util.Collections;
    1516import java.util.Date;
    1617import java.util.Iterator;
     
    2223/**
    2324 * Defines a method of communicating with a router
     25 *
     26 * For efficiency, the options methods and structures here are unsynchronized.
     27 * Initialize the structure with readBytes(), or call the setOptions().
     28 * Don't change it after that.
     29 *
     30 * To ensure integrity of the RouterInfo, methods that change an element of the
     31 * RouterInfo will throw an IllegalStateException after the RouterInfo is signed.
    2432 *
    2533 * @author jrandom
     
    2937    private Date _expiration;
    3038    private String _transportStyle;
    31     private Properties _options;
     39    private final Properties _options;
    3240
    3341    public RouterAddress() {
    3442        _cost = -1;
     43        _options = new OrderedProperties();
    3544    }
    3645
     
    8695     * Configure the type of transport that must be used to communicate on this address
    8796     *
     97     * @throws IllegalStateException if was already set
    8898     */
    8999    public void setTransportStyle(String transportStyle) {
     100        if (_transportStyle != null)
     101            throw new IllegalStateException();
    90102        _transportStyle = transportStyle;
    91103    }
     
    94106     * Retrieve the transport specific options necessary for communication
    95107     *
     108     * @deprecated use getOptionsMap()
     109     * @return sorted, non-null, NOT a copy, do not modify
    96110     */
    97111    public Properties getOptions() {
     
    100114
    101115    /**
    102      * Specify the transport specific options necessary for communication
    103      *
     116     * Retrieve the transport specific options necessary for communication
     117     *
     118     * @return an unmodifiable view, non-null, sorted
     119     * @since 0.8.13
     120     */
     121    public Map getOptionsMap() {
     122        return Collections.unmodifiableMap(_options);
     123    }
     124
     125    /**
     126     * @since 0.8.13
     127     */
     128    public String getOption(String opt) {
     129        return _options.getProperty(opt);
     130    }
     131
     132    /**
     133     * Specify the transport specific options necessary for communication.
     134     * Makes a copy.
     135     * @param options non-null
     136     * @throws IllegalStateException if was already set
    104137     */
    105138    public void setOptions(Properties options) {
    106         _options = options;
    107     }
    108    
     139        if (!_options.isEmpty())
     140            throw new IllegalStateException();
     141        _options.putAll(options);
     142    }
     143   
     144    /**
     145     *  @throws IllegalStateException if was already read in
     146     */
    109147    public void readBytes(InputStream in) throws DataFormatException, IOException {
     148        if (_transportStyle != null)
     149            throw new IllegalStateException();
    110150        _cost = (int) DataHelper.readLong(in, 1);
    111151        _expiration = DataHelper.readDate(in);
     
    116156        else if (_transportStyle.equals("NTCP"))
    117157            _transportStyle = "NTCP";
    118         _options = DataHelper.readProperties(in);
     158        DataHelper.readProperties(in, _options);
    119159    }
    120160   
    121161    public void writeBytes(OutputStream out) throws DataFormatException, IOException {
    122         if ((_cost < 0) || (_transportStyle == null) || (_options == null))
     162        if ((_cost < 0) || (_transportStyle == null))
    123163            throw new DataFormatException("Not enough data to write a router address");
    124164        DataHelper.writeLong(out, 1, _cost);
     
    132172        if ((object == null) || !(object instanceof RouterAddress)) return false;
    133173        RouterAddress addr = (RouterAddress) object;
     174        // let's keep this fast as we are putting an address into the RouterInfo set frequently
    134175        return
    135176               _cost == addr._cost &&
    136                DataHelper.eq(_transportStyle, addr._transportStyle) &&
    137                DataHelper.eq(_options, addr._options) &&
    138                DataHelper.eq(_expiration, addr._expiration);
     177               DataHelper.eq(_transportStyle, addr._transportStyle);
     178               //DataHelper.eq(_options, addr._options) &&
     179               //DataHelper.eq(_expiration, addr._expiration);
    139180    }
    140181   
     
    162203        if (_options != null) {
    163204            buf.append("\n\tOptions: #: ").append(_options.size());
    164             Properties p = new OrderedProperties();
    165             p.putAll(_options);
    166             for (Map.Entry e : p.entrySet()) {
     205            for (Map.Entry e : _options.entrySet()) {
    167206                String key = (String) e.getKey();
    168207                String val = (String) e.getValue();
  • core/java/src/net/i2p/data/RouterInfo.java

    r36cb07b0 r8fa7205  
    2020import java.util.Iterator;
    2121import java.util.List;
     22import java.util.Map;
    2223import java.util.Properties;
    2324import java.util.Set;
     
    3233 * Defines the data that a router either publishes to the global routing table or
    3334 * provides to trusted peers. 
     35 *
     36 * For efficiency, the methods and structures here are now unsynchronized.
     37 * Initialize the RI with readBytes(), or call the setters and then sign() in a single thread.
     38 * Don't change it after that.
     39 *
     40 * To ensure integrity of the RouterInfo, methods that change an element of the
     41 * RouterInfo will throw an IllegalStateException after the RouterInfo is signed.
    3442 *
    3543 * @author jrandom
     
    4250    /** may be null to save memory, no longer final */
    4351    private Set<Hash> _peers;
    44     private /* FIXME final FIXME */ Properties _options;
     52    private final Properties _options;
    4553    private volatile boolean _validated;
    4654    private volatile boolean _isValid;
     
    6876    }
    6977
     78    /**
     79     *  Used only by Router and PublishLocalRouterInfoJob.
     80     *  Copies ONLY the identity and peers.
     81     *  Does not copy published, addresses, options, or signature.
     82     */
    7083    public RouterInfo(RouterInfo old) {
    7184        this();
    7285        setIdentity(old.getIdentity());
    73         setPublished(old.getPublished());
    74         setAddresses(old.getAddresses());
     86        //setPublished(old.getPublished());
     87        //setAddresses(old.getAddresses());
    7588        setPeers(old.getPeers());
    76         setOptions(old.getOptions());
    77         setSignature(old.getSignature());
     89        //setOptions(old.getOptions());
     90        //setSignature(old.getSignature());
    7891        // copy over _byteified?
    7992    }
     
    91104    }
    92105
    93     private void resetCache() {
    94         _stringified = null;
    95         _byteified = null;
    96         _hashCodeInitialized = false;
    97     }
    98 
    99106    /**
    100107     * Retrieve the identity of the router represented
     
    108115     * Configure the identity of the router represented
    109116     *
     117     * @throws IllegalStateException if RouterInfo is already signed
    110118     */
    111119    public void setIdentity(RouterIdentity ident) {
     120        if (_signature != null)
     121            throw new IllegalStateException();
    112122        _identity = ident;
    113         resetCache();
    114123        // We only want to cache the bytes for our own RI, which is frequently written.
    115124        // To cache for all RIs doubles the RI memory usage.
     
    134143     * Date on which it was published, in milliseconds since Midnight GMT on Jan 01, 1970
    135144     *
     145     * @throws IllegalStateException if RouterInfo is already signed
    136146     */
    137147    public void setPublished(long published) {
     148        if (_signature != null)
     149            throw new IllegalStateException();
    138150        _published = published;
    139         resetCache();
    140151    }
    141152
     
    144155     * router can be contacted.
    145156     *
     157     * @return unmodifiable view, non-null
    146158     */
    147159    public Set<RouterAddress> getAddresses() {
    148         synchronized (_addresses) {
    149             return new HashSet(_addresses);
    150         }
     160            return Collections.unmodifiableSet(_addresses);
    151161    }
    152162
     
    155165     * can be contacted.
    156166     *
     167     * @throws IllegalStateException if RouterInfo is already signed
    157168     */
    158169    public void setAddresses(Set<RouterAddress> addresses) {
    159         synchronized (_addresses) {
    160             _addresses.clear();
    161             if (addresses != null) _addresses.addAll(addresses);
    162         }
    163         resetCache();
     170        if (_signature != null)
     171            throw new IllegalStateException();
     172        _addresses.clear();
     173        if (addresses != null) _addresses.addAll(addresses);
    164174    }
    165175
     
    181191     *
    182192     * @deprecated Implemented here but unused elsewhere
     193     * @throws IllegalStateException if RouterInfo is already signed
    183194     */
    184195    public void setPeers(Set<Hash> peers) {
     196        if (_signature != null)
     197            throw new IllegalStateException();
    185198        if (peers == null || peers.isEmpty()) {
    186199            _peers = null;
     
    193206            _peers.addAll(peers);
    194207        }
    195         resetCache();
    196     }
    197 
    198     /**
    199      * Retrieve a set of options or statistics that the router can expose
    200      *
     208    }
     209
     210    /**
     211     * Retrieve a set of options or statistics that the router can expose.
     212     *
     213     * @deprecated use getOptionsMap()
     214     * @return sorted, non-null, NOT a copy, do not modify!!!
    201215     */
    202216    public Properties getOptions() {
    203         if (_options == null) return new Properties();
    204         synchronized (_options) {
    205             return (Properties) _options.clone();
    206         }
    207     }
     217        return _options;
     218    }
     219
     220    /**
     221     * Retrieve a set of options or statistics that the router can expose.
     222     *
     223     * @return an unmodifiable view, non-null, sorted
     224     * @since 0.8.13
     225     */
     226    public Map getOptionsMap() {
     227        return Collections.unmodifiableMap(_options);
     228    }
     229
    208230    public String getOption(String opt) {
    209         if (_options == null) return null;
    210         synchronized (_options) {
    211             return _options.getProperty(opt);
    212         }
    213     }
    214 
    215     /**
    216      * Configure a set of options or statistics that the router can expose
     231        return _options.getProperty(opt);
     232    }
     233
     234    /**
     235     * Configure a set of options or statistics that the router can expose.
     236     * Makes a copy.
     237     *
    217238     * @param options if null, clears current options
     239     * @throws IllegalStateException if RouterInfo is already signed
    218240     */
    219241    public void setOptions(Properties options) {
    220         synchronized (_options) {
    221             _options.clear();
    222             if (options != null)
    223                 _options.putAll(options);
    224         }
    225         resetCache();
     242        if (_signature != null)
     243            throw new IllegalStateException();
     244
     245        _options.clear();
     246        if (options != null)
     247            _options.putAll(options);
    226248    }
    227249
     
    235257        if (_byteified != null) return _byteified;
    236258        if (_identity == null) throw new DataFormatException("Router identity isn't set? wtf!");
    237         if (_addresses == null) throw new DataFormatException("Router addressess isn't set? wtf!");
    238         if (_options == null) throw new DataFormatException("Router options isn't set? wtf!");
    239259
    240260        //long before = Clock.getInstance().now();
    241         ByteArrayOutputStream out = new ByteArrayOutputStream(6*1024);
     261        ByteArrayOutputStream out = new ByteArrayOutputStream(2*1024);
    242262        try {
    243263            _identity.writeBytes(out);
    244             DataHelper.writeDate(out, new Date(_published));
     264            // avoid thrashing objects
     265            //DataHelper.writeDate(out, new Date(_published));
     266            DataHelper.writeLong(out, 8, _published);
    245267            int sz = _addresses.size();
    246268            if (sz <= 0 || isHidden()) {
     
    250272                DataHelper.writeLong(out, 1, sz);
    251273                Collection<RouterAddress> addresses = _addresses;
    252                 if (sz > 1)
     274                if (sz > 1) {
    253275                    // WARNING this sort algorithm cannot be changed, as it must be consistent
    254276                    // network-wide. The signature is not checked at readin time, but only
    255277                    // later, and the addresses are stored in a Set, not a List.
    256278                    addresses = (Collection<RouterAddress>) DataHelper.sortStructures(addresses);
     279                }
    257280                for (RouterAddress addr : addresses) {
    258281                    addr.writeBytes(out);
     
    294317     *
    295318     */
    296     public synchronized boolean isValid() {
     319    public boolean isValid() {
    297320        if (!_validated) doValidate();
    298321        return _isValid;
     
    305328     */
    306329    public int getNetworkId() {
    307         if (_options == null) return -1;
    308         String id = null;
    309         synchronized (_options) {
    310             id = _options.getProperty(PROP_NETWORK_ID);
    311         }
     330        String id = _options.getProperty(PROP_NETWORK_ID);
    312331        if (id != null) {
    313332            try {
     
    323342     */
    324343    public String getCapabilities() {
    325         if (_options == null) return "";
    326         String capabilities = null;
    327         synchronized (_options) {
    328             capabilities = _options.getProperty(PROP_CAPABILITIES);
    329         }
     344        String capabilities = _options.getProperty(PROP_CAPABILITIES);
    330345        if (capabilities != null)
    331346            return capabilities;
     
    359374    }
    360375
     376    /**
     377     * @throws IllegalStateException if RouterInfo is already signed
     378     */
    361379    public void addCapability(char cap) {
    362         if (_options == null) _options = new OrderedProperties();
    363         synchronized (_options) {
     380        if (_signature != null)
     381            throw new IllegalStateException();
     382
    364383            String caps = _options.getProperty(PROP_CAPABILITIES);
    365384            if (caps == null)
     
    367386            else if (caps.indexOf(cap) == -1)
    368387                _options.setProperty(PROP_CAPABILITIES, caps + cap);
    369         }
    370     }
    371 
     388    }
     389
     390    /**
     391     * @throws IllegalStateException if RouterInfo is already signed
     392     */
    372393    public void delCapability(char cap) {
    373         if (_options == null) return;
    374         synchronized (_options) {
     394        if (_signature != null)
     395            throw new IllegalStateException();
     396
    375397            String caps = _options.getProperty(PROP_CAPABILITIES);
    376398            int idx;
     
    385407                _options.setProperty(PROP_CAPABILITIES, buf.toString());
    386408            }
    387         }
    388409    }
    389410
     
    410431     */
    411432    public RouterAddress getTargetAddress(String transportStyle) {
    412         synchronized (_addresses) {
    413             for (Iterator iter = _addresses.iterator(); iter.hasNext(); ) {
    414                 RouterAddress addr = (RouterAddress)iter.next();
    415                 if (addr.getTransportStyle().equals(transportStyle))
    416                     return addr;
    417             }
     433        for (RouterAddress addr :  _addresses) {
     434            if (addr.getTransportStyle().equals(transportStyle))
     435                return addr;
    418436        }
    419437        return null;
     
    426444    public List<RouterAddress> getTargetAddresses(String transportStyle) {
    427445        List<RouterAddress> ret = new Vector<RouterAddress>();
    428         synchronized(this._addresses) {
    429             for(Object o : this._addresses) {
    430                 RouterAddress addr = (RouterAddress)o;
    431                 if(addr.getTransportStyle().equals(transportStyle))
    432                     ret.add(addr);
    433             }
     446        for (RouterAddress addr :  _addresses) {
     447            if(addr.getTransportStyle().equals(transportStyle))
     448                ret.add(addr);
    434449        }
    435450        return ret;
     
    439454     * Actually validate the signature
    440455     */
    441     private synchronized void doValidate() {
     456    private void doValidate() {
     457        _isValid = super.verifySignature();
    442458        _validated = true;
    443         _isValid = super.verifySignature();
    444459
    445460        if (!_isValid) {
     
    460475    /**
    461476     *  This does NOT validate the signature
    462      */
    463     public synchronized void readBytes(InputStream in) throws DataFormatException, IOException {
     477     *
     478     *  @throws IllegalStateException if RouterInfo was already read in
     479     */
     480    public void readBytes(InputStream in) throws DataFormatException, IOException {
     481        if (_signature != null)
     482            throw new IllegalStateException();
    464483        _identity = new RouterIdentity();
    465484        _identity.readBytes(in);
    466         Date when = DataHelper.readDate(in);
    467         if (when == null)
    468             _published = 0;
    469         else
    470             _published = when.getTime();
     485        // avoid thrashing objects
     486        //Date when = DataHelper.readDate(in);
     487        //if (when == null)
     488        //    _published = 0;
     489        //else
     490        //    _published = when.getTime();
     491        _published = DataHelper.readLong(in, 8);
    471492        int numAddresses = (int) DataHelper.readLong(in, 1);
    472493        for (int i = 0; i < numAddresses; i++) {
     
    486507            }
    487508        }
    488         _options = DataHelper.readProperties(in);
     509        DataHelper.readProperties(in, _options);
    489510        _signature = new Signature();
    490511        _signature.readBytes(in);
    491512
    492         resetCache();
    493513
    494514        //_log.debug("Read routerInfo: " + toString());
     
    498518     *  This does NOT validate the signature
    499519     */
    500     public synchronized void writeBytes(OutputStream out) throws DataFormatException, IOException {
     520    public void writeBytes(OutputStream out) throws DataFormatException, IOException {
    501521        if (_identity == null) throw new DataFormatException("Missing identity");
    502522        if (_published < 0) throw new DataFormatException("Invalid published date: " + _published);
     
    504524        //if (!isValid())
    505525        //    throw new DataFormatException("Data is not valid");
    506         ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
     526        ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
    507527        baos.write(getBytes());
    508528        _signature.writeBytes(baos);
     
    519539        return DataHelper.eq(_identity, info.getIdentity())
    520540               && DataHelper.eq(_signature, info.getSignature())
    521                && _published == info.getPublished()
    522                && DataHelper.eq(_addresses, info.getAddresses())
    523                && DataHelper.eq(_options, info.getOptions())
    524                && DataHelper.eq(getPeers(), info.getPeers());
     541               && _published == info.getPublished();
     542               // Let's speed up the NetDB
     543               //&& DataHelper.eq(_addresses, info.getAddresses())
     544               //&& DataHelper.eq(_options, info.getOptions())
     545               //&& DataHelper.eq(getPeers(), info.getPeers());
    525546    }
    526547   
     
    542563        buf.append("\n\tSignature: ").append(_signature);
    543564        buf.append("\n\tPublished on: ").append(new Date(_published));
    544         Set addresses = _addresses; // getAddresses()
    545         buf.append("\n\tAddresses: #: ").append(addresses.size());
    546         for (Iterator iter = addresses.iterator(); iter.hasNext();) {
    547             RouterAddress addr = (RouterAddress) iter.next();
     565        buf.append("\n\tAddresses: #: ").append(_addresses.size());
     566        for (RouterAddress addr : _addresses) {
    548567            buf.append("\n\t\tAddress: ").append(addr);
    549568        }
    550         Set peers = getPeers();
     569        Set<Hash> peers = getPeers();
    551570        buf.append("\n\tPeers: #: ").append(peers.size());
    552         for (Iterator iter = peers.iterator(); iter.hasNext();) {
    553             Hash hash = (Hash) iter.next();
     571        for (Hash hash : peers) {
    554572            buf.append("\n\t\tPeer hash: ").append(hash);
    555573        }
    556         Properties options = _options; // getOptions();
    557         buf.append("\n\tOptions: #: ").append(options.size());
    558         for (Iterator iter = options.keySet().iterator(); iter.hasNext();) {
    559             String key = (String) iter.next();
    560             String val = options.getProperty(key);
     574        buf.append("\n\tOptions: #: ").append(_options.size());
     575        for (Map.Entry e : _options.entrySet()) {
     576            String key = (String) e.getKey();
     577            String val = (String) e.getValue();
    561578            buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");
    562579        }
  • router/java/src/net/i2p/router/Blocklist.java

    r36cb07b0 r8fa7205  
    489489            RouterAddress pa = (RouterAddress) pladdr.get(j);
    490490            if (pa == null) continue;
    491             Properties pprops = pa.getOptions();
    492             if (pprops == null) continue;
    493             String phost = pprops.getProperty("host");
     491            String phost = pa.getOption("host");
    494492            if (phost == null) continue;
    495493            if (oldphost != null && oldphost.equals(phost)) continue;
  • router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java

    r36cb07b0 r8fa7205  
    4242        if (_log.shouldLog(Log.DEBUG))
    4343            _log.debug("Old routerInfo contains " + ri.getAddresses().size()
    44                        + " addresses and " + ri.getOptions().size() + " options");
     44                       + " addresses and " + ri.getOptionsMap().size() + " options");
    4545        Properties stats = getContext().statPublisher().publishStatistics();
    4646        stats.setProperty(RouterInfo.PROP_NETWORK_ID, ""+Router.NETWORK_ID);
     
    6161            if (_log.shouldLog(Log.INFO))
    6262                _log.info("Newly updated routerInfo is published with " + stats.size()
    63                           + "/" + ri.getOptions().size() + " options on "
     63                          + "/" + ri.getOptionsMap().size() + " options on "
    6464                          + new Date(ri.getPublished()));
    6565            try {
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java

    r36cb07b0 r8fa7205  
    134134                happy = false;
    135135            else {
    136                 Properties props = ra.getOptions();
    137                 if (props == null || props.getProperty("ihost0") != null)
     136                if (ra.getOption("ihost0") != null)
    138137                   happy = false;
    139138            }
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r36cb07b0 r8fa7205  
    787787            if (ra != null) {
    788788                // Introducers change often, introducee will ping introducer for 2 hours
    789                 Properties props = ra.getOptions();
    790                 if (props != null && props.getProperty("ihost0") != null)
     789                if (ra.getOption("ihost0") != null)
    791790                    return "Peer " + key.toBase64() + " published > 75m ago with SSU Introducers";
    792791                if (routerInfo.getTargetAddress("NTCP") == null)
     
    825824        if (_log.shouldLog(Log.DEBUG))
    826825            _log.debug("RouterInfo " + key.toBase64() + " is stored with "
    827                        + routerInfo.getOptions().size() + " options on "
     826                       + routerInfo.getOptionsMap().size() + " options on "
    828827                       + new Date(routerInfo.getPublished()));
    829828   
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    r36cb07b0 r8fa7205  
    702702                        }
    703703                        // This is the quick way of doing UDPAddress.getIntroducerCount() > 0
    704                         Properties props = ra.getOptions();
    705                         if (props != null && props.getProperty("ihost0") != null)
     704                        if (ra.getOption("ihost0") != null)
    706705                            l.add(peer);
    707706                    }
     
    12641263            return rv;
    12651264        for (RouterAddress pa : paddr) {
    1266             Properties pprops = pa.getOptions();
    1267             if (pprops == null) continue;
    1268             String phost = pprops.getProperty("host");
     1265            String phost = pa.getOption("host");
    12691266            if (phost == null) continue;
    12701267            InetAddress pi;
  • router/java/src/net/i2p/router/transport/TransportManager.java

    r36cb07b0 r8fa7205  
    344344            int port = t.getRequestedPort();
    345345            if (t.getCurrentAddress() != null) {
    346                 Properties opts = t.getCurrentAddress().getOptions();
    347                 if (opts != null) {
    348                     String s = opts.getProperty("port");
     346                    String s = t.getCurrentAddress().getOption("port");
    349347                    if (s != null) {
    350348                        try {
     
    352350                        } catch (NumberFormatException nfe) {}
    353351                    }
    354                 }
    355352            }
    356353            // Use UDP port for NTCP too - see comment in NTCPTransport.getRequestedPort() for why this is here
  • router/java/src/net/i2p/router/transport/ntcp/NTCPAddress.java

    r36cb07b0 r8fa7205  
    5858            return;
    5959        }
    60         String host = addr.getOptions().getProperty(PROP_HOST);
     60        String host = addr.getOption(PROP_HOST);
    6161        if (host == null) {
    6262            _host = null;
     
    6464        } else {
    6565            _host = host.trim();
    66             String port = addr.getOptions().getProperty(PROP_PORT);
     66            String port = addr.getOption(PROP_PORT);
    6767            if ( (port != null) && (port.trim().length() > 0) && !("null".equals(port)) ) {
    6868                try {
     
    157157    public boolean equals(RouterAddress addr) {
    158158        if (addr == null) return false;
    159         Properties opts = addr.getOptions();
    160         if (opts == null) return false;
    161         return ( (_host.equals(opts.getProperty(PROP_HOST))) &&
    162                  (Integer.toString(_port).equals(opts.getProperty(PROP_PORT))) );
     159        return ( (_host.equals(addr.getOption(PROP_HOST))) &&
     160                 (Integer.toString(_port).equals(addr.getOption(PROP_PORT))) );
    163161    }
    164162}
  • router/java/src/net/i2p/router/transport/udp/UDPAddress.java

    r36cb07b0 r8fa7205  
    6565    private void parse(RouterAddress addr) {
    6666        if (addr == null) return;
    67         Properties opts = addr.getOptions();
    68         _host = opts.getProperty(PROP_HOST);
     67        _host = addr.getOption(PROP_HOST);
    6968        if (_host != null) _host = _host.trim();
    7069        try {
    71             String port = opts.getProperty(PROP_PORT);
     70            String port = addr.getOption(PROP_PORT);
    7271            if (port != null)
    7372                _port = Integer.parseInt(port);
     
    7574            _port = -1;
    7675        }
    77         String key = opts.getProperty(PROP_INTRO_KEY);
     76        String key = addr.getOption(PROP_INTRO_KEY);
    7877        if (key != null)
    7978            _introKey = Base64.decode(key.trim());
    8079       
    8180        for (int i = MAX_INTRODUCERS; i >= 0; i--) {
    82             String host = opts.getProperty(PROP_INTRO_HOST_PREFIX + i);
     81            String host = addr.getOption(PROP_INTRO_HOST_PREFIX + i);
    8382            if (host == null) continue;
    84             String port = opts.getProperty(PROP_INTRO_PORT_PREFIX + i);
     83            String port = addr.getOption(PROP_INTRO_PORT_PREFIX + i);
    8584            if (port == null) continue;
    86             String k = opts.getProperty(PROP_INTRO_KEY_PREFIX + i);
     85            String k = addr.getOption(PROP_INTRO_KEY_PREFIX + i);
    8786            if (k == null) continue;
    8887            byte ikey[] = Base64.decode(k);
    8988            if ( (ikey == null) || (ikey.length != SessionKey.KEYSIZE_BYTES) )
    9089                continue;
    91             String t = opts.getProperty(PROP_INTRO_TAG_PREFIX + i);
     90            String t = addr.getOption(PROP_INTRO_TAG_PREFIX + i);
    9291            if (t == null) continue;
    9392            int p = -1;
Note: See TracChangeset for help on using the changeset viewer.