1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00

Add support for proxying HTTP requests (#1461)

This commit is contained in:
Drew Edwards 2023-06-06 19:58:24 +01:00 committed by GitHub
parent d45f2bfe80
commit c91bb5ac33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 251 additions and 25 deletions

View File

@ -83,6 +83,8 @@ kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core",
kotlin-platform = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
netty-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }
netty-socks = { module = "io.netty:netty-codec-socks", version.ref = "netty" }
netty-proxy = { module = "io.netty:netty-handler-proxy", version.ref = "netty" }
nightConfig-core = { module = "com.electronwill.night-config:core", version.ref = "nightConfig" }
nightConfig-toml = { module = "com.electronwill.night-config:toml", version.ref = "nightConfig" }
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }

View File

@ -45,6 +45,9 @@ The maximum size (in bytes) that a computer can upload in a single request. This
config.setComment("max_websocket_message", "The maximum size (in bytes) that a computer can send or receive in one websocket packet.");
config.set("max_websocket_message", AddressRule.WEBSOCKET_MESSAGE);
config.setComment("use_proxy", "Enable use of the HTTP/SOCKS proxy if it is configured.");
config.set("use_proxy", false);
}
return config;
@ -58,6 +61,7 @@ && check(builder, "port", Number.class)
&& check(builder, "max_upload", Number.class)
&& check(builder, "max_download", Number.class)
&& check(builder, "websocket_message", Number.class)
&& check(builder, "use_proxy", Boolean.class)
&& AddressRule.parse(hostObj, port, PartialOptions.DEFAULT) != null;
}
@ -71,12 +75,14 @@ public static AddressRule parseRule(UnmodifiableConfig builder) {
var maxUpload = unboxOptLong(get(builder, "max_upload", Number.class).map(Number::longValue));
var maxDownload = unboxOptLong(get(builder, "max_download", Number.class).map(Number::longValue));
var websocketMessage = unboxOptInt(get(builder, "websocket_message", Number.class).map(Number::intValue));
var useProxy = get(builder, "use_proxy", Boolean.class);
var options = new PartialOptions(
action,
maxUpload,
maxDownload,
websocketMessage
websocketMessage,
useProxy
);
return AddressRule.parse(hostObj, port, options);

View File

@ -8,6 +8,7 @@
import javax.annotation.Nullable;
import javax.annotation.OverridingMethodsMustInvokeSuper;
import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
@ -141,6 +142,18 @@ public void pop() {
* @param onChange The function to run on change.
* @return The built config file.
*/
public abstract ConfigFile build(Runnable onChange);
public abstract ConfigFile build(ConfigListener onChange);
}
@FunctionalInterface
interface ConfigListener {
/**
* The function called then a config file is changed.
*
* @param path The path to the config file. This will be {@code null} when the config file does not exist on
* disk, such as when synced from a server to the client.
* @see Builder#build(ConfigListener)
*/
void onConfigChanged(@Nullable Path path);
}
}

View File

