<commit_before>package rendezvous

import (
	"fmt"
	"net"
	"os"
	"strconv"

	"github.com/armon/mdns"
)

const PROTOCOL = "tcp"

type MdnsService struct {
	id            string
	fullId        string
	discoveryAddr string
	server        *mdns.Server
	entriesCh     chan *mdns.ServiceEntry
	announced     bool
	discovering   bool
}

// Create a new mDNS rendezvous service
func NewMdnsService(discoveryAddr string, id string) (*MdnsService, error) {
	m := MdnsService{
		id:          		id,
		fullId:      		fmt.Sprintf("_%s._%s", id, PROTOCOL),
		discoveryAddr:  	discoveryAddr,
		entriesCh:   		make(chan *mdns.ServiceEntry, 4),
		announced:   		false,
		discovering: 		false,
	}
	return &m, nil
}

// Announce the service in the network
func (srv *MdnsService) AnnounceAndDiscover(external string, discoveries chan string) error {
	// Setup our service export
	host, _ := os.Hostname()
	_, portStr, _ := net.SplitHostPort(external)
	port, _ := strconv.Atoi(portStr)

	log.Info("Announcing with mDNS service %s at %s:%d", srv.fullId, host, port)
	service := &mdns.MDNSService{
		Instance: host,
		Service:  srv.fullId,
		Port:     port,
		Info:     "DiVS service",
	}
	service.Init()

	// Create the mDNS server, defer shutdown
	var err error
	srv.server, err = mdns.NewServer(&mdns.Config{Zone: service})
	if err != nil {
		return err
	} else {<commit_msg>Removed some filed that must have been removed from the mDNS lib<commit_after>package rendezvous

import (
	"fmt"
	"net"
	"os"
	"strconv"

	"github.com/armon/mdns"
)

const PROTOCOL = "tcp"

type MdnsService struct {
	id            string
	fullId        string
	discoveryAddr string
	server        *mdns.Server
	entriesCh     chan *mdns.ServiceEntry
	announced     bool
	discovering   bool
}

// Create a new mDNS rendezvous service
func NewMdnsService(discoveryAddr string, id string) (*MdnsService, error) {
	m := MdnsService{
		id:          		id,
		fullId:      		fmt.Sprintf("_%s._%s", id, PROTOCOL),
		discoveryAddr:  	discoveryAddr,
		entriesCh:   		make(chan *mdns.ServiceEntry, 4),
		announced:   		false,
		discovering: 		false,
	}
	return &m, nil
}

// Announce the service in the network
func (srv *MdnsService) AnnounceAndDiscover(external string, discoveries chan string) error {
	// Setup our service export
	host, _ := os.Hostname()
	_, portStr, _ := net.SplitHostPort(external)
	port, _ := strconv.Atoi(portStr)

	log.Info("Announcing with mDNS service %s at %s:%d", srv.fullId, host, port)
	service := &mdns.MDNSService{
		Instance: host,
		Service:  srv.fullId,
		Port:     port,
		//Info:     "DiVS service",
	}
	service.Init()

	// Create the mDNS server, defer shutdown
	var err error
	srv.server, err = mdns.NewServer(&mdns.Config{Zone: service})
	if err != nil {
		return err
	} else {
{'fraction_non_alphanumeric': 0.11147303655446977, 'fraction_numerical': 0.0007238508867173362, 'mean_word_length': 3.2919254658385095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6578345', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1005, 'n_words': 269}