package com.ifpdos.autotest.k0.b;

import com.ifpdos.autotest.k0.d.f;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/* JADX INFO: compiled from: AbstractTCPConnector.java */
/* JADX INFO: loaded from: classes.dex */
public class a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private int f2018a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private com.ifpdos.autotest.m0.a f2019b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private EventLoopGroup f2020c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private EventLoopGroup f2021d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private ServerBootstrap f2022e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private Channel f2023f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private f f2024g;

    public a(int i, com.ifpdos.autotest.m0.a aVar) {
        this.f2018a = i;
        this.f2019b = aVar;
    }

    private void a() {
        if (this.f2024g != null) {
            this.f2024g = null;
        }
    }

    public void b() {
        this.f2020c = new NioEventLoopGroup();
        this.f2021d = new NioEventLoopGroup();
        if (this.f2024g == null) {
            this.f2024g = new f(this.f2019b);
        }
        ServerBootstrap serverBootstrap = new ServerBootstrap();
        this.f2022e = serverBootstrap;
        serverBootstrap.group(this.f2020c, this.f2021d).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 32).childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE).childHandler(this.f2024g);
        ChannelFuture channelFutureBind = this.f2022e.bind(this.f2018a);
        this.f2023f = channelFutureBind.channel();
        b.c.c.l.b.a("robin", "[f] " + channelFutureBind + " [c] " + channelFutureBind.channel());
    }

    public void c() {
        a();
        Channel channel = this.f2023f;
        if (channel != null) {
            channel.close();
            this.f2023f = null;
        }
        EventLoopGroup eventLoopGroup = this.f2020c;
        if (eventLoopGroup != null) {
            eventLoopGroup.shutdownGracefully();
            this.f2020c = null;
        }
        EventLoopGroup eventLoopGroup2 = this.f2021d;
        if (eventLoopGroup2 != null) {
            eventLoopGroup2.shutdownGracefully();
            this.f2021d = null;
        }
        this.f2022e = null;
    }
}
