libp2p / libp2p/go-libp2p

Export mdnsService struct or rename the Service interface for mDNS

Open
#3,232 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
6.9k
Forks
1.3k
Avg merge
13d 21h
Merged PRs (30d)
1

Description

I would like to have my own struct, where I can assign mDNS service to [`mdns.NewMdnsService()`](https://github.com/libp2p/go-libp2p/blob/578af0c651a61549cc51a08c70f611c8977ae75e/p2p/discovery/mdns/mdns.go#L53):

```go
type MyStruct struct {
mdnsService *mdns.mdnsService // Error: name mdnsService not exported by package typesinternal#UnexportedName
}

// Meaning, this is currently NOT possible
MyStruct.mdnsService = mdns.NewMdnsService(p2pHost, "something", &mDNSNotifee{host: p2pHost})
if err := MyStruct.mdnsService.Start(); err != nil {
panic(err)
} else {
log.Println("mDNS service started")
}
```

If you would expose the `mdns.mdnsService` struct (just like you already do expose `dht.IpfsDHT`), I could assign it to my own struct.

Meaning it be much easier to later call a `MyStruct.mdnsService.Close()` on it for example. Maybe its just me, but I think it makes sense to export a struct that is getting returned by a public function.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in p2p/discovery/mdns/mdns.go at NewMdnsService and inspect the returned service's lifecycle methods, especially Start and Close. Compare the requested exported struct with the existing public API and determine which naming or exposure approach preserves usable mDNS startup and shutdown behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.