Skip to content

Commit

Permalink
Escape spaces in IPv6 ZoneID with %20
Browse files Browse the repository at this point in the history
Link-local IPv6 addresses may have ZoneID attached at the end. ZoneId
is name of corresponding network interface. On Windows usually it is
"Local connection". Space in ZoneID causes problem when ICE candidate
is parsed so it has to be escaped. It looks that there is no escaping
defined specifically for SDP; the closest one is RFC 6874 for URI.
This fix partially uses this approach and replaces spaces with %20.
  • Loading branch information
[email protected] authored and [email protected] committed Jun 30, 2024
1 parent 2a9fdb5 commit fefbc7f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions candidate_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ func NewCandidateHost(config *CandidateHostConfig) (*CandidateHost, error) {
network: config.Network,
}

if !strings.HasSuffix(config.Address, ".local") {
ipAddr, err := netip.ParseAddr(config.Address)
if !strings.HasSuffix(c.candidateBase.address, ".local") {
if addr, zoneId, found := strings.Cut(c.candidateBase.address, "%"); found {

Check warning on line 56 in candidate_host.go

View workflow job for this annotation

GitHub Actions / lint / Go

var-naming: var zoneId should be zoneID (revive)
c.candidateBase.address = addr+"%"+strings.ReplaceAll(zoneId, " ", "%20")

Check failure on line 57 in candidate_host.go

View workflow job for this annotation

GitHub Actions / lint / Go

File is not `gci`-ed with --skip-generated -s standard -s default (gci)

Check warning on line 57 in candidate_host.go

View check run for this annotation

Codecov / codecov/patch

candidate_host.go#L57

Added line #L57 was not covered by tests
}

ipAddr, err := netip.ParseAddr(c.candidateBase.address)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit fefbc7f

Please sign in to comment.