Giter Site home page Giter Site logo

Support ipv6 for mDNS Server about ice HOT 2 OPEN

TA2k avatar TA2k commented on May 26, 2024
Support ipv6 for mDNS Server

from ice.

Comments (2)

edaniels avatar edaniels commented on May 26, 2024

mdns/v2 now supports IPv6 so it can get into ICE now! Shouldn't be too difficult but we'll need to explicitly configure it

from ice.

edaniels avatar edaniels commented on May 26, 2024

@TA2k do you want to take a shot at this?

It may be as simple as in mdns.go:

func createMulticastDNS(n transport.Net, networkTypes []NetworkType, mDNSMode MulticastDNSMode, mDNSName string, log logging.LeveledLogger) (*mdns.Conn, MulticastDNSMode, error) {
	if mDNSMode == MulticastDNSModeDisabled {
		return nil, mDNSMode, nil
	}

	var wantV4, wantV6 bool
	if len(networkTypes) == 0 {
		wantV4 = true
		wantV6 = true
	}
	for _, nt := range networkTypes {
		switch nt {
		case NetworkTypeTCP4, NetworkTypeUDP4:
			wantV4 = true
		case NetworkTypeTCP6, NetworkTypeUDP6:
			wantV6 = true
		}
	}
	if !(wantV4 || wantV6) {
		return nil, mDNSMode, errMulticastDNSNoUsableNetworkType
	}

	var multicastPktConnV4 *ipv4.PacketConn
	if wantV4 {
		addr4, mdnsErr := n.ResolveUDPAddr("udp4", mdns.DefaultAddressIPv4)
		if mdnsErr != nil {
			return nil, mDNSMode, mdnsErr
		}

		l4, mdnsErr := n.ListenUDP("udp4", addr4)
		if mdnsErr != nil {
			// If ICE fails to start MulticastDNS server just warn the user and continue
			log.Errorf("Failed to enable mDNS, continuing in mDNS disabled mode: (%s)", mdnsErr)
			return nil, MulticastDNSModeDisabled, nil
		}

		multicastPktConnV4 = ipv4.NewPacketConn(l4)
	}

	var multicastPktConnV6 *ipv6.PacketConn
	if wantV6 {
		addr6, mdnsErr := n.ResolveUDPAddr("udp6", mdns.DefaultAddressIPv6)
		if mdnsErr != nil {
			return nil, mDNSMode, mdnsErr
		}

		l6, mdnsErr := n.ListenUDP("udp6", addr6)
		if mdnsErr != nil {
			// If ICE fails to start MulticastDNS server just warn the user and continue
			log.Errorf("Failed to enable mDNS, continuing in mDNS disabled mode: (%s)", mdnsErr)
			return nil, MulticastDNSModeDisabled, nil
		}

		multicastPktConnV6 = ipv6.NewPacketConn(l6)
	}

	switch mDNSMode {
	case MulticastDNSModeQueryOnly:
		conn, err := mdns.Server(multicastPktConnV4, multicastPktConnV6, &mdns.Config{})
		return conn, mDNSMode, err
	case MulticastDNSModeQueryAndGather:
		conn, err := mdns.Server(multicastPktConnV4, multicastPktConnV6, &mdns.Config{
			LocalNames: []string{mDNSName},
		})
		return conn, mDNSMode, err
	default:
		return nil, mDNSMode, nil
	}
}

but it needs some testing around interfaces that have supported ipv6 addresses https://tools.ietf.org/html/rfc8445#section-5.1.1.1 (link-local ones which are common are not allowed for security reasons of exposing the zone (I think))

from ice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.