forked from LunaNode/lobster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
718 lines (637 loc) · 18.5 KB
/
api.go
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
package lobster
import "github.com/LunaNode/lobster/api"
import "github.com/LunaNode/lobster/ipaddr"
import "github.com/LunaNode/lobster/utils"
import "github.com/gorilla/mux"
import "crypto/hmac"
import "crypto/sha512"
import "crypto/subtle"
import "encoding/hex"
import "encoding/json"
import "errors"
import "fmt"
import "io"
import "net/http"
import "net/url"
import "strconv"
import "strings"
import "time"
type ApiKey struct {
Id int
Label string
UserId int
ApiId string
CreatedTime time.Time
Nonce int64
// only set on apiCreate
ApiKey string
}
func apiListHelper(rows Rows) []*ApiKey {
var keys []*ApiKey
defer rows.Close()
for rows.Next() {
var key ApiKey
rows.Scan(&key.Id, &key.Label, &key.UserId, &key.ApiId, &key.CreatedTime, &key.Nonce)
keys = append(keys, &key)
}
return keys
}
func apiList(userId int) []*ApiKey {
return apiListHelper(
db.Query(
"SELECT id, label, user_id, api_id, time_created, nonce "+
"FROM api_keys "+
"WHERE user_id = ? "+
"ORDER BY label",
userId,
),
)
}
func apiGet(userId int, id int) *ApiKey {
keys := apiListHelper(
db.Query(
"SELECT id, label, user_id, api_id, time_created, nonce "+
"FROM api_keys "+
"WHERE user_id = ? AND id = ?",
userId, id,
),
)
if len(keys) == 1 {
return keys[0]
} else {
return nil
}
}
type ApiActionRestriction struct {
Path string `json:"path"`
Method string `json:"method"`
}
func apiCreate(userId int, label string, restrictAction string, restrictIp string) (*ApiKey, error) {
// validate restrictAction
if len(restrictAction) > MAX_API_RESTRICTION {
return nil, fmt.Errorf("action restriction JSON content cannot exceed %d characters", MAX_API_RESTRICTION)
} else if restrictAction != "" {
var actionRestrictions []*ApiActionRestriction
err := json.Unmarshal([]byte(restrictAction), &actionRestrictions)
if err != nil {
return nil, err
}
}
// validate restrictIp
if len(restrictIp) > MAX_API_RESTRICTION {
return nil, fmt.Errorf("IP restriction JSON content cannot exceed %d characters", MAX_API_RESTRICTION)
} else if restrictIp != "" {
_, err := ipaddr.ParseNetworks(restrictIp)
if err != nil {
return nil, err
}
}
apiId := utils.Uid(16)
apiKey := utils.Uid(128)
result := db.Exec(
"INSERT INTO api_keys (label, user_id, api_id, api_key, restrict_action, restrict_ip) "+
"VALUES (?, ?, ?, ?, ?, ?)",
label, userId, apiId, apiKey, restrictAction, restrictIp,
)
key := apiGet(userId, result.LastInsertId())
key.ApiKey = apiKey
return key, nil
}
func apiDelete(userId int, id int) {
db.Exec("DELETE FROM api_keys WHERE user_id = ? AND id = ?", userId, id)
}
type APIHandlerFunc func(http.ResponseWriter, *http.Request, int, []byte)
func apiCheck(path string, method string, authorization string, request []byte, ip string) (int, error) {
authParts := strings.Split(authorization, ":")
if len(authParts) != 4 {
return 0, fmt.Errorf("bad authorization: expected 4 semicolon-delimited parts, only found %d", len(authParts))
}
apiId := authParts[0]
apiPartialKey := authParts[1]
nonce, _ := strconv.ParseInt(authParts[2], 10, 64)
signature, _ := hex.DecodeString(authParts[3])
if len(apiId) != 16 || len(apiPartialKey) != 64 || len(signature) != 64 {
return 0, errors.New("bad authorization: id, partial key, or signature has bad length; or signature not hex-encoded")
}
rows := db.Query(
"SELECT api_keys.user_id, api_keys.api_key, api_keys.restrict_action, api_keys.restrict_ip "+
"FROM users, api_keys "+
"WHERE api_keys.api_id = ? AND api_keys.nonce < ? AND api_keys.user_id = users.id AND users.status != 'disabled'",
apiId, nonce,
)
defer rows.Close()
if !rows.Next() {
return 0, errors.New("authentication failure")
}
var userId int
var actualKey, restrictAction, restrictIp string
rows.Scan(&userId, &actualKey, &restrictAction, &restrictIp)
// determine expected signature, hmac_{apikey}(path|nonce|request)
mac := hmac.New(sha512.New, []byte(actualKey))
toSign := fmt.Sprintf("%s|%d|%s", path, nonce, string(request))
mac.Write([]byte(toSign))
expectedSignature := mac.Sum(nil)
partialGood := subtle.ConstantTimeCompare([]byte(actualKey)[:64], []byte(apiPartialKey)) == 1
signatureGood := hmac.Equal(signature, expectedSignature)
if partialGood && signatureGood {
// now apply action and IP restrictions
if restrictAction != "" {
var actionRestrictions []*ApiActionRestriction
err := json.Unmarshal([]byte(restrictAction), &actionRestrictions)
if err != nil {
return 0, err
}
passed := false
for _, actionRestriction := range actionRestrictions {
fmt.Printf("%s %s %s %s", actionRestriction.Method, method, actionRestriction.Path, path)
if (actionRestriction.Method == "*" || actionRestriction.Method == method) && wildcardMatcher(actionRestriction.Path, path) {
passed = true
break
}
}
if !passed {
return 0, errors.New("failed action restriction")
}
}
if restrictIp != "" && !ipaddr.MatchNetworks(restrictIp, ip) {
return 0, errors.New("failed IP restriction")
}
db.Exec("UPDATE api_keys SET nonce = GREATEST(nonce, ?) WHERE api_id = ?", nonce, apiId)
return userId, nil
} else {
return 0, errors.New("authentication failure")
}
}
func apiWrap(h APIHandlerFunc) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
authorization := r.Header.Get("Authorization")
if authorization == "" {
http.Error(w, "Missing Authorization header", 401)
return
}
authParts := strings.Split(authorization, " ")
if (len(authParts) != 2 || authParts[0] != "lobster") && authParts[0] != "session" {
http.Error(w, "Authorization header must take the form 'lobster authdata'", 400)
return
}
apiPath := strings.Split(r.URL.Path, "/api/")[1]
buf := make([]byte, API_MAX_REQUEST_LENGTH+1)
n, err := r.Body.Read(buf)
if err != nil && err != io.EOF {
http.Error(w, "Failed to read request body", 400)
return
} else if n > API_MAX_REQUEST_LENGTH {
http.Error(w, fmt.Sprintf("Request body too long (max is %d)", API_MAX_REQUEST_LENGTH), 400)
return
}
request := buf[:n]
if authParts[0] == "lobster" {
userId, err := apiCheck(apiPath, r.Method, authParts[1], request, ExtractIP(r.RemoteAddr))
if err != nil {
http.Error(w, err.Error(), 401)
return
}
h(w, r, userId, request)
} else if authParts[0] == "session" {
// we modify request properties to ensure that session applies CSRF protection
// TODO: this is a bit hacky
r.Method = "POST"
r.PostForm = url.Values{}
r.PostForm.Set("token", authParts[1])
SessionWrap(func(w http.ResponseWriter, r *http.Request, session *Session) {
if session.IsLoggedIn() {
h(w, r, session.UserId, request)
}
})(w, r)
}
}
}
func apiResponse(w http.ResponseWriter, code int, v interface{}) {
w.WriteHeader(code)
if v != nil {
bytes, err := json.Marshal(v)
checkErr(err)
w.Write(bytes)
}
}
func copyVM(src *VirtualMachine, dst *api.VirtualMachine) {
dst.Id = src.Id
dst.PlanId = src.Plan.Id
dst.Region = src.Region
dst.Name = src.Name
dst.Status = src.Status
dst.TaskPending = src.TaskPending
dst.ExternalIP = src.ExternalIP
dst.PrivateIP = src.PrivateIP
dst.CreatedTime = src.CreatedTime.Unix()
}
func copyVMDetails(src *VmInfo, dst *api.VirtualMachineDetails) {
dst.Ip = src.Ip
dst.PrivateIp = src.PrivateIp
dst.Status = src.Status
dst.Hostname = src.Hostname
dst.BandwidthUsed = src.BandwidthUsed
dst.LoginDetails = src.LoginDetails
dst.Details = src.Details
dst.CanVnc = src.CanVnc
dst.CanReimage = src.CanReimage
dst.CanResize = src.CanResize
dst.CanSnapshot = src.CanSnapshot
dst.CanAddresses = src.CanAddresses
for _, srcAction := range src.Actions {
dstAction := new(api.VirtualMachineAction)
dstAction.Action = srcAction.Action
dstAction.Name = srcAction.Name
dstAction.Options = srcAction.Options
dstAction.Description = srcAction.Description
dstAction.Dangerous = srcAction.Dangerous
dst.Actions = append(dst.Actions, dstAction)
}
}
func copyAddress(src *IpAddress, dst *api.IpAddress) {
dst.Ip = src.Ip
dst.PrivateIp = src.PrivateIp
dst.CanRdns = src.CanRdns
dst.Hostname = src.Hostname
}
func copyImage(src *Image, dst *api.Image) {
dst.Id = src.Id
dst.Region = src.Region
dst.Name = src.Name
dst.Status = src.Status
}
func copyImageDetails(src *ImageInfo, dst *api.ImageDetails) {
dst.Size = src.Size
dst.Details = src.Details
dst.Status = "unknown"
if src.Status == ImagePending {
dst.Status = "pending"
} else if src.Status == ImageActive {
dst.Status = "active"
} else if src.Status == ImageError {
dst.Status = "error"
}
}
func copyPlan(src *Plan, dst *api.Plan) {
dst.Id = src.Id
dst.Name = src.Name
dst.Price = src.Price
dst.Ram = src.Ram
dst.Cpu = src.Cpu
dst.Storage = src.Storage
dst.Bandwidth = src.Bandwidth
}
func copyKey(src *SSHKey, dst *api.Key) {
dst.Id = src.ID
dst.Name = src.Name
dst.Key = src.Key
}
func apiVMList(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
var response api.VMListResponse
for _, vm := range vmList(userId) {
vmCopy := new(api.VirtualMachine)
copyVM(vm, vmCopy)
response.VirtualMachines = append(response.VirtualMachines, vmCopy)
}
apiResponse(w, 200, &response)
}
func apiVMCreate(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
var request api.VMCreateRequest
err := json.Unmarshal(requestBytes, &request)
if err != nil {
http.Error(w, "Invalid json: "+err.Error(), 400)
return
}
vmId, err := vmCreate(userId, request.Name, request.PlanId, request.ImageId, VmCreateOptions{
KeyID: request.KeyId,
})
if err != nil {
http.Error(w, "Create failed: "+err.Error(), 400)
return
} else {
apiResponse(w, 201, api.VMCreateResponse{Id: vmId})
}
}
func apiVMInfo(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, vmId)
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
vm.LoadInfo()
var response api.VMInfoResponse
response.VirtualMachine = new(api.VirtualMachine)
response.Details = new(api.VirtualMachineDetails)
copyVM(vm, response.VirtualMachine)
copyVMDetails(vm.Info, response.Details)
apiResponse(w, 201, response)
}
func apiVMAction(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, vmId)
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
var request api.VMActionRequest
err = json.Unmarshal(requestBytes, &request)
if err != nil {
http.Error(w, "Invalid json: "+err.Error(), 400)
return
}
err = nil
var response interface{}
if request.Action == "start" {
err = vm.Start()
} else if request.Action == "stop" {
err = vm.Stop()
} else if request.Action == "reboot" {
err = vm.Reboot()
} else if request.Action == "vnc" {
var url string
url, err = vm.Vnc()
if err == nil {
response = api.VMVncResponse{Url: url}
}
} else if request.Action == "rename" {
err = vm.Rename(request.Value)
} else if request.Action == "snapshot" {
var imageId int
imageId, err = vm.Snapshot(request.Value)
if err == nil {
response = api.VMSnapshotResponse{Id: imageId}
}
} else {
err = vm.Action(request.Action, request.Value)
}
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 200, response)
}
}
func apiVMReimage(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, vmId)
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
var request api.VMReimageRequest
err = json.Unmarshal(requestBytes, &request)
if err != nil {
http.Error(w, "Invalid json: "+err.Error(), 400)
return
}
err = vmReimage(userId, vm.Id, request.ImageId)
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 200, nil)
}
}
func apiVMResize(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, vmId)
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
var request api.VMResizeRequest
err = json.Unmarshal(requestBytes, &request)
if err != nil {
http.Error(w, "Invalid json: "+err.Error(), 400)
return
}
err = vm.Resize(request.PlanId)
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 200, nil)
}
}
func apiVMDelete(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, vmId)
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
err = vm.Delete(userId)
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 204, nil)
}
}
func apiVMAddresses(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, int(vmId))
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
err = vm.LoadAddresses()
if err != nil {
http.Error(w, err.Error(), 400)
}
var response api.VMAddressesResponse
for _, address := range vm.Addresses {
addressCopy := new(api.IpAddress)
copyAddress(address, addressCopy)
response.Addresses = append(response.Addresses, addressCopy)
}
apiResponse(w, 200, &response)
}
func apiVMAddressAdd(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, vmId)
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
err = vm.AddAddress()
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 200, nil)
}
}
func apiVMAddressRemove(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, vmId)
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
var request api.VMAddressRemoveRequest
err = json.Unmarshal(requestBytes, &request)
if err != nil {
http.Error(w, "Invalid json: "+err.Error(), 400)
return
}
err = vm.RemoveAddress(request.Ip, request.PrivateIp)
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 200, nil)
}
}
func apiVMAddressRdns(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
vmId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid VM ID", 400)
return
}
vm := vmGetUser(userId, vmId)
if vm == nil {
http.Error(w, "No virtual machine with that ID", 404)
return
}
var request api.VMAddressRdnsRequest
err = json.Unmarshal(requestBytes, &request)
if err != nil {
http.Error(w, "Invalid json: "+err.Error(), 400)
return
}
err = vm.SetRdns(mux.Vars(r)["ip"], request.Hostname)
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 200, nil)
}
}
func apiImageList(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
var response api.ImageListResponse
for _, image := range imageList(userId) {
imageCopy := new(api.Image)
copyImage(image, imageCopy)
response.Images = append(response.Images, imageCopy)
}
apiResponse(w, 200, &response)
}
func apiImageFetch(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
var request api.ImageFetchRequest
err := json.Unmarshal(requestBytes, &request)
if err != nil {
http.Error(w, "Invalid json: "+err.Error(), 400)
return
}
imageId, err := imageFetch(userId, request.Region, request.Name, request.Url, request.Format)
if err != nil {
http.Error(w, "Fetch failed: "+err.Error(), 400)
return
} else {
apiResponse(w, 201, api.ImageFetchResponse{Id: imageId})
}
}
func apiImageInfo(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
imageId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid image ID", 400)
return
}
image := imageInfo(userId, imageId)
if image == nil {
http.Error(w, "No image with that ID", 404)
return
}
var response api.ImageInfoResponse
response.Image = new(api.Image)
response.Details = new(api.ImageDetails)
copyImage(image, response.Image)
copyImageDetails(image.Info, response.Details)
apiResponse(w, 201, response)
}
func apiImageDelete(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
imageId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid image ID", 400)
return
}
err = imageDelete(userId, imageId)
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 204, nil)
}
}
func apiPlanList(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
var response api.PlanListResponse
for _, plan := range planList() {
planCopy := new(api.Plan)
copyPlan(plan, planCopy)
response.Plans = append(response.Plans, planCopy)
}
apiResponse(w, 200, &response)
}
func apiKeyList(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
var response api.KeyListResponse
for _, key := range keyList(userId) {
keyCopy := new(api.Key)
copyKey(key, keyCopy)
response.Keys = append(response.Keys, keyCopy)
}
apiResponse(w, 200, &response)
}
func apiKeyAdd(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
var request api.KeyAddRequest
err := json.Unmarshal(requestBytes, &request)
if err != nil {
http.Error(w, "Invalid json: "+err.Error(), 400)
return
}
keyId, err := keyAdd(userId, request.Name, request.Key)
if err != nil {
http.Error(w, "Key add failed: "+err.Error(), 400)
return
} else {
apiResponse(w, 201, api.KeyAddResponse{Id: keyId})
}
}
func apiKeyRemove(w http.ResponseWriter, r *http.Request, userId int, requestBytes []byte) {
keyId, err := strconv.Atoi(mux.Vars(r)["id"])
if err != nil {
http.Error(w, "Invalid key ID", 400)
return
}
err = keyRemove(userId, keyId)
if err != nil {
http.Error(w, err.Error(), 400)
} else {
apiResponse(w, 204, nil)
}
}