GithubHelp home page GithubHelp logo

riant / host-switch-plus Goto Github PK

View Code? Open in Web Editor NEW
288.0 13.0 74.0 514 KB

Change the hosts rules in Chrome. It's easy, and effect immediately.

Home Page: http://riant.me/20150417/chrome-host-switch-plus/

JavaScript 83.78% CSS 4.90% HTML 11.32%
chrome switch-hosts

host-switch-plus's Introduction

由于一些特殊原因,该项目已经不再维护,请转往 Riant/chrome-simply-proxy, Chrome 插件安装

Host Switch Plus - Chrome Extension

最新版:1.3.11

通过该 Chrome 扩展,快捷方便的切换、设置 host 代理规则,而不用修改系统 hosts 文件,方便web开发人员在 各种/测试/开发/线上 环境快速切换

通过 Chrome Store 安装

无法通过 Chrome Store 安装或者更新的朋友,可以尝试使用 百度浏览器或者360之类的支持 Chrome 扩展的浏览器: 360 浏览器/百度浏览器等其他支持 Chrome 扩展的浏览器,下载 crx 文件,转至浏览器扩展程序管理界面,将下载的 crx 文件拖拽至该页面中释放,即可根据提示安装使用。

批量添加规则(IP:端口、域名、tag、备注分别用空格隔开;多个 tag 用英文逗号隔开):

#IP:端口 域名 tag 备注
127.0.0.1:8888 www.xyz.com prod Fiddler
127.0.0.1 *.xyz.com
192.168.1.2 www.xyz.com

注:

  1. https: 由于没有 https 目标服务器,https 的支持测试不完整(通过 Fiddler 和 Shadowsocks 2.5.2 测试),如果有需要,请确保您的目标服务器有相应的 https 请求支持。

Install from Chrome Store

Change the hosts rules in Chrome. It's easy, and effect immediately.

I just want to make the web developers work happy when they often need to switch hosts between develop/test/production environment.

One more feature is that you can set a local proxy for some kind of domain, For example, if you use Fiddler AutoResponder, you may set the domain IP as 127.0.0.1:8888.

By the way:

  1. if you use windows system and just want to easy to manage you system hosts config, I recommend a windows tool called SwitchHosts!

  2. If you use Fiddler, it had a hosts tool under menu Tools > HOSTS, but I think it's difficult to manage the host rules.

Sorry for my Poor English, learn more from the screenshots please.

Any questions/issues let me know: https://github.com/Riant/host-switch-plus/issues

Based on Chrome Host Switch

#起缘 在程序开发过程中,难免开发、测试、生产环境各种切换,一般我们直接修改系统的 hosts 文件。

这么做的几个问题:

  1. 编辑、管理麻烦,推荐 SwitchHosts!

  2. 生效延迟。用 Fiddler 的同学可以试试它 Tools 下的 HOSTS 工具;但是这个工具又让我们回到了第一个问题上。

好了,能否有一个工具管理方便,又快捷简单呢?我找到一个 Chrome 扩展 Chrome Host Switch;问题似乎解决了。

可是为了用 Fiddler,我还装了插件 Proxy SwitchySharp

而 Chrome 的代理插件只能同时有一个生效,那么有没有什么办法整合一下呢?

感谢 Chrome Host Switch 是在 Github 开源分享,遗憾给他的 Issues 一直没有回应,估计作者也是很久没有跟进了;于是自己动手吧。

大概看了下代理实现部分,尝试修改了一下,同时完善了原作者没有完成的编辑、批量添加等功能,同时新增了一个域名对应多个IP 时,只能有一个生效的检测,并清理了文件很大但用处不多的 Bootstrap 及其 Js 插件。

截图预览:

Popup Screenshot

Add New Screenshot

Bulk Add Screenshot

Hosts Manage Screenshot

由于最近忙,没有详细测试完善,任何疑问,建议,欢迎提交 Issues.

基于 Chrome Host Switch 修改完善、分享。感谢原作者开源共享。

##注:

  1. 该版本暂时没有支持原版 Host Switch 的别名功能 192.168.1.110 web1 #web1 www.wwbaidu.com

host-switch-plus's People

Contributors

riant 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

host-switch-plus's Issues

一些疑问与建议

疑问:

  1. note 是用来干嘛的?备注?

建议:

  1. 删除内置的 prod dev test 这三个 tag
    理由:用户会自己去建自己的 tag 名的...像我不需要生产环境和测试环境的 hosts,但是 prod 和 test 这两个 tag 又删不掉,各种蛋疼
  2. 优化下 tag 的写法
    理由:我开发环境的 hosts 有几十个,然后开发环境还分数个,而且还经常变动,批量切换功能需要根据 tag 来,而 tag 编辑起来又贼不方便 需要每行都去改,建议采用 Google Chrome App "HostAdmin App" 的写法,简化编译 tag 的费力程度。
    附: HostAdmin Grouping 的写法约定地址 https://github.com/tg123/chrome-hostadmin/blob/master/README.markdown(在这个地址里搜 Grouping 就看到了)

