From e8711e997490b780825c86c6f1c148aa084274e7 Mon Sep 17 00:00:00 2001 From: LamGC Date: Sat, 16 Jul 2022 20:26:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor(meta):=20=E4=B8=BA=20ProxyConfig=20?= =?UTF-8?q?=E8=A6=86=E7=9B=96=20toString=20=E6=96=B9=E6=B3=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 覆盖 toString 方法后, 可以输出易懂的代理信息(我担心按照 data class 的格式输出, 用户可能看不懂). --- scalabot-meta/src/main/kotlin/Configs.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scalabot-meta/src/main/kotlin/Configs.kt b/scalabot-meta/src/main/kotlin/Configs.kt index 1061680..949b5f0 100644 --- a/scalabot-meta/src/main/kotlin/Configs.kt +++ b/scalabot-meta/src/main/kotlin/Configs.kt @@ -72,8 +72,16 @@ enum class ProxyType { data class ProxyConfig( val type: ProxyType = ProxyType.NO_PROXY, val host: String = "127.0.0.1", - val port: Int = 1080 -) + val port: Int = 1080, +) { + override fun toString(): String { + return if (type != ProxyType.NO_PROXY) { + "$type://$host:$port" + } else { + "NO_PROXY" + } + } +} /** * ScalaBot 的运行指标公开配置.