Class NodeStatus


  • public class NodeStatus
    extends Document
    NodeStatus documents contain persistent state for data about relays. These are read by the hourly updater and then updated with new details where there are relevant descriptors, consensuses or other documents available.

    At the end of each run of the hourly updater, these documents are concatenated and written to a single file in status/summary. Each line contains a single document.

    A new NodeStatus can be created from a string using the fromString(String) static method. To create a serialization, the toString() method can be used.

    The lines are formed of tab-separated values. There must be at least 23 fields present in the document. Additional fields may be present but are not required for the document to be valid. A summary of the encoding can be found here:

    1. "r" or "b" to represent a relay or a bridge
    2. Nickname
    3. ASCII representation of hex-encoded fingerprint
    4. OR Addresses
    5. Last seen (date portion)
    6. Last seen (time portion)
    7. OR Port
    8. Dir Port
    9. Relay Flags
    10. Consensus Weight
    11. Country Code
    12. Blank field (previously used for host name)
    13. Last reverse DNS lookup time (milliseconds)
    14. Default policy
    15. Port list
    16. First seen (date portion)
    17. First seen (time portion)
    18. Last address change (date portion)
    19. Last address change (time portion)
    20. AS Number
    21. Contact
    22. Recommended version (boolean)
    23. Family
    24. Version
    25. Blank field (previously used for host name)
    26. Version status
    27. AS Name
    28. Verified and unverified host names

    This list only provides a summary, individual fields can have complex encodings with nested lists.

    • Constructor Detail

      • NodeStatus

        public NodeStatus​(java.lang.String fingerprint)
        Instantiates a new node status object from the given fingerprint.
    • Method Detail

      • setContact

        public void setContact​(java.lang.String contact)
        Sets the contact to a lower-cased variant of the given string with all non-printable characters outside of ASCII code 32 (space) to 126 (dash) replaced with spaces.
      • getContact

        public java.lang.String getContact()
      • setDeclaredFamily

        public void setDeclaredFamily​(java.util.SortedSet<java.lang.String> declaredFamily)
      • getDeclaredFamily

        public java.util.SortedSet<java.lang.String> getDeclaredFamily()
      • setRelay

        public void setRelay​(boolean isRelay)
      • isRelay

        public boolean isRelay()
      • getFingerprint

        public java.lang.String getFingerprint()
      • setNickname

        public void setNickname​(java.lang.String nickname)
      • getNickname

        public java.lang.String getNickname()
      • setAddress

        public void setAddress​(java.lang.String address)
      • getAddress

        public java.lang.String getAddress()
      • setOrAddressesAndPorts

        public void setOrAddressesAndPorts​(java.util.SortedSet<java.lang.String> orAddressesAndPorts)
      • getOrAddressesAndPorts

        public java.util.SortedSet<java.lang.String> getOrAddressesAndPorts()
      • getOrAddresses

        public java.util.SortedSet<java.lang.String> getOrAddresses()
        Returns all addresses used for the onion-routing protocol which includes the primary address and all additionally configured onion-routing addresses.
      • setFirstSeenMillis

        public void setFirstSeenMillis​(long firstSeenMillis)
      • getFirstSeenMillis

        public long getFirstSeenMillis()
      • setLastSeenMillis

        public void setLastSeenMillis​(long lastSeenMillis)
      • getLastSeenMillis

        public long getLastSeenMillis()
      • setOrPort

        public void setOrPort​(int orPort)
      • getOrPort

        public int getOrPort()
      • setDirPort

        public void setDirPort​(int dirPort)
      • getDirPort

        public int getDirPort()
      • setRelayFlags

        public void setRelayFlags​(java.util.SortedSet<java.lang.String> relayFlags)
      • getRelayFlags

        public java.util.SortedSet<java.lang.String> getRelayFlags()
      • setConsensusWeight

        public void setConsensusWeight​(long consensusWeight)
      • getConsensusWeight

        public long getConsensusWeight()
      • setDefaultPolicy

        public void setDefaultPolicy​(java.lang.String defaultPolicy)
      • getDefaultPolicy

        public java.lang.String getDefaultPolicy()
      • setPortList

        public void setPortList​(java.lang.String portList)
      • getPortList

        public java.lang.String getPortList()
      • getLastAddresses

        public java.util.SortedMap<java.lang.Long,​java.util.Set<java.lang.String>> getLastAddresses()
      • addLastAddresses

        public void addLastAddresses​(long lastSeenMillis,
                                     java.lang.String address,
                                     int orPort,
                                     int dirPort,
                                     java.util.SortedSet<java.lang.String> orAddressesAndPorts)
        Adds addresses and ports together with the time in milliseconds since the epoch when they were last seen to the history of last seen addresses and ports.
      • getLastChangedOrAddressOrPort

        public long getLastChangedOrAddressOrPort()
        Returns the time in milliseconds since the epoch when addresses or ports were last changed.
      • setRecommendedVersion

        public void setRecommendedVersion​(java.lang.Boolean recommendedVersion)
      • isRecommendedVersion

        public java.lang.Boolean isRecommendedVersion()
      • setVersion

        public void setVersion​(java.lang.String version)
      • getVersion

        public java.lang.String getVersion()
      • setVersionStatus

        public void setVersionStatus​(TorVersionStatus versionStatus)
      • setOperatingSystem

        public void setOperatingSystem​(java.lang.String operatingSystem)
      • getOperatingSystem

        public java.lang.String getOperatingSystem()
      • setExitAddresses

        public void setExitAddresses​(java.util.SortedSet<java.lang.String> exitAddresses)
      • getExitAddresses

        public java.util.SortedSet<java.lang.String> getExitAddresses()
      • setCountryCode

        public void setCountryCode​(java.lang.String countryCode)
      • getCountryCode

        public java.lang.String getCountryCode()
      • setAsNumber

        public void setAsNumber​(java.lang.String asNumber)
      • getAsNumber

        public java.lang.String getAsNumber()
      • setAsName

        public void setAsName​(java.lang.String asName)
      • getAsName

        public java.lang.String getAsName()
      • setHostName

        public void setHostName​(java.lang.String hostName)
      • getHostName

        public java.lang.String getHostName()
      • setVerifiedHostNames

        public void setVerifiedHostNames​(java.util.SortedSet<java.lang.String> verifiedHostNames)
      • getVerifiedHostNames

        public java.util.SortedSet<java.lang.String> getVerifiedHostNames()
      • setUnverifiedHostNames

        public void setUnverifiedHostNames​(java.util.SortedSet<java.lang.String> unverifiedHostNames)
      • getUnverifiedHostNames

        public java.util.SortedSet<java.lang.String> getUnverifiedHostNames()
      • setLastRdnsLookup

        public void setLastRdnsLookup​(long lastRdnsLookup)
      • getLastRdnsLookup

        public long getLastRdnsLookup()
      • setEffectiveFamily

        public void setEffectiveFamily​(java.util.SortedSet<java.lang.String> effectiveFamily)
      • getEffectiveFamily

        public java.util.SortedSet<java.lang.String> getEffectiveFamily()
      • setExtendedFamily

        public void setExtendedFamily​(java.util.SortedSet<java.lang.String> extendedFamily)
      • getExtendedFamily

        public java.util.SortedSet<java.lang.String> getExtendedFamily()
      • getAllegedFamily

        public java.util.SortedSet<java.lang.String> getAllegedFamily()
        Returns the alleged family consisting of all relays in this relay's declared family that are not in a mutual family relationship with this relay.
      • getIndirectFamily

        public java.util.SortedSet<java.lang.String> getIndirectFamily()
        Returns the indirect family consisting of all relays that can be reached via mutual family relationships except for those that can be reached directly via such a relationship.
      • fromString

        public static NodeStatus fromString​(java.lang.String documentString)
        Instantiates a new node status object from the given string that may have been produced by toString(). A document that has been written by a previous version of Onionoo that did not include all the currently supported fields will still be accepted, but will contain the new fields if serialized again using toString(). A document that has been generated by a newer version of Onionoo that contains new fields will be accepted, but those new fields will be ignored and the data discarded if serialized again using toString().
      • toString

        public java.lang.String toString()
        Generates a String serialization of the node status object that could be used by fromString(String) to recreate this object.
        Overrides:
        toString in class java.lang.Object