Run goimports
This commit is contained in:
parent
02ef5ab82c
commit
cdf9b1e4a0
16 changed files with 127 additions and 130 deletions
|
@ -2,6 +2,7 @@ package binary
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
5
libgm/cache/settings.go
vendored
5
libgm/cache/settings.go
vendored
|
@ -1,8 +1,7 @@
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
CarrierName string `json:"carrierName,omitempty"`
|
CarrierName string `json:"carrierName,omitempty"`
|
||||||
HexHash string `json:"hexHash,omitempty"`
|
HexHash string `json:"hexHash,omitempty"`
|
||||||
Version string `json:"version,omitempty"`
|
Version string `json:"version,omitempty"`
|
||||||
}
|
}
|
|
@ -15,25 +15,25 @@ func EncodeBase64(data []byte) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Base64Decode(input string) ([]byte, error) {
|
func Base64Decode(input string) ([]byte, error) {
|
||||||
padding := len(input) % 4
|
padding := len(input) % 4
|
||||||
if padding > 0 {
|
if padding > 0 {
|
||||||
input += strings.Repeat("=", 4-padding)
|
input += strings.Repeat("=", 4-padding)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := base64.URLEncoding.DecodeString(input)
|
data, err := base64.URLEncoding.DecodeString(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Base64DecodeStandard(input string) ([]byte, error) {
|
func Base64DecodeStandard(input string) ([]byte, error) {
|
||||||
decoded, err := base64.StdEncoding.DecodeString(input)
|
decoded, err := base64.StdEncoding.DecodeString(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("decode error:", err)
|
fmt.Println("decode error:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return decoded, nil
|
return decoded, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Base64Encode(input []byte) string {
|
func Base64Encode(input []byte) string {
|
||||||
|
|
|
@ -11,14 +11,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type JWK struct {
|
type JWK struct {
|
||||||
Kty string `json:"kty"`
|
Kty string `json:"kty"`
|
||||||
Crv string `json:"crv"`
|
Crv string `json:"crv"`
|
||||||
D string `json:"d"`
|
D string `json:"d"`
|
||||||
X string `json:"x"`
|
X string `json:"x"`
|
||||||
Y string `json:"y"`
|
Y string `json:"y"`
|
||||||
Ext bool `json:"ext"`
|
Ext bool `json:"ext"`
|
||||||
KeyOps []string `json:"key_ops"`
|
KeyOps []string `json:"key_ops"`
|
||||||
PrivateBytes []byte `json:"privateBytes,omitempty"`
|
PrivateBytes []byte `json:"privateBytes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a byte slice containing the JWK and an error if the generation or export failed.
|
// Returns a byte slice containing the JWK and an error if the generation or export failed.
|
||||||
|
@ -26,13 +26,13 @@ func (t *JWK) Marshal() ([]byte, error) {
|
||||||
JWKJSON, err := json.Marshal(t)
|
JWKJSON, err := json.Marshal(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to marshal JWK: %v", err)
|
fmt.Printf("Failed to marshal JWK: %v", err)
|
||||||
return nil,err
|
return nil, err
|
||||||
}
|
}
|
||||||
fmt.Printf("%s\n", JWKJSON)
|
fmt.Printf("%s\n", JWKJSON)
|
||||||
return JWKJSON,err
|
return JWKJSON, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *JWK) PrivKeyB64Bytes() ([]byte, error){
|
func (t *JWK) PrivKeyB64Bytes() ([]byte, error) {
|
||||||
decodedPrivateKey, err2 := Base64Decode(t.D)
|
decodedPrivateKey, err2 := Base64Decode(t.D)
|
||||||
return decodedPrivateKey, err2
|
return decodedPrivateKey, err2
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ func GenerateECDSA_P256_JWK() (*JWK, error) {
|
||||||
privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to generate private key: %v", err)
|
fmt.Printf("Failed to generate private key: %v", err)
|
||||||
return nil,err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
JWK := &JWK{
|
JWK := &JWK{
|
||||||
|
@ -109,5 +109,5 @@ func GenerateECDSA_P256_JWK() (*JWK, error) {
|
||||||
Ext: true,
|
Ext: true,
|
||||||
KeyOps: []string{"sign"},
|
KeyOps: []string{"sign"},
|
||||||
}
|
}
|
||||||
return JWK,nil
|
return JWK, nil
|
||||||
}
|
}
|
|
@ -75,7 +75,7 @@ func (ic *ImageCryptor) Decrypt(iv []byte, data []byte, aad []byte) ([]byte, err
|
||||||
|
|
||||||
func (ic *ImageCryptor) EncryptData(data []byte) ([]byte, error) {
|
func (ic *ImageCryptor) EncryptData(data []byte) ([]byte, error) {
|
||||||
rawChunkSize := 1 << 15
|
rawChunkSize := 1 << 15
|
||||||
chunkSize := rawChunkSize-28
|
chunkSize := rawChunkSize - 28
|
||||||
var tasks []chan []byte
|
var tasks []chan []byte
|
||||||
chunkIndex := 0
|
chunkIndex := 0
|
||||||
|
|
||||||
|
|
|
@ -3,21 +3,22 @@ package debug
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/mattn/go-colorable"
|
||||||
zerolog "github.com/rs/zerolog"
|
zerolog "github.com/rs/zerolog"
|
||||||
)
|
)
|
||||||
|
|
||||||
var colors = map[string]string{
|
var colors = map[string]string{
|
||||||
"text": "\x1b[38;5;6m%s\x1b[0m",
|
"text": "\x1b[38;5;6m%s\x1b[0m",
|
||||||
"debug": "\x1b[32mDEBUG\x1b[0m",
|
"debug": "\x1b[32mDEBUG\x1b[0m",
|
||||||
"gray": "\x1b[38;5;8m%s\x1b[0m",
|
"gray": "\x1b[38;5;8m%s\x1b[0m",
|
||||||
"info": "\x1b[38;5;111mINFO\x1b[0m",
|
"info": "\x1b[38;5;111mINFO\x1b[0m",
|
||||||
"error": "\x1b[38;5;204mERROR\x1b[0m",
|
"error": "\x1b[38;5;204mERROR\x1b[0m",
|
||||||
"fatal": "\x1b[38;5;52mFATAL\x1b[0m",
|
"fatal": "\x1b[38;5;52mFATAL\x1b[0m",
|
||||||
}
|
}
|
||||||
|
|
||||||
var output = zerolog.ConsoleWriter{
|
var output = zerolog.ConsoleWriter{
|
||||||
Out: colorable.NewColorableStdout(),
|
Out: colorable.NewColorableStdout(),
|
||||||
TimeFormat: time.ANSIC,
|
TimeFormat: time.ANSIC,
|
||||||
FormatLevel: func(i interface{}) string {
|
FormatLevel: func(i interface{}) string {
|
||||||
name := fmt.Sprintf("%s", i)
|
name := fmt.Sprintf("%s", i)
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package events
|
package events
|
||||||
|
|
||||||
type QRCODE_UPDATED struct {
|
type QRCODE_UPDATED struct {
|
||||||
Image []byte
|
Image []byte
|
||||||
Height int
|
Height int
|
||||||
Width int
|
Width int
|
||||||
|
|
||||||
googleUrl string
|
googleUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewQrCodeUpdated(image []byte, height int, width int, googleUrl string) *QRCODE_UPDATED {
|
func NewQrCodeUpdated(image []byte, height int, width int, googleUrl string) *QRCODE_UPDATED {
|
||||||
return &QRCODE_UPDATED{
|
return &QRCODE_UPDATED{
|
||||||
Image: image,
|
Image: image,
|
||||||
Height: height,
|
Height: height,
|
||||||
Width: width,
|
Width: width,
|
||||||
googleUrl: googleUrl,
|
googleUrl: googleUrl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package events
|
package events
|
||||||
|
|
||||||
|
|
||||||
type BROWSER_ACTIVE struct {
|
type BROWSER_ACTIVE struct {
|
||||||
SessionId string
|
SessionId string
|
||||||
}
|
}
|
||||||
|
@ -11,13 +10,13 @@ func NewBrowserActive(sessionId string) *BROWSER_ACTIVE {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type BATTERY struct {}
|
type BATTERY struct{}
|
||||||
|
|
||||||
func NewBattery() *BATTERY {
|
func NewBattery() *BATTERY {
|
||||||
return &BATTERY{}
|
return &BATTERY{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DATA_CONNECTION struct {}
|
type DATA_CONNECTION struct{}
|
||||||
|
|
||||||
func NewDataConnection() *DATA_CONNECTION {
|
func NewDataConnection() *DATA_CONNECTION {
|
||||||
return &DATA_CONNECTION{}
|
return &DATA_CONNECTION{}
|
||||||
|
|
|
@ -57,44 +57,44 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Serialize(m protoreflect.Message) ([]interface{}, error) {
|
func Serialize(m protoreflect.Message) ([]interface{}, error) {
|
||||||
maxFieldNumber := 0
|
maxFieldNumber := 0
|
||||||
for i := 0; i < m.Descriptor().Fields().Len(); i++ {
|
for i := 0; i < m.Descriptor().Fields().Len(); i++ {
|
||||||
fieldNumber := int(m.Descriptor().Fields().Get(i).Number())
|
fieldNumber := int(m.Descriptor().Fields().Get(i).Number())
|
||||||
if fieldNumber > maxFieldNumber {
|
if fieldNumber > maxFieldNumber {
|
||||||
maxFieldNumber = fieldNumber
|
maxFieldNumber = fieldNumber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
serialized := make([]interface{}, maxFieldNumber)
|
serialized := make([]interface{}, maxFieldNumber)
|
||||||
for i := 0; i < m.Descriptor().Fields().Len(); i++ {
|
for i := 0; i < m.Descriptor().Fields().Len(); i++ {
|
||||||
fieldDescriptor := m.Descriptor().Fields().Get(i)
|
fieldDescriptor := m.Descriptor().Fields().Get(i)
|
||||||
fieldValue := m.Get(fieldDescriptor)
|
fieldValue := m.Get(fieldDescriptor)
|
||||||
fieldNumber := int(fieldDescriptor.Number())
|
fieldNumber := int(fieldDescriptor.Number())
|
||||||
switch fieldDescriptor.Kind() {
|
switch fieldDescriptor.Kind() {
|
||||||
case protoreflect.MessageKind:
|
case protoreflect.MessageKind:
|
||||||
if m.Has(fieldDescriptor) {
|
if m.Has(fieldDescriptor) {
|
||||||
serializedMsg, err := Serialize(fieldValue.Message().Interface().ProtoReflect())
|
serializedMsg, err := Serialize(fieldValue.Message().Interface().ProtoReflect())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
serialized[fieldNumber-1] = serializedMsg
|
serialized[fieldNumber-1] = serializedMsg
|
||||||
}
|
}
|
||||||
case protoreflect.BytesKind:
|
case protoreflect.BytesKind:
|
||||||
if m.Has(fieldDescriptor) {
|
if m.Has(fieldDescriptor) {
|
||||||
serialized[fieldNumber-1] = fieldValue.Bytes()
|
serialized[fieldNumber-1] = fieldValue.Bytes()
|
||||||
}
|
}
|
||||||
case protoreflect.Int32Kind, protoreflect.Int64Kind:
|
case protoreflect.Int32Kind, protoreflect.Int64Kind:
|
||||||
if m.Has(fieldDescriptor) {
|
if m.Has(fieldDescriptor) {
|
||||||
serialized[fieldNumber-1] = fieldValue.Int()
|
serialized[fieldNumber-1] = fieldValue.Int()
|
||||||
}
|
}
|
||||||
case protoreflect.StringKind:
|
case protoreflect.StringKind:
|
||||||
if m.Has(fieldDescriptor) {
|
if m.Has(fieldDescriptor) {
|
||||||
serialized[fieldNumber-1] = fieldValue.String()
|
serialized[fieldNumber-1] = fieldValue.String()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// ignore fields of other types
|
// ignore fields of other types
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return serialized, nil
|
return serialized, nil
|
||||||
}
|
}
|
|
@ -7,10 +7,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ResponseChan struct {
|
type ResponseChan struct {
|
||||||
responses []*Response
|
responses []*Response
|
||||||
receivedResponses int64
|
receivedResponses int64
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SessionHandler) addRequestToChannel(requestId string, opCode int64) {
|
func (s *SessionHandler) addRequestToChannel(requestId string, opCode int64) {
|
||||||
|
@ -42,7 +42,6 @@ func (s *SessionHandler) addRequestToChannel(requestId string, opCode int64) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s *SessionHandler) respondToRequestChannel(res *Response) {
|
func (s *SessionHandler) respondToRequestChannel(res *Response) {
|
||||||
requestId := res.Data.RequestId
|
requestId := res.Data.RequestId
|
||||||
reqChannel, ok := s.requests[requestId]
|
reqChannel, ok := s.requests[requestId]
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
|
|
||||||
var GOOG_API_KEY = "AIzaSyCA4RsOZUFrm9whhtGosPlJLmVPnfSHKz8"
|
var GOOG_API_KEY = "AIzaSyCA4RsOZUFrm9whhtGosPlJLmVPnfSHKz8"
|
||||||
var USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
|
var USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
|
||||||
var OS = "Linux"
|
var OS = "Linux"
|
||||||
|
|
|
@ -2,7 +2,6 @@ package util
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
|
||||||
type InstructionNotFound struct {
|
type InstructionNotFound struct {
|
||||||
Opcode int64
|
Opcode int64
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,17 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nu7hatch/gouuid"
|
uuid "github.com/nu7hatch/gouuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Charset = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
|
var Charset = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
|
||||||
|
|
||||||
func RandStr(length int) string {
|
func RandStr(length int) string {
|
||||||
b := make([]rune, length)
|
b := make([]rune, length)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = Charset[rand.Intn(len(Charset))]
|
b[i] = Charset[rand.Intn(len(Charset))]
|
||||||
}
|
}
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenerateImageId() string {
|
func GenerateImageId() string {
|
||||||
|
@ -35,8 +35,8 @@ func GenerateTmpId() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseTimestamp(unixTs int64) time.Time {
|
func ParseTimestamp(unixTs int64) time.Time {
|
||||||
seconds := unixTs / int64(time.Second / time.Microsecond)
|
seconds := unixTs / int64(time.Second/time.Microsecond)
|
||||||
nanoseconds := (unixTs % int64(time.Second / time.Microsecond)) * int64(time.Microsecond / time.Nanosecond)
|
nanoseconds := (unixTs % int64(time.Second/time.Microsecond)) * int64(time.Microsecond/time.Nanosecond)
|
||||||
return time.Unix(seconds, nanoseconds).UTC()
|
return time.Unix(seconds, nanoseconds).UTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@ func RandomUUIDv4() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoveFromSlice(s []string, v string) []string {
|
func RemoveFromSlice(s []string, v string) []string {
|
||||||
newS := []string{}
|
newS := []string{}
|
||||||
for _, i := range s {
|
for _, i := range s {
|
||||||
if i != v {
|
if i != v {
|
||||||
newS = append(newS, i)
|
newS = append(newS, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newS
|
return newS
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildRelayHeaders(req *http.Request, contentType string, accept string) {
|
func BuildRelayHeaders(req *http.Request, contentType string, accept string) {
|
||||||
|
|
|
@ -2,22 +2,22 @@ package util
|
||||||
|
|
||||||
var MESSAGES_GOOGLE_BASE_URL = "https://messages.google.com"
|
var MESSAGES_GOOGLE_BASE_URL = "https://messages.google.com"
|
||||||
|
|
||||||
var MESSAGES_GOOGLE_AUTHENTICATION = MESSAGES_GOOGLE_BASE_URL+"/web/authentication"
|
var MESSAGES_GOOGLE_AUTHENTICATION = MESSAGES_GOOGLE_BASE_URL + "/web/authentication"
|
||||||
var MESSAGES_GOOGLE_TIMESOURCE = MESSAGES_GOOGLE_BASE_URL+"/web/timesource"
|
var MESSAGES_GOOGLE_TIMESOURCE = MESSAGES_GOOGLE_BASE_URL + "/web/timesource"
|
||||||
|
|
||||||
var INSTANT_MESSAGING = "https://instantmessaging-pa.googleapis.com"
|
var INSTANT_MESSAGING = "https://instantmessaging-pa.googleapis.com"
|
||||||
|
|
||||||
var UPLOAD_MEDIA = INSTANT_MESSAGING+"/upload"
|
var UPLOAD_MEDIA = INSTANT_MESSAGING + "/upload"
|
||||||
|
|
||||||
var PAIRING = INSTANT_MESSAGING+"/$rpc/google.internal.communications.instantmessaging.v1.Pairing"
|
var PAIRING = INSTANT_MESSAGING + "/$rpc/google.internal.communications.instantmessaging.v1.Pairing"
|
||||||
var REGISTER_PHONE_RELAY = PAIRING+"/RegisterPhoneRelay"
|
var REGISTER_PHONE_RELAY = PAIRING + "/RegisterPhoneRelay"
|
||||||
var REFRESH_PHONE_RELAY = PAIRING+"/RefreshPhoneRelay"
|
var REFRESH_PHONE_RELAY = PAIRING + "/RefreshPhoneRelay"
|
||||||
var GET_WEB_ENCRYPTION_KEY = PAIRING+"/GetWebEncryptionKey"
|
var GET_WEB_ENCRYPTION_KEY = PAIRING + "/GetWebEncryptionKey"
|
||||||
|
|
||||||
var MESSAGING = INSTANT_MESSAGING+"/$rpc/google.internal.communications.instantmessaging.v1.Messaging"
|
var MESSAGING = INSTANT_MESSAGING + "/$rpc/google.internal.communications.instantmessaging.v1.Messaging"
|
||||||
var RECEIVE_MESSAGES = MESSAGING+"/ReceiveMessages"
|
var RECEIVE_MESSAGES = MESSAGING + "/ReceiveMessages"
|
||||||
var SEND_MESSAGE = MESSAGING+"/SendMessage"
|
var SEND_MESSAGE = MESSAGING + "/SendMessage"
|
||||||
var ACK_MESSAGES = MESSAGING+"/AckMessages"
|
var ACK_MESSAGES = MESSAGING + "/AckMessages"
|
||||||
|
|
||||||
var TENOR_BASE_URL = "https://api.tenor.com/v1"
|
var TENOR_BASE_URL = "https://api.tenor.com/v1"
|
||||||
var TENOR_SEARCH_GIF = TENOR_BASE_URL+"/search"
|
var TENOR_SEARCH_GIF = TENOR_BASE_URL + "/search"
|
||||||
|
|
Loading…
Reference in a new issue