aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authordevonh <devon.dmytro@gmail.com>2022-10-26 16:25:57 +0000
committerGitHub <noreply@github.com>2022-10-26 17:25:57 +0100
commita74aea07144615f20a71f1c2f62f4ba0946d7b54 (patch)
tree9540566f2bae3163a361989ab3d9c068538127be /build
parent5298dd1133948606172944b7e5ec3805ccc72644 (diff)
Add network interface callback to pinecone build (#2825)
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'build')
-rw-r--r--build/gobind-pinecone/monolith.go52
1 files changed, 40 insertions, 12 deletions
diff --git a/build/gobind-pinecone/monolith.go b/build/gobind-pinecone/monolith.go
index 4a96e4be..adb4e40a 100644
--- a/build/gobind-pinecone/monolith.go
+++ b/build/gobind-pinecone/monolith.go
@@ -101,18 +101,46 @@ func (m *DendriteMonolith) SessionCount() int {
return len(m.PineconeQUIC.Protocol("matrix").Sessions())
}
-func (m *DendriteMonolith) RegisterNetworkInterface(name string, index int, mtu int, up bool, broadcast bool, loopback bool, pointToPoint bool, multicast bool, addrs string) {
- m.PineconeMulticast.RegisterInterface(pineconeMulticast.InterfaceInfo{
- Name: name,
- Index: index,
- Mtu: mtu,
- Up: up,
- Broadcast: broadcast,
- Loopback: loopback,
- PointToPoint: pointToPoint,
- Multicast: multicast,
- Addrs: addrs,
- })
+type InterfaceInfo struct {
+ Name string
+ Index int
+ Mtu int
+ Up bool
+ Broadcast bool
+ Loopback bool
+ PointToPoint bool
+ Multicast bool
+ Addrs string
+}
+
+type InterfaceRetriever interface {
+ CacheCurrentInterfaces() int
+ GetCachedInterface(index int) *InterfaceInfo
+}
+
+func (m *DendriteMonolith) RegisterNetworkCallback(intfCallback InterfaceRetriever) {
+ callback := func() []pineconeMulticast.InterfaceInfo {
+ count := intfCallback.CacheCurrentInterfaces()
+ intfs := []pineconeMulticast.InterfaceInfo{}
+ for i := 0; i < count; i++ {
+ iface := intfCallback.GetCachedInterface(i)
+ if iface != nil {
+ intfs = append(intfs, pineconeMulticast.InterfaceInfo{
+ Name: iface.Name,
+ Index: iface.Index,
+ Mtu: iface.Mtu,
+ Up: iface.Up,
+ Broadcast: iface.Broadcast,
+ Loopback: iface.Loopback,
+ PointToPoint: iface.PointToPoint,
+ Multicast: iface.Multicast,
+ Addrs: iface.Addrs,
+ })
+ }
+ }
+ return intfs
+ }
+ m.PineconeMulticast.RegisterNetworkCallback(callback)
}
func (m *DendriteMonolith) SetMulticastEnabled(enabled bool) {