package p138.p329.p362;

import com.hierynomus.smbj.common.SMBRuntimeException;
import java.io.Closeable;
import java.io.IOException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import p138.p329.p346.EnumC6222;
import p138.p329.p351.p352.C6292;
import p138.p329.p351.p352.InterfaceC6290;
import p138.p329.p351.p352.p355.C6304;
import p138.p329.p357.p358.C6326;
import p138.p329.p357.p359.C6330;
import p138.p329.p361.AbstractC6334;
import p138.p329.p361.AbstractC6335;
import p138.p329.p362.p363.C6347;
import p138.p329.p362.p363.InterfaceC6344;
import p138.p329.p362.p365.C6354;
import p138.p329.p362.p366.C6365;
import p138.p329.p362.p368.C6374;
import p138.p329.p362.p368.C6381;
import p138.p329.p362.p368.InterfaceC6379;
import p138.p329.p362.p371.p372.p373.C6417;
import p463.p481.C7162;
import p463.p481.InterfaceC7161;

/* JADX INFO: renamed from: ދ.ށ.މ.ހ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C6339 implements Closeable {

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public static final InterfaceC7161 f17682 = C7162.m10575((Class<?>) C6339.class);

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public Map<String, C6354> f17683;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public C6340 f17684;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public C6365 f17685;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public InterfaceC6379 f17686;

    public C6339() {
        C6340 c6340 = new C6340(null);
        UUID uuidRandomUUID = UUID.randomUUID();
        if (uuidRandomUUID == null) {
            throw new IllegalArgumentException("Client GUID may not be null");
        }
        c6340.f17695 = uuidRandomUUID;
        c6340.f17694 = new SecureRandom();
        c6340.f17699 = C6340.f17690 ? new C6326() : new C6330();
        c6340.f17693 = new C6304();
        c6340.f17696 = false;
        c6340.f17697 = false;
        c6340.f17698 = false;
        c6340.f17700 = 1048576;
        c6340.f17702 = 1048576;
        c6340.f17704 = 1048576;
        C6417<AbstractC6335<?>, AbstractC6334<?, ?>> c6417 = C6340.f17689;
        if (c6417 == null) {
            throw new IllegalArgumentException("Transport layer factory may not be null");
        }
        c6340.f17705 = c6417;
        long millis = C6340.f17687.toMillis(0L);
        if (millis > 2147483647L) {
            throw new IllegalArgumentException("Socket timeout should be less than 2147483647ms");
        }
        c6340.f17709 = (int) millis;
        List<EnumC6222> listAsList = Arrays.asList(EnumC6222.SMB_2_1, EnumC6222.SMB_2_0_2);
        if (listAsList == null) {
            throw new IllegalArgumentException("Dialects may not be null");
        }
        c6340.f17691.clear();
        for (EnumC6222 enumC6222 : listAsList) {
            if (enumC6222 == null) {
                throw new IllegalArgumentException("Dialect may not be null");
            }
            c6340.f17691.add(enumC6222);
        }
        ArrayList<InterfaceC6290.InterfaceC6291<InterfaceC6344>> arrayList = new ArrayList();
        if (!C6340.f17690) {
            try {
                arrayList.add((InterfaceC6290.InterfaceC6291) Class.forName("ދ.ށ.މ.ނ.ބ$ؠ").newInstance());
            } catch (ClassCastException | ClassNotFoundException | IllegalAccessException | InstantiationException e) {
                throw new SMBRuntimeException(e);
            }
        }
        arrayList.add(new C6347.C6348());
        c6340.f17692.clear();
        for (InterfaceC6290.InterfaceC6291<InterfaceC6344> interfaceC6291 : arrayList) {
            if (interfaceC6291 == null) {
                throw new IllegalArgumentException("Authenticator may not be null");
            }
            c6340.f17692.add(interfaceC6291);
        }
        TimeUnit timeUnit = C6340.f17688;
        c6340.f17701 = timeUnit.toMillis(60L);
        c6340.f17703 = timeUnit.toMillis(60L);
        c6340.f17706 = timeUnit.toMillis(60L);
        C6336 c6336 = new C6336(null);
        c6336.f17680 = true;
        c6336.f17681 = false;
        c6340.f17707 = new C6336(c6336, null);
        if (c6340.f17691.isEmpty()) {
            throw new IllegalStateException("At least one SMB dialect should be specified");
        }
        C6340 c63402 = new C6340(c6340, null);
        C6365 c6365 = new C6365();
        this.f17683 = new ConcurrentHashMap();
        this.f17684 = c63402;
        this.f17685 = c6365;
        c6365.m9587(this);
        this.f17686 = new C6381(InterfaceC6379.f17811);
        if (c63402.f17697) {
            this.f17686 = new C6374(this.f17686);
        }
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        f17682.mo10560("Going to close all remaining connections");
        for (C6354 c6354 : this.f17683.values()) {
            try {
                c6354.close();
            } catch (Exception e) {
                f17682.mo10573("Error closing connection to host {}", c6354.f17745);
                f17682.mo10563("Exception was: ", (Throwable) e);
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C6354 m9558(String str, int i) {
        synchronized (this) {
            String str2 = str + ":" + i;
            C6354 c6354 = this.f17683.get(str2);
            if (c6354 != null && c6354.f17733.getAndIncrement() <= 0) {
                c6354 = null;
            }
            if (c6354 != null && c6354.f17748.m9641()) {
                return c6354;
            }
            C6354 c63542 = new C6354(this.f17684, this, this.f17685);
            try {
                c63542.m9577(str, i);
                this.f17683.put(str2, c63542);
                return c63542;
            } catch (IOException e) {
                C6292.m9525(c63542);
                throw e;
            }
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public C6354 m9559(String str) {
        return m9558(str, 445);
    }
}
