use of lee.study.down.model.ConfigInfo in project proxyee-down by monkeyWie.
the class ConfigContent method init.
public void init() {
if (FileUtil.exists(HttpDownConstant.CONFIG_PATH)) {
try (InputStream inputStream = new FileInputStream(HttpDownConstant.CONFIG_PATH)) {
set(JSON.parseObject(inputStream, ConfigInfo.class));
} catch (Exception e) {
if (!(e instanceof FileNotFoundException)) {
try {
FileUtil.deleteIfExists(HttpDownConstant.CONFIG_PATH);
} catch (IOException e1) {
e1.printStackTrace();
}
}
LOGGER.error("加载配置文件失败:", e);
}
}
if (configContent == null || configContent.getProxyPort() == 0) {
set(new ConfigInfo());
save();
}
}
use of lee.study.down.model.ConfigInfo in project proxyee-down by monkeyWie.
the class HttpDownApplication method start.
@Override
public void start(Stage stage) throws Exception {
initHandle();
this.stage = stage;
Platform.setImplicitExit(false);
isSupportBrowser = isSupportBrowser();
SwingUtilities.invokeLater(this::addTray);
// webview加载
if (ContentManager.CONFIG.get().getUiModel() == 1 && isSupportBrowser) {
initBrowser();
}
stage.setTitle("proxyee-down-" + version);
Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
ConfigInfo cf = ContentManager.CONFIG.get();
stage.setX(cf.getGuiX() >= 0 ? cf.getGuiX() : bounds.getMinX());
stage.setY(cf.getGuiY() >= 0 ? cf.getGuiY() : bounds.getMinY());
stage.setWidth(cf.getGuiWidth() >= 0 ? cf.getGuiWidth() : bounds.getWidth());
stage.setHeight(cf.getGuiHeight() >= 0 ? cf.getGuiHeight() : bounds.getHeight());
stage.getIcons().add(new Image(Thread.currentThread().getContextClassLoader().getResourceAsStream("favicon.png")));
// 关闭窗口监听
stage.setOnCloseRequest(event -> {
event.consume();
close();
});
}
use of lee.study.down.model.ConfigInfo in project proxyee-down by monkeyWie.
the class HttpDownController method setConfigInfo.
@RequestMapping("/setConfigInfo")
public ResultInfo setConfigInfo(@RequestBody ConfigForm configForm) {
ResultInfo resultInfo = new ResultInfo();
int beforePort = ContentManager.CONFIG.get().getProxyPort();
boolean beforeSecProxyEnable = ContentManager.CONFIG.get().isSecProxyEnable();
ProxyConfig beforeSecProxyConfig = ContentManager.CONFIG.get().getSecProxyConfig();
if (!configForm.isSecProxyEnable()) {
configForm.setSecProxyConfig(null);
}
ConfigInfo configInfo = configForm.convert();
ContentManager.CONFIG.set(configInfo);
ContentManager.CONFIG.save();
// 代理服务器需要重新启动
if (beforePort != configInfo.getProxyPort() || beforeSecProxyEnable != configInfo.isSecProxyEnable() || (configInfo.isSecProxyEnable() && !configInfo.getSecProxyConfig().equals(beforeSecProxyConfig))) {
new Thread(() -> {
HttpDownApplication.getProxyServer().close();
HttpDownApplication.getProxyServer().setProxyConfig(configInfo.getSecProxyConfig());
HttpDownApplication.getProxyServer().start(configInfo.getProxyPort());
}).start();
}
return resultInfo;
}
use of lee.study.down.model.ConfigInfo in project proxyee-down by monkeyWie.
the class ConfigForm method convert.
public ConfigInfo convert() {
ConfigInfo configInfo = new ConfigInfo();
BeanUtils.copyProperties(this, configInfo, new String[] { "secProxyConfig" });
if (secProxyConfig != null) {
configInfo.setSecProxyConfig(secProxyConfig.convert());
}
return configInfo;
}
Aggregations