无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
查看: 1898|回复: 38
打印 上一主题 下一主题

[教程] 修改Hosts 解决 Github 访问失败

  [复制链接]
跳转到指定楼层
1#
发表于 2024-1-26 16:07:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
github被墙,据我所知只是DNS污染,IP并没有封杀。所以可以修改hosts文件即可访问github。速度特快!

----------引

(1) 每日更新 github hosts 初衷
我是一个热爱祖国的人,祖国发动引擎需要科技,而科技的发展需要国际交流,github最为最大的开源社区,我经常在上面发现很多优秀的新项目。但是由于某些不能说的原因,github 很多时候压根不能访问。总结前人修改 hosts 的经验之后,写了一个小项目,每日晚间定时查询最新的 hosts 信息:


(2)如何修改hosts
那么如何修改hosts呢?下面将介绍windows和Mac系统的设置方法:

windows:

1、文本编辑器“管理员权限”打开 C:\Windows\System32\drivers\etc\hosts 文件,新增一行,复制上面每日更新的内容并保存即可。

2、命令行执行 ipconfig /flushdns 刷新 dns,或者重启电脑。

mac(苹果PC系统):

1、文本编辑器打开 /etc/hosts 文件,新增一行,同上,复制上面每日更新的hosts内容即可。

2、 命令行执行 sudo killall -HUP mDNSResponder ,或者重启电脑。

(3)常见问题
当然,ip和域名并非一直都绑定不变,一个ip可以绑定多个域名,一个域名也可以设置多个IP。有一些ip在不同地方还是无法访问!所以还是需要检查下资源链接。是否都加载成功:


可以看到 api.github.com 这个没有设置ip,访问就需要3s才加载完成。所以设置就好了。。。

(4)项目开源
jianboy/github-host

开发人员可以访问该项目,fork贡献自己的代码咯。

今天是2022年3月1日,俄罗斯入侵乌克兰的第五天,几十万乌克兰人民流离失所,我国同胞仍无法回国。至此今日建了个小群,让大伙有个家。


(5)备注
host方法并非一定有效,据我所知github采用的是 亚马逊的服务器,而亚马逊和google服务器由于某些总所周知的原因,分布在海外,很多都延时很大,多个数据中心访问延时也不同。

大家可以发邮件私信我,分享其他 gihtub 科学使用方法,作为祖国的花朵,拒绝讨论任何不遵守法律的话题。
备注

185.199.108.154   github.githubassets.com
140.82.114.21     central.github.com
185.199.108.133   desktop.githubusercontent.com
185.199.109.153   assets-cdn.github.com
185.199.108.133   camo.githubusercontent.com
185.199.108.133   github.map.fastly.net
146.75.29.194     github.global.ssl.fastly.net
140.82.114.3      gist.github.com
185.199.108.153   github.io
140.82.114.3      github.com
140.82.112.6      api.github.com
185.199.109.133   raw.githubusercontent.com
185.199.110.133   user-images.githubusercontent.com
185.199.108.133   favicons.githubusercontent.com
185.199.109.133   avatars5.githubusercontent.com
185.199.108.133   avatars4.githubusercontent.com
185.199.108.133   avatars3.githubusercontent.com
185.199.108.133   avatars2.githubusercontent.com
185.199.111.133   avatars1.githubusercontent.com
185.199.109.133   avatars0.githubusercontent.com
185.199.111.133   avatars.githubusercontent.com
140.82.114.10     codeload.github.com
54.231.163.185    github-cloud.s3.amazonaws.com
52.216.58.41      github-com.s3.amazonaws.com
52.217.126.97     github-production-release-asset-2e65be.s3.amazonaws.com
52.216.26.92      github-production-user-asset-6210df.s3.amazonaws.com
52.217.90.148     github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.109.153   githubstatus.com
140.82.114.17     github.community
185.199.108.133   media.githubusercontent.com

评分