附:感谢作者的辛勤开发~~~工具的确好用~~~

这是什么问题?

1111

如图,配置了10.125.42.41 averyhuang.oa.com 如果这个host配置配到hosts文件是没问题的,走host switch plus就会报这个错误。10.125.42.41:80是一个apache,只转发请求,会转发到10.125.42.41:8888上 也是一台apache

与SwitchyOmega冲突

你们的不冲突么?每次我启动Host Switch Plus 后 SwitchyOmega就不能用了,什么情况?要怎么配置才行么?

添加批量数据,会造成内存耗尽

严重问题:一次添加几千行hosts记录,在task manager看到内存逐渐升高,最后耗尽了机器的内存(chromebook)。
暂时不知道该是否能工作正常,毕竟无法添加需要的所有项。

瑕疵:另外 有注释#和空行会被停止解析,需要用shell重新整理才能batch导入。

不支持https

配置好的host switch plus,在http模式下工作正常,换成https就不起作用了。
console里还是会输出目标IP,但那是DNS服务器解析出来的。

两个问题,麻烦看下

1、已经有人提到的,如果当前域名,我在插件上设置了指向的ip,把ip显示出来
2、之前用的switchySharp,优先级貌似地域本插件;但是升级使用switchyOmega后,优先级变了。建议把优先级拿回来,毕竟修改host,是人主观所为,更需要被支持。

插件非常棒,感谢作者!

无法一键取消tag下的重复的 域名

例如,我在dev下配置了3个域名,其中有两个域名相同,点击 dev 的时候,没有任何变化。
1.1.1.1 a.abc.com
2.2.2.2 a.abc.com
3.3.3.3 b.abc.com

如果激活了 3.3.3.3 b.abc.com, 再次点击 dev 的时候,没有任何变化,无法关闭 3.3.3.3 b.abc.com,只能点击 3.3.3.3 b.abc.com 。

【请教】请问修改host是怎么实现的?

打算写一个chrome插件,需要用到切换域名所对应的远程ip地址。

找到作者的这个插件,看了下源码,没太明白作者怎么实现强制设置远程ip的。

background.js里的代码我打断点后根本不会触发。。

var enableHosts = [];

chrome.webRequest.onCompleted.addListener(function (details) {
    //data[details.tabId] = details.ip;
    setTimeout(function(){
        details.req = 'showip';
        details.hosts = enableHosts;
        chrome.tabs.sendRequest(details.tabId, details, function (response) {
            // console.log('res:', response);
        });
    },1000);
}, {
    urls: [ 'http://*/*', 'https://*/*' ],
    types: [ 'main_frame' ]
});

chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
    enableHosts = request;
});

求教>.<

可以增加导出备份和排序的功能吗?

如果能云备份就更好了,另外hosts文件还是有他的用处的,如果本插件可以把hosts文件导进去,但是并不在控制面板里面直接显示就完美了,即常用切换在切换面板显示,不常用的就在另外一个面板显示。还有,如果能和ping.chinaz.com结合起来,自动选取最优ip的话就可以当作收费插件出售了。

大小写敏感

如果配置host表时使用的是小写,地址栏里域名部分字母大写了,host switch plus会先把域名转换成小写,然后还是拦截失败,会使用DNS解析的真实IP

但console里输出的hostname是正确的

我配置的是*.xxx.com。没有试过不使用通配符是不是也存在这个问题

望能支持 端口号后项目名的映射

实际开发中往往是 (ip+端口号+项目名)对应 一个域名,希望本插件能支持添加项目名的映射,从而不需要nginx代理配置(前端人员一般不用这个,虽然用fiddler等工具也能解决,但麻烦)

Does not appear to work with HTTPS/SSL traffic

The plugin does not appear to work with HTTPS/SSL traffic. I have a sever with SSL configured, but if I switch from HTTP to HTTPS it is unable to perform a DNS lookup for a host record. Any suggests or fixes?

I cannot get this extension to work

I've never been able to get this to work. I've tried disabling all other extensions. I've tried both 'System' and 'Direct'. I've restarted Chrome.

I'm on Chrome Version 54.0.2840.59 (64-bit) on MAC OS X El Capitan 10.11.6

这个扩展改掉了请求的头信息?

使用插件获取到的REQUEST_URI是包含了域名部分的,导致一些项目不能正常运行,比如设置www.example.com到本地后,得到的REQUEST_URIhttp://www.example.com,改本地host的是/,为何要这样做?这样不就跟改本地host文件不同了吗

关于charles

用了这个插件后,charles抓不到包,应该怎么设置可以解决?

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.