Overview
These types and functions are deprecated. Use the pion/stun package directly instead.
The Pion ICE library provides type aliases for STUN and TURN URI parsing from the pion/stun/v3 package. These are maintained for backward compatibility.
Type Aliases
URL
Deprecated: Use stun.URI from github.com/pion/stun/v3 instead.
Represents a STUN (RFC 7064) or TURN (RFC 7065) URI.
SchemeType
type SchemeType = stun . SchemeType
Deprecated: Use stun.SchemeType from github.com/pion/stun/v3 instead.
Indicates the server type (STUN, STUNS, TURN, TURNS).
ProtoType
type ProtoType = stun . ProtoType
Deprecated: Use stun.ProtoType from github.com/pion/stun/v3 instead.
Indicates the transport protocol (UDP, TCP).
Constants
Scheme Types
const (
SchemeTypeSTUN = stun . SchemeTypeSTUN // "stun"
SchemeTypeSTUNS = stun . SchemeTypeSTUNS // "stuns" (secure)
SchemeTypeTURN = stun . SchemeTypeTURN // "turn"
SchemeTypeTURNS = stun . SchemeTypeTURNS // "turns" (secure)
)
Protocol Types
const (
ProtoTypeUDP = stun . ProtoTypeUDP // UDP transport
ProtoTypeTCP = stun . ProtoTypeTCP // TCP transport
)
Unknown
Represents an unknown ProtoType or SchemeType.
Functions
ParseURL
var ParseURL = stun . ParseURI
Deprecated: Use stun.ParseURI from github.com/pion/stun/v3 instead.
Parses a STUN or TURN URL following the ABNF syntax described in RFC 7064 and RFC 7065.
Signature:
func ParseURI ( uri string ) ( * URI , error )
NewSchemeType
var NewSchemeType = stun . NewSchemeType
Deprecated: Use stun.NewSchemeType from github.com/pion/stun/v3 instead.
Creates a new SchemeType from a raw string.
Signature:
func NewSchemeType ( scheme string ) SchemeType
NewProtoType
var NewProtoType = stun . NewProtoType
Deprecated: Use stun.NewProtoType from github.com/pion/stun/v3 instead.
Creates a new ProtoType from a raw string.
Signature:
func NewProtoType ( proto string ) ProtoType
Usage Examples
Basic STUN URL
TURN URL with Credentials
Multiple Servers
Secure TURN (TURNS)
import (
" github.com/pion/ice/v4 "
" github.com/pion/stun/v3 "
)
// Parse STUN URL (recommended: use stun.ParseURI directly)
stunURL , err := stun . ParseURI ( "stun:stun.l.google.com:19302" )
if err != nil {
panic ( err )
}
agent , _ := ice . NewAgentWithOptions (
ice . WithUrls ([] * stun . URI { stunURL }),
)
STUN URI
stun:<host>[:<port>]
stuns:<host>[:<port>]
Examples:
stun:stun.example.com
stun:stun.example.com:3478
stuns:stun.example.com:5349
TURN URI
turn:<host>[:<port>][?transport=<udp|tcp>]
turns:<host>[:<port>][?transport=<tcp>]
Examples:
turn:turn.example.com:3478
turn:turn.example.com:3478?transport=udp
turn:turn.example.com:3478?transport=tcp
turns:turn.example.com:5349?transport=tcp
Default Ports
Scheme Default Port stun 3478 stuns 5349 turn 3478 turns 5349
URI Structure
The stun.URI type has the following structure:
type URI struct {
Scheme SchemeType // STUN, STUNS, TURN, TURNS
Host string // Hostname or IP address
Port int // Port number
Proto ProtoType // UDP or TCP
Username string // TURN username (optional)
Password string // TURN password (optional)
}
Migration Guide
Before (Deprecated)
After (Recommended)
import " github.com/pion/ice/v4 "
url , err := ice . ParseURL ( "stun:stun.example.com:3478" )
External References