yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.qianwen.smartman.common.config;
 
import cn.hutool.core.lang.Tuple;
import com.dtflys.forest.callback.AddressSource;
import com.dtflys.forest.http.ForestAddress;
import com.dtflys.forest.http.ForestRequest;
import java.net.MalformedURLException;
import java.net.URL;
import com.qianwen.smartman.common.cache.ParamCache;
import com.qianwen.smartman.common.constant.CommonConstant;
 
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/common/config/ForestConfig.class */
public class ForestConfig implements AddressSource {
    public ForestAddress getAddress(ForestRequest forestRequest) {
        String value = ParamCache.getValue(CommonConstant.DMP_CONFIG_NAME);
        Tuple tuple = getIpPort(value);
        return new ForestAddress((String) tuple.get(0), (Integer) tuple.get(1));
    }
 
    private Tuple getIpPort(String value) {
        try {
            URL url = new URL(value);
            return new Tuple(new Object[]{url.getHost(), Integer.valueOf(url.getPort())});
        } catch (MalformedURLException e) {
            return new Tuple(new Object[0]);
        }
    }
}