参与人数 2无忧币 +10 收起 理由
董大 + 5 赞一个!
tt911 + 5 淡定

查看全部评分

2#
发表于 2024-1-26 16:17:41 | 只看该作者
感谢,改天试试
回复

使用道具 举报

3#
发表于 2024-1-26 16:29:09 | 只看该作者
帮忙看下这个问题怎么解决
.\files\get_aria2.ps1 : 无法将“.\files\get_aria2.ps1”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的
拼写,如果包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ .\files\get_aria2.ps1
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (.\files\get_aria2.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

请按任意键继续. . .

点评

来自 AI (Google Bard)的回答: 问: how to run a .ps1 script within another pwsh script? 如何在另一个 pwsh 脚本中运行 .ps1 脚本? 答: Here are the ways to run a .ps1 script within another P  详情 回复 发表于 2024-1-26 18:16
回复

使用道具 举报

4#
发表于 2024-1-26 16:41:00 | 只看该作者
难怪之前还能上的,现在不行了
回复

使用道具 举报

5#
发表于 2024-1-26 17:39:28 | 只看该作者
修改试一下,感谢分享
回复

使用道具 举报

6#
发表于 2024-1-26 17:44:38 | 只看该作者
学习学习
回复

使用道具 举报

7#
发表于 2024-1-26 17:57:54 | 只看该作者
感谢  补 课。
回复

使用道具 举报

8#
发表于 2024-1-26 18:16:28 | 只看该作者
金辰影视 发表于 2024-1-26 16:29
帮忙看下这个问题怎么解决
.\files\get_aria2.ps1 : 无法将“.\files\get_aria2.ps1”项识别为 cmdlet、函 ...

来自 AI (Google Bard)的回答:

问:
how to run a .ps1 script within another pwsh script?
如何在另一个 pwsh 脚本中运行 .ps1 脚本?

答:
Here are the ways to run a .ps1 script within another PowerShell script:
以下是在另一个 PowerShell 脚本中运行 .ps1 脚本的方法:

1. Using the Call Operator (&):
1. 使用呼叫运算符 (&):

    This is the most common and straightforward method.
    这是最常见、最直接的方法。
    Syntax: & C:\path\to\your\script.ps1
    Example:

PowerShell

& C:\Scripts\myFunctions.ps1

请谨慎使用这些代码。了解详情

2. Using the Invoke-Expression Cmdlet:
2. 使用 Invoke-Expression Cmdlet:

    Offers more flexibility, like evaluating expressions and variables.
    提供更大的灵活性,例如计算表达式和变量。
    Syntax: Invoke-Expression -Command "C:\path\to\your\script.ps1"
    Example:

PowerShell

$scriptPath = "C:\Scripts\myFunctions.ps1"
Invoke-Expression -Command "& $scriptPath"

请谨慎使用这些代码。了解详情

3. Using the Dot-Source Operator (.):
3. 使用点源运算符 (.):

    Executes the script in the current scope, allowing access to its functions and variables.
    在当前作用域中执行脚本,允许访问其函数和变量。
    Syntax: . C:\path\to\your\script.ps1
    Example:

PowerShell

. C:\Scripts\myFunctions.ps1

请谨慎使用这些代码。了解详情

4. Using the Start-Job Cmdlet:
4. 使用启动作业 Cmdlet:

    Runs the script in a separate job, allowing parallel execution.
    在单独的作业中运行脚本,允许并行执行。
    Syntax: Start-Job { C:\path\to\your\script.ps1 }
    Example:

PowerShell

Start-Job { C:\Scripts\myFunctions.ps1 } | Wait-Job | Receive-Job

请谨慎使用这些代码。了解详情

Key Points: 关键点:

    Execution Policy: Ensure the execution policy allows script execution. Use Get-ExecutionPolicy and Set-ExecutionPolicy to check and adjust.
    执行策略:确保执行策略允许脚本执行。使用 Get-ExecutionPolicy 和 Set-ExecutionPolicy 检查和调整。
    File Paths: Provide accurate paths to the scripts. Use absolute or relative paths as needed.
    文件路径:提供脚本的准确路径。根据需要使用绝对或相对路径。
    Scope: Understand the scope implications of each method (dot-sourcing shares variables and functions, while others run in separate scopes).
    范围:了解每种方法的范围含义(点源共享变量和函数,而其他方法在单独的范围中运行)。
    Error Handling: Implement proper error handling to catch any issues during script execution.
    错误处理:实施适当的错误处理以捕获脚本执行期间的任何问题。
    Asynchronous Execution: For non-blocking execution, consider using jobs (Start-Job) or PowerShell workflows.
    异步执行:对于非阻塞执行,请考虑使用作业 (Start-Job) 或 PowerShell 工作流。
回复

使用道具 举报

9#
发表于 2024-1-26 19:05:10 | 只看该作者
还是不喜欢修改系统默认host文件。。
回复

使用道具 举报

10#
发表于 2024-1-26 19:15:31 | 只看该作者
直接在github后加一个fast就行

点评

牛X  详情 回复 发表于 2024-1-26 21:05
回复

使用道具 举报

11#
发表于 2024-1-26 19:40:14 | 只看该作者
谢谢分享
回复

使用道具 举报

12#
发表于 2024-1-26 20:28:20 | 只看该作者
多谢分享!
回复

使用道具 举报

13#
发表于 2024-1-26 20:48:23 | 只看该作者
修改试一下,感谢分享
回复

使用道具 举报

14#
发表于 2024-1-26 21:05:24 | 只看该作者
tenyu 发表于 2024-1-26 19:15
直接在github后加一个fast就行

牛X
回复

使用道具 举报

15#
发表于 2024-1-26 21:42:21 | 只看该作者
感谢分享
回复

使用道具 举报

16#
发表于 2024-1-26 21:53:43 来自手机 | 只看该作者
感谢分享
回复

使用道具 举报

17#
发表于 2024-1-26 22:40:03 | 只看该作者
好好好
回复

使用道具 举报

18#
发表于 2024-1-27 00:16:16 | 只看该作者
感谢,学习了!
回复

使用道具 举报

19#
发表于 2024-1-27 07:30:03 | 只看该作者
经常会变,但不用HOSTS,电信貌似能上(仅仅是能)
回复

使用道具 举报

20#
发表于 2024-1-27 08:03:07 来自手机 | 只看该作者
的的的自我修养
回复

使用道具 举报

21#
发表于 2024-1-27 08:18:32 | 只看该作者
多谢分享,不过这种方法有时也不行
回复

使用道具 举报

22#
发表于 2024-1-27 08:28:32 | 只看该作者
进来学习学习
回复

使用道具 举报

23#
发表于 2024-1-27 08:41:03 | 只看该作者
感谢分享
回复

使用道具 举报

24#
发表于 2024-1-27 09:00:40 | 只看该作者
用上了,可以访问了,谢谢
回复

使用道具 举报

25#
发表于 2024-1-27 09:09:18 | 只看该作者
下载速度还是慢
回复

使用道具 举报

26#
发表于 2024-1-27 09:09:54 | 只看该作者
大神666,感谢分享
回复

使用道具 举报

27#
发表于 2024-1-27 09:16:10 | 只看该作者
访问GitHub的方法千千万、很多种
回复

使用道具 举报

28#
发表于 2024-1-27 09:17:53 | 只看该作者
感谢,改天试试

点评

今天已经不行了。。。  发表于 2024-1-27 09:30
回复

使用道具 举报

29#
发表于 2024-1-27 09:41:03 | 只看该作者
试了试 效果不错 谢谢
回复

使用道具 举报

30#
发表于 2024-1-27 10:40:21 | 只看该作者
来学习下 感谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-5-7 17:50

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表