From 466b4fee8591e10d39deffb488e2a8729945706f Mon Sep 17 00:00:00 2001 From: Burzah <116982774+Burzah@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:17:12 -0700 Subject: [PATCH 1/5] proxyDaemon initial commit --- .../aa07/paradise/taskdaemon/core/Core.java | 16 ++ .../taskdaemon/core/config/ConfigHolder.java | 1 + .../taskdaemon/core/config/PfsenseConfig.java | 6 + .../modules/aclcleanup/AclCleanupJob.java | 175 ++++++++++++++++++ config.toml.example | 4 + 5 files changed, 202 insertions(+) create mode 100644 TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/PfsenseConfig.java create mode 100644 TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java index 25366a4..2508240 100644 --- a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java @@ -5,6 +5,7 @@ import java.util.Optional; import me.aa07.paradise.taskdaemon.core.config.ConfigHolder; import me.aa07.paradise.taskdaemon.core.database.DbCore; +import me.aa07.paradise.taskdaemon.core.modules.aclcleanup.AclCleanupJob; import me.aa07.paradise.taskdaemon.core.modules.bouncerrestart.BouncerRestartJob; import me.aa07.paradise.taskdaemon.core.modules.ip2asn.Ip2AsnJob; import me.aa07.paradise.taskdaemon.core.modules.profilercleanup.ProfilerCleanupJob; @@ -121,11 +122,26 @@ private void setupJobs(Scheduler scheduler, DbCore dbCore, ConfigHolder config, .withSchedule(CronScheduleBuilder.cronSchedule("0 0 8 * * ?")) // Every day - 8AM .build(); + // ACL cleanup + JobDataMap jdm_aclcleanup = new JobDataMap(); + jdm_aclcleanup.put("LOGGER", logger); + jdm_aclcleanup.put("DBCORE", dbCore); + jdm_aclcleanup.put("PFSENSE_CFG", config.pfsense); + JobDetail jd_aclcleanup = JobBuilder.newJob(AclCleanupJob.class) + .withIdentity("aclcleanup", "aclcleanup") + .usingJobData(jdm_aclcleanup) + .build(); + CronTrigger ct_aclcleanup = TriggerBuilder.newTrigger() + .withIdentity("aclcleanup", "aclcleanup") + .withSchedule(CronScheduleBuilder.cronSchedule("0 */10 * * * ?")) + .build(); + // Schedule all scheduler.scheduleJob(jd_bouncerrestart, ct_bouncerrestart); scheduler.scheduleJob(jd_ip2asn, ct_ip2asn); scheduler.scheduleJob(jd_profilercleanup, ct_profilercleanup); + scheduler.scheduleJob(jd_aclcleanup, ct_aclcleanup); } private void launchAll() { diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java index df7c442..fd230b0 100644 --- a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java @@ -6,4 +6,5 @@ public class ConfigHolder { public DatabaseConfig profilerDatabase; public RedisConfig redis; public TgsConfig tgs; + public PfsenseConfig pfsense; } diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/PfsenseConfig.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/PfsenseConfig.java new file mode 100644 index 0000000..8d05331 --- /dev/null +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/PfsenseConfig.java @@ -0,0 +1,6 @@ +package me.aa07.paradise.taskdaemon.core.config; + +public class PfsenseConfig{ + public String host; + public int port; +} diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java new file mode 100644 index 0000000..3dfd5e4 --- /dev/null +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java @@ -0,0 +1,175 @@ +package me.aa07.paradise.taskdaemon.core.modules.aclcleanup; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import me.aa07.paradise.taskdaemon.core.config.PfsenseConfig; +import me.aa07.paradise.taskdaemon.core.database.DatabaseType; +import me.aa07.paradise.taskdaemon.core.database.DbCore; +import me.aa07.paradise.taskdaemon.database.gamedb.Tables; +import org.apache.logging.log4j.Logger; +import org.jooq.DSLContext; +import org.quartz.Job; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +public class AclCleanupJob implements Job { + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + JobDataMap datamap = context.getMergedJobDataMap(); + + // Get our logger - important + Object raw_logger = datamap.get("LOGGER"); + Optional logger_holder = Optional.empty(); + + if (raw_logger instanceof Logger l2) { + logger_holder = Optional.of(l2); + } + + if (!logger_holder.isPresent()) { + System.out.println("[AclCleanup] LOGGER WAS SOMEHOW NULL - THIS IS VERY BAD"); + return; + } + + Logger logger = logger_holder.get(); + + // Now get our DB + Object raw_db = datamap.get("DBCORE"); + Optional dbcore_holder = Optional.empty(); + + if (raw_db instanceof DbCore db2) { + dbcore_holder = Optional.of(db2); + } + + if (!dbcore_holder.isPresent()) { + logger.error("[AclCleanup] DBCORE WAS SOMEHOW NULL - THIS IS VERY BAD"); + return; + } + + DbCore dbcore = dbcore_holder.get(); + + Object raw_pfs_cfg = datamap.get("PFSENSE_CFG"); + Optional pfs_cfg_holder = Optional.empty(); + + if (raw_pfs_cfg instanceof PfsenseConfig pfsCfg) { + pfs_cfg_holder = Optional.of(pfsCfg); + } + + if (pfs_cfg_holder.isEmpty()) { + logger.error("[AclCleanup] PFSENSE_CFG WAS SOMEHOW NULL - THIS IS VERY BAD"); + return; + } + + PfsenseConfig pfs_cfg = pfs_cfg_holder.get(); + + try { + List current_acl_ips = fetchAcl(logger, pfs_cfg); + logger.info("IPs in ACL ({}): {}", current_acl_ips.size(), String.join(" ", current_acl_ips)); + + List ips_to_remove = checkIpsInDatabase(current_acl_ips, logger, dbcore); + + if (ips_to_remove.isEmpty()) { + logger.info("No IPs to remove from ACL"); + } else { + logger.info("IPs to remove from ACL ({}): {}", ips_to_remove.size(), String.join(" ", ips_to_remove)); + + for (String ip : ips_to_remove) { + removeIpFromAcl(ip, logger, pfs_cfg); + } + + logger.info("Removed {} IPs from ACL", ips_to_remove.size()); + } + + List updated_acl_ips = fetchAcl(logger, pfs_cfg); + logger.info("IPs now in ACL ({}): {}", updated_acl_ips.size(), String.join(" ", updated_acl_ips)); + + } catch (IOException e) { + logger.error("Error in AclCleanupJob!"); + logger.error(e); + } + } + + public void removeIpFromAcl(String ip, Logger logger, PfsenseConfig cfg) throws IOException { + logger.info("Removing {} from ACL", ip); + + Socket socket = new Socket(cfg.host, cfg.port); + OutputStream out = socket.getOutputStream(); + + String command = "del acl #1 " + ip + "\n"; + out.write(command.getBytes("ascii")); + + socket.close(); + } + + public List fetchAcl(Logger logger, PfsenseConfig cfg) throws IOException { + List ip_list = new ArrayList<>(); + + Socket socket = new Socket("10.0.0.1", 7542); + socket.setSoTimeout(10000); + + OutputStream out = socket.getOutputStream(); + InputStream in = socket.getInputStream(); + + String command = "show acl #1\n"; + out.write(command.getBytes("ascii")); + + StringBuilder retval = new StringBuilder(); + byte[] buffer = new byte[16]; + int bytes_read; + + while ((bytes_read = in.read(buffer)) != -1) { + retval.append(new String(buffer, 0, bytes_read)); + } + + socket.close(); + + String[] raw_ips = retval.toString().split("\n"); + for (String ip : raw_ips) { + if (ip.trim().isEmpty()) { + continue; + } + + String[] parts = ip.split(" "); + if (parts.length >= 2) { + ip_list.add(parts[1]); + } + } + + return ip_list; + } + + public List checkIpsInDatabase(List ips, Logger logger, DbCore dbcore) { + List to_remove = new ArrayList<>(); + + DSLContext ctx = dbcore.jooq(DatabaseType.GameDb); + LocalDateTime ten_mins_ago = dbcore.now().minusMinutes(10); + + for (String ip : ips) { + if (!ctx.fetchExists(ctx.select(Tables.PLAYER.CKEY).from(Tables.PLAYER).where(Tables.PLAYER.IP.eq(ip)))) { + logger.info("IP {} no longer in database.", ip); + to_remove.add(ip); + continue; + } + + boolean seen_in_last_10m = ctx.fetchExists( + ctx.select(Tables.PLAYER.CKEY).from(Tables.PLAYER).where(Tables.PLAYER.IP.eq(ip)) + .and(Tables.PLAYER.LASTSEEN.lt(ten_mins_ago)) + ); + + if (!seen_in_last_10m) { + logger.info("IP {} not active within last 10 minutes.", ip); + to_remove.add(ip); + } + } + + return to_remove; + } +} diff --git a/config.toml.example b/config.toml.example index 10566eb..959f868 100644 --- a/config.toml.example +++ b/config.toml.example @@ -22,3 +22,7 @@ host = "172.16.0.200" tgsHost = "http://10.0.0.30:5000" # dont put a trailing slash on the end of this username = "username_here" password = "password_here" + +[pfsense] +host = "127.0.0.1" +port = 1234 From 5f02aba5d469a3e16ec505d27d616abee0904cdf Mon Sep 17 00:00:00 2001 From: Burzah <116982774+Burzah@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:00:52 -0700 Subject: [PATCH 2/5] alphabetize and commenting --- .../aa07/paradise/taskdaemon/core/Core.java | 29 ++++---- .../modules/aclcleanup/AclCleanupJob.java | 74 +++++++++++-------- config.toml.example | 8 +- 3 files changed, 63 insertions(+), 48 deletions(-) diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java index 2508240..dea60ab 100644 --- a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java @@ -82,6 +82,20 @@ private void setupJobs(Scheduler scheduler, DbCore dbCore, ConfigHolder config, // See below for CRON format // https://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html + // ACL cleanup + JobDataMap jdm_aclcleanup = new JobDataMap(); + jdm_aclcleanup.put("LOGGER", logger); + jdm_aclcleanup.put("DBCORE", dbCore); + jdm_aclcleanup.put("PFSENSE_CFG", config.pfsense); + JobDetail jd_aclcleanup = JobBuilder.newJob(AclCleanupJob.class) + .withIdentity("aclcleanup", "aclcleanup") + .usingJobData(jdm_aclcleanup) + .build(); + CronTrigger ct_aclcleanup = TriggerBuilder.newTrigger() + .withIdentity("aclcleanup", "aclcleanup") + .withSchedule(CronScheduleBuilder.cronSchedule("0 */10 * * * ?")) + .build(); + // Bouncer restart JobDataMap jdm_bouncerrestart = new JobDataMap(); jdm_bouncerrestart.put("LOGGER", logger); @@ -122,21 +136,6 @@ private void setupJobs(Scheduler scheduler, DbCore dbCore, ConfigHolder config, .withSchedule(CronScheduleBuilder.cronSchedule("0 0 8 * * ?")) // Every day - 8AM .build(); - // ACL cleanup - JobDataMap jdm_aclcleanup = new JobDataMap(); - jdm_aclcleanup.put("LOGGER", logger); - jdm_aclcleanup.put("DBCORE", dbCore); - jdm_aclcleanup.put("PFSENSE_CFG", config.pfsense); - JobDetail jd_aclcleanup = JobBuilder.newJob(AclCleanupJob.class) - .withIdentity("aclcleanup", "aclcleanup") - .usingJobData(jdm_aclcleanup) - .build(); - CronTrigger ct_aclcleanup = TriggerBuilder.newTrigger() - .withIdentity("aclcleanup", "aclcleanup") - .withSchedule(CronScheduleBuilder.cronSchedule("0 */10 * * * ?")) - .build(); - - // Schedule all scheduler.scheduleJob(jd_bouncerrestart, ct_bouncerrestart); scheduler.scheduleJob(jd_ip2asn, ct_ip2asn); diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java index 3dfd5e4..425589a 100644 --- a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java @@ -20,8 +20,14 @@ import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; +/** + * Scheduled job that cleans up ACL by removing inactive player IPs + */ public class AclCleanupJob implements Job { + /** + * Main job execution - fetches current ACL, checks database for inactive IPs, and removes them + */ @Override public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap datamap = context.getMergedJobDataMap(); @@ -97,18 +103,40 @@ public void execute(JobExecutionContext context) throws JobExecutionException { } } - public void removeIpFromAcl(String ip, Logger logger, PfsenseConfig cfg) throws IOException { - logger.info("Removing {} from ACL", ip); + /** + * Checks which IPs should be removed from ACL based on database activity + * Removes IPs that don't exist in DB or haven't been seen in last 10 minutes + */ + public List checkIpsInDatabase(List ips, Logger logger, DbCore dbcore) { + List to_remove = new ArrayList<>(); - Socket socket = new Socket(cfg.host, cfg.port); - OutputStream out = socket.getOutputStream(); + DSLContext ctx = dbcore.jooq(DatabaseType.GameDb); + LocalDateTime ten_mins_ago = dbcore.now().minusMinutes(10); - String command = "del acl #1 " + ip + "\n"; - out.write(command.getBytes("ascii")); + for (String ip : ips) { + if (!ctx.fetchExists(ctx.select(Tables.PLAYER.CKEY).from(Tables.PLAYER).where(Tables.PLAYER.IP.eq(ip)))) { + logger.info("IP {} no longer in database.", ip); + to_remove.add(ip); + continue; + } - socket.close(); + boolean seen_in_last_10m = ctx.fetchExists( + ctx.select(Tables.PLAYER.CKEY).from(Tables.PLAYER).where(Tables.PLAYER.IP.eq(ip)) + .and(Tables.PLAYER.LASTSEEN.lt(ten_mins_ago)) + ); + + if (!seen_in_last_10m) { + logger.info("IP {} not active within last 10 minutes.", ip); + to_remove.add(ip); + } + } + + return to_remove; } + /** + * Retrieves current IP list from ACL via socket connection + */ public List fetchAcl(Logger logger, PfsenseConfig cfg) throws IOException { List ip_list = new ArrayList<>(); @@ -146,30 +174,18 @@ public List fetchAcl(Logger logger, PfsenseConfig cfg) throws IOExceptio return ip_list; } - public List checkIpsInDatabase(List ips, Logger logger, DbCore dbcore) { - List to_remove = new ArrayList<>(); - - DSLContext ctx = dbcore.jooq(DatabaseType.GameDb); - LocalDateTime ten_mins_ago = dbcore.now().minusMinutes(10); - - for (String ip : ips) { - if (!ctx.fetchExists(ctx.select(Tables.PLAYER.CKEY).from(Tables.PLAYER).where(Tables.PLAYER.IP.eq(ip)))) { - logger.info("IP {} no longer in database.", ip); - to_remove.add(ip); - continue; - } + /** + * Removes a specific IP from ACL #1 via socket command + */ + public void removeIpFromAcl(String ip, Logger logger, PfsenseConfig cfg) throws IOException { + logger.info("Removing {} from ACL", ip); - boolean seen_in_last_10m = ctx.fetchExists( - ctx.select(Tables.PLAYER.CKEY).from(Tables.PLAYER).where(Tables.PLAYER.IP.eq(ip)) - .and(Tables.PLAYER.LASTSEEN.lt(ten_mins_ago)) - ); + Socket socket = new Socket(cfg.host, cfg.port); + OutputStream out = socket.getOutputStream(); - if (!seen_in_last_10m) { - logger.info("IP {} not active within last 10 minutes.", ip); - to_remove.add(ip); - } - } + String command = "del acl #1 " + ip + "\n"; + out.write(command.getBytes("ascii")); - return to_remove; + socket.close(); } } diff --git a/config.toml.example b/config.toml.example index 959f868..94e5d48 100644 --- a/config.toml.example +++ b/config.toml.example @@ -9,6 +9,10 @@ database = "paradise_profilerdaemon" [ip2asn] host = "http://127.0.0.1:53661/v1/as/ip/" # Fill out URL - IP will be appended at the end +[pfsense] +host = "127.0.0.1" +port = 1234 + [profilerDatabase] host = "172.16.0.200" username = "myuser" @@ -22,7 +26,3 @@ host = "172.16.0.200" tgsHost = "http://10.0.0.30:5000" # dont put a trailing slash on the end of this username = "username_here" password = "password_here" - -[pfsense] -host = "127.0.0.1" -port = 1234 From 2a52ca2f3ac78b48fee16fc9f0205af7db6625a7 Mon Sep 17 00:00:00 2001 From: Burzah <116982774+Burzah@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:23:05 -0700 Subject: [PATCH 3/5] Update TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java I forgot to do this. Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> --- TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java index dea60ab..a4147b4 100644 --- a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/Core.java @@ -137,10 +137,10 @@ private void setupJobs(Scheduler scheduler, DbCore dbCore, ConfigHolder config, .build(); // Schedule all + scheduler.scheduleJob(jd_aclcleanup, ct_aclcleanup); scheduler.scheduleJob(jd_bouncerrestart, ct_bouncerrestart); scheduler.scheduleJob(jd_ip2asn, ct_ip2asn); scheduler.scheduleJob(jd_profilercleanup, ct_profilercleanup); - scheduler.scheduleJob(jd_aclcleanup, ct_aclcleanup); } private void launchAll() { From d8a20b725ca9b4f9c2ac83ffd692dc32c72e5ba2 Mon Sep 17 00:00:00 2001 From: Burzah <116982774+Burzah@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:27:38 -0700 Subject: [PATCH 4/5] alphabetize and commenting part dos --- .../me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java | 2 +- .../taskdaemon/core/modules/aclcleanup/AclCleanupJob.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java index fd230b0..d37353b 100644 --- a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/config/ConfigHolder.java @@ -3,8 +3,8 @@ public class ConfigHolder { public DatabaseConfig gameDatabase; public Ip2AsnSerivceConfig ip2asn; + public PfsenseConfig pfsense; public DatabaseConfig profilerDatabase; public RedisConfig redis; public TgsConfig tgs; - public PfsenseConfig pfsense; } diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java index 425589a..bbf358d 100644 --- a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java @@ -62,6 +62,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException { DbCore dbcore = dbcore_holder.get(); + // Get pfSense configuration Object raw_pfs_cfg = datamap.get("PFSENSE_CFG"); Optional pfs_cfg_holder = Optional.empty(); From dda20ba1865f604b7286da75080fff5a37447cef Mon Sep 17 00:00:00 2001 From: Burzah <116982774+Burzah@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:38:43 -0700 Subject: [PATCH 5/5] Update TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> --- .../taskdaemon/core/modules/aclcleanup/AclCleanupJob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java index bbf358d..41277f4 100644 --- a/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java +++ b/TaskDaemon.Core/src/me/aa07/paradise/taskdaemon/core/modules/aclcleanup/AclCleanupJob.java @@ -141,7 +141,7 @@ public List checkIpsInDatabase(List ips, Logger logger, DbCore d public List fetchAcl(Logger logger, PfsenseConfig cfg) throws IOException { List ip_list = new ArrayList<>(); - Socket socket = new Socket("10.0.0.1", 7542); + Socket socket = new Socket(cfg.host, cfg.port); socket.setSoTimeout(10000); OutputStream out = socket.getOutputStream();