doc.txt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package subservice // import "imuslab.com/arozos/mod/subservice"
  2. TYPES
  3. type SubService struct {
  4. Port int //Port that this subservice use
  5. ServiceDir string //The directory where the service is located
  6. Path string //Path that this subservice is located
  7. RpEndpoint string //Reverse Proxy Endpoint
  8. ProxyHandler *reverseproxy.ReverseProxy //Reverse Proxy Object
  9. Info modules.ModuleInfo //Module information for this subservice
  10. Process *exec.Cmd //The CMD runtime object of the process
  11. }
  12. type SubServiceRouter struct {
  13. ReservePaths []string
  14. RunningSubService []SubService
  15. BasePort int
  16. // Has unexported fields.
  17. }
  18. func NewSubServiceRouter(ReservePaths []string, basePort int, userHandler *user.UserHandler, moduleHandler *modules.ModuleHandler, parentPort int) *SubServiceRouter
  19. func (sr *SubServiceRouter) CheckIfPortInUse(port int) bool
  20. func (sr *SubServiceRouter) CheckIfReverseProxyPath(r *http.Request) (bool, *reverseproxy.ReverseProxy, string, *SubService)
  21. Check if the target is reverse proxy. If yes, return the proxy handler and
  22. the rewritten url in string
  23. func (sr *SubServiceRouter) CheckUserPermissionOnSubservice(ss *SubService, u *user.User) bool
  24. Check if the user has permission to access such proxy module
  25. func (sr *SubServiceRouter) Close()
  26. func (sr *SubServiceRouter) GetNextUsablePort() int
  27. Scan and get the next avaible port for subservice from its basePort
  28. func (sr *SubServiceRouter) GetSubserviceRoot() []string
  29. Get a list of subservice roots in realpath
  30. func (sr *SubServiceRouter) HandleKillSubService(w http.ResponseWriter, r *http.Request)
  31. Kill the subservice that is currently running
  32. func (sr *SubServiceRouter) HandleListing(w http.ResponseWriter, r *http.Request)
  33. func (sr *SubServiceRouter) HandleRoutingRequest(w http.ResponseWriter, r *http.Request, proxy *reverseproxy.ReverseProxy, subserviceObject *SubService, rewriteURL string)
  34. func (sr *SubServiceRouter) HandleStartSubService(w http.ResponseWriter, r *http.Request)
  35. func (sr *SubServiceRouter) KillSubService(serviceDir string) error
  36. func (sr *SubServiceRouter) Launch(servicePath string, startupMode bool) error
  37. func (sr *SubServiceRouter) LoadSubservicesFromRootPath(rootpath string)
  38. Load and start all the subservices inside this rootpath
  39. func (sr *SubServiceRouter) RestartSubService(ss *SubService)
  40. Handle fail start over when the remote target is not responding
  41. func (sr *SubServiceRouter) StartSubService(serviceDir string) error