Signed-off-by: Syrone Wong <wong.syrone@gmail.com>tags/3.3.3
@@ -104,6 +104,7 @@ Reg All=注册全部热键 | |||||
Shadowsocks Error: {0}=Shadowsocks 错误: {0} | Shadowsocks Error: {0}=Shadowsocks 错误: {0} | ||||
Port already in use=端口已被占用 | Port already in use=端口已被占用 | ||||
Illegal port number format=非法端口格式 | Illegal port number format=非法端口格式 | ||||
Illegal timeout format=非法超时格式 | |||||
Please add at least one server=请添加至少一个服务器 | Please add at least one server=请添加至少一个服务器 | ||||
Server IP can not be blank=服务器 IP 不能为空 | Server IP can not be blank=服务器 IP 不能为空 | ||||
Password can not be blank=密码不能为空 | Password can not be blank=密码不能为空 | ||||
@@ -104,6 +104,7 @@ Reg All=註冊全部捷徑鍵 | |||||
Shadowsocks Error: {0}=Shadowsocks 錯誤: {0} | Shadowsocks Error: {0}=Shadowsocks 錯誤: {0} | ||||
Port already in use=連接埠號碼已被占用 | Port already in use=連接埠號碼已被占用 | ||||
Illegal port number format=非法連接埠號碼格式 | Illegal port number format=非法連接埠號碼格式 | ||||
Illegal timeout format=非法超時格式 | |||||
Please add at least one server=請新增至少一個伺服器 | Please add at least one server=請新增至少一個伺服器 | ||||
Server IP can not be blank=伺服器 IP 不能為空 | Server IP can not be blank=伺服器 IP 不能為空 | ||||
Password can not be blank=密碼不能為空 | Password can not be blank=密碼不能為空 | ||||
@@ -79,16 +79,32 @@ namespace Shadowsocks.View | |||||
{ | { | ||||
return true; | return true; | ||||
} | } | ||||
Server server = new Server | |||||
Server server = new Server(); | |||||
server.server = IPTextBox.Text.Trim(); | |||||
try | |||||
{ | { | ||||
server = IPTextBox.Text.Trim(), | |||||
server_port = int.Parse(ServerPortTextBox.Text), | |||||
password = PasswordTextBox.Text, | |||||
method = EncryptionSelect.Text, | |||||
remarks = RemarksTextBox.Text, | |||||
timeout = int.Parse(TimeoutTextBox.Text), | |||||
auth = OneTimeAuth.Checked | |||||
}; | |||||
server.server_port = int.Parse(ServerPortTextBox.Text); | |||||
} | |||||
catch (FormatException) | |||||
{ | |||||
MessageBox.Show(I18N.GetString("Illegal port number format")); | |||||
ServerPortTextBox.Clear(); | |||||
return false; | |||||
} | |||||
server.password = PasswordTextBox.Text; | |||||
server.method = EncryptionSelect.Text; | |||||
server.remarks = RemarksTextBox.Text; | |||||
try | |||||
{ | |||||
server.timeout = int.Parse(TimeoutTextBox.Text); | |||||
} | |||||
catch (FormatException) | |||||
{ | |||||
MessageBox.Show(I18N.GetString("Illegal timeout format")); | |||||
TimeoutTextBox.Clear(); | |||||
return false; | |||||
} | |||||
server.auth = OneTimeAuth.Checked; | |||||
int localPort = int.Parse(ProxyPortTextBox.Text); | int localPort = int.Parse(ProxyPortTextBox.Text); | ||||
Configuration.CheckServer(server); | Configuration.CheckServer(server); | ||||
Configuration.CheckLocalPort(localPort); | Configuration.CheckLocalPort(localPort); | ||||
@@ -97,10 +113,6 @@ namespace Shadowsocks.View | |||||
return true; | return true; | ||||
} | } | ||||
catch (FormatException) | |||||
{ | |||||
MessageBox.Show(I18N.GetString("Illegal port number format")); | |||||
} | |||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
MessageBox.Show(ex.Message); | MessageBox.Show(ex.Message); | ||||
@@ -58,30 +58,48 @@ namespace Shadowsocks.View | |||||
private void OKButton_Click(object sender, EventArgs e) | private void OKButton_Click(object sender, EventArgs e) | ||||
{ | { | ||||
var type = ProxyTypeComboBox.SelectedIndex; | |||||
var proxy = ProxyServerTextBox.Text; | |||||
var port = 0; | |||||
var timeout = 3; | |||||
if (UseProxyCheckBox.Checked) | if (UseProxyCheckBox.Checked) | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
var type = ProxyTypeComboBox.SelectedIndex; | |||||
var proxy = ProxyServerTextBox.Text; | |||||
var port = int.Parse(ProxyPortTextBox.Text); | |||||
var timeout = int.Parse(ProxyTimeoutTextBox.Text); | |||||
Configuration.CheckServer(proxy); | |||||
Configuration.CheckPort(port); | |||||
Configuration.CheckTimeout(timeout, ProxyConfig.MaxProxyTimeoutSec); | |||||
controller.EnableProxy(type, proxy, port); | |||||
port = int.Parse(ProxyPortTextBox.Text); | |||||
} | } | ||||
catch (FormatException) | catch (FormatException) | ||||
{ | { | ||||
MessageBox.Show(I18N.GetString("Illegal port number format")); | MessageBox.Show(I18N.GetString("Illegal port number format")); | ||||
ProxyPortTextBox.Clear(); | |||||
return; | return; | ||||
} | } | ||||
try | |||||
{ | |||||
timeout = int.Parse(ProxyTimeoutTextBox.Text); | |||||
} | |||||
catch (FormatException) | |||||
{ | |||||
MessageBox.Show(I18N.GetString("Illegal timeout format")); | |||||
ProxyTimeoutTextBox.Clear(); | |||||
return; | |||||
} | |||||
try | |||||
{ | |||||
Configuration.CheckServer(proxy); | |||||
Configuration.CheckPort(port); | |||||
Configuration.CheckTimeout(timeout, ProxyConfig.MaxProxyTimeoutSec); | |||||
} | |||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
MessageBox.Show(ex.Message); | MessageBox.Show(ex.Message); | ||||
return; | return; | ||||
} | } | ||||
controller.EnableProxy(type, proxy, port); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -89,14 +107,10 @@ namespace Shadowsocks.View | |||||
} | } | ||||
_modifiedConfiguration.useProxy = UseProxyCheckBox.Checked; | _modifiedConfiguration.useProxy = UseProxyCheckBox.Checked; | ||||
_modifiedConfiguration.proxyType = ProxyTypeComboBox.SelectedIndex; | |||||
_modifiedConfiguration.proxyServer = ProxyServerTextBox.Text; | |||||
var tmpProxyPort = 0; | |||||
int.TryParse(ProxyPortTextBox.Text, out tmpProxyPort); | |||||
_modifiedConfiguration.proxyPort = tmpProxyPort; | |||||
var tmpProxyTimeout = 0; | |||||
int.TryParse(ProxyTimeoutTextBox.Text, out tmpProxyTimeout); | |||||
_modifiedConfiguration.proxyTimeout = tmpProxyTimeout; | |||||
_modifiedConfiguration.proxyType = type; | |||||
_modifiedConfiguration.proxyServer = proxy; | |||||
_modifiedConfiguration.proxyPort = port; | |||||
_modifiedConfiguration.proxyTimeout = timeout; | |||||
controller.SaveProxyConfig(_modifiedConfiguration); | controller.SaveProxyConfig(_modifiedConfiguration); | ||||
this.Close(); | this.Close(); | ||||