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