Skip to content

Conversation

@xinze-zheng
Copy link
Member

Description

Logic for nat behavior discovery (RFC5780). Adapted and modified from pion/stun.

Reference issue

#22

@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

❌ Patch coverage is 84.15301% with 29 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@f81a03a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/ice/network_discover.go 84.15% 17 Missing and 12 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #26   +/-   ##
=======================================
  Coverage        ?   84.60%           
=======================================
  Files           ?       12           
  Lines           ?     1065           
  Branches        ?        0           
=======================================
  Hits            ?      901           
  Misses          ?      131           
  Partials        ?       33           
Flag Coverage Δ
go 84.60% <84.15%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xinze-zheng xinze-zheng requested a review from JoTurk November 16, 2025 22:37
@JoTurk
Copy link
Member

JoTurk commented Dec 3, 2025

@xinze-zheng This is waiting for your ice PR right? I think we'll be able to finally migrate ice to options tomorrow.

Comment on lines +330 to +373
func parse(msg *stun.Message, log *slog.Logger) (ret struct {
xorAddr *stun.XORMappedAddress
otherAddr *stun.OtherAddress
respOrigin *stun.ResponseOrigin
mappedAddr *stun.MappedAddress
software *stun.Software
},
) {
ret.mappedAddr = &stun.MappedAddress{}
ret.xorAddr = &stun.XORMappedAddress{}
ret.respOrigin = &stun.ResponseOrigin{}
ret.otherAddr = &stun.OtherAddress{}
ret.software = &stun.Software{}
if ret.xorAddr.GetFrom(msg) != nil {
ret.xorAddr = nil
}
if ret.otherAddr.GetFrom(msg) != nil {
ret.otherAddr = nil
}
if ret.respOrigin.GetFrom(msg) != nil {
ret.respOrigin = nil
}
if ret.mappedAddr.GetFrom(msg) != nil {
ret.mappedAddr = nil
}
if ret.software.GetFrom(msg) != nil {
ret.software = nil
}
for _, attr := range msg.Attributes {
switch attr.Type {
case
stun.AttrXORMappedAddress,
stun.AttrOtherAddress,
stun.AttrResponseOrigin,
stun.AttrMappedAddress,
stun.AttrSoftware:
break //nolint:staticcheck
default:
log.Debug(fmt.Sprintf("\t%v (l=%v)", attr, attr.Length))
}
}

return ret
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should just use pion/stun here, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants