Search in sources :

Example 1 with ExternalSeedPeer

use of com.biglybt.plugin.extseed.ExternalSeedPeer in project BiglyBT by BiglySoftware.

the class DownloadManagerController method addHTTPSeed.

@Override
public void addHTTPSeed(String address, int port) {
    ExternalSeedPlugin plugin = getExternalSeedPlugin();
    try {
        if (plugin != null) {
            Map config = new HashMap();
            List urls = new ArrayList();
            String seed_url = "http://" + UrlUtils.convertIPV6Host(address) + ":" + port + "/webseed";
            urls.add(seed_url.getBytes());
            config.put("httpseeds", urls);
            Map params = new HashMap();
            params.put("supports_503", new Long(0));
            params.put("transient", new Long(1));
            config.put("httpseeds-params", params);
            List<ExternalSeedPeer> new_seeds = plugin.addSeed(com.biglybt.pifimpl.local.download.DownloadManagerImpl.getDownloadStatic(download_manager), config);
            if (new_seeds.size() > 0) {
                List<ExternalSeedPeer> to_remove = new ArrayList<>();
                synchronized (http_seeds) {
                    http_seeds.addAll(new_seeds);
                    while (http_seeds.size() > HTTP_SEEDS_MAX) {
                        ExternalSeedPeer x = http_seeds.removeFirst();
                        to_remove.add(x);
                    }
                }
                for (ExternalSeedPeer peer : to_remove) {
                    peer.remove();
                }
            }
        }
    } catch (Throwable e) {
        Debug.printStackTrace(e);
    }
}
Also used : ExternalSeedPlugin(com.biglybt.plugin.extseed.ExternalSeedPlugin) ExternalSeedPeer(com.biglybt.plugin.extseed.ExternalSeedPeer)

Aggregations

ExternalSeedPeer (com.biglybt.plugin.extseed.ExternalSeedPeer)1 ExternalSeedPlugin (com.biglybt.plugin.extseed.ExternalSeedPlugin)1