Skip to content

Commit

Permalink
Fixed not waiting after the outbound has founded
Browse files Browse the repository at this point in the history
  • Loading branch information
lilendian0x00 committed Feb 20, 2024
1 parent c71fd0c commit 94e9d69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions cmd/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,24 @@ var ProxyCmd = &cobra.Command{
}
customlog.Printf(customlog.Success, "Started listening for new connections...")
fmt.Printf("\n")

time.Sleep(time.Duration(interval) * time.Second)
}
// The procedure of selecting a new outbound and starting it
connect()

// A ticker for the interval in which the outbound changes
ticker := time.NewTicker(time.Duration(interval) * time.Second)
for range ticker.C {
for {
// The procedure of selecting a new outbound and starting it
// Do it for the first time before first tick starts
connect()

customlog.Printf(customlog.Processing, "Switching outbound connection...\n")

// Check if any xrayInstance is running
if xrayInstance != nil {
err = xrayInstance.Close()
if err != nil {
//log.Fatalf(err.Error())
log.Fatalf(err.Error())
}
}

// The procedure of selecting a new outbound and starting it
// Do it for the first time before first tick starts
connect()
}
} else {
// Configuring outbound
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var rootCmd = &cobra.Command{
Use: "xray-knife",
Short: "Swiss Army Knife for xray-core",
Long: ``,
Version: "2.8.15",
Version: "2.8.16",
// Main Tools:
//1. parse: Parses xray config link.
//2. net: Multiple network tests for xray configs.
Expand Down

0 comments on commit 94e9d69

Please sign in to comment.