Thanks to visit codestin.com
Credit goes to github.com

Skip to content

turn.Client to allow net.Conn #87

@enobufs

Description

@enobufs

Summary

As preparation for tackling TCP support TURN protocol (#1), TURN client implementation needs to be able to take net.Conn in addition to net.PacketConn.

Motivation

See #1.

Proposal

Current TURN Client design assumes that an instance of Client is created per socket (net.PacketConn). See Pion: TURN Client Refactor.
ClientConfig takes a parameter, net.PacketConn only, which needs to be changed.

Proposed change is to introduce an interface, turn.Conn which wraps both net.PacketConn and net.Conn.

// Conn a network connection interface with TURN server.
type Conn interface {
	LocalAddr() net.Addr // used to determine transport type and IP version
}

Justification: to prevent a user from trying to pass both net.PacketConn and net.Conn. (Client can only handle one underlying socket).

Above code won't work due to "duplicate method". We need to manually define methods.

Inside NetClient(), use type-switch to determine which transport protocol the app wants to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions