File: use-explicit-localhost-ip.patch

package info (click to toggle)
golang-github-go-git-go-git 5.16.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,684 kB
  • sloc: makefile: 81; sh: 76
file content (60 lines) | stat: -rw-r--r-- 2,302 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From: Maytham Alsudany <maytha8thedev@gmail.com>
Description: Use explicit loopback IP instead of localhost
 Tests were failing because they were attempting to connect to a DNS server
 (which requires internet) and looking up "localhost". This patch changes out
 "localhost" for the more explicit "127.0.0.1" loopback IP.

--- a/plumbing/transport/git/common_test.go
+++ b/plumbing/transport/git/common_test.go
@@ -71,7 +71,7 @@
 }
 
 func (s *BaseSuite) newEndpoint(c *C, name string) *transport.Endpoint {
-	ep, err := transport.NewEndpoint(fmt.Sprintf("git://localhost:%d/%s", s.port, name))
+	ep, err := transport.NewEndpoint(fmt.Sprintf("git://127.0.0.1:%d/%s", s.port, name))
 	c.Assert(err, IsNil)
 
 	return ep
@@ -103,7 +103,7 @@
 }
 
 func freePort() (int, error) {
-	addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
+	addr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:0")
 	if err != nil {
 		return 0, err
 	}
--- a/plumbing/transport/ssh/internal/test/proxy_test.go
+++ b/plumbing/transport/ssh/internal/test/proxy_test.go
@@ -36,7 +36,7 @@
 // Its located in a separate package because golang caches the value
 // of proxy env vars leading to misleading/unexpected test results.
 func (s *ProxyEnvSuite) TestCommand(c *C) {
-	socksListener, err := net.Listen("tcp", "localhost:0")
+	socksListener, err := net.Listen("tcp", "127.0.0.1:0")
 	c.Assert(err, IsNil)
 
 	socksServer, err := socks5.New(&socks5.Config{
@@ -46,11 +46,11 @@
 	go func() {
 		socksServer.Serve(socksListener)
 	}()
-	socksProxyAddr := fmt.Sprintf("socks5://localhost:%d", socksListener.Addr().(*net.TCPAddr).Port)
+	socksProxyAddr := fmt.Sprintf("socks5://127.0.0.1:%d", socksListener.Addr().(*net.TCPAddr).Port)
 	os.Setenv("ALL_PROXY", socksProxyAddr)
 	defer os.Unsetenv("ALL_PROXY")
 
-	sshListener, err := net.Listen("tcp", "localhost:0")
+	sshListener, err := net.Listen("tcp", "127.0.0.1:0")
 	c.Assert(err, IsNil)
 	sshServer := &ssh.Server{Handler: HandlerSSH}
 	go func() {
@@ -97,7 +97,7 @@
 
 func (s *ProxyEnvSuite) newEndpoint(c *C, name string) *transport.Endpoint {
 	ep, err := transport.NewEndpoint(fmt.Sprintf(
-		"ssh://git@localhost:%d/%s/%s", s.port, filepath.ToSlash(s.base), name,
+		"ssh://git@127.0.0.1:%d/%s/%s", s.port, filepath.ToSlash(s.base), name,
 	))
 
 	c.Assert(err, IsNil)