Add comments

This commit is contained in:
wuyuhao 2024-06-20 16:05:19 +08:00
parent 0babad0c14
commit dcfd16a1b5
3 changed files with 14 additions and 3 deletions

View File

@ -28,11 +28,13 @@ public class XdsTlsConfigRepository {
/**
* inbound ports -> configs
* Indicates the TLS configuration for inbound connections.
*/
private volatile Map<String, DownstreamTlsConfig> downstreamConfigs = Collections.emptyMap();
/**
* clusterName -> configs
* Indicates the TLS configuration for outbound connection to certain cluster.
*/
private volatile Map<String, UpstreamTlsConfig> upstreamConfigs = Collections.emptyMap();

View File

@ -67,7 +67,7 @@ public class XdsCertProvider implements CertProvider {
@Override
public boolean isSupport(URL address) {
String side = address.getSide();
if (PROVIDER.equals(side)) {
if (CONSUMER.equals(side)) {
// TODO: If XDS URL can support version tag, key should be address.getServiceKey()
UpstreamTlsConfig upstreamConfig = configRepo.getUpstreamConfig(address.getServiceInterface());
if (upstreamConfig == null || upstreamConfig.getGeneralTlsConfig() == null) {
@ -80,7 +80,7 @@ public class XdsCertProvider implements CertProvider {
// At least one config provided by LDS
return !trustConfigs.isEmpty() || !certConfigs.isEmpty();
} else if (CONSUMER.equals(side)) {
} else if (PROVIDER.equals(side)) {
DownstreamTlsConfig downstreamConfig = configRepo.getDownstreamConfig(String.valueOf(address.getPort()));
if (downstreamConfig == null) {
return false;
@ -94,6 +94,15 @@ public class XdsCertProvider implements CertProvider {
return !secretConfigs.isEmpty() || !certConfigs.isEmpty();
}
throw new IllegalStateException("Can't determine side for url:" + address);
// seems we don't need url to check here anymore
// if (TlsType.PERMISSIVE.equals(type)) {
// String security = address.getParameter("security");
// String mesh = address.getParameter("mesh");
// return mesh != null
// && security != null
// && Arrays.asList(security.split(",")).contains("mTLS");
// }
}
@Override

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.xds.security.authn;
/**
* Tls config for outbound request
* Tls config for outbound connection
*/
public class UpstreamTlsConfig {