mirror of
https://github.com/netfun2000/rttys_zhaojh329.git
synced 2026-02-27 09:53:24 +08:00
+1
-1
@@ -105,7 +105,7 @@ func serveCmd(br *Broker, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
token = UniqueId()
|
||||
token = UniqueId("cmd")
|
||||
|
||||
commands[token] = &commandStatus{
|
||||
t: time.AfterFunc(30*time.Second, func() {
|
||||
|
||||
@@ -63,12 +63,14 @@ func allowOrigin(w http.ResponseWriter) {
|
||||
var hsMutex sync.Mutex
|
||||
var httpSessions = make(map[string]*HttpSession)
|
||||
|
||||
func UniqueId() string {
|
||||
func UniqueId(extra string) string {
|
||||
b := make([]byte, 48)
|
||||
io.ReadFull(rand.Reader, b)
|
||||
|
||||
h := md5.New()
|
||||
h.Write([]byte(base64.URLEncoding.EncodeToString(b)))
|
||||
h.Write([]byte(extra))
|
||||
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
@@ -194,7 +196,7 @@ func main() {
|
||||
password := r.PostFormValue("password")
|
||||
|
||||
if httpLogin(cfg, username, password) {
|
||||
sid := UniqueId()
|
||||
sid := UniqueId("http")
|
||||
cookie := http.Cookie{
|
||||
Name: "sid",
|
||||
Value: sid,
|
||||
|
||||
Reference in New Issue
Block a user