slidge-whatsapp 0.3.7__cp312-cp312-manylinux_2_41_aarch64.whl → 0.3.8__cp312-cp312-manylinux_2_41_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slidge_whatsapp/config.py +7 -2
- slidge_whatsapp/contact.py +3 -2
- slidge_whatsapp/event.go +14 -9
- slidge_whatsapp/gateway.go +7 -1
- slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.h +182 -178
- slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.so +0 -0
- slidge_whatsapp/generated/build.py +146 -142
- slidge_whatsapp/generated/whatsapp.c +1456 -1376
- slidge_whatsapp/generated/whatsapp.go +1069 -1045
- slidge_whatsapp/generated/whatsapp.py +1324 -1298
- slidge_whatsapp/generated/whatsapp_go.h +182 -178
- slidge_whatsapp/go.mod +6 -6
- slidge_whatsapp/go.sum +12 -12
- slidge_whatsapp/group.py +25 -0
- slidge_whatsapp/session.go +69 -67
- slidge_whatsapp/session.py +11 -1
- slidge_whatsapp/vendor/github.com/coder/websocket/LICENSE.txt +13 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/Makefile +18 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/README.md +162 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/accept.go +378 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/close.go +335 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/compress.go +234 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/conn.go +306 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/dial.go +347 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/doc.go +33 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/errors.go +8 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/frame.go +173 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/hijack.go +33 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/internal/bpool/bpool.go +25 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/internal/errd/wrap.go +14 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/internal/util/util.go +15 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/internal/wsjs/wsjs_js.go +169 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask.go +128 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask_amd64.s +127 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask_arm64.s +72 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask_asm.go +26 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/mask_go.go +7 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/netconn.go +233 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/netconn_js.go +11 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/netconn_notjs.go +19 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/read.go +540 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/stringer.go +91 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/write.go +384 -0
- slidge_whatsapp/vendor/github.com/coder/websocket/ws_js.go +598 -0
- slidge_whatsapp/vendor/github.com/ebitengine/purego/func.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_amd64.go +1 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_arm64.go +3 -1
- slidge_whatsapp/vendor/github.com/ebitengine/purego/struct_loong64.go +1 -1
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/directive.go +3 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/selection.go +3 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/value.go +4 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/encode.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +18 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/broadcast.go +3 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +6 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +90 -80
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +14 -11
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +4 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +47 -48
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/handshake.go +3 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +79 -75
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/keepalive.go +8 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/mediaconn.go +1 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/mediaretry.go +2 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +42 -40
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/newsletter.go +35 -32
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +2 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair-code.go +2 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair.go +19 -19
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/prekeys.go +9 -8
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/presence.go +9 -9
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/privacysettings.go +4 -5
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAICommon/WAAICommon.pb.go +1145 -335
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAICommon/WAAICommon.proto +78 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waAdv/WAAdv.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloApplication/WAArmadilloApplication.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCert/WACert.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waChatLockSettings/WAProtobufsChatLockSettings.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCommon/WACommon.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.pb.go +22 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.proto +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waConsumerApplication/WAConsumerApplication.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.pb.go +104 -30
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waDeviceCapabilities/WAProtobufsDeviceCapabilities.proto +7 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +1037 -963
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +15 -8
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMediaTransport/WAMediaTransport.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMmsRetry/WAMmsRetry.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgApplication/WAMsgApplication.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/WAMsgTransport.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMultiDevice/WAMultiDevice.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waServerSync/WAServerSync.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +40 -35
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +921 -653
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +44 -15
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waUserPassword/WAProtobufsUserPassword.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waVnameCert/WAWebProtobufsVnameCert.pb.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +9 -5
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +193 -115
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +9 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/push.go +2 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +12 -12
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/request.go +25 -19
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +2 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +43 -27
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +4 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/constants.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/framesocket.go +43 -56
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/noisehandshake.go +9 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/socket/noisesocket.go +36 -22
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +24 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +12 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/appstate.go +2 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/upload.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +79 -40
- slidge_whatsapp/vendor/golang.org/x/sys/unix/mkerrors.sh +2 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_linux.go +6 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux.go +359 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_linux.go +10 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux.go +31 -0
- slidge_whatsapp/vendor/golang.org/x/sys/windows/syscall_windows.go +15 -0
- slidge_whatsapp/vendor/golang.org/x/sys/windows/types_windows.go +76 -0
- slidge_whatsapp/vendor/golang.org/x/sys/windows/zsyscall_windows.go +37 -0
- slidge_whatsapp/vendor/modules.txt +12 -8
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/METADATA +1 -1
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/RECORD +145 -136
- slidge_whatsapp/vendor/github.com/gorilla/websocket/.gitignore +0 -25
- slidge_whatsapp/vendor/github.com/gorilla/websocket/AUTHORS +0 -9
- slidge_whatsapp/vendor/github.com/gorilla/websocket/LICENSE +0 -22
- slidge_whatsapp/vendor/github.com/gorilla/websocket/README.md +0 -33
- slidge_whatsapp/vendor/github.com/gorilla/websocket/client.go +0 -434
- slidge_whatsapp/vendor/github.com/gorilla/websocket/compression.go +0 -148
- slidge_whatsapp/vendor/github.com/gorilla/websocket/conn.go +0 -1238
- slidge_whatsapp/vendor/github.com/gorilla/websocket/doc.go +0 -227
- slidge_whatsapp/vendor/github.com/gorilla/websocket/join.go +0 -42
- slidge_whatsapp/vendor/github.com/gorilla/websocket/json.go +0 -60
- slidge_whatsapp/vendor/github.com/gorilla/websocket/mask.go +0 -55
- slidge_whatsapp/vendor/github.com/gorilla/websocket/mask_safe.go +0 -16
- slidge_whatsapp/vendor/github.com/gorilla/websocket/prepared.go +0 -102
- slidge_whatsapp/vendor/github.com/gorilla/websocket/proxy.go +0 -77
- slidge_whatsapp/vendor/github.com/gorilla/websocket/server.go +0 -365
- slidge_whatsapp/vendor/github.com/gorilla/websocket/tls_handshake.go +0 -21
- slidge_whatsapp/vendor/github.com/gorilla/websocket/tls_handshake_116.go +0 -21
- slidge_whatsapp/vendor/github.com/gorilla/websocket/util.go +0 -298
- slidge_whatsapp/vendor/github.com/gorilla/websocket/x_net_proxy.go +0 -473
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/WHEEL +0 -0
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/entry_points.txt +0 -0
- {slidge_whatsapp-0.3.7.dist-info → slidge_whatsapp-0.3.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
// Package websocket implements the WebSocket protocol defined in RFC 6455.
|
|
6
|
-
//
|
|
7
|
-
// Overview
|
|
8
|
-
//
|
|
9
|
-
// The Conn type represents a WebSocket connection. A server application calls
|
|
10
|
-
// the Upgrader.Upgrade method from an HTTP request handler to get a *Conn:
|
|
11
|
-
//
|
|
12
|
-
// var upgrader = websocket.Upgrader{
|
|
13
|
-
// ReadBufferSize: 1024,
|
|
14
|
-
// WriteBufferSize: 1024,
|
|
15
|
-
// }
|
|
16
|
-
//
|
|
17
|
-
// func handler(w http.ResponseWriter, r *http.Request) {
|
|
18
|
-
// conn, err := upgrader.Upgrade(w, r, nil)
|
|
19
|
-
// if err != nil {
|
|
20
|
-
// log.Println(err)
|
|
21
|
-
// return
|
|
22
|
-
// }
|
|
23
|
-
// ... Use conn to send and receive messages.
|
|
24
|
-
// }
|
|
25
|
-
//
|
|
26
|
-
// Call the connection's WriteMessage and ReadMessage methods to send and
|
|
27
|
-
// receive messages as a slice of bytes. This snippet of code shows how to echo
|
|
28
|
-
// messages using these methods:
|
|
29
|
-
//
|
|
30
|
-
// for {
|
|
31
|
-
// messageType, p, err := conn.ReadMessage()
|
|
32
|
-
// if err != nil {
|
|
33
|
-
// log.Println(err)
|
|
34
|
-
// return
|
|
35
|
-
// }
|
|
36
|
-
// if err := conn.WriteMessage(messageType, p); err != nil {
|
|
37
|
-
// log.Println(err)
|
|
38
|
-
// return
|
|
39
|
-
// }
|
|
40
|
-
// }
|
|
41
|
-
//
|
|
42
|
-
// In above snippet of code, p is a []byte and messageType is an int with value
|
|
43
|
-
// websocket.BinaryMessage or websocket.TextMessage.
|
|
44
|
-
//
|
|
45
|
-
// An application can also send and receive messages using the io.WriteCloser
|
|
46
|
-
// and io.Reader interfaces. To send a message, call the connection NextWriter
|
|
47
|
-
// method to get an io.WriteCloser, write the message to the writer and close
|
|
48
|
-
// the writer when done. To receive a message, call the connection NextReader
|
|
49
|
-
// method to get an io.Reader and read until io.EOF is returned. This snippet
|
|
50
|
-
// shows how to echo messages using the NextWriter and NextReader methods:
|
|
51
|
-
//
|
|
52
|
-
// for {
|
|
53
|
-
// messageType, r, err := conn.NextReader()
|
|
54
|
-
// if err != nil {
|
|
55
|
-
// return
|
|
56
|
-
// }
|
|
57
|
-
// w, err := conn.NextWriter(messageType)
|
|
58
|
-
// if err != nil {
|
|
59
|
-
// return err
|
|
60
|
-
// }
|
|
61
|
-
// if _, err := io.Copy(w, r); err != nil {
|
|
62
|
-
// return err
|
|
63
|
-
// }
|
|
64
|
-
// if err := w.Close(); err != nil {
|
|
65
|
-
// return err
|
|
66
|
-
// }
|
|
67
|
-
// }
|
|
68
|
-
//
|
|
69
|
-
// Data Messages
|
|
70
|
-
//
|
|
71
|
-
// The WebSocket protocol distinguishes between text and binary data messages.
|
|
72
|
-
// Text messages are interpreted as UTF-8 encoded text. The interpretation of
|
|
73
|
-
// binary messages is left to the application.
|
|
74
|
-
//
|
|
75
|
-
// This package uses the TextMessage and BinaryMessage integer constants to
|
|
76
|
-
// identify the two data message types. The ReadMessage and NextReader methods
|
|
77
|
-
// return the type of the received message. The messageType argument to the
|
|
78
|
-
// WriteMessage and NextWriter methods specifies the type of a sent message.
|
|
79
|
-
//
|
|
80
|
-
// It is the application's responsibility to ensure that text messages are
|
|
81
|
-
// valid UTF-8 encoded text.
|
|
82
|
-
//
|
|
83
|
-
// Control Messages
|
|
84
|
-
//
|
|
85
|
-
// The WebSocket protocol defines three types of control messages: close, ping
|
|
86
|
-
// and pong. Call the connection WriteControl, WriteMessage or NextWriter
|
|
87
|
-
// methods to send a control message to the peer.
|
|
88
|
-
//
|
|
89
|
-
// Connections handle received close messages by calling the handler function
|
|
90
|
-
// set with the SetCloseHandler method and by returning a *CloseError from the
|
|
91
|
-
// NextReader, ReadMessage or the message Read method. The default close
|
|
92
|
-
// handler sends a close message to the peer.
|
|
93
|
-
//
|
|
94
|
-
// Connections handle received ping messages by calling the handler function
|
|
95
|
-
// set with the SetPingHandler method. The default ping handler sends a pong
|
|
96
|
-
// message to the peer.
|
|
97
|
-
//
|
|
98
|
-
// Connections handle received pong messages by calling the handler function
|
|
99
|
-
// set with the SetPongHandler method. The default pong handler does nothing.
|
|
100
|
-
// If an application sends ping messages, then the application should set a
|
|
101
|
-
// pong handler to receive the corresponding pong.
|
|
102
|
-
//
|
|
103
|
-
// The control message handler functions are called from the NextReader,
|
|
104
|
-
// ReadMessage and message reader Read methods. The default close and ping
|
|
105
|
-
// handlers can block these methods for a short time when the handler writes to
|
|
106
|
-
// the connection.
|
|
107
|
-
//
|
|
108
|
-
// The application must read the connection to process close, ping and pong
|
|
109
|
-
// messages sent from the peer. If the application is not otherwise interested
|
|
110
|
-
// in messages from the peer, then the application should start a goroutine to
|
|
111
|
-
// read and discard messages from the peer. A simple example is:
|
|
112
|
-
//
|
|
113
|
-
// func readLoop(c *websocket.Conn) {
|
|
114
|
-
// for {
|
|
115
|
-
// if _, _, err := c.NextReader(); err != nil {
|
|
116
|
-
// c.Close()
|
|
117
|
-
// break
|
|
118
|
-
// }
|
|
119
|
-
// }
|
|
120
|
-
// }
|
|
121
|
-
//
|
|
122
|
-
// Concurrency
|
|
123
|
-
//
|
|
124
|
-
// Connections support one concurrent reader and one concurrent writer.
|
|
125
|
-
//
|
|
126
|
-
// Applications are responsible for ensuring that no more than one goroutine
|
|
127
|
-
// calls the write methods (NextWriter, SetWriteDeadline, WriteMessage,
|
|
128
|
-
// WriteJSON, EnableWriteCompression, SetCompressionLevel) concurrently and
|
|
129
|
-
// that no more than one goroutine calls the read methods (NextReader,
|
|
130
|
-
// SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler)
|
|
131
|
-
// concurrently.
|
|
132
|
-
//
|
|
133
|
-
// The Close and WriteControl methods can be called concurrently with all other
|
|
134
|
-
// methods.
|
|
135
|
-
//
|
|
136
|
-
// Origin Considerations
|
|
137
|
-
//
|
|
138
|
-
// Web browsers allow Javascript applications to open a WebSocket connection to
|
|
139
|
-
// any host. It's up to the server to enforce an origin policy using the Origin
|
|
140
|
-
// request header sent by the browser.
|
|
141
|
-
//
|
|
142
|
-
// The Upgrader calls the function specified in the CheckOrigin field to check
|
|
143
|
-
// the origin. If the CheckOrigin function returns false, then the Upgrade
|
|
144
|
-
// method fails the WebSocket handshake with HTTP status 403.
|
|
145
|
-
//
|
|
146
|
-
// If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail
|
|
147
|
-
// the handshake if the Origin request header is present and the Origin host is
|
|
148
|
-
// not equal to the Host request header.
|
|
149
|
-
//
|
|
150
|
-
// The deprecated package-level Upgrade function does not perform origin
|
|
151
|
-
// checking. The application is responsible for checking the Origin header
|
|
152
|
-
// before calling the Upgrade function.
|
|
153
|
-
//
|
|
154
|
-
// Buffers
|
|
155
|
-
//
|
|
156
|
-
// Connections buffer network input and output to reduce the number
|
|
157
|
-
// of system calls when reading or writing messages.
|
|
158
|
-
//
|
|
159
|
-
// Write buffers are also used for constructing WebSocket frames. See RFC 6455,
|
|
160
|
-
// Section 5 for a discussion of message framing. A WebSocket frame header is
|
|
161
|
-
// written to the network each time a write buffer is flushed to the network.
|
|
162
|
-
// Decreasing the size of the write buffer can increase the amount of framing
|
|
163
|
-
// overhead on the connection.
|
|
164
|
-
//
|
|
165
|
-
// The buffer sizes in bytes are specified by the ReadBufferSize and
|
|
166
|
-
// WriteBufferSize fields in the Dialer and Upgrader. The Dialer uses a default
|
|
167
|
-
// size of 4096 when a buffer size field is set to zero. The Upgrader reuses
|
|
168
|
-
// buffers created by the HTTP server when a buffer size field is set to zero.
|
|
169
|
-
// The HTTP server buffers have a size of 4096 at the time of this writing.
|
|
170
|
-
//
|
|
171
|
-
// The buffer sizes do not limit the size of a message that can be read or
|
|
172
|
-
// written by a connection.
|
|
173
|
-
//
|
|
174
|
-
// Buffers are held for the lifetime of the connection by default. If the
|
|
175
|
-
// Dialer or Upgrader WriteBufferPool field is set, then a connection holds the
|
|
176
|
-
// write buffer only when writing a message.
|
|
177
|
-
//
|
|
178
|
-
// Applications should tune the buffer sizes to balance memory use and
|
|
179
|
-
// performance. Increasing the buffer size uses more memory, but can reduce the
|
|
180
|
-
// number of system calls to read or write the network. In the case of writing,
|
|
181
|
-
// increasing the buffer size can reduce the number of frame headers written to
|
|
182
|
-
// the network.
|
|
183
|
-
//
|
|
184
|
-
// Some guidelines for setting buffer parameters are:
|
|
185
|
-
//
|
|
186
|
-
// Limit the buffer sizes to the maximum expected message size. Buffers larger
|
|
187
|
-
// than the largest message do not provide any benefit.
|
|
188
|
-
//
|
|
189
|
-
// Depending on the distribution of message sizes, setting the buffer size to
|
|
190
|
-
// a value less than the maximum expected message size can greatly reduce memory
|
|
191
|
-
// use with a small impact on performance. Here's an example: If 99% of the
|
|
192
|
-
// messages are smaller than 256 bytes and the maximum message size is 512
|
|
193
|
-
// bytes, then a buffer size of 256 bytes will result in 1.01 more system calls
|
|
194
|
-
// than a buffer size of 512 bytes. The memory savings is 50%.
|
|
195
|
-
//
|
|
196
|
-
// A write buffer pool is useful when the application has a modest number
|
|
197
|
-
// writes over a large number of connections. when buffers are pooled, a larger
|
|
198
|
-
// buffer size has a reduced impact on total memory use and has the benefit of
|
|
199
|
-
// reducing system calls and frame overhead.
|
|
200
|
-
//
|
|
201
|
-
// Compression EXPERIMENTAL
|
|
202
|
-
//
|
|
203
|
-
// Per message compression extensions (RFC 7692) are experimentally supported
|
|
204
|
-
// by this package in a limited capacity. Setting the EnableCompression option
|
|
205
|
-
// to true in Dialer or Upgrader will attempt to negotiate per message deflate
|
|
206
|
-
// support.
|
|
207
|
-
//
|
|
208
|
-
// var upgrader = websocket.Upgrader{
|
|
209
|
-
// EnableCompression: true,
|
|
210
|
-
// }
|
|
211
|
-
//
|
|
212
|
-
// If compression was successfully negotiated with the connection's peer, any
|
|
213
|
-
// message received in compressed form will be automatically decompressed.
|
|
214
|
-
// All Read methods will return uncompressed bytes.
|
|
215
|
-
//
|
|
216
|
-
// Per message compression of messages written to a connection can be enabled
|
|
217
|
-
// or disabled by calling the corresponding Conn method:
|
|
218
|
-
//
|
|
219
|
-
// conn.EnableWriteCompression(false)
|
|
220
|
-
//
|
|
221
|
-
// Currently this package does not support compression with "context takeover".
|
|
222
|
-
// This means that messages must be compressed and decompressed in isolation,
|
|
223
|
-
// without retaining sliding window or dictionary state across messages. For
|
|
224
|
-
// more details refer to RFC 7692.
|
|
225
|
-
//
|
|
226
|
-
// Use of compression is experimental and may result in decreased performance.
|
|
227
|
-
package websocket
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Copyright 2019 The Gorilla WebSocket Authors. All rights reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
package websocket
|
|
6
|
-
|
|
7
|
-
import (
|
|
8
|
-
"io"
|
|
9
|
-
"strings"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
// JoinMessages concatenates received messages to create a single io.Reader.
|
|
13
|
-
// The string term is appended to each message. The returned reader does not
|
|
14
|
-
// support concurrent calls to the Read method.
|
|
15
|
-
func JoinMessages(c *Conn, term string) io.Reader {
|
|
16
|
-
return &joinReader{c: c, term: term}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type joinReader struct {
|
|
20
|
-
c *Conn
|
|
21
|
-
term string
|
|
22
|
-
r io.Reader
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
func (r *joinReader) Read(p []byte) (int, error) {
|
|
26
|
-
if r.r == nil {
|
|
27
|
-
var err error
|
|
28
|
-
_, r.r, err = r.c.NextReader()
|
|
29
|
-
if err != nil {
|
|
30
|
-
return 0, err
|
|
31
|
-
}
|
|
32
|
-
if r.term != "" {
|
|
33
|
-
r.r = io.MultiReader(r.r, strings.NewReader(r.term))
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
n, err := r.r.Read(p)
|
|
37
|
-
if err == io.EOF {
|
|
38
|
-
err = nil
|
|
39
|
-
r.r = nil
|
|
40
|
-
}
|
|
41
|
-
return n, err
|
|
42
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
package websocket
|
|
6
|
-
|
|
7
|
-
import (
|
|
8
|
-
"encoding/json"
|
|
9
|
-
"io"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
// WriteJSON writes the JSON encoding of v as a message.
|
|
13
|
-
//
|
|
14
|
-
// Deprecated: Use c.WriteJSON instead.
|
|
15
|
-
func WriteJSON(c *Conn, v interface{}) error {
|
|
16
|
-
return c.WriteJSON(v)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// WriteJSON writes the JSON encoding of v as a message.
|
|
20
|
-
//
|
|
21
|
-
// See the documentation for encoding/json Marshal for details about the
|
|
22
|
-
// conversion of Go values to JSON.
|
|
23
|
-
func (c *Conn) WriteJSON(v interface{}) error {
|
|
24
|
-
w, err := c.NextWriter(TextMessage)
|
|
25
|
-
if err != nil {
|
|
26
|
-
return err
|
|
27
|
-
}
|
|
28
|
-
err1 := json.NewEncoder(w).Encode(v)
|
|
29
|
-
err2 := w.Close()
|
|
30
|
-
if err1 != nil {
|
|
31
|
-
return err1
|
|
32
|
-
}
|
|
33
|
-
return err2
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// ReadJSON reads the next JSON-encoded message from the connection and stores
|
|
37
|
-
// it in the value pointed to by v.
|
|
38
|
-
//
|
|
39
|
-
// Deprecated: Use c.ReadJSON instead.
|
|
40
|
-
func ReadJSON(c *Conn, v interface{}) error {
|
|
41
|
-
return c.ReadJSON(v)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// ReadJSON reads the next JSON-encoded message from the connection and stores
|
|
45
|
-
// it in the value pointed to by v.
|
|
46
|
-
//
|
|
47
|
-
// See the documentation for the encoding/json Unmarshal function for details
|
|
48
|
-
// about the conversion of JSON to a Go value.
|
|
49
|
-
func (c *Conn) ReadJSON(v interface{}) error {
|
|
50
|
-
_, r, err := c.NextReader()
|
|
51
|
-
if err != nil {
|
|
52
|
-
return err
|
|
53
|
-
}
|
|
54
|
-
err = json.NewDecoder(r).Decode(v)
|
|
55
|
-
if err == io.EOF {
|
|
56
|
-
// One value is expected in the message.
|
|
57
|
-
err = io.ErrUnexpectedEOF
|
|
58
|
-
}
|
|
59
|
-
return err
|
|
60
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
|
|
2
|
-
// this source code is governed by a BSD-style license that can be found in the
|
|
3
|
-
// LICENSE file.
|
|
4
|
-
|
|
5
|
-
//go:build !appengine
|
|
6
|
-
// +build !appengine
|
|
7
|
-
|
|
8
|
-
package websocket
|
|
9
|
-
|
|
10
|
-
import "unsafe"
|
|
11
|
-
|
|
12
|
-
const wordSize = int(unsafe.Sizeof(uintptr(0)))
|
|
13
|
-
|
|
14
|
-
func maskBytes(key [4]byte, pos int, b []byte) int {
|
|
15
|
-
// Mask one byte at a time for small buffers.
|
|
16
|
-
if len(b) < 2*wordSize {
|
|
17
|
-
for i := range b {
|
|
18
|
-
b[i] ^= key[pos&3]
|
|
19
|
-
pos++
|
|
20
|
-
}
|
|
21
|
-
return pos & 3
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Mask one byte at a time to word boundary.
|
|
25
|
-
if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 {
|
|
26
|
-
n = wordSize - n
|
|
27
|
-
for i := range b[:n] {
|
|
28
|
-
b[i] ^= key[pos&3]
|
|
29
|
-
pos++
|
|
30
|
-
}
|
|
31
|
-
b = b[n:]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Create aligned word size key.
|
|
35
|
-
var k [wordSize]byte
|
|
36
|
-
for i := range k {
|
|
37
|
-
k[i] = key[(pos+i)&3]
|
|
38
|
-
}
|
|
39
|
-
kw := *(*uintptr)(unsafe.Pointer(&k))
|
|
40
|
-
|
|
41
|
-
// Mask one word at a time.
|
|
42
|
-
n := (len(b) / wordSize) * wordSize
|
|
43
|
-
for i := 0; i < n; i += wordSize {
|
|
44
|
-
*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Mask one byte at a time for remaining bytes.
|
|
48
|
-
b = b[n:]
|
|
49
|
-
for i := range b {
|
|
50
|
-
b[i] ^= key[pos&3]
|
|
51
|
-
pos++
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return pos & 3
|
|
55
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
|
|
2
|
-
// this source code is governed by a BSD-style license that can be found in the
|
|
3
|
-
// LICENSE file.
|
|
4
|
-
|
|
5
|
-
//go:build appengine
|
|
6
|
-
// +build appengine
|
|
7
|
-
|
|
8
|
-
package websocket
|
|
9
|
-
|
|
10
|
-
func maskBytes(key [4]byte, pos int, b []byte) int {
|
|
11
|
-
for i := range b {
|
|
12
|
-
b[i] ^= key[pos&3]
|
|
13
|
-
pos++
|
|
14
|
-
}
|
|
15
|
-
return pos & 3
|
|
16
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// Copyright 2017 The Gorilla WebSocket Authors. All rights reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
package websocket
|
|
6
|
-
|
|
7
|
-
import (
|
|
8
|
-
"bytes"
|
|
9
|
-
"net"
|
|
10
|
-
"sync"
|
|
11
|
-
"time"
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
// PreparedMessage caches on the wire representations of a message payload.
|
|
15
|
-
// Use PreparedMessage to efficiently send a message payload to multiple
|
|
16
|
-
// connections. PreparedMessage is especially useful when compression is used
|
|
17
|
-
// because the CPU and memory expensive compression operation can be executed
|
|
18
|
-
// once for a given set of compression options.
|
|
19
|
-
type PreparedMessage struct {
|
|
20
|
-
messageType int
|
|
21
|
-
data []byte
|
|
22
|
-
mu sync.Mutex
|
|
23
|
-
frames map[prepareKey]*preparedFrame
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// prepareKey defines a unique set of options to cache prepared frames in PreparedMessage.
|
|
27
|
-
type prepareKey struct {
|
|
28
|
-
isServer bool
|
|
29
|
-
compress bool
|
|
30
|
-
compressionLevel int
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// preparedFrame contains data in wire representation.
|
|
34
|
-
type preparedFrame struct {
|
|
35
|
-
once sync.Once
|
|
36
|
-
data []byte
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// NewPreparedMessage returns an initialized PreparedMessage. You can then send
|
|
40
|
-
// it to connection using WritePreparedMessage method. Valid wire
|
|
41
|
-
// representation will be calculated lazily only once for a set of current
|
|
42
|
-
// connection options.
|
|
43
|
-
func NewPreparedMessage(messageType int, data []byte) (*PreparedMessage, error) {
|
|
44
|
-
pm := &PreparedMessage{
|
|
45
|
-
messageType: messageType,
|
|
46
|
-
frames: make(map[prepareKey]*preparedFrame),
|
|
47
|
-
data: data,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Prepare a plain server frame.
|
|
51
|
-
_, frameData, err := pm.frame(prepareKey{isServer: true, compress: false})
|
|
52
|
-
if err != nil {
|
|
53
|
-
return nil, err
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// To protect against caller modifying the data argument, remember the data
|
|
57
|
-
// copied to the plain server frame.
|
|
58
|
-
pm.data = frameData[len(frameData)-len(data):]
|
|
59
|
-
return pm, nil
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
func (pm *PreparedMessage) frame(key prepareKey) (int, []byte, error) {
|
|
63
|
-
pm.mu.Lock()
|
|
64
|
-
frame, ok := pm.frames[key]
|
|
65
|
-
if !ok {
|
|
66
|
-
frame = &preparedFrame{}
|
|
67
|
-
pm.frames[key] = frame
|
|
68
|
-
}
|
|
69
|
-
pm.mu.Unlock()
|
|
70
|
-
|
|
71
|
-
var err error
|
|
72
|
-
frame.once.Do(func() {
|
|
73
|
-
// Prepare a frame using a 'fake' connection.
|
|
74
|
-
// TODO: Refactor code in conn.go to allow more direct construction of
|
|
75
|
-
// the frame.
|
|
76
|
-
mu := make(chan struct{}, 1)
|
|
77
|
-
mu <- struct{}{}
|
|
78
|
-
var nc prepareConn
|
|
79
|
-
c := &Conn{
|
|
80
|
-
conn: &nc,
|
|
81
|
-
mu: mu,
|
|
82
|
-
isServer: key.isServer,
|
|
83
|
-
compressionLevel: key.compressionLevel,
|
|
84
|
-
enableWriteCompression: true,
|
|
85
|
-
writeBuf: make([]byte, defaultWriteBufferSize+maxFrameHeaderSize),
|
|
86
|
-
}
|
|
87
|
-
if key.compress {
|
|
88
|
-
c.newCompressionWriter = compressNoContextTakeover
|
|
89
|
-
}
|
|
90
|
-
err = c.WriteMessage(pm.messageType, pm.data)
|
|
91
|
-
frame.data = nc.buf.Bytes()
|
|
92
|
-
})
|
|
93
|
-
return pm.messageType, frame.data, err
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
type prepareConn struct {
|
|
97
|
-
buf bytes.Buffer
|
|
98
|
-
net.Conn
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
func (pc *prepareConn) Write(p []byte) (int, error) { return pc.buf.Write(p) }
|
|
102
|
-
func (pc *prepareConn) SetWriteDeadline(t time.Time) error { return nil }
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// Copyright 2017 The Gorilla WebSocket Authors. All rights reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
package websocket
|
|
6
|
-
|
|
7
|
-
import (
|
|
8
|
-
"bufio"
|
|
9
|
-
"encoding/base64"
|
|
10
|
-
"errors"
|
|
11
|
-
"net"
|
|
12
|
-
"net/http"
|
|
13
|
-
"net/url"
|
|
14
|
-
"strings"
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
type netDialerFunc func(network, addr string) (net.Conn, error)
|
|
18
|
-
|
|
19
|
-
func (fn netDialerFunc) Dial(network, addr string) (net.Conn, error) {
|
|
20
|
-
return fn(network, addr)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
func init() {
|
|
24
|
-
proxy_RegisterDialerType("http", func(proxyURL *url.URL, forwardDialer proxy_Dialer) (proxy_Dialer, error) {
|
|
25
|
-
return &httpProxyDialer{proxyURL: proxyURL, forwardDial: forwardDialer.Dial}, nil
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type httpProxyDialer struct {
|
|
30
|
-
proxyURL *url.URL
|
|
31
|
-
forwardDial func(network, addr string) (net.Conn, error)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error) {
|
|
35
|
-
hostPort, _ := hostPortNoPort(hpd.proxyURL)
|
|
36
|
-
conn, err := hpd.forwardDial(network, hostPort)
|
|
37
|
-
if err != nil {
|
|
38
|
-
return nil, err
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
connectHeader := make(http.Header)
|
|
42
|
-
if user := hpd.proxyURL.User; user != nil {
|
|
43
|
-
proxyUser := user.Username()
|
|
44
|
-
if proxyPassword, passwordSet := user.Password(); passwordSet {
|
|
45
|
-
credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword))
|
|
46
|
-
connectHeader.Set("Proxy-Authorization", "Basic "+credential)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
connectReq := &http.Request{
|
|
51
|
-
Method: http.MethodConnect,
|
|
52
|
-
URL: &url.URL{Opaque: addr},
|
|
53
|
-
Host: addr,
|
|
54
|
-
Header: connectHeader,
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if err := connectReq.Write(conn); err != nil {
|
|
58
|
-
conn.Close()
|
|
59
|
-
return nil, err
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Read response. It's OK to use and discard buffered reader here becaue
|
|
63
|
-
// the remote server does not speak until spoken to.
|
|
64
|
-
br := bufio.NewReader(conn)
|
|
65
|
-
resp, err := http.ReadResponse(br, connectReq)
|
|
66
|
-
if err != nil {
|
|
67
|
-
conn.Close()
|
|
68
|
-
return nil, err
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if resp.StatusCode != 200 {
|
|
72
|
-
conn.Close()
|
|
73
|
-
f := strings.SplitN(resp.Status, " ", 2)
|
|
74
|
-
return nil, errors.New(f[1])
|
|
75
|
-
}
|
|
76
|
-
return conn, nil
|
|
77
|
-
}
|