Log DNS result for discord domains

This commit is contained in:
Vankka 2024-10-30 21:18:46 +02:00
parent a8752dd96c
commit 51cd79e700
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB

View File

@ -72,11 +72,11 @@ import com.discordsrv.common.feature.linking.LinkProvider;
import com.discordsrv.common.feature.linking.LinkingModule;
import com.discordsrv.common.feature.linking.impl.MinecraftAuthenticationLinker;
import com.discordsrv.common.feature.linking.impl.StorageLinker;
import com.discordsrv.common.feature.mention.MentionCachingModule;
import com.discordsrv.common.feature.mention.MentionGameRenderingModule;
import com.discordsrv.common.feature.messageforwarding.discord.DiscordChatMessageModule;
import com.discordsrv.common.feature.messageforwarding.discord.DiscordMessageMirroringModule;
import com.discordsrv.common.feature.messageforwarding.game.*;
import com.discordsrv.common.feature.mention.MentionCachingModule;
import com.discordsrv.common.feature.profile.ProfileManager;
import com.discordsrv.common.feature.update.UpdateChecker;
import com.discordsrv.common.helper.ChannelConfigHelper;
@ -102,8 +102,10 @@ import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.UnknownHostException;
import java.nio.file.Path;
import java.time.Duration;
import java.util.*;
@ -114,6 +116,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.stream.Collectors;
/**
* DiscordSRV's implementation's common code.
@ -607,6 +610,23 @@ public abstract class AbstractDiscordSRV<
// Integrations
registerIntegration("com.discordsrv.common.integration.LuckPermsIntegration");
// Check if the system has working DNS
try {
String discordDomain = "discord.com";
String gatewayDomain = "gateway.discord.gg";
String discordAddresses = Arrays.stream(InetAddress.getAllByName(discordDomain))
.map(InetAddress::getHostAddress)
.collect(Collectors.joining(", "));
String gatewayAddresses = Arrays.stream(InetAddress.getAllByName(gatewayDomain))
.map(InetAddress::getHostAddress)
.collect(Collectors.joining(", "));
logger().debug("DNS OK (" + discordDomain + "=[" + discordAddresses
+ "], " + gatewayDomain + "=[" + gatewayAddresses + "])");
} catch (UnknownHostException e) {
logger().debug("DNS check failed", e);
}
// Initial load
try {
runReload(ReloadFlag.ALL, true);