parser

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cli.Command{
	Category: "Misc",
	Name:     "parser",
	Usage:    "Parse some file",
	Commands: []*cli.Command{

		{
			Name:    "procnet",
			Aliases: []string{"net"},
			Usage:   "Parse /proc/net/tcp|udp",
			Flags: []cli.Flag{
				&cli.StringFlag{
					Name:    "filepath",
					Aliases: []string{"f"},
					Usage:   "Which file for parse",
				},
			},
			Action: func(c *cli.Context) (err error) {
				filepath := c.String("filepath")
				if filepath == "" {
					if c.NArg() > 0 {
						filepath = c.Args().First()
					} else if data, err := utils.GetFromPipe(); err == nil {
						filepath = string(data)
					} else {
						return fmt.Errorf("invalid filepath")
					}
				}
				r, err := ParseProcNet(filepath)
				if err != nil {
					return err
				}
				_, err = fmt.Println(r)
				return
			},
		},
		DsStoreCmd,
	},
}
View Source
var DsStoreCmd = &cli.Command{
	Name:  "dsstore",
	Usage: ".DS_Store Parser",
	Action: func(c *cli.Context) (err error) {
		target := c.Args().First()
		if err := utils.ValidArg(target, "url|file"); err != nil {
			return err
		}
		r, err := DSStore(target)
		if err != nil {
			return err
		}
		_, err = fmt.Println(r)
		return
	},
}
View Source
var TcpState = map[string]string{
	"01": "ESTABLISHED",
	"02": "SYN-SENT",
	"03": "SYN-RECEIVED",
	"04": "FIN-WAIT-1",
	"05": "FIN-WAIT-2",
	"06": "TIME-WAIT",
	"07": "CLOSED",
	"08": "CLOSE-WAIT",
	"09": "LAST-ACK",
	"0A": "LISTEN",
	"0B": "CLOSING",
	"0C": "NEW-SYN-RECEIVED",
}

Functions

func DSStore

func DSStore(s string) (string, error)

func ParseProcNet

func ParseProcNet(src string) (string, error)

ParseProcNet Parse /proc/net/tcp|udp

Types

This section is empty.

Jump to

Keyboard shortcuts

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