signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig := <-sig
- log.Println("Radio shutting down due to signal", sig)
+ log.Println("Radio shutting down due to signal:", sig)
// Make sure we always stop PTT when program ends
ptt.DisengagePTT()
os.Exit(0)
func InitAudioFiles(path string) {
files.changeWait = make(chan bool)
files.path = path
- log.Println("initing audio files")
files.Refresh()
- log.Println("done")
}
func (r *AudioFiles) Refresh() {
entries, err := os.ReadDir(r.path)
if err != nil {
- log.Println("couldn't read dir", r.path)
+ log.Println("Couldn't read dir", r.path)
return
}
r.filesMutex.Lock()
for _, file := range entries {
f, err := os.Open(filepath.Join(r.path, file.Name()))
if err != nil {
- log.Println("couldn't open", file.Name())
+ log.Println("Couldn't open", file.Name())
return
}
hash := sha256.New()
data.ShowForm = false
cookie, err := r.Cookie("broadcast_session")
if err == nil {
- log.Println("clearing other sessions for username", user.Username, "token", cookie.Value)
+ log.Println("Clearing other sessions for username", user.Username, "token", cookie.Value)
db.ClearOtherSessions(user.Username, cookie.Value)
}
}
data := FilesPageData{
Files: files.Files(),
}
- log.Println("file page data", data)
tmpl := template.Must(template.ParseFS(content, "templates/files.html"))
err := tmpl.Execute(w, data)
if err != nil {
f, _ := os.Create(path)
defer f.Close()
io.Copy(f, file)
- log.Println("uploaded file to", path)
+ log.Println("Uploaded file to", path)
files.Refresh()
}
http.Redirect(w, r, "/files/", http.StatusFound)
)
func RadioSync(ws *websocket.Conn) {
- log.Println("A websocket connected, I think")
+ log.Println("Radio websocket connected, not yet authenticated")
buf := make([]byte, 16384)
badRead := false
func createSessionCookie(w http.ResponseWriter, username string) {
sess := generateSession()
- log.Println("Generated a random session", sess)
expiration := time.Now().Add(365 * 24 * time.Hour)
cookie := http.Cookie{Name: "broadcast_session", Value: sess, Expires: expiration, SameSite: http.SameSiteLaxMode}
db.InsertSession(username, sess, expiration)