1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
diff --git a/go.work.sum b/go.work.sum
index e2446a065d43ab64119e938e20b356cb3150803d..5caa5f8f765360f3a9433d235cde5611566d8edc 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -1,6 +1,7 @@
cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE=
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
+github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
@@ -12,8 +13,11 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
+github.com/valyala/fasthttp v1.48.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
diff --git a/internal/mansion/room.go b/internal/mansion/room.go
index 8d8d2a6aa95e3381467e1e9357a1c95aa02a4262..fa7ad2ca164d01099dc984debcf2285f566a1632 100644
--- a/internal/mansion/room.go
+++ b/internal/mansion/room.go
@@ -20,6 +20,8 @@
playbackStart time.Time
playbackPos time.Duration
playbackPaused bool
+
+ password string
}
func newRoom(ctx context.Context) *room {
diff --git a/internal/mansion/type.go b/internal/mansion/type.go
index 080690409814c7767647e7e7b63f22499525cc0a..086e8e25e3573c9623f7613bf3f535ccd0c6100a 100644
--- a/internal/mansion/type.go
+++ b/internal/mansion/type.go
@@ -87,11 +87,16 @@ }
}
}
-func (m *Mansion) GetRoom(name string) (*room, uint64) {
+func (m *Mansion) GetRoom(name string, password string) (*room, uint64) {
slog.Debug("requested room", "id", name)
m.roomsMtx.RLock()
if r, exists := m.rooms[name]; exists {
m.roomsMtx.RUnlock()
+
+ if r.password != "" && r.password != password {
+ return nil, 0
+ }
+
id := m.clientID.Add(1)
return r, id
}
@@ -100,6 +105,7 @@ slog.Debug("creating new room", "id", name)
m.roomsMtx.RUnlock()
m.roomsMtx.Lock()
r := newRoom(m.ctx)
+ r.password = password
m.rooms[name] = r
m.roomsMtx.Unlock()
diff --git a/internal/server/server.go b/internal/server/server.go
index ecaae8b88bf5b60038466585cd988a0738d5890c..f2fb61afc609f39f4a31f0c2e596e59a9bf7d71d 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -36,7 +36,11 @@ if s.Rooms.Closing() {
return status.Error(codes.Unavailable, "the server is shutting down")
}
- room, id := s.Rooms.GetRoom(joinEv.Name)
+ room, id := s.Rooms.GetRoom(joinEv.Name, joinEv.Password)
+ if room == nil {
+ return status.Error(codes.PermissionDenied, "joining the room failed")
+ }
+
log = slog.With("grpc_client_id", id)
log.Debug("client connected")
room.Client(feed, id)
diff --git a/protocol/uniview.pb.go b/protocol/uniview.pb.go
index e809f6bea4fc8b9c6ff5428d1447ac86e5ed540c..5ec17c44df46cb3c2fe9571da89de28d656e7ef3 100644
--- a/protocol/uniview.pb.go
+++ b/protocol/uniview.pb.go
@@ -196,6 +196,7 @@
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Timestamp *durationpb.Duration `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"`
+ Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"`
}
func (x *RoomJoin) Reset() {
@@ -247,6 +248,13 @@
func (x *RoomJoin) GetUrl() string {
if x != nil {
return x.Url
+ }
+ return ""
+}
+
+func (x *RoomJoin) GetPassword() string {
+ if x != nil {
+ return x.Password
}
return ""
}
@@ -373,41 +381,43 @@ 0x70, 0x61, 0x75, 0x73, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x09, 0x6a, 0x75,
0x6d, 0x70, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x62, 0x61, 0x63,
0x6b, 0x4a, 0x75, 0x6d, 0x70, 0x48, 0x00, 0x52, 0x09, 0x6a, 0x75, 0x6d, 0x70, 0x45, 0x76, 0x65,
- 0x6e, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x69, 0x0a, 0x08, 0x52,
- 0x6f, 0x6f, 0x6d, 0x4a, 0x6f, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
- 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x09, 0x74,
- 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19,
- 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
- 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73,
- 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x5a, 0x0a, 0x09, 0x50, 0x6c, 0x61, 0x79, 0x50, 0x61,
- 0x75, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x75, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01,
- 0x28, 0x08, 0x52, 0x05, 0x70, 0x61, 0x75, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x09, 0x74, 0x69, 0x6d,
- 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67,
- 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44,
- 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
- 0x6d, 0x70, 0x22, 0x47, 0x0a, 0x0c, 0x50, 0x6c, 0x61, 0x79, 0x62, 0x61, 0x63, 0x6b, 0x4a, 0x75,
- 0x6d, 0x70, 0x12, 0x37, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18,
- 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
- 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2a, 0x9f, 0x01, 0x0a, 0x09,
- 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x56, 0x45,
- 0x4e, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00,
- 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x4a, 0x4f, 0x49, 0x4e, 0x10, 0x01,
- 0x12, 0x0f, 0x0a, 0x0b, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x50, 0x41, 0x55, 0x53, 0x45, 0x10,
- 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x4a, 0x55, 0x4d, 0x50, 0x10,
- 0x03, 0x12, 0x16, 0x0a, 0x12, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45,
- 0x52, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x10, 0x04, 0x12, 0x1b, 0x0a, 0x17, 0x45, 0x56, 0x45,
- 0x4e, 0x54, 0x5f, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x5f, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e,
- 0x4e, 0x45, 0x43, 0x54, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f,
- 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, 0x50, 0x49, 0x4e, 0x47, 0x10, 0x06, 0x32, 0x3f, 0x0a,
- 0x07, 0x55, 0x6e, 0x69, 0x56, 0x69, 0x65, 0x77, 0x12, 0x34, 0x0a, 0x04, 0x52, 0x6f, 0x6f, 0x6d,
- 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x52, 0x6f, 0x6f, 0x6d,
- 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c,
- 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x28, 0x01, 0x30, 0x01, 0x42, 0x23,
- 0x5a, 0x21, 0x67, 0x69, 0x74, 0x2e, 0x73, 0x72, 0x2e, 0x68, 0x74, 0x2f, 0x7e, 0x6d, 0x70, 0x6c,
- 0x64, 0x72, 0x2f, 0x75, 0x6e, 0x69, 0x76, 0x69, 0x65, 0x77, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x63, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x6e, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x85, 0x01, 0x0a, 0x08,
+ 0x52, 0x6f, 0x6f, 0x6d, 0x4a, 0x6f, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
+ 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x09,
+ 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32,
+ 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
+ 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65,
+ 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01,
+ 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77,
+ 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77,
+ 0x6f, 0x72, 0x64, 0x22, 0x5a, 0x0a, 0x09, 0x50, 0x6c, 0x61, 0x79, 0x50, 0x61, 0x75, 0x73, 0x65,
+ 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x75, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
+ 0x05, 0x70, 0x61, 0x75, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
+ 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
+ 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22,
+ 0x47, 0x0a, 0x0c, 0x50, 0x6c, 0x61, 0x79, 0x62, 0x61, 0x63, 0x6b, 0x4a, 0x75, 0x6d, 0x70, 0x12,
+ 0x37, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01,
+ 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x74,
+ 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2a, 0x9f, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65,
+ 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f,
+ 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a,
+ 0x0a, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x4a, 0x4f, 0x49, 0x4e, 0x10, 0x01, 0x12, 0x0f, 0x0a,
+ 0x0b, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x50, 0x41, 0x55, 0x53, 0x45, 0x10, 0x02, 0x12, 0x0e,
+ 0x0a, 0x0a, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x4a, 0x55, 0x4d, 0x50, 0x10, 0x03, 0x12, 0x16,
+ 0x0a, 0x12, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, 0x43,
+ 0x4c, 0x4f, 0x53, 0x45, 0x10, 0x04, 0x12, 0x1b, 0x0a, 0x17, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f,
+ 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x5f, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43,
+ 0x54, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x53, 0x45, 0x52,
+ 0x56, 0x45, 0x52, 0x5f, 0x50, 0x49, 0x4e, 0x47, 0x10, 0x06, 0x32, 0x3f, 0x0a, 0x07, 0x55, 0x6e,
+ 0x69, 0x56, 0x69, 0x65, 0x77, 0x12, 0x34, 0x0a, 0x04, 0x52, 0x6f, 0x6f, 0x6d, 0x12, 0x13, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x52, 0x6f, 0x6f, 0x6d, 0x45, 0x76, 0x65,
+ 0x6e, 0x74, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x52, 0x6f,
+ 0x6f, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x28, 0x01, 0x30, 0x01, 0x42, 0x23, 0x5a, 0x21, 0x67,
+ 0x69, 0x74, 0x2e, 0x73, 0x72, 0x2e, 0x68, 0x74, 0x2f, 0x7e, 0x6d, 0x70, 0x6c, 0x64, 0x72, 0x2f,
+ 0x75, 0x6e, 0x69, 0x76, 0x69, 0x65, 0x77, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c,
+ 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
diff --git a/protocol/uniview.proto b/protocol/uniview.proto
index 17daff6ceded56e98011bdbeb5a6f3058056964b..7a907b169f0f771299df57bd3c3306284a2f6087 100644
--- a/protocol/uniview.proto
+++ b/protocol/uniview.proto
@@ -35,6 +35,7 @@ message RoomJoin {
string name = 1;
google.protobuf.Duration timestamp = 2;
string url = 3;
+ string password = 4;
}
message PlayPause {
|