Skip to content

Commit

Permalink
Fix UDPMux logger
Browse files Browse the repository at this point in the history
If no logger is passed in, it will be created.
Error running webrtc/examples/ice-single-port :
invalid memory address or nil pointer dereference
  • Loading branch information
cgojin committed Apr 27, 2021
1 parent c4d5d1c commit 1f4e18f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
* [Will Forcey](https://github.com/wawesomeNOGUI)
* [David Zhao](https://github.com/davidzhao)
* [Juliusz Chroboczek](https://github.com/jech)
* [Jin Gong](https://github.com/cgojin)

### License
MIT License - see [LICENSE](LICENSE) for full text
4 changes: 4 additions & 0 deletions udp_mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ type UDPMuxParams struct {

// NewUDPMuxDefault creates an implementation of UDPMux
func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault {
if params.Logger == nil {
params.Logger = logging.NewDefaultLoggerFactory().NewLogger("ice")
}

m := &UDPMuxDefault{
addressMap: map[string]*udpMuxedConn{},
params: params,
Expand Down
4 changes: 1 addition & 3 deletions udp_mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"testing"
"time"

"github.com/pion/logging"
"github.com/pion/stun"
"github.com/pion/transport/test"
"github.com/stretchr/testify/require"
Expand All @@ -28,9 +27,8 @@ func TestUDPMux(t *testing.T) {
conn, err := net.ListenUDP(udp, &net.UDPAddr{})
require.NoError(t, err)

loggerFactory := logging.NewDefaultLoggerFactory()
udpMux := NewUDPMuxDefault(UDPMuxParams{
Logger: loggerFactory.NewLogger("ice"),
Logger: nil,
UDPConn: conn,
})

Expand Down

0 comments on commit 1f4e18f

Please sign in to comment.