Class SettingsPack

java.lang.Object
com.frostwire.jlibtorrent.SettingsPack

public final class SettingsPack extends Object
The ``settings_pack`` struct, contains the names of all settings as enum values. These values are passed in to the ``set_str()``, ``set_int()``, ``set_bool()`` functions, to specify the setting to change.
  • Constructor Details

    • SettingsPack

      public SettingsPack(settings_pack sp)
    • SettingsPack

      public SettingsPack()
      Example, how to turn on the DHT using SettingsPack.
      
       SettingsPack pack = new SettingsPack();
       pack.setBoolean(settings_pack.bool_types.enable_dht.swigValue(), on);
       s.applySettings(pack);
       
  • Method Details

    • swig

      public settings_pack swig()
      Returns:
    • getBoolean

      public boolean getBoolean(int name)
      Parameters:
      name -
      Returns:
    • setBoolean

      public SettingsPack setBoolean(int name, boolean value)
      Parameters:
      name -
      value -
    • getInteger

      public int getInteger(int name)
      Parameters:
      name -
      Returns:
    • setInteger

      public SettingsPack setInteger(int name, int value)
      Parameters:
      name -
      value -
    • getString

      public String getString(int name)
      Parameters:
      name -
      Returns:
    • setString

      public SettingsPack setString(int name, String value)
      Parameters:
      name -
      value -
    • getBytes

      public byte[] getBytes(int name)
    • setBytes

      public void setBytes(int name, byte[] value)
    • clear

      public void clear()
    • clear

      public void clear(int name)
    • hasValue

      public boolean hasValue(int name)
      Queries whether the specified configuration option has a value set in this pack. ``name`` can be any enumeration value from string_types, int_types or bool_types.
      Parameters:
      name - name id of the setting
      Returns:
      true if present
    • getPeerFingerprint

      public byte[] getPeerFingerprint()
      The fingerprint for the client. It will be used as the prefix to the peer-id. If this is 20 bytes (or longer) it will be truncated to 20 bytes and used as the entire peer-id.
    • setPeerFingerprint

      public void setPeerFingerprint(byte[] value)
      The fingerprint for the client. It will be used as the prefix to the peer-id. If this is 20 bytes (or longer) it will be truncated to 20 bytes and used as the entire peer-id.
    • downloadRateLimit

      public int downloadRateLimit()
      Returns:
      the session-global download rate limit in bytes per second. (0 for unlimited)
    • downloadRateLimit

      public SettingsPack downloadRateLimit(int value)
      Sets the session-global limits of download rate limit, in bytes per second.

      A value of 0 means unlimited.

      Parameters:
      value -
    • uploadRateLimit

      public int uploadRateLimit()
      Returns:
      the session-global upload rate limit in bytes per second. (0 for unlimited)
    • uploadRateLimit

      public SettingsPack uploadRateLimit(int value)
      Sets the session-global limits of upload rate limit, in bytes per second.

      A value of 0 means unlimited.

      Parameters:
      value -
    • activeDownloads

      public int activeDownloads()
      active_downloads controls how many active downloading torrents the queuing mechanism allows.

      The target number of active torrents is min(active_downloads + active_seeds, active_limit). active_downloads and active_seeds are upper limits on the number of downloading torrents and seeding torrents respectively. Setting the value to -1 means unlimited.

      For auto managed torrents, these are the limits they are subject to. If there are too many torrents some of the auto managed ones will be paused until some slots free up.

      You can have more torrents *active*, even though they are not announced to the DHT, lsd or their tracker. If some peer knows about you for any reason and tries to connect, it will still be accepted, unless the torrent is paused, which means it won't accept any connections.

      For example if there are 10 seeding torrents and 10 downloading torrents, and ``active_downloads`` is 4 and ``active_seeds`` is 4, there will be 4 seeds active and 4 downloading torrents. If the settings are ``active_downloads`` = 2 and ``active_seeds`` = 4, then there will be 2 downloading torrents and 4 seeding torrents active. Torrents that are not auto managed are also counted against these limits. If there are non-auto managed torrents that use up all the slots, no auto managed torrent will be activated.

      Returns:
    • activeDownloads

      public SettingsPack activeDownloads(int value)
      Parameters:
      value -
      See Also:
    • activeSeeds

      public int activeSeeds()
      active_seeds controls how many active seeding torrents the queuing mechanism allows.
      Returns:
      See Also:
    • activeSeeds

      public SettingsPack activeSeeds(int value)
      Parameters:
      value -
      See Also:
    • activeChecking

      public int activeChecking()
      active_checking is the limit of number of simultaneous checking torrents.
      Returns:
      See Also:
    • activeChecking

      public SettingsPack activeChecking(int value)
      Parameters:
      value -
      See Also:
    • activeDhtLimit

      public int activeDhtLimit()
      active_dht_limit is the max number of torrents to announce to the DHT. By default this is set to 88, which is no more than one DHT announce every 10 seconds.
      Returns:
      See Also:
    • activeDhtLimit

      public SettingsPack activeDhtLimit(int value)
      Parameters:
      value -
      See Also:
    • dhtUploadRate

      public int dhtUploadRate()
    • dhtUploadRate

      public SettingsPack dhtUploadRate(int value)
    • activeTrackerLimit

      public int activeTrackerLimit()
      active_tracker_limit is the max number of torrents to announce to their trackers. By default this is 360, which is no more than one announce every 5 seconds.
      Returns:
      See Also:
    • activeTrackerLimit

      public SettingsPack activeTrackerLimit(int value)
      Parameters:
      value -
      See Also:
    • activeLsdLimit

      public int activeLsdLimit()
      active_lsd_limit is the max number of torrents to announce to the local network over the local service discovery protocol. By default this is 80, which is no more than one announce every 5 seconds (assuming the default announce interval of 5 minutes).
      Returns:
      See Also:
    • activeLsdLimit

      public SettingsPack activeLsdLimit(int value)
      Parameters:
      value -
      See Also:
    • activeLimit

      public int activeLimit()
      active_limit is a hard limit on the number of active (auto managed) torrents. This limit also applies to slow torrents.
      Returns:
      the value
      See Also:
    • activeLimit

      public SettingsPack activeLimit(int value)
      active_limit is a hard limit on the number of active (auto managed) torrents. This limit also applies to slow torrents.
      Parameters:
      value - the value
      See Also:
    • connectionsLimit

      public int connectionsLimit()
      Returns:
      global limit on the number of connections opened.
    • connectionsLimit

      public SettingsPack connectionsLimit(int value)
      Sets a global limit on the number of connections opened. The number of connections is set to a hard minimum of at least two per torrent, so if you set a too low connections limit, and open too many torrents, the limit will not be met.
      Parameters:
      value -
    • maxPeerlistSize

      public int maxPeerlistSize()
      Returns:
      the maximum number of peers in the list of known peers. (0 for unlimited)
    • maxPeerlistSize

      public SettingsPack maxPeerlistSize(int value)
      Sets the maximum number of peers in the list of known peers. These peers are not necessarily connected, so this number should be much greater than the maximum number of connected peers. Peers are evicted from the cache when the list grows passed 90% of this limit, and once the size hits the limit, peers are no longer added to the list. If this limit is set to 0, there is no limit on how many peers we'll keep in the peer list.
      Parameters:
      value -
    • maxQueuedDiskBytes

      public int maxQueuedDiskBytes()
      Returns:
      the maximum number of bytes a connection may have pending in the disk write queue before its download rate is being throttled.
    • maxQueuedDiskBytes

      public SettingsPack maxQueuedDiskBytes(int value)
      Sets the maximum number of bytes a connection may have pending in the disk write queue before its download rate is being throttled. This prevents fast downloads to slow medias to allocate more memory indefinitely. This should be set to at least 16 kB to not completely disrupt normal downloads. If it's set to 0, you will be starving the disk thread and nothing will be written to disk. this is a per session setting.

      When this limit is reached, the peer connections will stop reading data from their sockets, until the disk thread catches up. Setting this too low will severely limit your download rate.

      Parameters:
      value -
    • sendBufferWatermark

      public int sendBufferWatermark()
      Returns:
      the upper limit of the send buffer low-watermark.
    • sendBufferWatermark

      public SettingsPack sendBufferWatermark(int value)
      Sets the upper limit of the send buffer low-watermark.

      if the send buffer has fewer bytes than this, we'll read another 16kB block onto it. If set too small, upload rate capacity will suffer. If set too high, memory will be wasted. The actual watermark may be lower than this in case the upload rate is low, this is the upper limit.

      Parameters:
      value -
    • tickInterval

      public int tickInterval()
      Returns:
    • tickInterval

      public SettingsPack tickInterval(int value)
      Specifies the number of milliseconds between internal ticks. This is the frequency with which bandwidth quota is distributed to peers. It should not be more than one second (i.e. 1000 ms). Setting this to a low value (around 100) means higher resolution bandwidth quota distribution, setting it to a higher value saves CPU cycles.
      Parameters:
      value -
    • inactivityTimeout

      public int inactivityTimeout()
      Returns:
    • inactivityTimeout

      public SettingsPack inactivityTimeout(int value)
      if a peer is uninteresting and uninterested for longer than this number of seconds, it will be disconnected. default is 10 minutes
      Parameters:
      value -
    • seedingOutgoingConnections

      public boolean seedingOutgoingConnections()
      Returns:
    • seedingOutgoingConnections

      public SettingsPack seedingOutgoingConnections(boolean value)
      Determines if seeding (and finished) torrents should attempt to make outgoing connections or not. By default this is true. It may be set to false in very specific applications where the cost of making outgoing connections is high, and there are no or small benefits of doing so. For instance, if no nodes are behind a firewall or a NAT, seeds don't need to make outgoing connections.
      Parameters:
      value -
    • anonymousMode

      public boolean anonymousMode()
      Returns:
    • anonymousMode

      public SettingsPack anonymousMode(boolean value)
      defaults to false. When set to true, the client tries to hide its identity to a certain degree. The peer-ID will no longer include the client's fingerprint. The user-agent will be reset to an empty string. It will also try to not leak other identifying information, such as your local listen port, your IP etc.

      If you're using I2P, a VPN or a proxy, it might make sense to enable anonymous mode.

      Parameters:
      value -
    • isEnableDht

      public boolean isEnableDht()
      Starts the dht node and makes the trackerless service available to torrents.
      Returns:
      true if enable
    • setEnableDht

      public void setEnableDht(boolean value)
      Starts the dht node and makes the trackerless service available to torrents.
      Parameters:
      value - true if enable
    • isEnableLsd

      public boolean isEnableLsd()
      Starts and stops Local Service Discovery. This service will broadcast the info-hashes of all the non-private torrents on the local network to look for peers on the same swarm within multicast reach.
      Returns:
      true if enable
    • setEnableLsd

      public void setEnableLsd(boolean value)
      Starts and stops Local Service Discovery. This service will broadcast the info-hashes of all the non-private torrents on the local network to look for peers on the same swarm within multicast reach.
      Parameters:
      value - true if enable
    • getMaxMetadataSize

      public int getMaxMetadataSize()
      The maximum allowed size (in bytes) to be received by the metadata extension, i.e. magnet links.
    • setMaxMetadataSize

      public void setMaxMetadataSize(int value)
      The maximum allowed size (in bytes) to be received by the metadata extension, i.e. magnet links.
      Parameters:
      value - true if enable
    • getDhtBootstrapNodes

      public String getDhtBootstrapNodes()
      This is a comma-separated list of IP port-pairs. They will be added to the DHT node (if it's enabled) as back-up nodes in case we don't know of any.

      Changing these after the DHT has been started may not have any effect until the DHT is restarted.

    • setDhtBootstrapNodes

      public void setDhtBootstrapNodes(String value)
      This is a comma-separated list of IP port-pairs. They will be added to the DHT node (if it's enabled) as back-up nodes in case we don't know of any.

      Changing these after the DHT has been started may not have any effect until the DHT is restarted.

      Parameters:
      value - the IP port-pairs list
    • getWebtorrentStunServer

      public String getWebtorrentStunServer()
      This is the STUN server used by WebTorrent to enable ICE NAT traversal for WebRTC. It must have the format ``hostname:port``. TODO: Uncomment code below when settings_pack.hpp from libtorrent master is merged to RC_2_0 See https://github.com/arvidn/libtorrent/blob/master/include/libtorrent/settings_pack.hpp#L370
    • setWebtorrentStunServer

      public void setWebtorrentStunServer(String value)
      This is the STUN server used by WebTorrent to enable ICE NAT traversal for WebRTC. It must have the format ``hostname:port``. TODO: Uncomment code below when settings_pack.hpp from libtorrent master is merged to RC_2_0 See https://github.com/arvidn/libtorrent/blob/master/include/libtorrent/settings_pack.hpp#L370
      Parameters:
      value - the STUN server endpoint
    • listenInterfaces

      public String listenInterfaces()
      Returns:
    • listenInterfaces

      public SettingsPack listenInterfaces(String value)
      Parameters:
      value -
      Returns:
      this
    • stopTrackerTimeout

      public int stopTrackerTimeout()
      Returns:
      the current value
      See Also:
    • stopTrackerTimeout

      public SettingsPack stopTrackerTimeout(int value)
      stop_tracker_timeout is the number of seconds to wait when sending a stopped message before considering a tracker to have timed out. This is usually shorter, to make the client quit faster. If the value is set to 0, the connections to trackers with the stopped event are suppressed.
      Parameters:
      value - the new value
      Returns:
      this
    • alertQueueSize

      public int alertQueueSize()
      Returns:
      the current value
      See Also:
    • alertQueueSize

      public SettingsPack alertQueueSize(int value)
      alert_queue_size is the maximum number of alerts queued up internally. If alerts are not popped, the queue will eventually fill up to this level.
      Parameters:
      value - the new value
      Returns:
      this
    • validateHttpsTrackers

      public SettingsPack validateHttpsTrackers(boolean value)
      validate_https_trackers when set to true, the certificate of HTTPS trackers and HTTPS web seeds will be validated against the system's certificate store (as defined by OpenSSL). If the system does not have a certificate store, this option may have to be disabled in order to get trackers and web seeds to work).
    • validateHttpsTrackers

      public boolean validateHttpsTrackers()