|
|
|
@ -77,16 +77,16 @@ func usePassword(user string, pass string, ip string) bool {
@@ -77,16 +77,16 @@ func usePassword(user string, pass string, ip string) bool {
|
|
|
|
|
log.LogInfo("%+v", toks) |
|
|
|
|
tok := toks[user] |
|
|
|
|
delete(toks, user) |
|
|
|
|
if time.Since(tok.timestamp) > (time.Minute * 5) { |
|
|
|
|
log.LogWarn(fmt.Sprintf("%s attempted to use expired token. %+v", user, time.Since(tok.timestamp))) |
|
|
|
|
if time.Since(tok.Timestamp) > (time.Minute * 5) { |
|
|
|
|
log.LogWarn(fmt.Sprintf("%s attempted to use expired token. %+v", user, time.Since(tok.Timestamp))) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
if tok.ip != ip { |
|
|
|
|
if tok.IP != ip { |
|
|
|
|
log.LogWarn(fmt.Sprintf("%s attempted to use an improper IP.", user)) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
if tok.password != pass { |
|
|
|
|
log.LogWarn(fmt.Sprintf("%s attempted to use an improper password. %s vs %s", user, tok.password, pass)) |
|
|
|
|
if tok.Password != pass { |
|
|
|
|
log.LogWarn(fmt.Sprintf("%s attempted to use an improper password. %s vs %s", user, tok.Password, pass)) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -113,11 +113,11 @@ func sendPassword(user string, ipaddr string) {
@@ -113,11 +113,11 @@ func sendPassword(user string, ipaddr string) {
|
|
|
|
|
if err != nil { |
|
|
|
|
log.LogErrorType(err) |
|
|
|
|
} |
|
|
|
|
toks[m.User.Username] = tokens{ |
|
|
|
|
username: user, |
|
|
|
|
ip: ipaddr, |
|
|
|
|
password: str, |
|
|
|
|
timestamp: time.Now(), |
|
|
|
|
toks[m.Nick] = Tokens{ |
|
|
|
|
Username: user, |
|
|
|
|
IP: ipaddr, |
|
|
|
|
Password: str, |
|
|
|
|
Timestamp: time.Now(), |
|
|
|
|
} |
|
|
|
|
pmChann, err := dg.UserChannelCreate(user) |
|
|
|
|
if err != nil { |
|
|
|
|