修复 新建隧道的重置bug

This commit is contained in:
octopusYan 2022-04-11 17:24:50 +08:00
parent 27e124dfaf
commit ca480243ae
3 changed files with 27 additions and 16 deletions

View File

@ -8,14 +8,15 @@ import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import okhttp3.logging.HttpLoggingInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.octopusyan.config.OkHttpClientConfig;
import top.octopusyan.controller.LoginController;
import top.octopusyan.http.HttpConfig;
import top.octopusyan.http.config.LogStrategy;
import top.octopusyan.http.request.RequestHandler;
import top.octopusyan.manager.FrpManager;
import top.octopusyan.manager.http.OkHttpClientConfig;
import top.octopusyan.model.ApplicatonStore;
import top.octopusyan.utils.AlertUtil;
import top.octopusyan.utils.EncryptionUtil;
@ -46,12 +47,17 @@ public class YanFrpApplication extends Application {
// 初始化frp客户端临时文件
FrpManager.initFrpc();
// 网络请求日志
OkHttpClientConfig.showLog = false;
// 网络请求设置
HttpConfig.with(OkHttpClientConfig.httpClient())
HttpConfig.with(OkHttpClientConfig.httpClient(
HttpLoggingInterceptor.Level.HEADERS
))
// 请求服务地址
.serverPath("https://frp.octopusyan.top")
// 是否打印日志
.setLogEnabled(false)
.setLogEnabled(true)
// 设置日志打印策略
.setLogStrategy(new LogStrategy())
// 设置请求处理策略

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http;
package top.octopusyan.config;
import kotlin.text.Charsets;
import okhttp3.*;
@ -26,19 +26,23 @@ import java.util.concurrent.TimeUnit;
* @create : 2022-4-2 15:27
*/
public class OkHttpClientConfig {
public static boolean showLog = false;
public static final String TAG = "OkHttpLogger";
private static final Logger log = LoggerFactory.getLogger(TAG);
public static final HashMap<String, List<Cookie>> cookieStore = new HashMap<>();
public static OkHttpClient httpClient() {
/**
* 初始化okhttp client
* @param logLevel 日志等级
*/
public static OkHttpClient httpClient(HttpLoggingInterceptor.Level logLevel) {
HttpLoggingInterceptor logginInterceptor = new HttpLoggingInterceptor(
new HttpLoggingInterceptor.Logger() {
@Override
public void log(String message) {
try {
log.info(message);
if(showLog) log.info(message);
} catch (Exception e) {
e.printStackTrace();
log.error(message);
@ -48,11 +52,11 @@ public class OkHttpClientConfig {
);
// setlevel用来设置日志打印的级别共包括了四个级别NONE,BASIC,HEADER,BODY
// BASEIC:请求/响应行
// HEADER:请求/响应行 +
// BASIC:请求/响应行
// HEADERS:请求/响应行 +
// BODY:请求/响应行 + +
//包含headerbody数据
logginInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
logginInterceptor.setLevel(logLevel);
Dispatcher dispatcher = new Dispatcher();
dispatcher.setMaxRequests(16);

View File

@ -326,10 +326,11 @@ public class MainController extends BaseController<StackPane> implements Initial
// 重置
resetProxyBtn.setOnMouseClicked(event -> {
ProxySetup proxySetup = userProxy.get(proxySetupModel.getId());
proxySetup = userProxy.get(proxySetup.getId());
proxySetup.setRuning(proxySetupModel.isRunning());
proxySetupModel.set(proxySetup);
domainTextField.resetValidation();
if(proxySetup != null){
proxySetup.setRuning(proxySetupModel.isRunning());
proxySetupModel.set(proxySetup);
domainTextField.resetValidation();
}
});
// 日志清理
@ -565,12 +566,12 @@ public class MainController extends BaseController<StackPane> implements Initial
private void start(ProxySetup setup) {
// 添加成功设置运行状态
setup.setRuning(frpUtilMap.containsKey(setup.getId()));
setup.setRuning(frpUtilMap.containsKey(setup.getId().toString()));
proxySetupModel.set(setup);
// 初始化frputil
FrpManager frpManager;
if ((frpManager = frpUtilMap.get(setup.getId())) == null)
if ((frpManager = frpUtilMap.get(setup.getId().toString())) == null)
frpUtilMap.put(proxySetupModel.getId(), frpManager = FrpManager.init(proxySetupModel));
// 设置文本域对象