|
|
@ -2,11 +2,11 @@ package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"container/list"
|
|
|
|
"container/list"
|
|
|
|
|
|
|
|
"crypto/rand"
|
|
|
|
|
|
|
|
"encoding/base64"
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
. "github.com/elisescu/tty-share/common"
|
|
|
|
. "github.com/elisescu/tty-share/common"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -27,8 +27,14 @@ type ttyShareSession struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func generateNewSessionID() string {
|
|
|
|
func generateNewSessionID() string {
|
|
|
|
// TODO: replace this with a proper way of generating secret session IDs
|
|
|
|
binID := make([]byte, 32)
|
|
|
|
return fmt.Sprintf("%x", time.Now().UnixNano())
|
|
|
|
_, err := rand.Read(binID)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return base64.URLEncoding.EncodeToString([]byte(binID))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func newTTYShareSession(conn net.Conn, serverURL string) *ttyShareSession {
|
|
|
|
func newTTYShareSession(conn net.Conn, serverURL string) *ttyShareSession {
|
|
|
|