MCPcopy Create free account
hub / github.com/pion/ice / TestRemoteIPFilterInAddRemoteCandidate

Function TestRemoteIPFilterInAddRemoteCandidate

agent_test.go:1991–2025  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1989}
1990
1991func TestRemoteIPFilterInAddRemoteCandidate(t *testing.T) {
1992 agent, err := NewAgent(&AgentConfig{
1993 RemoteIPFilter: func(ip net.IP) (keep bool) {
1994 return !ip.Equal(net.IPv4(203, 0, 113, 9))
1995 },
1996 })
1997 require.NoError(t, err)
1998 defer func() {
1999 require.NoError(t, agent.Close())
2000 }()
2001
2002 blocked, err := NewCandidateHost(&CandidateHostConfig{
2003 Network: "udp",
2004 Address: "203.0.113.9",
2005 Port: 40000,
2006 Component: 1,
2007 })
2008 require.NoError(t, err)
2009
2010 allowed, err := NewCandidateHost(&CandidateHostConfig{
2011 Network: "udp",
2012 Address: "198.51.100.10",
2013 Port: 40001,
2014 Component: 1,
2015 })
2016 require.NoError(t, err)
2017
2018 agent.addRemoteCandidate(blocked)
2019 agent.addRemoteCandidate(allowed)
2020
2021 actual, err := agent.GetRemoteCandidates()
2022 require.NoError(t, err)
2023 require.Len(t, actual, 1)
2024 require.Equal(t, allowed.Address(), actual[0].Address())
2025}
2026
2027func TestAddRemoteCandidateHonorsRemoteIPFilter(t *testing.T) {
2028 agent, err := NewAgent(&AgentConfig{

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
addRemoteCandidateMethod · 0.95
GetRemoteCandidatesMethod · 0.95
NewAgentFunction · 0.85
NewCandidateHostFunction · 0.85
EqualMethod · 0.65
AddressMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…