2

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

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?

metakeule
  • 3,724
  • 2
  • 23
  • 29
  • Why not just write `mygo get` using `get.go` and `vcs.go` from [there](http://golang.org/src/cmd/go/)? For some unknown reason people tend to perceive the `go get` tool as something instilled upon them to use, but this is wrong: if this tool does not work for you write another one that works. – kostix Jul 26 '14 at 12:59
  • Another suggestion: there's no need to mess with DNS. Import paths have no semantic meaning beyond designating distinct packages. So you might use any sort of database that would map import paths to source code repositories. – kostix Jul 26 '14 at 13:00
  • @kostix I know that I could write another go get alternative and also what import paths are. However that was not the question here. I just wanted to go the mentioned route. – metakeule Jul 26 '14 at 13:15
  • You don't need to mess with DNS - you can just set up a git proxy that will do your stuff. or you can just define your proxy in the /etc/hosts or something simple like that. Having said that, what you suggest is very over the top in terms of work needed, compared to just wrapping go get in your own command, or using something like godep. – Not_a_Golfer Jul 26 '14 at 13:15
  • re git proxying - here's an example of configuring a proxy. http://stackoverflow.com/questions/783811/getting-git-to-work-with-a-proxy-server – Not_a_Golfer Jul 26 '14 at 13:16
  • @Not_a_Golfer git proxying looks reasonable, will check. – metakeule Jul 26 '14 at 13:21

1 Answers1

1

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

[http "http://github.com" ]
  proxy = http://my.proxy:8080
[https "https://github.com" ]
  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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250