mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-02-23 17:31:17 +00:00
Compare commits
No commits in common. "f7cf187bacfa67bacd045ca7ec3f7b0da5dc178c" and "e6fd4f635205b8d9b5398b563522dcfc18e7089f" have entirely different histories.
f7cf187bac
...
e6fd4f6352
@ -10,19 +10,19 @@ func TestBasicLogin(t *testing.T) {
|
||||
|
||||
// Test good credentials
|
||||
backend, _ := New(&Options{Credentials: basicCredentials})
|
||||
ok, _, err := backend.Login("demo", "demo")
|
||||
ok, err := backend.Login("demo", "demo")
|
||||
if !ok {
|
||||
t.Error("Error while logging with the basic authentication:", err)
|
||||
}
|
||||
|
||||
// Test bad username
|
||||
ok, _, err = backend.Login("baduser", "demo")
|
||||
ok, err = backend.Login("baduser", "demo")
|
||||
if ok {
|
||||
t.Error("Authentification failed to fail:", err)
|
||||
}
|
||||
|
||||
// Test bad password
|
||||
ok, _, err = backend.Login("demo", "badpass")
|
||||
ok, err = backend.Login("demo", "badpass")
|
||||
if ok {
|
||||
t.Error("Authentification failed to fail:", err)
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ func Serve(streams *messaging.Streams, authBackend auth.Backend, cfg *Options) {
|
||||
|
||||
if len(split) > 1 {
|
||||
// password was provided so it is a streamer
|
||||
name, password := strings.ToLower(split[0]), split[1]
|
||||
name, password := split[0], split[1]
|
||||
if authBackend != nil {
|
||||
// check password
|
||||
ok, username, err := authBackend.Login(name, password)
|
||||
@ -94,7 +94,7 @@ func Serve(streams *messaging.Streams, authBackend auth.Backend, cfg *Options) {
|
||||
go handleStreamer(s, streams, name)
|
||||
} else {
|
||||
// password was not provided so it is a viewer
|
||||
name := strings.ToLower(split[0])
|
||||
name := split[0]
|
||||
|
||||
// Send stream
|
||||
go handleViewer(s, streams, name)
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
|
||||
var (
|
||||
// Precompile regex
|
||||
validPath = regexp.MustCompile("^/[a-zA-Z0-9@_-]*$")
|
||||
validPath = regexp.MustCompile("^/[a-z0-9@_-]*$")
|
||||
|
||||
counterMutex = new(sync.Mutex)
|
||||
connectedClients = make(map[string]map[string]int64)
|
||||
@ -42,7 +42,7 @@ func viewerHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Get stream ID from URL, or from domain name
|
||||
path := strings.ToLower(r.URL.Path[1:])
|
||||
path := r.URL.Path[1:]
|
||||
host := r.Host
|
||||
if strings.Contains(host, ":") {
|
||||
realHost, _, err := net.SplitHostPort(r.Host)
|
||||
@ -58,7 +58,7 @@ func viewerHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if path == "about" {
|
||||
path = ""
|
||||
} else {
|
||||
path = strings.ToLower(streamID)
|
||||
path = streamID
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +97,6 @@ func staticHandler() http.Handler {
|
||||
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Retrieve stream name from URL
|
||||
name := strings.SplitN(strings.Replace(r.URL.Path[7:], "/", "", -1), "@", 2)[0]
|
||||
name = strings.ToLower(name)
|
||||
userCount := 0
|
||||
|
||||
// Clients have a unique generated identifier per session, that expires in 40 seconds.
|
||||
|
Loading…
x
Reference in New Issue
Block a user