Compare commits

...

3 Commits

Author SHA1 Message Date
Rohit Vighne
88bdefcd90
Merge d29b8f2afa32fb0d249dc719d5522ca19c0f600d into c348593ef4af350eaad92925cf9684f5947d70cb 2025-03-27 11:21:41 -04:00
Rohit Vighne
d29b8f2afa Listen on AF_UNIX socket if -addr is a path 2025-03-27 11:19:26 -04:00
nkanaev
c348593ef4
Update readme.md 2025-03-27 09:38:18 +00:00
3 changed files with 32 additions and 8 deletions

View File

@ -90,6 +90,10 @@ func main() {
log.SetOutput(os.Stdout)
}
if open && strings.HasPrefix(addr, "unix:") {
log.Fatal("Cannot open ", addr, " in browser")
}
if db == "" {
configPath, err := os.UserConfigDir()
if err != nil {

View File

@ -13,9 +13,9 @@ The latest prebuilt binaries for Linux/MacOS/Windows are available
[here](https://github.com/nkanaev/yarr/releases/latest).
The archives follow the naming convention `yarr_{OS}_{ARCH}[_gui].zip`, where:
* `OS` corresponds to the target operating system (darwin/linux/windows for Linux, MacOS, Windows, respectively)
* `ARCH` is the CPU architecture (`arm64` for AMD64/Aarch64, `amd64` for X86-64)
* `-gui` indicates that the application ships with the GUI (tray icon), and is a command line application if omitted
* `OS` is the target operating system
* `ARCH` is the CPU architecture (`arm64` for AArch64, `amd64` for X86-64)
* `-gui` indicates that the binary ships with the GUI (tray icon), and is a command line application if omitted
Usage instructions:

View File

@ -2,7 +2,10 @@ package server
import (
"log"
"net"
"net/http"
"os"
"strings"
"sync"
"github.com/nkanaev/yarr/src/storage"
@ -53,14 +56,31 @@ func (s *Server) Start() {
s.worker.RefreshFeeds()
}
httpserver := &http.Server{Addr: s.Addr, Handler: s.handler()}
var ln net.Listener
var err error
if s.CertFile != "" && s.KeyFile != "" {
err = httpserver.ListenAndServeTLS(s.CertFile, s.KeyFile)
if path, isUnix := strings.CutPrefix(s.Addr, "unix:"); isUnix {
err = os.Remove(path)
if err != nil {
log.Print(err)
}
ln, err = net.Listen("unix", path)
} else {
err = httpserver.ListenAndServe()
ln, err = net.Listen("tcp", s.Addr)
}
if err != nil {
log.Fatal(err)
}
httpserver := &http.Server{Handler: s.handler()}
if s.CertFile != "" && s.KeyFile != "" {
err = httpserver.ServeTLS(ln, s.CertFile, s.KeyFile)
ln.Close()
} else {
err = httpserver.Serve(ln)
}
if err != http.ErrServerClosed {
log.Fatal(err)
}