tryConfigure
fun <B : TorSetting.BuilderScope> ConfigureBuildableTry<B>.tryConfigure(block: ThisBlock<B>): TorConfig.BuilderScope(source)
Configures a TorOption which implements the ConfigureBuildableTry contract type for TorSetting.BuilderScope of type B, adding the resultant TorSetting to BuilderScope.
e.g.
TorConfig.Builder {
try {
TorOption.TransPort.tryConfigure {
auto()
}
} catch(_: UnsupportedOperationException) {
// Unavailable for current host
// do something else
}
// No try/catch needed because we know requirements
// for BuilderScopeHS are going to be met.
TorOption.HiddenServiceDir.tryConfigure {
directory("/path/to/this/hs/dir".toFile())
version(3)
port(virtual = Port.HTTP) {
target(port = 8080.toPort())
}
}
}
Content copied to clipboard
Throws
ClassCastException
when ConfigureBuildableTry is not an instance of TorOption.
UnsupportedOperationException
when the TorOption has host and/or environment requirements that were not met.