remote.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package main
  2. import (
  3. "net/http"
  4. "runtime"
  5. module "imuslab.com/arozos/mod/modules"
  6. prout "imuslab.com/arozos/mod/prouter"
  7. "imuslab.com/arozos/mod/wsshell"
  8. )
  9. /*
  10. Remote.go
  11. author: tobychui
  12. This module handles the remote maintaince of the arozos system
  13. Any modules that handles remote access / deployment should be placed here
  14. */
  15. func WebsocketShellInit() {
  16. //This module only avaible for administrator that has permission to this module and is admin
  17. if runtime.GOOS == "windows" {
  18. ttyRouter := prout.NewModuleRouter(prout.RouterOption{
  19. ModuleName: "WsTTY",
  20. AdminOnly: true,
  21. UserHandler: userHandler,
  22. RequireLAN: true,
  23. DeniedHandler: func(w http.ResponseWriter, r *http.Request) {
  24. w.WriteHeader(http.StatusForbidden)
  25. w.Write([]byte("403 - Permission Denied"))
  26. },
  27. })
  28. //Create new terminal object
  29. terminal := wsshell.NewWebSocketShellTerminal()
  30. ttyRouter.HandleFunc("/system/tty/", terminal.HandleOpen)
  31. //Register the module
  32. moduleHandler.RegisterModule(module.ModuleInfo{
  33. Name: "WsTTY",
  34. Group: "System Tools",
  35. IconPath: "SystemAO/wstty/img/small_icon.png",
  36. Version: "1.0",
  37. StartDir: "SystemAO/wstty/console.html",
  38. SupportFW: true,
  39. InitFWSize: []int{900, 480},
  40. LaunchFWDir: "SystemAO/wstty/console.html",
  41. SupportEmb: false,
  42. })
  43. } else {
  44. //Linux. Use the WsTTY subservice instead.
  45. }
  46. }