flags.go 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "time"
  6. apt "imuslab.com/arozos/mod/apt"
  7. auth "imuslab.com/arozos/mod/auth"
  8. db "imuslab.com/arozos/mod/database"
  9. "imuslab.com/arozos/mod/disk/raid"
  10. "imuslab.com/arozos/mod/docker"
  11. "imuslab.com/arozos/mod/info/logger"
  12. "imuslab.com/arozos/mod/media/mediaserver"
  13. permission "imuslab.com/arozos/mod/permission"
  14. user "imuslab.com/arozos/mod/user"
  15. "imuslab.com/arozos/mod/www"
  16. )
  17. /*
  18. System Flags
  19. */
  20. // =========== SYSTEM PARAMTERS ==============
  21. var sysdb *db.Database //System database
  22. var authAgent *auth.AuthAgent //System authentication agent
  23. var permissionHandler *permission.PermissionHandler
  24. var userHandler *user.UserHandler //User Handler
  25. var packageManager *apt.AptPackageManager //Manager for package auto installation
  26. var raidManager *raid.Manager //Software RAID Manager, only activate on Linux hosts
  27. var dockerManager *docker.DockerManager //Docker management, only active when Docker is detected on host
  28. var userWwwHandler *www.Handler //User Webroot handler
  29. var mediaServer *mediaserver.Instance //Media handling server for streaming and downloading large files
  30. var subserviceBasePort = 12810 //Next subservice port
  31. // =========== SYSTEM BUILD INFORMATION ==============
  32. var build_version = "development" //System build flag, this can be either {development / production / stable}
  33. var internal_version = "3.0.1" //Internal build version, [fork_id].[major_release_no].[minor_release_no]
  34. var deviceUUID string //The device uuid of this host
  35. var deviceVendor = "IMUSLAB.INC" //Vendor of the system
  36. var deviceVendorURL = "http://imuslab.com" //Vendor contact information
  37. var deviceModel = "AR100" //Hardware Model of the system
  38. var deviceModelDesc = "General Purpose Cloud Platform" //Device Model Description
  39. var vendorWebExists = false //Flag to indicate if the vendor web directory exists, this is used to determine if the system should serve vendor customized web resources or not
  40. var vendorResRoot = "./vendor-res/" //Root folder for vendor overwrite resources
  41. // =========== RUNTTIME RELATED ================
  42. var max_upload_size int64 = 8192 << 20 //Maxmium upload size, default 8GB
  43. var sudo_mode bool = (os.Geteuid() == 0 || os.Geteuid() == -1) //Check if the program is launched as sudo mode or -1 on windows
  44. var startupTime int64 = time.Now().Unix() //The startup time of the ArozOS Core
  45. var systemWideLogger *logger.Logger //The sync map to store all system wide loggers
  46. // =========== SYSTEM FLAGS ==============
  47. // Flags related to System startup
  48. var listen_host = flag.String("host", "", "Listening host for HTTP server")
  49. var listen_port = flag.Int("port", 8080, "Listening port for HTTP server")
  50. var tls_listen_port = flag.Int("tls_port", 8443, "Listening port for HTTPS server")
  51. var show_version = flag.Bool("version", false, "Show system build version")
  52. var host_name = flag.String("hostname", "My ArOZ", "Default name for this host")
  53. var system_uuid = flag.String("uuid", "", "System UUID for clustering and distributed computing. Only need to config once for first time startup. Leave empty for auto generation.")
  54. var disable_subservices = flag.Bool("disable_subservice", false, "Disable subservices completely")
  55. // Flags related to Networking
  56. var allow_upnp = flag.Bool("allow_upnp", false, "Enable uPNP service, recommended for host under NAT router")
  57. var allow_ssdp = flag.Bool("allow_ssdp", true, "Enable SSDP service, disable this if you do not want your device to be scanned by Windows's Network Neighborhood Page")
  58. var allow_mdns = flag.Bool("allow_mdns", true, "Enable MDNS service. Allow device to be scanned by nearby ArOZ Hosts")
  59. var force_mac = flag.String("force_mac", "", "Force MAC address to be used for discovery services. If not set, it will use the first NIC")
  60. var disable_ip_resolve_services = flag.Bool("disable_ip_resolver", false, "Disable IP resolving if the system is running under reverse proxy environment")
  61. var enable_gzip = flag.Bool("gzip", true, "Enable gzip compress on file server")
  62. // Flags related to Arozcast (remote projection / screen share)
  63. var arozcast_enable_turn = flag.Bool("arozcast_turn", true, "Enable the built-in Arozcast TURN relay so WebRTC screen share works over the Internet / behind NAT")
  64. var arozcast_turn_port = flag.Int("arozcast_turn_port", 3478, "Listening port (UDP and TCP) for the built-in Arozcast TURN relay")
  65. var arozcast_turn_publicip = flag.String("arozcast_turn_publicip", "", "Public IP or hostname advertised by the Arozcast TURN relay. Leave empty to auto-detect the outbound interface address (set this when the host is behind NAT)")
  66. var arozcast_turn_tls = flag.Bool("arozcast_turn_tls", true, "Also serve TURN-over-TLS (TURNS) so screen share traverses restrictive firewalls that only allow outbound TLS. Uses the system TLS certificate (-cert/-key); a no-op when no certificate can be loaded")
  67. var arozcast_turn_tls_port = flag.Int("arozcast_turn_tls_port", 5349, "Listening TCP port for the Arozcast TURN-over-TLS (TURNS) relay. Set to 443 to share the standard HTTPS port for maximum firewall traversal")
  68. // Flags related to Security
  69. var use_tls = flag.Bool("tls", false, "Enable TLS on HTTP serving (HTTPS Mode)")
  70. var disable_http = flag.Bool("disable_http", false, "Disable HTTP server, require tls=true")
  71. var tls_cert = flag.String("cert", "localhost.crt", "TLS certificate file (.crt)")
  72. var tls_key = flag.String("key", "localhost.key", "TLS key file (.key)")
  73. var session_key = flag.String("session_key", "", "Session key, must be 16, 24 or 32 bytes long (AES-128, AES-192 or AES-256). Leave empty for auto generated.")
  74. // Flags related to hardware or interfaces
  75. var allow_hardware_management = flag.Bool("enable_hwman", true, "Enable hardware management functions in system")
  76. var allow_power_management = flag.Bool("enable_pwman", true, "Enable power management of the host system")
  77. var wpa_supplicant_path = flag.String("wpa_supplicant_config", "/etc/wpa_supplicant/wpa_supplicant.conf", "Path for the wpa_supplicant config") // arozos-lint-ignore: Linux-only wpa_supplicant default; overridable by flag
  78. var wan_interface_name = flag.String("wlan_interface_name", "wlan0", "The default wireless interface for connecting to an AP")
  79. var skip_mdadm_reload = flag.Bool("skip_mdadm_reload", false, "Skip mdadm reload config during startup, might result in werid RAID device ID in some Linux distro")
  80. var allow_docker_management = flag.Bool("enable_docker", true, "Enable Docker container/compose management if Docker is detected on host")
  81. // Flags related to files and uploads
  82. var max_upload = flag.Int("max_upload_size", 8192, "Maxmium upload size in MB. Must not exceed the available ram on your system")
  83. var upload_buf = flag.Int("upload_buf", 25, "Upload buffer memory in MB. Any file larger than this size will be buffered to disk (slower).")
  84. var storage_config_file = flag.String("storage_config", "./system/storage.json", "File location of the storage config file")
  85. var tmp_directory = flag.String("tmp", "./", "Temporary storage, can be access via tmp:/. A tmp/ folder will be created in this path. Recommend fast storage devices like SSD")
  86. var root_directory = flag.String("root", "./files/", "User root directories")
  87. var file_opr_buff = flag.Int("iobuf", 1024, "Amount of buffer memory for IO operations")
  88. var enable_dir_listing = flag.Bool("dir_list", true, "Enable directory listing")
  89. var enable_asyncFileUpload = flag.Bool("upload_async", false, "Enable file upload buffering to run in async mode (Faster upload, require RAM >= 8GB)")
  90. // Flags related to file system abstractions
  91. var bufferPoolSize = flag.Int("buffpool_size", 1024, "Maxmium buffer pool size (in MB) for buffer required file system abstractions")
  92. var bufferFileMaxSize = flag.Int("bufffile_size", 25, "Maxmium buffer file size (in MB) for buffer required file system abstractions")
  93. var enable_buffering = flag.Bool("enable_buffpool", true, "Enable buffer pool for buffer required file system abstractions")
  94. // Flags related to compatibility or testing
  95. var enable_beta_scanning_support = flag.Bool("beta_scan", false, "Allow compatibility to ArOZ Online Beta Clusters")
  96. var enable_console = flag.Bool("console", false, "Enable the debugging console.")
  97. var enable_logging = flag.Bool("logging", true, "Enable logging to file for debug purpose")
  98. var log_format = flag.String("log_format", "text", "Console log output format: text or json")
  99. // Flags related to running on Cloud Environment or public domain
  100. var allow_public_registry = flag.Bool("public_reg", false, "Enable public register interface for account creation")
  101. var allow_autologin = flag.Bool("allow_autologin", true, "Allow RESTFUL login redirection that allow machines like billboards to login to the system on boot")
  102. var allow_package_autoInstall = flag.Bool("allow_pkg_install", true, "Allow the system to install package using Advanced Package Tool (aka apt or apt-get)")
  103. var allow_homepage = flag.Bool("homepage", true, "Enable user homepage. Accessible via /www/{username}/")
  104. // Scheduling and System Service Related
  105. var nightlyTaskRunTime = flag.Int("ntt", 3, "Nightly tasks execution time. Default 3 = 3 am in the morning")
  106. var maxTempFileKeepTime = flag.Int("tmp_time", 86400, "Time before tmp file will be deleted in seconds. Default 86400 seconds = 24 hours")
  107. // Flags related to ArozOS Cluster services
  108. var allow_iot = flag.Bool("allow_iot", true, "Enable IoT related APIs and scanner. Require MDNS enabled")