java.lang.Object
org.klomp.snark.ClientID.Profile
Enclosing class:
ClientID

public static final class ClientID.Profileextends Object
One impersonatable client: peer ID prefix plus the matching tracker User-Agent and extension handshake "v" strings.
  • Field Details

    • name

      private final String name
      Client name shown in the logs.
    • peerIdPrefixStr

      private final String peerIdPrefixStr
      Peer id prefix this profile sends, null for none.
    • peerIdPrefix

      private final byte[] peerIdPrefix
      Exact leading peer ID bytes, 5-8 long, e.g. "-AZ5770-" or "TIX34".
    • uaBase

      private final String uaBase
      User-Agent base; ";<OS>;Java <ver>" appended when appendOsJava is set.
    • appendOsJava

      private final boolean appendOsJava
      True to name the OS and Java in the peer id.
    • extV

      private final String extV
      Extension version advertised in the peer id.
  • Constructor Details

    • Profile

      private Profile(String n, String prefix, String ua, boolean osJava, String v)
      Describes one client identity profile.
      Parameters:
      n - the client name
      prefix - the peer id prefix, null for none
      ua - the user agent for trackers
      osJava - true to name the OS and Java in the peer id
      v - the extension version advertised
  • Method Details

    • getName

      public String getName()
      The profile name, also the accepted i2psnark.clientId token.
      Returns:
      the name identifying this profile
    • getPeerIdPrefix

      String getPeerIdPrefix()
      The ASCII peer ID prefix, e.g. "-AZ5770-". Package visible for tests.
      Returns:
      the prefix string
    • buildPeerId

      public byte[] buildPeerId(Random random)
      A fresh 20-byte peer ID: this profile's prefix followed by random alphanumeric bytes.
      Parameters:
      random - the randomness source
      Returns:
      a new 20-byte peer ID
    • getUserAgent

      public String getUserAgent()
      The HTTP User-Agent for tracker announces and webseed fetches. Never null.
      Returns:
      the base user agent, with ";OS;Java version" appended when this profile requests it
    • getExtHandshakeName

      public String getExtHandshakeName()
      The BEP 10 extension handshake "v" value. Never null.
      Returns:
      the extension protocol version string advertised in the handshake
    • toString

      public String toString()
      Overrides:
      toString in class Object