This file is indexed.

/usr/share/gocode/src/code.google.com/p/go.net/ipv6/icmp_test.go is in golang-go.net-dev 0.0~hg20131201-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2013 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package ipv6_test

import (
	"code.google.com/p/go.net/ipv6"
	"net"
	"os"
	"reflect"
	"runtime"
	"sync"
	"testing"
)

func TestICMPFilter(t *testing.T) {
	switch runtime.GOOS {
	case "plan9", "windows":
		t.Skipf("not supported on %q", runtime.GOOS)
	}

	var f ipv6.ICMPFilter
	for _, toggle := range []bool{false, true} {
		f.SetAll(toggle)
		var wg sync.WaitGroup
		for _, typ := range []ipv6.ICMPType{
			ipv6.ICMPTypeDestinationUnreachable,
			ipv6.ICMPTypeEchoReply,
			ipv6.ICMPTypeNeighborSolicitation,
			ipv6.ICMPTypeDuplicateAddressConfirmation,
		} {
			wg.Add(1)
			go func(typ ipv6.ICMPType) {
				defer wg.Done()
				f.Set(typ, false)
				if f.WillBlock(typ) {
					t.Errorf("ipv6.ICMPFilter.Set(%v, false) failed", typ)
				}
				f.Set(typ, true)
				if !f.WillBlock(typ) {
					t.Errorf("ipv6.ICMPFilter.Set(%v, true) failed", typ)
				}
			}(typ)
		}
		wg.Wait()
	}
}

func TestSetICMPFilter(t *testing.T) {
	switch runtime.GOOS {
	case "plan9", "windows":
		t.Skipf("not supported on %q", runtime.GOOS)
	}
	if !supportsIPv6 {
		t.Skip("ipv6 is not supported")
	}
	if os.Getuid() != 0 {
		t.Skip("must be root")
	}

	c, err := net.ListenPacket("ip6:ipv6-icmp", "::1")
	if err != nil {
		t.Fatalf("net.ListenPacket failed: %v", err)
	}
	defer c.Close()

	p := ipv6.NewPacketConn(c)

	var f ipv6.ICMPFilter
	f.SetAll(true)
	f.Set(ipv6.ICMPTypeEchoRequest, false)
	f.Set(ipv6.ICMPTypeEchoReply, false)
	if err := p.SetICMPFilter(&f); err != nil {
		t.Fatalf("ipv6.PacketConn.SetICMPFilter failed: %v", err)
	}
	kf, err := p.ICMPFilter()
	if err != nil {
		t.Fatalf("ipv6.PacketConn.ICMPFilter failed: %v", err)
	}
	if !reflect.DeepEqual(kf, &f) {
		t.Fatalf("got unexpected filter %#v; expected %#v", kf, f)
	}
}