package io.netty.handler.codec.socksx.v4;

import g.a.a.a.a;
import io.netty.handler.codec.DecoderResult;
import io.netty.util.NetUtil;
import io.netty.util.internal.StringUtil;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class DefaultSocks4CommandResponse extends AbstractSocks4Message implements Socks4CommandResponse {
    private final String dstAddr;
    private final int dstPort;
    private final Socks4CommandStatus status;

    public DefaultSocks4CommandResponse(Socks4CommandStatus socks4CommandStatus) {
        this(socks4CommandStatus, null, 0);
    }

    public DefaultSocks4CommandResponse(Socks4CommandStatus socks4CommandStatus, String str, int i2) {
        Objects.requireNonNull(socks4CommandStatus, "cmdStatus");
        if (str != null && !NetUtil.isValidIpV4Address(str)) {
            throw new IllegalArgumentException(a.u("dstAddr: ", str, " (expected: a valid IPv4 address)"));
        }
        if (i2 < 0 || i2 > 65535) {
            throw new IllegalArgumentException(a.n("dstPort: ", i2, " (expected: 0~65535)"));
        }
        this.status = socks4CommandStatus;
        this.dstAddr = str;
        this.dstPort = i2;
    }

    @Override // io.netty.handler.codec.socksx.v4.Socks4CommandResponse
    public String dstAddr() {
        return this.dstAddr;
    }

    @Override // io.netty.handler.codec.socksx.v4.Socks4CommandResponse
    public int dstPort() {
        return this.dstPort;
    }

    @Override // io.netty.handler.codec.socksx.v4.Socks4CommandResponse
    public Socks4CommandStatus status() {
        return this.status;
    }

    public String toString() {
        String str;
        StringBuilder sb = new StringBuilder(96);
        sb.append(StringUtil.simpleClassName(this));
        DecoderResult decoderResult = decoderResult();
        if (decoderResult.isSuccess()) {
            str = "(dstAddr: ";
        } else {
            sb.append("(decoderResult: ");
            sb.append(decoderResult);
            str = ", dstAddr: ";
        }
        sb.append(str);
        sb.append(dstAddr());
        sb.append(", dstPort: ");
        sb.append(dstPort());
        sb.append(')');
        return sb.toString();
    }
}
