移动/manager/http -> /http 与 /http -> /manager/http
修复切换禁用后启动后变禁用的bug
This commit is contained in:
parent
1ddf14060e
commit
27e124dfaf
8
pom.xml
8
pom.xml
@ -85,19 +85,13 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 算法库 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-crypto</artifactId>
|
<artifactId>hutool-crypto</artifactId>
|
||||||
<version>5.8.0.M2</version>
|
<version>5.8.0.M2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 算法库 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
|
||||||
<version>1.70</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- json -->
|
<!-- json -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
|
@ -11,11 +11,11 @@ import javafx.stage.StageStyle;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import top.octopusyan.controller.LoginController;
|
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.FrpManager;
|
||||||
import top.octopusyan.manager.http.HttpConfig;
|
import top.octopusyan.manager.http.OkHttpClientConfig;
|
||||||
import top.octopusyan.manager.http.config.LogStrategy;
|
|
||||||
import top.octopusyan.manager.http.request.RequestHandler;
|
|
||||||
import top.octopusyan.model.ApplicatonStore;
|
import top.octopusyan.model.ApplicatonStore;
|
||||||
import top.octopusyan.utils.AlertUtil;
|
import top.octopusyan.utils.AlertUtil;
|
||||||
import top.octopusyan.utils.EncryptionUtil;
|
import top.octopusyan.utils.EncryptionUtil;
|
||||||
|
@ -12,8 +12,8 @@ import javafx.scene.layout.Pane;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import top.octopusyan.http.EasyHttp;
|
||||||
import top.octopusyan.manager.FrpManager;
|
import top.octopusyan.manager.FrpManager;
|
||||||
import top.octopusyan.manager.http.EasyHttp;
|
|
||||||
import top.octopusyan.model.ApplicatonStore;
|
import top.octopusyan.model.ApplicatonStore;
|
||||||
import top.octopusyan.utils.FxmlUtil;
|
import top.octopusyan.utils.FxmlUtil;
|
||||||
import top.octopusyan.utils.Loading;
|
import top.octopusyan.utils.Loading;
|
||||||
|
@ -19,14 +19,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.kordamp.ikonli.javafx.FontIcon;
|
import org.kordamp.ikonli.javafx.FontIcon;
|
||||||
import top.octopusyan.base.BaseController;
|
import top.octopusyan.base.BaseController;
|
||||||
import top.octopusyan.config.TextValidate;
|
import top.octopusyan.config.TextValidate;
|
||||||
import top.octopusyan.http.Api;
|
import top.octopusyan.http.EasyHttp;
|
||||||
import top.octopusyan.http.request.FindPassParam;
|
import top.octopusyan.http.api.NotParamApi;
|
||||||
import top.octopusyan.http.request.LoginParam;
|
import top.octopusyan.http.config.HttpConstant;
|
||||||
|
import top.octopusyan.http.listener.OnHttpListener;
|
||||||
import top.octopusyan.manager.ProxyManager;
|
import top.octopusyan.manager.ProxyManager;
|
||||||
import top.octopusyan.manager.http.EasyHttp;
|
import top.octopusyan.manager.http.Api;
|
||||||
import top.octopusyan.manager.http.api.NotParamApi;
|
import top.octopusyan.manager.http.request.FindPassParam;
|
||||||
import top.octopusyan.manager.http.config.HttpConstant;
|
import top.octopusyan.manager.http.request.LoginParam;
|
||||||
import top.octopusyan.manager.http.listener.OnHttpListener;
|
|
||||||
import top.octopusyan.model.ApplicatonStore;
|
import top.octopusyan.model.ApplicatonStore;
|
||||||
import top.octopusyan.utils.AlertUtil;
|
import top.octopusyan.utils.AlertUtil;
|
||||||
import top.octopusyan.utils.JsoupUtil;
|
import top.octopusyan.utils.JsoupUtil;
|
||||||
|
@ -21,10 +21,10 @@ import top.octopusyan.config.ProxyConfig;
|
|||||||
import top.octopusyan.config.ProxyConfig.ProxyServer;
|
import top.octopusyan.config.ProxyConfig.ProxyServer;
|
||||||
import top.octopusyan.config.ProxyConfig.ProxyType;
|
import top.octopusyan.config.ProxyConfig.ProxyType;
|
||||||
import top.octopusyan.config.TextValidate;
|
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.FrpManager;
|
||||||
import top.octopusyan.manager.ProxyManager;
|
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.ApplicatonStore;
|
||||||
import top.octopusyan.model.ProxySetupModel;
|
import top.octopusyan.model.ProxySetupModel;
|
||||||
import top.octopusyan.utils.AlertUtil;
|
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 ToggleGroup openProxyGroup = new ToggleGroup();
|
||||||
private final SimpleBooleanProperty customizeDomain = new SimpleBooleanProperty(false);
|
private final SimpleBooleanProperty customizeDomain = new SimpleBooleanProperty(false);
|
||||||
private final Map<Integer, FrpManager> frpUtilMap = new HashMap<>();
|
private final Map<String, FrpManager> frpUtilMap = new HashMap<>();
|
||||||
private final Map<Integer, ProxySetup> userProxy = new HashMap<>();
|
private final Map<String, ProxySetup> userProxy = new HashMap<>();
|
||||||
private ProxySetupModel proxySetupModel;
|
private ProxySetupModel proxySetupModel;
|
||||||
private ProxySetup proxySetup;
|
|
||||||
private final SimpleBooleanProperty setup = new SimpleBooleanProperty(false);
|
private final SimpleBooleanProperty setup = new SimpleBooleanProperty(false);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -134,7 +133,7 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
@Override
|
@Override
|
||||||
public void initData() {
|
public void initData() {
|
||||||
// 初始化视图模型
|
// 初始化视图模型
|
||||||
proxySetup = ProxyManager.initProxy(null);
|
ProxySetup proxySetup = ProxyManager.initProxy(null);
|
||||||
proxySetupModel = new ProxySetupModel(proxySetup);
|
proxySetupModel = new ProxySetupModel(proxySetup);
|
||||||
// 初始化用户隧道列表
|
// 初始化用户隧道列表
|
||||||
setProxyList(Collections.singletonList(proxySetup));
|
setProxyList(Collections.singletonList(proxySetup));
|
||||||
@ -167,10 +166,9 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
|
|
||||||
// 保存用户隧道信息
|
// 保存用户隧道信息
|
||||||
for (ProxySetup setup : result) {
|
for (ProxySetup setup : result) {
|
||||||
userProxy.put(setup.getId(), setup);
|
userProxy.put(setup.getId().toString(), setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxySetup = result.get(selectProxy());
|
|
||||||
proxySetupModel.set(result.get(selectProxy()));
|
proxySetupModel.set(result.get(selectProxy()));
|
||||||
// 初始化用户隧道列表
|
// 初始化用户隧道列表
|
||||||
setProxyList(result);
|
setProxyList(result);
|
||||||
@ -230,7 +228,7 @@ 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(proxySetup.getProxy_type())) {
|
if (!newType.equals(userProxy.get(proxySetupModel.getId()))) {
|
||||||
host = "127.0.0.1";
|
host = "127.0.0.1";
|
||||||
port = ProxyConfig.getTypePort(newType).toString();
|
port = ProxyConfig.getTypePort(newType).toString();
|
||||||
} else {
|
} else {
|
||||||
@ -296,7 +294,7 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
proxySetupModel.setDomainSuffix("." + ProxyConfig.getServerPath(proxySetupModel.getServer()));
|
proxySetupModel.setDomainSuffix("." + ProxyConfig.getServerPath(proxySetupModel.getServer()));
|
||||||
} else {
|
} else {
|
||||||
proxySetupModel.setDomain(DomainUtil.getCustomize(proxySetupModel.get()));
|
proxySetupModel.setDomain(DomainUtil.getCustomize(proxySetupModel.get()));
|
||||||
proxySetupModel.setDomainSuffix(DomainUtil.getSuffix(proxySetup));
|
proxySetupModel.setDomainSuffix(DomainUtil.getSuffix(userProxy.get(proxySetupModel.getId())));
|
||||||
}
|
}
|
||||||
domainTextField.promptTextProperty().set("自定义子域名 大于3位");
|
domainTextField.promptTextProperty().set("自定义子域名 大于3位");
|
||||||
customizeDomainBtn.setText("自定义");
|
customizeDomainBtn.setText("自定义");
|
||||||
@ -327,6 +325,7 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
public void initViewAction() {
|
public void initViewAction() {
|
||||||
// 重置
|
// 重置
|
||||||
resetProxyBtn.setOnMouseClicked(event -> {
|
resetProxyBtn.setOnMouseClicked(event -> {
|
||||||
|
ProxySetup proxySetup = userProxy.get(proxySetupModel.getId());
|
||||||
proxySetup = userProxy.get(proxySetup.getId());
|
proxySetup = userProxy.get(proxySetup.getId());
|
||||||
proxySetup.setRuning(proxySetupModel.isRunning());
|
proxySetup.setRuning(proxySetupModel.isRunning());
|
||||||
proxySetupModel.set(proxySetup);
|
proxySetupModel.set(proxySetup);
|
||||||
@ -335,6 +334,7 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
|
|
||||||
// 日志清理
|
// 日志清理
|
||||||
clearLogBtn.setOnMouseClicked(event -> {
|
clearLogBtn.setOnMouseClicked(event -> {
|
||||||
|
ProxySetup proxySetup = userProxy.get(proxySetupModel.getId());
|
||||||
if (frpUtilMap.get(proxySetup.getId()) != null)
|
if (frpUtilMap.get(proxySetup.getId()) != null)
|
||||||
frpUtilMap.get(proxySetup.getId()).clearLog();
|
frpUtilMap.get(proxySetup.getId()).clearLog();
|
||||||
});
|
});
|
||||||
@ -407,13 +407,15 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
ObservableList<ProxySetup> proxyList = proxyList();
|
ObservableList<ProxySetup> proxyList = proxyList();
|
||||||
if (oldIndex != -1 && StringUtils.isNotEmpty(proxyList.get(oldIndex).getProxy_name()))
|
if (oldIndex != -1 && StringUtils.isNotEmpty(proxyList.get(oldIndex).getProxy_name()))
|
||||||
proxyList.set(oldIndex, proxySetupModel.get());
|
proxyList.set(oldIndex, proxySetupModel.get());
|
||||||
proxySetup = proxyList.get(newIndex);
|
ProxySetup proxySetup = proxyList.get(newIndex);
|
||||||
selectProxy(newIndex);
|
selectProxy(newIndex);
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
setup.set(false);
|
setup.set(false);
|
||||||
proxySetupModel.set(proxySetup);
|
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());
|
proxyLogPane.contentProperty().set(frpManager == null ? null : frpManager.getConsole());
|
||||||
|
}
|
||||||
setup.set(true);
|
setup.set(true);
|
||||||
setDomainLink();
|
setDomainLink();
|
||||||
});
|
});
|
||||||
@ -455,7 +457,7 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
logoutBtn.setOnMouseClicked(event -> {
|
logoutBtn.setOnMouseClicked(event -> {
|
||||||
for (Integer key : frpUtilMap.keySet()) {
|
for (String key : frpUtilMap.keySet()) {
|
||||||
frpUtilMap.get(key).stop();
|
frpUtilMap.get(key).stop();
|
||||||
}
|
}
|
||||||
ApplicatonStore.logout();
|
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>() {
|
ProxyManager.add(new OnHttpListener<ProxySetup>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSucceed(ProxySetup result) {
|
public void onSucceed(ProxySetup result) {
|
||||||
// 如果添加成功
|
// 如果添加成功
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
userProxy.put(result.getId(), result);
|
userProxy.put(result.getId().toString(), result);
|
||||||
start(result);
|
start(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,7 +559,7 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
}
|
}
|
||||||
}, proxySetupModel.get());
|
}, proxySetupModel.get());
|
||||||
} else {
|
} else {
|
||||||
start(proxySetup);
|
start(proxySetupModel.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,7 +571,7 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
// 初始化frputil
|
// 初始化frputil
|
||||||
FrpManager frpManager;
|
FrpManager frpManager;
|
||||||
if ((frpManager = frpUtilMap.get(setup.getId())) == null)
|
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());
|
if (proxyLogPane.getContent() == null) proxyLogPane.contentProperty().set(frpManager.getConsole());
|
||||||
@ -586,7 +588,7 @@ public class MainController extends BaseController<StackPane> implements Initial
|
|||||||
*/
|
*/
|
||||||
private void stopProxy() {
|
private void stopProxy() {
|
||||||
// 关闭CMD
|
// 关闭CMD
|
||||||
FrpManager frpManager = frpUtilMap.get(proxySetup.getId());
|
FrpManager frpManager = frpUtilMap.get(proxySetupModel.getId());
|
||||||
if (frpManager != null) frpManager.stop();
|
if (frpManager != null) frpManager.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import top.octopusyan.base.BaseController;
|
import top.octopusyan.base.BaseController;
|
||||||
import top.octopusyan.config.TextValidate;
|
import top.octopusyan.config.TextValidate;
|
||||||
import top.octopusyan.http.Api;
|
import top.octopusyan.http.EasyHttp;
|
||||||
import top.octopusyan.http.request.RegisterParam;
|
import top.octopusyan.http.listener.OnHttpListener;
|
||||||
import top.octopusyan.http.request.SendEmailCheckParam;
|
import top.octopusyan.manager.http.Api;
|
||||||
import top.octopusyan.manager.http.EasyHttp;
|
import top.octopusyan.manager.http.request.RegisterParam;
|
||||||
import top.octopusyan.manager.http.listener.OnHttpListener;
|
import top.octopusyan.manager.http.request.SendEmailCheckParam;
|
||||||
import top.octopusyan.model.ApplicatonStore;
|
import top.octopusyan.model.ApplicatonStore;
|
||||||
import top.octopusyan.utils.AlertUtil;
|
import top.octopusyan.utils.AlertUtil;
|
||||||
import top.octopusyan.utils.JsoupUtil;
|
import top.octopusyan.utils.JsoupUtil;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package top.octopusyan.manager.http;
|
package top.octopusyan.http;
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import top.octopusyan.manager.http.api.NotParamApi;
|
import top.octopusyan.http.api.NotParamApi;
|
||||||
import top.octopusyan.manager.http.api.ParamApi;
|
import top.octopusyan.http.api.ParamApi;
|
||||||
import top.octopusyan.manager.http.config.HttpConstant;
|
import top.octopusyan.http.config.HttpConstant;
|
||||||
import top.octopusyan.manager.http.config.LogStrategy;
|
import top.octopusyan.http.config.LogStrategy;
|
||||||
import top.octopusyan.manager.http.listener.OnHttpListener;
|
import top.octopusyan.http.listener.OnHttpListener;
|
||||||
import top.octopusyan.manager.http.model.ResponseClass;
|
import top.octopusyan.http.model.ResponseClass;
|
||||||
import top.octopusyan.manager.http.request.RequestHandler;
|
import top.octopusyan.http.request.RequestHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,19 +1,19 @@
|
|||||||
package top.octopusyan.manager.http;
|
package top.octopusyan.http;
|
||||||
|
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
import top.octopusyan.manager.http.annotation.HttpHeader;
|
import top.octopusyan.http.annotation.HttpHeader;
|
||||||
import top.octopusyan.manager.http.annotation.HttpIgnore;
|
import top.octopusyan.http.annotation.HttpIgnore;
|
||||||
import top.octopusyan.manager.http.annotation.HttpRename;
|
import top.octopusyan.http.annotation.HttpRename;
|
||||||
import top.octopusyan.manager.http.api.NotParamApi;
|
import top.octopusyan.http.api.NotParamApi;
|
||||||
import top.octopusyan.manager.http.api.ParamApi;
|
import top.octopusyan.http.api.ParamApi;
|
||||||
import top.octopusyan.manager.http.api.PathParamApi;
|
import top.octopusyan.http.api.PathParamApi;
|
||||||
import top.octopusyan.manager.http.api.RequestApi;
|
import top.octopusyan.http.api.RequestApi;
|
||||||
import top.octopusyan.manager.http.callback.NormalCallback;
|
import top.octopusyan.http.callback.NormalCallback;
|
||||||
import top.octopusyan.manager.http.config.BodyType;
|
import top.octopusyan.http.config.BodyType;
|
||||||
import top.octopusyan.manager.http.config.HttpConstant;
|
import top.octopusyan.http.config.HttpConstant;
|
||||||
import top.octopusyan.manager.http.listener.OnHttpListener;
|
import top.octopusyan.http.listener.OnHttpListener;
|
||||||
import top.octopusyan.manager.http.model.*;
|
import top.octopusyan.http.model.*;
|
||||||
import top.octopusyan.manager.http.request.IRequestHandler;
|
import top.octopusyan.http.request.IRequestHandler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -32,25 +32,39 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class EasyHttp<Param, Result> {
|
public class EasyHttp<Param, Result> {
|
||||||
|
|
||||||
/** 请求处理策略 */
|
/**
|
||||||
|
* 请求处理策略
|
||||||
|
*/
|
||||||
private final IRequestHandler mHandler = HttpConfig.getInstance().getHandler();
|
private final IRequestHandler mHandler = HttpConfig.getInstance().getHandler();
|
||||||
|
|
||||||
/** 请求执行代理类 */
|
/**
|
||||||
|
* 请求执行代理类
|
||||||
|
*/
|
||||||
private CallProxy mCallProxy;
|
private CallProxy mCallProxy;
|
||||||
|
|
||||||
/** 请求标记 */
|
/**
|
||||||
|
* 请求标记
|
||||||
|
*/
|
||||||
private String mTag;
|
private String mTag;
|
||||||
|
|
||||||
/** 请求延迟 */
|
/**
|
||||||
|
* 请求延迟
|
||||||
|
*/
|
||||||
private long mDelayMillis;
|
private long mDelayMillis;
|
||||||
|
|
||||||
/** 请求服务地址 */
|
/**
|
||||||
|
* 请求服务地址
|
||||||
|
*/
|
||||||
private final String server = HttpConfig.getInstance().getServerPath();
|
private final String server = HttpConfig.getInstance().getServerPath();
|
||||||
|
|
||||||
/** 请求接口 */
|
/**
|
||||||
|
* 请求接口
|
||||||
|
*/
|
||||||
private RequestApi<Param, Result> mRequestApi;
|
private RequestApi<Param, Result> mRequestApi;
|
||||||
|
|
||||||
/** 请求参数 */
|
/**
|
||||||
|
* 请求参数
|
||||||
|
*/
|
||||||
private Param param;
|
private Param param;
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
@ -87,6 +101,7 @@ public class EasyHttp<Param, Result> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 带参请求
|
* 带参请求
|
||||||
|
*
|
||||||
* @param param 请求参数
|
* @param param 请求参数
|
||||||
*/
|
*/
|
||||||
public <Param, Result> ParamRequest<Param, Result> build(Param param, ResponseClass<Result> result) {
|
public <Param, Result> ParamRequest<Param, Result> build(Param param, ResponseClass<Result> result) {
|
||||||
@ -176,6 +191,7 @@ public class EasyHttp<Param, Result> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行同步请求
|
* 执行同步请求
|
||||||
|
*
|
||||||
* @param responseClass 需要解析泛型的对象
|
* @param responseClass 需要解析泛型的对象
|
||||||
* @return 返回解析完成的对象
|
* @return 返回解析完成的对象
|
||||||
* @throws Exception 如果请求失败或者解析失败则抛出异常
|
* @throws Exception 如果请求失败或者解析失败则抛出异常
|
||||||
@ -548,7 +564,6 @@ public class EasyHttp<Param, Result> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* 带参数请求
|
* 带参数请求
|
||||||
*
|
*
|
||||||
* @param <Param> 参数类型
|
* @param <Param> 参数类型
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http;
|
package top.octopusyan.http;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONException;
|
import com.alibaba.fastjson.JSONException;
|
||||||
@ -7,11 +7,11 @@ import okhttp3.MediaType;
|
|||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
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.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.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
@ -1,8 +1,8 @@
|
|||||||
package top.octopusyan.manager.http;
|
package top.octopusyan.http;
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import top.octopusyan.manager.http.config.ILogStrategy;
|
import top.octopusyan.http.config.ILogStrategy;
|
||||||
import top.octopusyan.manager.http.request.IRequestHandler;
|
import top.octopusyan.http.request.IRequestHandler;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http;
|
package top.octopusyan.http;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.annotation;
|
package top.octopusyan.http.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.annotation;
|
package top.octopusyan.http.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.annotation;
|
package top.octopusyan.http.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
@ -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
|
* @author : octopus yan
|
@ -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
|
* @author : octopus yan
|
@ -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
|
* @author : octopus yan
|
@ -1,7 +1,7 @@
|
|||||||
package top.octopusyan.manager.http.api;
|
package top.octopusyan.http.api;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import top.octopusyan.manager.http.config.BodyType;
|
import top.octopusyan.http.config.BodyType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,13 +1,13 @@
|
|||||||
package top.octopusyan.manager.http.callback;
|
package top.octopusyan.http.callback;
|
||||||
|
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import top.octopusyan.manager.http.EasyUtils;
|
import top.octopusyan.http.EasyUtils;
|
||||||
import top.octopusyan.manager.http.HttpConfig;
|
import top.octopusyan.http.HttpConfig;
|
||||||
import top.octopusyan.manager.http.HttpLog;
|
import top.octopusyan.http.HttpLog;
|
||||||
import top.octopusyan.manager.http.model.CallProxy;
|
import top.octopusyan.http.model.CallProxy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
@ -1,13 +1,13 @@
|
|||||||
package top.octopusyan.manager.http.callback;
|
package top.octopusyan.http.callback;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import top.octopusyan.manager.http.EasyUtils;
|
import top.octopusyan.http.EasyUtils;
|
||||||
import top.octopusyan.manager.http.HttpLog;
|
import top.octopusyan.http.HttpLog;
|
||||||
import top.octopusyan.manager.http.api.RequestApi;
|
import top.octopusyan.http.api.RequestApi;
|
||||||
import top.octopusyan.manager.http.listener.OnHttpListener;
|
import top.octopusyan.http.listener.OnHttpListener;
|
||||||
import top.octopusyan.manager.http.model.CallProxy;
|
import top.octopusyan.http.model.CallProxy;
|
||||||
import top.octopusyan.manager.http.request.IRequestHandler;
|
import top.octopusyan.http.request.IRequestHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.config;
|
package top.octopusyan.http.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.config;
|
package top.octopusyan.http.config;
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.config;
|
package top.octopusyan.http.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.config;
|
package top.octopusyan.http.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,10 +1,10 @@
|
|||||||
package top.octopusyan.manager.http.config;
|
package top.octopusyan.http.config;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import top.octopusyan.manager.http.EasyHttp;
|
import top.octopusyan.http.EasyHttp;
|
||||||
import top.octopusyan.manager.http.HttpConfig;
|
import top.octopusyan.http.HttpConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求取消异常
|
* 请求取消异常
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据解析异常
|
* 数据解析异常
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络请求异常
|
* 网络请求异常
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络连接异常
|
* 网络连接异常
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回结果异常
|
* 返回结果异常
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器连接异常
|
* 服务器连接异常
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器超时异常
|
* 服务器超时异常
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.exception;
|
package top.octopusyan.http.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Token 失效异常
|
* Token 失效异常
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.listener;
|
package top.octopusyan.http.listener;
|
||||||
|
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.model;
|
package top.octopusyan.http.model;
|
||||||
|
|
||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
@ -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.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
@ -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.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.model;
|
package top.octopusyan.http.model;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
@ -7,7 +7,7 @@ import lombok.NonNull;
|
|||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
import top.octopusyan.manager.http.config.ContentType;
|
import top.octopusyan.http.config.ContentType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.model;
|
package top.octopusyan.http.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,12 +1,12 @@
|
|||||||
package top.octopusyan.manager.http.model;
|
package top.octopusyan.http.model;
|
||||||
|
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
import okio.Okio;
|
import okio.Okio;
|
||||||
import okio.Source;
|
import okio.Source;
|
||||||
import top.octopusyan.manager.http.EasyUtils;
|
import top.octopusyan.http.EasyUtils;
|
||||||
import top.octopusyan.manager.http.config.ContentType;
|
import top.octopusyan.http.config.ContentType;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
@ -1,9 +1,9 @@
|
|||||||
package top.octopusyan.manager.http.request;
|
package top.octopusyan.http.request;
|
||||||
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import top.octopusyan.manager.http.EasyUtils;
|
import top.octopusyan.http.EasyUtils;
|
||||||
import top.octopusyan.manager.http.api.RequestApi;
|
import top.octopusyan.http.api.RequestApi;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.request;
|
package top.octopusyan.http.request;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
@ -8,10 +8,10 @@ import okhttp3.Headers;
|
|||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import top.octopusyan.manager.http.HttpLog;
|
import top.octopusyan.http.HttpLog;
|
||||||
import top.octopusyan.manager.http.api.RequestApi;
|
import top.octopusyan.http.api.RequestApi;
|
||||||
import top.octopusyan.manager.http.exception.*;
|
import top.octopusyan.http.exception.*;
|
||||||
import top.octopusyan.manager.http.response.BaseRest;
|
import top.octopusyan.http.response.BaseRest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.response;
|
package top.octopusyan.http.response;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.ssl;
|
package top.octopusyan.http.ssl;
|
||||||
|
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
@ -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 javax.net.ssl.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.ssl;
|
package top.octopusyan.http.ssl;
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.SSLSession;
|
import javax.net.ssl.SSLSession;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.manager.http.ssl;
|
package top.octopusyan.http.ssl;
|
||||||
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
@ -6,9 +6,9 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import top.octopusyan.http.Api;
|
import top.octopusyan.http.EasyHttp;
|
||||||
import top.octopusyan.manager.http.EasyHttp;
|
import top.octopusyan.http.model.ResponseClass;
|
||||||
import top.octopusyan.manager.http.model.ResponseClass;
|
import top.octopusyan.manager.http.Api;
|
||||||
import top.octopusyan.model.ApplicatonStore;
|
import top.octopusyan.model.ApplicatonStore;
|
||||||
import top.octopusyan.model.ProxySetupModel;
|
import top.octopusyan.model.ProxySetupModel;
|
||||||
import top.octopusyan.utils.JsoupUtil;
|
import top.octopusyan.utils.JsoupUtil;
|
||||||
|
@ -8,11 +8,11 @@ import org.jsoup.select.Elements;
|
|||||||
import top.octopusyan.config.ProxyConfig;
|
import top.octopusyan.config.ProxyConfig;
|
||||||
import top.octopusyan.config.ProxyConfig.ProxyServer;
|
import top.octopusyan.config.ProxyConfig.ProxyServer;
|
||||||
import top.octopusyan.config.ProxyConfig.ProxyType;
|
import top.octopusyan.config.ProxyConfig.ProxyType;
|
||||||
import top.octopusyan.http.Api;
|
import top.octopusyan.http.EasyHttp;
|
||||||
import top.octopusyan.http.request.ProxySetup;
|
import top.octopusyan.http.listener.OnHttpListener;
|
||||||
import top.octopusyan.manager.http.EasyHttp;
|
import top.octopusyan.http.model.ResponseClass;
|
||||||
import top.octopusyan.manager.http.listener.OnHttpListener;
|
import top.octopusyan.manager.http.Api;
|
||||||
import top.octopusyan.manager.http.model.ResponseClass;
|
import top.octopusyan.manager.http.request.ProxySetup;
|
||||||
import top.octopusyan.utils.AlertUtil;
|
import top.octopusyan.utils.AlertUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -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.ProxyManager;
|
||||||
import top.octopusyan.manager.http.api.NotParamApi;
|
import top.octopusyan.manager.http.request.*;
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : octopus yan
|
* @author : octopus yan
|
@ -1,14 +1,15 @@
|
|||||||
package top.octopusyan.http;
|
package top.octopusyan.manager.http;
|
||||||
|
|
||||||
import kotlin.text.Charsets;
|
import kotlin.text.Charsets;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
import okio.BufferedSource;
|
import okio.BufferedSource;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import top.octopusyan.manager.http.ssl.HttpSslConfig;
|
import top.octopusyan.http.ssl.HttpSslConfig;
|
||||||
import top.octopusyan.manager.http.ssl.HttpSslFactory;
|
import top.octopusyan.http.ssl.HttpSslFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@ -25,35 +26,33 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @create : 2022-4-2 15:27
|
* @create : 2022-4-2 15:27
|
||||||
*/
|
*/
|
||||||
public class OkHttpClientConfig {
|
public class OkHttpClientConfig {
|
||||||
public static final String TAG = "OkHttpClientConfig";
|
public static final String TAG = "OkHttpLogger";
|
||||||
private static final Logger log = LoggerFactory.getLogger(TAG);
|
private static final Logger log = LoggerFactory.getLogger(TAG);
|
||||||
|
|
||||||
|
|
||||||
public static final HashMap<String, List<Cookie>> cookieStore = new HashMap<>();
|
public static final HashMap<String, List<Cookie>> cookieStore = new HashMap<>();
|
||||||
|
|
||||||
public static OkHttpClient httpClient() {
|
public static OkHttpClient httpClient() {
|
||||||
//全局拦截器,往请求头部添加 token 字段,实现全局添加 token
|
HttpLoggingInterceptor logginInterceptor = new HttpLoggingInterceptor(
|
||||||
Interceptor tokenInterceptor = chain -> {// 打印请求报文
|
new HttpLoggingInterceptor.Logger() {
|
||||||
// 获取请求
|
@Override
|
||||||
Request request = chain.request();
|
public void log(String message) {
|
||||||
// 取出请求参数
|
try {
|
||||||
String reqBody = getRequestBody(request);
|
log.info(message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// 打印请求报文
|
// setlevel用来设置日志打印的级别,共包括了四个级别:NONE,BASIC,HEADER,BODY
|
||||||
log.info("【" + TAG + "】 " + String.format("发送新请求\n-\tmethod:%s\n-\turl:%s\n-\theaders: %s\n-\tbody:%s",
|
// BASEIC:请求/响应行
|
||||||
request.method(), request.url(), request.headers(), reqBody));
|
// HEADER:请求/响应行 + 头
|
||||||
// 执行请求,获取响应报文
|
// BODY:请求/响应行 + 头 + 体
|
||||||
Response response = chain.proceed(request);
|
//包含header、body数据
|
||||||
// 获取响应内容 TODO 读取结果乱码
|
logginInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
Dispatcher dispatcher = new Dispatcher();
|
Dispatcher dispatcher = new Dispatcher();
|
||||||
dispatcher.setMaxRequests(16);
|
dispatcher.setMaxRequests(16);
|
||||||
@ -63,7 +62,7 @@ public class OkHttpClientConfig {
|
|||||||
|
|
||||||
return new OkHttpClient.Builder()
|
return new OkHttpClient.Builder()
|
||||||
.retryOnConnectionFailure(true)
|
.retryOnConnectionFailure(true)
|
||||||
.addNetworkInterceptor(tokenInterceptor)
|
.addInterceptor(logginInterceptor)
|
||||||
.dispatcher(dispatcher)
|
.dispatcher(dispatcher)
|
||||||
.cookieJar(cookieJar())
|
.cookieJar(cookieJar())
|
||||||
.connectionPool(new ConnectionPool(16, 5, TimeUnit.MINUTES))
|
.connectionPool(new ConnectionPool(16, 5, TimeUnit.MINUTES))
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.http.request;
|
package top.octopusyan.manager.http.request;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.http.request;
|
package top.octopusyan.manager.http.request;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.http.request;
|
package top.octopusyan.manager.http.request;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.http.request;
|
package top.octopusyan.manager.http.request;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,4 +1,4 @@
|
|||||||
package top.octopusyan.http.request;
|
package top.octopusyan.manager.http.request;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -8,7 +8,7 @@ import javafx.beans.property.SimpleStringProperty;
|
|||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import org.apache.commons.io.FileUtils;
|
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 top.octopusyan.utils.EncryptionUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -5,7 +5,7 @@ import javafx.beans.property.SimpleIntegerProperty;
|
|||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import top.octopusyan.config.ProxyConfig;
|
import top.octopusyan.config.ProxyConfig;
|
||||||
import top.octopusyan.http.request.ProxySetup;
|
import top.octopusyan.manager.http.request.ProxySetup;
|
||||||
import top.octopusyan.utils.DomainUtil;
|
import top.octopusyan.utils.DomainUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package top.octopusyan.utils;
|
package top.octopusyan.utils;
|
||||||
|
|
||||||
import top.octopusyan.config.ProxyConfig;
|
import top.octopusyan.config.ProxyConfig;
|
||||||
import top.octopusyan.http.request.ProxySetup;
|
import top.octopusyan.manager.http.request.ProxySetup;
|
||||||
import top.octopusyan.model.ProxySetupModel;
|
import top.octopusyan.model.ProxySetupModel;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package top.octopusyan.utils;
|
package top.octopusyan.utils;
|
||||||
|
|
||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.crypto.ProviderFactory;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sun.misc.BASE64Encoder;
|
import sun.misc.BASE64Encoder;
|
||||||
@ -168,7 +168,7 @@ public class EncryptionUtil {
|
|||||||
*/
|
*/
|
||||||
public static String AESencode(String data, String password) throws Exception {
|
public static String AESencode(String data, String password) throws Exception {
|
||||||
byte[] result;
|
byte[] result;
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(ProviderFactory.createBouncyCastleProvider());
|
||||||
// 创建密码器
|
// 创建密码器
|
||||||
// 初始化为加密模式的密码
|
// 初始化为加密模式的密码
|
||||||
Cipher_ALGORITHM_MODE_PADDING.init(Cipher.ENCRYPT_MODE, getSecretKey(password));
|
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 {
|
public static String AESdecode(String base64Data, String password) throws Exception {
|
||||||
byte[] result;
|
byte[] result;
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(ProviderFactory.createBouncyCastleProvider());
|
||||||
// 使用密钥初始化,设置为解密模式
|
// 使用密钥初始化,设置为解密模式
|
||||||
Cipher_ALGORITHM_MODE_PADDING.init(Cipher.DECRYPT_MODE, getSecretKey(password));
|
Cipher_ALGORITHM_MODE_PADDING.init(Cipher.DECRYPT_MODE, getSecretKey(password));
|
||||||
// 执行操作
|
// 执行操作
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import com.jfoenix.controls.JFXButton?>
|
<?import com.jfoenix.controls.*?>
|
||||||
<?import com.jfoenix.controls.JFXCheckBox?>
|
|
||||||
<?import com.jfoenix.controls.JFXPasswordField?>
|
|
||||||
<?import com.jfoenix.controls.JFXTextField?>
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.image.ImageView?>
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.StackPane?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
<?import javafx.scene.shape.Rectangle?>
|
<?import javafx.scene.shape.Rectangle?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.*?>
|
||||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||||
|
|
||||||
<StackPane fx:id="root" prefHeight="330.0" prefWidth="430.0" stylesheets="@../css/login.css"
|
<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"
|
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="top.octopusyan.controller.LoginController">
|
fx:controller="top.octopusyan.controller.LoginController">
|
||||||
|
@ -1,26 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import com.jfoenix.controls.JFXButton?>
|
<?import com.jfoenix.controls.*?>
|
||||||
<?import com.jfoenix.controls.JFXComboBox?>
|
<?import javafx.geometry.*?>
|
||||||
<?import com.jfoenix.controls.JFXListView?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import com.jfoenix.controls.JFXRadioButton?>
|
<?import javafx.scene.*?>
|
||||||
<?import com.jfoenix.controls.JFXTabPane?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import com.jfoenix.controls.JFXTextField?>
|
<?import javafx.scene.text.*?>
|
||||||
<?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 org.kordamp.ikonli.javafx.FontIcon?>
|
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||||
|
|
||||||
<StackPane fx:id="root" prefHeight="700.0" prefWidth="750.0" stylesheets="@../css/main.css"
|
<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"
|
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="top.octopusyan.controller.MainController">
|
fx:controller="top.octopusyan.controller.MainController">
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||||
|
|
||||||
<Label text=" 默认连接" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
|
<Label text=" 默认连接" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<graphic>
|
<graphic>
|
||||||
<FontIcon iconLiteral="fa-circle" iconSize="14"/>
|
<FontIcon iconLiteral="fa-circle" iconSize="14"/>
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import com.jfoenix.controls.JFXButton?>
|
<?import com.jfoenix.controls.*?>
|
||||||
<?import com.jfoenix.controls.JFXPasswordField?>
|
|
||||||
<?import com.jfoenix.controls.JFXTextField?>
|
|
||||||
<?import javafx.scene.image.ImageView?>
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.StackPane?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
<?import javafx.scene.shape.Rectangle?>
|
<?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">
|
<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">
|
<ImageView fx:id="registBkgPane" fitHeight="330.0" fitWidth="430.0">
|
||||||
<clip>
|
<clip>
|
||||||
|
Loading…
Reference in New Issue
Block a user