Skip to content

6 lavalink tutorial

Tomato6966 edited this page Jan 15, 2024 · 18 revisions

Requirements - JAVA-Version (Recommendations)

  • v18 - for Lavalink@latest (v3.5+ or rc*)
  • v13 - for Lavalink v3.3-v3.4
  • v11 - for all older Versions

What is Lavalink?

  • Lavalink is an open-source Discord Queue Manager and Audioplayer, as well as scraper.

Installation

wget https://github.com/freyacodes/Lavalink/releases/download/3.7.5/Lavalink.jar
wget https://raw.githubusercontent.com/Tomato6966/Debian-Cheat-Sheet-Setup/main/application.yml

Make sure the file-name is equal to: application.yml

NOTE: If you don't wanna use the spotify plugin, then remove it from MY EXAMPLE application.yml

other wise you'd get errors. as far this is just a note-cheatsheet FOR ME

Plugins Example

  • Then download all the available Plugins: List & Infos and put them in ./plugins
mkdir plugins && cd plugins
# adds additional source managers that are not widely used
wget https://github.com/DuncteBot/skybot-lavalink-plugin/releases/download/1.3.3/skybot-lavalink-plugin-1.3.3.jar
# adds spotify (api) and apple music search support
wget https://github.com/Topis-Lavalink-Plugins/Topis-Source-Managers-Plugin/releases/download/v2.0.6/topis-source-managers-plugin-2.0.6.jar

Now everything should look like this: image image

Edit Application.yml

make sure to edit:

  • port to access Lavalink from a different Port
  • password so that you have a password
  • spotify -> clientId & clientSecret get them from here
  • All other values to fit your needs

Start Lavalink

in the folder of Lavalink.jar and application.yml execute the following

java -jar Lavalink.jar

How to start it 24/7 - 2 Methods

  • pm2:
npm i -g pm2; # add pm2 to the system
pm2 start --name Lavalink --max-memory-restart 4G java -- -jar Lavalink.jar
  • screen: screen -t Lavalink -s Lavalink java -jar Lavalink # in the screen window:

strg + alt + a + d -> to exit

screen -ls to view all screens

screen -r to re-enter a screen

How to connect to it?

you need the following information:

  • host: localhost | 127.0.0.1 | IPV4 Address (if the port is open)
  • port: 2333 | defined_port
  • password: youshallnotpass | defined_port

And then connect with a client-wrapper list

for nodejs I recommend erela.js fork by me

Recommendation

Start using ipv6 routating, to prevent an ip ban from youtube! check here for more infos

How to do ip routing notes:

First enable allowments for ipv6

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

More ipv6 Settings for your sysctl.conf file which are recommended:

sysctl -w net.ipv6.conf.all.autoconf=0
sysctl -w net.ipv6.conf.all.accept_ra=0
echo 'net.ipv6.conf.all.autoconf=0' >> /etc/sysctl.conf
echo 'net.ipv6.conf.all.accept_ra=0' >> /etc/sysctl.conf

replace 1234:1234:1234::/64 with your BLOCK (e.g. 2a01:12ab:12::/64), if it's a /48 then it's 1234:1234:1234::/48 ofc.

ip -6 route replace local 1234:1234:1234::/64 dev lo

Don't know how to route it with netplan / interfaces? Ask your provider or do:

ip add add local 1234:1234:1234::/64 dev lo

Test the config

# Test that IPv6 works in the first place
ping6 google.com

# If you have the IPv6 block 1234:1234:1234::/48
# You should be able to use any of the IPs within that block
ping6 -I 1234:1234:1234:: -c 2 google.com
ping6 -I 1234:1234:1234::1 -c 2 google.com
ping6 -I 1234:1234:1234::2 -c 2 google.com
ping6 -I 1234:1234:1234:dead:beef:1234:1234 -c 2 google.com

IF you get could not assign requested address, then it's not routed to your system..

IF YOU GET 100% PACKET LOSS THEN EVERYTHING IS OKAY DO THE FOLLOWING:

# Install routing proxy
sudo apt-get -y install ndppd
# Create / edit it's config file
nano /etc/ndppd.conf
# Next paste the following: again replace the block with your block

route-ttl 30000 

proxy enp1s0 { # your interface name
   router no # If it should send router bit | default: yes
   timeout 500 # How long (in ms) it waits to assign a request address (lower == faster but more unstable) | default: 500
   ttl 30000 # How long (in ms) it caches an Ip Address (for lavalink you can def. set this one to 3600000 | default: 30000
   rule 1234:1234:1234::/64{
       static # to respond immediatelly
   }
}

Before saving replace enp1s0 with your interface block name

It's findable with: ip addr there are multiple, just find the name of the one where your ipv6 Block is in!

NOW START ndppd

ndppd -d -c /etc/ndppd.conf
# Restart: systemctl restart ndppd
# Stop: systemctl stop ndppd
# Status : systemctl status ndppd
# Start: systemctl start ndppd

If apt-install fails do this:

wget http://data.vshell.net/files/ndppd-0.2.5.tar.gz
tar -zxvf ndppd-0.2.5.tar.gz
cd ndppd-0.2.5
make
make install

How does my /etc/ndppd.conf look like?

route-ttl 3600000 
proxy enp1s0 {
   router yes
   timeout 50
   ttl 3600000 
   rule 2423:2220:123:1234::/64{
       static
   }
}

Ipv6 Setup Script

If you'd like to do all that within a script, simply copy the following code into a setupIpv6.sh file (make sure to do chmod +rwx setupIpv6.sh):

#!/bin/bash
read -p "enter the ipv6 Block with suffix (e.g. 1234:204:7cde::/48 / 1234:204:7cde:1234::/64): " ipBlock

echo "sysctl -w net.ipv6.ip_nonlocal_bind=1"
sysctl -w net.ipv6.ip_nonlocal_bind=1

echo "sysctl -w net.ipv6.conf.all.autoconf=0"
sysctl -w net.ipv6.conf.all.autoconf=0

echo "sysctl -w net.ipv6.conf.all.accept_ra=0"
sysctl -w net.ipv6.conf.all.accept_ra=0

echo "ip add add local $ipBlock dev lo"
ip add add local $ipBlock dev lo

echo "ip -6 route replace local $ipBlock dev lo"
ip -6 route replace local $ipBlock dev lo

read -p "ipv6 configuration commands executed, wanna test it? (y / n): " yn

case $yn in
        [yY] )  echo "now testing the ipv6";
                break;;
        [nN] )
                exit;;
        * ) echo invalid response;
                exit 1;;
esac

# define blocks
ipBlockUse=${ipBlock::-3}
ipBlockUse2="${ipBlock::-3}1234:1234"
ipBlockUse3="${ipBlock::-3}dead:beef"
ipBlockUse4="${ipBlock::-3}deaf:1234:beef"
# loop over the blocks
for i in $ipBlockUse $ipBlockUse2 $ipBlockUse3 $ipBlockUse4
  do
    echo "Now testing the Ipv6 / Block: $i"
    ping6 -I $i -c 2 google.com
  done

echo "done testing"
Clone this wiki locally