mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
code fmt change.
This commit is contained in:
parent
00fc3afcd7
commit
d7671942a6
@ -14,9 +14,7 @@ import (
|
||||
|
||||
type key int
|
||||
|
||||
const (
|
||||
keyMemberCtx key = iota
|
||||
)
|
||||
const keyMemberCtx key = iota
|
||||
|
||||
type MembersHandler struct {
|
||||
members types.MemberManager
|
||||
|
@ -10,13 +10,11 @@ import (
|
||||
"demodesk/neko/internal/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
// Maximum upload of 32 MB files.
|
||||
MAX_UPLOAD_SIZE = 32 << 20
|
||||
)
|
||||
// maximum upload size of 32 MB
|
||||
const maxUploadSize = 32 << 20
|
||||
|
||||
func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseMultipartForm(MAX_UPLOAD_SIZE)
|
||||
err := r.ParseMultipartForm(maxUploadSize)
|
||||
if err != nil {
|
||||
utils.HttpBadRequest(w, "failed to parse multipart form")
|
||||
return
|
||||
@ -87,7 +85,7 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (h *RoomHandler) uploadDialogPost(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseMultipartForm(MAX_UPLOAD_SIZE)
|
||||
err := r.ParseMultipartForm(maxUploadSize)
|
||||
if err != nil {
|
||||
utils.HttpBadRequest(w, "failed to parse multipart form")
|
||||
return
|
||||
|
@ -28,6 +28,7 @@ type ScreencastManagerCtx struct {
|
||||
image types.Sample
|
||||
}
|
||||
|
||||
// timeout between intervals, when screencast pipeline is checked
|
||||
const screencastTimeout = 5 * time.Second
|
||||
|
||||
func screencastNew(enabled bool, pipelineStr string) *ScreencastManagerCtx {
|
||||
|
@ -13,6 +13,15 @@ import (
|
||||
"demodesk/neko/internal/utils"
|
||||
)
|
||||
|
||||
// default port range - min
|
||||
const defEprMin = 59000
|
||||
|
||||
// default port range - max
|
||||
const defEprMax = 59100
|
||||
|
||||
// default stun server
|
||||
const defStunSrv = "stun:stun.l.google.com:19302"
|
||||
|
||||
type WebRTC struct {
|
||||
ICELite bool
|
||||
ICETrickle bool
|
||||
@ -24,12 +33,6 @@ type WebRTC struct {
|
||||
IpRetrievalUrl string
|
||||
}
|
||||
|
||||
const (
|
||||
defEprMin = 59000
|
||||
defEprMax = 59100
|
||||
defStun = "stun:stun.l.google.com:19302"
|
||||
)
|
||||
|
||||
func (WebRTC) Init(cmd *cobra.Command) error {
|
||||
cmd.PersistentFlags().Bool("webrtc.icelite", false, "configures whether or not the ICE agent should be a lite agent")
|
||||
if err := viper.BindPFlag("webrtc.icelite", cmd.PersistentFlags().Lookup("webrtc.icelite")); err != nil {
|
||||
@ -76,7 +79,7 @@ func (s *WebRTC) Set() {
|
||||
|
||||
if len(s.ICEServers) == 0 {
|
||||
s.ICEServers = append(s.ICEServers, types.ICEServer{
|
||||
URLs: []string{defStun},
|
||||
URLs: []string{defStunSrv},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,11 @@ import (
|
||||
"demodesk/neko/internal/desktop/drop"
|
||||
)
|
||||
|
||||
const (
|
||||
DROP_MOVE_REPEAT = 4
|
||||
DROP_DELAY = 100 * time.Millisecond
|
||||
)
|
||||
// repeat move event multiple times
|
||||
const dropMoveRepeat = 4
|
||||
|
||||
// wait after each repeated move event
|
||||
const dropMoveDelay = 100 * time.Millisecond
|
||||
|
||||
func (manager *DesktopManagerCtx) DropFiles(x int, y int, files []string) bool {
|
||||
mu.Lock()
|
||||
@ -31,9 +32,9 @@ func (manager *DesktopManagerCtx) DropFiles(x int, y int, files []string) bool {
|
||||
})
|
||||
|
||||
drop.Emmiter.Once("begin", func(payload ...interface{}) {
|
||||
for i := 0; i < DROP_MOVE_REPEAT; i++ {
|
||||
for i := 0; i < dropMoveRepeat; i++ {
|
||||
manager.Move(x, y)
|
||||
time.Sleep(DROP_DELAY)
|
||||
time.Sleep(dropMoveDelay)
|
||||
}
|
||||
|
||||
//nolint
|
||||
|
@ -6,11 +6,14 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
FILE_CHOOSER_DIALOG_NAME = "Open File"
|
||||
FILE_CHOOSER_DIALOG_SHORT_SLEEP = "0.2"
|
||||
FILE_CHOOSER_DIALOG_LONG_SLEEP = "0.4"
|
||||
)
|
||||
// name of the window that is being controlled
|
||||
const fileChooserDialogName = "Open File"
|
||||
|
||||
// short sleep value between fake user interactions
|
||||
const fileChooserDialogShortSleep = "0.2"
|
||||
|
||||
// long sleep value between fake user interactions
|
||||
const fileChooserDialogLongSleep = "0.4"
|
||||
|
||||
func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
||||
mu.Lock()
|
||||
@ -19,19 +22,19 @@ func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
||||
// TODO: Use native API.
|
||||
err1 := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"search", "--name", fileChooserDialogName, "windowfocus",
|
||||
"sleep", fileChooserDialogShortSleep,
|
||||
"key", "--clearmodifiers", "ctrl+l",
|
||||
"type", "--args", "1", uri+"//",
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"sleep", fileChooserDialogShortSleep,
|
||||
"key", "Delete", // remove autocomplete results
|
||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||
"sleep", fileChooserDialogShortSleep,
|
||||
"key", "Return",
|
||||
"sleep", FILE_CHOOSER_DIALOG_LONG_SLEEP,
|
||||
"sleep", fileChooserDialogLongSleep,
|
||||
"key", "Down",
|
||||
"key", "--clearmodifiers", "ctrl+a",
|
||||
"key", "Return",
|
||||
"sleep", FILE_CHOOSER_DIALOG_LONG_SLEEP,
|
||||
"sleep", fileChooserDialogLongSleep,
|
||||
).Run()
|
||||
|
||||
if err1 != nil {
|
||||
@ -41,7 +44,7 @@ func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
||||
// TODO: Use native API.
|
||||
err2 := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME,
|
||||
"search", "--name", fileChooserDialogName,
|
||||
).Run()
|
||||
|
||||
// if last command didn't return error, consider dialog as still open
|
||||
@ -61,7 +64,7 @@ func (manager *DesktopManagerCtx) CloseFileChooserDialog() {
|
||||
// TODO: Use native API.
|
||||
err := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
||||
"search", "--name", fileChooserDialogName, "windowfocus",
|
||||
).Run()
|
||||
|
||||
if err != nil {
|
||||
@ -92,7 +95,7 @@ func (manager *DesktopManagerCtx) IsFileChooserDialogOpened() bool {
|
||||
// TODO: Use native API.
|
||||
err := exec.Command(
|
||||
"xdotool",
|
||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME,
|
||||
"search", "--name", fileChooserDialogName,
|
||||
).Run()
|
||||
|
||||
return err == nil
|
||||
|
@ -95,19 +95,19 @@ func (manager *DesktopManagerCtx) GetKeyboardMap() (*types.KeyboardMap, error) {
|
||||
|
||||
func (manager *DesktopManagerCtx) SetKeyboardModifiers(mod types.KeyboardModifiers) {
|
||||
if mod.NumLock != nil {
|
||||
xorg.SetKeyboardModifier(xorg.KBD_NUM_LOCK, *mod.NumLock)
|
||||
xorg.SetKeyboardModifier(xorg.KbdModNumLock, *mod.NumLock)
|
||||
}
|
||||
|
||||
if mod.CapsLock != nil {
|
||||
xorg.SetKeyboardModifier(xorg.KBD_CAPS_LOCK, *mod.CapsLock)
|
||||
xorg.SetKeyboardModifier(xorg.KbdModCapsLock, *mod.CapsLock)
|
||||
}
|
||||
}
|
||||
|
||||
func (manager *DesktopManagerCtx) GetKeyboardModifiers() types.KeyboardModifiers {
|
||||
modifiers := xorg.GetKeyboardModifiers()
|
||||
|
||||
NumLock := (modifiers & xorg.KBD_NUM_LOCK) != 0
|
||||
CapsLock := (modifiers & xorg.KBD_CAPS_LOCK) != 0
|
||||
NumLock := (modifiers & xorg.KbdModNumLock) != 0
|
||||
CapsLock := (modifiers & xorg.KbdModCapsLock) != 0
|
||||
|
||||
return types.KeyboardModifiers{
|
||||
NumLock: &NumLock,
|
||||
|
@ -19,11 +19,11 @@ import (
|
||||
"demodesk/neko/internal/types"
|
||||
)
|
||||
|
||||
type KbdModifiers uint8
|
||||
type KbdMod uint8
|
||||
|
||||
const (
|
||||
KBD_CAPS_LOCK KbdModifiers = 2
|
||||
KBD_NUM_LOCK KbdModifiers = 16
|
||||
KbdModCapsLock KbdMod = 2
|
||||
KbdModNumLock KbdMod = 16
|
||||
)
|
||||
|
||||
var ScreenConfigurations = make(map[int]types.ScreenConfiguration)
|
||||
@ -213,7 +213,7 @@ func GetScreenSize() *types.ScreenSize {
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetKeyboardModifier(mod KbdModifiers, active bool) {
|
||||
func SetKeyboardModifier(mod KbdMod, active bool) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
@ -225,11 +225,11 @@ func SetKeyboardModifier(mod KbdModifiers, active bool) {
|
||||
C.XSetKeyboardModifier(C.int(mod), num)
|
||||
}
|
||||
|
||||
func GetKeyboardModifiers() KbdModifiers {
|
||||
func GetKeyboardModifiers() KbdMod {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
return KbdModifiers(C.XGetKeyboardModifiers())
|
||||
return KbdMod(C.XGetKeyboardModifiers())
|
||||
}
|
||||
|
||||
func GetCursorImage() *types.CursorImage {
|
||||
|
@ -10,9 +10,7 @@ import (
|
||||
|
||||
type key int
|
||||
|
||||
const (
|
||||
keySessionCtx key = iota
|
||||
)
|
||||
const keySessionCtx key = iota
|
||||
|
||||
func SetSession(r *http.Request, session types.Session) *http.Request {
|
||||
ctx := context.WithValue(r.Context(), keySessionCtx, session)
|
||||
|
@ -15,6 +15,9 @@ import (
|
||||
"demodesk/neko/internal/websocket/handler"
|
||||
)
|
||||
|
||||
// send pings to peer with this period - must be less than pongWait
|
||||
const pingPeriod = 10 * time.Second
|
||||
|
||||
func New(
|
||||
sessions types.SessionManager,
|
||||
desktop types.DesktopManager,
|
||||
@ -32,9 +35,6 @@ func New(
|
||||
}
|
||||
}
|
||||
|
||||
// Send pings to peer with this period. Must be less than pongWait.
|
||||
const pingPeriod = 10 * time.Second
|
||||
|
||||
type WebSocketManagerCtx struct {
|
||||
logger zerolog.Logger
|
||||
sessions types.SessionManager
|
||||
|
Loading…
Reference in New Issue
Block a user