Alanxtl commented on code in PR #3401:
URL: https://github.com/apache/dubbo-go/pull/3401#discussion_r3407499739


##########
remoting/getty/getty_client.go:
##########
@@ -63,71 +62,31 @@ func initClient(url *common.URL) {
                return
        }
 
-       // load client config from rootConfig.Protocols
-       // default use dubbo
-       // TODO: Temporary compatibility with old APIs, can be removed later
-       if url.GetParam(constant.ApplicationKey, "") == "" && 
config.GetApplicationConfig() == nil {
-               return
-       }
+       // Ensure application config is available via URL attribute
+       commonCfg.EnsureApplicationAttribute(url)
 
-       // TODO: Temporary compatibility with old APIs, can be removed later
-       if url.GetParam(constant.ProtocolKey, "") == "" && 
config.GetRootConfig().Protocols == nil {
+       protocolConfRaw, ok := url.GetAttribute(constant.ProtocolConfigKey)
+       if !ok || protocolConfRaw == nil {
+               logger.Warn("[Remoting][Getty] protocolConfig not found in URL 
attributes")
                return
        }
-
-       // TODO: Temporary compatibility with old APIs, can be removed later
-       protocolConfMap := 
dubbo.CompatGlobalProtocolConfigMap(config.GetRootConfig().Protocols)
-       if protocolConfMap == nil {
-               if protocolConfRaw, ok := 
url.GetAttribute(constant.ProtocolConfigKey); ok {
-                       protocolConfig, ok := 
protocolConfRaw.(map[string]*global.ProtocolConfig)
-                       if !ok {
-                               logger.Warn("[Remoting][Getty] protocolConfig 
assert failed")
-                               return
-                       }
-                       if protocolConfig == nil {
-                               logger.Warn("[Remoting][Getty] protocolConfig 
is nil")
-                               return
-                       }
-                       protocolConfMap = protocolConfig
-               }
+       protocolConfMap, ok := 
protocolConfRaw.(map[string]*global.ProtocolConfig)
+       if !ok || protocolConfMap == nil {
+               logger.Warn("[Remoting][Getty] protocolConfig assert failed or 
is nil")
+               return
        }
 
        protocolConf := protocolConfMap[url.Protocol]
        if protocolConf == nil {
                logger.Info("[Remoting][Getty] use default getty client config")
                return
        } else {
-               //client tls config
-               tlsConfig := 
dubbo.CompatGlobalTLSConfig(config.GetRootConfig().TLSConfig)
-
-               if tlsConfig == nil {
-                       if tlsConfRaw, ok := 
url.GetAttribute(constant.TLSConfigKey); ok {
-                               tlsConf, ok := tlsConfRaw.(*global.TLSConfig)
-                               if !ok {
-                                       logger.Error("[Remoting][Getty] getty 
client initialized the TLSConfig configuration failed")
-                                       return
-                               }
-                               tlsConfig = tlsConf
-                       }
-               }
-
-               if tlsConfig != nil {
-                       clientConf.SSLEnabled = true
-                       clientConf.TLSBuilder = &getty.ClientTlsConfigBuilder{
-                               ClientKeyCertChainPath:        
tlsConfig.TLSCertFile,
-                               ClientPrivateKeyPath:          
tlsConfig.TLSKeyFile,
-                               ClientTrustCertCollectionPath: 
tlsConfig.CACertFile,
-                       }
-               } else if tlsConfRaw, ok := 
url.GetAttribute(constant.TLSConfigKey); ok {
-                       // use global TLSConfig handle tls
+               // client tls config
+               if tlsConfRaw, ok := url.GetAttribute(constant.TLSConfigKey); 
ok {
                        tlsConf, ok := tlsConfRaw.(*global.TLSConfig)
-                       if !ok {
-                               logger.Error("[Remoting][Getty] getty client 
initialized the TLSConfig configuration failed")
-                               return
-                       }
-                       if dubbotls.IsClientTLSValid(tlsConf) {
-                               srvConf.SSLEnabled = true
-                               srvConf.TLSBuilder = 
&getty.ClientTlsConfigBuilder{
+                       if ok && dubbotls.IsClientTLSValid(tlsConf) {

Review Comment:
   改成这样
   ```
   if tlsConf, ok := tlsConfRaw.(*global.TLSConfig); ok && 
dubbotls.IsClientTLSValid(tlsConf) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to