com.sedmelluq.lava.extensions.youtuberotator.tools.ip.IpBlock Java Examples
The following examples show how to use
com.sedmelluq.lava.extensions.youtuberotator.tools.ip.IpBlock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MusicManager.java From Shadbot with GNU General Public License v3.0 | 6 votes |
private MusicManager() { this.audioPlayerManager = new DefaultAudioPlayerManager(); this.audioPlayerManager.getConfiguration().setFrameBufferFactory(NonAllocatingAudioFrameBuffer::new); this.audioPlayerManager.getConfiguration().setFilterHotSwapEnabled(true); AudioSourceManagers.registerRemoteSources(this.audioPlayerManager); this.guildMusics = new ConcurrentHashMap<>(); this.guildJoining = new ConcurrentHashMap<>(); //IPv6 rotation config final String ipv6Block = CredentialManager.getInstance().get(Credential.IPV6_BLOCK); if (!Config.IS_SNAPSHOT && ipv6Block != null && !ipv6Block.isBlank()) { LOGGER.info("Configuring YouTube IP rotator"); final List<IpBlock> blocks = Collections.singletonList(new Ipv6Block(ipv6Block)); final AbstractRoutePlanner planner = new RotatingNanoIpRoutePlanner(blocks); new YoutubeIpRotatorSetup(planner) .forSource(this.audioPlayerManager.source(YoutubeAudioSourceManager.class)) .setup(); } }
Example #2
Source File: NanoIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 5 votes |
public NanoIpRoutePlanner(final List<IpBlock> ipBlocks, final boolean handleSearchFailure) { super(ipBlocks, handleSearchFailure); if (ipBlock.getSize().compareTo(Ipv6Block.BLOCK64_IPS) < 0) throw new IllegalArgumentException("Nano IP Route planner requires an IPv6Block which is greater or equal to a /64"); startTime = BigInteger.valueOf(System.nanoTime()); maskBits = ipBlock.getMaskBits(); }
Example #3
Source File: BalancingIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 5 votes |
private InetAddress getRandomAddress(final IpBlock ipBlock) { InetAddress localAddress; BigInteger it = BigInteger.valueOf(0); do { if (ipBlock.getSize().multiply(BigInteger.valueOf(2)).compareTo(it) < 0) { throw new RuntimeException("Can't find a free ip"); } it = it.add(BigInteger.ONE); localAddress = ipBlock.getRandomAddress(); } while (localAddress == null || !ipFilter.test(localAddress) || !isValidAddress(localAddress)); return localAddress; }
Example #4
Source File: RotatingIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 5 votes |
/** * @param ipBlocks the block to perform balancing over. * @param ipFilter function to filter out certain IP addresses picked from the IP block, causing another random to be chosen. * @param handleSearchFailure whether a search 429 should trigger the ip as failing */ public RotatingIpRoutePlanner(final List<IpBlock> ipBlocks, final Predicate<InetAddress> ipFilter, final boolean handleSearchFailure) { super(ipBlocks, handleSearchFailure); this.ipFilter = ipFilter; this.next = new AtomicBoolean(false); this.rotateIndex = new AtomicReference<>(BigInteger.valueOf(0)); this.index = new AtomicReference<>(BigInteger.valueOf(0)); this.lastFailingAddress = null; }
Example #5
Source File: AbstractRoutePlanner.java From lavaplayer with Apache License 2.0 | 5 votes |
protected AbstractRoutePlanner(final List<IpBlock> ipBlocks, final boolean handleSearchFailure) { this.ipBlock = new CombinedIpBlock(ipBlocks); this.failingAddresses = new HashMap<>(); this.schemePortResolver = DefaultSchemePortResolver.INSTANCE; this.handleSearchFailure = handleSearchFailure; log.info("Active RoutePlanner: {} using total of {} ips", getClass().getCanonicalName(), this.ipBlock.getSize()); }
Example #6
Source File: RotatingNanoIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 5 votes |
public RotatingNanoIpRoutePlanner(final List<IpBlock> ipBlocks, final Predicate<InetAddress> ipFilter, final boolean handleSearchFailure) { super(ipBlocks, handleSearchFailure); this.ipFilter = ipFilter; this.currentBlock = new AtomicReference<>(BigInteger.ZERO); this.blockNanoStart = new AtomicReference<>(BigInteger.valueOf(System.nanoTime())); this.next = new AtomicBoolean(false); if (ipBlock.getType() != Inet6Address.class || ipBlock.getSize().compareTo(Ipv6Block.BLOCK64_IPS) < 0) throw new IllegalArgumentException("Please use a bigger IPv6 Block!"); }
Example #7
Source File: BalancingIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 4 votes |
/** * @param ipBlocks the block to perform balancing over. */ public BalancingIpRoutePlanner(List<IpBlock> ipBlocks) { this(ipBlocks, i -> true); }
Example #8
Source File: RotatingIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 4 votes |
/** * @param ipBlocks the block to perform balancing over. */ public RotatingIpRoutePlanner(final List<IpBlock> ipBlocks) { this(ipBlocks, i -> true); }
Example #9
Source File: AbstractRoutePlanner.java From lavaplayer with Apache License 2.0 | 4 votes |
public IpBlock getIpBlock() { return ipBlock; }
Example #10
Source File: RotatingNanoIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 4 votes |
public RotatingNanoIpRoutePlanner(final List<IpBlock> ipBlocks) { this(ipBlocks, ip -> true); }
Example #11
Source File: RotatingNanoIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 4 votes |
public RotatingNanoIpRoutePlanner(final List<IpBlock> ipBlocks, final Predicate<InetAddress> ipFilter) { this(ipBlocks, ipFilter, true); }
Example #12
Source File: MantaroAudioManager.java From MantaroBot with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("rawtypes") public MantaroAudioManager() { this.musicManagers = new ConcurrentHashMap<>(); this.playerManager = new DefaultAudioPlayerManager(); //Youtube is special because rotation stuff. YoutubeAudioSourceManager youtubeAudioSourceManager = new YoutubeAudioSourceManager(true); //IPv6 rotation config start Config config = MantaroData.config().get(); if (!config.getIpv6Block().isEmpty()) { AbstractRoutePlanner planner; String block = config.getIpv6Block(); List<IpBlock> blocks = Collections.singletonList(new Ipv6Block(block)); //Damn you, YouTube. if (config.getExcludeAddress().isEmpty()) planner = new RotatingNanoIpRoutePlanner(blocks); else { try { InetAddress blacklistedGW = InetAddress.getByName(config.getExcludeAddress()); planner = new RotatingNanoIpRoutePlanner(blocks, inetAddress -> !inetAddress.equals(blacklistedGW)); } catch (Exception e) { //Fallback: did I screw up putting the IP in? lmao planner = new RotatingNanoIpRoutePlanner(blocks); e.printStackTrace(); } } new YoutubeIpRotatorSetup(planner) .forSource(youtubeAudioSourceManager) .setup(); } //IPv6 rotation config end //Register source manager and configure the Player playerManager.registerSourceManager(youtubeAudioSourceManager); playerManager.registerSourceManager(SoundCloudAudioSourceManager.createDefault()); playerManager.registerSourceManager(new BandcampAudioSourceManager()); playerManager.registerSourceManager(new VimeoAudioSourceManager()); playerManager.registerSourceManager(new TwitchStreamAudioSourceManager()); playerManager.registerSourceManager(new BeamAudioSourceManager()); if (!ExtraRuntimeOptions.DISABLE_NON_ALLOCATING_BUFFER) { log.info("Enabled non-allocating audio buffer."); playerManager.getConfiguration().setFrameBufferFactory(NonAllocatingAudioFrameBuffer::new); } }
Example #13
Source File: BalancingIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 2 votes |
/** * @param ipBlocks the block to perform balancing over. * @param ipFilter function to filter out certain IP addresses picked from the IP block, causing another random to be chosen. */ public BalancingIpRoutePlanner(List<IpBlock> ipBlocks, Predicate<InetAddress> ipFilter) { this(ipBlocks, ipFilter, true); }
Example #14
Source File: BalancingIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 2 votes |
/** * @param ipBlocks the block to perform balancing over. * @param ipFilter function to filter out certain IP addresses picked from the IP block, causing another random to be chosen. * @param handleSearchFailure whether a search 429 should trigger the ip as failing */ public BalancingIpRoutePlanner(List<IpBlock> ipBlocks, Predicate<InetAddress> ipFilter, boolean handleSearchFailure) { super(ipBlocks, handleSearchFailure); this.ipFilter = ipFilter; }
Example #15
Source File: RotatingIpRoutePlanner.java From lavaplayer with Apache License 2.0 | 2 votes |
/** * @param ipBlocks the block to perform balancing over. * @param ipFilter function to filter out certain IP addresses picked from the IP block, causing another random to be chosen. */ public RotatingIpRoutePlanner(final List<IpBlock> ipBlocks, final Predicate<InetAddress> ipFilter) { this(ipBlocks, ipFilter, true); }