mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Make mDNS opportunistic
It seems like mDNS was intended to be opportunistic, but right now, if creating an mDNS client fails, the whole ICE connection fails. This allows pion to work in more restricted network namespaces, or on less supported environments like 9front. This fixes webwormhole on 9front.
This commit is contained in:
committed by
Sean DuBois
parent
9a730dc549
commit
61849bec47
@@ -49,6 +49,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
|
||||
* [Nevio Vesic](https://github.com/0x19)
|
||||
* [David Hamilton](https://github.com/dihamilton)
|
||||
* [adwpc](https://github.com/adwpc)
|
||||
* [Ori Bernstein](https://eigenstate.org)
|
||||
|
||||
### License
|
||||
MIT License - see [LICENSE](LICENSE) for full text
|
||||
|
||||
@@ -354,8 +354,10 @@ func NewAgent(config *AgentConfig) (*Agent, error) {
|
||||
|
||||
var mDNSConn *mdns.Conn
|
||||
mDNSConn, mDNSMode, err = createMulticastDNS(mDNSMode, mDNSName, log)
|
||||
// Opportunistic mDNS: If we can't open the connection, that's ok: we
|
||||
// can continue without it.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Warnf("Failed to initialize mDNS %s: %v", mDNSName, err)
|
||||
}
|
||||
closeMDNSConn := func() {
|
||||
if mDNSConn != nil {
|
||||
@@ -808,6 +810,9 @@ func (a *Agent) AddRemoteCandidate(c Candidate) error {
|
||||
}
|
||||
|
||||
func (a *Agent) resolveAndAddMulticastCandidate(c *CandidateHost) {
|
||||
if a.mDNSConn == nil {
|
||||
return
|
||||
}
|
||||
_, src, err := a.mDNSConn.Query(context.TODO(), c.Address())
|
||||
if err != nil {
|
||||
a.log.Warnf("Failed to discover mDNS candidate %s: %v", c.Address(), err)
|
||||
|
||||
Reference in New Issue
Block a user