Skip to content

Commit 4a34fc0

Browse files
committed
PHP-163 - Disable hostname resolution if not supported
* Emit a warning if hostname resolution is not supported * Updated documentation
1 parent 562d251 commit 4a34fc0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ext/src/Cluster/Builder.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ zend_class_entry *php_driver_cluster_builder_ce = NULL;
2929

3030
PHP_METHOD(ClusterBuilder, build)
3131
{
32+
CassError rc;
3233
php_driver_cluster* cluster;
3334
php_driver_cluster_builder *self = PHP_DRIVER_GET_CLUSTER_BUILDER(getThis());
3435

@@ -125,7 +126,16 @@ PHP_METHOD(ClusterBuilder, build)
125126
cass_cluster_set_tcp_nodelay(cluster->cluster, self->enable_tcp_nodelay);
126127
cass_cluster_set_tcp_keepalive(cluster->cluster, self->enable_tcp_keepalive, self->tcp_keepalive_delay);
127128
cass_cluster_set_use_schema(cluster->cluster, self->enable_schema);
128-
ASSERT_SUCCESS(cass_cluster_set_use_hostname_resolution(cluster->cluster, self->enable_hostname_resolution));
129+
130+
rc = cass_cluster_set_use_hostname_resolution(cluster->cluster, self->enable_hostname_resolution);
131+
if (rc == CASS_ERROR_LIB_NOT_IMPLEMENTED) {
132+
if (self->enable_hostname_resolution) {
133+
php_error_docref0(NULL, E_WARNING,
134+
"The underlying C/C++ driver does not implement hostname resolution it will be disabled");
135+
}
136+
} else {
137+
ASSERT_SUCCESS(rc);
138+
}
129139
ASSERT_SUCCESS(cass_cluster_set_use_randomized_contact_points(cluster->cluster, self->enable_randomized_contact_points));
130140
cass_cluster_set_connection_heartbeat_interval(cluster->cluster, self->connection_heartbeat_interval);
131141

ext/src/Cluster/Builder.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ Cluster\Builder:
284284
If enabled the driver will resolve hostnames for IP addresses using
285285
reverse IP lookup. This is useful for authentication (Kerberos) or
286286
encryption SSL services that require a valid hostname for verification.
287+
288+
Important: It's possible that the underlying C/C++ driver does not
289+
support hostname resolution. A PHP warning will be emitted if the driver
290+
does not support hostname resolution.
287291
params:
288292
enabled:
289293
comment: whether the driver uses hostname resolution.

0 commit comments

Comments
 (0)