Shadorc / Shadbot

A configurable multipurpose bot bringing you music, multiplayer games, moderation commands and more!
GNU General Public License v3.0
50 stars 39 forks source link

Question about Lavaplayers YouTube Rotator #28

Closed Portagoras closed 4 years ago

Portagoras commented 4 years ago

Heyho Shadorc,

we just implemented Lavaplayers YouTube Rotator on our Bot, but it seems like YouTube, in the usual period, Ratelimited our whole IPv6 subnet.

I wonder why your implementation of it works, as we did it quite similarly with our IPv6 CIDR block.

Maybe you could give us a clue on what is going on, even if that is not the right repo :)

Thanks and I added the Stacktrace down here:

Stacktrace ``` com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Loading information for a YouTube track failed. at com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.wrapUnfriendlyExceptions(ExceptionTools.java:43) at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager.loadTrackWithVideoId(YoutubeAudioSourceManager.java:212) at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager$LoadingRoutes.track(YoutubeAudioSourceManager.java:224) at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager$LoadingRoutes.track(YoutubeAudioSourceManager.java:220) at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeLinkRouter.routeFromUrlWithVideoId(DefaultYoutubeLinkRouter.java:96) at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeLinkRouter.routeFromMainDomain(DefaultYoutubeLinkRouter.java:61) at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeLinkRouter.route(DefaultYoutubeLinkRouter.java:39) at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager.loadItemOnce(YoutubeAudioSourceManager.java:188) at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager.loadItem(YoutubeAudioSourceManager.java:127) at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.checkSourcesForItemOnce(DefaultAudioPlayerManager.java:437) at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.checkSourcesForItem(DefaultAudioPlayerManager.java:419) at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$createItemLoader$0(DefaultAudioPlayerManager.java:218) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at com.sedmelluq.discord.lavaplayer.tools.OrderedExecutor$ChannelRunnable.executeQueue(OrderedExecutor.java:98) at com.sedmelluq.discord.lavaplayer.tools.OrderedExecutor$ChannelRunnable.run(OrderedExecutor.java:87) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: com.sedmelluq.lava.extensions.youtuberotator.tools.RateLimitException: Retry aborted, too many retries on ratelimit. at com.sedmelluq.lava.extensions.youtuberotator.YoutubeIpRotatorFilter.limitedRetry(YoutubeIpRotatorFilter.java:114) at com.sedmelluq.lava.extensions.youtuberotator.YoutubeIpRotatorFilter.onRequestException(YoutubeIpRotatorFilter.java:102) at com.sedmelluq.discord.lavaplayer.tools.http.SettableHttpRequestFilter.onRequestException(SettableHttpRequestFilter.java:61) at com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface.execute(HttpInterface.java:79) at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeTrackDetailsLoader.load(DefaultYoutubeTrackDetailsLoader.java:35) at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeTrackDetailsLoader.loadDetails(DefaultYoutubeTrackDetailsLoader.java:26) at com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager.loadTrackWithVideoId(YoutubeAudioSourceManager.java:200) ... 16 more ```
Shadorc commented 4 years ago

Hey, So, your IPv6 configuration and IP rotator are currently working, it just gets rate limited after a period of time, right ? Do you have a /48 or /64 block ?

Portagoras commented 4 years ago

What I did was to register that AudioPlayerManager as Remote and Local Source and setup the YouTubeRotator (RotatingNano) with my global IPv6 Block. Also Added Twitch,Vimeo and Soundcloud sources to it (Without any rotation features).

I looked at it again and it might have used IPv4 again cause I made a mistake, but after the fix I still got the Ratelimit Exception for all possible IPv6 Adresses (Tried so other Routers too, and outputted the tested IPv6 adresses)

Perhaps I made mistakes on my Linux platform. I'm not really secure with Routing and all that.

We really want to implement that feature tho, as we kinda get the usual Ratelimit in under 24h and till now just switched servers every day or so...

Thanks for you help! Really appreciate it! I'm currently at work, but l'll see that I upload the relevant codesnipped here later today :)

Shadorc commented 4 years ago

I don't think a piece of code is needed, if you get the ip rotator to work, even if it gets rate limited, that probably means it does not come from this. Do you see "XXXXXX ips are being used" when starting your bot ? Did it worked a little before getting ratelimited or no ? I've heard that IPv6 /64 blocks are also subject to rate limitation with some traffic, only /48 are really secure (for now).

