[server][ xray]- 代理节点的数据库内容 - 2
This commit is contained in:
@@ -11,10 +11,7 @@ import io.wdd.func.xray.service.XrayCoreService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static io.wdd.func.xray.persisit.cache.ProxyNodeCache.*;
|
||||
|
||||
@@ -57,6 +54,23 @@ public class XrayController {
|
||||
);
|
||||
}
|
||||
|
||||
@PostMapping("/cache/manual")
|
||||
@ApiOperation("[缓存] - 手动更新代理链缓存")
|
||||
public R<HashMap<String, ProxyNode>> manualUpdateProxyNodeListCache() {
|
||||
|
||||
return R.ok(
|
||||
xrayCoreService.manualUpdateProxyNodeListCache()
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("/cache/get")
|
||||
@ApiOperation("[缓存] - 获取代理链缓存")
|
||||
public R<HashMap<String, ProxyNode>> getProxyNodeListCache() {
|
||||
|
||||
return R.ok(ProxyNodeMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/test")
|
||||
public void test() {
|
||||
|
||||
@@ -13,7 +13,10 @@ public enum ProxyNodeType {
|
||||
RELAY,
|
||||
|
||||
|
||||
// 数据库中标记为0
|
||||
EXTERNAL
|
||||
// 数据库中标记为2
|
||||
EXTERNAL,
|
||||
|
||||
UNKNOWN
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.wdd.func.xray.persisit;
|
||||
|
||||
import io.wdd.func.xray.beans.node.ProxyNode;
|
||||
import io.wdd.func.xray.beans.node.ProxyNodeType;
|
||||
import io.wdd.func.xray.beans.node.XrayConfigInfo;
|
||||
import io.wdd.server.beans.vo.ServerInfoVO;
|
||||
import io.wdd.server.coreService.CoreServerService;
|
||||
@@ -55,7 +56,7 @@ public class XrayDBOperator {
|
||||
private void transferServerInfoToProxyNode(List<ServerInfoVO> serverInfoVOList) {
|
||||
|
||||
// 临时内容
|
||||
int[] bitmap = new int[ALL_SERVER_CITY_INDEX.size()];
|
||||
int[] bitmap = new int[ALL_SERVER_CITY_INDEX.size() * 10];
|
||||
|
||||
//
|
||||
int[] finalBitmap = bitmap;
|
||||
@@ -85,6 +86,9 @@ public class XrayDBOperator {
|
||||
.publicIPv6(serverInfoVO.getServerIpPbV6())
|
||||
.name(serverCity + serverGraphNum)
|
||||
.agentName(serverInfoVO.getServerName())
|
||||
.proxyNodeType(
|
||||
convertNodeType(serverInfoVO.getProxyType())
|
||||
)
|
||||
.location(serverCity)
|
||||
.xrayConfigInfo(new XrayConfigInfo())
|
||||
.build();
|
||||
@@ -131,4 +135,22 @@ public class XrayDBOperator {
|
||||
|
||||
}
|
||||
|
||||
private ProxyNodeType convertNodeType(Integer proxyType) {
|
||||
|
||||
if (null == proxyType) {
|
||||
return ProxyNodeType.UNKNOWN;
|
||||
}
|
||||
|
||||
switch (proxyType) {
|
||||
case 0:
|
||||
return ProxyNodeType.INTERFACE;
|
||||
case 1:
|
||||
return ProxyNodeType.RELAY;
|
||||
case 2:
|
||||
return ProxyNodeType.EXTERNAL;
|
||||
default:
|
||||
return ProxyNodeType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.wdd.func.xray.service;
|
||||
import io.wdd.func.xray.beans.node.ProxyNode;
|
||||
import io.wdd.func.xray.beans.node.XrayConfigInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public interface XrayCoreService {
|
||||
@@ -18,4 +19,12 @@ public interface XrayCoreService {
|
||||
|
||||
List<XrayConfigInfo> generateXrayConfigFromNodeList(List<List<ProxyNode>> allNetworkPathList);
|
||||
|
||||
|
||||
/**
|
||||
* 手动更新代理链缓存, 并返回结果
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
HashMap<String, ProxyNode> manualUpdateProxyNodeListCache();
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import io.wdd.func.xray.beans.xray.protocol.inbound.vmess.VMESS;
|
||||
import io.wdd.func.xray.beans.xray.protocol.outbound.Freedom;
|
||||
import io.wdd.func.xray.beans.xray.protocol.outbound.OutboundConfigurationObject;
|
||||
import io.wdd.func.xray.beans.xray.transport.OutboundObject;
|
||||
import io.wdd.func.xray.persisit.XrayDBOperator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -24,6 +25,7 @@ import static io.wdd.func.xray.beans.config.InboundVmessHTTPTemplateClass.Inboun
|
||||
import static io.wdd.func.xray.beans.config.InboundVmessHTTPTemplateClass.ListenAddress;
|
||||
import static io.wdd.func.xray.beans.config.LogTemplateClass.LogTemplate;
|
||||
import static io.wdd.func.xray.beans.config.OutboundVmessHTTPTemplateClass.*;
|
||||
import static io.wdd.func.xray.persisit.cache.ProxyNodeCache.ProxyNodeMap;
|
||||
import static io.wdd.func.xray.service.XrayConfigPersistor.cleanVersion;
|
||||
|
||||
@Service
|
||||
@@ -33,6 +35,9 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
@Resource
|
||||
XrayConfigPersistor xrayConfigPersistor;
|
||||
|
||||
@Resource
|
||||
XrayDBOperator xrayDBOperator;
|
||||
|
||||
private static final String ProxyChainSplitor = "->";
|
||||
|
||||
@Override
|
||||
@@ -104,6 +109,14 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, ProxyNode> manualUpdateProxyNodeListCache() {
|
||||
|
||||
xrayDBOperator.CacheAllProxyNodeInfo();
|
||||
|
||||
return ProxyNodeMap;
|
||||
}
|
||||
|
||||
private void generateXrayJsonSinglePath(List<ProxyNode> networkPathList) {
|
||||
int pathLength = networkPathList.size();
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package io.wdd.server.beans.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -65,6 +63,11 @@ public class ServerInfoPO implements Serializable {
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 服务器节点的代理类型,0代表INTERFACE, 1代表relay,2代表external
|
||||
*/
|
||||
private Integer proxyType;
|
||||
|
||||
/**
|
||||
* server location , type City Country
|
||||
*/
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
package io.wdd.server.beans.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@@ -68,6 +62,11 @@ public class ServerInfoVO {
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 服务器节点的代理类型,0代表INTERFACE, 1代表relay,2代表external
|
||||
*/
|
||||
private Integer proxyType;
|
||||
|
||||
/**
|
||||
* server location , type City Country
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user