Commit f7e6ff1f3fb0a57e1eff00053441b65911a171fd
1 parent
818b6cd1
feat: add frp server address for change frpc.ini
Showing
3 changed files
with
24 additions
and
5 deletions
... | ... | @@ -542,7 +542,7 @@ spring: |
542 | 542 | url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://47.99.141.212:20638/thingsboard-3.3.4}" |
543 | 543 | username: "${SPRING_DATASOURCE_USERNAME:postgres}" |
544 | 544 | password: "${SPRING_DATASOURCE_PASSWORD:Vrr861!@waja}" |
545 | -# url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://101.133.234.90:28776/thingsboard-3.3.4}" | |
545 | +# url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://101.133.234.90:28776/thingsboard-3.3.2}" | |
546 | 546 | # username: "${SPRING_DATASOURCE_USERNAME:postgres}" |
547 | 547 | # password: "${SPRING_DATASOURCE_PASSWORD:Bua312!!iwcw}" |
548 | 548 | hikari: |
... | ... | @@ -1167,3 +1167,6 @@ logging: |
1167 | 1167 | #mybatis-plus: |
1168 | 1168 | # configuration: |
1169 | 1169 | # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
1170 | +frp: | |
1171 | + server: | |
1172 | + address: http://127.0.0.1 | ... | ... |
1 | +package org.thingsboard.server.common.data.yunteng.core.utils; | |
2 | + | |
3 | +import lombok.Data; | |
4 | +import org.springframework.boot.context.properties.ConfigurationProperties; | |
5 | +import org.springframework.stereotype.Component; | |
6 | + | |
7 | +@ConfigurationProperties(prefix = "frp.server") | |
8 | +@Component | |
9 | +@Data | |
10 | +public class FrpServerProperties { | |
11 | + private String address; | |
12 | +} | ... | ... |
... | ... | @@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import com.baomidou.mybatisplus.core.metadata.IPage; |
5 | 5 | import com.fasterxml.jackson.databind.node.ObjectNode; |
6 | 6 | import org.apache.commons.lang3.StringUtils; |
7 | +import org.springframework.beans.factory.annotation.Autowired; | |
7 | 8 | import org.springframework.stereotype.Service; |
8 | 9 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; |
9 | 10 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
11 | +import org.thingsboard.server.common.data.yunteng.core.utils.FrpServerProperties; | |
10 | 12 | import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO; |
11 | 13 | import org.thingsboard.server.common.data.yunteng.dto.FrpInfoDTO; |
12 | 14 | import org.thingsboard.server.common.data.yunteng.enums.StatusEnum; |
... | ... | @@ -16,7 +18,6 @@ import org.thingsboard.server.dao.yunteng.mapper.FrpInfoMapper; |
16 | 18 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
17 | 19 | import org.thingsboard.server.dao.yunteng.service.YtFrpInfoService; |
18 | 20 | |
19 | -import java.net.InetAddress; | |
20 | 21 | import java.net.UnknownHostException; |
21 | 22 | import java.time.LocalDateTime; |
22 | 23 | import java.util.Map; |
... | ... | @@ -25,6 +26,9 @@ import java.util.Optional; |
25 | 26 | @Service |
26 | 27 | public class YtFrpInfoServiceImpl extends AbstractBaseService<FrpInfoMapper, FrpInfo> |
27 | 28 | implements YtFrpInfoService { |
29 | + | |
30 | + @Autowired private FrpServerProperties frpServerProperties; | |
31 | + | |
28 | 32 | @Override |
29 | 33 | public YtPageData<FrpInfoDTO> page(Map<String, Object> queryMap) { |
30 | 34 | String proxyName = |
... | ... | @@ -90,7 +94,8 @@ public class YtFrpInfoServiceImpl extends AbstractBaseService<FrpInfoMapper, Frp |
90 | 94 | } |
91 | 95 | FrpInfo frpInfo = |
92 | 96 | baseMapper.selectOne( |
93 | - new LambdaQueryWrapper<FrpInfo>().eq(StringUtils.isNotEmpty(proxyName),FrpInfo::getProxyName, proxyName)); | |
97 | + new LambdaQueryWrapper<FrpInfo>() | |
98 | + .eq(StringUtils.isNotEmpty(proxyName), FrpInfo::getProxyName, proxyName)); | |
94 | 99 | return Optional.ofNullable(frpInfo).map(info -> frpInfo.getDTO(FrpInfoDTO.class)).orElse(null); |
95 | 100 | } |
96 | 101 | |
... | ... | @@ -119,8 +124,7 @@ public class YtFrpInfoServiceImpl extends AbstractBaseService<FrpInfoMapper, Frp |
119 | 124 | queryFrpInfoDTO.setStatus(StatusEnum.ONLINE.getIndex()); |
120 | 125 | saveFrpInfoDTO = queryFrpInfoDTO; |
121 | 126 | } |
122 | - saveFrpInfoDTO.setAddress( | |
123 | - "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + remotePort); | |
127 | + saveFrpInfoDTO.setAddress(frpServerProperties.getAddress() + ":" + remotePort); | |
124 | 128 | return saveOrUpdateFrpInfo(saveFrpInfoDTO); |
125 | 129 | } |
126 | 130 | } | ... | ... |