4

让Github畅通无阻,FastGithub1.0.0发布

 3 years ago
source link: https://www.cnblogs.com/kewei/p/14913063.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

前言#

我近半年来被github的抽风虐得没脾气了,虽然我有代理的方式来上网,但代理速度并不理想,而且有时代理服务一起跟着抽风。这时候,我会搜索“github访问不了”相关题材,其中有“Github镜像服务器加速版”的,但这种是readonly的,不适合要提交代码到github的人群;也有“ipaddress.com”查找ip然后写到host文件的,但查到的ip,并不是适合很有网络环境,或者这个ip一下子也抽风了。

FastGithub#

如果拿到github的大量ip数据,我们可以写程序来检测哪些ip可用,哪些ip访问速度最佳,然后编写一个本地版的dns服务,当要解析github相关时,返回这个最佳ip,这就解决了github抽风的问题。
于是我根据这个原理,又闭关几天不吃不喝,将老夫多年练就的网络通讯技术功力融入其中,100+的commits之后,终于写出FastGithub这个软件,好东西自然要分享,好代码也自然也开源。

功能介绍#

超大量的IP资源#

FastGithub从github、各家公共dns服务器、ipaddress.com查找github相关的2w+个ip,这个查找工作,每间隔2小时之后重新进行一次。

快速的ip检测#

FastGithub使用并行IO异步,快速检测ip的443端口是否开放,在速度与系统资源占用寻求一个平衡点,垃圾配置的电脑,cpu占用也不超过1%,但每秒可检测的ip至少为cpu核心数*2

微小的带宽占用#

FastGithub的https扫描功能,会保持与复用http连接5分钟,同时使用HEAD请求扫描,带宽占用几乎不影响到系统。

智能的DNS设置#

FastGithub能在多网络接口的电脑上选择用于上外网的一个网络接口,修改其dns地址为FastGithub提供的127.0.0.1,关闭FastGithub之后,dns地址恢复为原值。

多平台支持#

FastGithub基于.net6编写,支持win-x86、win-x64、linux-x64和osx-x64,同时在windows上,还支持以windows服务运行,自带将自身安装为windows服务安装和卸载的启动命令。

支持加速其它域名#

默认配置是为github专门配置的,但可以修改配置,用于支持非github的其它域名的抽风病,实际上github也不仅仅使用github.com这个域名。

配置介绍#

{
  "Dns": {
    "UpStream": "114.114.114.114", // 上游dns
    "GithubTTL": "00:10:00", // github相关域名解析结果的存活时长
    "SetToLocalMachine": true // 是否设置本机使用此dns(仅支持windows)
  },
  "Github": {
    "Lookup": { // ip查找
      "Domains": [ // 查找的域名,下面是github最主要的域名
        "github.com",
        "api.github.com",
        "collector.githubapp.com",
        "github.githubassets.com",
        "raw.githubusercontent.com",
        "avatars.githubusercontent.com",
        "favicons.githubusercontent.com"
      ],
      "IPAddressComProvider": {
        "Enable": true // 是从启用从address.com查找ip
      },
      "GithubMetaProvider": {
        "Enable": true, // 是否从github获取ip列表
        "MetaUri": "https://gitee.com/jiulang/fast-github/raw/master/FastGithub/meta.json"
      },
      "PublicDnsProvider": {
        "Enable": true, // 是否需要从dns服务器查找ip
        "Dnss": [ // dns服务器列表
          "1.2.4.8",
          "8.8.8.8",
          "223.5.5.5",
          "123.125.81.6",
          "180.76.76.76",
          "119.29.29.29",
          "208.67.220.220",
          "114.114.114.114"
        ]
      }
    },
    "Scan": {
      "FullScanInterval": "02:00:00", // 完整扫描时间间隔
      "ResultScanInterval": "00:01:00", // 结果扫描时间间隔
      "TcpScan": {
        "Timeout": "00:00:01", // tcp扫描超时时间
        "CacheExpiration": "00:30:00" // 扫描结果缓存时长
      },
      "HttpsScan": {
        "Timeout": "00:00:05", // https扫描超时时间
        "ConnectionClose": false, // 是否使用https短连接
        "Rules": { // 域名扫描规则,缺失的域名,将默认HEAD请求到域名的根路径
          "github.com": {
            "Method": "HEAD",
            "Path": "/xljiulang/FastGithub"
          },
          "github.githubassets.com": {
            "Method": "HEAD",
            "Path": "/favicons/favicon.png"
          },
          "raw.githubusercontent.com": {
            "Method": "HEAD",
            "Path": "/xljiulang/FastGithub/master/README.md"
          },
          "avatars.githubusercontent.com": {
            "Method": "HEAD",
            "Path": "/u/8308014?s=40&v=4"
          },
          "favicons.githubusercontent.com": {
            "Method": "HEAD",
            "Path": "/github.com"
          }
        }
      }
    }
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "System": "Warning",
      "Microsoft": "Warning"
    }
  }
}

使用方法#

本机使用#

  • 运行FastGithub程序,本机的网络适配器的dns会自动变成127.0.0.1
  • 如果网络适配器的dns没有变成127.0.0.1,请手工修改网络适配器的dns

局域网服务器使用(推荐)#

  • 在局域网服务器运行FastGithub程序
  • 手工修改你电脑的网络适配器的dns,值为局域网服务器的ip

以windows服务运行#

以管理员身份运行cmd,键入如下命令,其中D:\Softs为软件实际目录

  • D:\Softs\FastGithub.exe start // 安装并启动服务
  • D:\Softs\FastGithub.exe stop // 卸载并删除服务

源代码与软件发布#

github上的FastGithub

gitee上的FastGithub


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK