(t *testing.T)
| 1989 | } |
| 1990 | |
| 1991 | func 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 | |
| 2027 | func TestAddRemoteCandidateHonorsRemoteIPFilter(t *testing.T) { |
| 2028 | agent, err := NewAgent(&AgentConfig{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…