1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
11 check "gopkg.in/check.v1"
14 func Test(t *testing.T) {
18 type supervisorSuite struct{}
20 var _ = check.Suite(&supervisorSuite{})
22 func (s *supervisorSuite) TestAddrIsLocal(c *check.C) {
23 is, err := addrIsLocal("0.0.0.0:0")
24 c.Check(err, check.IsNil)
25 c.Check(is, check.Equals, true)
27 is, err = addrIsLocal("127.0.0.1:9")
28 c.Check(err, check.IsNil)
29 c.Check(is, check.Equals, true)
31 is, err = addrIsLocal("127.0.0.127:32767")
32 c.Check(err, check.IsNil)
33 c.Check(is, check.Equals, true)
35 is, err = addrIsLocal("[::1]:32767")
36 c.Check(err, check.IsNil)
37 c.Check(is, check.Equals, true)
39 is, err = addrIsLocal("8.8.8.8:32767")
40 c.Check(err, check.IsNil)
41 c.Check(is, check.Equals, false)
43 is, err = addrIsLocal("example.com:32767")
44 c.Check(err, check.IsNil)
45 c.Check(is, check.Equals, false)
47 is, err = addrIsLocal("1.2.3.4.5:32767")
48 c.Check(err, check.NotNil)
50 ln, err := net.Listen("tcp", ":")
51 c.Assert(err, check.IsNil)
53 is, err = addrIsLocal(ln.Addr().String())
54 c.Check(err, check.IsNil)
55 c.Check(is, check.Equals, true)