BuilderScope

abstract class BuilderScope(source)

A DSL builder scope for creating TorConfig.

e.g. (Kotlin)

val config = TorConfig.Builder {

    TorOption.DisableNetwork.configure(true)

    TorOption.DataDirectory.configure("/path/to/data".toFile())

    TorOption.__SocksPort.configure {
        port(9055.toPortEphemeral())
        flagsSocks {
            OnionTrafficOnly = true
            PreferIPv6 = true
        }
    }

    try {
        TorOption.__TransPort.tryConfigure {
            auto()
            flagsIsolation {
                IsolateClientProtocol = true
            }
        }
    } catch(_: UnsupportedOperationException) {
        // recover
    }

    put(somePreDefinedTorSetting)
}

e.g. (Java)

TorConfig config = TorConfig.Builder(c -> {

    c.configure(TorOption.DisableNetwork.INSTANCE, true);

    c.configure(TorOption.DataDirectory.INSTANCE, new File("/path/to/data"));

    c.configure(TorOption.__SocksPort.INSTANCE, b -> {
        b.port(Port.Ephemeral.get(9055));
        b.flagsSocks(f -> {
            f.OnionTrafficOnly = true;
            f.PreferIPv6 = true;
        });
    });

    try {
        c.tryConfigure(TorOption.TransPort.INSTANCE, b -> {
            b.auto();
            b.flagsIsolation(f -> {
                f.IsolateClientProtocol = true;
            });
        });
    } catch (UnsupportedOperationException e) {
        // recover
    }

    c.put(somePreDefinedTorSetting);
});

See also

Types

Link copied to clipboard
protected object Companion

Functions

Link copied to clipboard

Configures a TorOption which implements the ConfigureBoolean contract type, adding the resultant TorSetting to BuilderScope.

Configures a TorOption which implements the ConfigureBuildable contract type for TorSetting.BuilderScope of type B, adding the resultant TorSetting to BuilderScope.

Configures a TorOption which implements the ConfigureDirectory contract type, adding the resultant TorSetting to BuilderScope.

Configures a TorOption which implements the ConfigureFile contract type, adding the resultant TorSetting to BuilderScope.

Configures a TorOption which implements the ConfigureIntervalMsec contract type, adding the resultant TorSetting to BuilderScope.

Configures a TorOption which implements the ConfigureInterval contract type, adding the resultant TorSetting to BuilderScope.

Link copied to clipboard
abstract fun put(setting: TorSetting): TorConfig.BuilderScope

Add an already configured TorSetting to BuilderScope.

Link copied to clipboard
fun putAll(setting: Collection<TorSetting>): TorConfig.BuilderScope

Add already configured TorSetting to BuilderScope.

Link copied to clipboard

Configures a TorOption which implements the ConfigureBuildableTry contract type for TorSetting.BuilderScope of type B, adding the resultant TorSetting to BuilderScope.