├── .gitignore ├── LICENSE ├── README.md ├── TODO ├── client ├── cli.go ├── cmd │ └── warp │ │ └── main.go ├── command │ ├── authorize.go │ ├── connect.go │ ├── help.go │ ├── open.go │ ├── revoke.go │ └── state.go ├── config.go ├── local.go ├── session.go ├── shell.go ├── srv.go └── warp_state.go ├── daemon ├── cmd │ └── warpd │ │ └── main.go ├── session.go ├── srv.go └── warp.go ├── lib ├── errors │ ├── function.go │ ├── user_error.go │ └── wrap.go ├── logging │ └── logging.go ├── out │ └── out.go ├── plex │ └── plex.go └── token │ └── token.go ├── protocol.go └── vendor ├── github.com ├── fatih │ └── color │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── color.go │ │ └── doc.go ├── hashicorp │ └── yamux │ │ ├── LICENSE │ │ ├── README.md │ │ ├── addr.go │ │ ├── const.go │ │ ├── mux.go │ │ ├── session.go │ │ ├── spec.md │ │ ├── stream.go │ │ └── util.go ├── kr │ └── pty │ │ ├── License │ │ ├── README.md │ │ ├── doc.go │ │ ├── ioctl.go │ │ ├── ioctl_bsd.go │ │ ├── mktypes.bash │ │ ├── pty_darwin.go │ │ ├── pty_dragonfly.go │ │ ├── pty_freebsd.go │ │ ├── pty_linux.go │ │ ├── pty_unsupported.go │ │ ├── run.go │ │ ├── types.go │ │ ├── types_dragonfly.go │ │ ├── types_freebsd.go │ │ ├── util.go │ │ ├── ztypes_386.go │ │ ├── ztypes_amd64.go │ │ ├── ztypes_arm.go │ │ ├── ztypes_arm64.go │ │ ├── ztypes_dragonfly_amd64.go │ │ ├── ztypes_freebsd_386.go │ │ ├── ztypes_freebsd_amd64.go │ │ ├── ztypes_freebsd_arm.go │ │ ├── ztypes_mipsx.go │ │ ├── ztypes_ppc64.go │ │ ├── ztypes_ppc64le.go │ │ └── ztypes_s390x.go ├── mattn │ ├── go-colorable │ │ ├── LICENSE │ │ ├── colorable_others.go │ │ ├── colorable_windows.go │ │ └── noncolorable.go │ └── go-isatty │ │ ├── LICENSE │ │ ├── doc.go │ │ ├── isatty_appengine.go │ │ ├── isatty_bsd.go │ │ ├── isatty_linux.go │ │ ├── isatty_others.go │ │ ├── isatty_solaris.go │ │ └── isatty_windows.go └── mitchellh │ └── go-homedir │ ├── LICENSE │ ├── README.md │ └── homedir.go ├── golang.org └── x │ ├── crypto │ ├── LICENSE │ ├── PATENTS │ └── ssh │ │ └── terminal │ │ ├── terminal.go │ │ ├── util.go │ │ ├── util_bsd.go │ │ ├── util_linux.go │ │ ├── util_plan9.go │ │ ├── util_solaris.go │ │ └── util_windows.go │ └── sys │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_mipsx.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_s390x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_solaris_amd64.s │ ├── bluetooth_linux.go │ ├── constants.go │ ├── dirent.go │ ├── endian_big.go │ ├── endian_little.go │ ├── env_unix.go │ ├── env_unset.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── gccgo_linux_sparc64.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mkpost.go │ ├── mksyscall.pl │ ├── mksyscall_solaris.pl │ ├── mksysctl_openbsd.pl │ ├── mksysnum_darwin.pl │ ├── mksysnum_dragonfly.pl │ ├── mksysnum_freebsd.pl │ ├── mksysnum_linux.pl │ ├── mksysnum_netbsd.pl │ ├── mksysnum_openbsd.pl │ ├── openbsd_pledge.go │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_amd64_gc.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.go │ ├── syscall_linux_sparc64.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_no_getwd.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── syscall_unix_gc.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_linux.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_mipsle.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_solaris_amd64.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_mipsle.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_mipsle.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_mipsle.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ └── ztypes_solaris_amd64.go └── vendor.json /.gitignore: -------------------------------------------------------------------------------- 1 | .*~ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Stanislas Polu (polu.stanislas@gmail.com) 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | # v0.0.4 "vt100" 2 | 3 | [ ] port vt.js to golang 4 | [ ] refactor warp/warpd to use websockets 5 | 6 | # v0.0.2 "bare" 7 | 8 | [x] TLS 9 | [x] Send version as part of Hello 10 | [x] in-warp commands 11 | [x] set env __WARP= 12 | [x] set env __WARP_UNIX_SOCKET= 13 | [x] local unix socket that is a commandC channel > updateC 14 | [x] warp state 15 | [x] warp authorize stan 16 | [x] warp revoke stan 17 | [x] warp revoke 18 | [x] warpd 100% CPU :/ 19 | [x] errorC and meaningful errors to client 20 | [x] factor session creation / remove hostC 21 | [x] rename Client/Session 22 | [x] rename warp/warp Session/Warp 23 | [x] prevent write at host level (if noone authorized at all) 24 | [x] protect warpd sessions with mutex (mostly teardown) 25 | 26 | # v0.0.3 "safe" 27 | 28 | [x] graceful host reconnection (closes warp for clients but auto reconnects) 29 | [x] client session and error handling refactor 30 | [x] generate and persists user/secret in ~/.warp 31 | [x] verify secret match on connect 32 | [x] fix host client session writing (expected: HostCanReceiveWrite) 33 | [x] test verification of secret match on connect 34 | [x] fix verification of secret match on connect (stalls future connections) 35 | [x] protocol mode -> int64 36 | [x] credentials -> configuration 37 | [x] WARPD_NO_TLS env 38 | [x] confirmation on warp authorize (also show warpd ID) 39 | [x] brew recipe 40 | [-] PROMPT support for bash, zsh, csh 41 | [-] docker image for quick warp trial / warpd deployment 42 | 43 | # v0.0.x "voice" 44 | 45 | [ ] voice dependent of warp being open 46 | [ ] warp voice :id 47 | [ ] minimal command system 48 | [ ] /unmute /mute 49 | 50 | -------------------------------------------------------------------------------- /client/cli.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "context" 5 | "regexp" 6 | "strings" 7 | 8 | "github.com/spolu/warp/lib/errors" 9 | ) 10 | 11 | // CmdName represents a command name. 12 | type CmdName string 13 | 14 | // Command is the interface for a cli command. 15 | type Command interface { 16 | // Name returns the command name. 17 | Name() CmdName 18 | 19 | // Help prints out the help message for the command. 20 | Help(context.Context) 21 | 22 | // Parse the arguments and flags passed to the command. 23 | Parse(context.Context, []string, map[string]string) error 24 | 25 | // Execute the command or return a human-friendly error. 26 | Execute(context.Context) error 27 | } 28 | 29 | // Registrar is used to register command generators within the module. 30 | var Registrar = map[CmdName](func() Command){} 31 | 32 | // Cli represents a cli instance. 33 | type Cli struct { 34 | Ctx context.Context 35 | Flags map[string]string 36 | Args []string 37 | } 38 | 39 | // flagFilterRegexp filters out flags from arguments. 40 | var flagFilterRegexp = regexp.MustCompile("^-+") 41 | 42 | // New initializes a new Cli by parsing the passed arguments. 43 | func New( 44 | argv []string, 45 | ) (*Cli, error) { 46 | ctx := context.Background() 47 | 48 | args := []string{} 49 | flags := map[string]string{} 50 | 51 | for _, a := range argv { 52 | if flagFilterRegexp.MatchString(a) { 53 | a = strings.Trim(a, "-") 54 | s := strings.Split(a, "=") 55 | if len(s) == 2 { 56 | flags[s[0]] = s[1] 57 | } else if len(s) == 1 { 58 | flags[s[0]] = "true" 59 | } 60 | } else { 61 | args = append(args, strings.TrimSpace(a)) 62 | } 63 | } 64 | 65 | return &Cli{ 66 | Ctx: ctx, 67 | Args: args, 68 | Flags: flags, 69 | }, nil 70 | } 71 | 72 | // Run the cli. 73 | func (c *Cli) Run() error { 74 | if len(c.Args) == 0 { 75 | c.Args = append(c.Args, "help") 76 | } 77 | 78 | var command Command 79 | cmd, args := c.Args[0], c.Args[1:] 80 | if r, ok := Registrar[CmdName(cmd)]; !ok { 81 | command = Registrar[CmdName("help")]() 82 | } else { 83 | command = r() 84 | } 85 | 86 | err := command.Parse(c.Ctx, args, c.Flags) 87 | if err != nil { 88 | command.Help(c.Ctx) 89 | return errors.Trace(err) 90 | } 91 | 92 | err = command.Execute(c.Ctx) 93 | if err != nil { 94 | return errors.Trace(err) 95 | } 96 | 97 | return nil 98 | } 99 | -------------------------------------------------------------------------------- /client/cmd/warp/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spolu/warp/client" 7 | _ "github.com/spolu/warp/client/command" 8 | "github.com/spolu/warp/lib/out" 9 | ) 10 | 11 | func main() { 12 | cli, err := cli.New(os.Args[1:]) 13 | if err != nil { 14 | out.Errof("[Error] %s\n", err.Error()) 15 | } 16 | 17 | err = cli.Run() 18 | if err != nil { 19 | out.Errof("[Error] %s\n", err.Error()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /client/command/authorize.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "bufio" 5 | "context" 6 | "os" 7 | "strings" 8 | 9 | "github.com/spolu/warp" 10 | "github.com/spolu/warp/client" 11 | "github.com/spolu/warp/lib/errors" 12 | "github.com/spolu/warp/lib/out" 13 | ) 14 | 15 | const ( 16 | // CmdNmAuthorize is the command name. 17 | CmdNmAuthorize cli.CmdName = "authorize" 18 | ) 19 | 20 | func init() { 21 | cli.Registrar[CmdNmAuthorize] = NewAuthorize 22 | } 23 | 24 | // Authorize authorizes write access to a warp client. 25 | type Authorize struct { 26 | usernameOrToken string 27 | } 28 | 29 | // NewAuthorize constructs and initializes the command. 30 | func NewAuthorize() cli.Command { 31 | return &Authorize{} 32 | } 33 | 34 | // Name returns the command name. 35 | func (c *Authorize) Name() cli.CmdName { 36 | return CmdNmAuthorize 37 | } 38 | 39 | // Help prints out the help message for the command. 40 | func (c *Authorize) Help( 41 | ctx context.Context, 42 | ) { 43 | out.Normf("\nUsage: ") 44 | out.Boldf("warp authorize \n") 45 | out.Normf("\n") 46 | out.Normf(" Grants write access to a client of the current warp.\n") 47 | out.Normf("\n") 48 | out.Errof(" Be extra careful!") 49 | out.Normf(" Please make sure that the user you are granting write\n") 50 | out.Normf(" access to is who you think they are. An attacker could take over your machine\n") 51 | out.Normf(" in a split second with write access to one of your warps.\n") 52 | out.Normf("\n") 53 | out.Normf(" If the username of a user is ambiguous (multiple users connnected with the\n") 54 | out.Normf(" same username), you must use the associated user token, as returned by the\n") 55 | out.Boldf(" state") 56 | out.Normf(" command.\n") 57 | out.Normf("\n") 58 | out.Normf("Arguments:\n") 59 | out.Boldf(" username_or_token\n") 60 | out.Normf(" The username or token of a connected user.\n") 61 | out.Valuf(" guest_JpJP50EIas9cOfwo goofy\n") 62 | out.Normf("\n") 63 | out.Normf("Examples:\n") 64 | out.Valuf(" warp authorize goofy\n") 65 | out.Valuf(" warp authorize guest_JpJP50EIas9cOfwo\n") 66 | out.Normf("\n") 67 | } 68 | 69 | // Parse parses the arguments passed to the command. 70 | func (c *Authorize) Parse( 71 | ctx context.Context, 72 | args []string, 73 | flags map[string]string, 74 | ) error { 75 | if len(args) == 0 { 76 | return errors.Trace( 77 | errors.Newf("Username or token required."), 78 | ) 79 | } else { 80 | c.usernameOrToken = args[0] 81 | } 82 | 83 | return nil 84 | } 85 | 86 | // Execute the command or return a human-friendly error. 87 | func (c *Authorize) Execute( 88 | ctx context.Context, 89 | ) error { 90 | err := cli.CheckEnvWarp(ctx) 91 | if err != nil { 92 | return errors.Trace(err) 93 | } 94 | 95 | result, err := cli.RunLocalCommand(ctx, warp.Command{ 96 | Type: warp.CmdTpState, 97 | Args: []string{}, 98 | }) 99 | if err != nil { 100 | return errors.Trace(err) 101 | } 102 | 103 | if result.Disconnected { 104 | return errors.Trace( 105 | errors.Newf( 106 | "The warp is currently disconnected. No client has access to " + 107 | "it and all previously authorized users will be revoked " + 108 | "upon reconnection.", 109 | ), 110 | ) 111 | } 112 | 113 | username := "" 114 | user := "" 115 | args := []string{} 116 | matches := 0 117 | for _, u := range result.SessionState.Users { 118 | if !u.Hosting { 119 | if u.Username == c.usernameOrToken || 120 | u.Token == c.usernameOrToken { 121 | matches += 1 122 | args = append(args, u.Token) 123 | username = u.Username 124 | user = u.Token 125 | } 126 | } 127 | } 128 | 129 | if matches == 0 { 130 | return errors.Trace( 131 | errors.Newf( 132 | "Username or token not found: %s. Use `warp state` to "+ 133 | "retrieve a list of currently connected warp clients.", 134 | c.usernameOrToken, 135 | ), 136 | ) 137 | } else if matches > 1 { 138 | return errors.Trace( 139 | errors.Newf( 140 | "Username ambiguous, please provide a user token instead. " + 141 | "Warp clients user tokens can be retrieved with " + 142 | "`warp state`.", 143 | ), 144 | ) 145 | } 146 | 147 | out.Normf("You are about to authorize the following user to write to ") 148 | out.Valuf("%s\n", os.Getenv(warp.EnvWarp)) 149 | out.Normf(" ID: ") 150 | out.Boldf("%s", user) 151 | out.Normf(" Username: ") 152 | out.Valuf("%s\n", username) 153 | out.Normf("Are you sure this is who you think this is? [Y/n]: ") 154 | 155 | reader := bufio.NewReader(os.Stdin) 156 | confirmation, _ := reader.ReadString('\n') 157 | confirmation = strings.TrimSpace(confirmation) 158 | 159 | if confirmation != "" && confirmation != "Y" && confirmation != "y" { 160 | return errors.Trace( 161 | errors.Newf("Authorizxation aborted by user."), 162 | ) 163 | } 164 | result, err = cli.RunLocalCommand(ctx, warp.Command{ 165 | Type: warp.CmdTpAuthorize, 166 | Args: args, 167 | }) 168 | if err != nil { 169 | return errors.Trace(err) 170 | } 171 | 172 | out.Normf("\n") 173 | out.Normf("Done! You can revoke authorizations at any time with ") 174 | out.Boldf("warp revoke\n") 175 | out.Normf("\n") 176 | 177 | PrintSessionState(ctx, result.Disconnected, result.SessionState) 178 | 179 | return nil 180 | } 181 | -------------------------------------------------------------------------------- /client/command/help.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/spolu/warp" 7 | "github.com/spolu/warp/client" 8 | "github.com/spolu/warp/lib/out" 9 | ) 10 | 11 | const ( 12 | // CmdNmHelp is the command name. 13 | CmdNmHelp cli.CmdName = "help" 14 | ) 15 | 16 | func init() { 17 | cli.Registrar[CmdNmHelp] = NewHelp 18 | } 19 | 20 | // Help a user 21 | type Help struct { 22 | Command cli.Command 23 | } 24 | 25 | // NewHelp constructs and initializes the command. 26 | func NewHelp() cli.Command { 27 | return &Help{} 28 | } 29 | 30 | // Name returns the command name. 31 | func (c *Help) Name() cli.CmdName { 32 | return CmdNmHelp 33 | } 34 | 35 | // Help prints out the help message for the command. 36 | func (c *Help) Help( 37 | ctx context.Context, 38 | ) { 39 | out.Normf("\n") 40 | out.Normf(" _ ______ __________ \n") 41 | out.Normf(" | | /| / / __ `/ ___/ __ \\ \n") 42 | out.Normf(" | |/ |/ / /_/ / / / /_/ / \n") 43 | out.Normf(" |__/|__/\\__,_/_/ / .___/ \n") 44 | out.Normf(" /_/ ") 45 | out.Boldf("v%s\n", warp.Version) 46 | out.Normf("\n") 47 | out.Normf(" Secure terminal sharing with one simple command.\n") 48 | out.Normf("\n") 49 | out.Normf("Usage:\n") 50 | out.Boldf(" warp [ ...]\n") 51 | out.Normf("\n") 52 | out.Normf("Commands:\n") 53 | out.Boldf(" help \n") 54 | out.Normf(" Show help for a specific command.\n") 55 | out.Valuf(" warp help open\n") 56 | out.Normf("\n") 57 | out.Boldf(" open []\n") 58 | out.Normf(" Creates a new warp.\n") 59 | out.Valuf(" warp open\n") 60 | out.Normf("\n") 61 | out.Boldf(" connect \n") 62 | out.Normf(" Connects to an existing warp.\n") 63 | out.Valuf(" warp connect goofy-dev\n") 64 | out.Normf("\n") 65 | out.Boldf(" state\n") 66 | out.Normf(" Displays the state of the current warp (in-warp only).\n") 67 | out.Valuf(" warp state\n") 68 | out.Normf("\n") 69 | out.Boldf(" authorize \n") 70 | out.Normf(" Grants write access to a client (in-warp only).\n") 71 | out.Valuf(" warp authorize goofy\n") 72 | out.Normf("\n") 73 | out.Boldf(" revoke []\n") 74 | out.Normf(" Revokes write access to one or all clients (in-warp only).\n") 75 | out.Valuf(" warp revoke\n") 76 | out.Normf("\n") 77 | } 78 | 79 | // Parse parses the arguments passed to the command. 80 | func (c *Help) Parse( 81 | ctx context.Context, 82 | args []string, 83 | flags map[string]string, 84 | ) error { 85 | if len(args) == 0 { 86 | c.Command = NewHelp() 87 | } else { 88 | if r, ok := cli.Registrar[cli.CmdName(args[0])]; !ok { 89 | c.Command = NewHelp() 90 | } else { 91 | c.Command = r() 92 | } 93 | } 94 | return nil 95 | } 96 | 97 | // Execute the command or return a human-friendly error. 98 | func (c *Help) Execute( 99 | ctx context.Context, 100 | ) error { 101 | c.Command.Help(ctx) 102 | return nil 103 | } 104 | -------------------------------------------------------------------------------- /client/command/revoke.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/spolu/warp" 7 | "github.com/spolu/warp/client" 8 | "github.com/spolu/warp/lib/errors" 9 | "github.com/spolu/warp/lib/out" 10 | ) 11 | 12 | const ( 13 | // CmdNmRevoke is the command name. 14 | CmdNmRevoke cli.CmdName = "revoke" 15 | ) 16 | 17 | func init() { 18 | cli.Registrar[CmdNmRevoke] = NewRevoke 19 | } 20 | 21 | // Revoke authorizes write access to a warp client. 22 | type Revoke struct { 23 | usernameOrToken string 24 | } 25 | 26 | // NewRevoke constructs and initializes the command. 27 | func NewRevoke() cli.Command { 28 | return &Revoke{} 29 | } 30 | 31 | // Name returns the command name. 32 | func (c *Revoke) Name() cli.CmdName { 33 | return CmdNmRevoke 34 | } 35 | 36 | // Help prints out the help message for the command. 37 | func (c *Revoke) Help( 38 | ctx context.Context, 39 | ) { 40 | out.Normf("\nUsage: ") 41 | out.Boldf("warp revoke []\n") 42 | out.Normf("\n") 43 | out.Normf(" Revokes write access to a client of the current warp. If no argument is\n") 44 | out.Normf(" provided, it revokes write access to all connected clients.\n") 45 | out.Normf("\n") 46 | out.Normf("Arguments:\n") 47 | out.Boldf(" username_or_token\n") 48 | out.Normf(" The username or token of a connected user.\n") 49 | out.Valuf(" guest_JpJP50EIas9cOfwo goofy\n") 50 | out.Normf("\n") 51 | out.Normf("Examples:\n") 52 | out.Valuf(" warp revoke\n") 53 | out.Valuf(" warp revoke goofy\n") 54 | out.Valuf(" warp revoke guest_JpJP50EIas9cOfwo\n") 55 | out.Normf("\n") 56 | } 57 | 58 | // Parse parses the arguments passed to the command. 59 | func (c *Revoke) Parse( 60 | ctx context.Context, 61 | args []string, 62 | flags map[string]string, 63 | ) error { 64 | if len(args) > 0 { 65 | c.usernameOrToken = args[0] 66 | } 67 | 68 | return nil 69 | } 70 | 71 | // Execute the command or return a human-friendly error. 72 | func (c *Revoke) Execute( 73 | ctx context.Context, 74 | ) error { 75 | err := cli.CheckEnvWarp(ctx) 76 | if err != nil { 77 | return errors.Trace(err) 78 | } 79 | 80 | result, err := cli.RunLocalCommand(ctx, warp.Command{ 81 | Type: warp.CmdTpState, 82 | Args: []string{}, 83 | }) 84 | if err != nil { 85 | return errors.Trace(err) 86 | } 87 | 88 | if result.Disconnected { 89 | return errors.Trace( 90 | errors.Newf( 91 | "The warp is currently disconnected. No client has access to " + 92 | "it and all previously authorized users will be revoked " + 93 | "upon reconnection.", 94 | ), 95 | ) 96 | } 97 | 98 | args := []string{} 99 | match := false 100 | for _, user := range result.SessionState.Users { 101 | if !user.Hosting { 102 | if user.Username == c.usernameOrToken || 103 | user.Token == c.usernameOrToken { 104 | match = true 105 | args = append(args, user.Token) 106 | } 107 | if c.usernameOrToken == "" && user.Mode&warp.ModeShellWrite != 0 { 108 | match = true 109 | args = append(args, user.Token) 110 | } 111 | } 112 | } 113 | 114 | if c.usernameOrToken != "" && !match { 115 | return errors.Trace( 116 | errors.Newf( 117 | "Username or token not found: %s. Use `warp state` to "+ 118 | "retrieve a list of currently connected warp clients.", 119 | c.usernameOrToken, 120 | ), 121 | ) 122 | } 123 | 124 | result, err = cli.RunLocalCommand(ctx, warp.Command{ 125 | Type: warp.CmdTpRevoke, 126 | Args: args, 127 | }) 128 | if err != nil { 129 | return errors.Trace(err) 130 | } 131 | 132 | PrintSessionState(ctx, result.Disconnected, result.SessionState) 133 | 134 | return nil 135 | } 136 | -------------------------------------------------------------------------------- /client/command/state.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/spolu/warp" 7 | "github.com/spolu/warp/client" 8 | "github.com/spolu/warp/lib/errors" 9 | "github.com/spolu/warp/lib/out" 10 | ) 11 | 12 | const ( 13 | // CmdNmState is the command name. 14 | CmdNmState cli.CmdName = "state" 15 | ) 16 | 17 | func init() { 18 | cli.Registrar[CmdNmState] = NewState 19 | } 20 | 21 | // State retrieve the state of the current warp (in-warp only). 22 | type State struct { 23 | } 24 | 25 | // NewState constructs and initializes the command. 26 | func NewState() cli.Command { 27 | return &State{} 28 | } 29 | 30 | // Name returns the command name. 31 | func (c *State) Name() cli.CmdName { 32 | return CmdNmState 33 | } 34 | 35 | // Help prints out the help message for the command. 36 | func (c *State) Help( 37 | ctx context.Context, 38 | ) { 39 | out.Normf("\nUsage: ") 40 | out.Boldf("warp state\n") 41 | out.Normf("\n") 42 | out.Normf(" Displays the state of the current warp, including the list of connected users\n") 43 | out.Normf(" and their authorization state. This command is only available from inside a\n") 44 | out.Normf(" warp.\n") 45 | out.Normf("\n") 46 | out.Normf("Examples:\n") 47 | out.Valuf(" warp state\n") 48 | out.Normf("\n") 49 | } 50 | 51 | // Parse parses the arguments passed to the command. 52 | func (c *State) Parse( 53 | ctx context.Context, 54 | args []string, 55 | flags map[string]string, 56 | ) error { 57 | return nil 58 | } 59 | 60 | // Execute the command or return a human-friendly error. 61 | func (c *State) Execute( 62 | ctx context.Context, 63 | ) error { 64 | err := cli.CheckEnvWarp(ctx) 65 | if err != nil { 66 | return errors.Trace(err) 67 | } 68 | 69 | result, err := cli.RunLocalCommand(ctx, warp.Command{ 70 | Type: warp.CmdTpState, 71 | Args: []string{}, 72 | }) 73 | if err != nil { 74 | return errors.Trace(err) 75 | } 76 | 77 | PrintSessionState(ctx, result.Disconnected, result.SessionState) 78 | 79 | return nil 80 | } 81 | 82 | func PrintSessionState( 83 | ctx context.Context, 84 | disconnected bool, 85 | state warp.State, 86 | ) { 87 | out.Boldf("Warp:\n") 88 | out.Normf(" ID: ") 89 | out.Valuf("%s\n", state.Warp) 90 | if !disconnected { 91 | out.Normf(" Size: ") 92 | out.Valuf( 93 | "%dx%d\n", state.WindowSize.Cols, state.WindowSize.Rows, 94 | ) 95 | } 96 | out.Normf(" Status: ") 97 | if disconnected { 98 | out.Errof("disconnected\n") 99 | } else { 100 | out.Statf("connected\n") 101 | } 102 | out.Normf("\n") 103 | 104 | out.Boldf("Host:\n") 105 | for _, u := range state.Users { 106 | if u.Hosting { 107 | out.Normf(" ID: ") 108 | out.Valuf("%s", u.Token) 109 | out.Normf(" Username: ") 110 | out.Valuf("%s", u.Username) 111 | out.Normf("\n") 112 | } 113 | } 114 | out.Normf("\n") 115 | 116 | if !disconnected { 117 | out.Boldf("Clients:\n") 118 | found := false 119 | for _, u := range state.Users { 120 | if !u.Hosting { 121 | found = true 122 | out.Normf(" ID: ") 123 | out.Valuf("%s", u.Token) 124 | out.Normf(" Username: ") 125 | out.Valuf("%s", u.Username) 126 | out.Normf(" Authorized: ") 127 | if u.Mode&warp.ModeShellWrite != 0 { 128 | out.Errof("true") 129 | } else { 130 | out.Valuf("false") 131 | } 132 | out.Normf("\n") 133 | } 134 | } 135 | if !found { 136 | out.Normf(" No client.\n") 137 | } 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /client/config.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "io/ioutil" 7 | "os" 8 | "path/filepath" 9 | 10 | homedir "github.com/mitchellh/go-homedir" 11 | "github.com/spolu/warp/lib/errors" 12 | "github.com/spolu/warp/lib/token" 13 | ) 14 | 15 | // Credentials repesents the credentials of the currently logged in user. 16 | type Credentials struct { 17 | User string `json:"user"` 18 | Secret string `json:"secret"` 19 | } 20 | 21 | // Config represents the local configuration for warp. 22 | type Config struct { 23 | Credentials Credentials `json:"credentials"` 24 | } 25 | 26 | // ConfigPath returns the crendentials path for the current environment. 27 | func ConfigPath( 28 | ctx context.Context, 29 | ) (*string, error) { 30 | path, err := homedir.Expand( 31 | "~/.warp/config.json", 32 | ) 33 | if err != nil { 34 | return nil, errors.Trace(err) 35 | } 36 | 37 | err = os.MkdirAll(filepath.Dir(path), 0777) 38 | if err != nil { 39 | return nil, errors.Trace(err) 40 | } 41 | 42 | return &path, nil 43 | } 44 | 45 | // RetrieveConfig retrieves the current user config by reading ConfigPath. 46 | func RetrieveConfig( 47 | ctx context.Context, 48 | ) (*Config, error) { 49 | path, err := ConfigPath(ctx) 50 | if err != nil { 51 | return nil, errors.Trace(err) 52 | } 53 | 54 | if _, err := os.Stat(*path); os.IsNotExist(err) { 55 | return nil, nil 56 | } 57 | 58 | raw, err := ioutil.ReadFile(*path) 59 | if err != nil { 60 | return nil, errors.Trace(err) 61 | } 62 | 63 | var c Config 64 | err = json.Unmarshal(raw, &c) 65 | if err != nil { 66 | return nil, errors.Trace(err) 67 | } 68 | 69 | return &c, nil 70 | } 71 | 72 | // GenerateConfig generates a new config and store it. As part of it, it 73 | // generates a new set of credentials. 74 | func GenerateConfig( 75 | ctx context.Context, 76 | ) (*Config, error) { 77 | config := &Config{ 78 | Credentials: Credentials{ 79 | User: token.New("guest"), 80 | Secret: token.RandStr(), 81 | }, 82 | } 83 | 84 | path, err := ConfigPath(ctx) 85 | if err != nil { 86 | return nil, errors.Trace(err) 87 | } 88 | 89 | formatted, err := json.MarshalIndent(config, "", " ") 90 | if err != nil { 91 | return nil, errors.Trace(err) 92 | } 93 | 94 | err = ioutil.WriteFile(*path, formatted, 0644) 95 | if err != nil { 96 | return nil, errors.Trace(err) 97 | } 98 | 99 | return config, nil 100 | } 101 | 102 | // RetrieveOrGenerateConfig retrieves the current config or generates it. 103 | func RetrieveOrGenerateConfig( 104 | ctx context.Context, 105 | ) (*Config, error) { 106 | 107 | config, err := RetrieveConfig(ctx) 108 | if err != nil { 109 | return nil, errors.Trace(err) 110 | } 111 | 112 | if config == nil { 113 | config, err = GenerateConfig(ctx) 114 | if err != nil { 115 | return nil, errors.Trace(err) 116 | } 117 | } 118 | 119 | return config, nil 120 | } 121 | -------------------------------------------------------------------------------- /client/local.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "context" 5 | "encoding/gob" 6 | "fmt" 7 | "net" 8 | "os" 9 | "path" 10 | 11 | "github.com/spolu/warp" 12 | "github.com/spolu/warp/lib/errors" 13 | "github.com/spolu/warp/lib/out" 14 | ) 15 | 16 | // RunLocalCommand runs a local in-warp command and returns the result. If an 17 | // error is returned as part of the result, it formats a human readable error 18 | // that can be safely returned top the user. 19 | func RunLocalCommand( 20 | ctx context.Context, 21 | cmd warp.Command, 22 | ) (*warp.CommandResult, error) { 23 | p := path.Join( 24 | os.TempDir(), 25 | fmt.Sprintf("_warp_%s.sock", os.Getenv(warp.EnvWarp)), 26 | ) 27 | 28 | conn, err := net.Dial("unix", p) 29 | if err != nil { 30 | return nil, errors.Trace( 31 | errors.Newf("Failed to connect to warpd: %v", err), 32 | ) 33 | } 34 | defer conn.Close() 35 | 36 | commandR := gob.NewDecoder(conn) 37 | commandW := gob.NewEncoder(conn) 38 | 39 | if err := commandW.Encode(cmd); err != nil { 40 | return nil, errors.Trace( 41 | errors.Newf("Failed to send command: %v", err), 42 | ) 43 | } 44 | 45 | // Waiting for command result. 46 | var result warp.CommandResult 47 | if err := commandR.Decode(&result); err != nil { 48 | return nil, errors.Trace(err) 49 | } 50 | 51 | if result.Error.Code != "" { 52 | return nil, errors.Newf( 53 | "Received %s: %s", 54 | result.Error.Code, 55 | result.Error.Message, 56 | ) 57 | } 58 | 59 | return &result, nil 60 | } 61 | 62 | // CheckWarpEnv checks that the warp.EnvWarp env variable is set. If not it 63 | // returns an error after displaying an helpful message. 64 | func CheckEnvWarp( 65 | ctx context.Context, 66 | ) error { 67 | if os.Getenv(warp.EnvWarp) != "" { 68 | return nil 69 | } 70 | out.Normf("\n") 71 | out.Normf("`warp` uses the environment variable `%s` to detect that it is running from\n", warp.EnvWarp) 72 | out.Normf("inside a warp (for in-warp commands). `%s` not being currently set, it\n", warp.EnvWarp) 73 | out.Normf("indicates that you are not executing this from inside a warp.\n") 74 | out.Normf("\n") 75 | out.Normf("Expert only: if you connected to a pre-existing tmux or screen session from\n") 76 | out.Normf("your current warp, `%s` will not be propagated automatically. You can fix\n", warp.EnvWarp) 77 | out.Normf("this by setting `%s` to the ID of your current warp in your environment\n", warp.EnvWarp) 78 | out.Normf("(running `export __WARP=`).\n") 79 | out.Normf("\n") 80 | 81 | return errors.Trace( 82 | errors.Newf("This command is only available from inside a warp."), 83 | ) 84 | } 85 | -------------------------------------------------------------------------------- /client/shell.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "context" 5 | "os" 6 | 7 | "github.com/spolu/warp/lib/errors" 8 | ) 9 | 10 | type Shell struct { 11 | Command string 12 | } 13 | 14 | // retrieveShell retrieves the current shell for the user using the following 15 | // fallbacks: 16 | // - read env variable SHELL 17 | // - TODO: read /etc/password 18 | // - default to `/bin/bash` 19 | func retrieveShell( 20 | ctx context.Context, 21 | ) (string, error) { 22 | if os.Getenv("SHELL") != "" { 23 | return os.Getenv("SHELL"), nil 24 | } 25 | return "/bin/bash", nil 26 | } 27 | 28 | func DetectShell( 29 | ctx context.Context, 30 | ) (*Shell, error) { 31 | command, err := retrieveShell(ctx) 32 | if err != nil { 33 | return nil, errors.Trace(err) 34 | } 35 | 36 | shell := Shell{ 37 | Command: command, 38 | } 39 | 40 | return &shell, nil 41 | } 42 | -------------------------------------------------------------------------------- /client/warp_state.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "github.com/spolu/warp" 5 | "github.com/spolu/warp/lib/errors" 6 | ) 7 | 8 | // WarpState repreents the state of a warp client side. The warp state method 9 | // are not thread-safe and access to it should be protected by the associated 10 | // session lock. 11 | type WarpState struct { 12 | token string 13 | 14 | windowSize warp.Size 15 | users map[string]UserState 16 | } 17 | 18 | // UserState represents the state of a user as seen client-side. 19 | type UserState struct { 20 | token string 21 | username string 22 | mode warp.Mode 23 | hosting bool 24 | } 25 | 26 | // User returns a warp.User from the current UserState. 27 | func (u *UserState) ProtocolUser() warp.User { 28 | return warp.User{ 29 | Token: u.token, 30 | Username: u.username, 31 | Mode: u.mode, 32 | Hosting: u.hosting, 33 | } 34 | } 35 | 36 | // Returns a new warp state initialized by a hello message. 37 | func NewWarpState( 38 | hello warp.SessionHello, 39 | ) *WarpState { 40 | w := &WarpState{ 41 | token: hello.Warp, 42 | users: map[string]UserState{ 43 | hello.From.User: UserState{ 44 | token: hello.From.User, 45 | username: hello.Username, 46 | mode: warp.DefaultUserMode, 47 | hosting: false, 48 | }, 49 | }, 50 | } 51 | if hello.Type == warp.SsTpHost { 52 | userState := w.users[hello.From.User] 53 | userState.hosting = true 54 | userState.mode = warp.DefaultHostMode 55 | w.users[hello.From.User] = userState 56 | } 57 | return w 58 | } 59 | 60 | // Update the warp state given a warp.State received over the wire. 61 | // 62 | // If preserveModes is true the modes are preserved (used from the host session 63 | // as the server is not trusted with modes). If the state includes an unknown 64 | // user, the default secure modes are used (~read-only). 65 | func (w *WarpState) Update( 66 | state warp.State, 67 | hosting bool, 68 | ) error { 69 | if state.Warp != w.token { 70 | return errors.Trace( 71 | errors.Newf("Warp token mismatch: %s", state.Warp), 72 | ) 73 | } 74 | 75 | w.windowSize = state.WindowSize 76 | 77 | for token, user := range state.Users { 78 | if token != user.Token { 79 | return errors.Trace( 80 | errors.Newf( 81 | "User token mismatch: %s <> %s", 82 | token, user.Token, 83 | ), 84 | ) 85 | } 86 | if _, ok := w.users[token]; !ok { 87 | // User connected. 88 | 89 | if hosting && user.Hosting { 90 | return errors.Trace( 91 | errors.Newf("Unexptected hosting user update: %s", token), 92 | ) 93 | } 94 | if hosting && user.Mode != warp.DefaultUserMode { 95 | return errors.Trace( 96 | errors.Newf( 97 | "Unexptected user update mode: %s %d", 98 | token, user.Mode, 99 | ), 100 | ) 101 | } 102 | 103 | // We have a new user that connected let's add it. 104 | w.users[token] = UserState{ 105 | token: token, 106 | username: user.Username, 107 | mode: warp.DefaultUserMode, 108 | hosting: user.Hosting, 109 | } 110 | } else { 111 | // Update the user state. 112 | userState := w.users[token] 113 | userState.username = user.Username 114 | if !hosting { 115 | userState.mode = user.Mode 116 | } 117 | w.users[token] = userState 118 | } 119 | } 120 | 121 | for token, _ := range w.users { 122 | if _, ok := state.Users[token]; !ok { 123 | // User disconnected. 124 | delete(w.users, token) 125 | } 126 | } 127 | 128 | return nil 129 | } 130 | 131 | // GetMode returns the mode of a given user. 132 | func (w *WarpState) GetMode( 133 | user string, 134 | ) (*warp.Mode, error) { 135 | userState, ok := w.users[user] 136 | if !ok { 137 | return nil, errors.Trace( 138 | errors.Newf("Unknown user: %s", user), 139 | ) 140 | } 141 | 142 | return &userState.mode, nil 143 | } 144 | 145 | // SetMode updates the mode of a given user. 146 | func (w *WarpState) SetMode( 147 | user string, 148 | mode warp.Mode, 149 | ) error { 150 | userState, ok := w.users[user] 151 | if !ok { 152 | return errors.Trace( 153 | errors.Newf("Unknown user: %s", user), 154 | ) 155 | } 156 | 157 | userState.mode = mode 158 | w.users[user] = userState 159 | 160 | return nil 161 | } 162 | 163 | // HostCanReceiveWrite computes whether the host can receive write from the 164 | // shell clients. This is used as defense in depth to prevent any write if 165 | // that's not the case. 166 | func (w *WarpState) HostCanReceiveWrite() bool { 167 | can := false 168 | for _, user := range w.users { 169 | if !user.hosting && user.mode&warp.ModeShellWrite != 0 { 170 | can = true 171 | } 172 | } 173 | return can 174 | } 175 | 176 | // ProtocolState computes a warp.State from the current warp. It acquires the 177 | // warp lock. 178 | func (w *WarpState) ProtocolState() warp.State { 179 | state := warp.State{ 180 | Warp: w.token, 181 | WindowSize: w.windowSize, 182 | Users: map[string]warp.User{}, 183 | } 184 | 185 | for token, user := range w.users { 186 | state.Users[token] = user.ProtocolUser() 187 | } 188 | 189 | return state 190 | } 191 | 192 | // WindowSizse returns the current window size. 193 | func (w *WarpState) WindowSize() warp.Size { 194 | return w.windowSize 195 | } 196 | 197 | // Modes returns user modes. 198 | func (w *WarpState) Modes() map[string]warp.Mode { 199 | modes := map[string]warp.Mode{} 200 | for token, u := range w.users { 201 | if !u.hosting { 202 | modes[token] = u.mode 203 | } 204 | } 205 | return modes 206 | } 207 | -------------------------------------------------------------------------------- /daemon/cmd/warpd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "flag" 6 | "log" 7 | "os" 8 | "runtime/pprof" 9 | "time" 10 | 11 | "github.com/spolu/warp" 12 | "github.com/spolu/warp/daemon" 13 | "github.com/spolu/warp/lib/errors" 14 | "github.com/spolu/warp/lib/logging" 15 | ) 16 | 17 | var lstFlag string 18 | var prfFlag string 19 | var crtFlag string 20 | var keyFlag string 21 | 22 | func init() { 23 | flag.StringVar(&lstFlag, "listen", 24 | ":4242", "Address to listen on ([ip]:port), default: `:4242`") 25 | flag.StringVar(&prfFlag, "cpuprofile", 26 | "", "Enalbe CPU profiling and write to specified file") 27 | flag.StringVar(&crtFlag, "cert", 28 | "", "Use the specified cert file to accetpt connections over TLS") 29 | flag.StringVar(&keyFlag, "key", 30 | "", "Use the specified key file to accept connections over TLS") 31 | 32 | if fl := log.Flags(); fl&log.Ltime != 0 { 33 | log.SetFlags(fl | log.Lmicroseconds) 34 | } 35 | } 36 | 37 | func main() { 38 | if !flag.Parsed() { 39 | flag.Parse() 40 | } 41 | 42 | if prfFlag != "" { 43 | f, err := os.Create(prfFlag) 44 | if err != nil { 45 | log.Fatal(errors.Details(err)) 46 | } 47 | 48 | go func() { 49 | pprof.StartCPUProfile(f) 50 | time.Sleep(10 * time.Second) 51 | pprof.StopCPUProfile() 52 | log.Fatal("OUT!") 53 | }() 54 | } 55 | 56 | ctx := context.Background() 57 | 58 | srv := daemon.NewSrv( 59 | ctx, 60 | lstFlag, 61 | crtFlag, 62 | keyFlag, 63 | ) 64 | 65 | logging.Logf(ctx, "Started warpd: version=%s", warp.Version) 66 | 67 | err := srv.Run(ctx) 68 | if err != nil { 69 | log.Fatal(errors.Details(err)) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /daemon/session.go: -------------------------------------------------------------------------------- 1 | package daemon 2 | 3 | import ( 4 | "context" 5 | "encoding/gob" 6 | "fmt" 7 | "net" 8 | "sync" 9 | "time" 10 | 11 | "github.com/hashicorp/yamux" 12 | "github.com/spolu/warp" 13 | "github.com/spolu/warp/lib/errors" 14 | "github.com/spolu/warp/lib/logging" 15 | ) 16 | 17 | // Session represents a client session connected to the warp. 18 | type Session struct { 19 | session warp.Session 20 | 21 | warp string 22 | sessionType warp.SessionType 23 | 24 | username string 25 | 26 | conn net.Conn 27 | mux *yamux.Session 28 | 29 | stateC net.Conn 30 | stateW *gob.Encoder 31 | updateC net.Conn 32 | updateR *gob.Decoder 33 | errorC net.Conn 34 | errorW *gob.Encoder 35 | dataC net.Conn 36 | 37 | tornDown bool 38 | ctx context.Context 39 | cancel func() 40 | 41 | mutex *sync.Mutex 42 | } 43 | 44 | // NewSession sets up a session, opens the associated channels and return a 45 | // Session object. 46 | func NewSession( 47 | ctx context.Context, 48 | cancel func(), 49 | conn net.Conn, 50 | ) (*Session, error) { 51 | mux, err := yamux.Server(conn, nil) 52 | if err != nil { 53 | return nil, errors.Trace( 54 | errors.Newf("Mux error: %v", err), 55 | ) 56 | } 57 | 58 | ss := &Session{ 59 | conn: conn, 60 | mux: mux, 61 | tornDown: false, 62 | ctx: ctx, 63 | cancel: cancel, 64 | mutex: &sync.Mutex{}, 65 | } 66 | 67 | // Opens state channel stateC. 68 | ss.stateC, err = mux.Accept() 69 | if err != nil { 70 | ss.TearDown() 71 | return nil, errors.Trace( 72 | errors.Newf("State channel open error: %v", err), 73 | ) 74 | } 75 | ss.stateW = gob.NewEncoder(ss.stateC) 76 | 77 | // Open update channel updateC. 78 | ss.updateC, err = mux.Accept() 79 | if err != nil { 80 | ss.TearDown() 81 | return nil, errors.Trace( 82 | errors.Newf("Update channel open error: %v", err), 83 | ) 84 | } 85 | ss.updateR = gob.NewDecoder(ss.updateC) 86 | 87 | var hello warp.SessionHello 88 | if err := ss.updateR.Decode(&hello); err != nil { 89 | ss.TearDown() 90 | return nil, errors.Trace( 91 | errors.Newf("Initial client update error: %v", err), 92 | ) 93 | } 94 | ss.session = hello.From 95 | ss.warp = hello.Warp 96 | ss.sessionType = hello.Type 97 | ss.username = hello.Username 98 | 99 | logging.Logf(ctx, 100 | "Session hello received: session=%s type=%s username=%s", 101 | ss.ToString(), hello.Type, hello.Username, 102 | ) 103 | 104 | // Opens error channel errorC. 105 | ss.errorC, err = mux.Accept() 106 | if err != nil { 107 | ss.TearDown() 108 | return nil, errors.Trace( 109 | errors.Newf("Error channel open error: %v", err), 110 | ) 111 | } 112 | ss.errorW = gob.NewEncoder(ss.errorC) 113 | 114 | // Open data channel dataC. 115 | ss.dataC, err = mux.Accept() 116 | if err != nil { 117 | ss.TearDown() 118 | return nil, errors.Trace( 119 | errors.Newf("Data channel open error: %v", err), 120 | ) 121 | } 122 | 123 | return ss, nil 124 | } 125 | 126 | // ToStering returns a string that identifies the session for logging. 127 | func (ss *Session) ToString() string { 128 | return fmt.Sprintf( 129 | "%s/%s:%s", ss.warp, ss.session.User, ss.session.Token, 130 | ) 131 | } 132 | 133 | // TearDown tears down a session, closing and reclaiming channels. 134 | func (ss *Session) TearDown() { 135 | ss.mutex.Lock() 136 | defer ss.mutex.Unlock() 137 | if !ss.tornDown { 138 | ss.tornDown = true 139 | ss.cancel() 140 | go func() { 141 | // Sleep for 500ms before killing the session to give a chance to 142 | // the bufffers to flush. 143 | time.Sleep(500 * time.Millisecond) 144 | // Closes stateC, updateC, errorC, dataC, mux and conn. 145 | ss.mux.Close() 146 | }() 147 | } 148 | } 149 | 150 | // SendError sends an error to the client which should trigger a disconnection 151 | // on its end. 152 | func (ss *Session) SendError( 153 | ctx context.Context, 154 | code string, 155 | message string, 156 | ) { 157 | ss.mutex.Lock() 158 | defer ss.mutex.Unlock() 159 | if ss.tornDown { 160 | return 161 | } 162 | logging.Logf(ctx, 163 | "Sending session error: session=%s code=%s message=%s", 164 | ss.ToString(), code, message, 165 | ) 166 | if err := ss.errorW.Encode(warp.Error{ 167 | Code: code, 168 | Message: message, 169 | }); err != nil { 170 | logging.Logf(ctx, 171 | "Error sending session error: session=%s error=%v", 172 | ss.ToString(), err, 173 | ) 174 | } 175 | } 176 | 177 | // SendInternalError sends an internal error to the client which should trigger 178 | // a disconnection on its end. 179 | func (ss *Session) SendInternalError( 180 | ctx context.Context, 181 | ) { 182 | ss.SendError(ctx, 183 | "internal_error", 184 | fmt.Sprintf( 185 | "The warp experienced an internal error (session: %s).", 186 | ss.ToString(), 187 | ), 188 | ) 189 | } 190 | -------------------------------------------------------------------------------- /lib/errors/function.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // Newf creates a new raw error and trace it. 9 | func Newf(format string, args ...interface{}) error { 10 | err := &wrap{ 11 | previous: fmt.Errorf(format, args...), 12 | } 13 | err.setLocation(1) 14 | return err 15 | } 16 | 17 | // Trace attach a location to the error. It should be called each time an error 18 | // is returned. If the error is nil, it returns nil. 19 | func Trace(other error) error { 20 | if other == nil { 21 | return nil 22 | } 23 | err := &wrap{ 24 | previous: other, 25 | } 26 | err.setLocation(1) 27 | return err 28 | } 29 | 30 | // Tracef attach a location and an annotation to the error. If the error is nil 31 | // it returns nil. 32 | func Tracef(other error, format string, args ...interface{}) error { 33 | if other == nil { 34 | return nil 35 | } 36 | err := &wrap{ 37 | traceMessage: fmt.Sprintf(format, args...), 38 | previous: other, 39 | } 40 | err.setLocation(1) 41 | return err 42 | } 43 | 44 | // Cause returns the underlying cause error of the passed error if it exists. 45 | func Cause(e error) error { 46 | switch e := e.(type) { 47 | case *wrap: 48 | return e.Cause() 49 | case UserError: 50 | return e.Cause() 51 | default: 52 | return e 53 | } 54 | } 55 | 56 | // ExtractUserError returns the underlying UserError or nil otherwise 57 | func ExtractUserError(err error) UserError { 58 | if err == nil { 59 | return nil 60 | } 61 | switch e := err.(type) { 62 | case *wrap: 63 | return e.UserError() 64 | case UserError: 65 | return e 66 | default: 67 | return nil 68 | } 69 | } 70 | 71 | // ErrorStack returns the full stack of information attached to this error. 72 | func ErrorStack(err error) []string { 73 | if err == nil { 74 | return []string{} 75 | } 76 | 77 | var lines []string 78 | for { 79 | var buff []byte 80 | if e, ok := err.(*wrap); ok { 81 | buff = append(buff, fmt.Sprintf("[trace] ")...) 82 | file, line := e.location() 83 | if file != "" { 84 | buff = append(buff, fmt.Sprintf("%s:%d", file, line)...) 85 | } 86 | if len(e.traceMessage) > 0 { 87 | buff = append(buff, fmt.Sprintf(": %s", e.traceMessage)...) 88 | } 89 | err = e.previous 90 | } else { 91 | buff = append(buff, fmt.Sprintf("[error] ")...) 92 | buff = append(buff, err.Error()...) 93 | err = nil 94 | } 95 | if len(string(buff)) > 0 { 96 | lines = append(lines, string(buff)) 97 | } 98 | if err == nil { 99 | break 100 | } 101 | } 102 | 103 | // reverse the lines to get the original error, which was at the end of 104 | // the list, back to the start. 105 | var result []string 106 | for i := len(lines); i > 0; i-- { 107 | result = append(result, lines[i-1]) 108 | } 109 | return result 110 | } 111 | 112 | // Details returned a formatted ErrorStack string 113 | func Details(err error) string { 114 | return strings.Join(ErrorStack(err), "\n") 115 | } 116 | -------------------------------------------------------------------------------- /lib/errors/user_error.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import "fmt" 4 | 5 | // UserError is the error interface that can be returned by the API 6 | type UserError interface { 7 | Cause() error 8 | Status() int 9 | Code() string 10 | Message() string 11 | Error() string 12 | } 13 | 14 | // ConcreteUserError is a concrete type that implements the UserError 15 | // interface. 16 | type ConcreteUserError struct { 17 | ErrCause error `json:"-"` 18 | ErrStatus int `json:"-"` 19 | ErrCode string `json:"code"` 20 | ErrMessage string `json:"message"` 21 | } 22 | 23 | // Build constructs a ConcreteUserError from a UserError. 24 | func Build(err UserError) *ConcreteUserError { 25 | return &ConcreteUserError{ 26 | ErrCause: err.Cause(), 27 | ErrStatus: err.Status(), 28 | ErrCode: err.Code(), 29 | ErrMessage: err.Message(), 30 | } 31 | } 32 | 33 | // Error complies to the UserError and error interface. 34 | func (e *ConcreteUserError) Error() string { 35 | if e.ErrCause != nil { 36 | return e.ErrCause.Error() 37 | } 38 | return "" 39 | } 40 | 41 | // Cause complies to the UserError interface. 42 | func (e *ConcreteUserError) Cause() error { 43 | return e.ErrCause 44 | } 45 | 46 | // Status complies to the UserError interface. 47 | func (e *ConcreteUserError) Status() int { 48 | return e.ErrStatus 49 | } 50 | 51 | // Code complies to the UserError interface. 52 | func (e *ConcreteUserError) Code() string { 53 | return e.ErrCode 54 | } 55 | 56 | // Message complies to the UserError interface. 57 | func (e *ConcreteUserError) Message() string { 58 | return e.ErrMessage 59 | } 60 | 61 | // NewUserError is an helper function to construct a new UserError. 62 | func NewUserError( 63 | err error, 64 | status int, 65 | code string, 66 | message string, 67 | ) UserError { 68 | return &ConcreteUserError{ 69 | ErrCause: err, 70 | ErrStatus: status, 71 | ErrCode: code, 72 | ErrMessage: message, 73 | } 74 | } 75 | 76 | // NewUserErrorf is an helper function to construct a new UserError. 77 | func NewUserErrorf( 78 | err error, 79 | status int, 80 | code string, 81 | format string, 82 | args ...interface{}, 83 | ) UserError { 84 | message := fmt.Sprintf(format, args...) 85 | return NewUserError(err, status, code, message) 86 | } 87 | -------------------------------------------------------------------------------- /lib/errors/wrap.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | "runtime" 5 | ) 6 | 7 | // wrap is the internal error type used to attach information to an underlying 8 | // error. As information is attached, the error is wrapped in wrap structures 9 | // each containing details about the error. 10 | type wrap struct { 11 | traceFile string 12 | traceLine int 13 | traceMessage string 14 | previous error 15 | } 16 | 17 | func (e *wrap) UserError() UserError { 18 | switch e := e.previous.(type) { 19 | case *wrap: 20 | return e.UserError() 21 | case UserError: 22 | return e 23 | default: 24 | return nil 25 | } 26 | } 27 | 28 | // Cause returns the underlying error if not nil 29 | func (e *wrap) Cause() error { 30 | switch e := e.previous.(type) { 31 | case *wrap: 32 | return e.Cause() 33 | case UserError: 34 | return e.Cause() 35 | default: 36 | return e 37 | } 38 | } 39 | 40 | // Error returns the error message of the underlying error if not nil otherwise 41 | // it returns the error stack consumable message. 42 | func (e *wrap) Error() string { 43 | err := e.Cause() 44 | if err != nil { 45 | return err.Error() 46 | } 47 | return "" 48 | } 49 | 50 | // StackTrace returns the full stack of information attached to the error 51 | func (e *wrap) StackTrace() []string { 52 | return ErrorStack(e) 53 | } 54 | 55 | func (e *wrap) setLocation(callDepth int) { 56 | _, file, line, _ := runtime.Caller(callDepth + 1) 57 | e.traceFile = file 58 | e.traceLine = line 59 | } 60 | 61 | func (e *wrap) location() (filename string, line int) { 62 | return e.traceFile, e.traceLine 63 | } 64 | -------------------------------------------------------------------------------- /lib/logging/logging.go: -------------------------------------------------------------------------------- 1 | package logging 2 | 3 | import ( 4 | "context" 5 | "log" 6 | ) 7 | 8 | var silentKey = new(int) 9 | 10 | // SetSilent indicates that logs should not actually be omitted for this ctx 11 | func SetSilent(ctx context.Context, val bool) context.Context { 12 | return context.WithValue(ctx, silentKey, val) 13 | } 14 | 15 | // Silent indicates whether this context has been marked as silent (so 16 | // we shouldn't chunder logs) 17 | func Silent(ctx context.Context) bool { 18 | val, ok := ctx.Value(silentKey).(bool) 19 | return ok && val 20 | } 21 | 22 | // Log shells out to log.Print if Silent is not set. 23 | func Log(c context.Context, v ...interface{}) { 24 | if c != nil { 25 | if !Silent(c) { 26 | log.Print(v...) 27 | } 28 | } else { 29 | log.Print(v...) 30 | } 31 | } 32 | 33 | // Logf shells out to log.Printf if Silent is not set. 34 | func Logf(c context.Context, format string, v ...interface{}) { 35 | if c != nil { 36 | if !Silent(c) { 37 | log.Printf(format, v...) 38 | } 39 | } else { 40 | log.Printf(format, v...) 41 | } 42 | } 43 | 44 | // PadRight right-pads a string. 45 | func PadRight( 46 | str string, 47 | pad string, 48 | lenght int, 49 | ) string { 50 | for { 51 | str += pad 52 | if len(str) > lenght { 53 | return str[0:lenght] 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/out/out.go: -------------------------------------------------------------------------------- 1 | package out 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/fatih/color" 7 | ) 8 | 9 | var white *color.Color 10 | var bold *color.Color 11 | var cyan *color.Color 12 | var yellow *color.Color 13 | var magenta *color.Color 14 | var redBold *color.Color 15 | 16 | func init() { 17 | white = color.New(color.FgWhite) 18 | bold = color.New(color.Bold) 19 | cyan = color.New(color.FgCyan) 20 | yellow = color.New(color.FgYellow) 21 | magenta = color.New(color.FgMagenta) 22 | redBold = color.New(color.FgRed, color.Bold) 23 | } 24 | 25 | // Normf prints a normal message. 26 | func Normf(format string, v ...interface{}) { 27 | fmt.Printf(format, v...) 28 | } 29 | 30 | // Boldf prints a bold message. 31 | func Boldf(format string, v ...interface{}) { 32 | bold.PrintfFunc()(format, v...) 33 | } 34 | 35 | // Valuf prints an example message. 36 | func Valuf(format string, v ...interface{}) { 37 | cyan.PrintfFunc()(format, v...) 38 | } 39 | 40 | // Warnf prints a warning message. 41 | func Warnf(format string, v ...interface{}) { 42 | yellow.PrintfFunc()(format, v...) 43 | } 44 | 45 | // Errof prints an error message. 46 | func Errof(format string, v ...interface{}) { 47 | redBold.PrintfFunc()(format, v...) 48 | } 49 | 50 | // Statf prints an error message. 51 | func Statf(format string, v ...interface{}) { 52 | magenta.PrintfFunc()(format, v...) 53 | } 54 | -------------------------------------------------------------------------------- /lib/plex/plex.go: -------------------------------------------------------------------------------- 1 | package plex 2 | 3 | import ( 4 | "context" 5 | "io" 6 | ) 7 | 8 | // Run pipes src to a funtion and aborts if the context gets canceled. 9 | func Run( 10 | ctx context.Context, 11 | dst func([]byte), 12 | src io.Reader, 13 | ) { 14 | buf := make([]byte, 1024) 15 | PLEXLOOP: 16 | for { 17 | nr, err := src.Read(buf) 18 | if nr > 0 { 19 | cpy := make([]byte, nr) 20 | copy(cpy, buf) 21 | dst(cpy) 22 | } 23 | if err != nil { 24 | break 25 | } 26 | select { 27 | case <-ctx.Done(): 28 | break PLEXLOOP 29 | default: 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/token/token.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "bufio" 5 | "crypto/rand" 6 | "encoding/base64" 7 | "io" 8 | "log" 9 | ) 10 | 11 | // Tokens 12 | 13 | const ( 14 | tokenLength = 16 15 | a62 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__" 16 | ) 17 | 18 | var tokens = make(tokenFountain, 512) 19 | 20 | type tokenFountain chan string 21 | 22 | func (f tokenFountain) Write( 23 | buf []byte, 24 | ) (int, error) { 25 | var token [tokenLength]byte 26 | var i int 27 | for _, b := range buf { 28 | if b != '_' { 29 | token[i] = b 30 | i++ 31 | } 32 | if i == tokenLength { 33 | f <- string(token[:]) 34 | i = 0 35 | } 36 | } 37 | 38 | return len(buf), nil 39 | } 40 | 41 | func init() { 42 | buf := bufio.NewWriterSize(tokens, 1024) 43 | enc := base64.NewEncoder(base64.NewEncoding(a62), buf) 44 | 45 | go func() { 46 | _, err := io.Copy(enc, rand.Reader) 47 | // If rand.Reader ever ends or throws an error, we're going to have a 48 | // bad time, and there's really not much we can do about it. 49 | log.Panicln("utils.rand: token creation ran out of entropy", err) 50 | }() 51 | } 52 | 53 | // New generates a random token prefixed by prefix 54 | func New( 55 | name string, 56 | ) string { 57 | return name + "_" + RandStr() 58 | } 59 | 60 | // RandStr generates a random string 61 | func RandStr() string { 62 | return <-tokens 63 | } 64 | -------------------------------------------------------------------------------- /protocol.go: -------------------------------------------------------------------------------- 1 | package warp 2 | 3 | import "regexp" 4 | 5 | // 6 | // Remote Warpd Protocol 7 | // 8 | 9 | // Version is the current warp version. 10 | var Version = "0.0.3" 11 | 12 | // DefaultAddress to connect to 13 | var DefaultAddress = "warp.link:4242" 14 | 15 | // WarpRegexp warp token regular expression. 16 | var WarpRegexp = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9-_.]{0,255}$") 17 | 18 | // Mode is used to represent the mode of a client (read/write). 19 | type Mode uint64 20 | 21 | const ( 22 | ModeShellRead Mode = 1 23 | ModeShellWrite Mode = 1 << 1 24 | // Future usecases: 25 | // ModeVoicekRead|ModeVoicekWrite|ModeVoicekMuted 26 | // ModeVerified 27 | 28 | DefaultHostMode = ModeShellRead | ModeShellWrite 29 | DefaultUserMode = ModeShellRead 30 | ) 31 | 32 | // SessionType encodes the type of the session: 33 | type SessionType string 34 | 35 | const ( 36 | // SsTpHost the host session that created the warp (`warp open`) 37 | SsTpHost SessionType = "host" 38 | // SsTpShellClient shell client session (`warp connect`) 39 | SsTpShellClient SessionType = "shell" 40 | // SsTpChatClient chat client session (`warp chat`) 41 | SsTpChatClient SessionType = "chat" 42 | ) 43 | 44 | // User represents a user of a warp. 45 | type User struct { 46 | Token string 47 | Username string 48 | 49 | Mode Mode 50 | Hosting bool 51 | } 52 | 53 | // Session identifies a user's session. 54 | type Session struct { 55 | Token string 56 | User string 57 | Secret string 58 | } 59 | 60 | // Error is th struct sent over the network in case of errors. 61 | type Error struct { 62 | Code string 63 | Message string 64 | } 65 | 66 | // Size reprensents a window size. 67 | type Size struct { 68 | Rows int 69 | Cols int 70 | } 71 | 72 | // State is the struct sent over the network to update sessions state. 73 | type State struct { 74 | Warp string 75 | WindowSize Size 76 | Users map[string]User 77 | } 78 | 79 | // SessionHello is the initial message sent over a session update channel to 80 | // identify itself to the server. 81 | type SessionHello struct { 82 | Warp string 83 | From Session 84 | Version string 85 | 86 | Type SessionType 87 | Username string 88 | } 89 | 90 | // HostUpdate represents an update to the warp state from its host. 91 | type HostUpdate struct { 92 | Warp string 93 | From Session 94 | 95 | WindowSize Size 96 | // Modes is a map from user token to mode. 97 | Modes map[string]Mode 98 | } 99 | 100 | // 101 | // Local Command Server Protocol 102 | // 103 | 104 | // EnvWarp the env variable where the warp token is stored. 105 | var EnvWarp = "__WARP" 106 | 107 | // CommandType encodes the type of the session: 108 | type CommandType string 109 | 110 | const ( 111 | // CmdTpState retrieve the state of the warp. 112 | CmdTpState CommandType = "state" 113 | // CmdTpAuthorize authorizes a user for writing. 114 | CmdTpAuthorize CommandType = "authorize" 115 | // CmdTpRevoke a (or all) user(s) authorization to write. 116 | CmdTpRevoke CommandType = "revoke" 117 | ) 118 | 119 | // Command is used to send command to the local host. 120 | type Command struct { 121 | Type CommandType 122 | Args []string 123 | } 124 | 125 | // CommandResult is used to send command result to the local client. 126 | type CommandResult struct { 127 | Type CommandType 128 | Disconnected bool 129 | SessionState State 130 | Error Error 131 | } 132 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/README.md: -------------------------------------------------------------------------------- 1 | # Color [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/fatih/color) [![Build Status](http://img.shields.io/travis/fatih/color.svg?style=flat-square)](https://travis-ci.org/fatih/color) 2 | 3 | 4 | 5 | Color lets you use colorized outputs in terms of [ANSI Escape 6 | Codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) in Go (Golang). It 7 | has support for Windows too! The API can be used in several ways, pick one that 8 | suits you. 9 | 10 | 11 | ![Color](http://i.imgur.com/c1JI0lA.png) 12 | 13 | 14 | ## Install 15 | 16 | ```bash 17 | go get github.com/fatih/color 18 | ``` 19 | 20 | Note that the `vendor` folder is here for stability. Remove the folder if you 21 | already have the dependencies in your GOPATH. 22 | 23 | ## Examples 24 | 25 | ### Standard colors 26 | 27 | ```go 28 | // Print with default helper functions 29 | color.Cyan("Prints text in cyan.") 30 | 31 | // A newline will be appended automatically 32 | color.Blue("Prints %s in blue.", "text") 33 | 34 | // These are using the default foreground colors 35 | color.Red("We have red") 36 | color.Magenta("And many others ..") 37 | 38 | ``` 39 | 40 | ### Mix and reuse colors 41 | 42 | ```go 43 | // Create a new color object 44 | c := color.New(color.FgCyan).Add(color.Underline) 45 | c.Println("Prints cyan text with an underline.") 46 | 47 | // Or just add them to New() 48 | d := color.New(color.FgCyan, color.Bold) 49 | d.Printf("This prints bold cyan %s\n", "too!.") 50 | 51 | // Mix up foreground and background colors, create new mixes! 52 | red := color.New(color.FgRed) 53 | 54 | boldRed := red.Add(color.Bold) 55 | boldRed.Println("This will print text in bold red.") 56 | 57 | whiteBackground := red.Add(color.BgWhite) 58 | whiteBackground.Println("Red text with white background.") 59 | ``` 60 | 61 | ### Use your own output (io.Writer) 62 | 63 | ```go 64 | // Use your own io.Writer output 65 | color.New(color.FgBlue).Fprintln(myWriter, "blue color!") 66 | 67 | blue := color.New(color.FgBlue) 68 | blue.Fprint(writer, "This will print text in blue.") 69 | ``` 70 | 71 | ### Custom print functions (PrintFunc) 72 | 73 | ```go 74 | // Create a custom print function for convenience 75 | red := color.New(color.FgRed).PrintfFunc() 76 | red("Warning") 77 | red("Error: %s", err) 78 | 79 | // Mix up multiple attributes 80 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc() 81 | notice("Don't forget this...") 82 | ``` 83 | 84 | ### Custom fprint functions (FprintFunc) 85 | 86 | ```go 87 | blue := color.New(FgBlue).FprintfFunc() 88 | blue(myWriter, "important notice: %s", stars) 89 | 90 | // Mix up with multiple attributes 91 | success := color.New(color.Bold, color.FgGreen).FprintlnFunc() 92 | success(myWriter, "Don't forget this...") 93 | ``` 94 | 95 | ### Insert into noncolor strings (SprintFunc) 96 | 97 | ```go 98 | // Create SprintXxx functions to mix strings with other non-colorized strings: 99 | yellow := color.New(color.FgYellow).SprintFunc() 100 | red := color.New(color.FgRed).SprintFunc() 101 | fmt.Printf("This is a %s and this is %s.\n", yellow("warning"), red("error")) 102 | 103 | info := color.New(color.FgWhite, color.BgGreen).SprintFunc() 104 | fmt.Printf("This %s rocks!\n", info("package")) 105 | 106 | // Use helper functions 107 | fmt.Println("This", color.RedString("warning"), "should be not neglected.") 108 | fmt.Printf("%v %v\n", color.GreenString("Info:"), "an important message.") 109 | 110 | // Windows supported too! Just don't forget to change the output to color.Output 111 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS")) 112 | ``` 113 | 114 | ### Plug into existing code 115 | 116 | ```go 117 | // Use handy standard colors 118 | color.Set(color.FgYellow) 119 | 120 | fmt.Println("Existing text will now be in yellow") 121 | fmt.Printf("This one %s\n", "too") 122 | 123 | color.Unset() // Don't forget to unset 124 | 125 | // You can mix up parameters 126 | color.Set(color.FgMagenta, color.Bold) 127 | defer color.Unset() // Use it in your function 128 | 129 | fmt.Println("All text will now be bold magenta.") 130 | ``` 131 | 132 | ### Disable color 133 | 134 | There might be a case where you want to disable color output (for example to 135 | pipe the standard output of your app to somewhere else). `Color` has support to 136 | disable colors both globally and for single color definition. For example 137 | suppose you have a CLI app and a `--no-color` bool flag. You can easily disable 138 | the color output with: 139 | 140 | ```go 141 | 142 | var flagNoColor = flag.Bool("no-color", false, "Disable color output") 143 | 144 | if *flagNoColor { 145 | color.NoColor = true // disables colorized output 146 | } 147 | ``` 148 | 149 | It also has support for single color definitions (local). You can 150 | disable/enable color output on the fly: 151 | 152 | ```go 153 | c := color.New(color.FgCyan) 154 | c.Println("Prints cyan text") 155 | 156 | c.DisableColor() 157 | c.Println("This is printed without any color") 158 | 159 | c.EnableColor() 160 | c.Println("This prints again cyan...") 161 | ``` 162 | 163 | ## Todo 164 | 165 | * Save/Return previous values 166 | * Evaluate fmt.Formatter interface 167 | 168 | 169 | ## Credits 170 | 171 | * [Fatih Arslan](https://github.com/fatih) 172 | * Windows support via @mattn: [colorable](https://github.com/mattn/go-colorable) 173 | 174 | ## License 175 | 176 | The MIT License (MIT) - see [`LICENSE.md`](https://github.com/fatih/color/blob/master/LICENSE.md) for more details 177 | 178 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package color is an ANSI color package to output colorized or SGR defined 3 | output to the standard output. The API can be used in several way, pick one 4 | that suits you. 5 | 6 | Use simple and default helper functions with predefined foreground colors: 7 | 8 | color.Cyan("Prints text in cyan.") 9 | 10 | // a newline will be appended automatically 11 | color.Blue("Prints %s in blue.", "text") 12 | 13 | // More default foreground colors.. 14 | color.Red("We have red") 15 | color.Yellow("Yellow color too!") 16 | color.Magenta("And many others ..") 17 | 18 | However there are times where custom color mixes are required. Below are some 19 | examples to create custom color objects and use the print functions of each 20 | separate color object. 21 | 22 | // Create a new color object 23 | c := color.New(color.FgCyan).Add(color.Underline) 24 | c.Println("Prints cyan text with an underline.") 25 | 26 | // Or just add them to New() 27 | d := color.New(color.FgCyan, color.Bold) 28 | d.Printf("This prints bold cyan %s\n", "too!.") 29 | 30 | 31 | // Mix up foreground and background colors, create new mixes! 32 | red := color.New(color.FgRed) 33 | 34 | boldRed := red.Add(color.Bold) 35 | boldRed.Println("This will print text in bold red.") 36 | 37 | whiteBackground := red.Add(color.BgWhite) 38 | whiteBackground.Println("Red text with White background.") 39 | 40 | // Use your own io.Writer output 41 | color.New(color.FgBlue).Fprintln(myWriter, "blue color!") 42 | 43 | blue := color.New(color.FgBlue) 44 | blue.Fprint(myWriter, "This will print text in blue.") 45 | 46 | You can create PrintXxx functions to simplify even more: 47 | 48 | // Create a custom print function for convenient 49 | red := color.New(color.FgRed).PrintfFunc() 50 | red("warning") 51 | red("error: %s", err) 52 | 53 | // Mix up multiple attributes 54 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc() 55 | notice("don't forget this...") 56 | 57 | You can also FprintXxx functions to pass your own io.Writer: 58 | 59 | blue := color.New(FgBlue).FprintfFunc() 60 | blue(myWriter, "important notice: %s", stars) 61 | 62 | // Mix up with multiple attributes 63 | success := color.New(color.Bold, color.FgGreen).FprintlnFunc() 64 | success(myWriter, don't forget this...") 65 | 66 | 67 | Or create SprintXxx functions to mix strings with other non-colorized strings: 68 | 69 | yellow := New(FgYellow).SprintFunc() 70 | red := New(FgRed).SprintFunc() 71 | 72 | fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error")) 73 | 74 | info := New(FgWhite, BgGreen).SprintFunc() 75 | fmt.Printf("this %s rocks!\n", info("package")) 76 | 77 | Windows support is enabled by default. All Print functions works as intended. 78 | However only for color.SprintXXX functions, user should use fmt.FprintXXX and 79 | set the output to color.Output: 80 | 81 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS")) 82 | 83 | info := New(FgWhite, BgGreen).SprintFunc() 84 | fmt.Fprintf(color.Output, "this %s rocks!\n", info("package")) 85 | 86 | Using with existing code is possible. Just use the Set() method to set the 87 | standard output to the given parameters. That way a rewrite of an existing 88 | code is not required. 89 | 90 | // Use handy standard colors. 91 | color.Set(color.FgYellow) 92 | 93 | fmt.Println("Existing text will be now in Yellow") 94 | fmt.Printf("This one %s\n", "too") 95 | 96 | color.Unset() // don't forget to unset 97 | 98 | // You can mix up parameters 99 | color.Set(color.FgMagenta, color.Bold) 100 | defer color.Unset() // use it in your function 101 | 102 | fmt.Println("All text will be now bold magenta.") 103 | 104 | There might be a case where you want to disable color output (for example to 105 | pipe the standard output of your app to somewhere else). `Color` has support to 106 | disable colors both globally and for single color definition. For example 107 | suppose you have a CLI app and a `--no-color` bool flag. You can easily disable 108 | the color output with: 109 | 110 | var flagNoColor = flag.Bool("no-color", false, "Disable color output") 111 | 112 | if *flagNoColor { 113 | color.NoColor = true // disables colorized output 114 | } 115 | 116 | It also has support for single color definitions (local). You can 117 | disable/enable color output on the fly: 118 | 119 | c := color.New(color.FgCyan) 120 | c.Println("Prints cyan text") 121 | 122 | c.DisableColor() 123 | c.Println("This is printed without any color") 124 | 125 | c.EnableColor() 126 | c.Println("This prints again cyan...") 127 | */ 128 | package color 129 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/yamux/README.md: -------------------------------------------------------------------------------- 1 | # Yamux 2 | 3 | Yamux (Yet another Multiplexer) is a multiplexing library for Golang. 4 | It relies on an underlying connection to provide reliability 5 | and ordering, such as TCP or Unix domain sockets, and provides 6 | stream-oriented multiplexing. It is inspired by SPDY but is not 7 | interoperable with it. 8 | 9 | Yamux features include: 10 | 11 | * Bi-directional streams 12 | * Streams can be opened by either client or server 13 | * Useful for NAT traversal 14 | * Server-side push support 15 | * Flow control 16 | * Avoid starvation 17 | * Back-pressure to prevent overwhelming a receiver 18 | * Keep Alives 19 | * Enables persistent connections over a load balancer 20 | * Efficient 21 | * Enables thousands of logical streams with low overhead 22 | 23 | ## Documentation 24 | 25 | For complete documentation, see the associated [Godoc](http://godoc.org/github.com/hashicorp/yamux). 26 | 27 | ## Specification 28 | 29 | The full specification for Yamux is provided in the `spec.md` file. 30 | It can be used as a guide to implementors of interoperable libraries. 31 | 32 | ## Usage 33 | 34 | Using Yamux is remarkably simple: 35 | 36 | ```go 37 | 38 | func client() { 39 | // Get a TCP connection 40 | conn, err := net.Dial(...) 41 | if err != nil { 42 | panic(err) 43 | } 44 | 45 | // Setup client side of yamux 46 | session, err := yamux.Client(conn, nil) 47 | if err != nil { 48 | panic(err) 49 | } 50 | 51 | // Open a new stream 52 | stream, err := session.Open() 53 | if err != nil { 54 | panic(err) 55 | } 56 | 57 | // Stream implements net.Conn 58 | stream.Write([]byte("ping")) 59 | } 60 | 61 | func server() { 62 | // Accept a TCP connection 63 | conn, err := listener.Accept() 64 | if err != nil { 65 | panic(err) 66 | } 67 | 68 | // Setup server side of yamux 69 | session, err := yamux.Server(conn, nil) 70 | if err != nil { 71 | panic(err) 72 | } 73 | 74 | // Accept a stream 75 | stream, err := session.Accept() 76 | if err != nil { 77 | panic(err) 78 | } 79 | 80 | // Listen for a message 81 | buf := make([]byte, 4) 82 | stream.Read(buf) 83 | } 84 | 85 | ``` 86 | 87 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/yamux/addr.go: -------------------------------------------------------------------------------- 1 | package yamux 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | ) 7 | 8 | // hasAddr is used to get the address from the underlying connection 9 | type hasAddr interface { 10 | LocalAddr() net.Addr 11 | RemoteAddr() net.Addr 12 | } 13 | 14 | // yamuxAddr is used when we cannot get the underlying address 15 | type yamuxAddr struct { 16 | Addr string 17 | } 18 | 19 | func (*yamuxAddr) Network() string { 20 | return "yamux" 21 | } 22 | 23 | func (y *yamuxAddr) String() string { 24 | return fmt.Sprintf("yamux:%s", y.Addr) 25 | } 26 | 27 | // Addr is used to get the address of the listener. 28 | func (s *Session) Addr() net.Addr { 29 | return s.LocalAddr() 30 | } 31 | 32 | // LocalAddr is used to get the local address of the 33 | // underlying connection. 34 | func (s *Session) LocalAddr() net.Addr { 35 | addr, ok := s.conn.(hasAddr) 36 | if !ok { 37 | return &yamuxAddr{"local"} 38 | } 39 | return addr.LocalAddr() 40 | } 41 | 42 | // RemoteAddr is used to get the address of remote end 43 | // of the underlying connection 44 | func (s *Session) RemoteAddr() net.Addr { 45 | addr, ok := s.conn.(hasAddr) 46 | if !ok { 47 | return &yamuxAddr{"remote"} 48 | } 49 | return addr.RemoteAddr() 50 | } 51 | 52 | // LocalAddr returns the local address 53 | func (s *Stream) LocalAddr() net.Addr { 54 | return s.session.LocalAddr() 55 | } 56 | 57 | // LocalAddr returns the remote address 58 | func (s *Stream) RemoteAddr() net.Addr { 59 | return s.session.RemoteAddr() 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/yamux/const.go: -------------------------------------------------------------------------------- 1 | package yamux 2 | 3 | import ( 4 | "encoding/binary" 5 | "fmt" 6 | ) 7 | 8 | var ( 9 | // ErrInvalidVersion means we received a frame with an 10 | // invalid version 11 | ErrInvalidVersion = fmt.Errorf("invalid protocol version") 12 | 13 | // ErrInvalidMsgType means we received a frame with an 14 | // invalid message type 15 | ErrInvalidMsgType = fmt.Errorf("invalid msg type") 16 | 17 | // ErrSessionShutdown is used if there is a shutdown during 18 | // an operation 19 | ErrSessionShutdown = fmt.Errorf("session shutdown") 20 | 21 | // ErrStreamsExhausted is returned if we have no more 22 | // stream ids to issue 23 | ErrStreamsExhausted = fmt.Errorf("streams exhausted") 24 | 25 | // ErrDuplicateStream is used if a duplicate stream is 26 | // opened inbound 27 | ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") 28 | 29 | // ErrReceiveWindowExceeded indicates the window was exceeded 30 | ErrRecvWindowExceeded = fmt.Errorf("recv window exceeded") 31 | 32 | // ErrTimeout is used when we reach an IO deadline 33 | ErrTimeout = fmt.Errorf("i/o deadline reached") 34 | 35 | // ErrStreamClosed is returned when using a closed stream 36 | ErrStreamClosed = fmt.Errorf("stream closed") 37 | 38 | // ErrUnexpectedFlag is set when we get an unexpected flag 39 | ErrUnexpectedFlag = fmt.Errorf("unexpected flag") 40 | 41 | // ErrRemoteGoAway is used when we get a go away from the other side 42 | ErrRemoteGoAway = fmt.Errorf("remote end is not accepting connections") 43 | 44 | // ErrConnectionReset is sent if a stream is reset. This can happen 45 | // if the backlog is exceeded, or if there was a remote GoAway. 46 | ErrConnectionReset = fmt.Errorf("connection reset") 47 | 48 | // ErrConnectionWriteTimeout indicates that we hit the "safety valve" 49 | // timeout writing to the underlying stream connection. 50 | ErrConnectionWriteTimeout = fmt.Errorf("connection write timeout") 51 | 52 | // ErrKeepAliveTimeout is sent if a missed keepalive caused the stream close 53 | ErrKeepAliveTimeout = fmt.Errorf("keepalive timeout") 54 | ) 55 | 56 | const ( 57 | // protoVersion is the only version we support 58 | protoVersion uint8 = 0 59 | ) 60 | 61 | const ( 62 | // Data is used for data frames. They are followed 63 | // by length bytes worth of payload. 64 | typeData uint8 = iota 65 | 66 | // WindowUpdate is used to change the window of 67 | // a given stream. The length indicates the delta 68 | // update to the window. 69 | typeWindowUpdate 70 | 71 | // Ping is sent as a keep-alive or to measure 72 | // the RTT. The StreamID and Length value are echoed 73 | // back in the response. 74 | typePing 75 | 76 | // GoAway is sent to terminate a session. The StreamID 77 | // should be 0 and the length is an error code. 78 | typeGoAway 79 | ) 80 | 81 | const ( 82 | // SYN is sent to signal a new stream. May 83 | // be sent with a data payload 84 | flagSYN uint16 = 1 << iota 85 | 86 | // ACK is sent to acknowledge a new stream. May 87 | // be sent with a data payload 88 | flagACK 89 | 90 | // FIN is sent to half-close the given stream. 91 | // May be sent with a data payload. 92 | flagFIN 93 | 94 | // RST is used to hard close a given stream. 95 | flagRST 96 | ) 97 | 98 | const ( 99 | // initialStreamWindow is the initial stream window size 100 | initialStreamWindow uint32 = 256 * 1024 101 | ) 102 | 103 | const ( 104 | // goAwayNormal is sent on a normal termination 105 | goAwayNormal uint32 = iota 106 | 107 | // goAwayProtoErr sent on a protocol error 108 | goAwayProtoErr 109 | 110 | // goAwayInternalErr sent on an internal error 111 | goAwayInternalErr 112 | ) 113 | 114 | const ( 115 | sizeOfVersion = 1 116 | sizeOfType = 1 117 | sizeOfFlags = 2 118 | sizeOfStreamID = 4 119 | sizeOfLength = 4 120 | headerSize = sizeOfVersion + sizeOfType + sizeOfFlags + 121 | sizeOfStreamID + sizeOfLength 122 | ) 123 | 124 | type header []byte 125 | 126 | func (h header) Version() uint8 { 127 | return h[0] 128 | } 129 | 130 | func (h header) MsgType() uint8 { 131 | return h[1] 132 | } 133 | 134 | func (h header) Flags() uint16 { 135 | return binary.BigEndian.Uint16(h[2:4]) 136 | } 137 | 138 | func (h header) StreamID() uint32 { 139 | return binary.BigEndian.Uint32(h[4:8]) 140 | } 141 | 142 | func (h header) Length() uint32 { 143 | return binary.BigEndian.Uint32(h[8:12]) 144 | } 145 | 146 | func (h header) String() string { 147 | return fmt.Sprintf("Vsn:%d Type:%d Flags:%d StreamID:%d Length:%d", 148 | h.Version(), h.MsgType(), h.Flags(), h.StreamID(), h.Length()) 149 | } 150 | 151 | func (h header) encode(msgType uint8, flags uint16, streamID uint32, length uint32) { 152 | h[0] = protoVersion 153 | h[1] = msgType 154 | binary.BigEndian.PutUint16(h[2:4], flags) 155 | binary.BigEndian.PutUint32(h[4:8], streamID) 156 | binary.BigEndian.PutUint32(h[8:12], length) 157 | } 158 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/yamux/mux.go: -------------------------------------------------------------------------------- 1 | package yamux 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "time" 8 | ) 9 | 10 | // Config is used to tune the Yamux session 11 | type Config struct { 12 | // AcceptBacklog is used to limit how many streams may be 13 | // waiting an accept. 14 | AcceptBacklog int 15 | 16 | // EnableKeepalive is used to do a period keep alive 17 | // messages using a ping. 18 | EnableKeepAlive bool 19 | 20 | // KeepAliveInterval is how often to perform the keep alive 21 | KeepAliveInterval time.Duration 22 | 23 | // ConnectionWriteTimeout is meant to be a "safety valve" timeout after 24 | // we which will suspect a problem with the underlying connection and 25 | // close it. This is only applied to writes, where's there's generally 26 | // an expectation that things will move along quickly. 27 | ConnectionWriteTimeout time.Duration 28 | 29 | // MaxStreamWindowSize is used to control the maximum 30 | // window size that we allow for a stream. 31 | MaxStreamWindowSize uint32 32 | 33 | // LogOutput is used to control the log destination 34 | LogOutput io.Writer 35 | } 36 | 37 | // DefaultConfig is used to return a default configuration 38 | func DefaultConfig() *Config { 39 | return &Config{ 40 | AcceptBacklog: 256, 41 | EnableKeepAlive: true, 42 | KeepAliveInterval: 30 * time.Second, 43 | ConnectionWriteTimeout: 10 * time.Second, 44 | MaxStreamWindowSize: initialStreamWindow, 45 | LogOutput: os.Stderr, 46 | } 47 | } 48 | 49 | // VerifyConfig is used to verify the sanity of configuration 50 | func VerifyConfig(config *Config) error { 51 | if config.AcceptBacklog <= 0 { 52 | return fmt.Errorf("backlog must be positive") 53 | } 54 | if config.KeepAliveInterval == 0 { 55 | return fmt.Errorf("keep-alive interval must be positive") 56 | } 57 | if config.MaxStreamWindowSize < initialStreamWindow { 58 | return fmt.Errorf("MaxStreamWindowSize must be larger than %d", initialStreamWindow) 59 | } 60 | return nil 61 | } 62 | 63 | // Server is used to initialize a new server-side connection. 64 | // There must be at most one server-side connection. If a nil config is 65 | // provided, the DefaultConfiguration will be used. 66 | func Server(conn io.ReadWriteCloser, config *Config) (*Session, error) { 67 | if config == nil { 68 | config = DefaultConfig() 69 | } 70 | if err := VerifyConfig(config); err != nil { 71 | return nil, err 72 | } 73 | return newSession(config, conn, false), nil 74 | } 75 | 76 | // Client is used to initialize a new client-side connection. 77 | // There must be at most one client-side connection. 78 | func Client(conn io.ReadWriteCloser, config *Config) (*Session, error) { 79 | if config == nil { 80 | config = DefaultConfig() 81 | } 82 | 83 | if err := VerifyConfig(config); err != nil { 84 | return nil, err 85 | } 86 | return newSession(config, conn, true), nil 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/yamux/spec.md: -------------------------------------------------------------------------------- 1 | # Specification 2 | 3 | We use this document to detail the internal specification of Yamux. 4 | This is used both as a guide for implementing Yamux, but also for 5 | alternative interoperable libraries to be built. 6 | 7 | # Framing 8 | 9 | Yamux uses a streaming connection underneath, but imposes a message 10 | framing so that it can be shared between many logical streams. Each 11 | frame contains a header like: 12 | 13 | * Version (8 bits) 14 | * Type (8 bits) 15 | * Flags (16 bits) 16 | * StreamID (32 bits) 17 | * Length (32 bits) 18 | 19 | This means that each header has a 12 byte overhead. 20 | All fields are encoded in network order (big endian). 21 | Each field is described below: 22 | 23 | ## Version Field 24 | 25 | The version field is used for future backward compatibility. At the 26 | current time, the field is always set to 0, to indicate the initial 27 | version. 28 | 29 | ## Type Field 30 | 31 | The type field is used to switch the frame message type. The following 32 | message types are supported: 33 | 34 | * 0x0 Data - Used to transmit data. May transmit zero length payloads 35 | depending on the flags. 36 | 37 | * 0x1 Window Update - Used to updated the senders receive window size. 38 | This is used to implement per-session flow control. 39 | 40 | * 0x2 Ping - Used to measure RTT. It can also be used to heart-beat 41 | and do keep-alives over TCP. 42 | 43 | * 0x3 Go Away - Used to close a session. 44 | 45 | ## Flag Field 46 | 47 | The flags field is used to provide additional information related 48 | to the message type. The following flags are supported: 49 | 50 | * 0x1 SYN - Signals the start of a new stream. May be sent with a data or 51 | window update message. Also sent with a ping to indicate outbound. 52 | 53 | * 0x2 ACK - Acknowledges the start of a new stream. May be sent with a data 54 | or window update message. Also sent with a ping to indicate response. 55 | 56 | * 0x4 FIN - Performs a half-close of a stream. May be sent with a data 57 | message or window update. 58 | 59 | * 0x8 RST - Reset a stream immediately. May be sent with a data or 60 | window update message. 61 | 62 | ## StreamID Field 63 | 64 | The StreamID field is used to identify the logical stream the frame 65 | is addressing. The client side should use odd ID's, and the server even. 66 | This prevents any collisions. Additionally, the 0 ID is reserved to represent 67 | the session. 68 | 69 | Both Ping and Go Away messages should always use the 0 StreamID. 70 | 71 | ## Length Field 72 | 73 | The meaning of the length field depends on the message type: 74 | 75 | * Data - provides the length of bytes following the header 76 | * Window update - provides a delta update to the window size 77 | * Ping - Contains an opaque value, echoed back 78 | * Go Away - Contains an error code 79 | 80 | # Message Flow 81 | 82 | There is no explicit connection setup, as Yamux relies on an underlying 83 | transport to be provided. However, there is a distinction between client 84 | and server side of the connection. 85 | 86 | ## Opening a stream 87 | 88 | To open a stream, an initial data or window update frame is sent 89 | with a new StreamID. The SYN flag should be set to signal a new stream. 90 | 91 | The receiver must then reply with either a data or window update frame 92 | with the StreamID along with the ACK flag to accept the stream or with 93 | the RST flag to reject the stream. 94 | 95 | Because we are relying on the reliable stream underneath, a connection 96 | can begin sending data once the SYN flag is sent. The corresponding 97 | ACK does not need to be received. This is particularly well suited 98 | for an RPC system where a client wants to open a stream and immediately 99 | fire a request without waiting for the RTT of the ACK. 100 | 101 | This does introduce the possibility of a connection being rejected 102 | after data has been sent already. This is a slight semantic difference 103 | from TCP, where the conection cannot be refused after it is opened. 104 | Clients should be prepared to handle this by checking for an error 105 | that indicates a RST was received. 106 | 107 | ## Closing a stream 108 | 109 | To close a stream, either side sends a data or window update frame 110 | along with the FIN flag. This does a half-close indicating the sender 111 | will send no further data. 112 | 113 | Once both sides have closed the connection, the stream is closed. 114 | 115 | Alternatively, if an error occurs, the RST flag can be used to 116 | hard close a stream immediately. 117 | 118 | ## Flow Control 119 | 120 | When Yamux is initially starts each stream with a 256KB window size. 121 | There is no window size for the session. 122 | 123 | To prevent the streams from stalling, window update frames should be 124 | sent regularly. Yamux can be configured to provide a larger limit for 125 | windows sizes. Both sides assume the initial 256KB window, but can 126 | immediately send a window update as part of the SYN/ACK indicating a 127 | larger window. 128 | 129 | Both sides should track the number of bytes sent in Data frames 130 | only, as only they are tracked as part of the window size. 131 | 132 | ## Session termination 133 | 134 | When a session is being terminated, the Go Away message should 135 | be sent. The Length should be set to one of the following to 136 | provide an error code: 137 | 138 | * 0x0 Normal termination 139 | * 0x1 Protocol error 140 | * 0x2 Internal error 141 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/yamux/util.go: -------------------------------------------------------------------------------- 1 | package yamux 2 | 3 | // asyncSendErr is used to try an async send of an error 4 | func asyncSendErr(ch chan error, err error) { 5 | if ch == nil { 6 | return 7 | } 8 | select { 9 | case ch <- err: 10 | default: 11 | } 12 | } 13 | 14 | // asyncNotify is used to signal a waiting goroutine 15 | func asyncNotify(ch chan struct{}) { 16 | select { 17 | case ch <- struct{}{}: 18 | default: 19 | } 20 | } 21 | 22 | // min computes the minimum of two values 23 | func min(a, b uint32) uint32 { 24 | if a < b { 25 | return a 26 | } 27 | return b 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Keith Rarick 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall 13 | be included in all copies or substantial portions of the 14 | Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 17 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 19 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 20 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/README.md: -------------------------------------------------------------------------------- 1 | # pty 2 | 3 | Pty is a Go package for using unix pseudo-terminals. 4 | 5 | ## Install 6 | 7 | go get github.com/kr/pty 8 | 9 | ## Example 10 | 11 | ```go 12 | package main 13 | 14 | import ( 15 | "github.com/kr/pty" 16 | "io" 17 | "os" 18 | "os/exec" 19 | ) 20 | 21 | func main() { 22 | c := exec.Command("grep", "--color=auto", "bar") 23 | f, err := pty.Start(c) 24 | if err != nil { 25 | panic(err) 26 | } 27 | 28 | go func() { 29 | f.Write([]byte("foo\n")) 30 | f.Write([]byte("bar\n")) 31 | f.Write([]byte("baz\n")) 32 | f.Write([]byte{4}) // EOT 33 | }() 34 | io.Copy(os.Stdout, f) 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/doc.go: -------------------------------------------------------------------------------- 1 | // Package pty provides functions for working with Unix terminals. 2 | package pty 3 | 4 | import ( 5 | "errors" 6 | "os" 7 | ) 8 | 9 | // ErrUnsupported is returned if a function is not 10 | // available on the current platform. 11 | var ErrUnsupported = errors.New("unsupported") 12 | 13 | // Opens a pty and its corresponding tty. 14 | func Open() (pty, tty *os.File, err error) { 15 | return open() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ioctl.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import "syscall" 6 | 7 | func ioctl(fd, cmd, ptr uintptr) error { 8 | _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) 9 | if e != 0 { 10 | return e 11 | } 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ioctl_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd netbsd openbsd 2 | 3 | package pty 4 | 5 | // from 6 | const ( 7 | _IOC_VOID uintptr = 0x20000000 8 | _IOC_OUT uintptr = 0x40000000 9 | _IOC_IN uintptr = 0x80000000 10 | _IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN 11 | _IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN 12 | 13 | _IOC_PARAM_SHIFT = 13 14 | _IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1 15 | ) 16 | 17 | func _IOC_PARM_LEN(ioctl uintptr) uintptr { 18 | return (ioctl >> 16) & _IOC_PARAM_MASK 19 | } 20 | 21 | func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr { 22 | return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num 23 | } 24 | 25 | func _IO(group byte, ioctl_num uintptr) uintptr { 26 | return _IOC(_IOC_VOID, group, ioctl_num, 0) 27 | } 28 | 29 | func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 30 | return _IOC(_IOC_OUT, group, ioctl_num, param_len) 31 | } 32 | 33 | func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 34 | return _IOC(_IOC_IN, group, ioctl_num, param_len) 35 | } 36 | 37 | func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 38 | return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/mktypes.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | GOOSARCH="${GOOS}_${GOARCH}" 4 | case "$GOOSARCH" in 5 | _* | *_ | _) 6 | echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 7 | exit 1 8 | ;; 9 | esac 10 | 11 | GODEFS="go tool cgo -godefs" 12 | 13 | $GODEFS types.go |gofmt > ztypes_$GOARCH.go 14 | 15 | case $GOOS in 16 | freebsd|dragonfly) 17 | $GODEFS types_$GOOS.go |gofmt > ztypes_$GOOSARCH.go 18 | ;; 19 | esac 20 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_darwin.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func open() (pty, tty *os.File, err error) { 11 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 12 | if err != nil { 13 | return nil, nil, err 14 | } 15 | 16 | sname, err := ptsname(p) 17 | if err != nil { 18 | return nil, nil, err 19 | } 20 | 21 | err = grantpt(p) 22 | if err != nil { 23 | return nil, nil, err 24 | } 25 | 26 | err = unlockpt(p) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | t, err := os.OpenFile(sname, os.O_RDWR, 0) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | return p, t, nil 36 | } 37 | 38 | func ptsname(f *os.File) (string, error) { 39 | n := make([]byte, _IOC_PARM_LEN(syscall.TIOCPTYGNAME)) 40 | 41 | err := ioctl(f.Fd(), syscall.TIOCPTYGNAME, uintptr(unsafe.Pointer(&n[0]))) 42 | if err != nil { 43 | return "", err 44 | } 45 | 46 | for i, c := range n { 47 | if c == 0 { 48 | return string(n[:i]), nil 49 | } 50 | } 51 | return "", errors.New("TIOCPTYGNAME string not NUL-terminated") 52 | } 53 | 54 | func grantpt(f *os.File) error { 55 | return ioctl(f.Fd(), syscall.TIOCPTYGRANT, 0) 56 | } 57 | 58 | func unlockpt(f *os.File) error { 59 | return ioctl(f.Fd(), syscall.TIOCPTYUNLK, 0) 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_dragonfly.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "strings" 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | // same code as pty_darwin.go 12 | func open() (pty, tty *os.File, err error) { 13 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 14 | if err != nil { 15 | return nil, nil, err 16 | } 17 | 18 | sname, err := ptsname(p) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | err = grantpt(p) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | err = unlockpt(p) 29 | if err != nil { 30 | return nil, nil, err 31 | } 32 | 33 | t, err := os.OpenFile(sname, os.O_RDWR, 0) 34 | if err != nil { 35 | return nil, nil, err 36 | } 37 | return p, t, nil 38 | } 39 | 40 | func grantpt(f *os.File) error { 41 | _, err := isptmaster(f.Fd()) 42 | return err 43 | } 44 | 45 | func unlockpt(f *os.File) error { 46 | _, err := isptmaster(f.Fd()) 47 | return err 48 | } 49 | 50 | func isptmaster(fd uintptr) (bool, error) { 51 | err := ioctl(fd, syscall.TIOCISPTMASTER, 0) 52 | return err == nil, err 53 | } 54 | 55 | var ( 56 | emptyFiodgnameArg fiodgnameArg 57 | ioctl_FIODNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) 58 | ) 59 | 60 | func ptsname(f *os.File) (string, error) { 61 | name := make([]byte, _C_SPECNAMELEN) 62 | fa := fiodgnameArg{Name: (*byte)(unsafe.Pointer(&name[0])), Len: _C_SPECNAMELEN, Pad_cgo_0: [4]byte{0, 0, 0, 0}} 63 | 64 | err := ioctl(f.Fd(), ioctl_FIODNAME, uintptr(unsafe.Pointer(&fa))) 65 | if err != nil { 66 | return "", err 67 | } 68 | 69 | for i, c := range name { 70 | if c == 0 { 71 | s := "/dev/" + string(name[:i]) 72 | return strings.Replace(s, "ptm", "pts", -1), nil 73 | } 74 | } 75 | return "", errors.New("TIOCPTYGNAME string not NUL-terminated") 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_freebsd.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func posix_openpt(oflag int) (fd int, err error) { 11 | r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) 12 | fd = int(r0) 13 | if e1 != 0 { 14 | err = e1 15 | } 16 | return 17 | } 18 | 19 | func open() (pty, tty *os.File, err error) { 20 | fd, err := posix_openpt(syscall.O_RDWR | syscall.O_CLOEXEC) 21 | if err != nil { 22 | return nil, nil, err 23 | } 24 | 25 | p := os.NewFile(uintptr(fd), "/dev/pts") 26 | sname, err := ptsname(p) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | t, err := os.OpenFile("/dev/"+sname, os.O_RDWR, 0) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | return p, t, nil 36 | } 37 | 38 | func isptmaster(fd uintptr) (bool, error) { 39 | err := ioctl(fd, syscall.TIOCPTMASTER, 0) 40 | return err == nil, err 41 | } 42 | 43 | var ( 44 | emptyFiodgnameArg fiodgnameArg 45 | ioctl_FIODGNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) 46 | ) 47 | 48 | func ptsname(f *os.File) (string, error) { 49 | master, err := isptmaster(f.Fd()) 50 | if err != nil { 51 | return "", err 52 | } 53 | if !master { 54 | return "", syscall.EINVAL 55 | } 56 | 57 | const n = _C_SPECNAMELEN + 1 58 | var ( 59 | buf = make([]byte, n) 60 | arg = fiodgnameArg{Len: n, Buf: (*byte)(unsafe.Pointer(&buf[0]))} 61 | ) 62 | err = ioctl(f.Fd(), ioctl_FIODGNAME, uintptr(unsafe.Pointer(&arg))) 63 | if err != nil { 64 | return "", err 65 | } 66 | 67 | for i, c := range buf { 68 | if c == 0 { 69 | return string(buf[:i]), nil 70 | } 71 | } 72 | return "", errors.New("FIODGNAME string not NUL-terminated") 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_linux.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "strconv" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func open() (pty, tty *os.File, err error) { 11 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 12 | if err != nil { 13 | return nil, nil, err 14 | } 15 | 16 | sname, err := ptsname(p) 17 | if err != nil { 18 | return nil, nil, err 19 | } 20 | 21 | err = unlockpt(p) 22 | if err != nil { 23 | return nil, nil, err 24 | } 25 | 26 | t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | return p, t, nil 31 | } 32 | 33 | func ptsname(f *os.File) (string, error) { 34 | var n _C_uint 35 | err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) 36 | if err != nil { 37 | return "", err 38 | } 39 | return "/dev/pts/" + strconv.Itoa(int(n)), nil 40 | } 41 | 42 | func unlockpt(f *os.File) error { 43 | var u _C_int 44 | // use TIOCSPTLCK with a zero valued arg to clear the slave pty lock 45 | return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!darwin,!freebsd,!dragonfly 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func open() (pty, tty *os.File, err error) { 10 | return nil, nil, ErrUnsupported 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/run.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | "os/exec" 8 | "syscall" 9 | ) 10 | 11 | // Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, 12 | // and c.Stderr, calls c.Start, and returns the File of the tty's 13 | // corresponding pty. 14 | func Start(c *exec.Cmd) (pty *os.File, err error) { 15 | pty, tty, err := Open() 16 | if err != nil { 17 | return nil, err 18 | } 19 | defer tty.Close() 20 | c.Stdout = tty 21 | c.Stdin = tty 22 | c.Stderr = tty 23 | if c.SysProcAttr == nil { 24 | c.SysProcAttr = &syscall.SysProcAttr{} 25 | } 26 | c.SysProcAttr.Setctty = true 27 | c.SysProcAttr.Setsid = true 28 | err = c.Start() 29 | if err != nil { 30 | pty.Close() 31 | return nil, err 32 | } 33 | return pty, err 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | import "C" 6 | 7 | type ( 8 | _C_int C.int 9 | _C_uint C.uint 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types_dragonfly.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | /* 6 | #define _KERNEL 7 | #include 8 | #include 9 | #include 10 | */ 11 | import "C" 12 | 13 | const ( 14 | _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ 15 | ) 16 | 17 | type fiodgnameArg C.struct_fiodname_args 18 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types_freebsd.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | /* 6 | #include 7 | #include 8 | */ 9 | import "C" 10 | 11 | const ( 12 | _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ 13 | ) 14 | 15 | type fiodgnameArg C.struct_fiodgname_arg 16 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/util.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | // Getsize returns the number of rows (lines) and cols (positions 12 | // in each line) in terminal t. 13 | func Getsize(t *os.File) (rows, cols int, err error) { 14 | var ws winsize 15 | err = windowrect(&ws, t.Fd()) 16 | return int(ws.ws_row), int(ws.ws_col), err 17 | } 18 | 19 | type winsize struct { 20 | ws_row uint16 21 | ws_col uint16 22 | ws_xpixel uint16 23 | ws_ypixel uint16 24 | } 25 | 26 | func windowrect(ws *winsize, fd uintptr) error { 27 | _, _, errno := syscall.Syscall( 28 | syscall.SYS_IOCTL, 29 | fd, 30 | syscall.TIOCGWINSZ, 31 | uintptr(unsafe.Pointer(ws)), 32 | ) 33 | if errno != 0 { 34 | return syscall.Errno(errno) 35 | } 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_arm64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | // +build arm64 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_dragonfly.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Name *byte 12 | Len uint32 13 | Pad_cgo_0 [4]byte 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Buf *byte 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Pad_cgo_0 [4]byte 13 | Buf *byte 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Buf *byte 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_mipsx.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | // +build linux 5 | // +build mips mipsle mips64 mips64le 6 | 7 | package pty 8 | 9 | type ( 10 | _C_int int32 11 | _C_uint uint32 12 | ) 13 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_ppc64.go: -------------------------------------------------------------------------------- 1 | // +build ppc64 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_ppc64le.go: -------------------------------------------------------------------------------- 1 | // +build ppc64le 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_s390x.go: -------------------------------------------------------------------------------- 1 | // +build s390x 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | ) 9 | 10 | // NewColorable return new instance of Writer which handle escape sequence. 11 | func NewColorable(file *os.File) io.Writer { 12 | if file == nil { 13 | panic("nil passed instead of *os.File to NewColorable()") 14 | } 15 | 16 | return file 17 | } 18 | 19 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 20 | func NewColorableStdout() io.Writer { 21 | return os.Stdout 22 | } 23 | 24 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 25 | func NewColorableStderr() io.Writer { 26 | return os.Stderr 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable hold writer but remove escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | lastbuf bytes.Buffer 12 | } 13 | 14 | // NewNonColorable return new instance of Writer which remove escape sequence from Writer. 15 | func NewNonColorable(w io.Writer) io.Writer { 16 | return &NonColorable{out: w} 17 | } 18 | 19 | // Write write data on console 20 | func (w *NonColorable) Write(data []byte) (n int, err error) { 21 | er := bytes.NewReader(data) 22 | var bw [1]byte 23 | loop: 24 | for { 25 | c1, err := er.ReadByte() 26 | if err != nil { 27 | break loop 28 | } 29 | if c1 != 0x1b { 30 | bw[0] = c1 31 | w.out.Write(bw[:]) 32 | continue 33 | } 34 | c2, err := er.ReadByte() 35 | if err != nil { 36 | w.lastbuf.WriteByte(c1) 37 | break loop 38 | } 39 | if c2 != 0x5b { 40 | w.lastbuf.WriteByte(c1) 41 | w.lastbuf.WriteByte(c2) 42 | continue 43 | } 44 | 45 | var buf bytes.Buffer 46 | for { 47 | c, err := er.ReadByte() 48 | if err != nil { 49 | w.lastbuf.WriteByte(c1) 50 | w.lastbuf.WriteByte(c2) 51 | w.lastbuf.Write(buf.Bytes()) 52 | break loop 53 | } 54 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 55 | break 56 | } 57 | buf.Write([]byte(string(c))) 58 | } 59 | } 60 | return len(data) - w.lastbuf.Len(), nil 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 7 | // terminal. This is also always false on this environment. 8 | func IsCygwinTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "strings" 8 | "syscall" 9 | "unicode/utf16" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | fileNameInfo uintptr = 2 15 | fileTypePipe = 3 16 | ) 17 | 18 | var ( 19 | kernel32 = syscall.NewLazyDLL("kernel32.dll") 20 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 21 | procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx") 22 | procGetFileType = kernel32.NewProc("GetFileType") 23 | ) 24 | 25 | func init() { 26 | // Check if GetFileInformationByHandleEx is available. 27 | if procGetFileInformationByHandleEx.Find() != nil { 28 | procGetFileInformationByHandleEx = nil 29 | } 30 | } 31 | 32 | // IsTerminal return true if the file descriptor is terminal. 33 | func IsTerminal(fd uintptr) bool { 34 | var st uint32 35 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 36 | return r != 0 && e == 0 37 | } 38 | 39 | // Check pipe name is used for cygwin/msys2 pty. 40 | // Cygwin/MSYS2 PTY has a name like: 41 | // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master 42 | func isCygwinPipeName(name string) bool { 43 | token := strings.Split(name, "-") 44 | if len(token) < 5 { 45 | return false 46 | } 47 | 48 | if token[0] != `\msys` && token[0] != `\cygwin` { 49 | return false 50 | } 51 | 52 | if token[1] == "" { 53 | return false 54 | } 55 | 56 | if !strings.HasPrefix(token[2], "pty") { 57 | return false 58 | } 59 | 60 | if token[3] != `from` && token[3] != `to` { 61 | return false 62 | } 63 | 64 | if token[4] != "master" { 65 | return false 66 | } 67 | 68 | return true 69 | } 70 | 71 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 72 | // terminal. 73 | func IsCygwinTerminal(fd uintptr) bool { 74 | if procGetFileInformationByHandleEx == nil { 75 | return false 76 | } 77 | 78 | // Cygwin/msys's pty is a pipe. 79 | ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0) 80 | if ft != fileTypePipe || e != 0 { 81 | return false 82 | } 83 | 84 | var buf [2 + syscall.MAX_PATH]uint16 85 | r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 86 | 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)), 87 | uintptr(len(buf)*2), 0, 0) 88 | if r == 0 || e != 0 { 89 | return false 90 | } 91 | 92 | l := *(*uint32)(unsafe.Pointer(&buf)) 93 | return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2]))) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-homedir/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Mitchell Hashimoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-homedir/README.md: -------------------------------------------------------------------------------- 1 | # go-homedir 2 | 3 | This is a Go library for detecting the user's home directory without 4 | the use of cgo, so the library can be used in cross-compilation environments. 5 | 6 | Usage is incredibly simple, just call `homedir.Dir()` to get the home directory 7 | for a user, and `homedir.Expand()` to expand the `~` in a path to the home 8 | directory. 9 | 10 | **Why not just use `os/user`?** The built-in `os/user` package requires 11 | cgo on Darwin systems. This means that any Go code that uses that package 12 | cannot cross compile. But 99% of the time the use for `os/user` is just to 13 | retrieve the home directory, which we can do for the current user without 14 | cgo. This library does that, enabling cross-compilation. 15 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/go-homedir/homedir.go: -------------------------------------------------------------------------------- 1 | package homedir 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "os" 7 | "os/exec" 8 | "path/filepath" 9 | "runtime" 10 | "strconv" 11 | "strings" 12 | "sync" 13 | ) 14 | 15 | // DisableCache will disable caching of the home directory. Caching is enabled 16 | // by default. 17 | var DisableCache bool 18 | 19 | var homedirCache string 20 | var cacheLock sync.RWMutex 21 | 22 | // Dir returns the home directory for the executing user. 23 | // 24 | // This uses an OS-specific method for discovering the home directory. 25 | // An error is returned if a home directory cannot be detected. 26 | func Dir() (string, error) { 27 | if !DisableCache { 28 | cacheLock.RLock() 29 | cached := homedirCache 30 | cacheLock.RUnlock() 31 | if cached != "" { 32 | return cached, nil 33 | } 34 | } 35 | 36 | cacheLock.Lock() 37 | defer cacheLock.Unlock() 38 | 39 | var result string 40 | var err error 41 | if runtime.GOOS == "windows" { 42 | result, err = dirWindows() 43 | } else { 44 | // Unix-like system, so just assume Unix 45 | result, err = dirUnix() 46 | } 47 | 48 | if err != nil { 49 | return "", err 50 | } 51 | homedirCache = result 52 | return result, nil 53 | } 54 | 55 | // Expand expands the path to include the home directory if the path 56 | // is prefixed with `~`. If it isn't prefixed with `~`, the path is 57 | // returned as-is. 58 | func Expand(path string) (string, error) { 59 | if len(path) == 0 { 60 | return path, nil 61 | } 62 | 63 | if path[0] != '~' { 64 | return path, nil 65 | } 66 | 67 | if len(path) > 1 && path[1] != '/' && path[1] != '\\' { 68 | return "", errors.New("cannot expand user-specific home dir") 69 | } 70 | 71 | dir, err := Dir() 72 | if err != nil { 73 | return "", err 74 | } 75 | 76 | return filepath.Join(dir, path[1:]), nil 77 | } 78 | 79 | func dirUnix() (string, error) { 80 | // First prefer the HOME environmental variable 81 | if home := os.Getenv("HOME"); home != "" { 82 | return home, nil 83 | } 84 | 85 | // If that fails, try getent 86 | var stdout bytes.Buffer 87 | cmd := exec.Command("getent", "passwd", strconv.Itoa(os.Getuid())) 88 | cmd.Stdout = &stdout 89 | if err := cmd.Run(); err != nil { 90 | // If the error is ErrNotFound, we ignore it. Otherwise, return it. 91 | if err != exec.ErrNotFound { 92 | return "", err 93 | } 94 | } else { 95 | if passwd := strings.TrimSpace(stdout.String()); passwd != "" { 96 | // username:password:uid:gid:gecos:home:shell 97 | passwdParts := strings.SplitN(passwd, ":", 7) 98 | if len(passwdParts) > 5 { 99 | return passwdParts[5], nil 100 | } 101 | } 102 | } 103 | 104 | // If all else fails, try the shell 105 | stdout.Reset() 106 | cmd = exec.Command("sh", "-c", "cd && pwd") 107 | cmd.Stdout = &stdout 108 | if err := cmd.Run(); err != nil { 109 | return "", err 110 | } 111 | 112 | result := strings.TrimSpace(stdout.String()) 113 | if result == "" { 114 | return "", errors.New("blank output when reading home directory") 115 | } 116 | 117 | return result, nil 118 | } 119 | 120 | func dirWindows() (string, error) { 121 | // First prefer the HOME environmental variable 122 | if home := os.Getenv("HOME"); home != "" { 123 | return home, nil 124 | } 125 | 126 | drive := os.Getenv("HOMEDRIVE") 127 | path := os.Getenv("HOMEPATH") 128 | home := drive + path 129 | if drive == "" || path == "" { 130 | home = os.Getenv("USERPROFILE") 131 | } 132 | if home == "" { 133 | return "", errors.New("HOMEDRIVE, HOMEPATH, and USERPROFILE are blank") 134 | } 135 | 136 | return home, nil 137 | } 138 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux,!appengine netbsd openbsd 6 | 7 | // Package terminal provides support functions for dealing with terminals, as 8 | // commonly found on UNIX systems. 9 | // 10 | // Putting a terminal into raw mode is the most common requirement: 11 | // 12 | // oldState, err := terminal.MakeRaw(0) 13 | // if err != nil { 14 | // panic(err) 15 | // } 16 | // defer terminal.Restore(0, oldState) 17 | package terminal // import "golang.org/x/crypto/ssh/terminal" 18 | 19 | import ( 20 | "syscall" 21 | "unsafe" 22 | ) 23 | 24 | // State contains the state of a terminal. 25 | type State struct { 26 | termios syscall.Termios 27 | } 28 | 29 | // IsTerminal returns true if the given file descriptor is a terminal. 30 | func IsTerminal(fd int) bool { 31 | var termios syscall.Termios 32 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 33 | return err == 0 34 | } 35 | 36 | // MakeRaw put the terminal connected to the given file descriptor into raw 37 | // mode and returns the previous state of the terminal so that it can be 38 | // restored. 39 | func MakeRaw(fd int) (*State, error) { 40 | var oldState State 41 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 { 42 | return nil, err 43 | } 44 | 45 | newState := oldState.termios 46 | // This attempts to replicate the behaviour documented for cfmakeraw in 47 | // the termios(3) manpage. 48 | newState.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON 49 | newState.Oflag &^= syscall.OPOST 50 | newState.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN 51 | newState.Cflag &^= syscall.CSIZE | syscall.PARENB 52 | newState.Cflag |= syscall.CS8 53 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { 54 | return nil, err 55 | } 56 | 57 | return &oldState, nil 58 | } 59 | 60 | // GetState returns the current state of a terminal which may be useful to 61 | // restore the terminal after a signal. 62 | func GetState(fd int) (*State, error) { 63 | var oldState State 64 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 { 65 | return nil, err 66 | } 67 | 68 | return &oldState, nil 69 | } 70 | 71 | // Restore restores the terminal connected to the given file descriptor to a 72 | // previous state. 73 | func Restore(fd int, state *State) error { 74 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0); err != 0 { 75 | return err 76 | } 77 | return nil 78 | } 79 | 80 | // GetSize returns the dimensions of the given terminal. 81 | func GetSize(fd int) (width, height int, err error) { 82 | var dimensions [4]uint16 83 | 84 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0); err != 0 { 85 | return -1, -1, err 86 | } 87 | return int(dimensions[1]), int(dimensions[0]), nil 88 | } 89 | 90 | // passwordReader is an io.Reader that reads from a specific file descriptor. 91 | type passwordReader int 92 | 93 | func (r passwordReader) Read(buf []byte) (int, error) { 94 | return syscall.Read(int(r), buf) 95 | } 96 | 97 | // ReadPassword reads a line of input from a terminal without local echo. This 98 | // is commonly used for inputting passwords and other sensitive data. The slice 99 | // returned does not include the \n. 100 | func ReadPassword(fd int) ([]byte, error) { 101 | var oldState syscall.Termios 102 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); err != 0 { 103 | return nil, err 104 | } 105 | 106 | newState := oldState 107 | newState.Lflag &^= syscall.ECHO 108 | newState.Lflag |= syscall.ICANON | syscall.ISIG 109 | newState.Iflag |= syscall.ICRNL 110 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { 111 | return nil, err 112 | } 113 | 114 | defer func() { 115 | syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0) 116 | }() 117 | 118 | return readPasswordLine(passwordReader(fd)) 119 | } 120 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package terminal provides support functions for dealing with terminals, as 6 | // commonly found on UNIX systems. 7 | // 8 | // Putting a terminal into raw mode is the most common requirement: 9 | // 10 | // oldState, err := terminal.MakeRaw(0) 11 | // if err != nil { 12 | // panic(err) 13 | // } 14 | // defer terminal.Restore(0, oldState) 15 | package terminal 16 | 17 | import ( 18 | "fmt" 19 | "runtime" 20 | ) 21 | 22 | type State struct{} 23 | 24 | // IsTerminal returns true if the given file descriptor is a terminal. 25 | func IsTerminal(fd int) bool { 26 | return false 27 | } 28 | 29 | // MakeRaw put the terminal connected to the given file descriptor into raw 30 | // mode and returns the previous state of the terminal so that it can be 31 | // restored. 32 | func MakeRaw(fd int) (*State, error) { 33 | return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 34 | } 35 | 36 | // GetState returns the current state of a terminal which may be useful to 37 | // restore the terminal after a signal. 38 | func GetState(fd int) (*State, error) { 39 | return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 40 | } 41 | 42 | // Restore restores the terminal connected to the given file descriptor to a 43 | // previous state. 44 | func Restore(fd int, state *State) error { 45 | return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 46 | } 47 | 48 | // GetSize returns the dimensions of the given terminal. 49 | func GetSize(fd int) (width, height int, err error) { 50 | return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 51 | } 52 | 53 | // ReadPassword reads a line of input from a terminal without local echo. This 54 | // is commonly used for inputting passwords and other sensitive data. The slice 55 | // returned does not include the \n. 56 | func ReadPassword(fd int) ([]byte, error) { 57 | return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build solaris 6 | 7 | package terminal // import "golang.org/x/crypto/ssh/terminal" 8 | 9 | import ( 10 | "golang.org/x/sys/unix" 11 | "io" 12 | "syscall" 13 | ) 14 | 15 | // State contains the state of a terminal. 16 | type State struct { 17 | termios syscall.Termios 18 | } 19 | 20 | // IsTerminal returns true if the given file descriptor is a terminal. 21 | func IsTerminal(fd int) bool { 22 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 23 | var termio unix.Termio 24 | err := unix.IoctlSetTermio(fd, unix.TCGETA, &termio) 25 | return err == nil 26 | } 27 | 28 | // ReadPassword reads a line of input from a terminal without local echo. This 29 | // is commonly used for inputting passwords and other sensitive data. The slice 30 | // returned does not include the \n. 31 | func ReadPassword(fd int) ([]byte, error) { 32 | // see also: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libast/common/uwin/getpass.c 33 | val, err := unix.IoctlGetTermios(fd, unix.TCGETS) 34 | if err != nil { 35 | return nil, err 36 | } 37 | oldState := *val 38 | 39 | newState := oldState 40 | newState.Lflag &^= syscall.ECHO 41 | newState.Lflag |= syscall.ICANON | syscall.ISIG 42 | newState.Iflag |= syscall.ICRNL 43 | err = unix.IoctlSetTermios(fd, unix.TCSETS, &newState) 44 | if err != nil { 45 | return nil, err 46 | } 47 | 48 | defer unix.IoctlSetTermios(fd, unix.TCSETS, &oldState) 49 | 50 | var buf [16]byte 51 | var ret []byte 52 | for { 53 | n, err := syscall.Read(fd, buf[:]) 54 | if err != nil { 55 | return nil, err 56 | } 57 | if n == 0 { 58 | if len(ret) == 0 { 59 | return nil, io.EOF 60 | } 61 | break 62 | } 63 | if buf[n-1] == '\n' { 64 | n-- 65 | } 66 | ret = append(ret, buf[:n]...) 67 | if n < len(buf) { 68 | break 69 | } 70 | } 71 | 72 | return ret, nil 73 | } 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package terminal provides support functions for dealing with terminals, as 8 | // commonly found on UNIX systems. 9 | // 10 | // Putting a terminal into raw mode is the most common requirement: 11 | // 12 | // oldState, err := terminal.MakeRaw(0) 13 | // if err != nil { 14 | // panic(err) 15 | // } 16 | // defer terminal.Restore(0, oldState) 17 | package terminal 18 | 19 | import ( 20 | "syscall" 21 | "unsafe" 22 | ) 23 | 24 | const ( 25 | enableLineInput = 2 26 | enableEchoInput = 4 27 | enableProcessedInput = 1 28 | enableWindowInput = 8 29 | enableMouseInput = 16 30 | enableInsertMode = 32 31 | enableQuickEditMode = 64 32 | enableExtendedFlags = 128 33 | enableAutoPosition = 256 34 | enableProcessedOutput = 1 35 | enableWrapAtEolOutput = 2 36 | ) 37 | 38 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 39 | 40 | var ( 41 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 42 | procSetConsoleMode = kernel32.NewProc("SetConsoleMode") 43 | procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") 44 | ) 45 | 46 | type ( 47 | short int16 48 | word uint16 49 | 50 | coord struct { 51 | x short 52 | y short 53 | } 54 | smallRect struct { 55 | left short 56 | top short 57 | right short 58 | bottom short 59 | } 60 | consoleScreenBufferInfo struct { 61 | size coord 62 | cursorPosition coord 63 | attributes word 64 | window smallRect 65 | maximumWindowSize coord 66 | } 67 | ) 68 | 69 | type State struct { 70 | mode uint32 71 | } 72 | 73 | // IsTerminal returns true if the given file descriptor is a terminal. 74 | func IsTerminal(fd int) bool { 75 | var st uint32 76 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 77 | return r != 0 && e == 0 78 | } 79 | 80 | // MakeRaw put the terminal connected to the given file descriptor into raw 81 | // mode and returns the previous state of the terminal so that it can be 82 | // restored. 83 | func MakeRaw(fd int) (*State, error) { 84 | var st uint32 85 | _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 86 | if e != 0 { 87 | return nil, error(e) 88 | } 89 | raw := st &^ (enableEchoInput | enableProcessedInput | enableLineInput | enableProcessedOutput) 90 | _, _, e = syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(raw), 0) 91 | if e != 0 { 92 | return nil, error(e) 93 | } 94 | return &State{st}, nil 95 | } 96 | 97 | // GetState returns the current state of a terminal which may be useful to 98 | // restore the terminal after a signal. 99 | func GetState(fd int) (*State, error) { 100 | var st uint32 101 | _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 102 | if e != 0 { 103 | return nil, error(e) 104 | } 105 | return &State{st}, nil 106 | } 107 | 108 | // Restore restores the terminal connected to the given file descriptor to a 109 | // previous state. 110 | func Restore(fd int, state *State) error { 111 | _, _, err := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(state.mode), 0) 112 | return err 113 | } 114 | 115 | // GetSize returns the dimensions of the given terminal. 116 | func GetSize(fd int) (width, height int, err error) { 117 | var info consoleScreenBufferInfo 118 | _, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&info)), 0) 119 | if e != 0 { 120 | return 0, 0, error(e) 121 | } 122 | return int(info.size.x), int(info.size.y), nil 123 | } 124 | 125 | // passwordReader is an io.Reader that reads from a specific Windows HANDLE. 126 | type passwordReader int 127 | 128 | func (r passwordReader) Read(buf []byte) (int, error) { 129 | return syscall.Read(syscall.Handle(r), buf) 130 | } 131 | 132 | // ReadPassword reads a line of input from a terminal without local echo. This 133 | // is commonly used for inputting passwords and other sensitive data. The slice 134 | // returned does not include the \n. 135 | func ReadPassword(fd int) ([]byte, error) { 136 | var st uint32 137 | _, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 138 | if e != 0 { 139 | return nil, error(e) 140 | } 141 | old := st 142 | 143 | st &^= (enableEchoInput) 144 | st |= (enableProcessedInput | enableLineInput | enableProcessedOutput) 145 | _, _, e = syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(st), 0) 146 | if e != 0 { 147 | return nil, error(e) 148 | } 149 | 150 | defer func() { 151 | syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(old), 0) 152 | }() 153 | 154 | return readPasswordLine(passwordReader(fd)) 155 | } 156 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // readInt returns the size-bytes unsigned integer in native byte order at offset off. 12 | func readInt(b []byte, off, size uintptr) (u uint64, ok bool) { 13 | if len(b) < int(off+size) { 14 | return 0, false 15 | } 16 | if isBigEndian { 17 | return readIntBE(b[off:], size), true 18 | } 19 | return readIntLE(b[off:], size), true 20 | } 21 | 22 | func readIntBE(b []byte, size uintptr) uint64 { 23 | switch size { 24 | case 1: 25 | return uint64(b[0]) 26 | case 2: 27 | _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 28 | return uint64(b[1]) | uint64(b[0])<<8 29 | case 4: 30 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 31 | return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24 32 | case 8: 33 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 34 | return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | 35 | uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 36 | default: 37 | panic("syscall: readInt with unsupported size") 38 | } 39 | } 40 | 41 | func readIntLE(b []byte, size uintptr) uint64 { 42 | switch size { 43 | case 1: 44 | return uint64(b[0]) 45 | case 2: 46 | _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 47 | return uint64(b[0]) | uint64(b[1])<<8 48 | case 4: 49 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 50 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 51 | case 8: 52 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 53 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | 54 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 55 | default: 56 | panic("syscall: readInt with unsupported size") 57 | } 58 | } 59 | 60 | // ParseDirent parses up to max directory entries in buf, 61 | // appending the names to names. It returns the number of 62 | // bytes consumed from buf, the number of entries added 63 | // to names, and the new names slice. 64 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 65 | origlen := len(buf) 66 | count = 0 67 | for max != 0 && len(buf) > 0 { 68 | reclen, ok := direntReclen(buf) 69 | if !ok || reclen > uint64(len(buf)) { 70 | return origlen, count, names 71 | } 72 | rec := buf[:reclen] 73 | buf = buf[reclen:] 74 | ino, ok := direntIno(rec) 75 | if !ok { 76 | break 77 | } 78 | if ino == 0 { // File absent in directory. 79 | continue 80 | } 81 | const namoff = uint64(unsafe.Offsetof(Dirent{}.Name)) 82 | namlen, ok := direntNamlen(rec) 83 | if !ok || namoff+namlen > uint64(len(rec)) { 84 | break 85 | } 86 | name := rec[namoff : namoff+namlen] 87 | for i, c := range name { 88 | if c == 0 { 89 | name = name[:i] 90 | break 91 | } 92 | } 93 | // Check for useless names before allocating a string. 94 | if string(name) == "." || string(name) == ".." { 95 | continue 96 | } 97 | max-- 98 | count++ 99 | names = append(names, string(name)) 100 | } 101 | return origlen - len(buf), count, names 102 | } 103 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 31 | # ignore deprecated syscalls that are no longer implemented 32 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 33 | return; 34 | } 35 | $name =~ y/a-z/A-Z/; 36 | $num = $num + $offset; 37 | print " SYS_$name = $num;\n"; 38 | } 39 | 40 | my $prev; 41 | open(GCC, "gcc -E -dD @ARGV |") || die "can't run gcc"; 42 | while(){ 43 | if(/^#define __NR_Linux\s+([0-9]+)/){ 44 | # mips/mips64: extract offset 45 | $offset = $1; 46 | } 47 | elsif(/^#define __NR(\w*)_SYSCALL_BASE\s+([0-9]+)/){ 48 | # arm: extract offset 49 | $offset = $1; 50 | } 51 | elsif(/^#define __NR_syscalls\s+/) { 52 | # ignore redefinitions of __NR_syscalls 53 | } 54 | elsif(/^#define __NR_(\w*)Linux_syscalls\s+/) { 55 | # mips/mips64: ignore definitions about the number of syscalls 56 | } 57 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 58 | $prev = $2; 59 | fmt($1, $2); 60 | } 61 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 62 | $prev = $2; 63 | fmt($1, $2); 64 | } 65 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 66 | fmt($1, $prev+$2) 67 | } 68 | elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){ 69 | fmt($1, $2); 70 | } 71 | elsif(/^#define __NR_(\w+)\s+\(__NR_SYSCALL_BASE \+ ([0-9]+)/){ 72 | fmt($1, $2); 73 | } 74 | } 75 | 76 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print < uint64(len(b)) { 66 | return nil, nil, EINVAL 67 | } 68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 69 | } 70 | 71 | // UnixRights encodes a set of open file descriptors into a socket 72 | // control message for sending to another process. 73 | func UnixRights(fds ...int) []byte { 74 | datalen := len(fds) * 4 75 | b := make([]byte, CmsgSpace(datalen)) 76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 77 | h.Level = SOL_SOCKET 78 | h.Type = SCM_RIGHTS 79 | h.SetLen(CmsgLen(datalen)) 80 | data := cmsgData(h) 81 | for _, fd := range fds { 82 | *(*int32)(data) = int32(fd) 83 | data = unsafe.Pointer(uintptr(data) + 4) 84 | } 85 | return b 86 | } 87 | 88 | // ParseUnixRights decodes a socket control message that contains an 89 | // integer array of open file descriptors from another process. 90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 91 | if m.Header.Level != SOL_SOCKET { 92 | return nil, EINVAL 93 | } 94 | if m.Header.Type != SCM_RIGHTS { 95 | return nil, EINVAL 96 | } 97 | fds := make([]int, len(m.Data)>>2) 98 | for i, j := 0, 0; i < len(m.Data); i += 4 { 99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 100 | j++ 101 | } 102 | return fds, nil 103 | } 104 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | // ByteSliceFromString returns a NUL-terminated slice of bytes 25 | // containing the text of s. If s contains a NUL byte at any 26 | // location, it returns (nil, EINVAL). 27 | func ByteSliceFromString(s string) ([]byte, error) { 28 | for i := 0; i < len(s); i++ { 29 | if s[i] == 0 { 30 | return nil, EINVAL 31 | } 32 | } 33 | a := make([]byte, len(s)+1) 34 | copy(a, s) 35 | return a, nil 36 | } 37 | 38 | // BytePtrFromString returns a pointer to a NUL-terminated array of 39 | // bytes containing the text of s. If s contains a NUL byte at any 40 | // location, it returns (nil, EINVAL). 41 | func BytePtrFromString(s string) (*byte, error) { 42 | a, err := ByteSliceFromString(s) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return &a[0], nil 47 | } 48 | 49 | // Single-word zero for use when we need a valid pointer to 0 bytes. 50 | // See mkunix.pl. 51 | var _zero uintptr 52 | 53 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 54 | return int64(ts.Sec), int64(ts.Nsec) 55 | } 56 | 57 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 58 | return int64(tv.Sec), int64(tv.Usec) * 1000 59 | } 60 | 61 | func (ts *Timespec) Nano() int64 { 62 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 63 | } 64 | 65 | func (tv *Timeval) Nano() int64 { 66 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 67 | } 68 | 69 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 70 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/vendor.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "", 3 | "ignore": "test", 4 | "package": [ 5 | { 6 | "checksumSHA1": "16fWSep+3jUx8wADdbiTxSHjW14=", 7 | "path": "github.com/fatih/color", 8 | "revision": "9131ab34cf20d2f6d83fdc67168a5430d1c7dc23", 9 | "revisionTime": "2017-03-07T19:28:53Z" 10 | }, 11 | { 12 | "checksumSHA1": "ZhK6IO2XN81Y+3RAjTcVm1Ic7oU=", 13 | "path": "github.com/hashicorp/yamux", 14 | "revision": "d1caa6c97c9fc1cc9e83bbe34d0603f9ff0ce8bd", 15 | "revisionTime": "2016-07-20T23:31:40Z" 16 | }, 17 | { 18 | "checksumSHA1": "gGDSJToIqPYPEnKst2qLfuTeIZU=", 19 | "path": "github.com/kr/pty", 20 | "revision": "2c10821df3c3cf905230d078702dfbe9404c9b23", 21 | "revisionTime": "2017-03-07T14:53:09Z" 22 | }, 23 | { 24 | "checksumSHA1": "MrqRXuqj5suGXqcRUUwi+YA7PmE=", 25 | "origin": "github.com/fatih/color/vendor/github.com/mattn/go-colorable", 26 | "path": "github.com/mattn/go-colorable", 27 | "revision": "9131ab34cf20d2f6d83fdc67168a5430d1c7dc23", 28 | "revisionTime": "2017-03-07T19:28:53Z" 29 | }, 30 | { 31 | "checksumSHA1": "a/chskqRYBBHS8lDTpB3FQqgHb8=", 32 | "origin": "github.com/fatih/color/vendor/github.com/mattn/go-isatty", 33 | "path": "github.com/mattn/go-isatty", 34 | "revision": "9131ab34cf20d2f6d83fdc67168a5430d1c7dc23", 35 | "revisionTime": "2017-03-07T19:28:53Z" 36 | }, 37 | { 38 | "checksumSHA1": "V/quM7+em2ByJbWBLOsEwnY3j/Q=", 39 | "path": "github.com/mitchellh/go-homedir", 40 | "revision": "b8bc1bf767474819792c23f32d8286a45736f1c6", 41 | "revisionTime": "2016-12-03T19:45:07Z" 42 | }, 43 | { 44 | "checksumSHA1": "xiderUuvye8Kpn7yX3niiJg32bE=", 45 | "path": "golang.org/x/crypto/ssh/terminal", 46 | "revision": "453249f01cfeb54c3d549ddb75ff152ca243f9d8", 47 | "revisionTime": "2017-02-08T20:51:15Z" 48 | }, 49 | { 50 | "checksumSHA1": "mIZhS4hXW3qVQxsJ6tqztjJoJ8A=", 51 | "path": "golang.org/x/sys/unix", 52 | "revision": "9a7256cb28ed514b4e1e5f68959914c4c28a92e0", 53 | "revisionTime": "2017-03-29T05:31:33Z" 54 | } 55 | ], 56 | "rootPath": "github.com/spolu/warp" 57 | } 58 | --------------------------------------------------------------------------------