diff options
author | 2016-05-13 16:22:13 +0300 | |
---|---|---|
committer | 2016-05-13 16:22:13 +0300 | |
commit | 0ae572563427dcaba845b893bcef35fe7f172dd8 (patch) | |
tree | 44a1ac6e822557c77df3e537f61830c58ae0afeb /src/main/java/com/juick/xmpp/s2s/ConnectionIn.java | |
parent | 8e4ab831c7342d3fc4a7829c10152d41c3e61f1e (diff) | |
parent | c4d77b873c4deb15a968ac17998a024bd0c618d4 (diff) |
Merge branch 'rebase_all' of ssh://den.jabber.ru:2205/var/lib/git/com.juick.http.www into rebase_all
Diffstat (limited to 'src/main/java/com/juick/xmpp/s2s/ConnectionIn.java')
-rw-r--r-- | src/main/java/com/juick/xmpp/s2s/ConnectionIn.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java b/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java index 8fa773b7..554d3b05 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java @@ -46,15 +46,14 @@ public class ConnectionIn extends Connection implements Runnable { parser.next(); // stream:stream updateTsRemoteData(); if (!parser.getName().equals("stream") - || !parser.getNamespace("stream").equals(NS_STREAM) - || !parser.getNamespace("db").equals(NS_DB)) { + || !parser.getNamespace("stream").equals(NS_STREAM)) { // || !parser.getAttributeValue(null, "version").equals("1.0") // || !parser.getAttributeValue(null, "to").equals(Main.HOSTNAME)) { throw new Exception("STREAM FROM ? " + streamID + " INVALID FIRST PACKET"); } boolean xmppversionnew = parser.getAttributeValue(null, "version") != null; - sendOpenStream(xmppversionnew); + sendOpenStream(parser.getAttributeValue(null, "from"), xmppversionnew); while (parser.next() != XmlPullParser.END_DOCUMENT) { updateTsRemoteData(); @@ -85,7 +84,7 @@ public class ConnectionIn extends Connection implements Runnable { XMPPComponent.executorService.submit(c); } } else { - throw new Exception("STREAM FROM " + dfrom + " " + streamID + " DIALBACK RESULT FAIL"); + throw new HostUnknownException("STREAM FROM " + dfrom + " " + streamID + " INVALID TO " + to); } } else if (tag.equals("verify") && parser.getNamespace().equals(NS_DB)) { String vfrom = parser.getAttributeValue(null, "from"); @@ -145,7 +144,7 @@ public class ConnectionIn extends Connection implements Runnable { closeConnection(); } } else if (isSecured() && tag.equals("stream") && parser.getNamespace().equals(NS_STREAM)) { - sendOpenStream(true); + sendOpenStream(null, true); } else { LOGGER.info("STREAM " + streamID + ": " + XmlUtils.parseToString(parser, true)); } @@ -157,6 +156,8 @@ public class ConnectionIn extends Connection implements Runnable { LOGGER.info(String.format("STREAM %s CLOSED (dirty)", streamID)); XMPPComponent.removeConnectionIn(this); closeConnection(); + } catch (HostUnknownException e) { + LOGGER.warning(e.getMessage()); } catch (Exception e) { LOGGER.log(Level.WARNING, "STREAM " + streamID + " ERROR", e); XMPPComponent.removeConnectionIn(this); @@ -168,13 +169,13 @@ public class ConnectionIn extends Connection implements Runnable { tsRemoteData = System.currentTimeMillis(); } - void sendOpenStream(boolean xmppversionnew) throws IOException { + void sendOpenStream(String from, boolean xmppversionnew) throws IOException { String openStream = "<?xml version='1.0'?><stream:stream xmlns='jabber:server' " + "xmlns:stream='http://etherx.jabber.org/streams' xmlns:db='jabber:server:dialback' from='" + XMPPComponent.HOSTNAME + "' id='" + streamID + "' version='1.0'>"; if (xmppversionnew) { openStream += "<stream:features>"; - if (!isSecured()) { + if (!isSecured() && !XMPPComponent.brokenSSLhosts.contains(from)) { openStream += "<starttls xmlns=\"" + NS_TLS + "\"><optional/></starttls>"; } openStream += "</stream:features>"; @@ -211,4 +212,9 @@ public class ConnectionIn extends Connection implements Runnable { } return false; } + class HostUnknownException extends Exception { + public HostUnknownException(String message) { + super(message); + } + } } |