Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

lib/http: add Addr() method to return the first configured server address

Nick Craig-Wood90ea4a73ada3
diff --git a/lib/http/server.go b/lib/http/server.go
index 57ce8b8bb..98f4f5ca7 100644
--- a/lib/http/server.go
+++ b/lib/http/server.go
@@ -576,6 +576,14 @@ func (s *Server) URLs() []string {
return out
}
+// Addr returns the first configured address
+func (s *Server) Addr() net.Addr {
+ if len(s.instances) == 0 || s.instances[0].listener == nil {
+ return nil
+ }
+ return s.instances[0].listener.Addr()
+}
+
// UsingAuth returns true if authentication is required
func (s *Server) UsingAuth() bool {
return s.usingAuth