yangys
2024-03-27 e48aa2ac8dea1be5db11c63edf0b912c4ad5ce65
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/SerialAddressConfig.class */
public class SerialAddressConfig implements AddressSource {
    public ForestAddress getAddress(ForestRequest forestRequest) {
        String value = ParamCache.getValue(CommonConstant.SERIAL_CONFIG_ADDRESS);
        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]);
        }
    }
}