Fix TLS support.

This commit is contained in:
cnaude 2015-03-19 21:50:01 -07:00
parent b3e92df042
commit aec0df7274
5 changed files with 16 additions and 11 deletions

View File

@ -26,7 +26,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>

View File

@ -89,7 +89,7 @@
<dependency>
<groupId>com.cnaude.pircbotx</groupId>
<artifactId>pircbotx</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
</dependency>
<!-- Following dependency is provided by CraftBukkit -->
@ -357,7 +357,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.2</version>
<configuration>
<!-- Minimum Minecraft requirement -->
<source>1.7</source>

View File

@ -48,7 +48,7 @@ public class ServerResponseListener extends ListenerAdapter {
@Override
public void onServerResponse(ServerResponseEvent event) {
int serverReply = event.getCode();
if (serverReply == ReplyConstants.ERR_BADCHANNELKEY) {
plugin.logInfo("Bad channel password.");
}

View File

@ -55,6 +55,7 @@ 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.ssl.SSLSocketFactory;
import me.botsko.prism.actionlibs.QueryParameters;
import me.botsko.prism.events.BlockStateChange;
import org.bukkit.Achievement;
@ -265,17 +266,21 @@ public final class PurpleBot {
}
configBuilder.setNickservPassword(botIdentPassword);
}
if (ssl || tls) {
if (tls) {
plugin.logInfo("Enabling TLS ...");
configBuilder.addCapHandler(new TLSCapHandler());
} else if (ssl) {
UtilSSLSocketFactory socketFactory = new UtilSSLSocketFactory();
socketFactory.disableDiffieHellman();
if (trustAllCerts) {
plugin.logInfo("Enabling SSL and trusting all certificates ...");
socketFactory.trustAllCertificates();
} else {
plugin.logInfo("Enabling SSL ...");
}
configBuilder.setSocketFactory(socketFactory);
if (tls) {
configBuilder.addCapHandler(new TLSCapHandler(socketFactory, true));
}
}
if (charSet.isEmpty()) {
if (!reload) {
plugin.logInfo("Using default character set: " + Charset.defaultCharset());
@ -634,8 +639,8 @@ public final class PurpleBot {
try {
config.load(file);
autoConnect = config.getBoolean("autoconnect", true);
ssl = config.getBoolean("ssl", false);
tls = config.getBoolean("tls", false);
ssl = config.getBoolean("ssl", false);
trustAllCerts = config.getBoolean("trust-all-certs", false);
sendRawMessageOnConnect = config.getBoolean("raw-message-on-connect", false);
rawMessage = config.getString("raw-message", "");

View File

@ -17,10 +17,10 @@ realname: ''
server: irc.excample.com
# port - IRC server port
port: 6667
# Enable TLS support via STARTTLS. Must connect to non-SSL port to use this.
tls: false
# Attempt ssl connection to IRC server
ssl: false
# Enable TLS support
tls: false
# Trust all SSL certs
trust-all-certs: false
# Bind address