Browse Source

Minor bugfixes (#647)

* Drop unused variable to suppress warning in LogForm

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>

* Fix IPv6 displaying

It is a little ugly, send a PR if you can find a better way.

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
tags/3.2
Syrone Wong GitHub 8 years ago
parent
commit
3b5d38658f
2 changed files with 21 additions and 8 deletions
  1. +20
    -7
      shadowsocks-csharp/Model/Server.cs
  2. +1
    -1
      shadowsocks-csharp/View/LogForm.cs

+ 20
- 7
shadowsocks-csharp/Model/Server.cs View File

@@ -1,4 +1,6 @@
using System; using System;
using System.Net;
using System.Net.Sockets;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -39,14 +41,25 @@ namespace Shadowsocks.Model
{ {
return I18N.GetString("New server"); return I18N.GetString("New server");
} }
if (remarks.IsNullOrEmpty())
{
return server + ":" + server_port;
}
else
{
return remarks + " (" + server + ":" + server_port + ")";
IPAddress addr;
IPAddress.TryParse( server, out addr );
if ( remarks.IsNullOrEmpty() ) {
switch ( addr.AddressFamily ) {
case AddressFamily.InterNetwork:
return $"{server}:{server_port}";
case AddressFamily.InterNetworkV6:
return $"[{server}]:{server_port}";
}
} else {
switch ( addr.AddressFamily ) {
case AddressFamily.InterNetwork:
return $"{remarks} ({server}:{server_port})";
case AddressFamily.InterNetworkV6:
return $"{remarks} ([{server}]:{server_port})";
}
} }
// This should not happen, user should check the input instead of blaming
return null;
} }
public Server() public Server()


+ 1
- 1
shadowsocks-csharp/View/LogForm.cs View File

@@ -93,7 +93,7 @@ namespace Shadowsocks.View
})); }));
} }
} }
catch (ObjectDisposedException ex)
catch (ObjectDisposedException)
{ {
// suppress the thread race error: // suppress the thread race error:
// when closing the form but the Invoked Action is still working and cause 'Chart is Disposed' exception // when closing the form but the Invoked Action is still working and cause 'Chart is Disposed' exception


Loading…
Cancel
Save