]> git.r.bdr.sh - rbdr/mobius/commitdiff
Make Bonjour optional and disabled by default
authorJeff Halter <redacted>
Sat, 27 Jul 2024 01:19:33 +0000 (18:19 -0700)
committerJeff Halter <redacted>
Sat, 27 Jul 2024 01:19:33 +0000 (18:19 -0700)
Bonjour doesn't seem happy inside Docker, so I'm making it optional and off by default.

cmd/mobius-hotline-server/main.go
cmd/mobius-hotline-server/mobius/config/config.yaml
hotline/config.go

index e2c7789b19877cd1313792e39f5121e4e070b66a..1390dda34573e1618a72f0eb54fe615bd10ec3dd 100644 (file)
@@ -169,11 +169,13 @@ func main() {
        // Assign functions to handle specific Hotline transaction types
        mobius.RegisterHandlers(srv)
 
-       s, err := bonjour.Register(srv.Config.Name, "_hotline._tcp", "", *basePort, []string{"txtv=1", "app=hotline"}, nil)
-       if err != nil {
-               slogger.Error("Error registering Hotline server with Bonjour", "err", err)
+       if srv.Config.EnableBonjour {
+               s, err := bonjour.Register(srv.Config.Name, "_hotline._tcp", "", *basePort, []string{"txtv=1", "app=hotline"}, nil)
+               if err != nil {
+                       slogger.Error("Error registering Hotline server with Bonjour", "err", err)
+               }
+               defer s.Shutdown()
        }
-       defer s.Shutdown()
 
        // Serve Hotline requests until program exit
        log.Fatal(srv.ListenAndServe(ctx))
index 0801621db131f65e4c61c7b029af13ae77407812..7cb741282bff4c0b391a7c667d19cf0beceff2a1 100644 (file)
@@ -58,3 +58,6 @@ MaxConnectionsPerIP: 0
 IgnoreFiles:
   - '^\.'     # Ignore all files starting with ".".  Leave this set if you are using the PreserveResourceForks option.
   - '^@'       # Ignore all files starting with "@"
+
+# Enable service announcement on local network with Bonjour
+EnableBonjour: false
\ No newline at end of file
index 1ad0ec2ccb45a58cb1ac8eb52f9113a4abf2cbbc..a7bd81e4706956e4b68e3715c0bedc06bd573193 100644 (file)
@@ -14,4 +14,5 @@ type Config struct {
        MaxConnectionsPerIP       int      `yaml:"MaxConnectionsPerIP"`                     // Max connections per IP
        PreserveResourceForks     bool     `yaml:"PreserveResourceForks"`                   // Enable preservation of file info and resource forks in sidecar files
        IgnoreFiles               []string `yaml:"IgnoreFiles"`                             // List of regular expression for filtering files from the file list
+       EnableBonjour             bool     `yaml:"EnableBonjour"`                           // Enable service announcement on local network with Bonjour
 }