cmd

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

A program used to implement Ruijie web authentication

Index

Constants

View Source
const MaxCmdOutputSize = 64 * 1024

MaxCmdOutputSize is the maximum length of performed shell command output in bytes.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GetCookie

func GetCookie(url string) (*http.Cookie, error)

Get cookie of the auth page

func GetLoginUrl

func GetLoginUrl() (string, string, bool, error)

Get the login url from the redirect url

func IsOpenWrt added in v1.1.0

func IsOpenWrt() (ok bool)

IsOpenWrt returns true if host OS is OpenWrt.

func Login

func Login() (res string, err error)

Hust web auth once.

func RegisterMAC

func RegisterMAC(url string, userIndex string, cookie *http.Cookie) (string, error)

RegisterMAC register the mac address, only for the first time

func RootDirFS added in v1.1.0

func RootDirFS() (fsys fs.FS)

RootDirFS returns the fs.FS rooted at the operating system's root. On Windows it returns the fs.FS rooted at the volume of the system directory (usually, C:).

func RunCommand added in v1.1.0

func RunCommand(command string, arguments ...string) (code int, output []byte, err error)

RunCommand runs shell command.

Types

type FileWalker added in v1.1.0

type FileWalker func(r io.Reader) (patterns []string, cont bool, err error)

FileWalker is the signature of a function called for files in the file tree. As opposed to filepath.Walk it only walk the files (not directories) matching the provided pattern and those returned by function itself. All patterns should be valid for fs.Glob. If FileWalker returns false for cont then walking terminates. Prefer using bufio.Scanner to read the r since the input is not limited.

TODO(e.burkov, a.garipov): Move into another package like aghfs.

TODO(e.burkov): Think about passing filename or any additional data.

func (FileWalker) Walk added in v1.1.0

func (fw FileWalker) Walk(fsys fs.FS, initial ...string) (ok bool, err error)

Walk starts walking the files in fsys defined by patterns from initial. It only returns true if fw signed to stop walking.

Jump to

Keyboard shortcuts

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