Portagoras commented 4 years ago

Do you see "XXXXXX ips are being used" when starting your bot ?

When using my development version with debug outputs, I do. Live branch -> no

Did it worked a little before getting ratelimited or no ?

Worked for the usual period and was then ratelimited

I've heard that IPv6 /64 blocks are also subject to rate limitation with some traffic, only /48 are really secure (for now).

The server has a /64 subnet assigned by our router, the router itself got a /59 subnet. So might wanna rent a server that got at least a /48 subnet, I suppose!

Shadorc commented 4 years ago

It's weird that it is not printed in your live branch, is this because you don't have the debug output enabled?

Portagoras commented 4 years ago

That's what I meant. I might try that again! Can't do it right now, cause I'm at work, but I will come back to you in like 10h or so.

Thanks for your support, you already helped me a lot :)

Shadorc commented 4 years ago

You're welcome I hope your issue will be solved, it was a nightmare for me too

Portagoras commented 4 years ago
c.s.l.e.y.tools.ip.Ipv6Block             : Using Ipv6Block with 590295810358705651712 addresses
c.s.l.e.y.planner.AbstractRoutePlanner   : Active RoutePlanner: com.sedmelluq.lava.extensions.youtuberotator.planner.RotatingNanoIpRoutePlanner using total of 18446744073709551616 ips

Changed a some stuff up, but now it won't find any youtube links (currently only links enabled cause of some other project)

c.s.d.l.p.DefaultAudioPlayerManager      : No matches for track with identifier https://www.youtube.com/watch?v=g0cQRq2rR_I.

The building of my AudioPlayerManager now looks like this:

        logger.info("Starting PlayerManager");
        AudioPlayerManager audioPlayerManager = new DefaultAudioPlayerManager();
        audioPlayerManager.getConfiguration().setFrameBufferFactory(NonAllocatingAudioFrameBuffer::new);
        audioPlayerManager.getConfiguration().setFilterHotSwapEnabled(true);
        AudioSourceManagers.registerRemoteSources(audioPlayerManager);

        final String ipv6Block = ""; //Cleared for reasons
        logger.info("Configuring YouTube IP rotator");
        @SuppressWarnings("rawtypes") final List<IpBlock> blocks = Collections.singletonList(new Ipv6Block(ipv6Block));

        planner = new RotatingNanoIpRoutePlanner(blocks);
        new YoutubeIpRotatorSetup(planner)
                .withRetryLimit(50)
                .forSource(audioPlayerManager.source(YoutubeAudioSourceManager.class))
                .setup();

lavaplayer: 1.3.50 rotator: 0.2.3

Shadorc commented 4 years ago

Here are all the steps I use in order to configure my ipv6 block. From this guide: https://ramblings.fred.moe/2020/3/tunnelbroker-with-lavalink 1.

# Enable now
sudo sysctl -w net.ipv6.ip_nonlocal_bind=1
# Persist for next boot
sudo echo 'net.ipv6.ip_nonlocal_bind = 1' >> /etc/sysctl.conf

2.

Paste the following into /etc/network/interfaces.d/he-ipv6.cfg:
auto he-ipv6
iface he-ipv6 inet6 v4tunnel
        address IPv6_BLOCK::
        netmask 48
        endpoint 216.66.88.98
        local XX.XX.XX.XX
        ttl 255
        gateway IPv6_BLOCK::1

3.

sudo reboot

4.

# Must be executed each reboot
sudo ip -6 route replace local IPv6_BLOCK::/48 dev lo

5.

 # Test that IPv6 works
ping6 -I IPv6_BLOCK::2 google.com
ping6 -I IPv6_BLOCK::100:1520 google.com
Portagoras commented 4 years ago

Thanks a lot, I'll try as soon as I can!

Shadorc commented 4 years ago

You're welcome ! Also, it is important to note that these steps were not working for me on Ubuntu 18.04 (but for some others, it works). I'm using 16.04

Shadorc commented 4 years ago

Let me know if you have any other questions :)

Portagoras commented 4 years ago

Thanks a lot :) Currently got the error, that the interface cant be started, cause my linux machine is missing the sit module.