Giter Site home page Giter Site logo

smarthosts's Introduction

SmartHosts

SmartHosts是一个托管在谷歌代码上的项目,您可以轻松利用本项目使用到一份稳定的Hosts文件。

这份Hosts文件可以帮助您顺利打开一些网站,提高某些国外服务的打开或下载速度。

这里是Smarthosts的官方Github镜像。

北京服务器:https://raw.github.com/smarthosts/SmartHosts/master/trunk/hosts

美国服务器:https://github.com/smarthosts/SmartHosts/raw/master/trunk/hosts_us

手机版:https://github.com/smarthosts/SmartHosts/blob/master/trunk/mobile_devices/hosts

如果您使用IE浏览器,建议您使用境外版hosts。

注:YouTube的视频无法加载,但视频页可以打开。

SmartHosts不会在Hosts中加入来路不明的IP,所有IP都处于官方服务器所使用的IP段中。 某些网站需要您使用https方式打开,例如:

Facebook: https://www.facebook.com

smarthosts's People

Contributors

smarthosts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smarthosts's Issues

wikipedia

曾经有wikipedia的ip,为什么现在没有了?https,wikipedia访问不了~

github 换了服务器了

前面我碰到问题说 clone 不了,问 github 他们,说是更换了服务器了。
下面是从我这 nslookup 得到的结果
103.245.222.133 documentcloud.github.com
192.30.252.128 github.com
192.30.252.142 gist.github.com
107.20.136.254 help.github.com
192.30.252.145 nodeload.github.com
103.245.222.133 raw.github.com
107.22.3.110 status.github.com
103.245.222.133 training.github.com
192.30.252.130 www.github.com

Ingress

Ingress is not accessible in China. Can you please add the following Ingress host entries?

Ingress

173.194.75.141 betaspike.appspot.com
173.194.75.141 m-dot-betaspike.appspot.com
173.194.76.128 static.panoramio.com
173.194.37.99 panoramio.com
173.194.37.99 www.panoramio.com

Cheers,
Martin

hangouts 无法登录

差不多两周了,今天发现把 clients1-7.google.com 的hosts 去掉后就可以了。

不知这些域名提供什么服务。

Twitter

Twitter is not reachable anymore using the Android Twitter app. Is anyone having the same issue?

wikipedia

用了 smarthosts 之后,wikipedia 访问不了了……

Google Now

Google Now does not work anymore on Android 4.3 with the current hosts file. When I remove all entries, with an empty hosts file, Google Now works fine.

'Works' means I can search using the search bar of Google Now, and, for example, add a reminder.

ReadMe.md乱码

尝试切换为UTF-8?我是在Android上GitHub客户端访问的,其中只有ReadMe.md乱码,QA.wiki都正常

osx_linux.py 改进 每次只需执行该脚本即可

osx_linux.py脚本文件改进,每次只需要执行该脚本即可,无需对原hosts文件手动修改,解决问题如下:
场景需求: 假如我的hosts文件里配置了几个家庭主机的host信息(或者公司的host信息)例:

192.168.1.9  hosts1
192.168.1.6  hosts2
192.168.1.8  hosts3

原来脚本执行之后,需要手动从hosts.bak文件恢复,新脚本将无需改动自动在后面追加云hosts配置信息,当再次更新时会自动查找并删除原云hosts配置信息,家庭或企业hosts信息将保留,无需手动修改

osx_linux.py脚本文件以及patch见最后面.

tag: googlecode地址能访问的几率远远低于github,故将云hosts的URL文件修改为github地址

非常感谢你们的项目,愿尽绵薄之力,谢谢!
另敬请对外提供donate页面

osx_linux.py脚本文件

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#author:rikugun

import sys
import urllib
import os
from shutil import copyfile


HOSTS_URL='https://raw.githubusercontent.com/smarthosts/smarthosts/master/trunk/hosts'
# HOSTS_URL='https://smarthosts.googlecode.com/svn/trunk/hosts'

LOCAL_HOSTS='/etc/hosts'
TAG_START = '###start smarthosts###'
TAG_END = '###end smarthosts###'

def main():
    """主函数"""
    #备份文件
    copyfile(LOCAL_HOSTS,'hosts.bak')

    lines = list()
    start = -1
    end = -1
    with open(LOCAL_HOSTS, 'r') as f:
        for i, line in enumerate(f):
            if line.startswith(TAG_START):
                start = i
            elif line.startswith(TAG_END):
                end = i
                line=''
            if end == -1 and start == -1:
                lines.append(line)
            elif end > -1:
                lines.append(line)

    with open(LOCAL_HOSTS,'w') as f:
        for line in lines:
            f.write(line)
        f.write(TAG_START+os.linesep)
        for line in urllib.urlopen(HOSTS_URL):
            f.write(line.strip()+os.linesep)
        f.write(TAG_END)

    print "success!"

if __name__ == '__main__':
    if len(sys.argv)>1:
        HOSTS_URL = sys.argv[1]
    main()

patch文件内容

diff --git a/trunk/osx_linux.py b/trunk/osx_linux.py
index 35be490..2827978 100644
--- a/trunk/osx_linux.py
+++ b/trunk/osx_linux.py
@@ -8,20 +8,41 @@ import os
 from shutil import copyfile


-HOSTS_URL='https://smarthosts.googlecode.com/svn/trunk/hosts'
+HOSTS_URL='https://raw.githubusercontent.com/smarthosts/smarthosts/master/trunk/hosts'
+# HOSTS_URL='https://smarthosts.googlecode.com/svn/trunk/hosts'

 LOCAL_HOSTS='/etc/hosts'
+TAG_START = '###start smarthosts###'
+TAG_END = '###end smarthosts###'

 def main():
     """主函数"""
     #备份文件
     copyfile(LOCAL_HOSTS,'hosts.bak')
-    with open(LOCAL_HOSTS,'aw') as hosts:
-        hosts.write(os.linesep)
-        #转义windows和unix的换行
-        for line in urllib.urlopen(HOSTS_URL):
-            hosts.write(line.strip()+os.linesep)
+    
+    lines = list()
+    start = -1
+    end = -1
+    with open(LOCAL_HOSTS, 'r') as f:
+        for i, line in enumerate(f):
+            if line.startswith(TAG_START):
+                start = i
+            elif line.startswith(TAG_END):
+                end = i
+                line=''
+            if end == -1 and start == -1:
+                lines.append(line)
+            elif end > -1:
+                lines.append(line)

+    with open(LOCAL_HOSTS,'w') as f:
+        for line in lines:
+            f.write(line)
+        f.write(TAG_START+os.linesep)
+        for line in urllib.urlopen(HOSTS_URL):
+            f.write(line.strip()+os.linesep)
+        f.write(TAG_END)
+            
     print "success!"

 if __name__ == '__main__':

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.