Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nanu-c committed Jan 27, 2021
1 parent e32844b commit e77a304
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func updateContact(c *signalservice.ContactDetails) error {
InboxPosition: c.GetInboxPosition(),
Archived: c.GetArchived(),
}
log.Debugln(c.GetAvatar(), buf)
log.Debugln("[textsecure] avatar", c.GetAvatar(), buf)
return WriteContactsToPath()
}

Expand Down
2 changes: 1 addition & 1 deletion fingerprint/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func getFingerprint(iterations int, stableIdentifier []byte, identityKeys []axol
buf := new(bytes.Buffer)
err := binary.Write(buf, binary.BigEndian, FINGERPRINT_VERSION)
if err != nil {
fmt.Println("binary.Write failed:", err)
fmt.Println("[textsecure] binary.Write failed:", err)
}
version := buf.Bytes()
startData := append(version, publicKey...)
Expand Down
1 change: 0 additions & 1 deletion groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ func RequestGroupInfo(g *Group) error {
log.Debugln("[textsecure] request group update", g.Hexid)
for _, m := range g.Members {
if m != config.Tel {
log.Debugln(m)
omsg := &outgoingMessage{
destination: m,
group: &groupMessage{
Expand Down
22 changes: 9 additions & 13 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,23 @@ func requestCode(tel, method string) (string, error) {
log.Infoln("[textsecure] request verification code for ", tel)
resp, err := transport.Transport.Get(fmt.Sprintf(createAccountPath, method, tel, "android"))
if err != nil {
fmt.Println(err.Error())
log.Errorln("[textsecure] requestCode", err)
return "", err
}
if resp.IsError() {
if resp.Status == 402 {
log.Debugln(resp.Body)
buf := new(bytes.Buffer)
buf.ReadFrom(resp.Body)
newStr := buf.String()
fmt.Printf(newStr)
log.Errorln("[textsecure] requestCode", newStr)
defer resp.Body.Close()

return "", errors.New("Need to solve captcha")
} else if resp.Status == 413 {
log.Debugln(resp.Body)
buf := new(bytes.Buffer)
buf.ReadFrom(resp.Body)
newStr := buf.String()
log.Debugln(newStr)
log.Errorln("[textsecure] requestCode", newStr)
defer resp.Body.Close()

return "", errors.New("Rate Limit Exeded")
Expand Down Expand Up @@ -255,7 +253,7 @@ func verifyCode(code string, pin *string, credentials *AuthCredentials) (error,
}
resp, err := transport.Transport.PutJSON(fmt.Sprintf(VERIFY_ACCOUNT_CODE_PATH, code), body)
if err != nil {
fmt.Println(err.Error())
log.Errorln("[textsecure] verifyCode", err)
return err, nil
}
if resp.IsError() {
Expand All @@ -264,11 +262,9 @@ func verifyCode(code string, pin *string, credentials *AuthCredentials) (error,
buf := new(bytes.Buffer)
buf.ReadFrom(resp.Body)
newStr := buf.String()
fmt.Printf(newStr)
log.Errorln("[textsecure] verifyCode", newStr)
v := RegistrationLockFailure{}
err := json.Unmarshal([]byte(newStr), &v)
log.Debugln("v", v)

if err != nil {
return err, nil
}
Expand Down Expand Up @@ -455,14 +451,14 @@ func GetProfileE164(tel string) (Contact, error) {

resp, err := transport.Transport.Get(fmt.Sprintf(PROFILE_PATH, tel))
if err != nil {
log.Debugln(err)
log.Errorln("[textsecure] GetProfileE164 ", err)
}

profile := &Profile{}
dec := json.NewDecoder(resp.Body)
err = dec.Decode(&profile)
if err != nil {
log.Debugln(err)
log.Errorln("[textsecure] GetProfileE164 ", err)
}
avatar, _ := GetAvatar(profile.Avatar)
buf := new(bytes.Buffer)
Expand All @@ -471,7 +467,7 @@ func GetProfileE164(tel string) (Contact, error) {
c := contacts[profile.UUID]
avatarDecrypted, err := decryptAvatar(buf.Bytes(), []byte(profile.IdentityKey))
if err != nil {
log.Debugln(err)
log.Errorln("[textsecure] GetProfileE164 ", err)
}
c.Username = profile.Username
c.UUID = profile.UUID
Expand Down Expand Up @@ -800,7 +796,7 @@ func makePreKeyBundle(UUID string, deviceID uint32) (*axolotl.PreKeyBundle, erro
preKeyId := uint32(0)
var preKey *axolotl.ECPublicKey
if d.PreKey == nil {
log.Debugln(fmt.Errorf("no prekey for contact %s, device %d", UUID, deviceID))
log.Debugln("[textsecure] makePreKeyBundle", fmt.Errorf("no prekey for contact %s, device %d", UUID, deviceID))
} else {
preKeyId = d.PreKey.ID
decPK, err := decodeKey(d.PreKey.PublicKey)
Expand Down
3 changes: 2 additions & 1 deletion textsecure.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ func registerDevice() error {
}
client.RegistrationDone()
if client.RegistrationDone != nil {
fmt.Println("RegistrationDone__")
log.Infoln("[textsecure] RegistrationDone")

client.RegistrationDone()
}
return nil
Expand Down

0 comments on commit e77a304

Please sign in to comment.