]> Sergey Matveev's repositories - godlighty.git/commitdiff
Add pri/geo attributes to Links
authorSergey Matveev <stargrave@stargrave.org>
Fri, 13 Feb 2026 13:32:21 +0000 (16:32 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 13 Feb 2026 13:32:37 +0000 (16:32 +0300)
godlighty.go
handler.go
meta4/parse.go
meta4/scheme.go

index 834266e3dd9cbad9fcee1728483bb3cef0717bf7..60c1c4b5cd313e4358a856db400b35c6bcbd2fca 100644 (file)
@@ -1,6 +1,6 @@
 // Highly-customizable HTTP, HTTP/2, HTTPS server
 package godlighty
 
-const Version = "godlighty/0.10.0"
+const Version = "godlighty/0.11.0"
 
 var BindAddr string
index d31857a59a9a4e26eb924844e80f4c43c962456a..43fa36ae0bdb2b9e00bca4d2ca64ecccf500d0d8 100644 (file)
@@ -268,7 +268,14 @@ IndexLookuped:
                        `>; rel=describedby; type="application/metalink4+xml"`,
                )
                for _, u := range forHTTP.URLs {
-                       w.Header().Add("Link", "<"+u+">; rel=duplicate")
+                       s := "<" + u.URL + ">; rel=duplicate"
+                       if u.Priority != 0 {
+                               s += "; pri=" + strconv.Itoa(int(u.Priority))
+                       }
+                       if u.Location != "" {
+                               s += "; geo=" + u.Location
+                       }
+                       w.Header().Add("Link", s)
                }
                for name, digest := range forHTTP.Hashes {
                        w.Header().Add("Digest", name+"="+base64.StdEncoding.EncodeToString(digest))
index 7a90e46b106c4ab4cff462efe232ac81f2425872..ca128f1c3b29d7ed6d7949a23b9a06732284818e 100644 (file)
@@ -37,7 +37,7 @@ var KnownHashes = map[string]string{
 
 type ForHTTP struct {
        Hashes   map[string][]byte
-       URLs     []string
+       URLs     []URL
        Torrents []string
 }
 
@@ -63,9 +63,7 @@ func Parse(fn string, data []byte) (*ForHTTP, error) {
                        }
                        forHTTP.Hashes[name] = digest
                }
-               for _, u := range f.URLs {
-                       forHTTP.URLs = append(forHTTP.URLs, u.URL)
-               }
+               forHTTP.URLs = f.URLs
                for _, m := range f.MetaURLs {
                        if m.MediaType == "torrent" {
                                forHTTP.Torrents = append(forHTTP.Torrents, m.URL)
index 82ce4a5c0059232c6a48039ae8fc58d7ffae5a42..a082c9bc544ce4694ee225b58cf80535141610f1 100644 (file)
@@ -44,8 +44,10 @@ type File struct {
 }
 
 type URL struct {
-       XMLName xml.Name `xml:"url"`
-       URL     string   `xml:",chardata"`
+       XMLName  xml.Name `xml:"url"`
+       Location string   `xml:"location,attr"`
+       Priority uint     `xml:"priority,attr"`
+       URL      string   `xml:",chardata"`
 }
 
 type Signature struct {