移动/manager/http -> /http 与 /http -> /manager/http

修复切换禁用后启动后变禁用的bug
This commit is contained in:
octopusYan 2022-04-11 17:09:00 +08:00
parent 1ddf14060e
commit 27e124dfaf
65 changed files with 238 additions and 256 deletions

View File

@ -85,19 +85,13 @@
</dependency>
<!-- 算法库 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
<version>5.8.0.M2</version>
</dependency>
<!-- 算法库 -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.70</version>
</dependency>
<!-- json -->
<dependency>
<groupId>com.alibaba</groupId>

View File

@ -11,11 +11,11 @@ import javafx.stage.StageStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.octopusyan.controller.LoginController;
import top.octopusyan.http.OkHttpClientConfig;
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.HttpConfig;
import top.octopusyan.manager.http.config.LogStrategy;
import top.octopusyan.manager.http.request.RequestHandler;
import top.octopusyan.manager.http.OkHttpClientConfig;
import top.octopusyan.model.ApplicatonStore;
import top.octopusyan.utils.AlertUtil;
import top.octopusyan.utils.EncryptionUtil;

View File

@ -12,8 +12,8 @@ import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import top.octopusyan.http.EasyHttp;
import top.octopusyan.manager.FrpManager;
import top.octopusyan.manager.http.EasyHttp;
import top.octopusyan.model.ApplicatonStore;
import top.octopusyan.utils.FxmlUtil;
import top.octopusyan.utils.Loading;

View File

@ -19,14 +19,14 @@ import org.jetbrains.annotations.NotNull;
import org.kordamp.ikonli.javafx.FontIcon;
import top.octopusyan.base.BaseController;
import top.octopusyan.config.TextValidate;
import top.octopusyan.http.Api;
import top.octopusyan.http.request.FindPassParam;
import top.octopusyan.http.request.LoginParam;
import top.octopusyan.http.EasyHttp;
import top.octopusyan.http.api.NotParamApi;
import top.octopusyan.http.config.HttpConstant;
import top.octopusyan.http.listener.OnHttpListener;
import top.octopusyan.manager.ProxyManager;
import top.octopusyan.manager.http.EasyHttp;
import top.octopusyan.manager.http.api.NotParamApi;
import top.octopusyan.manager.http.config.HttpConstant;
import top.octopusyan.manager.http.listener.OnHttpListener;
import top.octopusyan.manager.http.Api;
import top.octopusyan.manager.http.request.FindPassParam;
import top.octopusyan.manager.http.request.LoginParam;
import top.octopusyan.model.ApplicatonStore;
import top.octopusyan.utils.AlertUtil;
import top.octopusyan.utils.JsoupUtil;

View File

