导航菜单

页面标题

页面副标题

bbinstant v6.24.0 - Bytestream.java 源代码

正在查看: bbinstant v6.24.0 应用的 Bytestream.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package org.jivesoftware.smackx.bytestreams.socks5.packet;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jxmpp.jid.i;

public class Bytestream extends IQ {
    public static final String ELEMENT = "query";
    public static final String NAMESPACE = "http://jabber.org/protocol/bytestreams";
    private Mode mode;
    private String sessionID;
    private final List<StreamHost> streamHosts;
    private Activate toActivate;
    private StreamHostUsed usedHost;

    static class AnonymousClass1 {
        static final int[] $SwitchMap$org$jivesoftware$smack$packet$IQ$Type;

        static {
            int[] iArr = new int[IQ.Type.values().length];
            $SwitchMap$org$jivesoftware$smack$packet$IQ$Type = iArr;
            try {
                iArr[IQ.Type.set.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$packet$IQ$Type[IQ.Type.result.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$org$jivesoftware$smack$packet$IQ$Type[IQ.Type.get.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    public static class Activate implements NamedElement {
        public static String ELEMENTNAME = "activate";
        private final i target;

        public Activate(i iVar) {
            this.target = iVar;
        }

        @Override
        public String getElementName() {
            return ELEMENTNAME;
        }

        public i getTarget() {
            return this.target;
        }

        @Override
        public XmlStringBuilder toXML() {
            XmlStringBuilder xmlStringBuilder = new XmlStringBuilder(this);
            xmlStringBuilder.rightAngleBracket();
            xmlStringBuilder.escape(getTarget());
            xmlStringBuilder.closeElement(this);
            return xmlStringBuilder;
        }
    }

    public enum Mode {
        tcp,
        udp;

        public static Mode fromName(String str) {
            try {
                return valueOf(str);
            } catch (Exception unused) {
                return tcp;
            }
        }
    }

    public static class StreamHost implements NamedElement {
        public static String ELEMENTNAME = "streamhost";
        private final i JID;
        private final String addy;
        private final int port;

        public StreamHost(i iVar, String str) {
            this(iVar, str, 0);
        }

        public String getAddress() {
            return this.addy;
        }

        @Override
        public String getElementName() {
            return ELEMENTNAME;
        }

        public i getJID() {
            return this.JID;
        }

        public int getPort() {
            return this.port;
        }

        public StreamHost(i iVar, String str, int i) {
            this.JID = (i) Objects.requireNonNull(iVar, "StreamHost JID must not be null");
            this.addy = (String) StringUtils.requireNotNullOrEmpty(str, "StreamHost address must not be null");
            this.port = i;
        }

        @Override
        public XmlStringBuilder toXML() {
            XmlStringBuilder xmlStringBuilder = new XmlStringBuilder(this);
            xmlStringBuilder.attribute(ParserUtils.JID, getJID());
            xmlStringBuilder.attribute("host", getAddress());
            if (getPort() != 0) {
                xmlStringBuilder.attribute("port", Integer.toString(getPort()));
            } else {
                xmlStringBuilder.attribute("zeroconf", "_jabber.bytestreams");
            }
            xmlStringBuilder.closeEmptyElement();
            return xmlStringBuilder;
        }
    }

    public static class StreamHostUsed implements NamedElement {
        public static String ELEMENTNAME = "streamhost-used";
        private final i JID;

        public StreamHostUsed(i iVar) {
            this.JID = iVar;
        }

        @Override
        public String getElementName() {
            return ELEMENTNAME;
        }

        public i getJID() {
            return this.JID;
        }

        @Override
        public XmlStringBuilder toXML() {
            XmlStringBuilder xmlStringBuilder = new XmlStringBuilder(this);
            xmlStringBuilder.attribute(ParserUtils.JID, getJID());
            xmlStringBuilder.closeEmptyElement();
            return xmlStringBuilder;
        }
    }

    public Bytestream() {
        super("query", NAMESPACE);
        this.mode = Mode.tcp;
        this.streamHosts = new ArrayList();
    }

    public StreamHost addStreamHost(i iVar, String str) {
        return addStreamHost(iVar, str, 0);
    }

    public int countStreamHosts() {
        return this.streamHosts.size();
    }

    @Override
    protected IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder iQChildElementXmlStringBuilder) {
        int i = AnonymousClass1.$SwitchMap$org$jivesoftware$smack$packet$IQ$Type[getType().ordinal()];
        if (i == 1) {
            iQChildElementXmlStringBuilder.optAttribute("sid", getSessionID());
            iQChildElementXmlStringBuilder.optAttribute("mode", getMode());
            iQChildElementXmlStringBuilder.rightAngleBracket();
            if (getToActivate() == null) {
                Iterator<StreamHost> it = getStreamHosts().iterator();
                while (it.hasNext()) {
                    iQChildElementXmlStringBuilder.append(it.next().toXML());
                }
            } else {
                iQChildElementXmlStringBuilder.append(getToActivate().toXML());
            }
        } else if (i == 2) {
            iQChildElementXmlStringBuilder.rightAngleBracket();
            iQChildElementXmlStringBuilder.optAppend(getUsedHost());
            Iterator<StreamHost> it2 = this.streamHosts.iterator();
            while (it2.hasNext()) {
                iQChildElementXmlStringBuilder.append(it2.next().toXML());
            }
        } else {
            if (i != 3) {
                throw new IllegalStateException();
            }
            iQChildElementXmlStringBuilder.setEmptyElement();
        }
        return iQChildElementXmlStringBuilder;
    }

    public Mode getMode() {
        return this.mode;
    }

    public String getSessionID() {
        return this.sessionID;
    }

    public StreamHost getStreamHost(i iVar) {
        if (iVar == null) {
            return null;
        }
        for (StreamHost streamHost : this.streamHosts) {
            if (streamHost.getJID().equals((CharSequence) iVar)) {
                return streamHost;
            }
        }
        return null;
    }

    public List<StreamHost> getStreamHosts() {
        return Collections.unmodifiableList(this.streamHosts);
    }

    public Activate getToActivate() {
        return this.toActivate;
    }

    public StreamHostUsed getUsedHost() {
        return this.usedHost;
    }

    public void setMode(Mode mode) {
        this.mode = mode;
    }

    public void setSessionID(String str) {
        this.sessionID = str;
    }

    public void setToActivate(i iVar) {
        this.toActivate = new Activate(iVar);
    }

    public void setUsedHost(i iVar) {
        this.usedHost = new StreamHostUsed(iVar);
    }

    public StreamHost addStreamHost(i iVar, String str, int i) {
        StreamHost streamHost = new StreamHost(iVar, str, i);
        addStreamHost(streamHost);
        return streamHost;
    }

    public Bytestream(String str) {
        this();
        setSessionID(str);
    }

    public void addStreamHost(StreamHost streamHost) {
        this.streamHosts.add(streamHost);
    }
}