修复新节点切换类型、复制服务名称有误的问题

This commit is contained in:
octopusYan 2022-04-16 20:47:45 +08:00
parent 9bd945f02b
commit db9a3c2272
3 changed files with 21 additions and 8 deletions

View File

@ -6,7 +6,7 @@
<groupId>top.octopusyan</groupId> <groupId>top.octopusyan</groupId>
<artifactId>YanFrp</artifactId> <artifactId>YanFrp</artifactId>
<version>1.1</version> <version>1.1.2</version>
<name>YanFrp</name> <name>YanFrp</name>
<properties> <properties>

View File

@ -263,7 +263,9 @@ public class MainController extends BaseController<StackPane> implements Initial
proxySetupModel.proxyTypeProperty().addListener((observable, oldValue, newValue) -> { proxySetupModel.proxyTypeProperty().addListener((observable, oldValue, newValue) -> {
String newType = StringUtils.lowerCase(newValue); String newType = StringUtils.lowerCase(newValue);
String port, host; String port, host;
if (!newType.equals(StringUtils.upperCase(userProxy.get(proxySetupModel.getId()).getProxy_type()))) { if (proxySetupModel.getId() == null ||
!newType.equals(StringUtils.upperCase(userProxy.get(proxySetupModel.getId()).getProxy_type()))
) {
host = "127.0.0.1"; host = "127.0.0.1";
port = ProxyConfig.getTypePort(newType).toString(); port = ProxyConfig.getTypePort(newType).toString();
} else { } else {
@ -321,7 +323,7 @@ public class MainController extends BaseController<StackPane> implements Initial
p2pValid.add(TextValidate.p2pPwdRequired); p2pValid.add(TextValidate.p2pPwdRequired);
p2pValid.add(TextValidate.p2pServerNameRequired); p2pValid.add(TextValidate.p2pServerNameRequired);
} }
serverNameTextField.textProperty().set("提供者");
domainTextField.getValidators().clear(); domainTextField.getValidators().clear();
} else { } else {
// tcp / udp // tcp / udp
@ -467,7 +469,7 @@ public class MainController extends BaseController<StackPane> implements Initial
// 日志清理 // 日志清理
clearLogBtn.setOnMouseClicked(event -> { clearLogBtn.setOnMouseClicked(event -> {
ProxySetup proxySetup = userProxy.get(proxySetupModel.getId()); ProxySetup proxySetup = userProxy.get(proxySetupModel.getId());
if (frpUtilMap.get(proxySetup.getId().toString()) != null) if (proxySetup != null && frpUtilMap.get(proxySetup.getId().toString()) != null)
frpUtilMap.get(proxySetup.getId().toString()).clearLog(); frpUtilMap.get(proxySetup.getId().toString()).clearLog();
}); });
@ -543,7 +545,13 @@ public class MainController extends BaseController<StackPane> implements Initial
return; return;
ProxySetup setup = proxySetupModel.get(); ProxySetup setup = proxySetupModel.get();
setup.setServer_name(EncryptionUtil.MD5_16(ApplicatonStore.getAccount() + "_" + setup.getSort()));
String serverName = getAccount() + "_" + setup.getSort();
setup.setServer_name(EncryptionUtil.MD5_16(serverName));
setup.setId(null);
setup.setRuning(false);
setup.setSort(null);
setup.setStatus(null);
JSONObject json = JSON.parseObject(JSON.toJSONString(setup)); JSONObject json = JSON.parseObject(JSON.toJSONString(setup));
try { try {
@ -565,7 +573,12 @@ public class MainController extends BaseController<StackPane> implements Initial
clipData = clipData.replace(FrpManager.serverConfigHeader, ""); clipData = clipData.replace(FrpManager.serverConfigHeader, "");
String jsonStr = EncryptionUtil.DESdecode(clipData, EncryptionUtil.getDefaultPassword()); String jsonStr = EncryptionUtil.DESdecode(clipData, EncryptionUtil.getDefaultPassword());
JSONObject jsonObject = JSON.parseObject(jsonStr); JSONObject jsonObject = JSON.parseObject(jsonStr);
proxySetupModel.set(jsonObject.toJavaObject(ProxySetup.class)); ProxySetup setup = jsonObject.toJavaObject(ProxySetup.class);
setup.setId(proxySetupModel.getId() == null ? null : Integer.parseInt(proxySetupModel.getId()));
setup.setSort(proxySetupModel.getSort());
setup.setRuning(proxySetupModel.isRunning());
setup.setStatus(proxySetupModel.getStatus());
proxySetupModel.set(setup);
AlertUtil.info("导入成功").show(); AlertUtil.info("导入成功").show();
} catch (Exception e) { } catch (Exception e) {
AlertUtil.error("导入失败,请重新复制服务设置").show(); AlertUtil.error("导入失败,请重新复制服务设置").show();

View File

@ -161,12 +161,12 @@ public class FrpManager {
// 基础配置 // 基础配置
StringBuilder stringBuilder = new StringBuilder("["); StringBuilder stringBuilder = new StringBuilder("[");
// 服务名称 // 服务名称
StringBuilder serverName = new StringBuilder(); StringBuilder serverName = new StringBuilder(ApplicatonStore.getAccount()+"_"+setup.getSort());
// p2p 服务名 // p2p 服务名
if (isp2p) { if (isp2p) {
if (setup.isProvider()) { if (setup.isProvider()) {
// 提供者 // 提供者
serverName.append(EncryptionUtil.MD5_16(serverName.toString())); serverName = new StringBuilder(EncryptionUtil.MD5_16(serverName.toString()));
} else { } else {
// 访问者 // 访问者
serverName.append(setup.getServerName()).append("_visitor"); serverName.append(setup.getServerName()).append("_visitor");