mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-17 04:34:40 +03:00
docs: add comments for all functions
This commit is contained in:
14
main.go
14
main.go
@@ -1,3 +1,5 @@
|
||||
// Package main is the entry point for the 3x-ui web panel application.
|
||||
// It initializes the database, web server, and handles command-line operations for managing the panel.
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -22,6 +24,7 @@ import (
|
||||
"github.com/op/go-logging"
|
||||
)
|
||||
|
||||
// runWebServer initializes and starts the web server for the 3x-ui panel.
|
||||
func runWebServer() {
|
||||
log.Printf("Starting %v %v", config.GetName(), config.GetVersion())
|
||||
|
||||
@@ -111,6 +114,7 @@ func runWebServer() {
|
||||
}
|
||||
}
|
||||
|
||||
// resetSetting resets all panel settings to their default values.
|
||||
func resetSetting() {
|
||||
err := database.InitDB(config.GetDBPath())
|
||||
if err != nil {
|
||||
@@ -127,6 +131,7 @@ func resetSetting() {
|
||||
}
|
||||
}
|
||||
|
||||
// showSetting displays the current panel settings if show is true.
|
||||
func showSetting(show bool) {
|
||||
if show {
|
||||
settingService := service.SettingService{}
|
||||
@@ -176,6 +181,7 @@ func showSetting(show bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// updateTgbotEnableSts enables or disables the Telegram bot notifications based on the status parameter.
|
||||
func updateTgbotEnableSts(status bool) {
|
||||
settingService := service.SettingService{}
|
||||
currentTgSts, err := settingService.GetTgbotEnabled()
|
||||
@@ -195,6 +201,7 @@ func updateTgbotEnableSts(status bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// updateTgbotSetting updates Telegram bot settings including token, chat ID, and runtime schedule.
|
||||
func updateTgbotSetting(tgBotToken string, tgBotChatid string, tgBotRuntime string) {
|
||||
err := database.InitDB(config.GetDBPath())
|
||||
if err != nil {
|
||||
@@ -232,6 +239,7 @@ func updateTgbotSetting(tgBotToken string, tgBotChatid string, tgBotRuntime stri
|
||||
}
|
||||
}
|
||||
|
||||
// updateSetting updates various panel settings including port, credentials, base path, listen IP, and two-factor authentication.
|
||||
func updateSetting(port int, username string, password string, webBasePath string, listenIP string, resetTwoFactor bool) {
|
||||
err := database.InitDB(config.GetDBPath())
|
||||
if err != nil {
|
||||
@@ -290,6 +298,7 @@ func updateSetting(port int, username string, password string, webBasePath strin
|
||||
}
|
||||
}
|
||||
|
||||
// updateCert updates the SSL certificate files for the panel.
|
||||
func updateCert(publicKey string, privateKey string) {
|
||||
err := database.InitDB(config.GetDBPath())
|
||||
if err != nil {
|
||||
@@ -317,6 +326,7 @@ func updateCert(publicKey string, privateKey string) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetCertificate displays the current SSL certificate settings if getCert is true.
|
||||
func GetCertificate(getCert bool) {
|
||||
if getCert {
|
||||
settingService := service.SettingService{}
|
||||
@@ -334,6 +344,7 @@ func GetCertificate(getCert bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetListenIP displays the current panel listen IP address if getListen is true.
|
||||
func GetListenIP(getListen bool) {
|
||||
if getListen {
|
||||
|
||||
@@ -348,6 +359,7 @@ func GetListenIP(getListen bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// migrateDb performs database migration operations for the 3x-ui panel.
|
||||
func migrateDb() {
|
||||
inboundService := service.InboundService{}
|
||||
|
||||
@@ -360,6 +372,8 @@ func migrateDb() {
|
||||
fmt.Println("Migration done!")
|
||||
}
|
||||
|
||||
// main is the entry point of the 3x-ui application.
|
||||
// It parses command-line arguments to run the web server, migrate database, or update settings.
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
runWebServer()
|
||||
|
||||
Reference in New Issue
Block a user