mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-28 01:52:26 -06:00
172 lines
7.3 KiB
Java
172 lines
7.3 KiB
Java
package okhttp3.internal;
|
|
|
|
import io.sentry.SentryLockReason;
|
|
import java.net.IDN;
|
|
import java.net.InetAddress;
|
|
import java.util.Locale;
|
|
import kotlin.Metadata;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.text.StringsKt;
|
|
import okio.Buffer;
|
|
|
|
/* compiled from: hostnames.kt */
|
|
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000&\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0012\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\u001a0\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\u0005H\u0002\u001a\"\u0010\n\u001a\u0004\u0018\u00010\u000b2\u0006\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u0005H\u0002\u001a\u0010\u0010\f\u001a\u00020\u00032\u0006\u0010\u0007\u001a\u00020\bH\u0002\u001a\f\u0010\r\u001a\u00020\u0001*\u00020\u0003H\u0002\u001a\f\u0010\u000e\u001a\u0004\u0018\u00010\u0003*\u00020\u0003¨\u0006\u000f"}, d2 = {"decodeIpv4Suffix", "", "input", "", "pos", "", "limit", SentryLockReason.JsonKeys.ADDRESS, "", "addressOffset", "decodeIpv6", "Ljava/net/InetAddress;", "inet6AddressToAscii", "containsInvalidHostnameAsciiCodes", "toCanonicalHost", "okhttp"}, k = 2, mv = {1, 4, 0})
|
|
/* loaded from: classes3.dex */
|
|
public final class HostnamesKt {
|
|
public static final String toCanonicalHost(String toCanonicalHost) {
|
|
InetAddress decodeIpv6;
|
|
Intrinsics.checkNotNullParameter(toCanonicalHost, "$this$toCanonicalHost");
|
|
if (StringsKt.contains$default((CharSequence) toCanonicalHost, (CharSequence) ":", false, 2, (Object) null)) {
|
|
if (StringsKt.startsWith$default(toCanonicalHost, "[", false, 2, (Object) null) && StringsKt.endsWith$default(toCanonicalHost, "]", false, 2, (Object) null)) {
|
|
decodeIpv6 = decodeIpv6(toCanonicalHost, 1, toCanonicalHost.length() - 1);
|
|
} else {
|
|
decodeIpv6 = decodeIpv6(toCanonicalHost, 0, toCanonicalHost.length());
|
|
}
|
|
if (decodeIpv6 == null) {
|
|
return null;
|
|
}
|
|
byte[] address = decodeIpv6.getAddress();
|
|
if (address.length == 16) {
|
|
Intrinsics.checkNotNullExpressionValue(address, "address");
|
|
return inet6AddressToAscii(address);
|
|
}
|
|
if (address.length == 4) {
|
|
return decodeIpv6.getHostAddress();
|
|
}
|
|
throw new AssertionError("Invalid IPv6 address: '" + toCanonicalHost + '\'');
|
|
}
|
|
try {
|
|
String ascii = IDN.toASCII(toCanonicalHost);
|
|
Intrinsics.checkNotNullExpressionValue(ascii, "IDN.toASCII(host)");
|
|
Locale locale = Locale.US;
|
|
Intrinsics.checkNotNullExpressionValue(locale, "Locale.US");
|
|
if (ascii == null) {
|
|
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
|
|
}
|
|
String lowerCase = ascii.toLowerCase(locale);
|
|
Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
|
|
if (lowerCase.length() != 0 && !containsInvalidHostnameAsciiCodes(lowerCase)) {
|
|
return lowerCase;
|
|
}
|
|
return null;
|
|
} catch (IllegalArgumentException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static final boolean containsInvalidHostnameAsciiCodes(String str) {
|
|
int length = str.length();
|
|
for (int i = 0; i < length; i++) {
|
|
char charAt = str.charAt(i);
|
|
if (Intrinsics.compare((int) charAt, 31) <= 0 || Intrinsics.compare((int) charAt, 127) >= 0 || StringsKt.indexOf$default((CharSequence) " #%/:?@[\\]", charAt, 0, false, 6, (Object) null) != -1) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:31:0x0097, code lost:
|
|
|
|
if (r13 == 16) goto L46;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:32:0x0099, code lost:
|
|
|
|
if (r14 != (-1)) goto L45;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:33:0x009b, code lost:
|
|
|
|
return null;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:34:0x009c, code lost:
|
|
|
|
r0 = r13 - r14;
|
|
java.lang.System.arraycopy(r9, r14, r9, 16 - r0, r0);
|
|
java.util.Arrays.fill(r9, r14, (16 - r13) + r14, (byte) 0);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:36:0x00ae, code lost:
|
|
|
|
return java.net.InetAddress.getByAddress(r9);
|
|
*/
|
|
/* JADX WARN: Removed duplicated region for block: B:15:0x006b */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
private static final java.net.InetAddress decodeIpv6(java.lang.String r18, int r19, int r20) {
|
|
/*
|
|
Method dump skipped, instructions count: 175
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.HostnamesKt.decodeIpv6(java.lang.String, int, int):java.net.InetAddress");
|
|
}
|
|
|
|
private static final boolean decodeIpv4Suffix(String str, int i, int i2, byte[] bArr, int i3) {
|
|
int i4 = i3;
|
|
while (i < i2) {
|
|
if (i4 == bArr.length) {
|
|
return false;
|
|
}
|
|
if (i4 != i3) {
|
|
if (str.charAt(i) != '.') {
|
|
return false;
|
|
}
|
|
i++;
|
|
}
|
|
int i5 = i;
|
|
int i6 = 0;
|
|
while (i5 < i2) {
|
|
char charAt = str.charAt(i5);
|
|
if (Intrinsics.compare((int) charAt, 48) < 0 || Intrinsics.compare((int) charAt, 57) > 0) {
|
|
break;
|
|
}
|
|
if ((i6 == 0 && i != i5) || (i6 = ((i6 * 10) + charAt) - 48) > 255) {
|
|
return false;
|
|
}
|
|
i5++;
|
|
}
|
|
if (i5 - i == 0) {
|
|
return false;
|
|
}
|
|
bArr[i4] = (byte) i6;
|
|
i4++;
|
|
i = i5;
|
|
}
|
|
return i4 == i3 + 4;
|
|
}
|
|
|
|
private static final String inet6AddressToAscii(byte[] bArr) {
|
|
int i = -1;
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
int i4 = 0;
|
|
while (i3 < bArr.length) {
|
|
int i5 = i3;
|
|
while (i5 < 16 && bArr[i5] == 0 && bArr[i5 + 1] == 0) {
|
|
i5 += 2;
|
|
}
|
|
int i6 = i5 - i3;
|
|
if (i6 > i4 && i6 >= 4) {
|
|
i = i3;
|
|
i4 = i6;
|
|
}
|
|
i3 = i5 + 2;
|
|
}
|
|
Buffer buffer = new Buffer();
|
|
while (i2 < bArr.length) {
|
|
if (i2 == i) {
|
|
buffer.writeByte(58);
|
|
i2 += i4;
|
|
if (i2 == 16) {
|
|
buffer.writeByte(58);
|
|
}
|
|
} else {
|
|
if (i2 > 0) {
|
|
buffer.writeByte(58);
|
|
}
|
|
buffer.writeHexadecimalUnsignedLong((Util.and(bArr[i2], 255) << 8) | Util.and(bArr[i2 + 1], 255));
|
|
i2 += 2;
|
|
}
|
|
}
|
|
return buffer.readUtf8();
|
|
}
|
|
}
|