diff --git a/client/src/main/java/com/lzf/flyingsocks/client/ClientOperator.java b/client/src/main/java/com/lzf/flyingsocks/client/ClientOperator.java index 181df21..604bf7f 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/ClientOperator.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/ClientOperator.java @@ -145,6 +145,12 @@ public interface ClientOperator { */ void updateHttpProxyConfig(boolean open, int port, boolean auth, String username, String password); + /** + * 打开Windows系统代理 + */ + void setupWindowsSystemProxy(boolean open); + + /** * @return 系统代理模式 */ diff --git a/client/src/main/java/com/lzf/flyingsocks/client/GlobalConfig.java b/client/src/main/java/com/lzf/flyingsocks/client/GlobalConfig.java index f46223d..da21998 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/GlobalConfig.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/GlobalConfig.java @@ -89,14 +89,16 @@ public class GlobalConfig extends AbstractConfig { */ @Override protected void initInternal() throws ConfigInitializationException { - String location; - - if (configManager.isWindows()) { - location = configManager.getSystemProperties("config.location.windows"); - } else if (configManager.isMacOS()) { - location = configManager.getSystemProperties("config.location.mac"); - } else { - location = configManager.getSystemProperties("config.location.linux"); + String location = configManager.getSystemProperties("config.location"); + + if (location == null) { + if (configManager.isWindows()) { + location = configManager.getSystemProperties("config.location.windows"); + } else if (configManager.isMacOS()) { + location = configManager.getSystemProperties("config.location.mac"); + } else { + location = configManager.getSystemProperties("config.location.linux"); + } } location = StringSubstitutor.replaceSystemProperties(location); diff --git a/client/src/main/java/com/lzf/flyingsocks/client/StandardClient.java b/client/src/main/java/com/lzf/flyingsocks/client/StandardClient.java index 71a5759..118f44f 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/StandardClient.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/StandardClient.java @@ -21,6 +21,7 @@ */ package com.lzf.flyingsocks.client; +import com.lzf.flyingsocks.Component; import com.lzf.flyingsocks.ComponentException; import com.lzf.flyingsocks.ConfigEvent; import com.lzf.flyingsocks.ConfigEventListener; @@ -98,7 +99,12 @@ protected void stopInternal() { */ @Override protected void restartInternal() { - throw new ComponentException("can not restart client"); + throw new ComponentException("Could not restart client"); + } + + @Override + protected void handleException(Component component, Exception exception) { + exitWithNotify(1, "exitmsg.component_failure", component.getName(), exception.getMessage()); } @Override @@ -287,6 +293,15 @@ public void updateHttpProxyConfig(boolean open, int port, boolean auth, String u } } + @Override + public void setupWindowsSystemProxy(boolean open) { + ConfigManager manager = getConfigManager(); + HttpProxyConfig cfg = manager.getConfig(HttpProxyConfig.NAME, HttpProxyConfig.class); + if (cfg != null) { + cfg.enableWindowsSystemProxy(open); + } + } + @Override public long queryProxyServerUploadThroughput(Node node) { ProxyComponent pc = getComponentByName(ProxyComponent.NAME, ProxyComponent.class); diff --git a/client/src/main/java/com/lzf/flyingsocks/client/gui/chart/DynamicTimeSeriesChart.java b/client/src/main/java/com/lzf/flyingsocks/client/gui/chart/DynamicTimeSeriesChart.java index 9526d44..ed05200 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/gui/chart/DynamicTimeSeriesChart.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/gui/chart/DynamicTimeSeriesChart.java @@ -28,6 +28,7 @@ import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYAreaRenderer; +import org.jfree.chart.title.TextTitle; import org.jfree.data.RangeType; import org.jfree.data.time.DynamicTimeSeriesCollection; import org.jfree.data.time.Second; @@ -36,6 +37,7 @@ import java.awt.BasicStroke; import java.awt.Color; +import java.awt.Font; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -79,8 +81,8 @@ public DynamicTimeSeriesChart(String title, String xAxisName, String yAxisName, dataset.setTimeBase(new Second(DateUtils.addSeconds(new Date(), -interval))); dataset.addSeries(new float[0], 0, ""); - JFreeChart chart = ChartFactory.createTimeSeriesChart(title, xAxisName, yAxisName, dataset, false, false, false); - + JFreeChart chart = ChartFactory.createTimeSeriesChart("", xAxisName, yAxisName, dataset, false, false, false); + chart.setTitle(new TextTitle(title, new Font("黑体", Font.PLAIN, 18))); if (style == STYLE_BLUE) { initialChartStyle(chart, Color.white, new Color(17, 125, 187), new Color(217, 234, 244), diff --git a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/HttpProxySettingModule.java b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/HttpProxySettingModule.java index 02d6574..0a1a000 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/HttpProxySettingModule.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/HttpProxySettingModule.java @@ -56,12 +56,14 @@ */ public class HttpProxySettingModule extends AbstractModule { + public static final String NAME = HttpProxySettingModule.class.getSimpleName(); + private final ClientOperator operator; private final Shell shell; HttpProxySettingModule(SWTViewComponent component) { - super(Objects.requireNonNull(component), "HttpProxySettingModule"); + super(Objects.requireNonNull(component), NAME); this.operator = component.getParentComponent(); Image icon; @@ -177,7 +179,6 @@ private void initial() { authCloseRadio.setSelection(true); } - addButtonSelectionListener(cancelBtn, e -> { if (operator.isHttpProxyOpen()) { openRadio.setSelection(true); diff --git a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/MainScreenModule.java b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/MainScreenModule.java index e5cb69d..2b5cff6 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/MainScreenModule.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/MainScreenModule.java @@ -65,6 +65,8 @@ */ final class MainScreenModule extends AbstractModule { + public static final String NAME = MainScreenModule.class.getSimpleName(); + private static final DateTimeFormatter STATUS_TEXT_TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss.SSS"); /** @@ -118,7 +120,7 @@ final class MainScreenModule extends AbstractModule { MainScreenModule(SWTViewComponent component) { - super(Objects.requireNonNull(component), "Main-Screen"); + super(Objects.requireNonNull(component), NAME); this.display = component.getDisplay(); this.operator = getComponent().getParentComponent(); @@ -127,13 +129,14 @@ final class MainScreenModule extends AbstractModule { this.shell = shell; this.statusTextArea = initStatusTextArea(shell); - this.uploadChart = new DynamicTimeSeriesChart("UPLOAD", "", "MB/s", 60, DynamicTimeSeriesChart.STYLE_PURPLE); - this.downloadChart = new DynamicTimeSeriesChart("DOWNLOAD", "", "MB/s", 60, DynamicTimeSeriesChart.STYLE_BLUE); + this.uploadChart = new DynamicTimeSeriesChart("上传", "", "MB/s", 60, DynamicTimeSeriesChart.STYLE_PURPLE); + this.downloadChart = new DynamicTimeSeriesChart("下载", "", "MB/s", 60, DynamicTimeSeriesChart.STYLE_BLUE); this.uploadChartCanvas = initChartCanvas(this.uploadChart, 10, 270, CHART_WIDTH, CHART_HEIGHT); this.downloadChartCanvas = initChartCanvas(this.downloadChart, 355, 270, CHART_WIDTH, CHART_HEIGHT); this.serverList = initServerChooseList(shell); + appendStatusText("swtui.main.status.not_connect"); adaptDPI(shell); setVisiable(false); submitChartUpdateTask(); @@ -225,7 +228,6 @@ public void focusLost(FocusEvent e) { } }); this.connBtn = conn; - appendStatusText("swtui.main.status.not_connect"); changeConnBtn(false); update(); operator.registerProxyServerConfigListener(Config.UPDATE_EVENT, this::update, false); @@ -290,7 +292,7 @@ public void focusLost(FocusEvent e) { } })); } else { - showMessageBox(shell, "提示", "请选择一个有效的服务器", SWT.ICON_INFORMATION | SWT.OK); + showMessageBox(shell, "swtui.main.notice.title", "swtui.main.notice.server_not_select", SWT.ICON_INFORMATION | SWT.OK); } } }); @@ -321,10 +323,10 @@ private void update() { private void changeConnBtn(boolean disconnect) { if (disconnect) { - connBtn.setText("断开连接"); + connBtn.setText(i18n("swtui.main.button.disconnect")); this.disconnect = true; } else { - connBtn.setText("连接"); + connBtn.setText(i18n("swtui.main.button.connect")); this.disconnect = false; } } @@ -345,8 +347,24 @@ void setVisiable(boolean visible) { private void appendStatusText(String text) { + StringBuilder sb = new StringBuilder(35); + LocalTime time = LocalTime.now(); - String str = "【" + STATUS_TEXT_TIME_FORMAT.format(time) + "】" + i18n(text) + Text.DELIMITER; + sb.append('<').append(STATUS_TEXT_TIME_FORMAT.format(time)).append('>'); + + Node selectNode = serverList.selectNode(); + sb.append('['); + if (selectNode == null) { + sb.append("NONE"); + } else { + sb.append(selectNode.getHost()).append(':').append(selectNode.getPort()); + } + sb.append("] "); + + sb.append(i18n(text)); + sb.append(Text.DELIMITER); + + String str = sb.toString(); if (statusTextArea.getLineCount() > 5000) { statusTextArea.setText(str); } else { diff --git a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/SWTViewComponent.java b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/SWTViewComponent.java index 3a0fd23..52f27b7 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/SWTViewComponent.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/SWTViewComponent.java @@ -37,27 +37,6 @@ public class SWTViewComponent extends AbstractComponent { private final Display display; - /** - * Socks代理设置页面 - */ - private SocksSettingModule socksSettingModule; - - /** - * 服务器设置页面 - */ - private ServerSettingModule serverSettingModule; - - /** - * 主界面 - */ - private MainScreenModule mainScreenModule; - - /** - * HTTP代理设置页面 - */ - private HttpProxySettingModule httpProxySettingModule; - - public SWTViewComponent(Client parent) { super("SWTViewComponent", Objects.requireNonNull(parent)); @@ -80,10 +59,10 @@ public SWTViewComponent(Client parent) { protected void initInternal() { try { addModule(new TrayModule(this)); - addModule(this.serverSettingModule = new ServerSettingModule(this)); - addModule(this.socksSettingModule = new SocksSettingModule(this)); - addModule(this.mainScreenModule = new MainScreenModule(this)); - addModule(this.httpProxySettingModule = new HttpProxySettingModule(this)); + addModule(new ServerSettingModule(this)); + addModule(new SocksSettingModule(this)); + addModule(new MainScreenModule(this)); + addModule(new HttpProxySettingModule(this)); } catch (Throwable t) { log.error("SWT Thread occur a error", t); Client.exitWithNotify(1, "exitmsg.swt_view.init_failure", t.getMessage()); @@ -114,19 +93,19 @@ Display getDisplay() { } void openSocksSettingUI() { - socksSettingModule.setVisiable(true); + getModuleByName(SocksSettingModule.NAME, SocksSettingModule.class).setVisiable(true); } void openServerSettingUI() { - serverSettingModule.setVisiable(true); + getModuleByName(ServerSettingModule.NAME, ServerSettingModule.class).setVisiable(true); } void openMainScreenUI() { - mainScreenModule.setVisiable(true); + getModuleByName(MainScreenModule.NAME, MainScreenModule.class).setVisiable(true); } void openHttpProxySettingUI() { - httpProxySettingModule.setVisiable(true); + getModuleByName(HttpProxySettingModule.NAME, HttpProxySettingModule.class).setVisiable(true); } @Override diff --git a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/ServerSettingModule.java b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/ServerSettingModule.java index 8633e76..d9936ec 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/ServerSettingModule.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/ServerSettingModule.java @@ -58,6 +58,8 @@ */ final class ServerSettingModule extends AbstractModule { + public static final String NAME = ServerSettingModule.class.getSimpleName(); + private static final Logger log = LoggerFactory.getLogger("ServerSettingUI"); private final Display display; @@ -71,7 +73,7 @@ final class ServerSettingModule extends AbstractModule { private final ServerSettingForm serverSettingForm; ServerSettingModule(SWTViewComponent component) { - super(Objects.requireNonNull(component)); + super(Objects.requireNonNull(component), NAME); this.display = component.getDisplay(); this.operator = component.getParentComponent(); @@ -375,6 +377,9 @@ void setEncrypt(EncryptType type) { case SSL: encrypt.select(1); break; + case SSL_CA: + encrypt.select(2); + break; } } diff --git a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/SocksSettingModule.java b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/SocksSettingModule.java index d389acf..0f3deb3 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/SocksSettingModule.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/SocksSettingModule.java @@ -52,12 +52,14 @@ */ final class SocksSettingModule extends AbstractModule { + public static final String NAME = SocksSettingModule.class.getSimpleName(); + private final ClientOperator operator; private final Shell shell; SocksSettingModule(SWTViewComponent component) { - super(Objects.requireNonNull(component)); + super(Objects.requireNonNull(component), NAME); this.operator = component.getParentComponent(); Image icon; diff --git a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/TrayModule.java b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/TrayModule.java index a41c3eb..11a7435 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/TrayModule.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/gui/swt/TrayModule.java @@ -25,6 +25,7 @@ import com.lzf.flyingsocks.client.ClientOperator; import com.lzf.flyingsocks.client.gui.ResourceManager; +import com.lzf.flyingsocks.client.proxy.http.HttpProxyConfig; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; @@ -81,6 +82,10 @@ private void initial() { //PAC设置菜单 initialPacMenu(shell, menu); + if (supportWindowsSystemProxy()) { + initialWindowsSystemProxyMenu(shell, menu); + } + createMenuItem(menu, "swtui.tray.item.server_config_ui", e -> belongComponent.openServerSettingUI()); createMenuSeparator(menu); createMenuItem(menu, "swtui.tray.item.socks5_config_ui", e -> belongComponent.openSocksSettingUI()); @@ -182,4 +187,45 @@ private void initialAboutMenu(Shell shell, Menu main) { createCascadeMenuItem(about, "swtui.tray.item.help.open_issue", e -> operator.openBrowser(ISSUE_PAGE)); } + + private void initialWindowsSystemProxyMenu(Shell shell, Menu main) { + MenuItem mi = new MenuItem(main, SWT.CASCADE); + mi.setText(i18n("swtui.tray.item.wsp_proxy")); + Menu menu = new Menu(shell, SWT.DROP_DOWN); + mi.setMenu(menu); + + MenuItem open = new MenuItem(menu, SWT.CASCADE ^ SWT.CHECK); + MenuItem close = new MenuItem(menu, SWT.CASCADE ^ SWT.CHECK); + open.setText(i18n("swtui.http.form.button.wsp_open")); + close.setText(i18n("swtui.http.form.button.wsp_close")); + + HttpProxyConfig cfg = operator.getHttpProxyConfig(); + if (cfg.isEnableWindowsSystemProxy()) { + open.setSelection(true); + } else { + close.setSelection(true); + } + + addMenuItemSelectionListener(open, e -> { + open.setSelection(true); + close.setSelection(false); + operator.setupWindowsSystemProxy(true); + }); + + addMenuItemSelectionListener(close, e -> { + open.setSelection(false); + close.setSelection(true); + operator.setupWindowsSystemProxy(false); + }); + } + + + private boolean supportWindowsSystemProxy() { + HttpProxyConfig cfg = operator.getHttpProxyConfig(); + if (cfg == null) { + return false; + } + return cfg.supportWindowsSystemProxy(); + } + } diff --git a/client/src/main/java/com/lzf/flyingsocks/client/proxy/http/HttpProxyConfig.java b/client/src/main/java/com/lzf/flyingsocks/client/proxy/http/HttpProxyConfig.java index f322dcb..0656e83 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/proxy/http/HttpProxyConfig.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/proxy/http/HttpProxyConfig.java @@ -122,6 +122,10 @@ public String getPassword() { return password; } + public boolean isEnableWindowsSystemProxy() { + return enableWindowsSystemProxy; + } + private void loadConfigFile(Path path) { JSONObject json; try (FileChannel ch = FileChannel.open(path, StandardOpenOption.READ)) { @@ -196,6 +200,11 @@ private static void createFileIfNotExists(Path path) { } + public boolean supportWindowsSystemProxy() { + return WindowsSystemProxy.isAvailable(); + } + + public void update(int port, boolean auth, String username, String password) { this.port = port; this.auth = auth; @@ -206,6 +215,15 @@ public void update(int port, boolean auth, String username, String password) { } + public void enableWindowsSystemProxy(boolean open) { + if (this.enableWindowsSystemProxy == open || (open && !supportWindowsSystemProxy())) { + return; + } + this.enableWindowsSystemProxy = open; + configManager.updateConfig(this); + } + + @Override public boolean canSave() { return true; @@ -236,36 +254,15 @@ public void save() throws Exception { private static class Facade extends HttpProxyConfig { - private final HttpProxyConfig config; - private Facade(HttpProxyConfig config) { super(config.configManager); - this.config = config; - } - - @Override - public int getBindPort() { - return config.getBindPort(); - } - - @Override - public String getBindAddress() { - return config.getBindAddress(); - } - - @Override - public boolean isAuth() { - return config.isAuth(); - } - - @Override - public String getUsername() { - return config.getUsername(); - } - - @Override - public String getPassword() { - return config.getPassword(); + super.filePath = config.filePath; + super.address = config.getBindAddress(); + super.port = config.getBindPort(); + super.auth = config.isAuth(); + super.username = config.getUsername(); + super.password = config.getPassword(); + super.enableWindowsSystemProxy = config.isEnableWindowsSystemProxy(); } @Override @@ -282,6 +279,11 @@ public void save() throws Exception { public void update(int port, boolean auth, String username, String password) { throw new UnsupportedOperationException("Facade object"); } + + @Override + public HttpProxyConfig configFacade() { + throw new UnsupportedOperationException(); + } } diff --git a/client/src/main/java/com/lzf/flyingsocks/client/proxy/http/HttpReceiverComponent.java b/client/src/main/java/com/lzf/flyingsocks/client/proxy/http/HttpReceiverComponent.java index 56f12c8..10360dc 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/proxy/http/HttpReceiverComponent.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/proxy/http/HttpReceiverComponent.java @@ -22,6 +22,7 @@ package com.lzf.flyingsocks.client.proxy.http; import com.lzf.flyingsocks.AbstractComponent; +import com.lzf.flyingsocks.ComponentException; import com.lzf.flyingsocks.Config; import com.lzf.flyingsocks.ConfigManager; import com.lzf.flyingsocks.client.proxy.ProxyComponent; @@ -88,6 +89,8 @@ public class HttpReceiverComponent extends AbstractComponent { private volatile EventLoopGroup eventLoopGroup; + private volatile boolean enableWindowsSystemProxy; + public HttpReceiverComponent(ProxyComponent parent) { super("HttpRequestReceiver", Objects.requireNonNull(parent)); } @@ -146,7 +149,7 @@ protected void initChannel(SocketChannel ch) { int port = config.getBindPort(); String address = config.getBindAddress(); - bootstrap.bind(address, port).addListener((ChannelFuture future) -> { + ChannelFuture bindFuture = bootstrap.bind(address, port).addListener((ChannelFuture future) -> { if (!future.isSuccess()) { log.error("HTTP Proxy service bind error", future.cause()); } else { @@ -154,15 +157,39 @@ protected void initChannel(SocketChannel ch) { } }).awaitUninterruptibly(); + if (!bindFuture.isSuccess()) { + throw new ComponentException(bindFuture.cause()); + } + + if (config.isEnableWindowsSystemProxy() && getConfigManager().isWindows()) { + if (WindowsSystemProxy.isAvailable()) { + boolean res = WindowsSystemProxy.switchProxy(true); + if (res) { + this.enableWindowsSystemProxy = true; + WindowsSystemProxy.setupProxyServerAddress("127.0.0.1", port); + } else { + log.warn("Could not open windows system proxy"); + } + } else { + log.warn("Unable to configure windows system proxy", WindowsSystemProxy.unavailabilityCause()); + } + } + super.startInternal(); } @Override protected void stopInternal() { + if (this.enableWindowsSystemProxy) { + WindowsSystemProxy.switchProxy(false); + this.enableWindowsSystemProxy = false; + } + EventLoopGroup eventLoopGroup = this.eventLoopGroup; if (eventLoopGroup != null) { eventLoopGroup.shutdownGracefully(); } + super.stopInternal(); } diff --git a/client/src/main/java/com/lzf/flyingsocks/client/proxy/socks/SocksConfig.java b/client/src/main/java/com/lzf/flyingsocks/client/proxy/socks/SocksConfig.java index 2bda8a5..20b5d37 100644 --- a/client/src/main/java/com/lzf/flyingsocks/client/proxy/socks/SocksConfig.java +++ b/client/src/main/java/com/lzf/flyingsocks/client/proxy/socks/SocksConfig.java @@ -217,6 +217,11 @@ public void save() { throw new UnsupportedOperationException(); } + @Override + public boolean canSave() { + return false; + } + @Override public void update(int port, boolean auth, String username, String password) { throw new UnsupportedOperationException(); diff --git a/client/src/main/resources/META-INF/i18n/exitmsg_en.properties b/client/src/main/resources/META-INF/i18n/exitmsg_en.properties index 83ba551..ed0243f 100644 --- a/client/src/main/resources/META-INF/i18n/exitmsg_en.properties +++ b/client/src/main/resources/META-INF/i18n/exitmsg_en.properties @@ -1,4 +1,5 @@ exitmsg.title = ERROR +exitmsg.component_failure = An error occur in Component {0}, error message: {1} exitmsg.client_boot.start_failure = Startup failure, error message\uFF1A{0} exitmsg.standard_client.config_load_error = Load config file at classpath://config.properties failure, detail message\uFF1A{0} exitmsg.swt_view.init_failure = UI component startup failure, detail message: {0} diff --git a/client/src/main/resources/META-INF/i18n/exitmsg_zh.properties b/client/src/main/resources/META-INF/i18n/exitmsg_zh.properties index 80c9659..2f7044a 100644 --- a/client/src/main/resources/META-INF/i18n/exitmsg_zh.properties +++ b/client/src/main/resources/META-INF/i18n/exitmsg_zh.properties @@ -1,4 +1,5 @@ exitmsg.title = \u9519\u8BEF +exitmsg.component_failure = \u7EC4\u4EF6[{0}]\u53D1\u751F\u9519\u8BEF\uFF0C\u8BE6\u7EC6\u4FE1\u606F\uFF1A{1} exitmsg.client_boot.start_failure = \u542F\u52A8\u9519\u8BEF\uFF0C\u9519\u8BEF\u4FE1\u606F\uFF1A{0} exitmsg.standard_client.config_load_error = \u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6classpath://config.properties\u5931\u8D25\uFF0C\u8BE6\u7EC6\u4FE1\u606F\uFF1A{0} exitmsg.swt_view.init_failure = UI\u7EC4\u4EF6\u542F\u52A8\u5931\u8D25\uFF0C\u8BE6\u7EC6\u4FE1\u606F\uFF1A{0} diff --git a/client/src/main/resources/META-INF/i18n/swtui_en.properties b/client/src/main/resources/META-INF/i18n/swtui_en.properties index 4f6b959..08df2f4 100644 --- a/client/src/main/resources/META-INF/i18n/swtui_en.properties +++ b/client/src/main/resources/META-INF/i18n/swtui_en.properties @@ -34,6 +34,10 @@ swtui.main.status.proxy_connect_auth_failure = Authentication failed, please che swtui.main.status.proxy_connect_error = An error occurred connecting to the proxy service swtui.main.status.proxy_disconnect = Temporarily disconnect from the server, try to reconnect... swtui.main.status.proxy_unused = Proxy server connection has been disconnected +swtui.main.button.connect = Connect +swtui.main.button.disconnect = Disconnect +swtui.main.notice.title = Notice +swtui.main.notice.server_not_select = Please select a server swtui.serverconfig.title = Server configure swtui.serverconfig.list.title = Server List @@ -72,6 +76,7 @@ swtui.socks5.form.button.open = Open swtui.socks5.form.button.close = Close swtui.socks5.form.button.enter = Confirm swtui.socks5.form.button.cancel = Cancel +swtui.socks5.notice.title=Notice swtui.socks5.notice.port_error = Port illegal swtui.socks5.notice.update_success = Update success, you need rebot program so that can be done. swtui.socks5.notice.unchanged = Update success @@ -91,4 +96,7 @@ swtui.http.form.button.cancel = Cancel swtui.http.notice.error.title = Error swtui.http.notice.error.port_error = Incorrect port number (A number between 1 and 65535) swtui.http.notice.error.auth_error = When authentication is turned on, the username and password must not be empty. -swtui.http.notice.update_success = Update successful, some settings need to restart the program to take effect. \ No newline at end of file +swtui.http.notice.update_success = Update successful, some settings need to restart the program to take effect. +swtui.http.form.button.wsp_open=Enable +swtui.http.form.button.wsp_close=Close +swtui.tray.item.wsp_proxy=Windows System Proxy \ No newline at end of file diff --git a/client/src/main/resources/META-INF/i18n/swtui_zh.properties b/client/src/main/resources/META-INF/i18n/swtui_zh.properties index b552992..cff8bd0 100644 --- a/client/src/main/resources/META-INF/i18n/swtui_zh.properties +++ b/client/src/main/resources/META-INF/i18n/swtui_zh.properties @@ -34,6 +34,10 @@ swtui.main.status.proxy_connect_auth_failure = \u4EE3\u7406\u670D\u52A1\u8BA4\u8 swtui.main.status.proxy_connect_error = \u4E0E\u4EE3\u7406\u670D\u52A1\u8FDE\u63A5\u53D1\u751F\u9519\u8BEF swtui.main.status.proxy_disconnect = \u6682\u65F6\u4E0E\u670D\u52A1\u5668\u65AD\u5F00\u8FDE\u63A5,\u5C1D\u8BD5\u8FDB\u884C\u91CD\u8FDE... swtui.main.status.proxy_unused = \u4EE3\u7406\u670D\u52A1\u5668\u8FDE\u63A5\u5DF2\u505C\u6B62 +swtui.main.button.connect = \u8FDE\u63A5 +swtui.main.button.disconnect = \u65AD\u5F00\u8FDE\u63A5 +swtui.main.notice.title = \u63D0\u793A +swtui.main.notice.server_not_select = \u8BF7\u9009\u62E9\u4E00\u4E2A\u6709\u6548\u7684\u670D\u52A1\u5668 swtui.serverconfig.title = \u670D\u52A1\u5668\u8BBE\u7F6E swtui.serverconfig.list.title = \u670D\u52A1\u5668\u5217\u8868 @@ -93,3 +97,6 @@ swtui.http.notice.error.title = \u9519\u8BEF swtui.http.notice.error.port_error = \u7AEF\u53E3\u53F7\u6709\u8BEF,\u5FC5\u987B\u4E3A1~65535\u4E4B\u95F4\u7684\u6570\u5B57 swtui.http.notice.error.auth_error = \u8BA4\u8BC1\u5F00\u542F\u65F6\uFF0C\u7528\u6237\u540D\u548C\u5BC6\u7801\u4E0D\u5F97\u4E3A\u7A7A swtui.http.notice.update_success = \u4FEE\u6539\u6210\u529F\uFF0C\u90E8\u5206\u8BBE\u7F6E\u9700\u8981\u91CD\u542F\u7A0B\u5E8F\u751F\u6548 +swtui.http.form.button.wsp_open=\u5F00\u542F +swtui.http.form.button.wsp_close=\u5173\u95ED +swtui.tray.item.wsp_proxy=Windows\u7CFB\u7EDF\u4EE3\u7406 diff --git a/common/src/main/java/com/lzf/flyingsocks/AbstractComponent.java b/common/src/main/java/com/lzf/flyingsocks/AbstractComponent.java index 3295aa6..187e628 100644 --- a/common/src/main/java/com/lzf/flyingsocks/AbstractComponent.java +++ b/common/src/main/java/com/lzf/flyingsocks/AbstractComponent.java @@ -190,6 +190,7 @@ protected void initInternal() { entry.getValue().init(); } catch (Exception e) { log.error(String.format("Component [%s] init failure.", entry.getKey()), e); + handleException(entry.getValue(), e); } } } @@ -203,6 +204,7 @@ protected void startInternal() { entry.getValue().start(); } catch (Exception e) { log.error(String.format("Component [%s] start failure.", entry.getKey()), e); + handleException(entry.getValue(), e); } } } @@ -216,6 +218,7 @@ protected void stopInternal() { entry.getValue().stop(); } catch (Exception e) { log.error(String.format("Component [%s] stop failure.", entry.getKey()), e); + handleException(entry.getValue(), e); } } } @@ -229,6 +232,7 @@ protected void restartInternal() { entry.getValue().restart(); } catch (Exception e) { log.error(String.format("Component [%s] restart failure.", entry.getKey()), e); + handleException(entry.getValue(), e); } } } @@ -236,6 +240,10 @@ protected void restartInternal() { super.restartInternal(); } + + protected void handleException(Component component, Exception exception) { } + + /** * 当子模块需要修改名称时由子模块调用 * diff --git a/pom.xml b/pom.xml index b853a67..7a2dbec 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ io.netty netty-all - 4.1.60.Final + 4.1.63.Final com.alibaba diff --git a/server/src/main/java/com/lzf/flyingsocks/server/ServerConfig.java b/server/src/main/java/com/lzf/flyingsocks/server/ServerConfig.java index 6ec12c0..38b7a90 100644 --- a/server/src/main/java/com/lzf/flyingsocks/server/ServerConfig.java +++ b/server/src/main/java/com/lzf/flyingsocks/server/ServerConfig.java @@ -33,6 +33,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; @@ -68,7 +69,7 @@ public class ServerConfig extends AbstractConfig implements Config { protected void initInternal() throws ConfigInitializationException { String folderString = configManager.getSystemProperties("flyingsocks.config.location"); if (folderString == null) { - folderString = configManager.getSystemProperties("user.home"); + folderString = configManager.getSystemProperties("user.home") + File.separatorChar + "flyingsocks-server"; log.info("Properties flyingsocks.config.location not configure, using path {}", folderString); }