mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-29 13:36:04 +01:00
Add TLS support.
This commit is contained in:
parent
701496debe
commit
620d1d0a9d
@ -55,6 +55,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import me.botsko.prism.actionlibs.QueryParameters;
|
||||
import me.botsko.prism.events.BlockStateChange;
|
||||
import org.bukkit.Achievement;
|
||||
@ -69,6 +71,7 @@ import org.pircbotx.Configuration;
|
||||
import org.pircbotx.PircBotX;
|
||||
import org.pircbotx.User;
|
||||
import org.pircbotx.UtilSSLSocketFactory;
|
||||
import org.pircbotx.cap.TLSCapHandler;
|
||||
import org.pircbotx.exception.IrcException;
|
||||
import org.pircbotx.hooks.ListenerAdapter;
|
||||
|
||||
@ -87,6 +90,7 @@ public final class PurpleBot {
|
||||
private boolean connected;
|
||||
public boolean autoConnect;
|
||||
public boolean ssl;
|
||||
public boolean tls;
|
||||
public boolean trustAllCerts;
|
||||
public boolean sendRawMessageOnConnect;
|
||||
public boolean showMOTD;
|
||||
@ -270,6 +274,9 @@ public final class PurpleBot {
|
||||
socketFactory.trustAllCertificates();
|
||||
}
|
||||
configBuilder.setSocketFactory(socketFactory);
|
||||
if (tls) {
|
||||
configBuilder.addCapHandler(new TLSCapHandler(socketFactory, true));
|
||||
}
|
||||
}
|
||||
if (charSet.isEmpty()) {
|
||||
if (!reload) {
|
||||
@ -630,6 +637,7 @@ public final class PurpleBot {
|
||||
config.load(file);
|
||||
autoConnect = config.getBoolean("autoconnect", true);
|
||||
ssl = config.getBoolean("ssl", false);
|
||||
tls = config.getBoolean("tls", false);
|
||||
trustAllCerts = config.getBoolean("trust-all-certs", false);
|
||||
sendRawMessageOnConnect = config.getBoolean("raw-message-on-connect", false);
|
||||
rawMessage = config.getString("raw-message", "");
|
||||
@ -668,6 +676,7 @@ public final class PurpleBot {
|
||||
plugin.logDebug("Channel Auto Join Delay => " + channelAutoJoinDelay);
|
||||
plugin.logDebug(("Bind => ") + bindAddress);
|
||||
plugin.logDebug("SSL => " + ssl);
|
||||
plugin.logDebug("TLS => " + tls);
|
||||
plugin.logDebug("Trust All Certs => " + trustAllCerts);
|
||||
plugin.logDebug("Port => " + botServerPort);
|
||||
plugin.logDebug("Command Prefix => " + commandPrefix);
|
||||
@ -941,7 +950,7 @@ public final class PurpleBot {
|
||||
connectMessage = "Connecting to " + botServer + ":"
|
||||
+ botServerPort + ": [Nick: " + botNick
|
||||
+ "] [SSL: " + ssl + "]" + " [TrustAllCerts: "
|
||||
+ trustAllCerts + "]";
|
||||
+ trustAllCerts + "] [TLS: " + tls + "]";
|
||||
}
|
||||
}
|
||||
} catch (IOException | InvalidConfigurationException ex) {
|
||||
|
@ -87,6 +87,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.pircbotx.IdentServer;
|
||||
@ -968,6 +970,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
try {
|
||||
if (vaultHelpers != null) {
|
||||
if (vaultHelpers.permission != null && vaultHelpers.permission != null) {
|
||||
logDebug("getPlayerGroup: " + player.getName());
|
||||
groupName = vaultHelpers.permission.getPrimaryGroup(player);
|
||||
}
|
||||
}
|
||||
@ -1006,6 +1009,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
if (vaultHelpers.permission != null && vaultHelpers.permission != null) {
|
||||
OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid);
|
||||
if (offlinePlayer != null) {
|
||||
logDebug("getPlayerGroup: " + worldName + " " + player);
|
||||
groupName = vaultHelpers.permission.getPrimaryGroup(worldName, offlinePlayer);
|
||||
}
|
||||
}
|
||||
@ -1051,6 +1055,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
if (vaultHelpers.chat != null) {
|
||||
OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid);
|
||||
if (offlinePlayer != null) {
|
||||
logDebug("getPlayerPrefix: " + worldName + " " + player);
|
||||
prefix = vaultHelpers.chat.getPlayerPrefix(worldName, offlinePlayer);
|
||||
}
|
||||
}
|
||||
@ -1096,6 +1101,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
if (vaultHelpers.chat != null) {
|
||||
OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid);
|
||||
if (offlinePlayer != null) {
|
||||
logDebug("getPlayerSuffix: " + worldName + " " + offlinePlayer.getName());
|
||||
suffix = vaultHelpers.chat.getPlayerSuffix(worldName, offlinePlayer);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class CaseInsensitiveMap<V> extends AbstractMap<String, V> {
|
||||
|
||||
private final Map<CaseInsensitiveKey, V> map = new ConcurrentHashMap<CaseInsensitiveKey, V>();
|
||||
private final Map<CaseInsensitiveKey, V> map = new ConcurrentHashMap<>();
|
||||
|
||||
private static final class KeySet extends AbstractSet<String> {
|
||||
|
||||
@ -201,7 +201,7 @@ public class CaseInsensitiveMap<V> extends AbstractMap<String, V> {
|
||||
*/
|
||||
@Override
|
||||
public Entry<String, V> next() {
|
||||
return new MapEntry<V>(this.iterator.next());
|
||||
return new MapEntry<>(this.iterator.next());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,7 +265,7 @@ public class CaseInsensitiveMap<V> extends AbstractMap<String, V> {
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Entry<String, V>> iterator() {
|
||||
return new EntrySetIterator<V>(this.entrySet.iterator());
|
||||
return new EntrySetIterator<>(this.entrySet.iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -397,7 +397,7 @@ public class CaseInsensitiveMap<V> extends AbstractMap<String, V> {
|
||||
*/
|
||||
@Override
|
||||
public Set<Entry<String, V>> entrySet() {
|
||||
return new EntrySet<V>(this.map.entrySet(), this);
|
||||
return new EntrySet<>(this.map.entrySet(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,8 @@ server: irc.excample.com
|
||||
port: 6667
|
||||
# Attempt ssl connection to IRC server
|
||||
ssl: false
|
||||
# Enable TLS support
|
||||
tls: false
|
||||
# Trust all SSL certs
|
||||
trust-all-certs: false
|
||||
# Bind address
|
||||
|
Loading…
Reference in New Issue
Block a user