-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (39 loc) · 1.09 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"crypto/tls"
"log"
"net/http"
"time"
"github.com/eyedeekay/apttransport"
"github.com/eyedeekay/onramp"
)
func main() {
transport := &apttransport.AptMethod{}
transport.Main = transport.DefaultMain
garlic, err := onramp.NewGarlic("apt-transport-garlic", "127.0.0.1:7656", nil)
if err == nil {
samHTTPClient := GenerateSAMHTTPClient(garlic)
transport.Client = samHTTPClient
transport.Main()
} else {
log.Fatal(err)
}
}
func GenerateSAMHTTPClient(garlic *onramp.Garlic) apttransport.AptClient {
aptClient := &http.Client{
Timeout: time.Duration(6) * time.Minute,
Transport: &http.Transport{
MaxIdleConns: 0,
MaxIdleConnsPerHost: 2,
DisableKeepAlives: false,
ResponseHeaderTimeout: time.Duration(10) * time.Minute,
ExpectContinueTimeout: time.Duration(10) * time.Minute,
IdleConnTimeout: time.Duration(10) * time.Minute,
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
Dial: garlic.Dial,
},
Jar: nil,
CheckRedirect: nil,
}
return aptClient
}