Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fix registration
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Nov 7, 2022
1 parent 54d322b commit 69f0541
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/textsecure/.config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
tel: "+1771111001"

#Server URL
server: https://textsecure-service.whispersystems.org:443
server: https://chat.signal.org:443

#Server's TLS root certificate path when using a non-default server
#See https://github.com/janimo/textsecure-docker#using-https
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func loadConfig() (*config.Config, error) {
}

if cfg.Server == "" {
cfg.Server = "https://textsecure-service.whispersystems.org:443"
cfg.Server = "https://chat.signal.org:443"
}

if cfg.VerificationType == "" {
Expand Down
1 change: 1 addition & 0 deletions crayfish/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type CrayfishWebSocketRequest_VERIFY_REGISTER_MESSAGE struct {
Number string `json:"number"`
Password string `json:"password"`
SignalingKey [52]byte `json:"signaling_key"`
Name string `json:"name"`
}

type CrayfishWebSocketRequestMessageTyp_SEALED_SESSION_DECRYPT_Message struct {
Expand Down
1 change: 1 addition & 0 deletions crayfish/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (c *CrayfishInstance) CrayfishRegisterWithCode(registrationInfo *registrati
Code: codeInt,
SignalingKey: signalingKey,
Password: registrationInfo.Password,
Name: registrationInfo.Name,
}
requestVerifyType := CrayfishWebSocketRequestMessageTyp_VERIFY_REGISTRATION
verificationRequest := &CrayfishWebSocketRequestMessage{
Expand Down
5 changes: 4 additions & 1 deletion profiles/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,11 @@ func GetProfileAndCredential(UUID string, profileKey []byte) (*Profile, error) {
if len(profileKey) == 0 {
return nil, errors.New("profileKey is empty")
}
if (len(UUID) == 0) || (UUID == "00000000-0000-0000-0000-000000000000") {
return nil, errors.New("UUID is empty")
}

log.Infoln("[textsecure] GetProfileAndCredential for " + UUID)
log.Infoln("[textsecure] GetProfileAndCredential for" + UUID)
uuid, err := uuidUtil.FromString(UUID)
if err != nil {
log.Debugln("[textsecure] GetProfileAndCredential", err)
Expand Down
1 change: 1 addition & 0 deletions registration/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type RegistrationInfo struct {
RegistrationID uint32
SignalingKey []byte
CaptchaToken string
Name string
}

var Registration RegistrationInfo
10 changes: 8 additions & 2 deletions textsecure.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ var (
// and environment variables
func setupLogging() {
loglevel := config.ConfigFile.LogLevel
if loglevel == "" {
if loglevel == "" || os.Getenv("TEXTSECURE_LOGLEVEL") != "" {
loglevel = os.Getenv("TEXTSECURE_LOGLEVEL")
}
fmt.Printf("INFO[0000] [textsecure] Setting log level to %s\n", loglevel)
Expand All @@ -250,7 +250,7 @@ func setupLogging() {
case "ERROR":
log.SetLevel(log.ErrorLevel)
default:
log.SetLevel(log.ErrorLevel)
log.SetLevel(log.InfoLevel)
}

log.SetFormatter(&log.TextFormatter{
Expand Down Expand Up @@ -408,6 +408,8 @@ func registerDevice() error {
client.GetConfig()
phoneNumber := client.GetPhoneNumber()
captcha := client.GetCaptchaToken()
name := client.GetUsername()
registration.Registration.Name = name
err = RegisterWithCrayfish(&registration.Registration, phoneNumber, captcha)
if err != nil {
log.Errorln("[textsecure] Crayfish registration failed", err)
Expand All @@ -421,6 +423,7 @@ func registerDevice() error {
}
config.ConfigFile.Tel = crayfishRegistration.Tel
config.ConfigFile.UUID = crayfishRegistration.UUID
config.ConfigFile.Name = name
config.ConfigFile.AccountCapabilities = config.AccountCapabilities{
// Uuid: false,
Gv2: true,
Expand All @@ -432,6 +435,9 @@ func registerDevice() error {
}

err = saveConfig(config.ConfigFile)
if err != nil {
return err
}
log.Debugln("[textsecure] Crayfish registration done")
transport.SetupTransporter(config.ConfigFile.Server, config.ConfigFile.UUID, registration.Registration.Password, config.ConfigFile.UserAgent, config.ConfigFile.ProxyServer)

Expand Down

0 comments on commit 69f0541

Please sign in to comment.