├── packages.config ├── Properties ├── Settings.settings ├── AssemblyInfo.cs ├── Settings.Designer.cs ├── Resources.Designer.cs └── Resources.resx ├── App.config ├── Program.cs ├── HttpResult.cs ├── JsonReader.cs ├── SteamHosts.sln ├── UpdateIp.cs ├── Hosts.cs ├── HttpHeader.cs ├── ip.json ├── .gitattributes ├── app.manifest ├── SteamHosts.csproj ├── .gitignore ├── Form1.resx ├── Form1.cs └── Form1.Designer.cs /packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace SteamHosts 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// 应用程序的主入口点。 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /HttpResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SteamHosts 8 | { 9 | class HttpResult 10 | { 11 | private bool flag; // true: has response false: no response 12 | private string result; 13 | private int time; 14 | 15 | public bool isSuccess(){ 16 | return flag; 17 | } 18 | 19 | public void setFlag(bool flag) { 20 | this.flag = flag; 21 | } 22 | 23 | public void setResult(string result) { 24 | this.result = result; 25 | } 26 | 27 | public string getResult() { 28 | return result; 29 | } 30 | 31 | public int getTime() { 32 | return time; 33 | } 34 | 35 | public void setTime(int time) { 36 | this.time = time; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /JsonReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Newtonsoft.Json; 8 | using System.Collections; 9 | 10 | namespace SteamHosts 11 | { 12 | class JsonReader 13 | { 14 | public static Dictionary readIpList(String filename) 15 | { 16 | Dictionary ipList = new Dictionary(); 17 | using (StreamReader sr = new StreamReader(filename)) 18 | { 19 | try 20 | { 21 | String data = sr.ReadToEnd(); 22 | return JsonConvert.DeserializeObject>(data); 23 | } catch(Exception e) 24 | { 25 | Console.WriteLine(e.ToString()); 26 | } 27 | } 28 | 29 | return null; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SteamHosts.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.14 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamHosts", "SteamHosts.csproj", "{00B71611-0D84-4BC7-971D-89288379E64C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {00B71611-0D84-4BC7-971D-89288379E64C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {00B71611-0D84-4BC7-971D-89288379E64C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {00B71611-0D84-4BC7-971D-89288379E64C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {00B71611-0D84-4BC7-971D-89288379E64C}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /UpdateIp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SteamHosts 9 | { 10 | class MyWebClient : WebClient 11 | { 12 | protected override WebRequest GetWebRequest(Uri uri) 13 | { 14 | WebRequest w = base.GetWebRequest(uri); 15 | w.Timeout = 6000; 16 | return w; 17 | } 18 | } 19 | 20 | class UpdateIp 21 | { 22 | private static string url = "https://stip.m21.win/ip"; 23 | 24 | public static string UpdateIpLibrary() 25 | { 26 | try 27 | { 28 | MyWebClient webClient = new MyWebClient(); 29 | webClient.Encoding = Encoding.UTF8; 30 | webClient.DownloadFile(url, "ip.json"); 31 | return "OK"; 32 | } catch (Exception e) 33 | { 34 | return e.Message; 35 | } 36 | 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("SteamHosts")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SteamHosts")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("00b71611-0d84-4bc7-971d-89288379e64c")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SteamHosts.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Hosts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using PSHostsFile; 8 | using System.Net; 9 | 10 | namespace SteamHosts 11 | { 12 | class Hosts 13 | { 14 | public static string ChangeHosts(string hostname, string ipAddr) 15 | { 16 | try 17 | { 18 | HostsFile.Set(hostname, ipAddr); 19 | return "OK"; 20 | } catch (Exception e) 21 | { 22 | Console.WriteLine(e.ToString()); 23 | return e.Message.ToString(); 24 | } 25 | } 26 | 27 | public static string getIPByDomain(string hostname) 28 | { 29 | try 30 | { 31 | IPHostEntry hostInfo = Dns.GetHostEntry(hostname); 32 | IPAddress[] IPAddr = hostInfo.AddressList; 33 | return IPAddr[0].ToString(); 34 | } catch (Exception e) 35 | { 36 | return e.Message.ToString(); 37 | } 38 | } 39 | 40 | public static string removeHostsItem(string domain) 41 | { 42 | try 43 | { 44 | HostsFile.Remove(domain); 45 | return "OK"; 46 | } catch (Exception e) 47 | { 48 | return e.Message; 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /HttpHeader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Diagnostics; 4 | 5 | namespace SteamHosts 6 | { 7 | class HttpHeader 8 | { 9 | private static string ERROR_TIMEOUT = "连接超时"; 10 | private static string ERROR_RESET = "连接被重置"; 11 | private static string ERROR_OTHER = "连接失败"; 12 | 13 | public static HttpResult GetHttpConnectionStatus( 14 | string hostname, string ip, int timeout) 15 | { 16 | HttpResult result = new HttpResult(); 17 | result.setFlag(false); 18 | 19 | try 20 | { 21 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + hostname + "/"); 22 | request.Timeout = 1000 * timeout; 23 | 24 | if (! string.IsNullOrEmpty(ip)) 25 | { 26 | WebProxy proxy = new WebProxy(ip); 27 | request.Proxy = proxy; 28 | } 29 | 30 | Stopwatch timer = new Stopwatch(); 31 | timer.Start(); 32 | 33 | HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 34 | response.Close(); 35 | 36 | timer.Stop(); 37 | TimeSpan timeSpan = timer.Elapsed; 38 | result.setTime((int) timeSpan.TotalMilliseconds); 39 | result.setFlag(true); 40 | } catch (WebException e) when (e.Status == WebExceptionStatus.Timeout) 41 | { 42 | result.setResult(ERROR_TIMEOUT); 43 | } catch (WebException e) when (e.Status == WebExceptionStatus.ReceiveFailure) 44 | { 45 | result.setResult(ERROR_RESET); 46 | } catch (WebException e) 47 | { 48 | Console.WriteLine(e); 49 | result.setResult(ERROR_OTHER); 50 | } 51 | 52 | return result; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ip.json: -------------------------------------------------------------------------------- 1 | { 2 | "104.71.138.149": "日本东京都", 3 | "121.156.60.202": "韩国", 4 | "104.115.209.150": "台湾", 5 | "104.96.140.251": "奥地利维也纳", 6 | "23.192.228.12": "美国圣何塞", 7 | "2.19.118.134": "瑞典斯德哥尔摩", 8 | "184.86.153.115": "美国达拉斯", 9 | "23.1.139.9": "美国阿什本", 10 | "88.221.71.104": "西班牙马德里", 11 | "104.108.51.241": "德国法兰克福", 12 | "2.18.171.228": "比利时布鲁塞尔", 13 | "104.111.200.96": "美国", 14 | "23.223.27.182": "瑞典斯德哥尔摩", 15 | "23.5.209.254": "美国圣何塞", 16 | "104.104.196.114": "美国", 17 | "184.26.227.22": "日本大阪府", 18 | "23.15.111.93": "新加坡", 19 | "23.66.80.79": "日本东京都", 20 | "23.8.232.137": "马来西亚赛城", 21 | "23.59.117.218": "波兰华沙", 22 | "104.98.6.105": "美国", 23 | "23.33.10.224": "意大利米兰", 24 | "23.214.102.15": "英国伦敦", 25 | "23.50.18.229": "香港", 26 | "23.3.163.89": "美国亚特兰大", 27 | "184.85.120.33": "香港", 28 | "23.52.51.147": "荷兰阿姆斯特丹", 29 | "184.26.114.232": "日本东京都", 30 | "104.85.171.18": "美国", 31 | "104.85.6.86": "美国", 32 | "104.73.24.159": "美国迈阿密", 33 | "23.63.11.49": "澳大利亚布里斯班", 34 | "104.76.18.71": "日本大阪府", 35 | "23.78.48.205": "丹麦哥本哈根", 36 | "23.220.195.167": "美国洛杉矶", 37 | "104.76.133.209": "韩国首尔", 38 | "23.66.253.192": "新加坡", 39 | "95.100.235.83": "意大利米兰", 40 | "125.56.229.186": "新加坡", 41 | "104.94.173.51": "美国", 42 | "23.2.39.9": "日本东京都", 43 | "104.82.83.38": "英国伦敦", 44 | "104.92.6.185": "美国亚特兰大", 45 | "104.94.55.49": "德国法兰克福", 46 | "104.125.192.229": "美国", 47 | "23.207.73.43": "葡萄牙里斯本", 48 | "23.211.56.171": "美国达拉斯", 49 | "23.41.10.4": "美国迈阿密", 50 | "23.79.47.47": "美国西雅图", 51 | "60.254.134.232": "日本东京都", 52 | "104.74.213.173": "韩国首尔", 53 | "23.199.157.145": "马来西亚", 54 | "104.122.102.69": "印度", 55 | "184.30.52.153": "印度", 56 | "104.113.185.151": "新西兰", 57 | "23.59.224.224": "美国纽约", 58 | "104.90.223.74": "泰国曼谷", 59 | "23.48.247.41": "美国洛杉矶", 60 | "104.116.1.112": "台湾", 61 | "104.95.59.167": "美国阿什本", 62 | "23.214.173.150": "英国伦敦", 63 | "23.50.91.168": "新加坡", 64 | "104.81.108.156": "波兰华沙", 65 | "104.70.215.61": "美国洛杉矶", 66 | "104.77.22.110": "日本东京都", 67 | "104.99.0.42": "美国", 68 | "23.217.43.159": "美国纽约", 69 | "104.122.202.20": "美国", 70 | "104.89.240.226": "美国达拉斯", 71 | "184.25.165.51": "美国", 72 | "23.37.249.168": "德国法兰克福", 73 | "96.7.203.235": "加拿大多伦多", 74 | "172.230.106.66": "美国圣何塞", 75 | "104.109.82.151": "英国伦敦", 76 | "23.37.168.155": "西班牙马德里", 77 | "23.9.157.4": "澳大利亚", 78 | "23.39.70.158": "西班牙马德里", 79 | "23.74.217.25": "新加坡", 80 | "23.4.168.253": "澳大利亚阿德莱德", 81 | "23.2.63.97": "美国达拉斯", 82 | "23.63.45.113": "澳大利亚珀斯", 83 | "184.84.152.218": "美国芝加哥", 84 | "104.84.107.79": "美国华盛顿", 85 | "23.32.131.235": "美国佛罗里达州", 86 | "23.9.1.240": "奥地利维也纳", 87 | "2.18.152.101": "爱尔兰都柏林", 88 | "23.12.166.213": "阿根廷布宜诺斯艾利斯", 89 | "23.2.19.134": "日本东京都" 90 | } -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本: 4.0.30319.42000 5 | // 6 | // 对此文件的更改可能导致不正确的行为,如果 7 | // 重新生成代码,则所做更改将丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SteamHosts.Properties 12 | { 13 | 14 | 15 | /// 16 | /// 强类型资源类,用于查找本地化字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// 返回此类使用的缓存 ResourceManager 实例。 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SteamHosts.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// 覆盖当前线程的 CurrentUICulture 属性 56 | /// 使用此强类型的资源类的资源查找。 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 52 | 59 | 60 | 61 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /SteamHosts.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {00B71611-0D84-4BC7-971D-89288379E64C} 8 | WinExe 9 | SteamHosts 10 | SteamHosts 11 | v4.5.2 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | app.manifest 36 | 37 | 38 | 39 | packages\EasyHttp.1.7.0\lib\net40\EasyHttp.dll 40 | 41 | 42 | packages\JsonFx.2.0.1209.2802\lib\net40\JsonFx.dll 43 | 44 | 45 | packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll 46 | 47 | 48 | packages\PSHostsFile.3.0.5\lib\PSHostsFile.dll 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Form 65 | 66 | 67 | Form1.cs 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Component 77 | 78 | 79 | Form1.cs 80 | 81 | 82 | ResXFileCodeGenerator 83 | Resources.Designer.cs 84 | Designer 85 | 86 | 87 | True 88 | Resources.resx 89 | 90 | 91 | 92 | 93 | SettingsSingleFileGenerator 94 | Settings.Designer.cs 95 | 96 | 97 | True 98 | Settings.settings 99 | True 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Form1.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | True 122 | 123 | 124 | True 125 | 126 | 127 | True 128 | 129 | 130 | True 131 | 132 | 133 | True 134 | 135 | 136 | True 137 | 138 | -------------------------------------------------------------------------------- /Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using System.Windows.Forms; 5 | using System.Threading; 6 | using System.Linq; 7 | using System.Drawing; 8 | 9 | namespace SteamHosts 10 | { 11 | public partial class Form1 : Form 12 | { 13 | const string Hostname = "store.steampowered.com"; 14 | const int MaximumConnection = 30; 15 | const int MaximumTimeout = 4; // seconds 16 | const string TimeUnitString = " ms"; 17 | 18 | Dictionary ipList; 19 | int foundCount; 20 | int minTime; 21 | string minIp; 22 | 23 | private delegate void UpdateListViewDelegate(string ip, bool success, int time, string result); 24 | 25 | private delegate void updateCurrentIpResultDelegate(bool success, int time, string result); 26 | 27 | public Form1() 28 | { 29 | InitializeComponent(); 30 | } 31 | 32 | private void UpdateListView(string ip, bool success, int time, string result) 33 | { 34 | DataGridViewRow row = dataGridView1.Rows 35 | .Cast() 36 | .Where(r => r.Cells["ip"].Value.ToString().Equals(ip)) 37 | .First(); 38 | 39 | if (success) 40 | { 41 | row.Cells["time"].Value = time.ToString() + TimeUnitString; 42 | 43 | if (time < minTime) 44 | { 45 | try 46 | { 47 | DataGridViewCellStyle style2 = new DataGridViewCellStyle(); 48 | style2.BackColor = Color.White; 49 | 50 | DataGridViewRow foundRow = dataGridView1.Rows 51 | .Cast() 52 | .Where(r => r.Cells["ip"].Value.ToString().Equals(minIp)) 53 | .First(); 54 | foundRow.Selected = false; 55 | foundRow.Cells["time"].Style = style2; 56 | } catch (Exception) 57 | { 58 | // 59 | } 60 | 61 | minTime = time; 62 | minIp = ip; 63 | 64 | DataGridViewCellStyle style = new DataGridViewCellStyle(); 65 | style.BackColor = Color.LightPink; 66 | row.Cells["time"].Style = style; 67 | 68 | dataGridView1.FirstDisplayedScrollingRowIndex = row.Index; 69 | dataGridView1.CurrentCell = dataGridView1.Rows[row.Index].Cells[0]; 70 | dataGridView1.Refresh(); 71 | row.Selected = true; 72 | } 73 | } 74 | else 75 | { 76 | row.Cells["time"].Value = result; 77 | } 78 | 79 | //foundCount++; 80 | Interlocked.Increment(ref foundCount); 81 | if (foundCount == ipList.Count) 82 | { 83 | button1.Enabled = true; 84 | button3.Enabled = true; 85 | } 86 | } 87 | 88 | private void updateCurrentIpResult(bool success, int time, string result) 89 | { 90 | if(success) 91 | { 92 | label4.ForeColor = Color.Green; 93 | label4.Text = "(连接成功,耗时:" + time + " ms)"; 94 | } else 95 | { 96 | label4.ForeColor = Color.Red; 97 | label4.Text = "(" + result + ")"; 98 | } 99 | } 100 | 101 | private void Form1_Load(object sender, EventArgs e) 102 | { 103 | getCurrentHosts(Hostname); 104 | 105 | initialize(); 106 | } 107 | 108 | private void initialize() 109 | { 110 | if (!System.IO.File.Exists("ip.json")) 111 | { 112 | MessageBox.Show("无法找到ip.json文件!", "SteamHosts"); 113 | Environment.Exit(0); 114 | } 115 | ipList = JsonReader.readIpList("ip.json"); 116 | 117 | dataGridView1.Rows.Clear(); 118 | dataGridView1.Refresh(); 119 | 120 | foreach (var item in ipList) 121 | { 122 | int index = dataGridView1.Rows.Add(); 123 | dataGridView1.Rows[index].Cells[0].Value = item.Key; 124 | dataGridView1.Rows[index].Cells[1].Value = ""; 125 | dataGridView1.Rows[index].Cells[2].Value = item.Value; 126 | } 127 | 128 | if (ipList.Count > 0) 129 | { 130 | button2.Enabled = true; 131 | } else 132 | { 133 | button2.Enabled = false; 134 | } 135 | } 136 | 137 | private void clearData() 138 | { 139 | foundCount = 0; 140 | minTime = 99999; 141 | minIp = null; 142 | 143 | dataGridView1.FirstDisplayedScrollingRowIndex = 0; 144 | dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[0]; 145 | dataGridView1.Refresh(); 146 | 147 | DataGridViewCellStyle style = new DataGridViewCellStyle(); 148 | style.BackColor = Color.White; 149 | 150 | foreach (DataGridViewRow row in dataGridView1.Rows) 151 | { 152 | row.Cells["time"].Style = style; 153 | row.Cells["time"].Value = ""; 154 | } 155 | } 156 | 157 | private void button1_Click(object sender, EventArgs e) 158 | { 159 | TestHttpSpeed(MaximumConnection, MaximumTimeout); 160 | } 161 | 162 | private void button2_Click(object sender, EventArgs e) 163 | { 164 | string hostsResult = "IP null"; 165 | 166 | string selectedIP = null; 167 | try 168 | { 169 | selectedIP = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells["ip"].Value.ToString(); 170 | } catch 171 | { 172 | // 173 | } 174 | 175 | if ( selectedIP != null ) 176 | { 177 | hostsResult = Hosts.ChangeHosts("steamcommunity.com", selectedIP); 178 | hostsResult = Hosts.ChangeHosts(Hostname, selectedIP); 179 | if (hostsResult == "OK") 180 | { 181 | MessageBox.Show("设置hosts成功!", "SteamHosts"); 182 | getCurrentHosts(Hostname); 183 | return; 184 | } 185 | } 186 | MessageBox.Show("设置hosts失败,原因:" + hostsResult, "SteamHosts"); 187 | } 188 | 189 | private void testSingleHttpWithIp(string ip, int timeout) 190 | { 191 | Task task = Task.Run(() => { 192 | HttpResult result = HttpHeader.GetHttpConnectionStatus(Hostname, ip, timeout); 193 | 194 | BeginInvoke(new updateCurrentIpResultDelegate(updateCurrentIpResult), 195 | result.isSuccess(), result.getTime(), result.getResult()); 196 | }); 197 | } 198 | 199 | private void TestHttpSpeed(int maxConn, int timeout) 200 | { 201 | clearData(); 202 | button1.Enabled = false; 203 | button3.Enabled = false; 204 | 205 | Task runTask = Task.Run( ()=> { 206 | Semaphore semaphore = new Semaphore(maxConn, maxConn); 207 | 208 | foreach (var item in ipList) { 209 | semaphore.WaitOne(); 210 | 211 | Task task = Task.Run( ()=> { 212 | HttpResult result = HttpHeader.GetHttpConnectionStatus(Hostname, item.Key, timeout); 213 | 214 | BeginInvoke(new UpdateListViewDelegate(UpdateListView), 215 | item.Key, result.isSuccess(), result.getTime(), result.getResult()); 216 | 217 | semaphore.Release(); 218 | } ); 219 | } 220 | }); 221 | } 222 | 223 | private void getCurrentHosts(string hostname) 224 | { 225 | string ip = Hosts.getIPByDomain(hostname); 226 | label3.Text = ip; 227 | 228 | label4.ForeColor = Color.Black; 229 | label4.Text = "(测试中...)"; 230 | 231 | testSingleHttpWithIp(ip, MaximumTimeout); 232 | } 233 | 234 | private void button3_Click(object sender, EventArgs e) 235 | { 236 | button3.Text = "更新中..."; 237 | button1.Enabled = false; 238 | button2.Enabled = false; 239 | button3.Enabled = false; 240 | 241 | System.IO.File.Copy("ip.json", "ip.json.bak", true); 242 | 243 | string result = UpdateIp.UpdateIpLibrary(); 244 | 245 | if (result.Equals("OK")) 246 | { 247 | MessageBox.Show("更新本地IP库文件成功!", "SteamHosts"); 248 | } else 249 | { 250 | if (System.IO.File.Exists("ip.json.bak")) 251 | { 252 | System.IO.File.Copy("ip.json.bak", "ip.json", true); 253 | } 254 | MessageBox.Show("更新本地IP库文件失败!原因:" + result, "SteamHosts"); 255 | } 256 | 257 | System.IO.File.Delete("ip.json.bak"); 258 | 259 | initialize(); 260 | 261 | button3.Text = "更新IP列表"; 262 | button1.Enabled = true; 263 | button3.Enabled = true; 264 | } 265 | 266 | private void label1_Click(object sender, EventArgs e) 267 | { 268 | System.Diagnostics.Process.Start("http://weibo.com/511200124/"); 269 | } 270 | 271 | private void button4_Click(object sender, EventArgs e) 272 | { 273 | if(MessageBox.Show("确定要清除Steam的hosts吗?", "SteamHosts", MessageBoxButtons.YesNo) 274 | == DialogResult.Yes) 275 | { 276 | Hosts.removeHostsItem(Hostname); 277 | string result = Hosts.removeHostsItem("steamcommunity.com"); 278 | 279 | if (result.Equals("OK")) 280 | { 281 | MessageBox.Show("清除Steam hosts成功!", "SteamHosts"); 282 | } else 283 | { 284 | MessageBox.Show("清除Steam hosts失败!原因:" + result, "SteamHosts"); 285 | } 286 | getCurrentHosts(Hostname); 287 | } 288 | } 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SteamHosts 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// 必需的设计器变量。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清理所有正在使用的资源。 12 | /// 13 | /// 如果应释放托管资源,为 true;否则为 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows 窗体设计器生成的代码 24 | 25 | /// 26 | /// 设计器支持所需的方法 - 不要修改 27 | /// 使用代码编辑器修改此方法的内容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); 32 | System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); 33 | System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); 34 | this.button1 = new System.Windows.Forms.Button(); 35 | this.button2 = new System.Windows.Forms.Button(); 36 | this.label1 = new System.Windows.Forms.Label(); 37 | this.dataGridView1 = new System.Windows.Forms.DataGridView(); 38 | this.ip = new System.Windows.Forms.DataGridViewTextBoxColumn(); 39 | this.time = new System.Windows.Forms.DataGridViewTextBoxColumn(); 40 | this.location = new System.Windows.Forms.DataGridViewTextBoxColumn(); 41 | this.label2 = new System.Windows.Forms.Label(); 42 | this.label3 = new System.Windows.Forms.Label(); 43 | this.button3 = new System.Windows.Forms.Button(); 44 | this.button4 = new System.Windows.Forms.Button(); 45 | this.label4 = new System.Windows.Forms.Label(); 46 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); 47 | this.SuspendLayout(); 48 | // 49 | // button1 50 | // 51 | this.button1.Location = new System.Drawing.Point(38, 597); 52 | this.button1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 53 | this.button1.Name = "button1"; 54 | this.button1.Size = new System.Drawing.Size(132, 37); 55 | this.button1.TabIndex = 1; 56 | this.button1.Text = "寻找可用IP"; 57 | this.button1.UseVisualStyleBackColor = true; 58 | this.button1.Click += new System.EventHandler(this.button1_Click); 59 | // 60 | // button2 61 | // 62 | this.button2.Enabled = false; 63 | this.button2.ForeColor = System.Drawing.SystemColors.Highlight; 64 | this.button2.Location = new System.Drawing.Point(189, 597); 65 | this.button2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 66 | this.button2.Name = "button2"; 67 | this.button2.Size = new System.Drawing.Size(190, 37); 68 | this.button2.TabIndex = 3; 69 | this.button2.Text = "为选中IP设置Hosts"; 70 | this.button2.UseVisualStyleBackColor = true; 71 | this.button2.Click += new System.EventHandler(this.button2_Click); 72 | // 73 | // label1 74 | // 75 | this.label1.AutoSize = true; 76 | this.label1.Location = new System.Drawing.Point(273, 660); 77 | this.label1.Name = "label1"; 78 | this.label1.Size = new System.Drawing.Size(182, 25); 79 | this.label1.TabIndex = 4; 80 | this.label1.Text = "©2017 Makazeu ♥"; 81 | this.label1.Click += new System.EventHandler(this.label1_Click); 82 | // 83 | // dataGridView1 84 | // 85 | this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 86 | this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 87 | this.ip, 88 | this.time, 89 | this.location}); 90 | this.dataGridView1.Location = new System.Drawing.Point(38, 34); 91 | this.dataGridView1.Name = "dataGridView1"; 92 | this.dataGridView1.RowTemplate.Height = 27; 93 | this.dataGridView1.Size = new System.Drawing.Size(659, 503); 94 | this.dataGridView1.TabIndex = 5; 95 | // 96 | // ip 97 | // 98 | dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 99 | this.ip.DefaultCellStyle = dataGridViewCellStyle13; 100 | this.ip.HeaderText = "IP地址"; 101 | this.ip.Name = "ip"; 102 | this.ip.ToolTipText = "Steam CDN服务器的IP地址"; 103 | this.ip.Width = 180; 104 | // 105 | // time 106 | // 107 | dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 108 | this.time.DefaultCellStyle = dataGridViewCellStyle14; 109 | this.time.HeaderText = "页面打开时间"; 110 | this.time.Name = "time"; 111 | this.time.ToolTipText = "从连接服务器到获取到首页代码的时间"; 112 | this.time.Width = 160; 113 | // 114 | // location 115 | // 116 | dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 117 | this.location.DefaultCellStyle = dataGridViewCellStyle15; 118 | this.location.HeaderText = "IP地理位置"; 119 | this.location.Name = "location"; 120 | this.location.ToolTipText = "IP地址的地理位置"; 121 | this.location.Width = 250; 122 | // 123 | // label2 124 | // 125 | this.label2.AutoSize = true; 126 | this.label2.Location = new System.Drawing.Point(174, 553); 127 | this.label2.Name = "label2"; 128 | this.label2.Size = new System.Drawing.Size(125, 25); 129 | this.label2.TabIndex = 6; 130 | this.label2.Text = "当前IP地址:"; 131 | // 132 | // label3 133 | // 134 | this.label3.AutoSize = true; 135 | this.label3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 136 | this.label3.Location = new System.Drawing.Point(284, 553); 137 | this.label3.Name = "label3"; 138 | this.label3.Size = new System.Drawing.Size(0, 25); 139 | this.label3.TabIndex = 7; 140 | // 141 | // button3 142 | // 143 | this.button3.Location = new System.Drawing.Point(566, 597); 144 | this.button3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 145 | this.button3.Name = "button3"; 146 | this.button3.Size = new System.Drawing.Size(131, 37); 147 | this.button3.TabIndex = 8; 148 | this.button3.Text = "更新IP列表"; 149 | this.button3.UseVisualStyleBackColor = true; 150 | this.button3.Click += new System.EventHandler(this.button3_Click); 151 | // 152 | // button4 153 | // 154 | this.button4.Location = new System.Drawing.Point(406, 597); 155 | this.button4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 156 | this.button4.Name = "button4"; 157 | this.button4.Size = new System.Drawing.Size(131, 37); 158 | this.button4.TabIndex = 9; 159 | this.button4.Text = "清除Hosts"; 160 | this.button4.UseVisualStyleBackColor = true; 161 | this.button4.Click += new System.EventHandler(this.button4_Click); 162 | // 163 | // label4 164 | // 165 | this.label4.AutoSize = true; 166 | this.label4.Location = new System.Drawing.Point(401, 553); 167 | this.label4.Name = "label4"; 168 | this.label4.Size = new System.Drawing.Size(122, 25); 169 | this.label4.TabIndex = 10; 170 | this.label4.Text = "(测试中...)"; 171 | // 172 | // Form1 173 | // 174 | this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); 175 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 176 | this.ClientSize = new System.Drawing.Size(744, 694); 177 | this.Controls.Add(this.label4); 178 | this.Controls.Add(this.button4); 179 | this.Controls.Add(this.button3); 180 | this.Controls.Add(this.label3); 181 | this.Controls.Add(this.label2); 182 | this.Controls.Add(this.dataGridView1); 183 | this.Controls.Add(this.label1); 184 | this.Controls.Add(this.button2); 185 | this.Controls.Add(this.button1); 186 | this.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 187 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 188 | this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 189 | this.Name = "Form1"; 190 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 191 | this.Text = "SteamHosts v1.5.0"; 192 | this.Load += new System.EventHandler(this.Form1_Load); 193 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); 194 | this.ResumeLayout(false); 195 | this.PerformLayout(); 196 | 197 | } 198 | 199 | #endregion 200 | private System.Windows.Forms.Button button1; 201 | private System.Windows.Forms.Button button2; 202 | private System.Windows.Forms.Label label1; 203 | private System.Windows.Forms.DataGridView dataGridView1; 204 | private System.Windows.Forms.Label label2; 205 | private System.Windows.Forms.Label label3; 206 | private System.Windows.Forms.DataGridViewTextBoxColumn ip; 207 | private System.Windows.Forms.DataGridViewTextBoxColumn time; 208 | private System.Windows.Forms.DataGridViewTextBoxColumn location; 209 | private System.Windows.Forms.Button button3; 210 | private System.Windows.Forms.Button button4; 211 | private System.Windows.Forms.Label label4; 212 | } 213 | } 214 | 215 | --------------------------------------------------------------------------------