@ -5,10 +5,12 @@
package dan200.computercraft.shared.config;
import com.electronwill.nightconfig.core.UnmodifiableConfig;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.core.CoreConfig;
import dan200.computercraft.core.Logging;
import dan200.computercraft.core.apis.http.NetworkUtils;
import dan200.computercraft.core.apis.http.options.Action;
import dan200.computercraft.core.apis.http.options.ProxyType;
import dan200.computercraft.core.computer.mainthread.MainThreadConfig;
import dan200.computercraft.shared.peripheral.monitor.MonitorRenderer;
import dan200.computercraft.shared.platform.PlatformHelper;
@ -16,6 +18,8 @@
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.filter.MarkerFilter;
import javax.annotation.Nullable;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@ -49,6 +53,10 @@ public final class ConfigSpec {
public static final ConfigFile.Value<Integer> httpDownloadBandwidth;
public static final ConfigFile.Value<Integer> httpUploadBandwidth;
public static final ConfigFile.Value<ProxyType> httpProxyType;
public static final ConfigFile.Value<String> httpProxyHost;
public static final ConfigFile.Value<Integer> httpProxyPort;
public static final ConfigFile.Value<Boolean> commandBlockEnabled;
public static final ConfigFile.Value<Integer> modemRange;
public static final ConfigFile.Value<Integer> modemHighAltitudeRange;
@ -222,6 +230,30 @@ CIDR notation ("127.0.0.0/8").
builder.pop();
builder
.comment("""
Tunnels HTTP and websocket requests through a proxy server. Only affects HTTP
rules with "use_proxy" set to true (off by default).
If authentication is required for the proxy, create a "computercraft-proxy.pw"
file in the same directory as "computercraft-server.toml", containing the
username and password separated by a colon, e.g. "myuser:mypassword". For
SOCKS4 proxies only the username is required.""")
.push("proxy");
httpProxyType = builder
.comment("The type of proxy to use.")
.defineEnum("type", CoreConfig.httpProxyType);
httpProxyHost = builder
.comment("The hostname or IP address of the proxy server.")
.define("host", CoreConfig.httpProxyHost);
httpProxyPort = builder
.comment("The port of the proxy server.")
.defineInRange("port", CoreConfig.httpProxyPort, 1, 65536);
builder.pop();
builder.pop();
}
@ -339,7 +371,7 @@ CIDR notation ("127.0.0.0/8").
clientSpec = clientBuilder.build(ConfigSpec::syncClient);
}
public static void syncServer() {
public static void syncServer(@Nullable Path path) {
// General
Config.computerSpaceLimit = computerSpaceLimit.get();
Config.floppySpaceLimit = floppySpaceLimit.get();
@ -370,6 +402,13 @@ public static void syncServer() {
CoreConfig.httpMaxWebsockets = httpMaxWebsockets.get();
CoreConfig.httpDownloadBandwidth = httpDownloadBandwidth.get();
CoreConfig.httpUploadBandwidth = httpUploadBandwidth.get();
CoreConfig.httpProxyType = httpProxyType.get();
CoreConfig.httpProxyHost = httpProxyHost.get();
CoreConfig.httpProxyPort = httpProxyPort.get();
if (path != null) ProxyPasswordConfig.init(path.resolveSibling(ComputerCraftAPI.MOD_ID + "-proxy.pw"));
NetworkUtils.reloadConfig();
// Peripheral
@ -396,7 +435,7 @@ public static void syncServer() {
Config.monitorHeight = monitorHeight.get();
}
public static void syncClient() {
public static void syncClient(@Nullable Path path) {
Config.monitorRenderer = monitorRenderer.get();
Config.monitorDistance = monitorDistance.get();
Config.uploadNagDelay = uploadNagDelay.get();

View File

@ -0,0 +1,48 @@
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.shared.config;
import dan200.computercraft.core.CoreConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
record ProxyPasswordConfig(String username, String password) {
private static final Logger LOG = LoggerFactory.getLogger(ProxyPasswordConfig.class);
@Nullable
private static ProxyPasswordConfig loadFromFile(@Nullable Path path) {
if (path == null || !path.toFile().exists()) return null;
try (var br = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
var line = br.readLine();
if (line == null) return null;
var parts = line.trim().split(":", 2);
if (parts.length == 0) return null;
return new ProxyPasswordConfig(parts[0], parts.length == 2 ? parts[1] : "");
} catch (IOException e) {
LOG.error("Failed to load proxy password from {}.", path, e);
return null;
}
}
static void init(@Nullable Path path) {
var config = loadFromFile(path);
if (config == null) {
CoreConfig.httpProxyUsername = "";
CoreConfig.httpProxyPassword = "";
} else {
CoreConfig.httpProxyUsername = config.username;
CoreConfig.httpProxyPassword = config.password;
}
}
}

View File

@ -21,6 +21,8 @@ dependencies {
implementation(libs.guava)
implementation(libs.jzlib)
implementation(libs.netty.http)
implementation(libs.netty.socks)
implementation(libs.netty.proxy)
implementation(libs.slf4j)
implementation(libs.asm)

View File

@ -6,6 +6,7 @@
import dan200.computercraft.core.apis.http.options.Action;
import dan200.computercraft.core.apis.http.options.AddressRule;
import dan200.computercraft.core.apis.http.options.ProxyType;
import java.util.List;
import java.util.OptionalInt;
@ -34,4 +35,9 @@ private CoreConfig() {
public static int httpMaxWebsockets = 4;
public static int httpDownloadBandwidth = 32 * 1024 * 1024;
public static int httpUploadBandwidth = 32 * 1024 * 1024;
public static ProxyType httpProxyType = ProxyType.HTTP;
public static String httpProxyHost = "";
public static int httpProxyPort = 8080;
public static String httpProxyUsername = "";
public static String httpProxyPassword = "";
}

View File

@ -4,6 +4,7 @@
package dan200.computercraft.core.apis.http;
import com.google.common.base.Strings;
import dan200.computercraft.core.CoreConfig;
import dan200.computercraft.core.apis.http.options.Action;
import dan200.computercraft.core.apis.http.options.AddressRule;
@ -17,11 +18,16 @@
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException;
import io.netty.handler.proxy.HttpProxyHandler;
import io.netty.handler.proxy.Socks4ProxyHandler;
import io.netty.handler.proxy.Socks5ProxyHandler;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.SslHandler;
import io.netty.handler.timeout.ReadTimeoutException;
import io.netty.handler.traffic.AbstractTrafficShapingHandler;
import io.netty.handler.traffic.GlobalTrafficShapingHandler;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -32,6 +38,7 @@
import java.net.URI;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
/**
* Just a shared object for executing simple HTTP related tasks.
@ -57,8 +64,7 @@ private NetworkUtils() {
private static @Nullable SslContext sslContext;
private static boolean triedSslContext = false;
@Nullable
private static SslContext makeSslContext() {
private static @Nullable SslContext makeSslContext() {
if (triedSslContext) return sslContext;
synchronized (sslLock) {
if (triedSslContext) return sslContext;
@ -133,6 +139,66 @@ public static Options getOptions(String host, InetSocketAddress address) throws
return options;
}
/**
* Creates a proxy handler for a specific domain. Returns null if a proxy is not required for this HTTP rule, or
* throws if it is required but is not configured correctly.
* <p>
* Note, this may require a DNS lookup, and so should not be executed on the main CC thread.
*
* @param options The options for the host to be proxied.
* @param timeout The timeout for this connection. Currently only used for establishing the SSL initialisation.
* @return A consumer that takes a {@link SocketChannel} and injects the proxy handler..
* @throws HTTPRequestException If a proxy is required but not configured correctly.
*/
public static @Nullable Consumer<SocketChannel> getProxyHandler(Options options, int timeout) throws HTTPRequestException {
if (!options.useProxy) return null;
var type = CoreConfig.httpProxyType;
var host = CoreConfig.httpProxyHost;
var port = CoreConfig.httpProxyPort;
var username = CoreConfig.httpProxyUsername;
var password = CoreConfig.httpProxyPassword;
if (Strings.isNullOrEmpty(host)) {
throw new HTTPRequestException("Proxy host not configured");
}
var proxyAddress = new InetSocketAddress(host, port);
if (proxyAddress.isUnresolved()) throw new HTTPRequestException("Unknown proxy host");
return switch (type) {
case HTTP -> ch -> ch.pipeline().addLast(new HttpProxyHandler(proxyAddress, username, password));
case HTTPS -> {
var sslContext = getSslContext();
yield ch -> {
var p = ch.pipeline();
// If we're using an HTTPS proxy, we need to add an SSL handler for the proxy too.
p.addLast(makeSslHandler(ch, sslContext, timeout, host, port));
p.addLast(new HttpProxyHandler(proxyAddress, username, password));
};
}
case SOCKS4 -> ch -> ch.pipeline().addLast(new Socks4ProxyHandler(proxyAddress, username));
case SOCKS5 -> ch -> ch.pipeline().addLast(new Socks5ProxyHandler(proxyAddress, username, password));
};
}
/**
* Make an SSL handler for the remote host.
*
* @param ch The channel the handler will be added to.
* @param sslContext The SSL context, if present.
* @param timeout The timeout on this channel.
* @param peerHost The host to connect to.
* @param peerPort The port to connect to.
* @return The SSL handler.
* @see io.netty.handler.ssl.SslHandler
*/
private static SslHandler makeSslHandler(SocketChannel ch, @NotNull SslContext sslContext, int timeout, String peerHost, int peerPort) {
var handler = sslContext.newHandler(ch.alloc(), peerHost, peerPort);
if (timeout > 0) handler.setHandshakeTimeoutMillis(timeout);
return handler;
}
/**
* Set up some basic properties of the channel. This adds a timeout, the traffic shaping handler, and the SSL
* handler.
@ -141,19 +207,20 @@ public static Options getOptions(String host, InetSocketAddress address) throws
* @param uri The URI to connect to.
* @param socketAddress The address of the socket to connect to.
* @param sslContext The SSL context, if present.
* @param proxy The proxy handler, if present.
* @param timeout The timeout on this channel.
* @see io.netty.channel.ChannelInitializer
*/
public static void initChannel(SocketChannel ch, URI uri, InetSocketAddress socketAddress, @Nullable SslContext sslContext, int timeout) {
public static void initChannel(SocketChannel ch, URI uri, InetSocketAddress socketAddress, @Nullable SslContext sslContext, @Nullable Consumer<SocketChannel> proxy, int timeout) {
if (timeout > 0) ch.config().setConnectTimeoutMillis(timeout);
var p = ch.pipeline();
p.addLast(SHAPING_HANDLER);
if (proxy != null) proxy.accept(ch);
if (sslContext != null) {
var handler = sslContext.newHandler(ch.alloc(), uri.getHost(), socketAddress.getPort());
if (timeout > 0) handler.setHandshakeTimeoutMillis(timeout);
p.addLast(handler);
p.addLast(makeSslHandler(ch, sslContext, timeout, uri.getHost(), socketAddress.getPort()));
}
}

View File

@ -4,6 +4,7 @@
package dan200.computercraft.core.apis.http.options;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.OptionalLong;
@ -12,7 +13,7 @@ public enum Action {
DENY;
private final PartialOptions partial = new PartialOptions(
this, OptionalLong.empty(), OptionalLong.empty(), OptionalInt.empty()
this, OptionalLong.empty(), OptionalLong.empty(), OptionalInt.empty(), Optional.empty()
);
public PartialOptions toPartial() {

View File

@ -13,11 +13,13 @@ public final class Options {
public final long maxUpload;
public final long maxDownload;
public final int websocketMessage;
public final boolean useProxy;
Options(Action action, long maxUpload, long maxDownload, int websocketMessage) {
Options(Action action, long maxUpload, long maxDownload, int websocketMessage, boolean useProxy) {
this.action = action;
this.maxUpload = maxUpload;
this.maxDownload = maxDownload;
this.websocketMessage = websocketMessage;
this.useProxy = useProxy;
}
}

View File

@ -7,28 +7,31 @@
import com.google.errorprone.annotations.Immutable;
import javax.annotation.Nullable;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.OptionalLong;
@Immutable
public final class PartialOptions {
public static final PartialOptions DEFAULT = new PartialOptions(
null, OptionalLong.empty(), OptionalLong.empty(), OptionalInt.empty()
null, OptionalLong.empty(), OptionalLong.empty(), OptionalInt.empty(), Optional.empty()
);
private final @Nullable Action action;
private final OptionalLong maxUpload;
private final OptionalLong maxDownload;
private final OptionalInt websocketMessage;
private final Optional<Boolean> useProxy;
@SuppressWarnings("Immutable") // Lazily initialised, so this mutation is invisible in the public API
private @Nullable Options options;
public PartialOptions(@Nullable Action action, OptionalLong maxUpload, OptionalLong maxDownload, OptionalInt websocketMessage) {
public PartialOptions(@Nullable Action action, OptionalLong maxUpload, OptionalLong maxDownload, OptionalInt websocketMessage, Optional<Boolean> useProxy) {
this.action = action;
this.maxUpload = maxUpload;
this.maxDownload = maxDownload;
this.websocketMessage = websocketMessage;
this.useProxy = useProxy;
}
Options toOptions() {
@ -38,7 +41,8 @@ Options toOptions() {
action == null ? Action.DENY : action,
maxUpload.orElse(AddressRule.MAX_UPLOAD),
maxDownload.orElse(AddressRule.MAX_DOWNLOAD),
websocketMessage.orElse(AddressRule.WEBSOCKET_MESSAGE)
websocketMessage.orElse(AddressRule.WEBSOCKET_MESSAGE),
useProxy.orElse(false)
);
}
@ -56,7 +60,8 @@ PartialOptions merge(PartialOptions other) {
action == null && other.action != null ? other.action : action,
maxUpload.isPresent() ? maxUpload : other.maxUpload,
maxDownload.isPresent() ? maxDownload : other.maxDownload,
websocketMessage.isPresent() ? websocketMessage : other.websocketMessage
websocketMessage.isPresent() ? websocketMessage : other.websocketMessage,
useProxy.isPresent() ? useProxy : other.useProxy
);
}
}

View File

@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.core.apis.http.options;
/**
* The type of proxy to use for HTTP requests.
*
* @see dan200.computercraft.core.apis.http.NetworkUtils#getProxyHandler(Options, int)
* @see dan200.computercraft.core.CoreConfig#httpProxyType
*/
public enum ProxyType {
HTTP,
HTTPS,
SOCKS4,
SOCKS5
}

View File

@ -124,6 +124,7 @@ private void doRequest(URI uri, HttpMethod method) {
var socketAddress = NetworkUtils.getAddress(uri, ssl);
var options = NetworkUtils.getOptions(uri.getHost(), socketAddress);
var sslContext = ssl ? NetworkUtils.getSslContext() : null;
var proxy = NetworkUtils.getProxyHandler(options, timeout);
// getAddress may have a slight delay, so let's perform another cancellation check.
if (isClosed()) return;
@ -145,7 +146,7 @@ private void doRequest(URI uri, HttpMethod method) {
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
NetworkUtils.initChannel(ch, uri, socketAddress, sslContext, timeout);
NetworkUtils.initChannel(ch, uri, socketAddress, sslContext, proxy, timeout);
var p = ch.pipeline();
if (timeout > 0) p.addLast(new ReadTimeoutHandler(timeout, TimeUnit.MILLISECONDS));

View File

@ -117,6 +117,7 @@ private void doConnect() {
var socketAddress = NetworkUtils.getAddress(uri, ssl);
var options = NetworkUtils.getOptions(uri.getHost(), socketAddress);
var sslContext = ssl ? NetworkUtils.getSslContext() : null;
var proxy = NetworkUtils.getProxyHandler(options, timeout);
// getAddress may have a slight delay, so let's perform another cancellation check.
if (isClosed()) return;
@ -127,7 +128,7 @@ private void doConnect() {
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
NetworkUtils.initChannel(ch, uri, socketAddress, sslContext, timeout);
NetworkUtils.initChannel(ch, uri, socketAddress, sslContext, proxy, timeout);
var subprotocol = headers.get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL);
var handshaker = new NoOriginWebSocketHandshaker(

View File

@ -54,6 +54,8 @@ dependencies {
include(libs.cobalt)
include(libs.jzlib)
include(libs.netty.http)
include(libs.netty.socks)
include(libs.netty.proxy)
include(libs.nightConfig.core)
include(libs.nightConfig.toml)
@ -65,6 +67,8 @@ dependencies {
// in our POM, and this is the easiest way.
runtimeOnly(libs.cobalt)
runtimeOnly(libs.netty.http)
runtimeOnly(libs.netty.socks)
runtimeOnly(libs.netty.proxy)
annotationProcessorEverywhere(libs.autoService)

View File

@ -34,11 +34,11 @@ public class FabricConfigFile implements ConfigFile {
private final ConfigSpec spec;
private final Trie<String, Entry> entries;
private final Runnable onChange;
private final ConfigListener onChange;
private @Nullable CommentedFileConfig config;
public FabricConfigFile(ConfigSpec spec, Trie<String, Entry> entries, Runnable onChange) {
public FabricConfigFile(ConfigSpec spec, Trie<String, Entry> entries, ConfigListener onChange) {
this.spec = spec;
this.entries = entries;
this.onChange = onChange;
@ -95,7 +95,7 @@ private synchronized boolean loadConfig() {
LOG.warn("Incorrect key {} was corrected from {} to {}", String.join(".", entryPath), oldValue, newValue);
});
onChange.run();
onChange.onConfigChanged(config.getNioPath());
return corrected > 0;
}
@ -204,7 +204,7 @@ public <V extends Enum<V>> Value<V> defineEnum(String path, V defaultValue) {
}
@Override
public ConfigFile build(Runnable onChange) {
public ConfigFile build(ConfigListener onChange) {
return new FabricConfigFile(spec, entries, onChange);
}
}

View File

@ -147,6 +147,14 @@ dependencies {
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
isTransitive = false
}
minecraftEmbed(libs.netty.socks) {
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
isTransitive = false
}
minecraftEmbed(libs.netty.proxy) {
jarJar.ranged(this, "[${libs.versions.netty.get()},)")
isTransitive = false
}
testFixturesApi(libs.bundles.test)
testFixturesApi(libs.bundles.kotlin)

View File

@ -4,6 +4,7 @@
package dan200.computercraft;
import com.electronwill.nightconfig.core.file.FileConfig;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.ForgeComputerCraftAPI;
import dan200.computercraft.api.detail.ForgeDetailRegistries;
@ -94,10 +95,12 @@ public static void sync(ModConfigEvent.Reloading event) {
private static void syncConfig(ModConfig config) {
if (!config.getModId().equals(ComputerCraftAPI.MOD_ID)) return;
var path = config.getConfigData() instanceof FileConfig fileConfig ? fileConfig.getNioPath() : null;
if (config.getType() == ModConfig.Type.SERVER && ((ForgeConfigFile) ConfigSpec.serverSpec).spec().isLoaded()) {
ConfigSpec.syncServer();
ConfigSpec.syncServer(path);
} else if (config.getType() == ModConfig.Type.CLIENT) {
ConfigSpec.syncClient();
ConfigSpec.syncClient(path);
}
}
}

View File

@ -117,7 +117,7 @@ public <V extends Enum<V>> ConfigFile.Value<V> defineEnum(String path, V default
}
@Override
public ConfigFile build(Runnable onChange) {
public ConfigFile build(ConfigListener onChange) {
var spec = builder.build();
entries.stream().forEach(x -> {
if (x instanceof ValueImpl<?> value) value.owner = spec;