YanFrp/src/main/java/top/octopusyan/controller/MainController.java

603 lines
23 KiB
Java
Raw Normal View History

2022-04-06 17:49:00 +08:00
package top.octopusyan.controller;
import com.jfoenix.controls.*;
import javafx.application.Platform;
2022-04-09 03:59:20 +08:00
import javafx.beans.property.SimpleBooleanProperty;
2022-04-06 17:49:00 +08:00
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
2022-04-09 03:59:20 +08:00
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;
2022-04-06 17:49:00 +08:00
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import top.octopusyan.base.BaseController;
import top.octopusyan.config.ProxyConfig;
import top.octopusyan.config.ProxyConfig.ProxyServer;
import top.octopusyan.config.ProxyConfig.ProxyType;
import top.octopusyan.config.TextValidate;
import top.octopusyan.http.listener.OnHttpListener;
import top.octopusyan.manager.FrpManager;
import top.octopusyan.manager.ProxyManager;
import top.octopusyan.manager.http.request.ProxySetup;
import top.octopusyan.model.ApplicatonStore;
2022-04-09 03:59:20 +08:00
import top.octopusyan.model.ProxySetupModel;
2022-04-06 17:49:00 +08:00
import top.octopusyan.utils.AlertUtil;
2022-04-09 03:59:20 +08:00
import top.octopusyan.utils.DomainUtil;
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
2022-04-06 17:49:00 +08:00
import java.io.IOException;
import java.util.List;
import java.util.*;
import static top.octopusyan.model.ApplicatonStore.*;
2022-04-06 17:49:00 +08:00
/**
* @author : octopus yan
* @email : octopus_yan@foxmail.com
* @description :
* @create : 2022-4-4 22:32
*/
public class MainController extends BaseController<StackPane> implements Initializable {
public static final String PROXY_LIST_ITEM_CLASS = "proxyListItem";
public static final String PROXY_LIST_ITEM_STOP_CLASS = "proxyListItem-stop";
public static final String PROXY_LIST_ITEM_RUN_CLASS = "proxyListItem-run";
public static final String PROXY_LIST_ITEM_CLOSE_CLASS = "proxyListItem-close";
2022-04-09 03:59:20 +08:00
public static final String PROXY_LIST_ITEM_SELECT_CLASS = "proxyListItem-select";
2022-04-06 17:49:00 +08:00
@FXML
public StackPane root;
@FXML
public JFXButton closeBtn, minimizeBtn;
@FXML
2022-04-09 03:59:20 +08:00
public JFXButton startProxyBtn, addProxyBtn;
2022-04-06 17:49:00 +08:00
@FXML
2022-04-09 03:59:20 +08:00
public JFXComboBox<String> proxyProtocolComboBox;
2022-04-06 17:49:00 +08:00
@FXML
public JFXButton customizeDomainBtn;
@FXML
public JFXRadioButton openProxyRBtn, closeProxyRBtn;
@FXML
public JFXTextField domainTextField, domainSuffixTextField;
@FXML
public JFXTextField proxyNameTextField, localHostTextField, localPortTextField;
@FXML
2022-04-09 03:59:20 +08:00
public JFXComboBox<String> proxyServerComboBox;
2022-04-06 17:49:00 +08:00
@FXML
public JFXTabPane tabPane;
@FXML
public JFXListView<Label> proxyListView;
2022-04-09 03:59:20 +08:00
@FXML
public Label domainHtinTextField;
@FXML
public HBox domainPane;
@FXML
public JFXButton resetProxyBtn, clearLogBtn, copyDomainBtn;
@FXML
public Tab proxyLogPane;
@FXML
public Hyperlink domainLink;
@FXML
public HBox proxyStatusPane;
@FXML
public JFXButton logoutBtn;
2022-04-06 17:49:00 +08:00
private final ToggleGroup openProxyGroup = new ToggleGroup();
private final SimpleBooleanProperty customizeDomain = new SimpleBooleanProperty(false);
private final Map<String, FrpManager> frpUtilMap = new HashMap<>();
private final Map<String, ProxySetup> userProxy = new HashMap<>();
2022-04-09 03:59:20 +08:00
private ProxySetupModel proxySetupModel;
private final SimpleBooleanProperty setup = new SimpleBooleanProperty(false);
2022-04-06 17:49:00 +08:00
@Override
public boolean dragWindow() {
return true;
}
@Override
public StackPane getRootPanel() {
return root;
}
@NotNull
@Override
public String getRootFxmlPath() {
return "/fxml/main.fxml";
}
@Override
public Button getClooseBtn() {
return closeBtn;
}
@Override
public Button getMinimizeBtn() {
return minimizeBtn;
}
@Override
public JFXButton getFirstBtn() {
return minimizeBtn;
}
@Override
public void initData() {
2022-04-09 03:59:20 +08:00
// 初始化视图模型
ProxySetup proxySetup = ProxyManager.initProxy(null);
2022-04-09 03:59:20 +08:00
proxySetupModel = new ProxySetupModel(proxySetup);
// 初始化用户隧道列表
setProxyList(Collections.singletonList(proxySetup));
// 重置隧道列表视图
initProxyListView();
2022-04-06 17:49:00 +08:00
// 隧道类型
2022-04-09 03:59:20 +08:00
Arrays.asList(ProxyType.values()).forEach((type) -> proxyProtocolComboBox.getItems().add(type.name()));
2022-04-06 17:49:00 +08:00
// 服务器
2022-04-09 03:59:20 +08:00
Arrays.asList(ProxyServer.values()).forEach((server) -> proxyServerComboBox.getItems().add(server.getServerName()));
2022-04-06 17:49:00 +08:00
// 获取用户隧道列表
ProxyManager.getList(new OnHttpListener<List<ProxySetup>>() {
@Override
public void onSucceed(List<ProxySetup> result) {
Platform.runLater(() -> {
// 如果用户隧道列表不为空
if (result != null && result.size() > 0) {
// 上次关闭时选择的隧道
if (selectProxyName != null)
for (int i = 0; i < result.size(); i++) {
if (result.get(i).getProxy_name().equals(selectProxyName))
selectProxy(i);
selectProxyName = null;
}
// 保存用户隧道信息
for (ProxySetup setup : result) {
userProxy.put(setup.getId().toString(), setup);
}
proxySetupModel.set(result.get(selectProxy()));
// 初始化用户隧道列表
setProxyList(result);
// 重置隧道列表视图
initProxyListView();
}
});
}
2022-04-09 03:59:20 +08:00
@Override
public void onFail(Exception e) {
2022-04-09 03:59:20 +08:00
}
2022-04-06 17:49:00 +08:00
});
2022-04-09 03:59:20 +08:00
/* 数据绑定 */
// 服务器
proxyServerComboBox.valueProperty().bindBidirectional(proxySetupModel.serverProperty());
// 隧道名称
proxyNameTextField.textProperty().bindBidirectional(proxySetupModel.proxyNameProperty());
// 隧道类型
proxyProtocolComboBox.valueProperty().bindBidirectional(proxySetupModel.proxyTypeProperty());
// 内网地址
localHostTextField.textProperty().bindBidirectional(proxySetupModel.localIpProperty());
// 内网端口
localPortTextField.textProperty().bindBidirectional(proxySetupModel.localPortProperty());
// 外网访问子域名
domainTextField.textProperty().bindBidirectional(proxySetupModel.domainProperty());
// 外网访问主域名
domainSuffixTextField.textProperty().bindBidirectional(proxySetupModel.domainSuffixProperty());
// 是否自定义访问域名
customizeDomain.bindBidirectional(proxySetupModel.isCustomizeProperty());
// 启动成功提示
proxyStatusPane.visibleProperty().bindBidirectional(proxySetupModel.runningProperty());
2022-04-06 17:49:00 +08:00
}
@Override
public void initViewStyle() {
// 设置列表
proxyListView.getSelectionModel().select(0);
2022-04-06 17:49:00 +08:00
// 启用链接
openProxyRBtn.setToggleGroup(openProxyGroup);
closeProxyRBtn.setToggleGroup(openProxyGroup);
openProxyRBtn.setUserData(true);
closeProxyRBtn.setUserData(false);
2022-04-09 03:59:20 +08:00
openProxyRBtn.setSelected(true);
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 是否启用
proxySetupModel.statusProperty().addListener((observable, oldValue, newValue) -> {
openProxyRBtn.setSelected(newValue);
closeProxyRBtn.setSelected(!newValue);
closeProxy(!newValue);
});
proxySetupModel.proxyTypeProperty().addListener((observable, oldValue, newValue) -> {
String newType = StringUtils.lowerCase(newValue);
String port, host;
if (!newType.equals(userProxy.get(proxySetupModel.getId()))) {
2022-04-09 03:59:20 +08:00
host = "127.0.0.1";
port = ProxyConfig.getTypePort(newType).toString();
} else {
host = proxySetupModel.getLocalIp();
port = proxySetupModel.getLocalPort();
}
// 域名提示
domainPane.setVisible(DomainUtil.isHttp(proxySetupModel));
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 设置
localHostTextField.setText(host);
localPortTextField.setText(port);
});
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 隧道名称
proxySetupModel.proxyNameProperty().addListener((observable, oldValue, newValue) -> {
if (proxyListView.getItems().size() > 0)
proxyListView.getItems().get(selectProxy()).setText(newValue);
2022-04-09 03:59:20 +08:00
});
// 运行状态监听
proxySetupModel.runningProperty().addListener((observable, oldValue, newValue) -> {
String startClass = "startProxyBtn";
String stopClass = "stopProxyBtn";
// 启动按钮
startProxyBtn.getStyleClass().remove(startClass);
startProxyBtn.getStyleClass().remove(stopClass);
startProxyBtn.getStyleClass().add(newValue ? stopClass : startClass);
startProxyBtn.setText(newValue ? "停止" : "启动");
// 列表显示
ObservableList<String> styleClass = proxyListView.getItems().get(selectProxy()).getStyleClass();
2022-04-09 03:59:20 +08:00
styleClass.remove(PROXY_LIST_ITEM_RUN_CLASS);
styleClass.remove(PROXY_LIST_ITEM_STOP_CLASS);
styleClass.add(newValue ? PROXY_LIST_ITEM_RUN_CLASS : PROXY_LIST_ITEM_STOP_CLASS);
setDomainLink();
2022-04-09 03:59:20 +08:00
});
// 自定义外网访问地址按钮
customizeDomain.addListener((observable, oldValue, newValue) -> {
AnchorPane parent = (AnchorPane) domainTextField.getParent();
2022-04-09 03:59:20 +08:00
// 是否切换为自定义域名
if (newValue) {
// 隐藏系统域名
parent.getChildren().remove(domainSuffixTextField);
2022-04-09 03:59:20 +08:00
// 用户域名是否自定义
if (!DomainUtil.isCustomize(proxySetupModel.get())) {
2022-04-09 03:59:20 +08:00
proxySetupModel.setDomain("");
} else {
proxySetupModel.setDomain(proxySetupModel.getDomain());
2022-04-09 03:59:20 +08:00
}
proxySetupModel.setDomainSuffix("");
domainTextField.promptTextProperty().set("自定义域名");
customizeDomainBtn.setText("系统分配");
domainHtinTextField.setText("请输入您的域名,并解析至: " + ProxyConfig.getServerIP(proxySetupModel.getServer()));
} else {
// 显示系统域名
if (!parent.getChildren().contains(domainSuffixTextField))
parent.getChildren().add(domainSuffixTextField);
// 用户域名是否自定义
if (DomainUtil.isCustomize(proxySetupModel.get())) {
2022-04-09 03:59:20 +08:00
proxySetupModel.setDomain("");
proxySetupModel.setDomainSuffix("." + ProxyConfig.getServerPath(proxySetupModel.getServer()));
} else {
proxySetupModel.setDomain(DomainUtil.getCustomize(proxySetupModel.get()));
proxySetupModel.setDomainSuffix(DomainUtil.getSuffix(userProxy.get(proxySetupModel.getId())));
2022-04-09 03:59:20 +08:00
}
domainTextField.promptTextProperty().set("自定义子域名 大于3位");
customizeDomainBtn.setText("自定义");
domainHtinTextField.setText("请输入子域名长度不小于3个字符");
}
});
// 默认展示 "常见问题" 面板
tabPane.getSelectionModel().select(1);
2022-04-06 17:49:00 +08:00
}
/**
* 设置访问链接
*/
private void setDomainLink() {
// 外网访问连接
if (DomainUtil.isHttp(proxySetupModel)) {
// http / https
String prefix = proxySetupModel.getProxyType() + "://";
domainLink.textProperty().set(prefix + proxySetupModel.getDomain() + proxySetupModel.getDomainSuffix());
} else {
// ssh / tcp
domainLink.textProperty().set(ProxyConfig.getServerIP(ProxyConfig.getServerNode(proxySetupModel.getServer())) + ":" + proxySetupModel.getRemotePort());
}
}
2022-04-06 17:49:00 +08:00
@Override
public void initViewAction() {
2022-04-09 03:59:20 +08:00
// 重置
resetProxyBtn.setOnMouseClicked(event -> {
ProxySetup proxySetup = userProxy.get(proxySetupModel.getId());
2022-04-11 17:24:50 +08:00
if(proxySetup != null){
proxySetup.setRuning(proxySetupModel.isRunning());
proxySetupModel.set(proxySetup);
domainTextField.resetValidation();
}
});
2022-04-09 03:59:20 +08:00
// 日志清理
clearLogBtn.setOnMouseClicked(event -> {
ProxySetup proxySetup = userProxy.get(proxySetupModel.getId());
if (frpUtilMap.get(proxySetup.getId()) != null)
frpUtilMap.get(proxySetup.getId()).clearLog();
2022-04-09 03:59:20 +08:00
});
// 更换服务器地址
proxyServerComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
// 重新设置是否自定义
proxySetupModel.set(proxySetupModel.get());
if (!customizeDomain.get()) {
proxySetupModel.setDomainSuffix("." + ProxyConfig.getServerPath(newValue));
} else {
proxySetupModel.setDomainSuffix("");
// 域名检查
domainTextField.validate();
}
});
2022-04-06 17:49:00 +08:00
// 是否启用
openProxyGroup.selectedToggleProperty().addListener(
(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) -> {
Toggle toggle = openProxyGroup.getSelectedToggle();
if (toggle != null) {
2022-04-09 03:59:20 +08:00
// 设置状态
proxySetupModel.setStatus((Boolean) toggle.getUserData());
2022-04-06 17:49:00 +08:00
}
}
);
2022-04-09 03:59:20 +08:00
// 自定义访问域名
customizeDomainBtn.setOnMouseClicked((event) -> customizeDomain.set(!customizeDomain.get()));
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 本地IP检查
localHostTextField.getValidators().add(TextValidate.IpRequired);
localHostTextField.getValidators().add(TextValidate.IpFormat);
localHostTextField.textProperty().addListener((observable, oldValue, newValue) -> localHostTextField.validate());
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 端口检查
localPortTextField.getValidators().add(TextValidate.PortRequired);
localPortTextField.getValidators().add(TextValidate.PortFormat);
localPortTextField.textProperty().addListener((observable, oldValue, newValue) -> localPortTextField.validate());
2022-04-09 03:59:20 +08:00
// 域名检查
setup.addListener((observable, oldValue, newValue) -> {
2022-04-09 03:59:20 +08:00
if (newValue) domainTextField.validate();
});
domainTextField.textProperty().addListener((observable, oldValue, newValue) -> {
if (!domainTextField.getValidators().contains(TextValidate.DomainRequired)) {
domainTextField.getValidators().add(TextValidate.DomainRequired);// 域名为空检查
domainTextField.getValidators().add(TextValidate.domainFormatValidator(proxySetupModel));// 域名格式检查
domainTextField.getValidators().add(TextValidate.domainLengthValidator(proxySetupModel));// 域名长度检查
domainTextField.getValidators().add(TextValidate.domainAddressValidator(proxySetupModel));// 自定义域名解析检查
} else
domainTextField.validate();
2022-04-06 17:49:00 +08:00
});
// 点击隧道列表
proxyListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
2022-04-09 03:59:20 +08:00
ObservableList<Label> items = proxyListView.getItems();
if (items.size() == 0) return;
2022-04-09 03:59:20 +08:00
for (Label item : items) {
item.getStyleClass().remove(PROXY_LIST_ITEM_SELECT_CLASS);
}
2022-04-06 17:49:00 +08:00
if (newValue != null) {
2022-04-09 03:59:20 +08:00
newValue.getStyleClass().add(PROXY_LIST_ITEM_SELECT_CLASS);
int oldIndex = items.indexOf(oldValue);
int newIndex = items.indexOf(newValue);
// 保存隧道状态
ObservableList<ProxySetup> proxyList = proxyList();
if (oldIndex != -1 && StringUtils.isNotEmpty(proxyList.get(oldIndex).getProxy_name()))
proxyList.set(oldIndex, proxySetupModel.get());
ProxySetup proxySetup = proxyList.get(newIndex);
selectProxy(newIndex);
2022-04-09 03:59:20 +08:00
Platform.runLater(() -> {
setup.set(false);
2022-04-09 03:59:20 +08:00
proxySetupModel.set(proxySetup);
if (proxySetup.getId() != null) {
FrpManager frpManager = frpUtilMap.get(proxySetup.getId().toString());
proxyLogPane.contentProperty().set(frpManager == null ? null : frpManager.getConsole());
}
setup.set(true);
setDomainLink();
2022-04-09 03:59:20 +08:00
});
2022-04-06 17:49:00 +08:00
}
});
// 添加隧道
addProxyBtn.setOnMouseClicked(event -> {
// 获取默认隧道设置加入列表
ObservableList<ProxySetup> proxyList = proxyList();
addProxyList(ProxyManager.initProxy(proxyList.get(proxyList.size() - 1).getSort()));
// 重置隧道列表视图
initProxyListView();
proxyListView.getSelectionModel().select(proxyListView.getItems().size() - 1);
2022-04-06 17:49:00 +08:00
});
2022-04-09 03:59:20 +08:00
// 启动
startProxyBtn.setOnMouseClicked(event -> {
if (proxySetupModel.isRunning())
stopProxy();
else
startProxy();
});
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 链接跳转
domainLink.setOnMouseClicked(event -> getApplication().getHostServices().showDocument(domainLink.getText()));
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 复制外网访问地址
copyDomainBtn.setOnMouseClicked(event -> {
//获取系统剪切板
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
//构建String数据类型
StringSelection selection = new StringSelection(domainLink.getText());
//添加文本到系统剪切板
clipboard.setContents(selection, null);
// 复制成功提示
AlertUtil.info("复制成功,快去分享给小伙伴吧!").show();
});
2022-04-06 17:49:00 +08:00
// 退出登录
logoutBtn.setOnMouseClicked(event -> {
for (String key : frpUtilMap.keySet()) {
frpUtilMap.get(key).stop();
}
ApplicatonStore.logout();
2022-04-06 17:49:00 +08:00
try {
jumpTo(new LoginController());
2022-04-06 17:49:00 +08:00
} catch (IOException e) {
e.printStackTrace();
}
});
2022-04-06 17:49:00 +08:00
}
//
// private void initEmptyProxyListView() {
// // 初始化视图模型
// proxySetup = ProxyManager.initProxy(null);
// proxySetupModel = new ProxySetupModel(proxySetup);
// setProxyList(Collections.singletonList(proxySetup));
// initProxyListView();
// }
2022-04-06 17:49:00 +08:00
/**
* 是否启用当前隧道
*/
private void closeProxy(boolean close) {
2022-04-09 03:59:20 +08:00
if (close && proxySetupModel.isRunning()) stopProxy();
2022-04-06 17:49:00 +08:00
proxyNameTextField.setDisable(close);// 隧道名称
2022-04-09 03:59:20 +08:00
proxyProtocolComboBox.setDisable(close);// 隧道类型
2022-04-06 17:49:00 +08:00
localHostTextField.setDisable(close);// 本地地址
localPortTextField.setDisable(close);// 本地端口
domainTextField.setDisable(close); // 外网子域名
startProxyBtn.setDisable(close); // 启动按钮
ObservableList<String> styleClass = proxyListView.getItems().get(selectProxy()).getStyleClass();
2022-04-09 03:59:20 +08:00
styleClass.remove(PROXY_LIST_ITEM_STOP_CLASS);
styleClass.remove(PROXY_LIST_ITEM_RUN_CLASS);
styleClass.remove(PROXY_LIST_ITEM_CLOSE_CLASS);
2022-04-06 17:49:00 +08:00
if (close) {
styleClass.add(PROXY_LIST_ITEM_CLOSE_CLASS);
} else {
2022-04-09 03:59:20 +08:00
styleClass.add(proxySetupModel.isRunning() ? PROXY_LIST_ITEM_RUN_CLASS : PROXY_LIST_ITEM_STOP_CLASS);
2022-04-06 17:49:00 +08:00
}
}
private void initProxyListView() {
ObservableList<ProxySetup> proxyList = proxyList();
for (ProxySetup proxy : proxyList.subList(proxyListView.getItems().size(), proxyList.size())) {
setProxyListView(proxyList.indexOf(proxy), proxy);
}
// 设置选中
proxyListView.getSelectionModel().select(selectProxy());
}
private void setProxyListView(int index, ProxySetup setup) {
ObservableList<Label> items = proxyListView.getItems();
try {
Label label = FXMLLoader.load(getClass().getResource("/fxml/proxyItem.fxml"));
label.textProperty().set(setup.getProxy_name());
ObservableList<String> styleClass = label.getStyleClass();
styleClass.addAll(PROXY_LIST_ITEM_CLASS, setup.isRuning() ? PROXY_LIST_ITEM_RUN_CLASS : PROXY_LIST_ITEM_STOP_CLASS);
if (index < items.size()) {
items.set(index, label);
} else {
items.add(label);
}
} catch (IOException e) {
e.printStackTrace();
}
}
2022-04-06 17:49:00 +08:00
/**
* 启动代理
2022-04-06 17:49:00 +08:00
*/
private void startProxy() {
// 验证
if (!domainTextField.validate() || !localHostTextField.validate() || !localPortTextField.validate())
return;
2022-04-09 03:59:20 +08:00
// 非 http 隧道系统随机分配端口
if (!DomainUtil.isHttp(proxySetupModel)) {
proxySetupModel.setRemotePort(String.valueOf(ProxyManager.randomPort()));
2022-04-09 03:59:20 +08:00
}
2022-04-06 17:49:00 +08:00
// 是否有修改
if (!proxySetupModel.get().equals(userProxy.get(proxySetupModel.getId()))) {
// 添加隧道
ProxyManager.add(new OnHttpListener<ProxySetup>() {
@Override
public void onSucceed(ProxySetup result) {
// 如果添加成功
if (result != null) {
userProxy.put(result.getId().toString(), result);
start(result);
}
}
@Override
public void onFail(Exception e) {
}
2022-04-09 03:59:20 +08:00
}, proxySetupModel.get());
} else {
start(proxySetupModel.get());
2022-04-09 03:59:20 +08:00
}
}
private void start(ProxySetup setup) {
// 添加成功,设置运行状态
2022-04-11 17:24:50 +08:00
setup.setRuning(frpUtilMap.containsKey(setup.getId().toString()));
proxySetupModel.set(setup);
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 初始化frputil
FrpManager frpManager;
2022-04-11 17:24:50 +08:00
if ((frpManager = frpUtilMap.get(setup.getId().toString())) == null)
frpUtilMap.put(proxySetupModel.getId(), frpManager = FrpManager.init(proxySetupModel));
2022-04-06 17:49:00 +08:00
2022-04-09 03:59:20 +08:00
// 设置文本域对象
if (proxyLogPane.getContent() == null) proxyLogPane.contentProperty().set(frpManager.getConsole());
2022-04-09 03:59:20 +08:00
// 开始
frpManager.start();
// 显示日志
tabPane.getSelectionModel().select(0);
2022-04-06 17:49:00 +08:00
}
/**
* 暂停代理
2022-04-06 17:49:00 +08:00
*/
private void stopProxy() {
// 关闭CMD
FrpManager frpManager = frpUtilMap.get(proxySetupModel.getId());
if (frpManager != null) frpManager.stop();
}
@Override
public void onDestroy() {
super.onDestroy();
2022-04-06 17:49:00 +08:00
}
}