mirror of
https://github.com/nkanaev/yarr.git
synced 2025-11-07 09:59:38 +00:00
Compare commits
8 Commits
ac9b635ed8
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16a7f3409c | ||
|
|
0e11cec99a | ||
|
|
c158912da4 | ||
|
|
08ad04401d | ||
|
|
a851d8ac9d | ||
|
|
5a3547e32e | ||
|
|
b24152c19a | ||
|
|
9f93298cf9 |
@@ -3,7 +3,10 @@
|
|||||||
- (new) serve on unix socket (thanks to @rvighne)
|
- (new) serve on unix socket (thanks to @rvighne)
|
||||||
- (new) more auto-refresh options: 12h & 24h (thanks to @aswerkljh for suggestion)
|
- (new) more auto-refresh options: 12h & 24h (thanks to @aswerkljh for suggestion)
|
||||||
- (fix) smooth scrolling on iOS (thanks to gatheraled)
|
- (fix) smooth scrolling on iOS (thanks to gatheraled)
|
||||||
|
- (fix) displaying youtube shorts in "Read Here" (thanks to @Dean-Corso for the report)
|
||||||
|
- (etc) theme-color support (thanks to @asimpson)
|
||||||
- (etc) cookie security measures (thanks to Tom Fitzhenry)
|
- (etc) cookie security measures (thanks to Tom Fitzhenry)
|
||||||
|
- (etc) restrict access to internal IPs for page crawler (thanks to Omar Kurt)
|
||||||
|
|
||||||
# v2.5 (2025-03-26)
|
# v2.5 (2025-03-26)
|
||||||
|
|
||||||
|
|||||||
3
makefile
3
makefile
@@ -5,6 +5,7 @@ GO_TAGS = sqlite_foreign_keys sqlite_json
|
|||||||
GO_LDFLAGS = -s -w -X 'main.Version=$(VERSION)' -X 'main.GitHash=$(GITHASH)'
|
GO_LDFLAGS = -s -w -X 'main.Version=$(VERSION)' -X 'main.GitHash=$(GITHASH)'
|
||||||
|
|
||||||
GO_FLAGS = -tags "$(GO_TAGS)" -ldflags="$(GO_LDFLAGS)"
|
GO_FLAGS = -tags "$(GO_TAGS)" -ldflags="$(GO_LDFLAGS)"
|
||||||
|
GO_FLAGS_DEBUG = -tags "$(GO_TAGS) debug"
|
||||||
GO_FLAGS_GUI = -tags "$(GO_TAGS) gui" -ldflags="$(GO_LDFLAGS)"
|
GO_FLAGS_GUI = -tags "$(GO_TAGS) gui" -ldflags="$(GO_LDFLAGS)"
|
||||||
GO_FLAGS_GUI_WIN = -tags "$(GO_TAGS) gui" -ldflags="$(GO_LDFLAGS) -H windowsgui"
|
GO_FLAGS_GUI_WIN = -tags "$(GO_TAGS) gui" -ldflags="$(GO_LDFLAGS) -H windowsgui"
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ windows_arm64_gui: src/platform/versioninfo.rc
|
|||||||
GOOS=windows GOARCH=arm64 go build $(GO_FLAGS_GUI_WIN) -o out/$@/yarr.exe ./cmd/yarr
|
GOOS=windows GOARCH=arm64 go build $(GO_FLAGS_GUI_WIN) -o out/$@/yarr.exe ./cmd/yarr
|
||||||
|
|
||||||
serve:
|
serve:
|
||||||
go run $(GO_FLAGS) ./cmd/yarr -db local.db
|
go run $(GO_FLAGS_DEBUG) ./cmd/yarr -db local.db
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test $(GO_FLAGS) ./...
|
go test $(GO_FLAGS) ./...
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build !debug
|
||||||
|
|
||||||
package assets
|
package assets
|
||||||
|
|
||||||
import "embed"
|
import "embed"
|
||||||
|
|||||||
@@ -24,21 +24,21 @@
|
|||||||
<div class="p-2 toolbar d-flex align-items-center">
|
<div class="p-2 toolbar d-flex align-items-center">
|
||||||
<div class="icon mx-2">{% inline "anchor.svg" %}</div>
|
<div class="icon mx-2">{% inline "anchor.svg" %}</div>
|
||||||
<div class="flex-grow-1"></div>
|
<div class="flex-grow-1"></div>
|
||||||
<button class="toolbar-item"
|
<button class="toolbar-item ml-1"
|
||||||
:class="{active: filterSelected == 'unread'}"
|
:class="{active: filterSelected == 'unread'}"
|
||||||
:aria-pressed="filterSelected == 'unread'"
|
:aria-pressed="filterSelected == 'unread'"
|
||||||
title="Unread"
|
title="Unread"
|
||||||
@click="filterSelected = 'unread'">
|
@click="filterSelected = 'unread'">
|
||||||
<span class="icon">{% inline "circle-full.svg" %}</span>
|
<span class="icon">{% inline "circle-full.svg" %}</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="toolbar-item"
|
<button class="toolbar-item mx-1"
|
||||||
:class="{active: filterSelected == 'starred'}"
|
:class="{active: filterSelected == 'starred'}"
|
||||||
:aria-pressed="filterSelected == 'starred'"
|
:aria-pressed="filterSelected == 'starred'"
|
||||||
title="Starred"
|
title="Starred"
|
||||||
@click="filterSelected = 'starred'">
|
@click="filterSelected = 'starred'">
|
||||||
<span class="icon">{% inline "star-full.svg" %}</span>
|
<span class="icon">{% inline "star-full.svg" %}</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="toolbar-item"
|
<button class="toolbar-item mr-1"
|
||||||
:class="{active: filterSelected == ''}"
|
:class="{active: filterSelected == ''}"
|
||||||
:aria-pressed="filterSelected == ''"
|
:aria-pressed="filterSelected == ''"
|
||||||
title="All"
|
title="All"
|
||||||
|
|||||||
@@ -820,7 +820,7 @@ var vm = new Vue({
|
|||||||
return this.filterSelected
|
return this.filterSelected
|
||||||
&& !(this.current.folder.id == folder.id || this.current.feed.folder_id == folder.id)
|
&& !(this.current.folder.id == folder.id || this.current.feed.folder_id == folder.id)
|
||||||
&& !this.filteredFolderStats[folder.id]
|
&& !this.filteredFolderStats[folder.id]
|
||||||
&& (!this.itemSelectedDetails || (this.feedsById[itemSelectedDetails.feed_id] || {}).folder_id != folder.id)
|
&& (!this.itemSelectedDetails || (this.feedsById[this.itemSelectedDetails.feed_id] || {}).folder_id != folder.id)
|
||||||
},
|
},
|
||||||
mustHideFeed: function (feed) {
|
mustHideFeed: function (feed) {
|
||||||
return this.filterSelected
|
return this.filterSelected
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ func VideoIFrame(link string) string {
|
|||||||
youtubeID := ""
|
youtubeID := ""
|
||||||
if l.Host == "www.youtube.com" && l.Path == "/watch" {
|
if l.Host == "www.youtube.com" && l.Path == "/watch" {
|
||||||
youtubeID = l.Query().Get("v")
|
youtubeID = l.Query().Get("v")
|
||||||
|
} else if l.Host == "www.youtube.com" && strings.HasPrefix(l.Path, "/shorts/") {
|
||||||
|
youtubeID = strings.TrimPrefix(l.Path, "/shorts/")
|
||||||
} else if l.Host == "youtu.be" {
|
} else if l.Host == "youtu.be" {
|
||||||
youtubeID = strings.TrimLeft(l.Path, "/")
|
youtubeID = strings.TrimLeft(l.Path, "/")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build linux || freebsd
|
//go:build linux || freebsd || openbsd
|
||||||
|
|
||||||
package platform
|
package platform
|
||||||
|
|
||||||
|
|||||||
@@ -513,6 +513,10 @@ func (s *Server) handlePageCrawl(c *router.Context) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if isInternalFromURL(url) {
|
||||||
|
log.Printf("attempt to access internal IP %s from %s", url, c.Req.RemoteAddr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
body, err := worker.GetBody(url)
|
body, err := worker.GetBody(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
35
src/server/util.go
Normal file
35
src/server/util.go
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func isInternalFromURL(urlStr string) bool {
|
||||||
|
parsedURL, err := url.Parse(urlStr)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
host := parsedURL.Host
|
||||||
|
|
||||||
|
// Handle "host:port" format
|
||||||
|
if strings.Contains(host, ":") {
|
||||||
|
host, _, err = net.SplitHostPort(host)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if host == "localhost" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
ip := net.ParseIP(host)
|
||||||
|
if ip == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast()
|
||||||
|
}
|
||||||
31
src/server/util_test.go
Normal file
31
src/server/util_test.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestIsInternalFromURL(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
url string
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{"http://192.168.1.1:8080", true},
|
||||||
|
{"http://10.0.0.5", true},
|
||||||
|
{"http://172.16.0.1", true},
|
||||||
|
{"http://172.31.255.255", true},
|
||||||
|
{"http://172.32.0.1", false}, // outside private range
|
||||||
|
{"http://127.0.0.1", true},
|
||||||
|
{"http://127.0.0.1:7000", true},
|
||||||
|
{"http://127.0.0.1:7000/secret", true},
|
||||||
|
{"http://169.254.0.5", true},
|
||||||
|
{"http://localhost", true}, // resolves to 127.0.0.1
|
||||||
|
{"http://8.8.8.8", false},
|
||||||
|
{"http://google.com", false}, // resolves to public IPs
|
||||||
|
{"invalid-url", false}, // invalid format
|
||||||
|
{"", false}, // empty string
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
result := isInternalFromURL(test.url)
|
||||||
|
if result != test.expected {
|
||||||
|
t.Errorf("isInternalFromURL(%q) = %v; want %v", test.url, result, test.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,11 +54,15 @@ type MediaLink struct {
|
|||||||
type MediaLinks []MediaLink
|
type MediaLinks []MediaLink
|
||||||
|
|
||||||
func (m *MediaLinks) Scan(src any) error {
|
func (m *MediaLinks) Scan(src any) error {
|
||||||
if data, ok := src.([]byte); ok {
|
switch data := src.(type) {
|
||||||
|
case []byte:
|
||||||
return json.Unmarshal(data, m)
|
return json.Unmarshal(data, m)
|
||||||
}
|
case string:
|
||||||
|
return json.Unmarshal([]byte(data), m)
|
||||||
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m MediaLinks) Value() (driver.Value, error) {
|
func (m MediaLinks) Value() (driver.Value, error) {
|
||||||
return json.Marshal(m)
|
return json.Marshal(m)
|
||||||
@@ -419,7 +423,6 @@ func (s *Storage) DeleteOldItems() {
|
|||||||
where status != ?
|
where status != ?
|
||||||
group by i.feed_id
|
group by i.feed_id
|
||||||
`, itemsKeepSize, STARRED)
|
`, itemsKeepSize, STARRED)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user