Пример #1
0
func TestICMPFilter(t *testing.T) {
	switch runtime.GOOS {
	case "nacl", "plan9", "solaris", "windows":
		t.Skipf("not supported on %q", runtime.GOOS)
	}

	var f ipv6.ICMPFilter
	for _, toggle := range []bool{false, true} {
		f.SetAll(toggle)
		for _, typ := range []ipv6.ICMPType{
			ipv6.ICMPTypeDestinationUnreachable,
			ipv6.ICMPTypeEchoReply,
			ipv6.ICMPTypeNeighborSolicitation,
			ipv6.ICMPTypeDuplicateAddressConfirmation,
		} {
			f.Accept(typ)
			if f.WillBlock(typ) {
				t.Errorf("ipv6.ICMPFilter.Set(%v, false) failed", typ)
			}
			f.Block(typ)
			if !f.WillBlock(typ) {
				t.Errorf("ipv6.ICMPFilter.Set(%v, true) failed", typ)
			}
		}
	}
}
Пример #2
0
func TestICMPFilter(t *testing.T) {
	switch runtime.GOOS {
	case "plan9", "solaris", "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()
	}
}