导航菜单

页面标题

页面副标题

Top浏览器 v4.6.16 - b.java 源代码

正在查看: Top浏览器 v4.6.16 应用的 b.java JAVA 源代码文件

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


package m.e.a.d.v;

import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.nio.channels.GatheringByteChannel;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SocketChannel;
import m.e.a.d.n;

public class b implements n {
    public static final m.e.a.h.a0.c a = m.e.a.h.a0.b.a(b.class);
    public final ByteChannel b;

    public final ByteBuffer[] f5119c = new ByteBuffer[2];

    public final Socket f5120d;

    public final InetSocketAddress f5121e;

    public final InetSocketAddress f5122f;

    public volatile int f5123g;

    public volatile boolean f5124h;

    public volatile boolean f5125i;

    public b(ByteChannel byteChannel, int i2) {
        this.b = byteChannel;
        this.f5123g = i2;
        Socket socket = byteChannel instanceof SocketChannel ? ((SocketChannel) byteChannel).socket() : null;
        this.f5120d = socket;
        if (socket == null) {
            this.f5122f = null;
            this.f5121e = null;
        } else {
            this.f5121e = (InetSocketAddress) socket.getLocalSocketAddress();
            this.f5122f = (InetSocketAddress) socket.getRemoteSocketAddress();
            socket.setSoTimeout(this.f5123g);
        }
    }

    public final void A() {
        Socket socket;
        a.b("oshut {}", this);
        this.f5125i = true;
        if (!this.b.isOpen() || (socket = this.f5120d) == null) {
            return;
        }
        try {
            try {
                if (!socket.isOutputShutdown()) {
                    this.f5120d.shutdownOutput();
                }
                if (!this.f5124h) {
                    return;
                }
            } catch (SocketException e2) {
                m.e.a.h.a0.c cVar = a;
                cVar.b(e2.toString(), new Object[0]);
                cVar.g(e2);
                if (!this.f5124h) {
                    return;
                }
            }
            close();
        } catch (Throwable th) {
            if (this.f5124h) {
                close();
            }
            throw th;
        }
    }

    @Override
    public void close() {
        a.b("close {}", this);
        this.b.close();
    }

    @Override
    public String e() {
        if (this.f5120d == null) {
            return null;
        }
        InetSocketAddress inetSocketAddress = this.f5121e;
        return (inetSocketAddress == null || inetSocketAddress.getAddress() == null || this.f5121e.getAddress().isAnyLocalAddress()) ? "0.0.0.0" : this.f5121e.getAddress().getHostAddress();
    }

    @Override
    public void flush() {
    }

    @Override
    public int g() {
        return this.f5123g;
    }

    @Override
    public int getLocalPort() {
        if (this.f5120d == null) {
            return 0;
        }
        InetSocketAddress inetSocketAddress = this.f5121e;
        if (inetSocketAddress == null) {
            return -1;
        }
        return inetSocketAddress.getPort();
    }

    @Override
    public Object getTransport() {
        return this.b;
    }

    @Override
    public String h() {
        InetSocketAddress inetSocketAddress;
        if (this.f5120d == null || (inetSocketAddress = this.f5122f) == null) {
            return null;
        }
        return inetSocketAddress.getAddress().getHostAddress();
    }

    @Override
    public void i(int i2) {
        if (this.f5120d != null && i2 != this.f5123g) {
            this.f5120d.setSoTimeout(i2 > 0 ? i2 : 0);
        }
        this.f5123g = i2;
    }

    @Override
    public boolean isOpen() {
        return this.b.isOpen();
    }

    @Override
    public void j() {
        z();
    }

    @Override
    public String k() {
        if (this.f5120d == null) {
            return null;
        }
        InetSocketAddress inetSocketAddress = this.f5121e;
        return (inetSocketAddress == null || inetSocketAddress.getAddress() == null || this.f5121e.getAddress().isAnyLocalAddress()) ? "0.0.0.0" : this.f5121e.getAddress().getCanonicalHostName();
    }

    @Override
    public boolean l(long j2) {
        return true;
    }

    @Override
    public boolean m() {
        Closeable closeable = this.b;
        return !(closeable instanceof SelectableChannel) || ((SelectableChannel) closeable).isBlocking();
    }

