parse

package
v0.0.0-...-a0c44de Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ParseCmd = &cobra.Command{
	Use:   "parse",
	Short: "Gives a detailed info about the config link",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) < 1 && readFromSTDIN != true && configLink == "" && configLinksFile == "" {
			cmd.Help()
			return
		}
		if readFromSTDIN {
			reader := bufio.NewReader(os.Stdin)
			fmt.Println("Reading config from STDIN:")
			text, _ := reader.ReadString('\n')
			configLink = text

		} else if configLinksFile != "" {
			links := utils.ParseFileByNewline(configLinksFile)

			d := color.New(color.FgCyan, color.Bold)
			for i, link := range links {
				d.Printf("Config Number: %d\n", i+1)
				protocol, err := xray.ParseXrayConfig(link)
				if err != nil {
					fmt.Fprintf(os.Stderr, "%v", err)
					os.Exit(1)
				}
				fmt.Println(protocol.DetailsStr() + "\n")
				time.Sleep(time.Duration(25) * time.Millisecond)
			}
			return

		}

		if readFromSTDIN || configLink != "" {
			fmt.Printf("\n")
			protocol, err := xray.ParseXrayConfig(configLink)
			if err != nil {
				fmt.Fprintf(os.Stderr, "%v", err)
				os.Exit(1)
			}
			fmt.Println(protocol.DetailsStr())
		}
	},
}

ParseCmd represents the parse command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL