Ghips: Automatically obtain the fastest IP of GitHub, refresh hosts with one click, and talk about the dry goods in the source code

Ghips is an open source software of only 601 KB:

项目:github.com/aardio/Ghips
镜像:gitcode.net/aardio/Ghips

Support Win7, Win8, Win10, Win11 and other operating systems.

The software obtains all IPs through GitHub's official API, and automatically finds the fastest IP.

 

 If the refresh interval is set to non-zero, the fastest IP will be obtained regularly and the domain name resolution will be refreshed automatically.

It may be a little slow to access GitHub for the first time after updating the IP, but it will be faster after a while.

The program needs to be run with administrative privileges to modify hosts.
It is recommended to right-click on the Ghips tray icon and select "Start on Boot" in the pop-up menu.

In this way, it will silently obtain administrative privileges to start after booting, and no warning will pop up again.

The IP with fast access speed changes frequently, and clicking the Ghips tray icon can quickly refresh the IP speed test results.

Ghips was developed using aardio, and the source code was released in aardio as early as 2019 (now separated into Ghips project):

HTTP APIs like GitHub generally do not require special encapsulation in aardio, and can be directly converted into general function objects. The key codes are:

import web.rest.jsonClient;

var http = web.rest.jsonClient();
var github = http.api("https://api.github.com/")	
var metaInfo = github.meta.get();

metaInfo.git is the obtained IP list.

It is troublesome to modify the files in the hosts file to seize power. The key source code is as follows:

fsys.hosts.ownCacls();
fsys.hosts.update(githubIps)

In addition, modifying hosts requires administrative privileges.

If the software is set to silently obtain administrative privileges when booting up - you don't have to click on the warning dialog every time.

The key source code to realize the automatic acquisition of management rights after booting is as follows:

import sys.runAsTask;
var sysTask = sys.runAsTask("Ghips","GitHub 网速优化工具")
sysTask.register("/tray");

The key source code for adding a timer to automatically refresh IP is as follows:

winform.setInterval( 
	function(){
		if(!winform.plusUpdateIps.disabled){
			winform.plusUpdateIps.oncommand(,,true);
		}
	},interval * 5000 
)

Guess you like

Origin blog.csdn.net/zhangdaiscott/article/details/131663293