@ -21,10 +21,10 @@ 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.request.ProxySetup;
import top.octopusyan.http.listener.OnHttpListener;
import top.octopusyan.manager.FrpManager;
import top.octopusyan.manager.ProxyManager;
import top.octopusyan.manager.http.listener.OnHttpListener;
import top.octopusyan.manager.http.request.ProxySetup;
import top.octopusyan.model.ApplicatonStore;
import top.octopusyan.model.ProxySetupModel;
import top.octopusyan.utils.AlertUtil;
@ -94,10 +94,9 @@ public class MainController extends BaseController<StackPane> implements Initial
private final ToggleGroup openProxyGroup = new ToggleGroup();
private final SimpleBooleanProperty customizeDomain = new SimpleBooleanProperty(false);
private final Map<Integer, FrpManager> frpUtilMap = new HashMap<>();
private final Map<Integer, ProxySetup> userProxy = new HashMap<>();
private final Map<String, FrpManager> frpUtilMap = new HashMap<>();
private final Map<String, ProxySetup> userProxy = new HashMap<>();
private ProxySetupModel proxySetupModel;
private ProxySetup proxySetup;
private final SimpleBooleanProperty setup = new SimpleBooleanProperty(false);
@Override
@ -134,7 +133,7 @@ public class MainController extends BaseController<StackPane> implements Initial
@Override
public void initData() {
// 初始化视图模型
proxySetup = ProxyManager.initProxy(null);
ProxySetup proxySetup = ProxyManager.initProxy(null);
proxySetupModel = new ProxySetupModel(proxySetup);
// 初始化用户隧道列表
setProxyList(Collections.singletonList(proxySetup));
@ -167,10 +166,9 @@ public class MainController extends BaseController<StackPane> implements Initial
// 保存用户隧道信息
for (ProxySetup setup : result) {
userProxy.put(setup.getId(), setup);
userProxy.put(setup.getId().toString(), setup);
}
proxySetup = result.get(selectProxy());
proxySetupModel.set(result.get(selectProxy()));
// 初始化用户隧道列表
setProxyList(result);
@ -230,7 +228,7 @@ public class MainController extends BaseController<StackPane> implements Initial
proxySetupModel.proxyTypeProperty().addListener((observable, oldValue, newValue) -> {
String newType = StringUtils.lowerCase(newValue);
String port, host;
if (!newType.equals(proxySetup.getProxy_type())) {
if (!newType.equals(userProxy.get(proxySetupModel.getId()))) {
host = "127.0.0.1";
port = ProxyConfig.getTypePort(newType).toString();
} else {
@ -296,7 +294,7 @@ public class MainController extends BaseController<StackPane> implements Initial
proxySetupModel.setDomainSuffix("." + ProxyConfig.getServerPath(proxySetupModel.getServer()));
} else {
proxySetupModel.setDomain(DomainUtil.getCustomize(proxySetupModel.get()));
proxySetupModel.setDomainSuffix(DomainUtil.getSuffix(proxySetup));
proxySetupModel.setDomainSuffix(DomainUtil.getSuffix(userProxy.get(proxySetupModel.getId())));
}
domainTextField.promptTextProperty().set("自定义子域名 大于3位");
customizeDomainBtn.setText("自定义");
@ -327,6 +325,7 @@ public class MainController extends BaseController<StackPane> implements Initial
public void initViewAction() {
// 重置
resetProxyBtn.setOnMouseClicked(event -> {
ProxySetup proxySetup = userProxy.get(proxySetupModel.getId());
proxySetup = userProxy.get(proxySetup.getId());
proxySetup.setRuning(proxySetupModel.isRunning());
proxySetupModel.set(proxySetup);
@ -335,6 +334,7 @@ public class MainController extends BaseController<StackPane> implements Initial
// 日志清理
clearLogBtn.setOnMouseClicked(event -> {
ProxySetup proxySetup = userProxy.get(proxySetupModel.getId());
if (frpUtilMap.get(proxySetup.getId()) != null)
frpUtilMap.get(proxySetup.getId()).clearLog();
});
@ -407,13 +407,15 @@ public class MainController extends BaseController<StackPane> implements Initial
ObservableList<ProxySetup> proxyList = proxyList();
if (oldIndex != -1 && StringUtils.isNotEmpty(proxyList.get(oldIndex).getProxy_name()))
proxyList.set(oldIndex, proxySetupModel.get());
proxySetup = proxyList.get(newIndex);
ProxySetup proxySetup = proxyList.get(newIndex);
selectProxy(newIndex);
Platform.runLater(() -> {
setup.set(false);
proxySetupModel.set(proxySetup);
FrpManager frpManager = frpUtilMap.get(proxySetup.getId());
if (proxySetup.getId() != null) {
FrpManager frpManager = frpUtilMap.get(proxySetup.getId().toString());
proxyLogPane.contentProperty().set(frpManager == null ? null : frpManager.getConsole());
}
setup.set(true);
setDomainLink();
});
@ -455,7 +457,7 @@ public class MainController extends BaseController<StackPane> implements Initial
// 退出登录
logoutBtn.setOnMouseClicked(event -> {
for (Integer key : frpUtilMap.keySet()) {
for (String key : frpUtilMap.keySet()) {
frpUtilMap.get(key).stop();
}
ApplicatonStore.logout();
@ -540,14 +542,14 @@ public class MainController extends BaseController<StackPane> implements Initial
}
// 是否有修改
if (!proxySetupModel.get().equals(userProxy.get(proxySetup.getId()))) {
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(), result);
userProxy.put(result.getId().toString(), result);
start(result);
}
}
@ -557,7 +559,7 @@ public class MainController extends BaseController<StackPane> implements Initial
}
}, proxySetupModel.get());
} else {
start(proxySetup);
start(proxySetupModel.get());
}
}
@ -569,7 +571,7 @@ public class MainController extends BaseController<StackPane> implements Initial
// 初始化frputil
FrpManager frpManager;
if ((frpManager = frpUtilMap.get(setup.getId())) == null)
frpUtilMap.put(proxySetup.getId(), frpManager = FrpManager.init(proxySetupModel));
frpUtilMap.put(proxySetupModel.getId(), frpManager = FrpManager.init(proxySetupModel));
// 设置文本域对象
if (proxyLogPane.getContent() == null) proxyLogPane.contentProperty().set(frpManager.getConsole());
@ -586,7 +588,7 @@ public class MainController extends BaseController<StackPane> implements Initial
*/
private void stopProxy() {
// 关闭CMD
FrpManager frpManager = frpUtilMap.get(proxySetup.getId());
FrpManager frpManager = frpUtilMap.get(proxySetupModel.getId());
if (frpManager != null) frpManager.stop();
}

View File

@ -11,11 +11,11 @@ import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import top.octopusyan.base.BaseController;
import top.octopusyan.config.TextValidate;
import top.octopusyan.http.Api;
import top.octopusyan.http.request.RegisterParam;
import top.octopusyan.http.request.SendEmailCheckParam;
import top.octopusyan.manager.http.EasyHttp;
import top.octopusyan.manager.http.listener.OnHttpListener;
import top.octopusyan.http.EasyHttp;
import top.octopusyan.http.listener.OnHttpListener;
import top.octopusyan.manager.http.Api;
import top.octopusyan.manager.http.request.RegisterParam;
import top.octopusyan.manager.http.request.SendEmailCheckParam;
import top.octopusyan.model.ApplicatonStore;
import top.octopusyan.utils.AlertUtil;
import top.octopusyan.utils.JsoupUtil;

View File

@ -1,13 +1,13 @@
package top.octopusyan.manager.http;
package top.octopusyan.http;
import okhttp3.OkHttpClient;
import top.octopusyan.manager.http.api.NotParamApi;
import top.octopusyan.manager.http.api.ParamApi;
import top.octopusyan.manager.http.config.HttpConstant;
import top.octopusyan.manager.http.config.LogStrategy;
import top.octopusyan.manager.http.listener.OnHttpListener;
import top.octopusyan.manager.http.model.ResponseClass;
import top.octopusyan.manager.http.request.RequestHandler;
import top.octopusyan.http.api.NotParamApi;
import top.octopusyan.http.api.ParamApi;
import top.octopusyan.http.config.HttpConstant;
import top.octopusyan.http.config.LogStrategy;
import top.octopusyan.http.listener.OnHttpListener;
import top.octopusyan.http.model.ResponseClass;
import top.octopusyan.http.request.RequestHandler;
/**
* @author : octopus yan

View File

@ -1,19 +1,19 @@
package top.octopusyan.manager.http;
package top.octopusyan.http;
import okhttp3.*;
import top.octopusyan.manager.http.annotation.HttpHeader;
import top.octopusyan.manager.http.annotation.HttpIgnore;
import top.octopusyan.manager.http.annotation.HttpRename;
import top.octopusyan.manager.http.api.NotParamApi;
import top.octopusyan.manager.http.api.ParamApi;
import top.octopusyan.manager.http.api.PathParamApi;
import top.octopusyan.manager.http.api.RequestApi;
import top.octopusyan.manager.http.callback.NormalCallback;
import top.octopusyan.manager.http.config.BodyType;
import top.octopusyan.manager.http.config.HttpConstant;
import top.octopusyan.manager.http.listener.OnHttpListener;
import top.octopusyan.manager.http.model.*;
import top.octopusyan.manager.http.request.IRequestHandler;
import top.octopusyan.http.annotation.HttpHeader;
import top.octopusyan.http.annotation.HttpIgnore;
import top.octopusyan.http.annotation.HttpRename;
import top.octopusyan.http.api.NotParamApi;
import top.octopusyan.http.api.ParamApi;
import top.octopusyan.http.api.PathParamApi;
import top.octopusyan.http.api.RequestApi;
import top.octopusyan.http.callback.NormalCallback;
import top.octopusyan.http.config.BodyType;
import top.octopusyan.http.config.HttpConstant;
import top.octopusyan.http.listener.OnHttpListener;
import top.octopusyan.http.model.*;
import top.octopusyan.http.request.IRequestHandler;
import java.io.File;
import java.io.InputStream;
@ -32,25 +32,39 @@ import java.util.Map;
*/
public class EasyHttp<Param, Result> {
/** 请求处理策略 */
/**
* 请求处理策略
*/
private final IRequestHandler mHandler = HttpConfig.getInstance().getHandler();
/** 请求执行代理类 */
/**
* 请求执行代理类
*/
private CallProxy mCallProxy;
/** 请求标记 */
/**
* 请求标记
*/
private String mTag;
/** 请求延迟 */
/**
* 请求延迟
*/
private long mDelayMillis;
/** 请求服务地址 */
/**
* 请求服务地址
*/
private final String server = HttpConfig.getInstance().getServerPath();
/** 请求接口 */
/**
* 请求接口
*/
private RequestApi<Param, Result> mRequestApi;
/** 请求参数 */
/**
* 请求参数
*/
private Param param;
public static class Builder {
@ -87,6 +101,7 @@ public class EasyHttp<Param, Result> {
/**
* 带参请求
*
* @param param 请求参数
*/
public <Param, Result> ParamRequest<Param, Result> build(Param param, ResponseClass<Result> result) {
@ -176,6 +191,7 @@ public class EasyHttp<Param, Result> {
/**
* 执行同步请求
*
* @param responseClass 需要解析泛型的对象
* @return 返回解析完成的对象
* @throws Exception 如果请求失败或者解析失败则抛出异常
@ -548,7 +564,6 @@ public class EasyHttp<Param, Result> {
}
/**
*
* 带参数请求
*
* @param <Param> 参数类型

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http;
package top.octopusyan.http;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
@ -7,11 +7,11 @@ import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import org.apache.commons.lang3.StringUtils;
import top.octopusyan.http.annotation.HttpIgnore;
import top.octopusyan.http.annotation.HttpRename;
import top.octopusyan.http.config.ContentType;
import top.octopusyan.http.model.UpdateBody;
import top.octopusyan.manager.ThreadPoolManager;
import top.octopusyan.manager.http.annotation.HttpIgnore;
import top.octopusyan.manager.http.annotation.HttpRename;
import top.octopusyan.manager.http.config.ContentType;
import top.octopusyan.manager.http.model.UpdateBody;
import java.io.*;
import java.lang.reflect.Field;

View File

@ -1,8 +1,8 @@
package top.octopusyan.manager.http;
package top.octopusyan.http;
import okhttp3.OkHttpClient;
import top.octopusyan.manager.http.config.ILogStrategy;
import top.octopusyan.manager.http.request.IRequestHandler;
import top.octopusyan.http.config.ILogStrategy;
import top.octopusyan.http.request.IRequestHandler;
import java.net.MalformedURLException;
import java.net.URL;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http;
package top.octopusyan.http;
/**
* @author : octopus yan

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.annotation;
package top.octopusyan.http.annotation;
import java.lang.annotation.*;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.annotation;
package top.octopusyan.http.annotation;
import java.lang.annotation.*;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.annotation;
package top.octopusyan.http.annotation;
import java.lang.annotation.*;

View File

@ -1,6 +1,6 @@
package top.octopusyan.manager.http.api;
package top.octopusyan.http.api;
import top.octopusyan.manager.http.config.BodyType;
import top.octopusyan.http.config.BodyType;
/**
* @author : octopus yan

View File

@ -1,6 +1,6 @@
package top.octopusyan.manager.http.api;
package top.octopusyan.http.api;
import top.octopusyan.manager.http.config.BodyType;
import top.octopusyan.http.config.BodyType;
/**
* @author : octopus yan

View File

@ -1,6 +1,6 @@
package top.octopusyan.manager.http.api;
package top.octopusyan.http.api;
import top.octopusyan.manager.http.config.BodyType;
import top.octopusyan.http.config.BodyType;
/**
* @author : octopus yan

View File

@ -1,7 +1,7 @@
package top.octopusyan.manager.http.api;
package top.octopusyan.http.api;
import lombok.Data;
import top.octopusyan.manager.http.config.BodyType;
import top.octopusyan.http.config.BodyType;
/**
* @author : octopus yan

View File

@ -1,13 +1,13 @@
package top.octopusyan.manager.http.callback;
package top.octopusyan.http.callback;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import top.octopusyan.manager.http.EasyUtils;
import top.octopusyan.manager.http.HttpConfig;
import top.octopusyan.manager.http.HttpLog;
import top.octopusyan.manager.http.model.CallProxy;
import top.octopusyan.http.EasyUtils;
import top.octopusyan.http.HttpConfig;
import top.octopusyan.http.HttpLog;
import top.octopusyan.http.model.CallProxy;
import java.io.IOException;
import java.net.SocketTimeoutException;

View File

@ -1,13 +1,13 @@
package top.octopusyan.manager.http.callback;
package top.octopusyan.http.callback;
import javafx.application.Platform;
import okhttp3.Response;
import top.octopusyan.manager.http.EasyUtils;
import top.octopusyan.manager.http.HttpLog;
import top.octopusyan.manager.http.api.RequestApi;
import top.octopusyan.manager.http.listener.OnHttpListener;
import top.octopusyan.manager.http.model.CallProxy;
import top.octopusyan.manager.http.request.IRequestHandler;
import top.octopusyan.http.EasyUtils;
import top.octopusyan.http.HttpLog;
import top.octopusyan.http.api.RequestApi;
import top.octopusyan.http.listener.OnHttpListener;
import top.octopusyan.http.model.CallProxy;
import top.octopusyan.http.request.IRequestHandler;
/**
* @author : octopus yan

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.config;
package top.octopusyan.http.config;
/**
* @author : octopus yan

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.config;
package top.octopusyan.http.config;
import okhttp3.MediaType;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.config;
package top.octopusyan.http.config;
/**
* @author : octopus yan

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.config;
package top.octopusyan.http.config;
/**
* @author : octopus yan

View File

@ -1,10 +1,10 @@
package top.octopusyan.manager.http.config;
package top.octopusyan.http.config;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.octopusyan.manager.http.EasyHttp;
import top.octopusyan.manager.http.HttpConfig;
import top.octopusyan.http.EasyHttp;
import top.octopusyan.http.HttpConfig;
/**
* @author : octopus yan

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
/**
* 请求取消异常

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
/**
* 数据解析异常

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
/**
* 网络请求异常

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
/**
* 网络连接异常

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
import okhttp3.Response;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
/**
* 返回结果异常

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
/**
* 服务器连接异常

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
/**
* 服务器超时异常

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.exception;
package top.octopusyan.http.exception;
/**
* Token 失效异常

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.listener;
package top.octopusyan.http.listener;
import okhttp3.Call;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.model;
package top.octopusyan.http.model;
import okhttp3.Call;
import okhttp3.Callback;

View File

@ -1,6 +1,6 @@
package top.octopusyan.manager.http.model;
package top.octopusyan.http.model;
import top.octopusyan.manager.http.HttpConfig;
import top.octopusyan.http.HttpConfig;
import java.util.HashMap;
import java.util.Set;

View File

@ -1,6 +1,6 @@
package top.octopusyan.manager.http.model;
package top.octopusyan.http.model;
import top.octopusyan.manager.http.HttpConfig;
import top.octopusyan.http.HttpConfig;
import java.util.HashMap;
import java.util.Set;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.model;
package top.octopusyan.http.model;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@ -7,7 +7,7 @@ import lombok.NonNull;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
import top.octopusyan.manager.http.config.ContentType;
import top.octopusyan.http.config.ContentType;
import java.io.IOException;
import java.util.List;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.model;
package top.octopusyan.http.model;
/**
* @author : octopus yan

View File

@ -1,12 +1,12 @@
package top.octopusyan.manager.http.model;
package top.octopusyan.http.model;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
import okio.Okio;
import okio.Source;
import top.octopusyan.manager.http.EasyUtils;
import top.octopusyan.manager.http.config.ContentType;
import top.octopusyan.http.EasyUtils;
import top.octopusyan.http.config.ContentType;
import java.io.File;
import java.io.FileNotFoundException;

View File

@ -1,9 +1,9 @@
package top.octopusyan.manager.http.request;
package top.octopusyan.http.request;
import okhttp3.Request;
import okhttp3.Response;
import top.octopusyan.manager.http.EasyUtils;
import top.octopusyan.manager.http.api.RequestApi;
import top.octopusyan.http.EasyUtils;
import top.octopusyan.http.api.RequestApi;
import java.lang.reflect.Type;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.request;
package top.octopusyan.http.request;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@ -8,10 +8,10 @@ import okhttp3.Headers;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import top.octopusyan.manager.http.HttpLog;
import top.octopusyan.manager.http.api.RequestApi;
import top.octopusyan.manager.http.exception.*;
import top.octopusyan.manager.http.response.BaseRest;
import top.octopusyan.http.HttpLog;
import top.octopusyan.http.api.RequestApi;
import top.octopusyan.http.exception.*;
import top.octopusyan.http.response.BaseRest;
import java.io.IOException;
import java.io.InputStream;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.response;
package top.octopusyan.http.response;
import java.io.Serializable;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.ssl;
package top.octopusyan.http.ssl;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;

View File

@ -1,6 +1,6 @@
package top.octopusyan.manager.http.ssl;
package top.octopusyan.http.ssl;
import top.octopusyan.manager.http.HttpLog;
import top.octopusyan.http.HttpLog;
import javax.net.ssl.*;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.ssl;
package top.octopusyan.http.ssl;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

View File

@ -1,4 +1,4 @@
package top.octopusyan.manager.http.ssl;
package top.octopusyan.http.ssl;
import javax.net.ssl.X509TrustManager;
import java.security.cert.X509Certificate;

View File

@ -6,9 +6,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import top.octopusyan.http.Api;
import top.octopusyan.manager.http.EasyHttp;
import top.octopusyan.manager.http.model.ResponseClass;
import top.octopusyan.http.EasyHttp;
import top.octopusyan.http.model.ResponseClass;
import top.octopusyan.manager.http.Api;
import top.octopusyan.model.ApplicatonStore;
import top.octopusyan.model.ProxySetupModel;
import top.octopusyan.utils.JsoupUtil;

View File

@ -8,11 +8,11 @@ import org.jsoup.select.Elements;
import top.octopusyan.config.ProxyConfig;
import top.octopusyan.config.ProxyConfig.ProxyServer;
import top.octopusyan.config.ProxyConfig.ProxyType;
import top.octopusyan.http.Api;
import top.octopusyan.http.request.ProxySetup;
import top.octopusyan.manager.http.EasyHttp;
import top.octopusyan.manager.http.listener.OnHttpListener;
import top.octopusyan.manager.http.model.ResponseClass;
import top.octopusyan.http.EasyHttp;
import top.octopusyan.http.listener.OnHttpListener;
import top.octopusyan.http.model.ResponseClass;
import top.octopusyan.manager.http.Api;
import top.octopusyan.manager.http.request.ProxySetup;
import top.octopusyan.utils.AlertUtil;
import java.util.List;

View File

@ -1,12 +1,12 @@
package top.octopusyan.http;
package top.octopusyan.manager.http;
import top.octopusyan.http.request.*;
import top.octopusyan.http.api.NotParamApi;
import top.octopusyan.http.api.ParamApi;
import top.octopusyan.http.api.PathParamApi;
import top.octopusyan.http.config.BodyType;
import top.octopusyan.http.config.HttpConstant;
import top.octopusyan.manager.ProxyManager;
import top.octopusyan.manager.http.api.NotParamApi;
import top.octopusyan.manager.http.api.ParamApi;
import top.octopusyan.manager.http.api.PathParamApi;
import top.octopusyan.manager.http.config.BodyType;
import top.octopusyan.manager.http.config.HttpConstant;
import top.octopusyan.manager.http.request.*;
/**
* @author : octopus yan

View File

@ -1,14 +1,15 @@
package top.octopusyan.http;
package top.octopusyan.manager.http;
import kotlin.text.Charsets;
import okhttp3.*;
import okhttp3.logging.HttpLoggingInterceptor;
import okio.Buffer;
import okio.BufferedSource;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.octopusyan.manager.http.ssl.HttpSslConfig;
import top.octopusyan.manager.http.ssl.HttpSslFactory;
import top.octopusyan.http.ssl.HttpSslConfig;
import top.octopusyan.http.ssl.HttpSslFactory;
import java.io.IOException;
import java.nio.charset.Charset;
@ -25,35 +26,33 @@ import java.util.concurrent.TimeUnit;
* @create : 2022-4-2 15:27
*/
public class OkHttpClientConfig {
public static final String TAG = "OkHttpClientConfig";
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() {
//全局拦截器往请求头部添加 token 字段实现全局添加 token
Interceptor tokenInterceptor = chain -> {// 打印请求报文
// 获取请求
Request request = chain.request();
// 取出请求参数
String reqBody = getRequestBody(request);
HttpLoggingInterceptor logginInterceptor = new HttpLoggingInterceptor(
new HttpLoggingInterceptor.Logger() {
@Override
public void log(String message) {
try {
log.info(message);
} catch (Exception e) {
e.printStackTrace();
log.error(message);
}
}
}
);
// 打印请求报文
log.info("" + TAG + "" + String.format("发送新请求\n-\tmethod%s\n-\turl%s\n-\theaders: %s\n-\tbody%s",
request.method(), request.url(), request.headers(), reqBody));
// 执行请求获取响应报文
Response response = chain.proceed(request);
// 获取响应内容 TODO 读取结果乱码
String respBody = getResponseBody(response);
// 打印响应报文
// log.info("" + TAG + "" + String.format("收到响应 %s %s\n-\t请求url%s\n-\t请求body%s\n-\t响应body%s",
// response.code(), response.message(), response.request().url(), reqBody, respBody));
log.info("" + TAG + "" + String.format("收到响应 %s %s\n-\t请求url%s\n-\t请求body%s",
response.code(), response.message(), response.request().url(), reqBody));
return response;
};
// setlevel用来设置日志打印的级别共包括了四个级别NONE,BASIC,HEADER,BODY
// BASEIC:请求/响应行
// HEADER:请求/响应行 +
// BODY:请求/响应行 + +
//包含headerbody数据
logginInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
Dispatcher dispatcher = new Dispatcher();
dispatcher.setMaxRequests(16);
@ -63,7 +62,7 @@ public class OkHttpClientConfig {
return new OkHttpClient.Builder()
.retryOnConnectionFailure(true)
.addNetworkInterceptor(tokenInterceptor)
.addInterceptor(logginInterceptor)
.dispatcher(dispatcher)
.cookieJar(cookieJar())
.connectionPool(new ConnectionPool(16, 5, TimeUnit.MINUTES))

View File

@ -1,4 +1,4 @@
package top.octopusyan.http.request;
package top.octopusyan.manager.http.request;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package top.octopusyan.http.request;
package top.octopusyan.manager.http.request;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package top.octopusyan.http.request;
package top.octopusyan.manager.http.request;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package top.octopusyan.http.request;
package top.octopusyan.manager.http.request;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package top.octopusyan.http.request;
package top.octopusyan.manager.http.request;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@ -8,7 +8,7 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.apache.commons.io.FileUtils;
import top.octopusyan.http.request.ProxySetup;
import top.octopusyan.manager.http.request.ProxySetup;
import top.octopusyan.utils.EncryptionUtil;
import java.io.File;

View File

@ -5,7 +5,7 @@ import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import org.apache.commons.lang3.StringUtils;
import top.octopusyan.config.ProxyConfig;
import top.octopusyan.http.request.ProxySetup;
import top.octopusyan.manager.http.request.ProxySetup;
import top.octopusyan.utils.DomainUtil;
/**

View File

@ -1,7 +1,7 @@
package top.octopusyan.utils;
import top.octopusyan.config.ProxyConfig;
import top.octopusyan.http.request.ProxySetup;
import top.octopusyan.manager.http.request.ProxySetup;
import top.octopusyan.model.ProxySetupModel;
import java.net.InetAddress;

View File

@ -1,9 +1,9 @@
package top.octopusyan.utils;
import cn.hutool.core.codec.Base64;
import cn.hutool.crypto.ProviderFactory;
import cn.hutool.crypto.SecureUtil;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.BASE64Encoder;
@ -168,7 +168,7 @@ public class EncryptionUtil {
*/
public static String AESencode(String data, String password) throws Exception {
byte[] result;
Security.addProvider(new BouncyCastleProvider());
Security.addProvider(ProviderFactory.createBouncyCastleProvider());
// 创建密码器
// 初始化为加密模式的密码
Cipher_ALGORITHM_MODE_PADDING.init(Cipher.ENCRYPT_MODE, getSecretKey(password));
@ -186,7 +186,7 @@ public class EncryptionUtil {
*/
public static String AESdecode(String base64Data, String password) throws Exception {
byte[] result;
Security.addProvider(new BouncyCastleProvider());
Security.addProvider(ProviderFactory.createBouncyCastleProvider());
// 使用密钥初始化设置为解密模式
Cipher_ALGORITHM_MODE_PADDING.init(Cipher.DECRYPT_MODE, getSecretKey(password));
// 执行操作

View File

@ -1,19 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXCheckBox?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import com.jfoenix.controls.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.*?>
<?import org.kordamp.ikonli.javafx.FontIcon?>
<StackPane fx:id="root" prefHeight="330.0" prefWidth="430.0" stylesheets="@../css/login.css"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="top.octopusyan.controller.LoginController">

View File

@ -1,26 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXComboBox?>
<?import com.jfoenix.controls.JFXListView?>
<?import com.jfoenix.controls.JFXRadioButton?>
<?import com.jfoenix.controls.JFXTabPane?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import com.jfoenix.controls.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<?import org.kordamp.ikonli.javafx.FontIcon?>
<StackPane fx:id="root" prefHeight="700.0" prefWidth="750.0" stylesheets="@../css/main.css"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="top.octopusyan.controller.MainController">

View File

@ -4,7 +4,6 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.text.Font?>
<?import org.kordamp.ikonli.javafx.FontIcon?>
<Label text=" 默认连接" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<graphic>
<FontIcon iconLiteral="fa-circle" iconSize="14"/>

View File

@ -1,16 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import com.jfoenix.controls.*?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.*?>
<StackPane fx:id="root" prefHeight="330.0" prefWidth="430.0" stylesheets="@../css/register.css" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="top.octopusyan.controller.RegisterController">
<ImageView fx:id="registBkgPane" fitHeight="330.0" fitWidth="430.0">
<clip>