Class NetworkScope

java.lang.Object
lol.trq.alts.net.NetworkScope

public final class NetworkScope extends Object
What a request is for, and on whose behalf. A host's ProxyProvider reads this to decide which route the request should take.

The account is carried because per-account proxying is the point: an alt manager that validates fifty accounts from one address looks like one machine hammering the service, which is what the rate limiter is there to stop. Both account fields are null for a request that has no account yet — a fresh Microsoft login, a cookie import — and a host proxying those assigns from its own pool.

The route tag is the host's own label for a request that has no account to route on yet. A host that runs one proxy per account, the host of a bot for one, signs a new account in through AltLoginService.routed(tag) (or a bulk import with BulkOptions.withRouteTag(tag)), and every request of that sign-in, on every hop, reaches the provider with the tag. It is empty for every other request.

A final class rather than a record since 1.0.0, so a later field is an addition and not a break: build one with of(NetworkScope.Purpose), forAccount(NetworkScope.Purpose, String, String) and withRouteTag(String). Two scopes are equal when every field is.

Since:
0.8.0
  • Method Details

    • of

      public static NetworkScope of(NetworkScope.Purpose purpose)
      Creates a scope for a request that belongs to no particular account.
      Parameters:
      purpose - what is being fetched; null reads as NetworkScope.Purpose.AUTH
      Returns:
      an account-less scope
      Since:
      0.8.0
    • forAccount

      public static NetworkScope forAccount(NetworkScope.Purpose purpose, String accountUuid, String accountUsername)
      Creates a scope for a request made on one account's behalf.
      Parameters:
      purpose - what is being fetched; null reads as NetworkScope.Purpose.AUTH
      accountUuid - the dashed UUID of the account, or null
      accountUsername - the username of the account, or null
      Returns:
      a scope naming the account
      Since:
      0.8.0
    • withRouteTag

      public NetworkScope withRouteTag(String tag)
      Returns a copy of this scope carrying a route tag.
      Parameters:
      tag - the host's route tag, or null for none
      Returns:
      the tagged copy
      Throws:
      IllegalArgumentException - if tag is blank
      Since:
      1.0.0
    • purpose

      public NetworkScope.Purpose purpose()
      Returns what is being fetched.
      Returns:
      the purpose, never null
      Since:
      0.8.0
    • accountUuid

      public String accountUuid()
      Returns the dashed UUID of the account this is for.
      Returns:
      the UUID, or null for a request with no account
      Since:
      0.8.0
    • accountUsername

      public String accountUsername()
      Returns the username of the account this is for.
      Returns:
      the username, or null for a request with no account
      Since:
      0.8.0
    • routeTag

      public Optional<String> routeTag()
      Returns the host's route tag for this request.
      Returns:
      the tag, or empty
      Since:
      1.0.0
    • equals

      public boolean equals(Object o)
      Returns whether o is a scope with every field equal to this one's.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare
      Returns:
      true when every field is equal
      Since:
      0.8.0
    • hashCode

      public int hashCode()
      Returns a hash over every field, consistent with equals(Object).
      Overrides:
      hashCode in class Object
      Returns:
      the hash
      Since:
      0.8.0
    • toString

      public String toString()
      Returns every field, in the form the record printed them.
      Overrides:
      toString in class Object
      Returns:
      a description
      Since:
      0.8.0