Compare commits
89
Commits
72376a4568
...
6fba25ca0b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fba25ca0b
|
||
|
|
e5c192c83c
|
||
|
|
c9f41810af | ||
|
|
3db183bda4 | ||
|
|
8ac8779b92 | ||
|
|
eaa82b00e5 | ||
|
|
223b7feab4 | ||
|
|
1bf4a5b0c1 | ||
|
|
db97bc753e | ||
|
|
5916a7fe7b | ||
|
|
d9facdcca6 | ||
|
|
21b562b5fe | ||
|
|
758c4c7279 | ||
|
|
4c5c015190 | ||
|
|
7159e1ca09 | ||
|
|
f812c15fa1 | ||
|
|
dc98b6aa50 | ||
|
|
e2415e944c | ||
|
|
0f7e24b39b | ||
|
|
f5195f15c4 | ||
|
|
fccf01642f | ||
|
|
5638ef5df7 | ||
|
|
6ca68b2c26 | ||
|
|
b36f26e32a | ||
|
|
995c566131 | ||
|
|
6eddc2a1a9 | ||
|
|
6d7c605578 | ||
|
|
6bf39cc0c4 | ||
|
|
8ba05ef14d | ||
|
|
dc3682dc8f | ||
|
|
3cf6d0a28b | ||
|
|
c531666eb6 | ||
|
|
02fd31452d | ||
|
|
9a97fa4b22 | ||
|
|
8d4c22ad2f | ||
|
|
0d85e0ce02 | ||
|
|
8793a36364 | ||
|
|
ac31258f88 | ||
|
|
683525aad2 | ||
|
|
bc62b213a5 | ||
|
|
f6ecd6d39b | ||
|
|
fdceb555bf | ||
|
|
6301cb25bc | ||
|
|
408d325c2c | ||
|
|
e944817f8b | ||
|
|
f8b0fbbfa2 | ||
|
|
90b5324179 | ||
|
|
05149961b5 | ||
|
|
84e29da258 | ||
|
|
7c6e1957fb | ||
|
|
df42923f7b | ||
|
|
4799fb2441 | ||
|
|
322aa0747a | ||
|
|
7558bb3f23 | ||
|
|
e770eaa07a | ||
|
|
a24b7c07cb | ||
|
|
c03e10454c | ||
|
|
a99d63ab12 | ||
|
|
667cf731fd | ||
|
|
38ea72bbc6 | ||
|
|
d6d51ed9f7 | ||
|
|
9e5b8d4ac8 | ||
|
|
238856ad73 | ||
|
|
7de6cf1e9e | ||
|
|
e7d6fdab69 | ||
|
|
94027dcf9b | ||
|
|
46dac6d463 | ||
|
|
fc08e0a171 | ||
|
|
c317046fc9 | ||
|
|
a558947da6 | ||
|
|
e5f815c79e | ||
|
|
80f5facbd2 | ||
|
|
23d23c7c6a | ||
|
|
1fd8c9b2c3 | ||
|
|
9c56bf61ab | ||
|
|
79b28ef653 | ||
|
|
d8338590fd | ||
|
|
fdb2ec66de | ||
|
|
6c8f5fa968 | ||
|
|
6602495032 | ||
|
|
6b2f853b3c | ||
|
|
23e797e62a | ||
|
|
1fab192195 | ||
|
|
98be763e37 | ||
|
|
830ab090fd | ||
|
|
13bb999bd5 | ||
|
|
ae9f95aa75 | ||
|
|
c5b35a6ff1 | ||
|
|
cf3f6666e0 |
No files matched your search
@@ -36,7 +36,7 @@ jobs:
|
|||||||
uses: golangci/golangci-lint-action@v8
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
install-mode: goinstall
|
install-mode: goinstall
|
||||||
version: v2.3.0
|
version: v2.4.0
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test ./...
|
run: go test ./...
|
||||||
build-release:
|
build-release:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ jobs:
|
|||||||
uses: golangci/golangci-lint-action@v8
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
install-mode: goinstall
|
install-mode: goinstall
|
||||||
version: v2.3.0
|
version: v2.4.0
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test ./...
|
run: go test ./...
|
||||||
release-please:
|
release-please:
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ jobs:
|
|||||||
uses: golangci/golangci-lint-action@v8
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
install-mode: goinstall
|
install-mode: goinstall
|
||||||
version: v2.3.0
|
version: v2.4.0
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test ./...
|
run: go test ./...
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
*.db
|
*.db
|
||||||
|
*.db.*.bak
|
||||||
*db-wal
|
*db-wal
|
||||||
*db-shm
|
*db-shm
|
||||||
*.sql
|
*.sql
|
||||||
|
|||||||
+2
-14
@@ -1,25 +1,13 @@
|
|||||||
FROM alpine:3.22 AS builder-taglib
|
FROM golang:1.25-alpine3.22 AS builder
|
||||||
WORKDIR /tmp
|
|
||||||
COPY alpine/taglib/APKBUILD .
|
|
||||||
RUN apk update && \
|
|
||||||
apk add --no-cache abuild doas && \
|
|
||||||
echo "permit nopass root" > /etc/doas.conf && \
|
|
||||||
abuild-keygen -a -n -i && \
|
|
||||||
REPODEST=/pkgs abuild -F -r
|
|
||||||
|
|
||||||
FROM golang:1.24-alpine3.22 AS builder
|
|
||||||
RUN apk add -U --no-cache \
|
RUN apk add -U --no-cache \
|
||||||
build-base \
|
build-base \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
git \
|
git \
|
||||||
sqlite \
|
sqlite \
|
||||||
zlib-dev \
|
zlib-dev \
|
||||||
|
taglib-dev \
|
||||||
go
|
go
|
||||||
|
|
||||||
# TODO: delete this block when taglib v2 is on alpine packages
|
|
||||||
COPY --from=builder-taglib /pkgs/*/*.apk /pkgs/
|
|
||||||
RUN apk add --no-cache --allow-untrusted /pkgs/*
|
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY go.mod .
|
COPY go.mod .
|
||||||
COPY go.sum .
|
COPY go.sum .
|
||||||
|
|||||||
@@ -85,10 +85,12 @@ the available modes are:
|
|||||||
|
|
||||||
| value | desc |
|
| value | desc |
|
||||||
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `multi` | gonic will explictly look for multi value fields in your audio metadata such as "genres" or "album_artists". software like [musicbrainz picard](https://picard.musicbrainz.org/), [beets](https://beets.io/) (v1.6.1+ / master), or [betanin](https://github.com/sentriz/betanin/) can set set these |
|
| `multi` | gonic will explictly look for multi value fields in your audio metadata such as "genres" or "album_artists". software like [musicbrainz picard](https://picard.musicbrainz.org/), [beets](https://beets.io/) (v1.6.1+ / master), [wrtag](https://github.com/sentriz/wrtag/), or [betanin](https://github.com/sentriz/betanin/) can set set these |
|
||||||
| `delim <delim>` | gonic will look at your normal audio metadata fields like "genre" or "album_artist", but split them on a delimiter. for example you could set `-multi-value-genre "delim ;"` to split the single genre field on ";". note this mode is not recommended unless you use an uncommon delimiter such as ";" or "\|". using a delimiter like "&" will likely lead to many [false positives](https://musicbrainz.org/artist/ccd4879c-5e88-4385-b131-bf65296bf245) |
|
| `delim <delim>` | gonic will look at your normal audio metadata fields like "genre" or "album_artist", but split them on a delimiter. for example you could set `-multi-value-genre "delim ;"` to split the single genre field on ";". note this mode is not recommended unless you use an uncommon delimiter such as ";" or "\|". using a delimiter like "&" will likely lead to many [false positives](https://musicbrainz.org/artist/ccd4879c-5e88-4385-b131-bf65296bf245) |
|
||||||
| `none` (default) | gonic will not attempt to do any multi value processing |
|
| `none` (default) | gonic will not attempt to do any multi value processing |
|
||||||
|
|
||||||
|
note: `,` is a special character in the environment variable parser. if you wish to use `,` for example for splitting genres, the `,` must be escaped with `\`. for example `"delim \,"`.
|
||||||
|
|
||||||
## screenshots
|
## screenshots
|
||||||
|
|
||||||
| | | | | |
|
| | | | | |
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
# Contributor: Leo <thinkabit.ukim@gmail.com>
|
|
||||||
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
|
|
||||||
pkgname=taglib2
|
|
||||||
pkgver=2.0.1
|
|
||||||
pkgrel=0
|
|
||||||
pkgdesc="Library for reading and editing metadata of several popular audio formats"
|
|
||||||
url="https://taglib.github.io/"
|
|
||||||
arch="all"
|
|
||||||
license="LGPL-2.1-only OR MPL-1.1"
|
|
||||||
makedepends="zlib-dev utfcpp cmake samurai"
|
|
||||||
checkdepends="cppunit-dev"
|
|
||||||
subpackages="
|
|
||||||
$pkgname-dev
|
|
||||||
libtag:_lib
|
|
||||||
libtag_c:_lib
|
|
||||||
"
|
|
||||||
source="https://taglib.github.io/releases/taglib-$pkgver.tar.gz"
|
|
||||||
builddir="$srcdir/taglib-$pkgver"
|
|
||||||
|
|
||||||
# secfixes:
|
|
||||||
# 1.11.1-r2:
|
|
||||||
# - CVE-2017-12678
|
|
||||||
# - CVE-2018-11439
|
|
||||||
|
|
||||||
build() {
|
|
||||||
CFLAGS="$CFLAGS -flto=auto" \
|
|
||||||
CXXFLAGS="$CXXFLAGS -flto=auto" \
|
|
||||||
cmake -B build -G Ninja \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
|
||||||
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
|
||||||
-DWITH_ZLIB=ON \
|
|
||||||
-DBUILD_SHARED_LIBS=ON \
|
|
||||||
-DBUILD_EXAMPLES=OFF \
|
|
||||||
-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
|
|
||||||
-DVISIBILITY_HIDDEN=ON
|
|
||||||
CPLUS_INCLUDE_PATH="/usr/include/utf8cpp" \
|
|
||||||
cmake --build build
|
|
||||||
}
|
|
||||||
|
|
||||||
check() {
|
|
||||||
ctest --test-dir build --output-on-failure
|
|
||||||
}
|
|
||||||
|
|
||||||
package() {
|
|
||||||
DESTDIR="$pkgdir" cmake --install build
|
|
||||||
}
|
|
||||||
|
|
||||||
_lib() {
|
|
||||||
pkgdesc="$pkgdesc ($subpkgname lib)"
|
|
||||||
|
|
||||||
amove usr/lib/$subpkgname.so.*
|
|
||||||
}
|
|
||||||
|
|
||||||
sha512sums="
|
|
||||||
25ee89293a96d7f8dca6276f822bdaef01fd98503b78c20ffeac8e1d9821de7273a5127146aa798d304c6a995cb2b7229a205aff1cc261b5d4fa9e499dda0439 taglib-2.0.1.tar.gz
|
|
||||||
"
|
|
||||||
+21
-2
@@ -38,6 +38,7 @@ import (
|
|||||||
"go.senan.xyz/gonic/infocache/artistinfocache"
|
"go.senan.xyz/gonic/infocache/artistinfocache"
|
||||||
"go.senan.xyz/gonic/jukebox"
|
"go.senan.xyz/gonic/jukebox"
|
||||||
"go.senan.xyz/gonic/lastfm"
|
"go.senan.xyz/gonic/lastfm"
|
||||||
|
"go.senan.xyz/gonic/ldap"
|
||||||
"go.senan.xyz/gonic/listenbrainz"
|
"go.senan.xyz/gonic/listenbrainz"
|
||||||
"go.senan.xyz/gonic/playlist"
|
"go.senan.xyz/gonic/playlist"
|
||||||
"go.senan.xyz/gonic/podcast"
|
"go.senan.xyz/gonic/podcast"
|
||||||
@@ -83,6 +84,24 @@ func main() {
|
|||||||
|
|
||||||
confExcludePattern := flag.String("exclude-pattern", "", "regex pattern to exclude files from scan (optional)")
|
confExcludePattern := flag.String("exclude-pattern", "", "regex pattern to exclude files from scan (optional)")
|
||||||
|
|
||||||
|
var ldapConfig ldap.Config
|
||||||
|
flag.StringVar(&ldapConfig.BindUser, "ldap-bind-user", "", "the bind user to bind to LDAP with (required for LDAP)")
|
||||||
|
flag.StringVar(&ldapConfig.BindPass, "ldap-bind-pass", "", "the password of the LDAP bind user (required for LDAP)")
|
||||||
|
flag.StringVar(&ldapConfig.BaseDN, "ldap-base-dn", "", "the base DN for LDAP objects (required for LDAP)")
|
||||||
|
|
||||||
|
flag.StringVar(&ldapConfig.Filter, "ldap-filter", "", "the filter to select LDAP objects with (optional)")
|
||||||
|
flag.StringVar(&ldapConfig.AdminFilter, "ldap-admin-filter", "(memberof=cn=admin)", "the filter to select LDAP objects with (optional)")
|
||||||
|
|
||||||
|
flag.StringVar(&ldapConfig.FQDN, "ldap-fqdn", "", "the name of the server to connect to (required for LDAP)")
|
||||||
|
flag.UintVar(&ldapConfig.Port, "ldap-port", 389, "what port the LDAP server is hosted on (optional)")
|
||||||
|
flag.BoolVar(&ldapConfig.TLS, "ldap-tls", false, "whether gonic will connect to the LDAP server using TLS (optional)")
|
||||||
|
|
||||||
|
if ldapConfig.FQDN != "" {
|
||||||
|
if ldapConfig.BindUser == "" || ldapConfig.BindPass == "" || ldapConfig.BaseDN == "" {
|
||||||
|
log.Fatal("a server was provided for an LDAP connection, but configuration is incomplete")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var confMultiValueGenre, confMultiValueArtist, confMultiValueAlbumArtist multiValueSetting
|
var confMultiValueGenre, confMultiValueArtist, confMultiValueAlbumArtist multiValueSetting
|
||||||
flag.Var(&confMultiValueGenre, "multi-value-genre", "setting for mutli-valued genre scanning (optional)")
|
flag.Var(&confMultiValueGenre, "multi-value-genre", "setting for mutli-valued genre scanning (optional)")
|
||||||
flag.Var(&confMultiValueArtist, "multi-value-artist", "setting for mutli-valued track artist scanning (optional)")
|
flag.Var(&confMultiValueArtist, "multi-value-artist", "setting for mutli-valued track artist scanning (optional)")
|
||||||
@@ -254,11 +273,11 @@ func main() {
|
|||||||
return url.String()
|
return url.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath)
|
ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath, ldapConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("error creating admin controller: %v\n", err)
|
log.Panicf("error creating admin controller: %v\n", err)
|
||||||
}
|
}
|
||||||
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, resolveProxyPath)
|
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, resolveProxyPath, ldapConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("error creating subsonic controller: %v\n", err)
|
log.Panicf("error creating subsonic controller: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func (db *DB) InsertBulkLeftMany(table string, head []string, left int, col []in
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var rows []string
|
var rows []string
|
||||||
var values []interface{}
|
var values []any
|
||||||
for _, c := range col {
|
for _, c := range col {
|
||||||
rows = append(rows, "(?, ?)")
|
rows = append(rows, "(?, ?)")
|
||||||
values = append(values, left, c)
|
values = append(values, left, c)
|
||||||
@@ -138,10 +138,7 @@ func (db *DB) TransactionChunked(data []int64, cb func(*DB, []int64) error) erro
|
|||||||
const size = 999
|
const size = 999
|
||||||
return db.Transaction(func(tx *DB) error {
|
return db.Transaction(func(tx *DB) error {
|
||||||
for i := 0; i < len(data); i += size {
|
for i := 0; i < len(data); i += size {
|
||||||
end := i + size
|
end := min(i+size, len(data))
|
||||||
if end > len(data) {
|
|
||||||
end = len(data)
|
|
||||||
}
|
|
||||||
if err := cb(tx, data[i:end]); err != nil {
|
if err := cb(tx, data[i:end]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -235,6 +232,7 @@ type Track struct {
|
|||||||
TagTrackNumber int `sql:"default: null"`
|
TagTrackNumber int `sql:"default: null"`
|
||||||
TagDiscNumber int `sql:"default: null"`
|
TagDiscNumber int `sql:"default: null"`
|
||||||
TagBrainzID string `sql:"default: null"`
|
TagBrainzID string `sql:"default: null"`
|
||||||
|
TagLyrics string `sql:"default:null"`
|
||||||
|
|
||||||
ReplayGainTrackGain float32
|
ReplayGainTrackGain float32
|
||||||
ReplayGainTrackPeak float32
|
ReplayGainTrackPeak float32
|
||||||
@@ -296,7 +294,7 @@ type User struct {
|
|||||||
ID int `gorm:"primary_key"`
|
ID int `gorm:"primary_key"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
Name string `gorm:"not null; unique_index" sql:"default: null"`
|
Name string `gorm:"not null; unique_index" sql:"default: null"`
|
||||||
Password string `gorm:"not null" sql:"default: null"`
|
Password string `sql:"default: null"`
|
||||||
LastFMSession string `sql:"default: null"`
|
LastFMSession string `sql:"default: null"`
|
||||||
ListenBrainzURL string `sql:"default: null"`
|
ListenBrainzURL string `sql:"default: null"`
|
||||||
ListenBrainzToken string `sql:"default: null"`
|
ListenBrainzToken string `sql:"default: null"`
|
||||||
@@ -642,8 +640,8 @@ func Dump(ctx context.Context, db *gorm.DB, to string) error {
|
|||||||
}
|
}
|
||||||
defer connDest.Close()
|
defer connDest.Close()
|
||||||
|
|
||||||
err = connDest.Raw(func(connDest interface{}) error {
|
err = connDest.Raw(func(connDest any) error {
|
||||||
return connSrc.Raw(func(connSrc interface{}) error {
|
return connSrc.Raw(func(connSrc any) error {
|
||||||
connDestq := connDest.(*sqlite3.SQLiteConn)
|
connDestq := connDest.(*sqlite3.SQLiteConn)
|
||||||
connSrcq := connSrc.(*sqlite3.SQLiteConn)
|
connSrcq := connSrc.(*sqlite3.SQLiteConn)
|
||||||
bk, err := connDestq.Backup("main", connSrcq, "main")
|
bk, err := connDestq.Backup("main", connSrcq, "main")
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
|
|||||||
construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID),
|
construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID),
|
||||||
construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID),
|
construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID),
|
||||||
construct(ctx, "202507062103", migrateAlbumCompilationReleaseType),
|
construct(ctx, "202507062103", migrateAlbumCompilationReleaseType),
|
||||||
|
construct(ctx, "202508261102", migrateAddLyrics),
|
||||||
}
|
}
|
||||||
|
|
||||||
return gormigrate.
|
return gormigrate.
|
||||||
@@ -861,3 +862,7 @@ func migrateAlbumCompilationReleaseType(tx *gorm.DB, _ MigrationContext) error {
|
|||||||
Album{},
|
Album{},
|
||||||
).Error
|
).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func migrateAddLyrics(tx *gorm.DB, _ MigrationContext) error {
|
||||||
|
return tx.AutoMigrate(Track{}).Error
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
module go.senan.xyz/gonic
|
module go.senan.xyz/gonic
|
||||||
|
|
||||||
go 1.24
|
go 1.25
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/sprig v2.22.0+incompatible
|
github.com/Masterminds/sprig v2.22.0+incompatible
|
||||||
@@ -9,8 +9,10 @@ require (
|
|||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
github.com/djherbis/times v1.6.0
|
github.com/djherbis/times v1.6.0
|
||||||
github.com/dustin/go-humanize v1.0.1
|
github.com/dustin/go-humanize v1.0.1
|
||||||
|
github.com/env25/mpdlrc v0.7.4
|
||||||
github.com/fatih/structs v1.1.0
|
github.com/fatih/structs v1.1.0
|
||||||
github.com/fsnotify/fsnotify v1.9.0
|
github.com/fsnotify/fsnotify v1.9.0
|
||||||
|
github.com/go-ldap/ldap/v3 v3.4.6
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/securecookie v1.1.2
|
github.com/gorilla/securecookie v1.1.2
|
||||||
@@ -18,6 +20,7 @@ require (
|
|||||||
github.com/jinzhu/gorm v1.9.17-0.20211120011537-5c235b72a414
|
github.com/jinzhu/gorm v1.9.17-0.20211120011537-5c235b72a414
|
||||||
github.com/josephburnett/jd v1.9.2
|
github.com/josephburnett/jd v1.9.2
|
||||||
github.com/mattn/go-sqlite3 v1.14.32
|
github.com/mattn/go-sqlite3 v1.14.32
|
||||||
|
github.com/microcosm-cc/bluemonday v1.0.27
|
||||||
github.com/mitchellh/mapstructure v1.5.0
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/mmcdole/gofeed v1.3.0
|
github.com/mmcdole/gofeed v1.3.0
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
@@ -25,41 +28,38 @@ require (
|
|||||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be
|
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be
|
||||||
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6
|
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6
|
||||||
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981
|
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.11.1
|
||||||
go.senan.xyz/flagconf v0.1.9
|
go.senan.xyz/flagconf v0.1.9
|
||||||
go.senan.xyz/wrtag v0.16.0
|
go.senan.xyz/wrtag v0.17.1
|
||||||
golang.org/x/net v0.43.0
|
golang.org/x/net v0.43.0
|
||||||
golang.org/x/sync v0.16.0
|
golang.org/x/sync v0.16.0
|
||||||
gopkg.in/gormigrate.v1 v1.6.0
|
gopkg.in/gormigrate.v1 v1.6.0
|
||||||
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
|
||||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||||
github.com/Masterminds/semver v1.5.0 // indirect
|
github.com/Masterminds/semver v1.5.0 // indirect
|
||||||
github.com/PuerkitoBio/goquery v1.10.3 // indirect
|
github.com/PuerkitoBio/goquery v1.10.3 // indirect
|
||||||
|
github.com/aymerick/douceur v0.2.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.21.2 // indirect
|
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
|
||||||
github.com/go-openapi/swag v0.23.1 // indirect
|
github.com/go-openapi/jsonpointer v0.22.0 // indirect
|
||||||
|
github.com/go-openapi/swag/jsonname v0.24.0 // indirect
|
||||||
github.com/gorilla/context v1.1.2 // indirect
|
github.com/gorilla/context v1.1.2 // indirect
|
||||||
|
github.com/gorilla/css v1.0.1 // indirect
|
||||||
github.com/huandu/xstrings v1.5.0 // indirect
|
github.com/huandu/xstrings v1.5.0 // indirect
|
||||||
github.com/imdario/mergo v0.3.16 // indirect
|
github.com/imdario/mergo v0.3.16 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.2 // indirect
|
github.com/jinzhu/now v1.1.2 // indirect
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/lib/pq v1.3.0 // indirect
|
github.com/lib/pq v1.3.0 // indirect
|
||||||
github.com/mailru/easyjson v0.9.0 // indirect
|
|
||||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
|
||||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||||
github.com/mmcdole/goxpp v1.1.1 // indirect
|
github.com/mmcdole/goxpp v1.1.1 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/olekukonko/tablewriter v1.0.9 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
|
||||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
|
|
||||||
golang.org/x/crypto v0.41.0 // indirect
|
golang.org/x/crypto v0.41.0 // indirect
|
||||||
golang.org/x/image v0.30.0 // indirect
|
golang.org/x/image v0.30.0 // indirect
|
||||||
golang.org/x/sys v0.35.0 // indirect
|
golang.org/x/sys v0.35.0 // indirect
|
||||||
@@ -68,6 +68,3 @@ require (
|
|||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://github.com/jaytaylor/html2text/issues/67
|
|
||||||
replace github.com/olekukonko/tablewriter => github.com/olekukonko/tablewriter v0.0.5
|
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
cloud.google.com/go v0.33.1/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.33.1/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8=
|
||||||
|
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
|
||||||
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
||||||
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||||
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
|
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
|
||||||
@@ -11,6 +13,8 @@ github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7
|
|||||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||||
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
||||||
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
|
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
|
||||||
|
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||||
|
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@@ -25,16 +29,22 @@ github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
|
|||||||
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
|
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
|
github.com/env25/mpdlrc v0.7.4 h1:A9If5JKVjgJldaIjJztqkXpUKXlsoRIwXqGK3qS38pY=
|
||||||
|
github.com/env25/mpdlrc v0.7.4/go.mod h1:Zyhq2WfcYeSJUCtx7mhbXwlh4Xt6mR7HDw0qQh7LvyY=
|
||||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
github.com/go-openapi/jsonpointer v0.21.2 h1:AqQaNADVwq/VnkCmQg6ogE+M3FOsKTytwges0JdwVuA=
|
github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=
|
||||||
github.com/go-openapi/jsonpointer v0.21.2/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk=
|
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||||
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU=
|
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
|
||||||
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0=
|
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
|
||||||
|
github.com/go-openapi/jsonpointer v0.22.0 h1:TmMhghgNef9YXxTu1tOopo+0BGEytxA+okbry0HjZsM=
|
||||||
|
github.com/go-openapi/jsonpointer v0.22.0/go.mod h1:xt3jV88UtExdIkkL7NloURjRQjbeUgcxFblMjq2iaiU=
|
||||||
|
github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k=
|
||||||
|
github.com/go-openapi/swag/jsonname v0.24.0/go.mod h1:GXqrPzGJe611P7LG4QB9JKPtUZ7flE4DOVechNaDd7Q=
|
||||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||||
@@ -49,11 +59,14 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
|||||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||||
|
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||||
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
|
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
|
||||||
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
|
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
|
||||||
|
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
||||||
|
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||||
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||||
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||||
@@ -78,8 +91,6 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
|||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/josephburnett/jd v1.9.2 h1:ECJRRFXCCqbtidkAHckHGSZm/JIaAxS1gygHLF8MI5Y=
|
github.com/josephburnett/jd v1.9.2 h1:ECJRRFXCCqbtidkAHckHGSZm/JIaAxS1gygHLF8MI5Y=
|
||||||
github.com/josephburnett/jd v1.9.2/go.mod h1:bImDr8QXpxMb3SD+w1cDRHp97xP6UwI88xUAuxwDQfM=
|
github.com/josephburnett/jd v1.9.2/go.mod h1:bImDr8QXpxMb3SD+w1cDRHp97xP6UwI88xUAuxwDQfM=
|
||||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
|
||||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
@@ -90,15 +101,12 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
|||||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
|
|
||||||
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
|
||||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
|
||||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
|
||||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
|
||||||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||||
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
||||||
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||||
|
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
|
||||||
|
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
|
||||||
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
||||||
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
@@ -116,34 +124,30 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
|||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
|
||||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
|
||||||
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4 h1:SvVjZyjXBOjqjCdMiC9ndyWb709aP5qU4Qbun40GCxA=
|
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4 h1:SvVjZyjXBOjqjCdMiC9ndyWb709aP5qU4Qbun40GCxA=
|
||||||
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4/go.mod h1:Mpa6Hci7lO3vybfdYlWXmH5gEq2vyOmYYjhrlwCTW3w=
|
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4/go.mod h1:Mpa6Hci7lO3vybfdYlWXmH5gEq2vyOmYYjhrlwCTW3w=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
|
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
|
||||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
|
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
|
||||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
|
||||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6 h1:WCZxu77OR9yzKGZugQC1dHhslXROOJT+UL5JCtJbBq8=
|
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6 h1:WCZxu77OR9yzKGZugQC1dHhslXROOJT+UL5JCtJbBq8=
|
||||||
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6/go.mod h1:+pmkMFDEXJuu/u4h2OYJVfYF2qIhXJD7kqvWq6q5Zo0=
|
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6/go.mod h1:+pmkMFDEXJuu/u4h2OYJVfYF2qIhXJD7kqvWq6q5Zo0=
|
||||||
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981 h1:sLILANWN76ja66/K4k/mBqJuCjDZaM67w+Ru6rEB0s0=
|
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981 h1:sLILANWN76ja66/K4k/mBqJuCjDZaM67w+Ru6rEB0s0=
|
||||||
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981/go.mod h1:Rx8XB1ck+so+41uu9VY1gMKs1CPQ2NTq0pzf+OCCQHo=
|
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981/go.mod h1:Rx8XB1ck+so+41uu9VY1gMKs1CPQ2NTq0pzf+OCCQHo=
|
||||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
|
|
||||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
go.senan.xyz/flagconf v0.1.9 h1:LBDmqiVFgijfqFXDzH97gPn0qDbg1Dq6/vxsxS/TzC4=
|
go.senan.xyz/flagconf v0.1.9 h1:LBDmqiVFgijfqFXDzH97gPn0qDbg1Dq6/vxsxS/TzC4=
|
||||||
go.senan.xyz/flagconf v0.1.9/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
|
go.senan.xyz/flagconf v0.1.9/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
|
||||||
go.senan.xyz/wrtag v0.16.0 h1:Txcl4OXwfLe5PO7agfRGaRD00GLji5wn9qwLFD/aR1E=
|
go.senan.xyz/wrtag v0.17.1 h1:QC40z0rRAZ8zjIwwIrFIhldviP9cW0Jpe9EDh5Bt2J8=
|
||||||
go.senan.xyz/wrtag v0.16.0/go.mod h1:XAbiIGbf0DP22RcQBW1n1KeeUTGQU9B6k5A6CGw2j4A=
|
go.senan.xyz/wrtag v0.17.1/go.mod h1:rrC+QaFcZACW/hcsZpQj6kTh69rjhxIoePk3MZG3/rA=
|
||||||
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
@@ -213,6 +217,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
|||||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||||
|
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
|
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
@@ -243,7 +249,6 @@ gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7
|
|||||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
|
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 h1:6YFJoB+0fUH6X3xU/G2tQqCYg+PkGtnZ5nMR5rpw72g=
|
|
||||||
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:OxvTsCwKosqQ1q7B+8FwXqg4rKZ/UG9dUW+g/VL2xH4=
|
|
||||||
+227
@@ -0,0 +1,227 @@
|
|||||||
|
package ldap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.senan.xyz/gonic/db"
|
||||||
|
|
||||||
|
"github.com/go-ldap/ldap/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
//nolint:gochecknoglobals
|
||||||
|
var ldapStore = make(LDAPStore)
|
||||||
|
|
||||||
|
// LDAPStore maps users to a cached password
|
||||||
|
type LDAPStore map[string]CachedLDAPpassword
|
||||||
|
|
||||||
|
// Add caches a password username set.
|
||||||
|
func (store LDAPStore) Add(username, password string) {
|
||||||
|
store[username] = CachedLDAPpassword{
|
||||||
|
Password: password,
|
||||||
|
ExpiresAt: time.Now().Add(time.Hour * 8), // Keep the password valid for 8 hours.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsValid checks if a user's password is stored in the cache and checks if a
|
||||||
|
// given password is valid.
|
||||||
|
func (store LDAPStore) IsValid(username, password string) bool {
|
||||||
|
cached, ok := store[username]
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if cached.Password != password {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return cached.IsValid()
|
||||||
|
}
|
||||||
|
|
||||||
|
// CachedLDAPpassword stores an LDAP user's password and a time at which the
|
||||||
|
// server should no longer accept it.
|
||||||
|
type CachedLDAPpassword struct {
|
||||||
|
Password string
|
||||||
|
ExpiresAt time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (password CachedLDAPpassword) IsValid() bool {
|
||||||
|
return password.ExpiresAt.After(time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cofig stores the user's LDAP server options.
|
||||||
|
type Config struct {
|
||||||
|
BindUser string
|
||||||
|
BindPass string
|
||||||
|
BaseDN string
|
||||||
|
|
||||||
|
Filter string
|
||||||
|
AdminFilter string
|
||||||
|
|
||||||
|
FQDN string
|
||||||
|
Port uint
|
||||||
|
TLS bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Config) IsSetup() bool {
|
||||||
|
// This is basically checking if LDAP is setup, if ldapFQDN isn't set we can
|
||||||
|
// assume that the user hasn't configured LDAP.
|
||||||
|
return c.FQDN != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckLDAPcreds(username string, password string, dbc *db.DB, config Config) (bool, error) {
|
||||||
|
if !config.IsSetup() {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if ldapStore.IsValid(username, password) {
|
||||||
|
log.Println("Password authenticated via cache!")
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("Checking password against LDAP server ...")
|
||||||
|
|
||||||
|
// Now, we can try to connect to the LDAP server.
|
||||||
|
l, err := createLDAPconnection(config)
|
||||||
|
if err != nil {
|
||||||
|
// Return a generic error.
|
||||||
|
log.Println("Failed to connect to LDAP server:", err)
|
||||||
|
return false, errors.New("failed to connect to LDAP server")
|
||||||
|
}
|
||||||
|
defer l.Close()
|
||||||
|
|
||||||
|
// Create the user if it doesn't exist on the database already.
|
||||||
|
err = createUserFromLDAP(username, dbc, config, l)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to create user from LDAP:", err)
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// After we have a connection, let's try binding
|
||||||
|
_, err = l.SimpleBind(&ldap.SimpleBindRequest{
|
||||||
|
Username: fmt.Sprintf("uid=%s,%s", username, config.BaseDN),
|
||||||
|
Password: password,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
// Authentication was OK
|
||||||
|
ldapStore.Add(username, password)
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("Failed to bind to LDAP server:", err)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creates a user from creds
|
||||||
|
func createUserFromLDAP(username string, dbc *db.DB, config Config, l *ldap.Conn) error {
|
||||||
|
user := dbc.GetUserByName(username)
|
||||||
|
if user != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if !config.IsSetup() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
isAdmin := doesLDAPAdminExist(username, config, l)
|
||||||
|
log.Println(username, isAdmin)
|
||||||
|
|
||||||
|
if !doesLDAPUserExist(username, config, l) {
|
||||||
|
return errors.New("no such user")
|
||||||
|
}
|
||||||
|
|
||||||
|
newUser := db.User{
|
||||||
|
Name: username,
|
||||||
|
Password: "", // no password because we want auth to fail.
|
||||||
|
IsAdmin: isAdmin,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := dbc.Create(&newUser).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("User created via LDAP:", username)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// doesLDAPAdminExist checks if an admin exists on the server.
|
||||||
|
func doesLDAPAdminExist(username string, config Config, l *ldap.Conn) bool {
|
||||||
|
filter := fmt.Sprintf("(&(uid=%s)%s)", ldap.EscapeFilter(username), config.AdminFilter)
|
||||||
|
|
||||||
|
searchReq := ldap.NewSearchRequest(
|
||||||
|
config.BaseDN,
|
||||||
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
|
filter,
|
||||||
|
[]string{"dn"},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
|
||||||
|
result, err := l.Search(searchReq)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("failed to query LDAP server:", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result.Entries) == 1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// doesLDAPUserExist checks if a user exists on the server.
|
||||||
|
func doesLDAPUserExist(username string, config Config, l *ldap.Conn) bool {
|
||||||
|
filter := fmt.Sprintf("(&(uid=%s)%s)", ldap.EscapeFilter(username), config.Filter)
|
||||||
|
|
||||||
|
searchReq := ldap.NewSearchRequest(
|
||||||
|
config.BaseDN,
|
||||||
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
|
filter,
|
||||||
|
[]string{"dn"},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
|
||||||
|
result, err := l.Search(searchReq)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("failed to query LDAP server:", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result.Entries) == 1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creates a connection to an LDAP server.
|
||||||
|
func createLDAPconnection(config Config) (*ldap.Conn, error) {
|
||||||
|
protocol := "ldap"
|
||||||
|
if config.TLS {
|
||||||
|
protocol = "ldaps"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now, we can try to connect to the LDAP server.
|
||||||
|
l, err := ldap.DialURL(fmt.Sprintf("%s://%s:%d", protocol, config.FQDN, config.Port))
|
||||||
|
if err != nil {
|
||||||
|
// Warn the server and return the error.
|
||||||
|
log.Println("Failed to connect to LDAP server", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// After we have a connection, let's try binding
|
||||||
|
_, err = l.SimpleBind(&ldap.SimpleBindRequest{
|
||||||
|
Username: fmt.Sprintf("uid=%s,%s", config.BindUser, config.BaseDN),
|
||||||
|
Password: config.BindPass,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to bind to LDAP:", err)
|
||||||
|
return nil, errors.New("wrong username or password")
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, nil
|
||||||
|
}
|
||||||
+5
-4
@@ -116,12 +116,12 @@ func (m *MockFS) AddItemsWithCovers() { m.addItems("", "", tr
|
|||||||
func (m *MockFS) AddItemsPrefixWithCovers(prefix string) { m.addItems(prefix, "", true) }
|
func (m *MockFS) AddItemsPrefixWithCovers(prefix string) { m.addItems(prefix, "", true) }
|
||||||
|
|
||||||
func (m *MockFS) addItems(prefix string, onlyGlob string, covers bool) {
|
func (m *MockFS) addItems(prefix string, onlyGlob string, covers bool) {
|
||||||
p := func(format string, a ...interface{}) string {
|
p := func(format string, a ...any) string {
|
||||||
return filepath.Join(prefix, fmt.Sprintf(format, a...))
|
return filepath.Join(prefix, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
for ar := 0; ar < 3; ar++ {
|
for ar := range 3 {
|
||||||
for al := 0; al < 3; al++ {
|
for al := range 3 {
|
||||||
for tr := 0; tr < 3; tr++ {
|
for tr := range 3 {
|
||||||
path := p("artist-%d/album-%d/track-%d.flac", ar, al, tr)
|
path := p("artist-%d/album-%d/track-%d.flac", ar, al, tr)
|
||||||
if !match(onlyGlob, path) {
|
if !match(onlyGlob, path) {
|
||||||
continue
|
continue
|
||||||
@@ -362,6 +362,7 @@ func (i *TagInfo) Genres() []string { return []string{i.RawGenre} }
|
|||||||
func (i *TagInfo) TrackNumber() int { return 1 }
|
func (i *TagInfo) TrackNumber() int { return 1 }
|
||||||
func (i *TagInfo) DiscNumber() int { return 1 }
|
func (i *TagInfo) DiscNumber() int { return 1 }
|
||||||
func (i *TagInfo) Year() int { return 2021 }
|
func (i *TagInfo) Year() int { return 2021 }
|
||||||
|
func (i *TagInfo) Lyrics() string { return "[00:01.58] Line one\n[00:03.44] Line two\n" }
|
||||||
|
|
||||||
func (i *TagInfo) Compilation() bool { return false }
|
func (i *TagInfo) Compilation() bool { return false }
|
||||||
func (i *TagInfo) ReleaseType() string { return "album" }
|
func (i *TagInfo) ReleaseType() string { return "album" }
|
||||||
|
|||||||
@@ -468,6 +468,7 @@ func populateTrack(tx *db.DB, album *db.Album, track *db.Track, trags tagcommon.
|
|||||||
track.FilenameUDec = decoded(basename)
|
track.FilenameUDec = decoded(basename)
|
||||||
track.Size = size
|
track.Size = size
|
||||||
track.AlbumID = album.ID
|
track.AlbumID = album.ID
|
||||||
|
track.TagLyrics = trags.Lyrics()
|
||||||
|
|
||||||
track.TagTitle = trags.Title()
|
track.TagTitle = trags.Title()
|
||||||
track.TagTitleUDec = decoded(trags.Title())
|
track.TagTitleUDec = decoded(trags.Title())
|
||||||
|
|||||||
@@ -9,21 +9,20 @@ import (
|
|||||||
|
|
||||||
func BenchmarkScanIncremental(b *testing.B) {
|
func BenchmarkScanIncremental(b *testing.B) {
|
||||||
m := mockfs.New(b)
|
m := mockfs.New(b)
|
||||||
for i := 0; i < 5; i++ {
|
for i := range 5 {
|
||||||
m.AddItemsPrefix(fmt.Sprintf("t-%d", i))
|
m.AddItemsPrefix(fmt.Sprintf("t-%d", i))
|
||||||
}
|
}
|
||||||
m.ScanAndClean()
|
m.ScanAndClean()
|
||||||
b.ResetTimer()
|
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
m.ScanAndClean()
|
m.ScanAndClean()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkScanFull(b *testing.B) {
|
func BenchmarkScanFull(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for b.Loop() {
|
||||||
m := mockfs.New(b)
|
m := mockfs.New(b)
|
||||||
for i := 0; i < 5; i++ {
|
for i := range 5 {
|
||||||
m.AddItemsPrefix(fmt.Sprintf("t-%d", i))
|
m.AddItemsPrefix(fmt.Sprintf("t-%d", i))
|
||||||
}
|
}
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func FuzzScanner(f *testing.F) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func fuzzStruct(taken int, data []byte, seed int64, dest interface{}) {
|
func fuzzStruct(taken int, data []byte, seed int64, dest any) {
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ func TestNewAlbumForExistingArtist(t *testing.T) {
|
|||||||
assert.NoError(t, m.DB().Where("name=?", "artist-2").Find(&artist).Error) // find orig artist
|
assert.NoError(t, m.DB().Where("name=?", "artist-2").Find(&artist).Error) // find orig artist
|
||||||
assert.Greater(t, artist.ID, 0)
|
assert.Greater(t, artist.ID, 0)
|
||||||
|
|
||||||
for tr := 0; tr < 3; tr++ {
|
for tr := range 3 {
|
||||||
m.AddTrack(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr))
|
m.AddTrack(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr))
|
||||||
m.SetTags(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr), func(tags *mockfs.TagInfo) {
|
m.SetTags(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr), func(tags *mockfs.TagInfo) {
|
||||||
tags.RawArtist = "artist-2"
|
tags.RawArtist = "artist-2"
|
||||||
@@ -552,7 +552,7 @@ func TestCompilationAlbumWithoutAlbumArtist(t *testing.T) {
|
|||||||
const toAdd = 5
|
const toAdd = 5
|
||||||
|
|
||||||
// add tracks to one folder with random artists and no album artist tag
|
// add tracks to one folder with random artists and no album artist tag
|
||||||
for i := 0; i < toAdd; i++ {
|
for i := range toAdd {
|
||||||
p := fmt.Sprintf("%s/%s/track-%d.flac", pathArtist, pathAlbum, i)
|
p := fmt.Sprintf("%s/%s/track-%d.flac", pathArtist, pathAlbum, i)
|
||||||
m.AddTrack(p)
|
m.AddTrack(p)
|
||||||
m.SetTags(p, func(tags *mockfs.TagInfo) {
|
m.SetTags(p, func(tags *mockfs.TagInfo) {
|
||||||
@@ -605,7 +605,7 @@ func TestAlbumAndArtistSameNameWeirdness(t *testing.T) {
|
|||||||
|
|
||||||
const name = "same"
|
const name = "same"
|
||||||
|
|
||||||
add := func(path string, a ...interface{}) {
|
add := func(path string, a ...any) {
|
||||||
m.AddTrack(fmt.Sprintf(path, a...))
|
m.AddTrack(fmt.Sprintf(path, a...))
|
||||||
m.SetTags(fmt.Sprintf(path, a...), func(tags *mockfs.TagInfo) {})
|
m.SetTags(fmt.Sprintf(path, a...), func(tags *mockfs.TagInfo) {})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import (
|
|||||||
"go.senan.xyz/gonic/db"
|
"go.senan.xyz/gonic/db"
|
||||||
"go.senan.xyz/gonic/handlerutil"
|
"go.senan.xyz/gonic/handlerutil"
|
||||||
"go.senan.xyz/gonic/lastfm"
|
"go.senan.xyz/gonic/lastfm"
|
||||||
|
"go.senan.xyz/gonic/ldap"
|
||||||
"go.senan.xyz/gonic/podcast"
|
"go.senan.xyz/gonic/podcast"
|
||||||
"go.senan.xyz/gonic/scanner"
|
"go.senan.xyz/gonic/scanner"
|
||||||
"go.senan.xyz/gonic/server/ctrladmin/adminui"
|
"go.senan.xyz/gonic/server/ctrladmin/adminui"
|
||||||
@@ -48,11 +49,12 @@ type Controller struct {
|
|||||||
podcasts *podcast.Podcasts
|
podcasts *podcast.Podcasts
|
||||||
lastfmClient *lastfm.Client
|
lastfmClient *lastfm.Client
|
||||||
resolveProxyPath ProxyPathResolver
|
resolveProxyPath ProxyPathResolver
|
||||||
|
ldapConfig ldap.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProxyPathResolver func(in string) string
|
type ProxyPathResolver func(in string) string
|
||||||
|
|
||||||
func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts *podcast.Podcasts, lastfmClient *lastfm.Client, resolveProxyPath ProxyPathResolver) (*Controller, error) {
|
func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts *podcast.Podcasts, lastfmClient *lastfm.Client, resolveProxyPath ProxyPathResolver, ldapConfig ldap.Config) (*Controller, error) {
|
||||||
c := Controller{
|
c := Controller{
|
||||||
ServeMux: http.NewServeMux(),
|
ServeMux: http.NewServeMux(),
|
||||||
|
|
||||||
@@ -62,6 +64,7 @@ func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts
|
|||||||
podcasts: podcasts,
|
podcasts: podcasts,
|
||||||
lastfmClient: lastfmClient,
|
lastfmClient: lastfmClient,
|
||||||
resolveProxyPath: resolveProxyPath,
|
resolveProxyPath: resolveProxyPath,
|
||||||
|
ldapConfig: ldapConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := respHandler(adminui.TemplatesFS, resolveProxyPath)
|
resp := respHandler(adminui.TemplatesFS, resolveProxyPath)
|
||||||
@@ -271,7 +274,7 @@ func respRaw(h http.HandlerFunc) http.Handler {
|
|||||||
|
|
||||||
type templateData struct {
|
type templateData struct {
|
||||||
// common
|
// common
|
||||||
Flashes []interface{}
|
Flashes []any
|
||||||
User *db.User
|
User *db.User
|
||||||
Version string
|
Version string
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,48 @@
|
|||||||
package ctrladmin
|
package ctrladmin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
|
"go.senan.xyz/gonic/ldap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
|
func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
|
||||||
session := r.Context().Value(CtxSession).(*sessions.Session)
|
session := r.Context().Value(CtxSession).(*sessions.Session)
|
||||||
username := r.FormValue("username")
|
username := r.FormValue("username")
|
||||||
password := r.FormValue("password")
|
password := r.FormValue("password")
|
||||||
|
user := c.dbc.GetUserByName(username)
|
||||||
if username == "" || password == "" {
|
if username == "" || password == "" {
|
||||||
sessAddFlashW(session, []string{"please provide username and password"})
|
sessAddFlashW(session, []string{"please provide username and password"})
|
||||||
sessLogSave(session, w, r)
|
sessLogSave(session, w, r)
|
||||||
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
|
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user := c.dbc.GetUserByName(username)
|
|
||||||
if user == nil || password != user.Password {
|
if c.ldapConfig.IsSetup() {
|
||||||
|
ok, err := ldap.CheckLDAPcreds(username, password, c.dbc, c.ldapConfig)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to check LDAP credentials:", err)
|
||||||
|
sessAddFlashW(session, []string{"failed to check LDAP credentials"})
|
||||||
|
sessLogSave(session, w, r)
|
||||||
|
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
|
||||||
|
return
|
||||||
|
} else if !ok {
|
||||||
sessAddFlashW(session, []string{"invalid username / password"})
|
sessAddFlashW(session, []string{"invalid username / password"})
|
||||||
sessLogSave(session, w, r)
|
sessLogSave(session, w, r)
|
||||||
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
|
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if user == nil || user.Password != password {
|
||||||
|
sessAddFlashW(session, []string{"invalid username / password"})
|
||||||
|
sessLogSave(session, w, r)
|
||||||
|
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
user = c.dbc.GetUserByName(username)
|
||||||
|
|
||||||
// put the user name into the session. future endpoints after this one
|
// put the user name into the session. future endpoints after this one
|
||||||
// are wrapped with WithUserSession() which will get the name from the
|
// are wrapped with WithUserSession() which will get the name from the
|
||||||
// session and put the row into the request context
|
// session and put the row into the request context
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.senan.xyz/gonic/db"
|
"go.senan.xyz/gonic/db"
|
||||||
@@ -18,6 +19,7 @@ import (
|
|||||||
"go.senan.xyz/gonic/infocache/artistinfocache"
|
"go.senan.xyz/gonic/infocache/artistinfocache"
|
||||||
"go.senan.xyz/gonic/jukebox"
|
"go.senan.xyz/gonic/jukebox"
|
||||||
"go.senan.xyz/gonic/lastfm"
|
"go.senan.xyz/gonic/lastfm"
|
||||||
|
"go.senan.xyz/gonic/ldap"
|
||||||
"go.senan.xyz/gonic/playlist"
|
"go.senan.xyz/gonic/playlist"
|
||||||
"go.senan.xyz/gonic/podcast"
|
"go.senan.xyz/gonic/podcast"
|
||||||
"go.senan.xyz/gonic/scanner"
|
"go.senan.xyz/gonic/scanner"
|
||||||
@@ -69,7 +71,7 @@ type Controller struct {
|
|||||||
resolveProxyPath ProxyPathResolver
|
resolveProxyPath ProxyPathResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPath string, cacheAudioPath string, cacheCoverPath string, jukebox *jukebox.Jukebox, playlistStore *playlist.Store, scrobblers []scrobble.Scrobbler, podcasts *podcast.Podcasts, transcoder transcode.Transcoder, lastFMClient *lastfm.Client, artistInfoCache *artistinfocache.ArtistInfoCache, albumInfoCache *albuminfocache.AlbumInfoCache, resolveProxyPath ProxyPathResolver) (*Controller, error) {
|
func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPath string, cacheAudioPath string, cacheCoverPath string, jukebox *jukebox.Jukebox, playlistStore *playlist.Store, scrobblers []scrobble.Scrobbler, podcasts *podcast.Podcasts, transcoder transcode.Transcoder, lastFMClient *lastfm.Client, artistInfoCache *artistinfocache.ArtistInfoCache, albumInfoCache *albuminfocache.AlbumInfoCache, resolveProxyPath ProxyPathResolver, ldapConfig ldap.Config) (*Controller, error) {
|
||||||
c := Controller{
|
c := Controller{
|
||||||
ServeMux: http.NewServeMux(),
|
ServeMux: http.NewServeMux(),
|
||||||
|
|
||||||
@@ -93,7 +95,7 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPa
|
|||||||
chain := handlerutil.Chain(
|
chain := handlerutil.Chain(
|
||||||
withParams,
|
withParams,
|
||||||
withRequiredParams,
|
withRequiredParams,
|
||||||
withUser(dbc),
|
withUser(dbc, ldapConfig),
|
||||||
)
|
)
|
||||||
chainRaw := handlerutil.Chain(
|
chainRaw := handlerutil.Chain(
|
||||||
chain,
|
chain,
|
||||||
@@ -127,6 +129,7 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPa
|
|||||||
c.Handle("/getSimilarSongs", chain(resp(c.ServeGetSimilarSongs)))
|
c.Handle("/getSimilarSongs", chain(resp(c.ServeGetSimilarSongs)))
|
||||||
c.Handle("/getSimilarSongs2", chain(resp(c.ServeGetSimilarSongsTwo)))
|
c.Handle("/getSimilarSongs2", chain(resp(c.ServeGetSimilarSongsTwo)))
|
||||||
c.Handle("/getLyrics", chain(resp(c.ServeGetLyrics)))
|
c.Handle("/getLyrics", chain(resp(c.ServeGetLyrics)))
|
||||||
|
c.Handle("/getLyricsBySongId", chain(resp(c.ServeGetLyricsBySongID)))
|
||||||
|
|
||||||
// raw
|
// raw
|
||||||
c.Handle("/getCoverArt", chainRaw(respRaw(c.ServeGetCoverArt)))
|
c.Handle("/getCoverArt", chainRaw(respRaw(c.ServeGetCoverArt)))
|
||||||
@@ -223,39 +226,82 @@ func withRequiredParams(next http.Handler) http.Handler {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUser(dbc *db.DB) handlerutil.Middleware {
|
func withUser(dbc *db.DB, ldapConfig ldap.Config) handlerutil.Middleware {
|
||||||
return func(next http.Handler) http.Handler {
|
return func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
params := r.Context().Value(CtxParams).(params.Params)
|
params := r.Context().Value(CtxParams).(params.Params)
|
||||||
// ignoring errors here, a middleware has already ensured they exist
|
// ignoring errors here, a middleware has already ensured they exist
|
||||||
username, _ := params.Get("u")
|
username, _ := params.Get("u")
|
||||||
password, _ := params.Get("p")
|
passwordHex, _ := params.Get("p")
|
||||||
token, _ := params.Get("t")
|
token, _ := params.Get("t")
|
||||||
salt, _ := params.Get("s")
|
salt, _ := params.Get("s")
|
||||||
|
|
||||||
passwordAuth := token == "" && salt == ""
|
passwordAuth := token == "" && salt == ""
|
||||||
tokenAuth := password == ""
|
tokenAuth := passwordHex == ""
|
||||||
if tokenAuth == passwordAuth {
|
if tokenAuth == passwordAuth {
|
||||||
_ = writeResp(w, r, spec.NewError(10,
|
_ = writeResp(w, r, spec.NewError(10,
|
||||||
"please provide `t` and `s`, or just `p`"))
|
"please provide `t` and `s`, or just `p`"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user := dbc.GetUserByName(username)
|
|
||||||
if user == nil {
|
var password string
|
||||||
_ = writeResp(w, r, spec.NewError(40,
|
if passwordAuth && passwordHex != "" {
|
||||||
"invalid username %q", username))
|
if strings.HasPrefix(passwordHex, "enc:") {
|
||||||
|
raw := strings.TrimPrefix(passwordHex, "enc:")
|
||||||
|
decoded, err := hex.DecodeString(raw)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to decode hex password:", err)
|
||||||
|
_ = writeResp(w, r, spec.NewError(40, "invalid password encoding"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
password = string(decoded)
|
||||||
|
} else {
|
||||||
|
// if not prefixed with "enc:", treat as plain text
|
||||||
|
password = passwordHex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
user := dbc.GetUserByName(username)
|
||||||
|
|
||||||
|
if ldapConfig.IsSetup() {
|
||||||
|
// Complete auth using LDAP
|
||||||
|
log.Println("Authenticating using LDAP ...")
|
||||||
|
|
||||||
|
ok, err := ldap.CheckLDAPcreds(username, password, dbc, ldapConfig)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to check LDAP creds:", err)
|
||||||
|
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
withUser := context.WithValue(r.Context(), CtxUser, user)
|
||||||
|
next.ServeHTTP(w, r.WithContext(withUser))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("Authenticating using built-in ...")
|
||||||
|
if user == nil {
|
||||||
|
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var credsOk bool
|
var credsOk bool
|
||||||
if tokenAuth {
|
if tokenAuth {
|
||||||
credsOk = checkCredsToken(user.Password, token, salt)
|
credsOk = checkCredsToken(user.Password, token, salt)
|
||||||
} else {
|
} else {
|
||||||
credsOk = checkCredsBasic(user.Password, password)
|
credsOk = checkCredsBasic(user.Password, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !credsOk {
|
if !credsOk {
|
||||||
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
|
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
withUser := context.WithValue(r.Context(), CtxUser, user)
|
withUser := context.WithValue(r.Context(), CtxUser, user)
|
||||||
next.ServeHTTP(w, r.WithContext(withUser))
|
next.ServeHTTP(w, r.WithContext(withUser))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ func makeHTTPMockWithAdmin(query url.Values) (*httptest.ResponseRecorder, *http.
|
|||||||
func runQueryCases(t *testing.T, h handlerSubsonic, cases []*queryCase) {
|
func runQueryCases(t *testing.T, h handlerSubsonic, cases []*queryCase) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
for _, qc := range cases {
|
for _, qc := range cases {
|
||||||
qc := qc
|
|
||||||
t.Run(qc.expectPath, func(t *testing.T) {
|
t.Run(qc.expectPath, func(t *testing.T) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func (c *Controller) ServeGetMusicDirectory(r *http.Request) *spec.Response {
|
|||||||
Preload("Artists").
|
Preload("Artists").
|
||||||
Preload("TrackStar", "user_id=?", user.ID).
|
Preload("TrackStar", "user_id=?", user.ID).
|
||||||
Preload("TrackRating", "user_id=?", user.ID).
|
Preload("TrackRating", "user_id=?", user.ID).
|
||||||
Order("tag_track_number").
|
Order("tracks.tag_disc_number, tracks.tag_track_number").
|
||||||
Order("filename").
|
Order("filename").
|
||||||
Find(&childTracks)
|
Find(&childTracks)
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
|
"github.com/env25/mpdlrc/lrc"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ func (c *Controller) ServeGetOpenSubsonicExtensions(_ *http.Request) *spec.Respo
|
|||||||
sub.OpenSubsonicExtensions = &spec.OpenSubsonicExtensions{
|
sub.OpenSubsonicExtensions = &spec.OpenSubsonicExtensions{
|
||||||
{Name: "transcodeOffset", Versions: []int{1}},
|
{Name: "transcodeOffset", Versions: []int{1}},
|
||||||
{Name: "formPost", Versions: []int{1}},
|
{Name: "formPost", Versions: []int{1}},
|
||||||
|
{Name: "songLyrics", Versions: []int{1}},
|
||||||
}
|
}
|
||||||
return sub
|
return sub
|
||||||
}
|
}
|
||||||
@@ -349,7 +352,7 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
|
|||||||
return sub
|
return sub
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNotATrack = errors.New("not a track")
|
var errUnknownPlaylistEntry = errors.New("unknown playlist entry")
|
||||||
|
|
||||||
func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:gocyclo
|
func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:gocyclo
|
||||||
if c.jukebox == nil {
|
if c.jukebox == nil {
|
||||||
@@ -391,11 +394,16 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("fetch track: %w", err)
|
return nil, fmt.Errorf("fetch track: %w", err)
|
||||||
}
|
}
|
||||||
track, ok := file.(*db.Track)
|
switch f := file.(type) {
|
||||||
if !ok {
|
case *db.Track:
|
||||||
return nil, fmt.Errorf("%q: %w", path, errNotATrack)
|
ret = append(ret, spec.NewTrackByTags(f, f.Album))
|
||||||
|
case *db.InternetRadioStation:
|
||||||
|
ret = append(ret, spec.NewTCInternetRadioStation(f))
|
||||||
|
case *db.PodcastEpisode:
|
||||||
|
ret = append(ret, spec.NewTCPodcastEpisode(f))
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("%q: %w", path, errUnknownPlaylistEntry)
|
||||||
}
|
}
|
||||||
ret = append(ret, spec.NewTrackByTags(track, track.Album))
|
|
||||||
}
|
}
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
@@ -482,10 +490,153 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
|
|||||||
return sub
|
return sub
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) ServeGetLyrics(_ *http.Request) *spec.Response {
|
func (c *Controller) ServeGetLyrics(r *http.Request) *spec.Response {
|
||||||
|
params := r.Context().Value(CtxParams).(params.Params)
|
||||||
|
artist, _ := params.Get("artist")
|
||||||
|
title, _ := params.Get("title")
|
||||||
|
|
||||||
|
var track db.Track
|
||||||
|
err := c.dbc.
|
||||||
|
Preload("Album").
|
||||||
|
Joins("JOIN track_artists ON track_artists.track_id = tracks.id").
|
||||||
|
Joins("JOIN artists ON artists.id = track_artists.artist_id").
|
||||||
|
Where("tracks.tag_title LIKE ? AND artists.name LIKE ?", title, artist).
|
||||||
|
First(&track).
|
||||||
|
Error
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return spec.NewError(70, "couldn't find a track with that id")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return spec.NewError(0, "lyrics: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
sub := spec.NewResponse()
|
sub := spec.NewResponse()
|
||||||
sub.Lyrics = &spec.Lyrics{}
|
|
||||||
|
if track.TagLyrics != "" {
|
||||||
|
sub.Lyrics = &spec.Lyrics{
|
||||||
|
Value: track.TagLyrics,
|
||||||
|
Artist: track.TagTrackArtist,
|
||||||
|
Title: track.TagTitle,
|
||||||
|
}
|
||||||
return sub
|
return sub
|
||||||
|
}
|
||||||
|
|
||||||
|
_, text, err := lyricsFile(track)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return sub
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return spec.NewError(0, "lyricsFile: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
contents := strings.Join(text, "\n")
|
||||||
|
|
||||||
|
sub.Lyrics = &spec.Lyrics{
|
||||||
|
Value: contents,
|
||||||
|
Artist: track.TagTrackArtist,
|
||||||
|
Title: track.TagTitle,
|
||||||
|
}
|
||||||
|
return sub
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Controller) ServeGetLyricsBySongID(r *http.Request) *spec.Response {
|
||||||
|
params := r.Context().Value(CtxParams).(params.Params)
|
||||||
|
id, err := params.GetID("id")
|
||||||
|
if err != nil {
|
||||||
|
return spec.NewError(10, "provide an `id` parameter")
|
||||||
|
}
|
||||||
|
|
||||||
|
var track db.Track
|
||||||
|
q := c.dbc.
|
||||||
|
Preload("Album").
|
||||||
|
Preload("Album.Artists").
|
||||||
|
Preload("Artists").
|
||||||
|
Where("id=?", id.Value).
|
||||||
|
First(&track)
|
||||||
|
if err := q.Error; err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return spec.NewError(70, "couldn't find a track with that id")
|
||||||
|
} else {
|
||||||
|
return spec.NewError(0, "lyrics: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub := spec.NewResponse()
|
||||||
|
|
||||||
|
if track.TagLyrics != "" {
|
||||||
|
times, lrc, err := lrc.ParseString(track.TagLyrics)
|
||||||
|
if err != nil {
|
||||||
|
return spec.NewError(0, "lyricsFile: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
lines := make([]spec.Lyric, len(times))
|
||||||
|
for i, time := range times {
|
||||||
|
lines[i] = spec.Lyric{
|
||||||
|
Start: time.Milliseconds(),
|
||||||
|
Value: strings.TrimSpace(lrc[i]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
structured := spec.StructuredLyrics{
|
||||||
|
Lang: "xxx",
|
||||||
|
Synced: true,
|
||||||
|
Lines: lines,
|
||||||
|
DisplayArtist: track.TagTrackArtist,
|
||||||
|
DisplayTitle: track.TagTitle,
|
||||||
|
Offset: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
sub.LyricsList = &spec.LyricsList{
|
||||||
|
StructuredLyrics: []spec.StructuredLyrics{structured},
|
||||||
|
}
|
||||||
|
return sub
|
||||||
|
}
|
||||||
|
|
||||||
|
times, lrc, err := lyricsFile(track)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
sub.LyricsList = &spec.LyricsList{
|
||||||
|
StructuredLyrics: []spec.StructuredLyrics{},
|
||||||
|
}
|
||||||
|
return sub
|
||||||
|
}
|
||||||
|
return spec.NewError(0, "lyricsFile: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
lines := make([]spec.Lyric, len(times))
|
||||||
|
for i, time := range times {
|
||||||
|
lines[i] = spec.Lyric{
|
||||||
|
Start: time.Milliseconds(),
|
||||||
|
Value: strings.TrimSpace(lrc[i]),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
structured := spec.StructuredLyrics{
|
||||||
|
Lang: "xxx",
|
||||||
|
Synced: true,
|
||||||
|
Lines: lines,
|
||||||
|
DisplayArtist: track.TagTrackArtist,
|
||||||
|
DisplayTitle: track.TagTitle,
|
||||||
|
Offset: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
sub.LyricsList = &spec.LyricsList{
|
||||||
|
StructuredLyrics: []spec.StructuredLyrics{structured},
|
||||||
|
}
|
||||||
|
return sub
|
||||||
|
}
|
||||||
|
|
||||||
|
func lyricsFile(file db.Track) ([]lrc.Duration, []lrc.Text, error) {
|
||||||
|
filePath := file.AbsPath()
|
||||||
|
fileDir := filepath.Dir(filePath)
|
||||||
|
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
|
||||||
|
|
||||||
|
lrcContent, err := os.ReadFile(filepath.Join(fileDir, fileName+".lrc"))
|
||||||
|
if err != nil {
|
||||||
|
return []lrc.Duration{}, []lrc.Text{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return lrc.Parse(lrcContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func scrobbleStatsUpdateTrack(dbc *db.DB, track *db.Track, userID int, playTime time.Time) error {
|
func scrobbleStatsUpdateTrack(dbc *db.DB, track *db.Track, userID int, playTime time.Time) error {
|
||||||
|
|||||||
@@ -155,11 +155,9 @@ func coverScaleAndSave(reader io.Reader, cachePath string, size int) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("resizing: %w", err)
|
return fmt.Errorf("resizing: %w", err)
|
||||||
}
|
}
|
||||||
width := size
|
width := min(size,
|
||||||
if width > src.Bounds().Dx() {
|
|
||||||
// don't upscale images
|
// don't upscale images
|
||||||
width = src.Bounds().Dx()
|
src.Bounds().Dx())
|
||||||
}
|
|
||||||
if err := imaging.Save(imaging.Resize(src, width, 0, imaging.Lanczos), cachePath); err != nil {
|
if err := imaging.Save(imaging.Resize(src, width, 0, imaging.Lanczos), cachePath); err != nil {
|
||||||
return fmt.Errorf("caching %q: %w", cachePath, err)
|
return fmt.Errorf("caching %q: %w", cachePath, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ package params
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"maps"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -44,9 +45,7 @@ func New(r *http.Request) Params {
|
|||||||
params := r.URL.Query()
|
params := r.URL.Query()
|
||||||
// also if there's any in the post body, use those too
|
// also if there's any in the post body, use those too
|
||||||
if err := r.ParseForm(); err == nil {
|
if err := r.ParseForm(); err == nil {
|
||||||
for k, v := range r.Form {
|
maps.Copy(params, r.Form)
|
||||||
params[k] = v
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Params(params)
|
return Params(params)
|
||||||
}
|
}
|
||||||
@@ -389,7 +388,7 @@ func parseTime(in string) (time.Time, error) {
|
|||||||
return time.Unix(0, ns), nil
|
return time.Unix(0, ns), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parse(values []string, i interface{}) error {
|
func parse(values []string, i any) error {
|
||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
return ErrNoValues
|
return ErrNoValues
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,3 +10,13 @@ func NewInternetRadioStation(irs *db.InternetRadioStation) *InternetRadioStation
|
|||||||
HomepageURL: irs.HomepageURL,
|
HomepageURL: irs.HomepageURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewTCInternetRadioStation(irs *db.InternetRadioStation) *TrackChild {
|
||||||
|
return &TrackChild{
|
||||||
|
ID: irs.SID(),
|
||||||
|
Title: irs.Name,
|
||||||
|
IsDir: false,
|
||||||
|
IsVideo: false,
|
||||||
|
Type: "internetradio",
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,14 +2,15 @@ package spec
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
|
"github.com/microcosm-cc/bluemonday"
|
||||||
"go.senan.xyz/gonic"
|
"go.senan.xyz/gonic"
|
||||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||||
"jaytaylor.com/html2text"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://web.archive.org/web/20220707025402/https://www.subsonic.org/pages/api.jsp
|
// https://web.archive.org/web/20220707025402/https://www.subsonic.org/pages/api.jsp
|
||||||
@@ -70,6 +71,7 @@ type Response struct {
|
|||||||
SimilarSongsTwo *SimilarSongsTwo `xml:"similarSongs2" json:"similarSongs2,omitempty"`
|
SimilarSongsTwo *SimilarSongsTwo `xml:"similarSongs2" json:"similarSongs2,omitempty"`
|
||||||
InternetRadioStations *InternetRadioStations `xml:"internetRadioStations" json:"internetRadioStations,omitempty"`
|
InternetRadioStations *InternetRadioStations `xml:"internetRadioStations" json:"internetRadioStations,omitempty"`
|
||||||
Lyrics *Lyrics `xml:"lyrics" json:"lyrics,omitempty"`
|
Lyrics *Lyrics `xml:"lyrics" json:"lyrics,omitempty"`
|
||||||
|
LyricsList *LyricsList `xml:"lyricsList" json:"lyricsList,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewResponse() *Response {
|
func NewResponse() *Response {
|
||||||
@@ -100,7 +102,7 @@ type Error struct {
|
|||||||
Message string `xml:"message,attr" json:"message"`
|
Message string `xml:"message,attr" json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewError(code int, message string, a ...interface{}) *Response {
|
func NewError(code int, message string, a ...any) *Response {
|
||||||
r := NewResponse()
|
r := NewResponse()
|
||||||
r.Status = "failed"
|
r.Status = "failed"
|
||||||
r.Error = &Error{
|
r.Error = &Error{
|
||||||
@@ -126,7 +128,7 @@ type GenreRef struct {
|
|||||||
// https://opensubsonic.netlify.app/docs/responses/albumid3/
|
// https://opensubsonic.netlify.app/docs/responses/albumid3/
|
||||||
type Album struct {
|
type Album struct {
|
||||||
ID *specid.ID `xml:"id,attr,omitempty" json:"id"`
|
ID *specid.ID `xml:"id,attr,omitempty" json:"id"`
|
||||||
Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
|
Created time.Time `xml:"created,attr,omitempty" json:"created"`
|
||||||
|
|
||||||
// legacy or single tag mode
|
// legacy or single tag mode
|
||||||
ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
|
ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
|
||||||
@@ -199,7 +201,7 @@ type TrackChild struct {
|
|||||||
Bitrate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
|
Bitrate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
|
||||||
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
|
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
|
||||||
CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
|
CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
|
||||||
CreatedAt time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
|
CreatedAt time.Time `xml:"created,attr,omitempty" json:"created"`
|
||||||
Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
|
Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
|
||||||
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
|
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
|
||||||
Genres []*GenreRef `xml:"genres,omitempty" json:"genres,omitempty"`
|
Genres []*GenreRef `xml:"genres,omitempty" json:"genres,omitempty"`
|
||||||
@@ -474,6 +476,24 @@ type Lyrics struct {
|
|||||||
Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
|
Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Lyric struct {
|
||||||
|
Start int64 `xml:"start,attr" json:"start"`
|
||||||
|
Value string `xml:",chardata" json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LyricsList struct {
|
||||||
|
StructuredLyrics []StructuredLyrics `xml:"structuredLyrics" json:"structuredLyrics"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type StructuredLyrics struct {
|
||||||
|
Lang string `xml:"lang,attr" json:"lang"` // ISO 639 (or und, xxx if unknown)
|
||||||
|
Synced bool `xml:"synced,attr" json:"synced"`
|
||||||
|
Lines []Lyric `xml:"line" json:"line"`
|
||||||
|
DisplayArtist string `xml:"displayArtist,attr,omitempty" json:"displayArtist,omitempty"`
|
||||||
|
DisplayTitle string `xml:"displayTitle,attr,omitempty" json:"displayTitle,omitempty"`
|
||||||
|
Offset int `xml:"offset,attr,omitempty" json:"offset,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type OpenSubsonicExtension struct {
|
type OpenSubsonicExtension struct {
|
||||||
Name string `xml:"name,attr" json:"name"`
|
Name string `xml:"name,attr" json:"name"`
|
||||||
Versions []int `xml:"versions" json:"versions"`
|
Versions []int `xml:"versions" json:"versions"`
|
||||||
@@ -515,8 +535,11 @@ var doublePuncExpr = regexp.MustCompile(`\.\s+\.\s+`)
|
|||||||
var licenceExpr = regexp.MustCompile(`(?i)\buser-contributed text.*`)
|
var licenceExpr = regexp.MustCompile(`(?i)\buser-contributed text.*`)
|
||||||
var readMoreExpr = regexp.MustCompile(`(?i)\bread more on.*`)
|
var readMoreExpr = regexp.MustCompile(`(?i)\bread more on.*`)
|
||||||
|
|
||||||
|
var bluemondayPolicy = bluemonday.StrictPolicy() //nolint:gochecknoglobals
|
||||||
|
|
||||||
func CleanExternalText(text string) string {
|
func CleanExternalText(text string) string {
|
||||||
text, _ = html2text.FromString(text, html2text.Options{TextOnly: true})
|
text = bluemondayPolicy.Sanitize(text)
|
||||||
|
text = html.UnescapeString(text)
|
||||||
text = licenceExpr.ReplaceAllString(text, "")
|
text = licenceExpr.ReplaceAllString(text, "")
|
||||||
text = readMoreExpr.ReplaceAllString(text, "")
|
text = readMoreExpr.ReplaceAllString(text, "")
|
||||||
text = doublePuncExpr.ReplaceAllString(text, ". ")
|
text = doublePuncExpr.ReplaceAllString(text, ". ")
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ func TestParseID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tcase := range tcases {
|
for _, tcase := range tcases {
|
||||||
tcase := tcase // pin
|
|
||||||
t.Run(tcase.param, func(t *testing.T) {
|
t.Run(tcase.param, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type Info interface {
|
|||||||
TrackNumber() int
|
TrackNumber() int
|
||||||
DiscNumber() int
|
DiscNumber() int
|
||||||
Year() int
|
Year() int
|
||||||
|
Lyrics() string
|
||||||
|
|
||||||
Compilation() bool
|
Compilation() bool
|
||||||
ReleaseType() string
|
ReleaseType() string
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ func (i *info) Genres() []string { return find(i.raw, "genres") }
|
|||||||
func (i *info) TrackNumber() int { return intSep("/", first(find(i.raw, "tracknumber"))) } // eg. 5/12
|
func (i *info) TrackNumber() int { return intSep("/", first(find(i.raw, "tracknumber"))) } // eg. 5/12
|
||||||
func (i *info) DiscNumber() int { return intSep("/", first(find(i.raw, "discnumber"))) } // eg. 1/2
|
func (i *info) DiscNumber() int { return intSep("/", first(find(i.raw, "discnumber"))) } // eg. 1/2
|
||||||
func (i *info) Year() int { return intSep("-", first(find(i.raw, "originaldate", "date", "year"))) } // eg. 2023-12-01
|
func (i *info) Year() int { return intSep("-", first(find(i.raw, "originaldate", "date", "year"))) } // eg. 2023-12-01
|
||||||
|
func (i *info) Lyrics() string {
|
||||||
|
return first(find(i.raw, "lyrics", "lyrics:description", "USLT:description", "LYRICS", "Lyrics", "©lyr"))
|
||||||
|
}
|
||||||
|
|
||||||
func (i *info) Compilation() bool { return bl(first(find(i.raw, "compilation"))) }
|
func (i *info) Compilation() bool { return bl(first(find(i.raw, "compilation"))) }
|
||||||
func (i *info) ReleaseType() string { return first(find(i.raw, "releasetype")) }
|
func (i *info) ReleaseType() string { return first(find(i.raw, "releasetype")) }
|
||||||
|
|||||||
@@ -116,15 +116,12 @@ func TestCachingParallelism(t *testing.T) {
|
|||||||
cacheTranscoder := transcode.NewCachingTranscoder(transcoder, t.TempDir(), 1024)
|
cacheTranscoder := transcode.NewCachingTranscoder(transcoder, t.TempDir(), 1024)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i := 0; i < 5; i++ {
|
for range 5 {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
require.NoError(t, cacheTranscoder.Transcode(context.Background(), transcode.PCM16le, "testdata/5s.flac", &buf))
|
require.NoError(t, cacheTranscoder.Transcode(context.Background(), transcode.PCM16le, "testdata/5s.flac", &buf))
|
||||||
require.Equal(t, 5*bytesPerSec, buf.Len())
|
require.Equal(t, 5*bytesPerSec, buf.Len())
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|||||||
Reference in New Issue
Block a user