    @Override
    public int n(m.e.a.d.e eVar, m.e.a.d.e eVar2, m.e.a.d.e eVar3) {
        m.e.a.d.e X = eVar == null ? null : eVar.X();
        m.e.a.d.e X2 = eVar2 != null ? eVar2.X() : null;
        if ((this.b instanceof GatheringByteChannel) && eVar != null && eVar.length() != 0 && (X instanceof e) && eVar2 != null && eVar2.length() != 0 && (X2 instanceof e)) {
            return x(eVar, ((e) X).t0(), eVar2, ((e) X2).t0());
        }
        int r = (eVar == null || eVar.length() <= 0) ? 0 : r(eVar);
        if ((eVar == null || eVar.length() == 0) && eVar2 != null && eVar2.length() > 0) {
            r += r(eVar2);
        }
        return ((eVar == null || eVar.length() == 0) && (eVar2 == null || eVar2.length() == 0) && eVar3 != null && eVar3.length() > 0) ? r(eVar3) + r : r;
    }

    @Override
    public boolean o() {
        Socket socket;
        return this.f5125i || !this.b.isOpen() || ((socket = this.f5120d) != null && socket.isOutputShutdown());
    }

    @Override
    public boolean p() {
        Socket socket;
        return this.f5124h || !this.b.isOpen() || ((socket = this.f5120d) != null && socket.isInputShutdown());
    }

    @Override
    public void q() {
        A();
    }

    @Override
    public int r(m.e.a.d.e eVar) {
        int write;
        m.e.a.d.e X = eVar.X();
        if (X instanceof e) {
            ByteBuffer asReadOnlyBuffer = ((e) X).t0().asReadOnlyBuffer();
            asReadOnlyBuffer.position(eVar.U());
            asReadOnlyBuffer.limit(eVar.B0());
            write = this.b.write(asReadOnlyBuffer);
            if (write > 0) {
                eVar.skip(write);
            }
        } else if (X instanceof f) {
            write = ((f) X).e(this.b, eVar.U(), eVar.length());
            if (write > 0) {
                eVar.skip(write);
            }
        } else {
            if (eVar.i0() == null) {
                throw new IOException("Not Implemented");
            }
            write = this.b.write(ByteBuffer.wrap(eVar.i0(), eVar.U(), eVar.length()));
            if (write > 0) {
                eVar.skip(write);
            }
        }
        return write;
    }

    @Override
    public boolean s(long j2) {
        return true;
    }

    @Override
    public int t(m.e.a.d.e r6) {
        throw new UnsupportedOperationException("Method not decompiled: m.e.a.d.v.b.t(m.e.a.d.e):int");
    }

    @Override
    public int v() {
        if (this.f5120d == null) {
            return 0;
        }
        InetSocketAddress inetSocketAddress = this.f5122f;
        if (inetSocketAddress == null) {
            return -1;
        }
        return inetSocketAddress.getPort();
    }

    public int x(m.e.a.d.e eVar, ByteBuffer byteBuffer, m.e.a.d.e eVar2, ByteBuffer byteBuffer2) {
        int write;
        synchronized (this) {
            ByteBuffer asReadOnlyBuffer = byteBuffer.asReadOnlyBuffer();
            asReadOnlyBuffer.position(eVar.U());
            asReadOnlyBuffer.limit(eVar.B0());
            ByteBuffer asReadOnlyBuffer2 = byteBuffer2.asReadOnlyBuffer();
            asReadOnlyBuffer2.position(eVar2.U());
            asReadOnlyBuffer2.limit(eVar2.B0());
            ByteBuffer[] byteBufferArr = this.f5119c;
            byteBufferArr[0] = asReadOnlyBuffer;
            byteBufferArr[1] = asReadOnlyBuffer2;
            write = (int) ((GatheringByteChannel) this.b).write(byteBufferArr);
            int length = eVar.length();
            if (write > length) {
                eVar.clear();
                eVar2.skip(write - length);
            } else if (write > 0) {
                eVar.skip(write);
            }
        }
        return write;
    }

    public ByteChannel y() {
        return this.b;
    }

    public final void z() {
        Socket socket;
        a.b("ishut {}", this);
        this.f5124h = true;
        if (!this.b.isOpen() || (socket = this.f5120d) == null) {
            return;
        }
        try {
            try {
                if (!socket.isInputShutdown()) {
                    this.f5120d.shutdownInput();
                }
                if (!this.f5125i) {
                    return;
                }
            } catch (SocketException e2) {
                m.e.a.h.a0.c cVar = a;
                cVar.b(e2.toString(), new Object[0]);
                cVar.g(e2);
                if (!this.f5125i) {
                    return;
                }
            }
            close();
        } catch (Throwable th) {
            if (this.f5125i) {
                close();
            }
            throw th;
        }
    }
}