refactor proxy

This commit is contained in:
Aria Moradi 2021-03-28 20:41:39 +04:30
parent e6ba2a0066
commit b1b1abad1d
3 changed files with 12 additions and 10 deletions

View File

@ -16,7 +16,7 @@ class ServerConfig(config: Config) : ConfigModule(config) {
val port: Int by config
// proxy
val socksProxy: Boolean by config
val socksProxyEnabled: Boolean by config
val socksProxyHost: String by config
val socksProxyPort: String by config

View File

@ -40,7 +40,7 @@ val androidCompat by lazy { AndroidCompat() }
fun applicationSetup() {
// register server config
GlobalConfigManager.registerModule(
ServerConfig.register(GlobalConfigManager.config)
ServerConfig.register(GlobalConfigManager.config)
)
// set application wide logging level
@ -50,10 +50,10 @@ fun applicationSetup() {
// make dirs we need
listOf(
applicationDirs.dataRoot,
applicationDirs.extensionsRoot,
"${applicationDirs.extensionsRoot}/icon",
applicationDirs.thumbnailsRoot
applicationDirs.dataRoot,
applicationDirs.extensionsRoot,
"${applicationDirs.extensionsRoot}/icon",
applicationDirs.thumbnailsRoot
).forEach {
File(it).mkdirs()
}
@ -95,7 +95,9 @@ fun applicationSetup() {
System.setProperty("org.eclipse.jetty.LEVEL", "OFF")
// socks proxy settings
System.getProperties()["proxySet"] = serverConfig.socksProxy.toString()
System.getProperties()["socksProxyHost"] = serverConfig.socksProxyHost
System.getProperties()["socksProxyPort"] = serverConfig.socksProxyPort
if (serverConfig.socksProxyEnabled) {
System.getProperties()["proxySet"] = "true"
System.getProperties()["socksProxyHost"] = serverConfig.socksProxyHost
System.getProperties()["socksProxyPort"] = serverConfig.socksProxyPort
}
}

View File

@ -3,7 +3,7 @@ server.ip = "0.0.0.0"
server.port = 4567
# Socks5 proxy
server.socksProxy = false
server.socksProxyEnabled = false
server.socksProxyHost = ""
server.socksProxyPort = ""