Remove unused code
This commit is contained in:
parent
c146c8dae2
commit
2f301ffc80
|
|
@ -3,14 +3,11 @@ package xmpp
|
||||||
import (
|
import (
|
||||||
"git.kingpenguin.tk/chteufleur/go-xmpp.git/src/xmpp"
|
"git.kingpenguin.tk/chteufleur/go-xmpp.git/src/xmpp"
|
||||||
|
|
||||||
"crypto/rand"
|
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
dictionary = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
||||||
|
|
||||||
REPLY_UNREACHABLE = "reply_unreachable"
|
REPLY_UNREACHABLE = "reply_unreachable"
|
||||||
REPLY_DENY = "reply_deny"
|
REPLY_DENY = "reply_deny"
|
||||||
REPLY_OK = "reply_ok"
|
REPLY_OK = "reply_ok"
|
||||||
|
|
@ -33,15 +30,9 @@ type Confirmation struct {
|
||||||
|
|
||||||
func (confirmation *Confirmation) SendConfirmation() {
|
func (confirmation *Confirmation) SendConfirmation() {
|
||||||
log.Printf("%sQuery JID %s", LogInfo, confirmation.JID)
|
log.Printf("%sQuery JID %s", LogInfo, confirmation.JID)
|
||||||
isAutoGeneratedTranctionID := false
|
|
||||||
if confirmation.Transaction == "" {
|
|
||||||
// Random transaction ID generation
|
|
||||||
confirmation.Transaction = TransactionID()
|
|
||||||
isAutoGeneratedTranctionID = true
|
|
||||||
}
|
|
||||||
clientJID, _ := xmpp.ParseJID(confirmation.JID)
|
clientJID, _ := xmpp.ParseJID(confirmation.JID)
|
||||||
if clientJID.Resource == "" {
|
if clientJID.Resource == "" {
|
||||||
confirmation.askViaMessage(isAutoGeneratedTranctionID)
|
confirmation.askViaMessage()
|
||||||
} else {
|
} else {
|
||||||
confirmation.askViaIQ()
|
confirmation.askViaIQ()
|
||||||
}
|
}
|
||||||
|
|
@ -60,16 +51,13 @@ func (confirmation *Confirmation) askViaIQ() {
|
||||||
confirmation.IdMap = stanzaIDstr
|
confirmation.IdMap = stanzaIDstr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (confirmation *Confirmation) askViaMessage(isAutoGeneratedTranctionID bool) {
|
func (confirmation *Confirmation) askViaMessage() {
|
||||||
m := xmpp.Message{From: jid.Full(), To: confirmation.JID, Type: xmpp.MessageTypeNormal}
|
m := xmpp.Message{From: jid.Full(), To: confirmation.JID, Type: xmpp.MessageTypeNormal}
|
||||||
|
|
||||||
m.Thread = xmpp.SessionID()
|
m.Thread = xmpp.SessionID()
|
||||||
m.Body = confirmation.Domain + " (with method " + confirmation.Method + ") need to validate your identity, do you agree ?"
|
m.Body = confirmation.Domain + " (with method " + confirmation.Method + ") need to validate your identity, do you agree ?"
|
||||||
m.Body += "\nValidation code : " + confirmation.Transaction
|
m.Body += "\nValidation code : " + confirmation.Transaction
|
||||||
if !isAutoGeneratedTranctionID {
|
m.Body += "\nPlease check that this code is the same as on " + confirmation.Domain
|
||||||
// Send only if the transaction ID is not autogenerated
|
|
||||||
m.Body += "\nPlease check that this code is the same as on " + confirmation.Domain
|
|
||||||
}
|
|
||||||
m.Body += "\n\nIf your client doesn't support that functionnality, please send back the validation code to confirm the request."
|
m.Body += "\n\nIf your client doesn't support that functionnality, please send back the validation code to confirm the request."
|
||||||
m.Confir = &xmpp.Confirm{Id: confirmation.Transaction, Method: confirmation.Method, URL: confirmation.Domain}
|
m.Confir = &xmpp.Confirm{Id: confirmation.Transaction, Method: confirmation.Method, URL: confirmation.Domain}
|
||||||
|
|
||||||
|
|
@ -80,14 +68,3 @@ func (confirmation *Confirmation) askViaMessage(isAutoGeneratedTranctionID bool)
|
||||||
confirmation.TypeSend = TYPE_SEND_MESSAGE
|
confirmation.TypeSend = TYPE_SEND_MESSAGE
|
||||||
confirmation.IdMap = confirmation.Transaction
|
confirmation.IdMap = confirmation.Transaction
|
||||||
}
|
}
|
||||||
|
|
||||||
func TransactionID() string {
|
|
||||||
var bytes = make([]byte, 8)
|
|
||||||
if _, err := rand.Read(bytes); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
for k, v := range bytes {
|
|
||||||
bytes[k] = dictionary[v%byte(len(dictionary))]
|
|
||||||
}
|
|
||||||
return string(bytes)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue