让git/go get使用代理域名。

huangapple go评论106阅读模式
英文:

Let git / go get use proxy domains

问题

在阅读之前:我不想做恶意的事情,而是建立一个工具链来克服"go get"的缺陷。

我想要建立一个设置,实现以下功能:

  • 我有一组域名,比如github.com,bitbucket.org等。
  • 如果使用git克隆/推送/拉取来自这些域名的远程仓库,这些域名将被解析为我的代理服务器的IP地址。
  • 对于其他任何程序,这些域名将解析为真实的IP地址。
  • 我的代理服务器应该是一个程序,用于托管/缓存仓库,并在缓存中不存在时从真实目标克隆它们。这个程序应该用Go语言编写。

必须像正常情况下一样使用git命令。可以更改git配置。

这个想法是让团队的所有开发计算机都以这种方式配置,以便任何外部仓库实际上都是代理上的克隆。这个克隆可以以集中的方式进行管理(特殊更改、合并将上游等),而不影响导入路径。

我应该如何设置DNS欺骗?
代理服务器必须如何构建才能与git正常工作?

英文:

Before you read: I don't want to do malicious things, but setup a tool chain to overcome the flaws of <code>go get</code>.

I want to have a setup that allows the following:

  • I have a set of domains, like github.com, bitbucket.org, etc.
  • If git clones/pushes/pulls with a remote repository from any of the domains
    the domains are resolved to an IP address of my proxy
  • For any other program the domains resolve to real IP addresses
  • My proxy should be a program that hosts/caches repositories and clones them from the real target if they are not in the cache. This program should be written in Go

The git commands must be used as normal. Git configuration may be changed.

The idea is to have all development computers of a team configured this way, so that any
external repository is in fact a clone on the proxy. That clone could be managed in a centralized way (special changes, merges will upstream etc.) without affecting the import paths.

How would I setup the DNS faking?
How must the proxy be built in order to properly work with git?

答案1

得分: 1

git 1.8.5 开始,你可以直接在 git 的全局设置中为特定的 URL 设置代理:

[http &quot;http://github.com&quot; ]
  proxy = http://my.proxy:8080
[https &quot;https://github.com&quot; ]
  proxy = http://my.proxy:8080

参见“只为特定的 git URL/域名使用代理?

这对于只想为特定的 URL 使用代理很有帮助。

英文:

Starting with git 1.8.5, you can setup directly in git global settings proxy for specific urls:

[http &quot;http://github.com&quot; ]
  proxy = http://my.proxy:8080
[https &quot;https://github.com&quot; ]
  proxy = http://my.proxy:8080

See "Only use a proxy for certain git urls/domains?"

That helps when you want to use a proxy only for certain urls.

huangapple
  • 本文由 发表于 2014年7月26日 19:33:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/24970586.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定