-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows for ICE to handle connections on a single UDP port
- Loading branch information
Showing
12 changed files
with
627 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// +build !js | ||
|
||
package ice | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pion/logging" | ||
"github.com/pion/transport/test" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestMuxAgent is an end to end test over UDP mux, ensuring two agents could connect over mux | ||
func TestMuxAgent(t *testing.T) { | ||
report := test.CheckRoutines(t) | ||
defer report() | ||
loggerFactory := logging.NewDefaultLoggerFactory() | ||
|
||
udpMux := NewUDPMuxDefault(UDPMuxParams{ | ||
Logger: loggerFactory.NewLogger("ice"), | ||
ReadBufferSize: 20, | ||
}) | ||
muxPort := 7686 | ||
require.NoError(t, udpMux.Start(muxPort)) | ||
|
||
muxedA, err := NewAgent(&AgentConfig{ | ||
UDPMux: udpMux, | ||
CandidateTypes: []CandidateType{CandidateTypeHost}, | ||
NetworkTypes: supportedNetworkTypes(), | ||
}) | ||
require.NoError(t, err) | ||
|
||
a, err := NewAgent(&AgentConfig{ | ||
CandidateTypes: []CandidateType{CandidateTypeHost}, | ||
NetworkTypes: supportedNetworkTypes(), | ||
}) | ||
require.NoError(t, err) | ||
|
||
conn, muxedConn := connect(a, muxedA) | ||
|
||
pair := muxedA.getSelectedPair() | ||
require.NotNil(t, pair) | ||
require.Equal(t, muxPort, pair.Local.Port()) | ||
|
||
// send a packet to Mux | ||
data := []byte("hello world") | ||
_, err = conn.Write(data) | ||
require.NoError(t, err) | ||
|
||
buffer := make([]byte, 1024) | ||
n, err := muxedConn.Read(buffer) | ||
require.NoError(t, err) | ||
require.Equal(t, data, buffer[:n]) | ||
|
||
// send a packet from Mux | ||
_, err = muxedConn.Write(data) | ||
require.NoError(t, err) | ||
|
||
n, err = conn.Read(buffer) | ||
require.NoError(t, err) | ||
require.Equal(t, data, buffer[:n]) | ||
|
||
// close it down | ||
require.NoError(t, conn.Close()) | ||
require.NoError(t, muxedConn.Close()) | ||
require.NoError(t, udpMux.Close()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.