From 6796ffc6eed85683008ec4f7c11866d6baae9c88 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 18 Apr 2025 17:14:49 +0800 Subject: [PATCH] Update libv2ray_main.go --- libv2ray_main.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libv2ray_main.go b/libv2ray_main.go index 3a56f41..99de802 100644 --- a/libv2ray_main.go +++ b/libv2ray_main.go @@ -37,7 +37,7 @@ type CoreController struct { CallbackHandler CoreCallbackHandler statsManager corestats.Manager coreMutex sync.Mutex - CoreInstance *core.Instance + coreInstance *core.Instance IsRunning bool } @@ -45,7 +45,6 @@ type CoreController struct { type CoreCallbackHandler interface { Startup() int Shutdown() int - Protect(int) bool OnEmitStatus(int, string) int } @@ -142,7 +141,7 @@ func (x *CoreController) MeasureDelay(url string) (int64, error) { ctx, cancel := context.WithTimeout(context.Background(), 12*time.Second) defer cancel() - return measureInstDelay(ctx, x.CoreInstance, url) + return measureInstDelay(ctx, x.coreInstance, url) } // MeasureOutboundDelay measures the outbound delay for a given configuration and URL @@ -179,9 +178,9 @@ func CheckVersionX() string { // doShutdown shuts down the Xray instance and cleans up resources func (x *CoreController) doShutdown() { - if x.CoreInstance != nil { - x.CoreInstance.Close() - x.CoreInstance = nil + if x.coreInstance != nil { + x.coreInstance.Close() + x.coreInstance = nil } x.IsRunning = false x.statsManager = nil @@ -196,15 +195,15 @@ func (x *CoreController) doStartLoop(configContent string) error { } log.Println("Creating new core instance") - x.CoreInstance, err = core.New(config) + x.coreInstance, err = core.New(config) if err != nil { return fmt.Errorf("failed to create core instance: %w", err) } - x.statsManager = x.CoreInstance.GetFeature(corestats.ManagerType()).(corestats.Manager) + x.statsManager = x.coreInstance.GetFeature(corestats.ManagerType()).(corestats.Manager) log.Println("Starting core") x.IsRunning = true - if err := x.CoreInstance.Start(); err != nil { + if err := x.coreInstance.Start(); err != nil { x.IsRunning = false return fmt.Errorf("failed to start core: %w", err) }