From d5d21e26157f7a5821a68f53e043ad88b150fca3 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 20 Jul 2016 15:03:48 +0300 Subject: xmpp: banned_hosts --- juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java | 7 ++++++- juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'juick-www') diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java b/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java index 7181f1c2..3b3c0316 100644 --- a/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java +++ b/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java @@ -55,8 +55,13 @@ public class ConnectionIn extends Connection implements Runnable { throw new Exception("STREAM FROM ? " + streamID + " INVALID FIRST PACKET"); } boolean xmppversionnew = parser.getAttributeValue(null, "version") != null; + String from = parser.getAttributeValue(null, "from"); - sendOpenStream(parser.getAttributeValue(null, "from"), xmppversionnew); + if (xmpp.bannedHosts.contains(from)) { + closeConnection(); + return; + } + sendOpenStream(from, xmppversionnew); while (parser.next() != XmlPullParser.END_DOCUMENT) { updateTsRemoteData(); diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java b/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java index d0b231e2..4fb40e23 100644 --- a/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java +++ b/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java @@ -46,6 +46,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe public String keystore; public String keystorePassword; public List brokenSSLhosts; + public List bannedHosts; final List inConnections = Collections.synchronizedList(new ArrayList<>()); final List outConnections = Collections.synchronizedList(new ArrayList<>()); final List outCache = Collections.synchronizedList(new ArrayList<>()); @@ -182,6 +183,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe keystore = conf.getProperty("keystore"); keystorePassword = conf.getProperty("keystore_password"); brokenSSLhosts = Arrays.asList(conf.getProperty("broken_ssl_hosts", "").split(",")); + bannedHosts = Arrays.asList(conf.getProperty("banned_hosts", "").split(",")); DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName(conf.getProperty("datasource_driver", "com.mysql.jdbc.Driver")); dataSource.setUrl(conf.getProperty("datasource_url")); -- cgit v1.2.3