mirror of
https://github.com/jech/galene.git
synced 2024-11-21 16:15:57 +01:00
Minor cleanups.
This commit is contained in:
parent
9ab84741d9
commit
fc9f28fd68
8 changed files with 8 additions and 19 deletions
|
@ -9,7 +9,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var errTruncated = errors.New("truncated packet")
|
var errTruncated = errors.New("truncated packet")
|
||||||
var errUnsupportedCodec = errors.New("unsupported codec")
|
|
||||||
|
|
||||||
// Keyframe determines if packet is the start of a keyframe.
|
// Keyframe determines if packet is the start of a keyframe.
|
||||||
// It returns (true, true) if that is the case, (false, true) if that is
|
// It returns (true, true) if that is the case, (false, true) if that is
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (p Password) Match(pw string) (bool, error) {
|
||||||
theirKey := pbkdf2.Key(
|
theirKey := pbkdf2.Key(
|
||||||
[]byte(pw), salt, p.Iterations, len(key), h,
|
[]byte(pw), salt, p.Iterations, len(key), h,
|
||||||
)
|
)
|
||||||
return bytes.Compare(key, theirKey) == 0, nil
|
return bytes.Equal(key, theirKey), nil
|
||||||
default:
|
default:
|
||||||
return false, errors.New("unknown password type")
|
return false, errors.New("unknown password type")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ice
|
package ice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
@ -10,6 +9,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -63,12 +63,12 @@ func getServer(server Server) (webrtc.ICEServer, error) {
|
||||||
}
|
}
|
||||||
mac := hmac.New(sha1.New, []byte(cred))
|
mac := hmac.New(sha1.New, []byte(cred))
|
||||||
mac.Write([]byte(username))
|
mac.Write([]byte(username))
|
||||||
buf := bytes.Buffer{}
|
buf := strings.Builder{}
|
||||||
e := base64.NewEncoder(base64.StdEncoding, &buf)
|
e := base64.NewEncoder(base64.StdEncoding, &buf)
|
||||||
e.Write(mac.Sum(nil))
|
e.Write(mac.Sum(nil))
|
||||||
e.Close()
|
e.Close()
|
||||||
s.Username = username
|
s.Username = username
|
||||||
s.Credential = string(buf.Bytes())
|
s.Credential = buf.String()
|
||||||
s.CredentialType = webrtc.ICECredentialTypePassword
|
s.CredentialType = webrtc.ICECredentialTypePassword
|
||||||
default:
|
default:
|
||||||
return webrtc.ICEServer{}, errors.New("unsupported credential type")
|
return webrtc.ICEServer{}, errors.New("unsupported credential type")
|
||||||
|
@ -245,7 +245,7 @@ func RelayTest(timeout time.Duration) (time.Duration, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return time.Now().Sub(tm), nil
|
return time.Since(tm), nil
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
return 0, errTimeout
|
return 0, errTimeout
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ice
|
package ice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
@ -57,11 +56,11 @@ func TestHMAC(t *testing.T) {
|
||||||
|
|
||||||
mac := hmac.New(sha1.New, []byte(s.Credential.(string)))
|
mac := hmac.New(sha1.New, []byte(s.Credential.(string)))
|
||||||
mac.Write([]byte(sss.Username))
|
mac.Write([]byte(sss.Username))
|
||||||
buf := bytes.Buffer{}
|
buf := strings.Builder{}
|
||||||
e := base64.NewEncoder(base64.StdEncoding, &buf)
|
e := base64.NewEncoder(base64.StdEncoding, &buf)
|
||||||
e.Write(mac.Sum(nil))
|
e.Write(mac.Sum(nil))
|
||||||
e.Close()
|
e.Close()
|
||||||
ss.Credential = string(buf.Bytes())
|
ss.Credential = buf.String()
|
||||||
|
|
||||||
if err != nil || !reflect.DeepEqual(sss, ss) {
|
if err != nil || !reflect.DeepEqual(sss, ss) {
|
||||||
t.Errorf("Got %v, expected %v", sss, ss)
|
t.Errorf("Got %v, expected %v", sss, ss)
|
||||||
|
|
|
@ -12,9 +12,6 @@ import (
|
||||||
// a multiple of 8.
|
// a multiple of 8.
|
||||||
const BufSize = 1504
|
const BufSize = 1504
|
||||||
|
|
||||||
// The maximum number of packets that constitute a keyframe.
|
|
||||||
const maxFrame = 1024
|
|
||||||
|
|
||||||
// entry represents a cached packet.
|
// entry represents a cached packet.
|
||||||
type entry struct {
|
type entry struct {
|
||||||
seqno uint16
|
seqno uint16
|
||||||
|
@ -118,7 +115,6 @@ func (bitmap *bitmap) set(seqno uint16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap.bitmap |= (1 << uint16(seqno-bitmap.first))
|
bitmap.bitmap |= (1 << uint16(seqno-bitmap.first))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BitmapGet shifts up to 17 bits out of the bitmap. It returns a boolean
|
// BitmapGet shifts up to 17 bits out of the bitmap. It returns a boolean
|
||||||
|
|
|
@ -410,7 +410,6 @@ type rtpUpTrack struct {
|
||||||
srTime uint64
|
srTime uint64
|
||||||
srNTPTime uint64
|
srNTPTime uint64
|
||||||
srRTPTime uint32
|
srRTPTime uint32
|
||||||
maxLayer uint8
|
|
||||||
local []conn.DownTrack
|
local []conn.DownTrack
|
||||||
bufferedNACKs []uint16
|
bufferedNACKs []uint16
|
||||||
actions []trackAction
|
actions []trackAction
|
||||||
|
|
|
@ -165,7 +165,7 @@ func addUpConn(c *webClient, id, label string, offer string) (*rtpUpConnection,
|
||||||
c.up = make(map[string]*rtpUpConnection)
|
c.up = make(map[string]*rtpUpConnection)
|
||||||
}
|
}
|
||||||
if c.down != nil && c.down[id] != nil {
|
if c.down != nil && c.down[id] != nil {
|
||||||
return nil, false, errors.New("Adding duplicate connection")
|
return nil, false, errors.New("adding duplicate connection")
|
||||||
}
|
}
|
||||||
|
|
||||||
old := c.up[id]
|
old := c.up[id]
|
||||||
|
|
|
@ -123,7 +123,6 @@ func httpError(w http.ResponseWriter, err error) {
|
||||||
log.Printf("HTTP server error: %v", err)
|
log.Printf("HTTP server error: %v", err)
|
||||||
http.Error(w, "500 Internal Server Error",
|
http.Error(w, "500 Internal Server Error",
|
||||||
http.StatusInternalServerError)
|
http.StatusInternalServerError)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -352,7 +351,6 @@ func groupStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
e := json.NewEncoder(w)
|
e := json.NewEncoder(w)
|
||||||
e.Encode(d)
|
e.Encode(d)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func publicHandler(w http.ResponseWriter, r *http.Request) {
|
func publicHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -366,7 +364,6 @@ func publicHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
g := group.GetPublic()
|
g := group.GetPublic()
|
||||||
e := json.NewEncoder(w)
|
e := json.NewEncoder(w)
|
||||||
e.Encode(g)
|
e.Encode(g)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func adminMatch(username, password string) (bool, error) {
|
func adminMatch(username, password string) (bool, error) {
|
||||||
|
@ -418,7 +415,6 @@ func statsHandler(w http.ResponseWriter, r *http.Request, dataDir string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("stats.json: %v", err)
|
log.Printf("stats.json: %v", err)
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var wsUpgrader = websocket.Upgrader{
|
var wsUpgrader = websocket.Upgrader{
|
||||||
|
|
Loading…
Reference in a new issue