Run gofmt.

This commit is contained in:
Juliusz Chroboczek
2025-03-21 15:15:41 +01:00
parent 400d821d1b
commit e09b135cd2
10 changed files with 38 additions and 38 deletions
+1 -1
View File
@@ -290,7 +290,7 @@ func PacketFlags(codec string, buf []byte) (Flags, error) {
flags.Start = vp9.B flags.Start = vp9.B
flags.End = vp9.E flags.End = vp9.E
if vp9.B && len(vp9.Payload) > 0 && if vp9.B && len(vp9.Payload) > 0 &&
(vp9.Payload[0] & 0xc0) == 0x80 { (vp9.Payload[0]&0xc0) == 0x80 {
profile := (vp9.Payload[0] >> 4) & 0x3 profile := (vp9.Payload[0] >> 4) & 0x3
if profile != 3 { if profile != 3 {
flags.Keyframe = (vp9.Payload[0] & 0xC) == 0 flags.Keyframe = (vp9.Payload[0] & 0xC) == 0
+5 -5
View File
@@ -28,7 +28,7 @@ func TestAdjustOriginLocalNow(t *testing.T) {
c := &diskConn{ c := &diskConn{
tracks: []*diskTrack{ tracks: []*diskTrack{
&diskTrack{}, {},
}, },
} }
for _, t := range c.tracks { for _, t := range c.tracks {
@@ -56,7 +56,7 @@ func TestAdjustOriginLocalEarlier(t *testing.T) {
c := &diskConn{ c := &diskConn{
originLocal: earlier, originLocal: earlier,
tracks: []*diskTrack{ tracks: []*diskTrack{
&diskTrack{}, {},
}, },
} }
for _, t := range c.tracks { for _, t := range c.tracks {
@@ -84,7 +84,7 @@ func TestAdjustOriginLocalLater(t *testing.T) {
c := &diskConn{ c := &diskConn{
originLocal: later, originLocal: later,
tracks: []*diskTrack{ tracks: []*diskTrack{
&diskTrack{}, {},
}, },
} }
for _, t := range c.tracks { for _, t := range c.tracks {
@@ -111,7 +111,7 @@ func TestAdjustOriginRemote(t *testing.T) {
c := &diskConn{ c := &diskConn{
tracks: []*diskTrack{ tracks: []*diskTrack{
&diskTrack{ {
remoteNTP: rtptime.TimeToNTP(earlier), remoteNTP: rtptime.TimeToNTP(earlier),
remoteRTP: 32, remoteRTP: 32,
}, },
@@ -144,7 +144,7 @@ func TestAdjustOriginLocalRemote(t *testing.T) {
c := &diskConn{ c := &diskConn{
tracks: []*diskTrack{ tracks: []*diskTrack{
&diskTrack{}, {},
}, },
} }
for _, t := range c.tracks { for _, t := range c.tracks {
+5 -5
View File
@@ -1,10 +1,10 @@
package estimator package estimator
import ( import (
"testing"
"time"
"sync" "sync"
"sync/atomic" "sync/atomic"
"testing"
"time"
"github.com/jech/galene/rtptime" "github.com/jech/galene/rtptime"
) )
@@ -87,7 +87,7 @@ func TestEstimatorParallel(t *testing.T) {
addNow(rtptime.JiffiesPerSec / 1000) addNow(rtptime.JiffiesPerSec / 1000)
b, p := estimate() b, p := estimate()
if i >= 1000 { if i >= 1000 {
if b != p * 42 { if b != p*42 {
t.Errorf("%v: Got %v %v (%v), expected %v %v", t.Errorf("%v: Got %v %v (%v), expected %v %v",
n, p, b, i, 1000, p*42, n, p, b, i, 1000, p*42,
) )
@@ -115,7 +115,7 @@ func BenchmarkEstimator(b *testing.B) {
e.Estimate() e.Estimate()
b.ResetTimer() b.ResetTimer()
for i := 0; i < 1000 * b.N; i++ { for i := 0; i < 1000*b.N; i++ {
e.Accumulate(100) e.Accumulate(100)
} }
@@ -130,7 +130,7 @@ func BenchmarkEstimatorParallel(b *testing.B) {
e.Estimate() e.Estimate()
b.ResetTimer() b.ResetTimer()
b.RunParallel(func (pb *testing.PB) { b.RunParallel(func(pb *testing.PB) {
for pb.Next() { for pb.Next() {
for i := 0; i < 1000; i++ { for i := 0; i < 1000; i++ {
e.Accumulate(100) e.Accumulate(100)
+1 -1
View File
@@ -1021,7 +1021,7 @@ func (g *Group) userExists(username string) bool {
return found return found
} }
//validUsername returns true if a string is a valid username. // validUsername returns true if a string is a valid username.
// On the one hand, we want to allow usernames such as "jch@work" // On the one hand, we want to allow usernames such as "jch@work"
// or "Alice c/o Bob". On the other hand, not restricting // or "Alice c/o Bob". On the other hand, not restricting
// usernames might lead to security vulnaribilities. // usernames might lead to security vulnaribilities.
+2 -2
View File
@@ -31,7 +31,7 @@ func (m *Map) Map(seqno uint16, pid uint16) (bool, uint16, uint16) {
if m.delta == 0 && m.entries == nil { if m.delta == 0 && m.entries == nil {
if compare(m.next, seqno) <= 0 || if compare(m.next, seqno) <= 0 ||
uint16(m.next - seqno) > 8 * 1024 { uint16(m.next-seqno) > 8*1024 {
m.next = seqno + 1 m.next = seqno + 1
m.nextPid = pid m.nextPid = pid
} }
@@ -192,7 +192,7 @@ func (m *Map) Drop(seqno uint16, pid uint16) bool {
if len(m.entries) == 0 { if len(m.entries) == 0 {
m.entries = []entry{ m.entries = []entry{
entry{ {
first: seqno - 8192, first: seqno - 8192,
count: 8192, count: 8192,
delta: 0, delta: 0,
+10 -10
View File
@@ -165,14 +165,14 @@ func TestWraparound(t *testing.T) {
} }
for i := 4; i < 256000; i++ { for i := 4; i < 256000; i++ {
ok, s, p = m.Map(uint16(i), uint16((i/2) & 0x7FFF)) ok, s, p = m.Map(uint16(i), uint16((i/2)&0x7FFF))
if !ok || s != uint16(i-2) || p != 1 { if !ok || s != uint16(i-2) || p != 1 {
t.Errorf("Expected %v, %v, got %v, %v, %v", t.Errorf("Expected %v, %v, got %v, %v, %v",
uint16(i-2), 1, ok, s, p) uint16(i-2), 1, ok, s, p)
} }
} }
ok, s, p = m.Map((256000 & 0xFFFF) + 2, 1) ok, s, p = m.Map((256000&0xFFFF)+2, 1)
expect := uint16((256000) & 0xFFFF) expect := uint16((256000) & 0xFFFF)
if !ok || s != expect || p != 1 { if !ok || s != expect || p != 1 {
t.Errorf("Expected %v, 1, got %v, %v, %v", expect, ok, s, p) t.Errorf("Expected %v, 1, got %v, %v, %v", expect, ok, s, p)
@@ -202,25 +202,25 @@ func TestWraparoundDrop(t *testing.T) {
t.Errorf("Expected 1, got %v, %v", ok, m.pidDelta) t.Errorf("Expected 1, got %v, %v", ok, m.pidDelta)
} }
for i := 4; i < 256000; i+= 3 { for i := 4; i < 256000; i += 3 {
ok, s, p = m.Map(uint16(i), uint16((i/2) & 0x7FFF)) ok, s, p = m.Map(uint16(i), uint16((i/2)&0x7FFF))
if !ok || s != uint16((i-1)/3*2) || p != 1 { if !ok || s != uint16((i-1)/3*2) || p != 1 {
t.Errorf("Expected %v, %v, got %v, %v, %v", t.Errorf("Expected %v, %v, got %v, %v, %v",
uint16((i-1)/3*2), 1, ok, s, p) uint16((i-1)/3*2), 1, ok, s, p)
} }
ok, s, p = m.Map(uint16(i + 1), uint16((i/2) & 0x7FFF)) ok, s, p = m.Map(uint16(i+1), uint16((i/2)&0x7FFF))
if !ok || s != uint16((i-1)/3*2 + 1) || p != 1 { if !ok || s != uint16((i-1)/3*2+1) || p != 1 {
t.Errorf("Expected %v, %v, got %v, %v, %v", t.Errorf("Expected %v, %v, got %v, %v, %v",
uint16((i-1)/3*2 + 1), 1, ok, s, p) uint16((i-1)/3*2+1), 1, ok, s, p)
} }
ok = m.Drop(uint16(i + 2), uint16((i/2) & 0x7FFF)) ok = m.Drop(uint16(i+2), uint16((i/2)&0x7FFF))
if !ok { if !ok {
t.Errorf("Expected ok") t.Errorf("Expected ok")
} }
} }
ok, s, p = m.Map((256000 & 0xFFFF) + 4, 0) ok, s, p = m.Map((256000&0xFFFF)+4, 0)
expect := uint16(((256000 - 1)/3*2 + 4) & 0xFFFF) expect := uint16(((256000-1)/3*2 + 4) & 0xFFFF)
if !ok || s != expect || p != 1 { if !ok || s != expect || p != 1 {
t.Errorf("Expected %v, 1, got %v, %v, %v", expect, ok, s, p) t.Errorf("Expected %v, 1, got %v, %v, %v", expect, ok, s, p)
} }
+2 -2
View File
@@ -234,8 +234,8 @@ func getCandidates(as []sdp.Attribute, mid *string, index *uint16, ufrag string)
continue continue
} }
c := webrtc.ICECandidateInit{ c := webrtc.ICECandidateInit{
Candidate: a.Value, Candidate: a.Value,
SDPMid: mid, SDPMid: mid,
SDPMLineIndex: index, SDPMLineIndex: index,
} }
if ufrag != "" { if ufrag != "" {
+2 -2
View File
@@ -1,8 +1,8 @@
package sdpfrag package sdpfrag
import ( import (
"testing"
"reflect" "reflect"
"testing"
"github.com/pion/sdp/v3" "github.com/pion/sdp/v3"
) )
@@ -238,7 +238,7 @@ func testRoundtrip(t *testing.T, sdpfrag string) {
} }
func TestRoundtrip(t *testing.T) { func TestRoundtrip(t *testing.T) {
type test struct { name, frag string } type test struct{ name, frag string }
for _, tt := range []test{ for _, tt := range []test{
{"sdpfragTrickle", sdpfragTrickle}, {"sdpfragTrickle", sdpfragTrickle},
{"sdpfragEndOfCandidates", sdpfragEndOfCandidates}, {"sdpfragEndOfCandidates", sdpfragEndOfCandidates},
+1 -1
View File
@@ -100,7 +100,7 @@ func ParseKeys(keys []map[string]any, alg, kid string) ([]jwt.VerificationKey, e
ks := make([]jwt.VerificationKey, 0, len(keys)) ks := make([]jwt.VerificationKey, 0, len(keys))
for _, ky := range keys { for _, ky := range keys {
// return all keys if alg and kid are not specified // return all keys if alg and kid are not specified
if alg != "" && ky["alg"] != alg { if alg != "" && ky["alg"] != alg {
continue continue
} }
if kid != "" && ky["kid"] != kid { if kid != "" && ky["kid"] != kid {
+9 -9
View File
@@ -17,7 +17,7 @@ func timeEqual(a, b *time.Time) bool {
return true return true
} }
if a!= nil && b != nil { if a != nil && b != nil {
return (*a).Equal(*b) return (*a).Equal(*b)
} }
@@ -228,14 +228,14 @@ func TestTokenStorage(t *testing.T) {
user2 := "user2" user2 := "user2"
user3 := "user3" user3 := "user3"
tokens := []*Stateful{ tokens := []*Stateful{
&Stateful{ {
Token: "tok1", Token: "tok1",
Group: "test", Group: "test",
Username: &user1, Username: &user1,
Permissions: []string{"present", "message"}, Permissions: []string{"present", "message"},
Expires: &future, Expires: &future,
}, },
&Stateful{ {
Token: "tok2", Token: "tok2",
Group: "test", Group: "test",
Username: &user2, Username: &user2,
@@ -243,7 +243,7 @@ func TestTokenStorage(t *testing.T) {
Expires: &nearFuture, Expires: &nearFuture,
NotBefore: &past, NotBefore: &past,
}, },
&Stateful{ {
Token: "tok3", Token: "tok3",
Group: "test", Group: "test",
Username: &user3, Username: &user3,
@@ -323,35 +323,35 @@ func TestExpire(t *testing.T) {
user := "user" user := "user"
tokens := []*Stateful{ tokens := []*Stateful{
&Stateful{ {
Token: "tok1", Token: "tok1",
Group: "test", Group: "test",
Username: &user, Username: &user,
Permissions: []string{"present", "message"}, Permissions: []string{"present", "message"},
Expires: &now, Expires: &now,
}, },
&Stateful{ {
Token: "tok2", Token: "tok2",
Group: "test", Group: "test",
Username: &user, Username: &user,
Permissions: []string{"present", "message"}, Permissions: []string{"present", "message"},
Expires: &future, Expires: &future,
}, },
&Stateful{ {
Token: "tok3", Token: "tok3",
Group: "test", Group: "test",
Username: &user, Username: &user,
Permissions: []string{"present", "message"}, Permissions: []string{"present", "message"},
Expires: &now, Expires: &now,
}, },
&Stateful{ {
Token: "tok4", Token: "tok4",
Group: "test", Group: "test",
Username: &user, Username: &user,
Permissions: []string{"present", "message"}, Permissions: []string{"present", "message"},
Expires: &past, Expires: &past,
}, },
&Stateful{ {
Token: "tok5", Token: "tok5",
Group: "test", Group: "test",
Username: &user, Username: &user,