1 // Copyright 2012 Google Inc. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // The git-remote-persistent-https binary speeds up SSL operations by running
16 // a daemon job that keeps a connection open to a Git server. This ensures the
17 // git-remote-persistent-https--proxy is running and delegating execution
18 // to the git-remote-http binary with the http_proxy set to the daemon job.
19 // A unix socket is used to authenticate the proxy and discover the
20 // HTTP address. Note, both the client and proxy are included in the same
34 forceProxy
= flag
.Bool("proxy", false, "Whether to start the binary in proxy mode")
35 proxyBin
= flag
.String("proxy_bin", "git-remote-persistent-https--proxy", "Path to the proxy binary")
36 printLabel
= flag
.Bool("print_label", false, "Prints the build label for the binary")
38 // Variable that should be defined through the -X linker flag.
39 _BUILD_EMBED_LABEL
string
43 defaultMaxIdleDuration
= 24 * time
.Hour
44 defaultPollUpdateInterval
= 15 * time
.Minute
50 // Short circuit execution to print the build label
51 fmt
.Println(buildLabel())
56 if *forceProxy || strings
.HasSuffix(os
.Args
[0], "--proxy") {
57 log
.SetPrefix("git-remote-persistent-https--proxy: ")
59 BuildLabel
: buildLabel(),
60 MaxIdleDuration
: defaultMaxIdleDuration
,
61 PollUpdateInterval
: defaultPollUpdateInterval
,
65 log
.SetPrefix("git-remote-persistent-https: ")
77 func buildLabel() string {
78 if _BUILD_EMBED_LABEL
== "" {
79 log
.Println(`unlabeled build; build with "make" to label`)
81 return _BUILD_EMBED_LABEL