Skip to content

Commit d341fef

Browse files
committed
client routes: add exclusive-proxy config flag for strict proxy enforcement
Introduces advanced.client-routes.exclusive-proxy (default: false). When false (default), the driver falls back to the node broadcast address when no client-route entry exists — preserving backward compatibility with mixed proxy/direct topologies. When true, no fallback is attempted: the node stays DOWN until a CLIENT_ROUTES_CHANGE event publishes the route. This prevents silent bypass of the proxy infrastructure during node additions.
1 parent 792d9c5 commit d341fef

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

core/src/main/java/com/datastax/oss/driver/api/core/config/DefaultDriverOption.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,22 @@ public enum DefaultDriverOption implements DriverOption {
11191119
*
11201120
* <p>Value type: boolean
11211121
*/
1122-
CLIENT_ROUTES_SHARD_AWARENESS_ENABLED("advanced.client-routes.shard-awarness-enabled");
1122+
CLIENT_ROUTES_SHARD_AWARENESS_ENABLED("advanced.client-routes.shard-awarness-enabled"),
1123+
1124+
/**
1125+
* Whether the driver connects exclusively through proxies when client routes are configured.
1126+
*
1127+
* <p>When {@code true}, any node whose {@code host_id} does not appear in the {@code
1128+
* system.client_routes} table is treated as unreachable; the driver will never fall back to the
1129+
* node's broadcast address. The node stays DOWN and the reconnection loop retries until a {@code
1130+
* CLIENT_ROUTES_CHANGE} event populates the route.
1131+
*
1132+
* <p>When {@code false} (the default), nodes that have no route entry are contacted directly
1133+
* using their broadcast address, preserving backward-compatible mixed proxy/direct topologies.
1134+
*
1135+
* <p>Value type: boolean
1136+
*/
1137+
CLIENT_ROUTES_EXCLUSIVE_PROXY("advanced.client-routes.exclusive-proxy");
11231138

11241139
private final String path;
11251140

core/src/main/java/com/datastax/oss/driver/api/core/config/OptionsMap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ protected static void fillWithDriverDefaults(OptionsMap map) {
400400
// values) with no sensible scalar default, analogous to how CONFIG_RELOAD_INTERVAL is omitted.
401401
map.put(TypedDriverOption.CLIENT_ROUTES_NATIVE_TRANSPORT_PORT, 9042);
402402
map.put(TypedDriverOption.CLIENT_ROUTES_SHARD_AWARENESS_ENABLED, false);
403+
map.put(TypedDriverOption.CLIENT_ROUTES_EXCLUSIVE_PROXY, false);
403404
}
404405

405406
@Immutable

core/src/main/java/com/datastax/oss/driver/api/core/config/TypedDriverOption.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,15 @@ public String toString() {
954954
new TypedDriverOption<>(
955955
DefaultDriverOption.CLIENT_ROUTES_SHARD_AWARENESS_ENABLED, GenericType.BOOLEAN);
956956

957+
/**
958+
* Whether the driver connects exclusively through proxies when client routes are configured. When
959+
* {@code false} (default), nodes without a route entry are contacted directly via their broadcast
960+
* address.
961+
*/
962+
public static final TypedDriverOption<Boolean> CLIENT_ROUTES_EXCLUSIVE_PROXY =
963+
new TypedDriverOption<>(
964+
DefaultDriverOption.CLIENT_ROUTES_EXCLUSIVE_PROXY, GenericType.BOOLEAN);
965+
957966
private static Iterable<TypedDriverOption<?>> introspectBuiltInValues() {
958967
try {
959968
ImmutableList.Builder<TypedDriverOption<?>> result = ImmutableList.builder();

core/src/main/resources/reference.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,19 @@ datastax-java-driver {
11731173
# Default: false
11741174
shard-awarness-enabled = false
11751175

1176+
# When true, the driver connects exclusively through proxies and will never fall back to a
1177+
# node's broadcast address when no route entry exists in system.client_routes. Any node
1178+
# without a route is treated as unreachable; it goes DOWN and the reconnection loop retries
1179+
# until a CLIENT_ROUTES_CHANGE event populates the route.
1180+
#
1181+
# When false (default), nodes that have no route entry are reached directly using their
1182+
# broadcast address, preserving backward-compatible mixed proxy/direct topologies where some
1183+
# nodes are behind the private endpoint and others are not.
1184+
#
1185+
# Required: no
1186+
# Default: false
1187+
exclusive-proxy = false
1188+
11761189
}
11771190

11781191
# Whether to resolve the addresses passed to `basic.contact-points`.

0 commit comments

Comments
 (0)