├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── _doc
├── account.png
├── encryption.png
├── splash1.png
└── splash2.png
├── address
└── address.go
├── gowallet.go
├── vendor
├── github.com
│ └── fatih
│ │ └── color
│ │ ├── .travis.yml
│ │ ├── LICENSE.md
│ │ ├── README.md
│ │ ├── color.go
│ │ ├── color_test.go
│ │ ├── doc.go
│ │ └── vendor
│ │ ├── github.com
│ │ └── 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
│ │ ├── golang.org
│ │ └── x
│ │ │ └── sys
│ │ │ └── unix
│ │ │ ├── LICENSE
│ │ │ ├── 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
│ │ │ ├── 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
│ │ │ ├── mkpost.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
│ │ └── manifest
└── golang.org
│ └── x
│ └── crypto
│ ├── pbkdf2
│ ├── pbkdf2.go
│ └── pbkdf2_test.go
│ ├── ripemd160
│ ├── ripemd160.go
│ ├── ripemd160_test.go
│ └── ripemd160block.go
│ ├── scrypt
│ ├── scrypt.go
│ └── scrypt_test.go
│ └── ssh
│ └── terminal
│ ├── terminal.go
│ ├── terminal_test.go
│ ├── util.go
│ ├── util_bsd.go
│ ├── util_linux.go
│ ├── util_plan9.go
│ ├── util_solaris.go
│ └── util_windows.go
├── view
├── account.go
├── grid.go
├── param.go
├── param_test.go
├── splash.go
└── tip.go
└── wallet
├── account.go
├── account_test.go
├── balance.go
├── balance_test.go
├── bip38.go
├── bip38_test.go
├── file.go
├── wallet.go
└── wallet_test.go
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: https://dogechain.info/address/DAYmexk7KcDFriqLuY5ntksns2giL4tSgq
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Binaries for programs and plugins
2 | *.exe
3 | *.dll
4 | *.so
5 | *.dylib
6 |
7 | # Test binary, build with `go test -c`
8 | *.test
9 |
10 | # Output of the go coverage tool, specifically when used with LiteIDE
11 | *.out
12 |
13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
14 | .glide/
15 |
16 | .idea/
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 UltraGIS
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # gowallet
2 |
3 | A console bitcoin wallet application written in golang.
4 |
5 | 
6 |
7 | **GoWallet uses a secret phrase and a salt phrase to generate your safe wallets.**
8 | Project location: https://github.com/aiportal/gowallet
9 |
10 | **GoWallet is a safe brain wallet for bitcoin.**
11 | Secret phrase at least 16 characters.
12 | Salt phrase at least 6 characters.
13 |
14 | Secret phrases should contain uppercase letters, lowercase letters, numbers, and special characters.
15 | Both secret phrases and salt phrases can use hexadecimal notation such as \xff or \xFF to represent a character.
16 |
17 | **It is recommended that use a more complex secret and put it on paper.**
18 | **It's also recommended that keep your salt in mind.**
19 |
20 | Donations are welcome at [1BTCzvzTn7QYBwFkRRkXGcVPodwrYoQyAq](https://blockchain.info/address/1BTCzvzTn7QYBwFkRRkXGcVPodwrYoQyAq)
21 |
22 | 
23 |
24 |
25 | #### Advanced usage
26 |
27 | You can export bulk wallets using the command line.
28 |
29 | -n or -number uint
30 |
31 | Number of wallets to generate.
32 | -v or -vanity string
33 |
34 | Find vanity wallet address matching. (prefix)
35 | -e or -export string
36 |
37 | Export wallets(child number, private key and address) in WIF format.
38 |
--------------------------------------------------------------------------------
/_doc/account.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aiportal/gowallet/827a5949c04f0d517213f6aec5248d1a3dcacaf5/_doc/account.png
--------------------------------------------------------------------------------
/_doc/encryption.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aiportal/gowallet/827a5949c04f0d517213f6aec5248d1a3dcacaf5/_doc/encryption.png
--------------------------------------------------------------------------------
/_doc/splash1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aiportal/gowallet/827a5949c04f0d517213f6aec5248d1a3dcacaf5/_doc/splash1.png
--------------------------------------------------------------------------------
/_doc/splash2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aiportal/gowallet/827a5949c04f0d517213f6aec5248d1a3dcacaf5/_doc/splash2.png
--------------------------------------------------------------------------------
/gowallet.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "os"
7 | "gowallet/view"
8 | "gowallet/wallet"
9 | )
10 |
11 | func main() {
12 | number, vanity, export := parseParams()
13 | if number > 0 {
14 | err := generateWallets(uint32(number), vanity, export)
15 | if err != nil {
16 | println(err.Error())
17 | return
18 | }
19 | } else {
20 | view.ShowSplashView(view.SplashStartView)
21 |
22 | var ws []*wallet.Wallet
23 | if !wallet.IsFileExists() {
24 | var err error
25 | ws, err = createWallets(1, 10)
26 | if err != nil {
27 | fmt.Println(err.Error())
28 | return
29 | }
30 | // save wallets
31 | wf := wallet.NewWalletFile(ws)
32 | wf.Save()
33 | } else {
34 | wf, err := wallet.LoadWalletFile()
35 | if err != nil {
36 | fmt.Println(err.Error())
37 | return
38 | }
39 | ws = wf.Wallets
40 | }
41 |
42 | showUI(ws)
43 | }
44 | }
45 |
46 | func showUI(ws []*wallet.Wallet) {
47 |
48 | accountView := view.NewAccountView(ws)
49 | accountView.Show()
50 |
51 | for accountView.Data != nil {
52 | cmd := accountView.Data.(string)
53 | if cmd == "quit" {
54 | break
55 | }
56 | tipView := view.NewTipView(cmd)
57 | if tipView != nil {
58 | tipView.Show()
59 | }
60 | accountView.Show()
61 | }
62 | }
63 |
64 | // create wallets by secret and salt
65 | func createWallets(start, count uint32) (ws []*wallet.Wallet, err error) {
66 | view.ShowSplashView(view.SplashCreateView)
67 |
68 | // create wallets
69 | wp, err := view.InputNewParameters(3)
70 | if err != nil {
71 | return
72 | }
73 | //wp := view.WalletParam{Secret:"https://github.com/aiportal", Salt:"gowallet"}
74 |
75 | wa, err := wallet.NewWalletAccount(wp.SecretBytes(), wp.SaltBytes())
76 | if err != nil {
77 | return
78 | }
79 | ws, err = wa.GenerateWallets(start, count)
80 | if err != nil {
81 | return
82 | }
83 | return
84 | }
85 |
86 | //Parse command line parameters
87 | func parseParams() (number uint, vanity, export string) {
88 |
89 | flag.UintVar(&number, "number", 0, "Number of wallets to generate.")
90 | flag.UintVar(&number, "n", 0, "Number of wallets to generate.")
91 |
92 | flag.StringVar(&vanity, "vanity", "", "Find vanity wallet address matching. (prefix)")
93 | flag.StringVar(&vanity, "v", "", "Find vanity wallet address matching. (prefix)")
94 |
95 | flag.StringVar(&export, "export", "", "Export wallets in WIF format.")
96 | flag.StringVar(&export, "e", "", "Export wallets in WIF format.")
97 |
98 | flag.Parse()
99 | return
100 | }
101 |
102 | func generateWallets(number uint32, vanity, export string) (err error) {
103 |
104 | view.ShowSplashView(view.SplashStartView)
105 | view.ShowSplashView(view.SplashCreateView)
106 | wp, err := view.InputNewParameters(3)
107 | if err != nil {
108 | return
109 | }
110 | wa, err := wallet.NewWalletAccount(wp.SecretBytes(), wp.SaltBytes())
111 | if err != nil {
112 | return
113 | }
114 | var ws []*wallet.Wallet
115 | if vanity == "" {
116 | ws, err = wa.GenerateWallets(0, uint32(number))
117 | if err != nil {
118 | return
119 | }
120 | } else {
121 | var patterns []string
122 | patterns, err = wa.NormalizeVanities([]string{vanity})
123 | if err != nil {
124 | return
125 | }
126 | ws, err = wa.FindVanities(patterns, func(i, c, n uint32) bool {
127 | fmt.Printf("progress: %d, %d, %d\n", i, c, n)
128 | return (n >= number)
129 | })
130 | }
131 | if export == "" {
132 | for _, w := range ws {
133 | fmt.Printf("wallet (%d): \n", w.No)
134 | fmt.Println(" " + w.Private)
135 | fmt.Println(" " + w.Address)
136 | }
137 | } else {
138 | var f *os.File
139 | f, err = os.Create(export)
140 | if err != nil {
141 | return
142 | }
143 | defer f.Close()
144 | for _, w := range ws {
145 | f.WriteString(fmt.Sprintf("wallet(%d): \r\n", w.No))
146 | f.WriteString(fmt.Sprintf(" private: %s\r\n", w.Private))
147 | f.WriteString(fmt.Sprintf(" address: %s\r\n", w.Address))
148 | }
149 | }
150 | return
151 | }
152 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - 1.8.x
4 | - tip
5 |
6 |
--------------------------------------------------------------------------------
/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 [](http://godoc.org/github.com/fatih/color) [](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 | 
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 | // Hi-intensity colors
19 | color.HiGreen("Bright green color.")
20 | color.HiBlack("Bright black means gray..")
21 | color.HiWhite("Shiny white color!")
22 |
23 | However there are times where custom color mixes are required. Below are some
24 | examples to create custom color objects and use the print functions of each
25 | separate color object.
26 |
27 | // Create a new color object
28 | c := color.New(color.FgCyan).Add(color.Underline)
29 | c.Println("Prints cyan text with an underline.")
30 |
31 | // Or just add them to New()
32 | d := color.New(color.FgCyan, color.Bold)
33 | d.Printf("This prints bold cyan %s\n", "too!.")
34 |
35 |
36 | // Mix up foreground and background colors, create new mixes!
37 | red := color.New(color.FgRed)
38 |
39 | boldRed := red.Add(color.Bold)
40 | boldRed.Println("This will print text in bold red.")
41 |
42 | whiteBackground := red.Add(color.BgWhite)
43 | whiteBackground.Println("Red text with White background.")
44 |
45 | // Use your own io.Writer output
46 | color.New(color.FgBlue).Fprintln(myWriter, "blue color!")
47 |
48 | blue := color.New(color.FgBlue)
49 | blue.Fprint(myWriter, "This will print text in blue.")
50 |
51 | You can create PrintXxx functions to simplify even more:
52 |
53 | // Create a custom print function for convenient
54 | red := color.New(color.FgRed).PrintfFunc()
55 | red("warning")
56 | red("error: %s", err)
57 |
58 | // Mix up multiple attributes
59 | notice := color.New(color.Bold, color.FgGreen).PrintlnFunc()
60 | notice("don't forget this...")
61 |
62 | You can also FprintXxx functions to pass your own io.Writer:
63 |
64 | blue := color.New(FgBlue).FprintfFunc()
65 | blue(myWriter, "important notice: %s", stars)
66 |
67 | // Mix up with multiple attributes
68 | success := color.New(color.Bold, color.FgGreen).FprintlnFunc()
69 | success(myWriter, don't forget this...")
70 |
71 |
72 | Or create SprintXxx functions to mix strings with other non-colorized strings:
73 |
74 | yellow := New(FgYellow).SprintFunc()
75 | red := New(FgRed).SprintFunc()
76 |
77 | fmt.Printf("this is a %s and this is %s.\n", yellow("warning"), red("error"))
78 |
79 | info := New(FgWhite, BgGreen).SprintFunc()
80 | fmt.Printf("this %s rocks!\n", info("package"))
81 |
82 | Windows support is enabled by default. All Print functions work as intended.
83 | However only for color.SprintXXX functions, user should use fmt.FprintXXX and
84 | set the output to color.Output:
85 |
86 | fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))
87 |
88 | info := New(FgWhite, BgGreen).SprintFunc()
89 | fmt.Fprintf(color.Output, "this %s rocks!\n", info("package"))
90 |
91 | Using with existing code is possible. Just use the Set() method to set the
92 | standard output to the given parameters. That way a rewrite of an existing
93 | code is not required.
94 |
95 | // Use handy standard colors.
96 | color.Set(color.FgYellow)
97 |
98 | fmt.Println("Existing text will be now in Yellow")
99 | fmt.Printf("This one %s\n", "too")
100 |
101 | color.Unset() // don't forget to unset
102 |
103 | // You can mix up parameters
104 | color.Set(color.FgMagenta, color.Bold)
105 | defer color.Unset() // use it in your function
106 |
107 | fmt.Println("All text will be now bold magenta.")
108 |
109 | There might be a case where you want to disable color output (for example to
110 | pipe the standard output of your app to somewhere else). `Color` has support to
111 | disable colors both globally and for single color definition. For example
112 | suppose you have a CLI app and a `--no-color` bool flag. You can easily disable
113 | the color output with:
114 |
115 | var flagNoColor = flag.Bool("no-color", false, "Disable color output")
116 |
117 | if *flagNoColor {
118 | color.NoColor = true // disables colorized output
119 | }
120 |
121 | It also has support for single color definitions (local). You can
122 | disable/enable color output on the fly:
123 |
124 | c := color.New(color.FgCyan)
125 | c.Println("Prints cyan text")
126 |
127 | c.DisableColor()
128 | c.Println("This is printed without any color")
129 |
130 | c.EnableColor()
131 | c.Println("This prints again cyan...")
132 | */
133 | package color
134 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/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/fatih/color/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/fatih/color/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/fatih/color/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/fatih/color/vendor/github.com/mattn/go-isatty/doc.go:
--------------------------------------------------------------------------------
1 | // Package isatty implements interface to isatty
2 | package isatty
3 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/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/fatih/color/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/fatih/color/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/fatih/color/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/fatih/color/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/fatih/color/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/fatih/color/vendor/golang.org/x/sys/unix/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/vendor/golang.org/x/sys/unix/race.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 darwin,race linux,race freebsd,race
6 |
7 | package unix
8 |
9 | import (
10 | "runtime"
11 | "unsafe"
12 | )
13 |
14 | const raceenabled = true
15 |
16 | func raceAcquire(addr unsafe.Pointer) {
17 | runtime.RaceAcquire(addr)
18 | }
19 |
20 | func raceReleaseMerge(addr unsafe.Pointer) {
21 | runtime.RaceReleaseMerge(addr)
22 | }
23 |
24 | func raceReadRange(addr unsafe.Pointer, len int) {
25 | runtime.RaceReadRange(addr, len)
26 | }
27 |
28 | func raceWriteRange(addr unsafe.Pointer, len int) {
29 | runtime.RaceWriteRange(addr, len)
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/vendor/golang.org/x/sys/unix/race0.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 darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly
6 |
7 | package unix
8 |
9 | import (
10 | "unsafe"
11 | )
12 |
13 | const raceenabled = false
14 |
15 | func raceAcquire(addr unsafe.Pointer) {
16 | }
17 |
18 | func raceReleaseMerge(addr unsafe.Pointer) {
19 | }
20 |
21 | func raceReadRange(addr unsafe.Pointer, len int) {
22 | }
23 |
24 | func raceWriteRange(addr unsafe.Pointer, len int) {
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/vendor/golang.org/x/sys/unix/sockcmsg_linux.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 | // Socket control messages
6 |
7 | package unix
8 |
9 | import "unsafe"
10 |
11 | // UnixCredentials encodes credentials into a socket control message
12 | // for sending to another process. This can be used for
13 | // authentication.
14 | func UnixCredentials(ucred *Ucred) []byte {
15 | b := make([]byte, CmsgSpace(SizeofUcred))
16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
17 | h.Level = SOL_SOCKET
18 | h.Type = SCM_CREDENTIALS
19 | h.SetLen(CmsgLen(SizeofUcred))
20 | *((*Ucred)(cmsgData(h))) = *ucred
21 | return b
22 | }
23 |
24 | // ParseUnixCredentials decodes a socket control message that contains
25 | // credentials in a Ucred structure. To receive such a message, the
26 | // SO_PASSCRED option must be enabled on the socket.
27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) {
28 | if m.Header.Level != SOL_SOCKET {
29 | return nil, EINVAL
30 | }
31 | if m.Header.Type != SCM_CREDENTIALS {
32 | return nil, EINVAL
33 | }
34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0]))
35 | return &ucred, nil
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/vendor/golang.org/x/sys/unix/sockcmsg_unix.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 netbsd openbsd solaris
6 |
7 | // Socket control messages
8 |
9 | package unix
10 |
11 | import "unsafe"
12 |
13 | // Round the length of a raw sockaddr up to align it properly.
14 | func cmsgAlignOf(salen int) int {
15 | salign := sizeofPtr
16 | // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels
17 | // still require 32-bit aligned access to network subsystem.
18 | if darwin64Bit || dragonfly64Bit {
19 | salign = 4
20 | }
21 | return (salen + salign - 1) & ^(salign - 1)
22 | }
23 |
24 | // CmsgLen returns the value to store in the Len field of the Cmsghdr
25 | // structure, taking into account any necessary alignment.
26 | func CmsgLen(datalen int) int {
27 | return cmsgAlignOf(SizeofCmsghdr) + datalen
28 | }
29 |
30 | // CmsgSpace returns the number of bytes an ancillary element with
31 | // payload of the passed data length occupies.
32 | func CmsgSpace(datalen int) int {
33 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
34 | }
35 |
36 | func cmsgData(h *Cmsghdr) unsafe.Pointer {
37 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
38 | }
39 |
40 | // SocketControlMessage represents a socket control message.
41 | type SocketControlMessage struct {
42 | Header Cmsghdr
43 | Data []byte
44 | }
45 |
46 | // ParseSocketControlMessage parses b as an array of socket control
47 | // messages.
48 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
49 | var msgs []SocketControlMessage
50 | i := 0
51 | for i+CmsgLen(0) <= len(b) {
52 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:])
53 | if err != nil {
54 | return nil, err
55 | }
56 | m := SocketControlMessage{Header: *h, Data: dbuf}
57 | msgs = append(msgs, m)
58 | i += cmsgAlignOf(int(h.Len))
59 | }
60 | return msgs, nil
61 | }
62 |
63 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
64 | h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
65 | if h.Len < SizeofCmsghdr || uint64(h.Len) > 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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/vendor/golang.org/x/sys/unix/syscall_linux_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,linux
6 |
7 | package unix
8 |
9 | //sys Dup2(oldfd int, newfd int) (err error)
10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
11 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
12 | //sys Fchown(fd int, uid int, gid int) (err error)
13 | //sys Fstat(fd int, stat *Stat_t) (err error)
14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error)
15 | //sys Ftruncate(fd int, length int64) (err error)
16 | //sysnb Getegid() (egid int)
17 | //sysnb Geteuid() (euid int)
18 | //sysnb Getgid() (gid int)
19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
20 | //sysnb Getuid() (uid int)
21 | //sysnb InotifyInit() (fd int, err error)
22 | //sys Ioperm(from int, num int, on int) (err error)
23 | //sys Iopl(level int) (err error)
24 | //sys Lchown(path string, uid int, gid int) (err error)
25 | //sys Listen(s int, n int) (err error)
26 | //sys Lstat(path string, stat *Stat_t) (err error)
27 | //sys Pause() (err error)
28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
33 | //sys Setfsgid(gid int) (err error)
34 | //sys Setfsuid(uid int) (err error)
35 | //sysnb Setregid(rgid int, egid int) (err error)
36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
39 | //sysnb Setreuid(ruid int, euid int) (err error)
40 | //sys Shutdown(fd int, how int) (err error)
41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
42 | //sys Stat(path string, stat *Stat_t) (err error)
43 | //sys Statfs(path string, buf *Statfs_t) (err error)
44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
45 | //sys Truncate(path string, length int64) (err error)
46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
51 | //sysnb setgroups(n int, list *_Gid_t) (err error)
52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
63 |
64 | func Gettimeofday(tv *Timeval) (err error) {
65 | errno := gettimeofday(tv)
66 | if errno != 0 {
67 | return errno
68 | }
69 | return nil
70 | }
71 |
72 | func Getpagesize() int { return 4096 }
73 |
74 | func Time(t *Time_t) (tt Time_t, err error) {
75 | var tv Timeval
76 | errno := gettimeofday(&tv)
77 | if errno != 0 {
78 | return 0, errno
79 | }
80 | if t != nil {
81 | *t = Time_t(tv.Sec)
82 | }
83 | return Time_t(tv.Sec), nil
84 | }
85 |
86 | //sys Utime(path string, buf *Utimbuf) (err error)
87 |
88 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
89 |
90 | func NsecToTimespec(nsec int64) (ts Timespec) {
91 | ts.Sec = nsec / 1e9
92 | ts.Nsec = nsec % 1e9
93 | return
94 | }
95 |
96 | func NsecToTimeval(nsec int64) (tv Timeval) {
97 | nsec += 999 // round up to microsecond
98 | tv.Sec = nsec / 1e9
99 | tv.Usec = nsec % 1e9 / 1e3
100 | return
101 | }
102 |
103 | //sysnb pipe(p *[2]_C_int) (err error)
104 |
105 | func Pipe(p []int) (err error) {
106 | if len(p) != 2 {
107 | return EINVAL
108 | }
109 | var pp [2]_C_int
110 | err = pipe(&pp)
111 | p[0] = int(pp[0])
112 | p[1] = int(pp[1])
113 | return
114 | }
115 |
116 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
117 |
118 | func Pipe2(p []int, flags int) (err error) {
119 | if len(p) != 2 {
120 | return EINVAL
121 | }
122 | var pp [2]_C_int
123 | err = pipe2(&pp, flags)
124 | p[0] = int(pp[0])
125 | p[1] = int(pp[1])
126 | return
127 | }
128 |
129 | func (r *PtraceRegs) PC() uint64 { return r.Rip }
130 |
131 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc }
132 |
133 | func (iov *Iovec) SetLen(length int) {
134 | iov.Len = uint64(length)
135 | }
136 |
137 | func (msghdr *Msghdr) SetControllen(length int) {
138 | msghdr.Controllen = uint64(length)
139 | }
140 |
141 | func (cmsg *Cmsghdr) SetLen(length int) {
142 | cmsg.Len = uint64(length)
143 | }
144 |
145 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
146 |
147 | func Poll(fds []PollFd, timeout int) (n int, err error) {
148 | if len(fds) == 0 {
149 | return poll(nil, 0, timeout)
150 | }
151 | return poll(&fds[0], len(fds), timeout)
152 | }
153 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/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/github.com/fatih/color/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.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 linux
6 | // +build ppc64 ppc64le
7 |
8 | package unix
9 |
10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
11 | //sys Dup2(oldfd int, newfd int) (err error)
12 | //sys Fchown(fd int, uid int, gid int) (err error)
13 | //sys Fstat(fd int, stat *Stat_t) (err error)
14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error)
15 | //sys Ftruncate(fd int, length int64) (err error)
16 | //sysnb Getegid() (egid int)
17 | //sysnb Geteuid() (euid int)
18 | //sysnb Getgid() (gid int)
19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT
20 | //sysnb Getuid() (uid int)
21 | //sysnb InotifyInit() (fd int, err error)
22 | //sys Ioperm(from int, num int, on int) (err error)
23 | //sys Iopl(level int) (err error)
24 | //sys Lchown(path string, uid int, gid int) (err error)
25 | //sys Listen(s int, n int) (err error)
26 | //sys Lstat(path string, stat *Stat_t) (err error)
27 | //sys Pause() (err error)
28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
33 | //sys Setfsgid(gid int) (err error)
34 | //sys Setfsuid(uid int) (err error)
35 | //sysnb Setregid(rgid int, egid int) (err error)
36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
39 | //sysnb Setreuid(ruid int, euid int) (err error)
40 | //sys Shutdown(fd int, how int) (err error)
41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
42 | //sys Stat(path string, stat *Stat_t) (err error)
43 | //sys Statfs(path string, buf *Statfs_t) (err error)
44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2
45 | //sys Truncate(path string, length int64) (err error)
46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
51 | //sysnb setgroups(n int, list *_Gid_t) (err error)
52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
63 |
64 | func Getpagesize() int { return 65536 }
65 |
66 | //sysnb Gettimeofday(tv *Timeval) (err error)
67 | //sysnb Time(t *Time_t) (tt Time_t, err error)
68 |
69 | //sys Utime(path string, buf *Utimbuf) (err error)
70 |
71 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
72 |
73 | func NsecToTimespec(nsec int64) (ts Timespec) {
74 | ts.Sec = nsec / 1e9
75 | ts.Nsec = nsec % 1e9
76 | return
77 | }
78 |
79 | func NsecToTimeval(nsec int64) (tv Timeval) {
80 | nsec += 999 // round up to microsecond
81 | tv.Sec = nsec / 1e9
82 | tv.Usec = nsec % 1e9 / 1e3
83 | return
84 | }
85 |
86 | func (r *PtraceRegs) PC() uint64 { return r.Nip }
87 |
88 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc }
89 |
90 | func (iov *Iovec) SetLen(length int) {
91 | iov.Len = uint64(length)
92 | }
93 |
94 | func (msghdr *Msghdr) SetControllen(length int) {
95 | msghdr.Controllen = uint64(length)
96 | }
97 |
98 | func (cmsg *Cmsghdr) SetLen(length int) {
99 | cmsg.Len = uint64(length)
100 | }
101 |
102 | //sysnb pipe(p *[2]_C_int) (err error)
103 |
104 | func Pipe(p []int) (err error) {
105 | if len(p) != 2 {
106 | return EINVAL
107 | }
108 | var pp [2]_C_int
109 | err = pipe(&pp)
110 | p[0] = int(pp[0])
111 | p[1] = int(pp[1])
112 | return
113 | }
114 |
115 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
116 |
117 | func Pipe2(p []int, flags int) (err error) {
118 | if len(p) != 2 {
119 | return EINVAL
120 | }
121 | var pp [2]_C_int
122 | err = pipe2(&pp, flags)
123 | p[0] = int(pp[0])
124 | p[1] = int(pp[1])
125 | return
126 | }
127 |
128 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
129 |
130 | func Poll(fds []PollFd, timeout int) (n int, err error) {
131 | if len(fds) == 0 {
132 | return poll(nil, 0, timeout)
133 | }
134 | return poll(&fds[0], len(fds), timeout)
135 | }
136 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.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 sparc64,linux
6 |
7 | package unix
8 |
9 | import (
10 | "sync/atomic"
11 | "syscall"
12 | )
13 |
14 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
15 | //sys Dup2(oldfd int, newfd int) (err error)
16 | //sys Fchown(fd int, uid int, gid int) (err error)
17 | //sys Fstat(fd int, stat *Stat_t) (err error)
18 | //sys Fstatfs(fd int, buf *Statfs_t) (err error)
19 | //sys Ftruncate(fd int, length int64) (err error)
20 | //sysnb Getegid() (egid int)
21 | //sysnb Geteuid() (euid int)
22 | //sysnb Getgid() (gid int)
23 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
24 | //sysnb Getuid() (uid int)
25 | //sysnb InotifyInit() (fd int, err error)
26 | //sys Lchown(path string, uid int, gid int) (err error)
27 | //sys Listen(s int, n int) (err error)
28 | //sys Lstat(path string, stat *Stat_t) (err error)
29 | //sys Pause() (err error)
30 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
31 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
32 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK
33 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
34 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error)
35 | //sys Setfsgid(gid int) (err error)
36 | //sys Setfsuid(uid int) (err error)
37 | //sysnb Setregid(rgid int, egid int) (err error)
38 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error)
39 | //sysnb Setresuid(ruid int, euid int, suid int) (err error)
40 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error)
41 | //sysnb Setreuid(ruid int, euid int) (err error)
42 | //sys Shutdown(fd int, how int) (err error)
43 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
44 | //sys Stat(path string, stat *Stat_t) (err error)
45 | //sys Statfs(path string, buf *Statfs_t) (err error)
46 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error)
47 | //sys Truncate(path string, length int64) (err error)
48 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
49 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
50 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
51 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
52 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error)
53 | //sysnb setgroups(n int, list *_Gid_t) (err error)
54 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
55 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
56 | //sysnb socket(domain int, typ int, proto int) (fd int, err error)
57 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
58 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
59 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
60 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
61 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
62 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
63 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
64 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error)
65 |
66 | func sysconf(name int) (n int64, err syscall.Errno)
67 |
68 | // pageSize caches the value of Getpagesize, since it can't change
69 | // once the system is booted.
70 | var pageSize int64 // accessed atomically
71 |
72 | func Getpagesize() int {
73 | n := atomic.LoadInt64(&pageSize)
74 | if n == 0 {
75 | n, _ = sysconf(_SC_PAGESIZE)
76 | atomic.StoreInt64(&pageSize, n)
77 | }
78 | return int(n)
79 | }
80 |
81 | func Ioperm(from int, num int, on int) (err error) {
82 | return ENOSYS
83 | }
84 |
85 | func Iopl(level int) (err error) {
86 | return ENOSYS
87 | }
88 |
89 | //sysnb Gettimeofday(tv *Timeval) (err error)
90 |
91 | func Time(t *Time_t) (tt Time_t, err error) {
92 | var tv Timeval
93 | err = Gettimeofday(&tv)
94 | if err != nil {
95 | return 0, err
96 | }
97 | if t != nil {
98 | *t = Time_t(tv.Sec)
99 | }
100 | return Time_t(tv.Sec), nil
101 | }
102 |
103 | //sys Utime(path string, buf *Utimbuf) (err error)
104 |
105 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
106 |
107 | func NsecToTimespec(nsec int64) (ts Timespec) {
108 | ts.Sec = nsec / 1e9
109 | ts.Nsec = nsec % 1e9
110 | return
111 | }
112 |
113 | func NsecToTimeval(nsec int64) (tv Timeval) {
114 | nsec += 999 // round up to microsecond
115 | tv.Sec = nsec / 1e9
116 | tv.Usec = int32(nsec % 1e9 / 1e3)
117 | return
118 | }
119 |
120 | func (r *PtraceRegs) PC() uint64 { return r.Tpc }
121 |
122 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc }
123 |
124 | func (iov *Iovec) SetLen(length int) {
125 | iov.Len = uint64(length)
126 | }
127 |
128 | func (msghdr *Msghdr) SetControllen(length int) {
129 | msghdr.Controllen = uint64(length)
130 | }
131 |
132 | func (cmsg *Cmsghdr) SetLen(length int) {
133 | cmsg.Len = uint64(length)
134 | }
135 |
136 | //sysnb pipe(p *[2]_C_int) (err error)
137 |
138 | func Pipe(p []int) (err error) {
139 | if len(p) != 2 {
140 | return EINVAL
141 | }
142 | var pp [2]_C_int
143 | err = pipe(&pp)
144 | p[0] = int(pp[0])
145 | p[1] = int(pp[1])
146 | return
147 | }
148 |
149 | //sysnb pipe2(p *[2]_C_int, flags int) (err error)
150 |
151 | func Pipe2(p []int, flags int) (err error) {
152 | if len(p) != 2 {
153 | return EINVAL
154 | }
155 | var pp [2]_C_int
156 | err = pipe2(&pp, flags)
157 | p[0] = int(pp[0])
158 | p[1] = int(pp[1])
159 | return
160 | }
161 |
162 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
163 |
164 | func Poll(fds []PollFd, timeout int) (n int, err error) {
165 | if len(fds) == 0 {
166 | return poll(nil, 0, timeout)
167 | }
168 | return poll(&fds[0], len(fds), timeout)
169 | }
170 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/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/github.com/fatih/color/vendor/golang.org/x/sys/unix/types_darwin.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 ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define __DARWIN_UNIX03 0
18 | #define KERNEL
19 | #define _DARWIN_USE_64_BIT_INODE
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 | #include
50 |
51 | enum {
52 | sizeofPtr = sizeof(void*),
53 | };
54 |
55 | union sockaddr_all {
56 | struct sockaddr s1; // this one gets used for fields
57 | struct sockaddr_in s2; // these pad it out
58 | struct sockaddr_in6 s3;
59 | struct sockaddr_un s4;
60 | struct sockaddr_dl s5;
61 | };
62 |
63 | struct sockaddr_any {
64 | struct sockaddr addr;
65 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
66 | };
67 |
68 | */
69 | import "C"
70 |
71 | // Machine characteristics; for internal use.
72 |
73 | const (
74 | sizeofPtr = C.sizeofPtr
75 | sizeofShort = C.sizeof_short
76 | sizeofInt = C.sizeof_int
77 | sizeofLong = C.sizeof_long
78 | sizeofLongLong = C.sizeof_longlong
79 | )
80 |
81 | // Basic types
82 |
83 | type (
84 | _C_short C.short
85 | _C_int C.int
86 | _C_long C.long
87 | _C_long_long C.longlong
88 | )
89 |
90 | // Time
91 |
92 | type Timespec C.struct_timespec
93 |
94 | type Timeval C.struct_timeval
95 |
96 | type Timeval32 C.struct_timeval32
97 |
98 | // Processes
99 |
100 | type Rusage C.struct_rusage
101 |
102 | type Rlimit C.struct_rlimit
103 |
104 | type _Gid_t C.gid_t
105 |
106 | // Files
107 |
108 | type Stat_t C.struct_stat64
109 |
110 | type Statfs_t C.struct_statfs64
111 |
112 | type Flock_t C.struct_flock
113 |
114 | type Fstore_t C.struct_fstore
115 |
116 | type Radvisory_t C.struct_radvisory
117 |
118 | type Fbootstraptransfer_t C.struct_fbootstraptransfer
119 |
120 | type Log2phys_t C.struct_log2phys
121 |
122 | type Fsid C.struct_fsid
123 |
124 | type Dirent C.struct_dirent
125 |
126 | // Sockets
127 |
128 | type RawSockaddrInet4 C.struct_sockaddr_in
129 |
130 | type RawSockaddrInet6 C.struct_sockaddr_in6
131 |
132 | type RawSockaddrUnix C.struct_sockaddr_un
133 |
134 | type RawSockaddrDatalink C.struct_sockaddr_dl
135 |
136 | type RawSockaddr C.struct_sockaddr
137 |
138 | type RawSockaddrAny C.struct_sockaddr_any
139 |
140 | type _Socklen C.socklen_t
141 |
142 | type Linger C.struct_linger
143 |
144 | type Iovec C.struct_iovec
145 |
146 | type IPMreq C.struct_ip_mreq
147 |
148 | type IPv6Mreq C.struct_ipv6_mreq
149 |
150 | type Msghdr C.struct_msghdr
151 |
152 | type Cmsghdr C.struct_cmsghdr
153 |
154 | type Inet4Pktinfo C.struct_in_pktinfo
155 |
156 | type Inet6Pktinfo C.struct_in6_pktinfo
157 |
158 | type IPv6MTUInfo C.struct_ip6_mtuinfo
159 |
160 | type ICMPv6Filter C.struct_icmp6_filter
161 |
162 | const (
163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
168 | SizeofLinger = C.sizeof_struct_linger
169 | SizeofIPMreq = C.sizeof_struct_ip_mreq
170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
171 | SizeofMsghdr = C.sizeof_struct_msghdr
172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
173 | SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo
174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
177 | )
178 |
179 | // Ptrace requests
180 |
181 | const (
182 | PTRACE_TRACEME = C.PT_TRACE_ME
183 | PTRACE_CONT = C.PT_CONTINUE
184 | PTRACE_KILL = C.PT_KILL
185 | )
186 |
187 | // Events (kqueue, kevent)
188 |
189 | type Kevent_t C.struct_kevent
190 |
191 | // Select
192 |
193 | type FdSet C.fd_set
194 |
195 | // Routing and interface messages
196 |
197 | const (
198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
199 | SizeofIfData = C.sizeof_struct_if_data
200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
201 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
202 | SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2
203 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
204 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
205 | )
206 |
207 | type IfMsghdr C.struct_if_msghdr
208 |
209 | type IfData C.struct_if_data
210 |
211 | type IfaMsghdr C.struct_ifa_msghdr
212 |
213 | type IfmaMsghdr C.struct_ifma_msghdr
214 |
215 | type IfmaMsghdr2 C.struct_ifma_msghdr2
216 |
217 | type RtMsghdr C.struct_rt_msghdr
218 |
219 | type RtMetrics C.struct_rt_metrics
220 |
221 | // Berkeley packet filter
222 |
223 | const (
224 | SizeofBpfVersion = C.sizeof_struct_bpf_version
225 | SizeofBpfStat = C.sizeof_struct_bpf_stat
226 | SizeofBpfProgram = C.sizeof_struct_bpf_program
227 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
228 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
229 | )
230 |
231 | type BpfVersion C.struct_bpf_version
232 |
233 | type BpfStat C.struct_bpf_stat
234 |
235 | type BpfProgram C.struct_bpf_program
236 |
237 | type BpfInsn C.struct_bpf_insn
238 |
239 | type BpfHdr C.struct_bpf_hdr
240 |
241 | // Terminal handling
242 |
243 | type Termios C.struct_termios
244 |
245 | // fchmodat-like syscalls.
246 |
247 | const (
248 | AT_FDCWD = C.AT_FDCWD
249 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
250 | )
251 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/vendor/golang.org/x/sys/unix/types_dragonfly.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 ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define KERNEL
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 |
46 | enum {
47 | sizeofPtr = sizeof(void*),
48 | };
49 |
50 | union sockaddr_all {
51 | struct sockaddr s1; // this one gets used for fields
52 | struct sockaddr_in s2; // these pad it out
53 | struct sockaddr_in6 s3;
54 | struct sockaddr_un s4;
55 | struct sockaddr_dl s5;
56 | };
57 |
58 | struct sockaddr_any {
59 | struct sockaddr addr;
60 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
61 | };
62 |
63 | */
64 | import "C"
65 |
66 | // Machine characteristics; for internal use.
67 |
68 | const (
69 | sizeofPtr = C.sizeofPtr
70 | sizeofShort = C.sizeof_short
71 | sizeofInt = C.sizeof_int
72 | sizeofLong = C.sizeof_long
73 | sizeofLongLong = C.sizeof_longlong
74 | )
75 |
76 | // Basic types
77 |
78 | type (
79 | _C_short C.short
80 | _C_int C.int
81 | _C_long C.long
82 | _C_long_long C.longlong
83 | )
84 |
85 | // Time
86 |
87 | type Timespec C.struct_timespec
88 |
89 | type Timeval C.struct_timeval
90 |
91 | // Processes
92 |
93 | type Rusage C.struct_rusage
94 |
95 | type Rlimit C.struct_rlimit
96 |
97 | type _Gid_t C.gid_t
98 |
99 | // Files
100 |
101 | const ( // Directory mode bits
102 | S_IFMT = C.S_IFMT
103 | S_IFIFO = C.S_IFIFO
104 | S_IFCHR = C.S_IFCHR
105 | S_IFDIR = C.S_IFDIR
106 | S_IFBLK = C.S_IFBLK
107 | S_IFREG = C.S_IFREG
108 | S_IFLNK = C.S_IFLNK
109 | S_IFSOCK = C.S_IFSOCK
110 | S_ISUID = C.S_ISUID
111 | S_ISGID = C.S_ISGID
112 | S_ISVTX = C.S_ISVTX
113 | S_IRUSR = C.S_IRUSR
114 | S_IWUSR = C.S_IWUSR
115 | S_IXUSR = C.S_IXUSR
116 | )
117 |
118 | type Stat_t C.struct_stat
119 |
120 | type Statfs_t C.struct_statfs
121 |
122 | type Flock_t C.struct_flock
123 |
124 | type Dirent C.struct_dirent
125 |
126 | type Fsid C.struct_fsid
127 |
128 | // Sockets
129 |
130 | type RawSockaddrInet4 C.struct_sockaddr_in
131 |
132 | type RawSockaddrInet6 C.struct_sockaddr_in6
133 |
134 | type RawSockaddrUnix C.struct_sockaddr_un
135 |
136 | type RawSockaddrDatalink C.struct_sockaddr_dl
137 |
138 | type RawSockaddr C.struct_sockaddr
139 |
140 | type RawSockaddrAny C.struct_sockaddr_any
141 |
142 | type _Socklen C.socklen_t
143 |
144 | type Linger C.struct_linger
145 |
146 | type Iovec C.struct_iovec
147 |
148 | type IPMreq C.struct_ip_mreq
149 |
150 | type IPv6Mreq C.struct_ipv6_mreq
151 |
152 | type Msghdr C.struct_msghdr
153 |
154 | type Cmsghdr C.struct_cmsghdr
155 |
156 | type Inet6Pktinfo C.struct_in6_pktinfo
157 |
158 | type IPv6MTUInfo C.struct_ip6_mtuinfo
159 |
160 | type ICMPv6Filter C.struct_icmp6_filter
161 |
162 | const (
163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
168 | SizeofLinger = C.sizeof_struct_linger
169 | SizeofIPMreq = C.sizeof_struct_ip_mreq
170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
171 | SizeofMsghdr = C.sizeof_struct_msghdr
172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
173 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
174 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
175 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
176 | )
177 |
178 | // Ptrace requests
179 |
180 | const (
181 | PTRACE_TRACEME = C.PT_TRACE_ME
182 | PTRACE_CONT = C.PT_CONTINUE
183 | PTRACE_KILL = C.PT_KILL
184 | )
185 |
186 | // Events (kqueue, kevent)
187 |
188 | type Kevent_t C.struct_kevent
189 |
190 | // Select
191 |
192 | type FdSet C.fd_set
193 |
194 | // Routing and interface messages
195 |
196 | const (
197 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
198 | SizeofIfData = C.sizeof_struct_if_data
199 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
200 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
204 | )
205 |
206 | type IfMsghdr C.struct_if_msghdr
207 |
208 | type IfData C.struct_if_data
209 |
210 | type IfaMsghdr C.struct_ifa_msghdr
211 |
212 | type IfmaMsghdr C.struct_ifma_msghdr
213 |
214 | type IfAnnounceMsghdr C.struct_if_announcemsghdr
215 |
216 | type RtMsghdr C.struct_rt_msghdr
217 |
218 | type RtMetrics C.struct_rt_metrics
219 |
220 | // Berkeley packet filter
221 |
222 | const (
223 | SizeofBpfVersion = C.sizeof_struct_bpf_version
224 | SizeofBpfStat = C.sizeof_struct_bpf_stat
225 | SizeofBpfProgram = C.sizeof_struct_bpf_program
226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
228 | )
229 |
230 | type BpfVersion C.struct_bpf_version
231 |
232 | type BpfStat C.struct_bpf_stat
233 |
234 | type BpfProgram C.struct_bpf_program
235 |
236 | type BpfInsn C.struct_bpf_insn
237 |
238 | type BpfHdr C.struct_bpf_hdr
239 |
240 | // Terminal handling
241 |
242 | type Termios C.struct_termios
243 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/vendor/golang.org/x/sys/unix/types_netbsd.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 ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define KERNEL
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 |
48 | enum {
49 | sizeofPtr = sizeof(void*),
50 | };
51 |
52 | union sockaddr_all {
53 | struct sockaddr s1; // this one gets used for fields
54 | struct sockaddr_in s2; // these pad it out
55 | struct sockaddr_in6 s3;
56 | struct sockaddr_un s4;
57 | struct sockaddr_dl s5;
58 | };
59 |
60 | struct sockaddr_any {
61 | struct sockaddr addr;
62 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
63 | };
64 |
65 | */
66 | import "C"
67 |
68 | // Machine characteristics; for internal use.
69 |
70 | const (
71 | sizeofPtr = C.sizeofPtr
72 | sizeofShort = C.sizeof_short
73 | sizeofInt = C.sizeof_int
74 | sizeofLong = C.sizeof_long
75 | sizeofLongLong = C.sizeof_longlong
76 | )
77 |
78 | // Basic types
79 |
80 | type (
81 | _C_short C.short
82 | _C_int C.int
83 | _C_long C.long
84 | _C_long_long C.longlong
85 | )
86 |
87 | // Time
88 |
89 | type Timespec C.struct_timespec
90 |
91 | type Timeval C.struct_timeval
92 |
93 | // Processes
94 |
95 | type Rusage C.struct_rusage
96 |
97 | type Rlimit C.struct_rlimit
98 |
99 | type _Gid_t C.gid_t
100 |
101 | // Files
102 |
103 | type Stat_t C.struct_stat
104 |
105 | type Statfs_t C.struct_statfs
106 |
107 | type Flock_t C.struct_flock
108 |
109 | type Dirent C.struct_dirent
110 |
111 | type Fsid C.fsid_t
112 |
113 | // Sockets
114 |
115 | type RawSockaddrInet4 C.struct_sockaddr_in
116 |
117 | type RawSockaddrInet6 C.struct_sockaddr_in6
118 |
119 | type RawSockaddrUnix C.struct_sockaddr_un
120 |
121 | type RawSockaddrDatalink C.struct_sockaddr_dl
122 |
123 | type RawSockaddr C.struct_sockaddr
124 |
125 | type RawSockaddrAny C.struct_sockaddr_any
126 |
127 | type _Socklen C.socklen_t
128 |
129 | type Linger C.struct_linger
130 |
131 | type Iovec C.struct_iovec
132 |
133 | type IPMreq C.struct_ip_mreq
134 |
135 | type IPv6Mreq C.struct_ipv6_mreq
136 |
137 | type Msghdr C.struct_msghdr
138 |
139 | type Cmsghdr C.struct_cmsghdr
140 |
141 | type Inet6Pktinfo C.struct_in6_pktinfo
142 |
143 | type IPv6MTUInfo C.struct_ip6_mtuinfo
144 |
145 | type ICMPv6Filter C.struct_icmp6_filter
146 |
147 | const (
148 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
149 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
150 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
151 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
152 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
153 | SizeofLinger = C.sizeof_struct_linger
154 | SizeofIPMreq = C.sizeof_struct_ip_mreq
155 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
156 | SizeofMsghdr = C.sizeof_struct_msghdr
157 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
158 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
159 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
160 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
161 | )
162 |
163 | // Ptrace requests
164 |
165 | const (
166 | PTRACE_TRACEME = C.PT_TRACE_ME
167 | PTRACE_CONT = C.PT_CONTINUE
168 | PTRACE_KILL = C.PT_KILL
169 | )
170 |
171 | // Events (kqueue, kevent)
172 |
173 | type Kevent_t C.struct_kevent
174 |
175 | // Select
176 |
177 | type FdSet C.fd_set
178 |
179 | // Routing and interface messages
180 |
181 | const (
182 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
183 | SizeofIfData = C.sizeof_struct_if_data
184 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
185 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
186 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
187 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
188 | )
189 |
190 | type IfMsghdr C.struct_if_msghdr
191 |
192 | type IfData C.struct_if_data
193 |
194 | type IfaMsghdr C.struct_ifa_msghdr
195 |
196 | type IfAnnounceMsghdr C.struct_if_announcemsghdr
197 |
198 | type RtMsghdr C.struct_rt_msghdr
199 |
200 | type RtMetrics C.struct_rt_metrics
201 |
202 | type Mclpool C.struct_mclpool
203 |
204 | // Berkeley packet filter
205 |
206 | const (
207 | SizeofBpfVersion = C.sizeof_struct_bpf_version
208 | SizeofBpfStat = C.sizeof_struct_bpf_stat
209 | SizeofBpfProgram = C.sizeof_struct_bpf_program
210 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
211 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
212 | )
213 |
214 | type BpfVersion C.struct_bpf_version
215 |
216 | type BpfStat C.struct_bpf_stat
217 |
218 | type BpfProgram C.struct_bpf_program
219 |
220 | type BpfInsn C.struct_bpf_insn
221 |
222 | type BpfHdr C.struct_bpf_hdr
223 |
224 | type BpfTimeval C.struct_bpf_timeval
225 |
226 | // Terminal handling
227 |
228 | type Termios C.struct_termios
229 |
230 | // Sysctl
231 |
232 | type Sysctlnode C.struct_sysctlnode
233 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/vendor/golang.org/x/sys/unix/types_openbsd.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 ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define KERNEL
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 |
47 | enum {
48 | sizeofPtr = sizeof(void*),
49 | };
50 |
51 | union sockaddr_all {
52 | struct sockaddr s1; // this one gets used for fields
53 | struct sockaddr_in s2; // these pad it out
54 | struct sockaddr_in6 s3;
55 | struct sockaddr_un s4;
56 | struct sockaddr_dl s5;
57 | };
58 |
59 | struct sockaddr_any {
60 | struct sockaddr addr;
61 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
62 | };
63 |
64 | */
65 | import "C"
66 |
67 | // Machine characteristics; for internal use.
68 |
69 | const (
70 | sizeofPtr = C.sizeofPtr
71 | sizeofShort = C.sizeof_short
72 | sizeofInt = C.sizeof_int
73 | sizeofLong = C.sizeof_long
74 | sizeofLongLong = C.sizeof_longlong
75 | )
76 |
77 | // Basic types
78 |
79 | type (
80 | _C_short C.short
81 | _C_int C.int
82 | _C_long C.long
83 | _C_long_long C.longlong
84 | )
85 |
86 | // Time
87 |
88 | type Timespec C.struct_timespec
89 |
90 | type Timeval C.struct_timeval
91 |
92 | // Processes
93 |
94 | type Rusage C.struct_rusage
95 |
96 | type Rlimit C.struct_rlimit
97 |
98 | type _Gid_t C.gid_t
99 |
100 | // Files
101 |
102 | const ( // Directory mode bits
103 | S_IFMT = C.S_IFMT
104 | S_IFIFO = C.S_IFIFO
105 | S_IFCHR = C.S_IFCHR
106 | S_IFDIR = C.S_IFDIR
107 | S_IFBLK = C.S_IFBLK
108 | S_IFREG = C.S_IFREG
109 | S_IFLNK = C.S_IFLNK
110 | S_IFSOCK = C.S_IFSOCK
111 | S_ISUID = C.S_ISUID
112 | S_ISGID = C.S_ISGID
113 | S_ISVTX = C.S_ISVTX
114 | S_IRUSR = C.S_IRUSR
115 | S_IWUSR = C.S_IWUSR
116 | S_IXUSR = C.S_IXUSR
117 | )
118 |
119 | type Stat_t C.struct_stat
120 |
121 | type Statfs_t C.struct_statfs
122 |
123 | type Flock_t C.struct_flock
124 |
125 | type Dirent C.struct_dirent
126 |
127 | type Fsid C.fsid_t
128 |
129 | // Sockets
130 |
131 | type RawSockaddrInet4 C.struct_sockaddr_in
132 |
133 | type RawSockaddrInet6 C.struct_sockaddr_in6
134 |
135 | type RawSockaddrUnix C.struct_sockaddr_un
136 |
137 | type RawSockaddrDatalink C.struct_sockaddr_dl
138 |
139 | type RawSockaddr C.struct_sockaddr
140 |
141 | type RawSockaddrAny C.struct_sockaddr_any
142 |
143 | type _Socklen C.socklen_t
144 |
145 | type Linger C.struct_linger
146 |
147 | type Iovec C.struct_iovec
148 |
149 | type IPMreq C.struct_ip_mreq
150 |
151 | type IPv6Mreq C.struct_ipv6_mreq
152 |
153 | type Msghdr C.struct_msghdr
154 |
155 | type Cmsghdr C.struct_cmsghdr
156 |
157 | type Inet6Pktinfo C.struct_in6_pktinfo
158 |
159 | type IPv6MTUInfo C.struct_ip6_mtuinfo
160 |
161 | type ICMPv6Filter C.struct_icmp6_filter
162 |
163 | const (
164 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
165 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
166 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
167 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
168 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
169 | SizeofLinger = C.sizeof_struct_linger
170 | SizeofIPMreq = C.sizeof_struct_ip_mreq
171 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
172 | SizeofMsghdr = C.sizeof_struct_msghdr
173 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
177 | )
178 |
179 | // Ptrace requests
180 |
181 | const (
182 | PTRACE_TRACEME = C.PT_TRACE_ME
183 | PTRACE_CONT = C.PT_CONTINUE
184 | PTRACE_KILL = C.PT_KILL
185 | )
186 |
187 | // Events (kqueue, kevent)
188 |
189 | type Kevent_t C.struct_kevent
190 |
191 | // Select
192 |
193 | type FdSet C.fd_set
194 |
195 | // Routing and interface messages
196 |
197 | const (
198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
199 | SizeofIfData = C.sizeof_struct_if_data
200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
204 | )
205 |
206 | type IfMsghdr C.struct_if_msghdr
207 |
208 | type IfData C.struct_if_data
209 |
210 | type IfaMsghdr C.struct_ifa_msghdr
211 |
212 | type IfAnnounceMsghdr C.struct_if_announcemsghdr
213 |
214 | type RtMsghdr C.struct_rt_msghdr
215 |
216 | type RtMetrics C.struct_rt_metrics
217 |
218 | type Mclpool C.struct_mclpool
219 |
220 | // Berkeley packet filter
221 |
222 | const (
223 | SizeofBpfVersion = C.sizeof_struct_bpf_version
224 | SizeofBpfStat = C.sizeof_struct_bpf_stat
225 | SizeofBpfProgram = C.sizeof_struct_bpf_program
226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
228 | )
229 |
230 | type BpfVersion C.struct_bpf_version
231 |
232 | type BpfStat C.struct_bpf_stat
233 |
234 | type BpfProgram C.struct_bpf_program
235 |
236 | type BpfInsn C.struct_bpf_insn
237 |
238 | type BpfHdr C.struct_bpf_hdr
239 |
240 | type BpfTimeval C.struct_bpf_timeval
241 |
242 | // Terminal handling
243 |
244 | type Termios C.struct_termios
245 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/vendor/golang.org/x/sys/unix/types_solaris.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 ignore
6 |
7 | /*
8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh
9 | */
10 |
11 | // +godefs map struct_in_addr [4]byte /* in_addr */
12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */
13 |
14 | package unix
15 |
16 | /*
17 | #define KERNEL
18 | // These defines ensure that builds done on newer versions of Solaris are
19 | // backwards-compatible with older versions of Solaris and
20 | // OpenSolaris-based derivatives.
21 | #define __USE_SUNOS_SOCKETS__ // msghdr
22 | #define __USE_LEGACY_PROTOTYPES__ // iovec
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 | #include
50 | #include
51 | #include
52 | #include
53 | #include
54 | #include
55 |
56 | enum {
57 | sizeofPtr = sizeof(void*),
58 | };
59 |
60 | union sockaddr_all {
61 | struct sockaddr s1; // this one gets used for fields
62 | struct sockaddr_in s2; // these pad it out
63 | struct sockaddr_in6 s3;
64 | struct sockaddr_un s4;
65 | struct sockaddr_dl s5;
66 | };
67 |
68 | struct sockaddr_any {
69 | struct sockaddr addr;
70 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
71 | };
72 |
73 | */
74 | import "C"
75 |
76 | // Machine characteristics; for internal use.
77 |
78 | const (
79 | sizeofPtr = C.sizeofPtr
80 | sizeofShort = C.sizeof_short
81 | sizeofInt = C.sizeof_int
82 | sizeofLong = C.sizeof_long
83 | sizeofLongLong = C.sizeof_longlong
84 | PathMax = C.PATH_MAX
85 | MaxHostNameLen = C.MAXHOSTNAMELEN
86 | )
87 |
88 | // Basic types
89 |
90 | type (
91 | _C_short C.short
92 | _C_int C.int
93 | _C_long C.long
94 | _C_long_long C.longlong
95 | )
96 |
97 | // Time
98 |
99 | type Timespec C.struct_timespec
100 |
101 | type Timeval C.struct_timeval
102 |
103 | type Timeval32 C.struct_timeval32
104 |
105 | type Tms C.struct_tms
106 |
107 | type Utimbuf C.struct_utimbuf
108 |
109 | // Processes
110 |
111 | type Rusage C.struct_rusage
112 |
113 | type Rlimit C.struct_rlimit
114 |
115 | type _Gid_t C.gid_t
116 |
117 | // Files
118 |
119 | const ( // Directory mode bits
120 | S_IFMT = C.S_IFMT
121 | S_IFIFO = C.S_IFIFO
122 | S_IFCHR = C.S_IFCHR
123 | S_IFDIR = C.S_IFDIR
124 | S_IFBLK = C.S_IFBLK
125 | S_IFREG = C.S_IFREG
126 | S_IFLNK = C.S_IFLNK
127 | S_IFSOCK = C.S_IFSOCK
128 | S_ISUID = C.S_ISUID
129 | S_ISGID = C.S_ISGID
130 | S_ISVTX = C.S_ISVTX
131 | S_IRUSR = C.S_IRUSR
132 | S_IWUSR = C.S_IWUSR
133 | S_IXUSR = C.S_IXUSR
134 | )
135 |
136 | type Stat_t C.struct_stat
137 |
138 | type Flock_t C.struct_flock
139 |
140 | type Dirent C.struct_dirent
141 |
142 | // Sockets
143 |
144 | type RawSockaddrInet4 C.struct_sockaddr_in
145 |
146 | type RawSockaddrInet6 C.struct_sockaddr_in6
147 |
148 | type RawSockaddrUnix C.struct_sockaddr_un
149 |
150 | type RawSockaddrDatalink C.struct_sockaddr_dl
151 |
152 | type RawSockaddr C.struct_sockaddr
153 |
154 | type RawSockaddrAny C.struct_sockaddr_any
155 |
156 | type _Socklen C.socklen_t
157 |
158 | type Linger C.struct_linger
159 |
160 | type Iovec C.struct_iovec
161 |
162 | type IPMreq C.struct_ip_mreq
163 |
164 | type IPv6Mreq C.struct_ipv6_mreq
165 |
166 | type Msghdr C.struct_msghdr
167 |
168 | type Cmsghdr C.struct_cmsghdr
169 |
170 | type Inet6Pktinfo C.struct_in6_pktinfo
171 |
172 | type IPv6MTUInfo C.struct_ip6_mtuinfo
173 |
174 | type ICMPv6Filter C.struct_icmp6_filter
175 |
176 | const (
177 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
178 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
179 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
180 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
181 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
182 | SizeofLinger = C.sizeof_struct_linger
183 | SizeofIPMreq = C.sizeof_struct_ip_mreq
184 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
185 | SizeofMsghdr = C.sizeof_struct_msghdr
186 | SizeofCmsghdr = C.sizeof_struct_cmsghdr
187 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
188 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
189 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
190 | )
191 |
192 | // Select
193 |
194 | type FdSet C.fd_set
195 |
196 | // Misc
197 |
198 | type Utsname C.struct_utsname
199 |
200 | type Ustat_t C.struct_ustat
201 |
202 | const (
203 | AT_FDCWD = C.AT_FDCWD
204 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
205 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
206 | AT_REMOVEDIR = C.AT_REMOVEDIR
207 | AT_EACCESS = C.AT_EACCESS
208 | )
209 |
210 | // Routing and interface messages
211 |
212 | const (
213 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr
214 | SizeofIfData = C.sizeof_struct_if_data
215 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
216 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
217 | SizeofRtMetrics = C.sizeof_struct_rt_metrics
218 | )
219 |
220 | type IfMsghdr C.struct_if_msghdr
221 |
222 | type IfData C.struct_if_data
223 |
224 | type IfaMsghdr C.struct_ifa_msghdr
225 |
226 | type RtMsghdr C.struct_rt_msghdr
227 |
228 | type RtMetrics C.struct_rt_metrics
229 |
230 | // Berkeley packet filter
231 |
232 | const (
233 | SizeofBpfVersion = C.sizeof_struct_bpf_version
234 | SizeofBpfStat = C.sizeof_struct_bpf_stat
235 | SizeofBpfProgram = C.sizeof_struct_bpf_program
236 | SizeofBpfInsn = C.sizeof_struct_bpf_insn
237 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr
238 | )
239 |
240 | type BpfVersion C.struct_bpf_version
241 |
242 | type BpfStat C.struct_bpf_stat
243 |
244 | type BpfProgram C.struct_bpf_program
245 |
246 | type BpfInsn C.struct_bpf_insn
247 |
248 | type BpfTimeval C.struct_bpf_timeval
249 |
250 | type BpfHdr C.struct_bpf_hdr
251 |
252 | // sysconf information
253 |
254 | const _SC_PAGESIZE = C._SC_PAGESIZE
255 |
256 | // Terminal handling
257 |
258 | type Termios C.struct_termios
259 |
260 | type Termio C.struct_termio
261 |
262 | type Winsize C.struct_winsize
263 |
--------------------------------------------------------------------------------
/vendor/github.com/fatih/color/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/github.com/fatih/color/vendor/manifest:
--------------------------------------------------------------------------------
1 | {
2 | "version": 0,
3 | "dependencies": [
4 | {
5 | "importpath": "github.com/mattn/go-colorable",
6 | "repository": "https://github.com/mattn/go-colorable",
7 | "vcs": "git",
8 | "revision": "5411d3eea5978e6cdc258b30de592b60df6aba96",
9 | "branch": "master",
10 | "notests": true
11 | },
12 | {
13 | "importpath": "github.com/mattn/go-isatty",
14 | "repository": "https://github.com/mattn/go-isatty",
15 | "vcs": "git",
16 | "revision": "57fdcb988a5c543893cc61bce354a6e24ab70022",
17 | "branch": "master",
18 | "notests": true
19 | },
20 | {
21 | "importpath": "golang.org/x/sys/unix",
22 | "repository": "https://go.googlesource.com/sys",
23 | "vcs": "git",
24 | "revision": "e24f485414aeafb646f6fca458b0bf869c0880a1",
25 | "branch": "master",
26 | "path": "/unix",
27 | "notests": true
28 | }
29 | ]
30 | }
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/pbkdf2/pbkdf2.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 | /*
6 | Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC
7 | 2898 / PKCS #5 v2.0.
8 |
9 | A key derivation function is useful when encrypting data based on a password
10 | or any other not-fully-random data. It uses a pseudorandom function to derive
11 | a secure encryption key based on the password.
12 |
13 | While v2.0 of the standard defines only one pseudorandom function to use,
14 | HMAC-SHA1, the drafted v2.1 specification allows use of all five FIPS Approved
15 | Hash Functions SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512 for HMAC. To
16 | choose, you can pass the `New` functions from the different SHA packages to
17 | pbkdf2.Key.
18 | */
19 | package pbkdf2 // import "golang.org/x/crypto/pbkdf2"
20 |
21 | import (
22 | "crypto/hmac"
23 | "hash"
24 | )
25 |
26 | // Key derives a key from the password, salt and iteration count, returning a
27 | // []byte of length keylen that can be used as cryptographic key. The key is
28 | // derived based on the method described as PBKDF2 with the HMAC variant using
29 | // the supplied hash function.
30 | //
31 | // For example, to use a HMAC-SHA-1 based PBKDF2 key derivation function, you
32 | // can get a derived key for e.g. AES-256 (which needs a 32-byte key) by
33 | // doing:
34 | //
35 | // dk := pbkdf2.Key([]byte("some password"), salt, 4096, 32, sha1.New)
36 | //
37 | // Remember to get a good random salt. At least 8 bytes is recommended by the
38 | // RFC.
39 | //
40 | // Using a higher iteration count will increase the cost of an exhaustive
41 | // search but will also make derivation proportionally slower.
42 | func Key(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte {
43 | prf := hmac.New(h, password)
44 | hashLen := prf.Size()
45 | numBlocks := (keyLen + hashLen - 1) / hashLen
46 |
47 | var buf [4]byte
48 | dk := make([]byte, 0, numBlocks*hashLen)
49 | U := make([]byte, hashLen)
50 | for block := 1; block <= numBlocks; block++ {
51 | // N.B.: || means concatenation, ^ means XOR
52 | // for each block T_i = U_1 ^ U_2 ^ ... ^ U_iter
53 | // U_1 = PRF(password, salt || uint(i))
54 | prf.Reset()
55 | prf.Write(salt)
56 | buf[0] = byte(block >> 24)
57 | buf[1] = byte(block >> 16)
58 | buf[2] = byte(block >> 8)
59 | buf[3] = byte(block)
60 | prf.Write(buf[:4])
61 | dk = prf.Sum(dk)
62 | T := dk[len(dk)-hashLen:]
63 | copy(U, T)
64 |
65 | // U_n = PRF(password, U_(n-1))
66 | for n := 2; n <= iter; n++ {
67 | prf.Reset()
68 | prf.Write(U)
69 | U = U[:0]
70 | U = prf.Sum(U)
71 | for x := range U {
72 | T[x] ^= U[x]
73 | }
74 | }
75 | }
76 | return dk[:keyLen]
77 | }
78 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/pbkdf2/pbkdf2_test.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 | package pbkdf2
6 |
7 | import (
8 | "bytes"
9 | "crypto/sha1"
10 | "crypto/sha256"
11 | "hash"
12 | "testing"
13 | )
14 |
15 | type testVector struct {
16 | password string
17 | salt string
18 | iter int
19 | output []byte
20 | }
21 |
22 | // Test vectors from RFC 6070, http://tools.ietf.org/html/rfc6070
23 | var sha1TestVectors = []testVector{
24 | {
25 | "password",
26 | "salt",
27 | 1,
28 | []byte{
29 | 0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71,
30 | 0xf3, 0xa9, 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06,
31 | 0x2f, 0xe0, 0x37, 0xa6,
32 | },
33 | },
34 | {
35 | "password",
36 | "salt",
37 | 2,
38 | []byte{
39 | 0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c,
40 | 0xcd, 0x1e, 0xd9, 0x2a, 0xce, 0x1d, 0x41, 0xf0,
41 | 0xd8, 0xde, 0x89, 0x57,
42 | },
43 | },
44 | {
45 | "password",
46 | "salt",
47 | 4096,
48 | []byte{
49 | 0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a,
50 | 0xbe, 0xad, 0x49, 0xd9, 0x26, 0xf7, 0x21, 0xd0,
51 | 0x65, 0xa4, 0x29, 0xc1,
52 | },
53 | },
54 | // // This one takes too long
55 | // {
56 | // "password",
57 | // "salt",
58 | // 16777216,
59 | // []byte{
60 | // 0xee, 0xfe, 0x3d, 0x61, 0xcd, 0x4d, 0xa4, 0xe4,
61 | // 0xe9, 0x94, 0x5b, 0x3d, 0x6b, 0xa2, 0x15, 0x8c,
62 | // 0x26, 0x34, 0xe9, 0x84,
63 | // },
64 | // },
65 | {
66 | "passwordPASSWORDpassword",
67 | "saltSALTsaltSALTsaltSALTsaltSALTsalt",
68 | 4096,
69 | []byte{
70 | 0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b,
71 | 0x80, 0xc8, 0xd8, 0x36, 0x62, 0xc0, 0xe4, 0x4a,
72 | 0x8b, 0x29, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70,
73 | 0x38,
74 | },
75 | },
76 | {
77 | "pass\000word",
78 | "sa\000lt",
79 | 4096,
80 | []byte{
81 | 0x56, 0xfa, 0x6a, 0xa7, 0x55, 0x48, 0x09, 0x9d,
82 | 0xcc, 0x37, 0xd7, 0xf0, 0x34, 0x25, 0xe0, 0xc3,
83 | },
84 | },
85 | }
86 |
87 | // Test vectors from
88 | // http://stackoverflow.com/questions/5130513/pbkdf2-hmac-sha2-test-vectors
89 | var sha256TestVectors = []testVector{
90 | {
91 | "password",
92 | "salt",
93 | 1,
94 | []byte{
95 | 0x12, 0x0f, 0xb6, 0xcf, 0xfc, 0xf8, 0xb3, 0x2c,
96 | 0x43, 0xe7, 0x22, 0x52, 0x56, 0xc4, 0xf8, 0x37,
97 | 0xa8, 0x65, 0x48, 0xc9,
98 | },
99 | },
100 | {
101 | "password",
102 | "salt",
103 | 2,
104 | []byte{
105 | 0xae, 0x4d, 0x0c, 0x95, 0xaf, 0x6b, 0x46, 0xd3,
106 | 0x2d, 0x0a, 0xdf, 0xf9, 0x28, 0xf0, 0x6d, 0xd0,
107 | 0x2a, 0x30, 0x3f, 0x8e,
108 | },
109 | },
110 | {
111 | "password",
112 | "salt",
113 | 4096,
114 | []byte{
115 | 0xc5, 0xe4, 0x78, 0xd5, 0x92, 0x88, 0xc8, 0x41,
116 | 0xaa, 0x53, 0x0d, 0xb6, 0x84, 0x5c, 0x4c, 0x8d,
117 | 0x96, 0x28, 0x93, 0xa0,
118 | },
119 | },
120 | {
121 | "passwordPASSWORDpassword",
122 | "saltSALTsaltSALTsaltSALTsaltSALTsalt",
123 | 4096,
124 | []byte{
125 | 0x34, 0x8c, 0x89, 0xdb, 0xcb, 0xd3, 0x2b, 0x2f,
126 | 0x32, 0xd8, 0x14, 0xb8, 0x11, 0x6e, 0x84, 0xcf,
127 | 0x2b, 0x17, 0x34, 0x7e, 0xbc, 0x18, 0x00, 0x18,
128 | 0x1c,
129 | },
130 | },
131 | {
132 | "pass\000word",
133 | "sa\000lt",
134 | 4096,
135 | []byte{
136 | 0x89, 0xb6, 0x9d, 0x05, 0x16, 0xf8, 0x29, 0x89,
137 | 0x3c, 0x69, 0x62, 0x26, 0x65, 0x0a, 0x86, 0x87,
138 | },
139 | },
140 | }
141 |
142 | func testHash(t *testing.T, h func() hash.Hash, hashName string, vectors []testVector) {
143 | for i, v := range vectors {
144 | o := Key([]byte(v.password), []byte(v.salt), v.iter, len(v.output), h)
145 | if !bytes.Equal(o, v.output) {
146 | t.Errorf("%s %d: expected %x, got %x", hashName, i, v.output, o)
147 | }
148 | }
149 | }
150 |
151 | func TestWithHMACSHA1(t *testing.T) {
152 | testHash(t, sha1.New, "SHA1", sha1TestVectors)
153 | }
154 |
155 | func TestWithHMACSHA256(t *testing.T) {
156 | testHash(t, sha256.New, "SHA256", sha256TestVectors)
157 | }
158 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/ripemd160/ripemd160.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 | // Package ripemd160 implements the RIPEMD-160 hash algorithm.
6 | package ripemd160 // import "golang.org/x/crypto/ripemd160"
7 |
8 | // RIPEMD-160 is designed by by Hans Dobbertin, Antoon Bosselaers, and Bart
9 | // Preneel with specifications available at:
10 | // http://homes.esat.kuleuven.be/~cosicart/pdf/AB-9601/AB-9601.pdf.
11 |
12 | import (
13 | "crypto"
14 | "hash"
15 | )
16 |
17 | func init() {
18 | crypto.RegisterHash(crypto.RIPEMD160, New)
19 | }
20 |
21 | // The size of the checksum in bytes.
22 | const Size = 20
23 |
24 | // The block size of the hash algorithm in bytes.
25 | const BlockSize = 64
26 |
27 | const (
28 | _s0 = 0x67452301
29 | _s1 = 0xefcdab89
30 | _s2 = 0x98badcfe
31 | _s3 = 0x10325476
32 | _s4 = 0xc3d2e1f0
33 | )
34 |
35 | // digest represents the partial evaluation of a checksum.
36 | type digest struct {
37 | s [5]uint32 // running context
38 | x [BlockSize]byte // temporary buffer
39 | nx int // index into x
40 | tc uint64 // total count of bytes processed
41 | }
42 |
43 | func (d *digest) Reset() {
44 | d.s[0], d.s[1], d.s[2], d.s[3], d.s[4] = _s0, _s1, _s2, _s3, _s4
45 | d.nx = 0
46 | d.tc = 0
47 | }
48 |
49 | // New returns a new hash.Hash computing the checksum.
50 | func New() hash.Hash {
51 | result := new(digest)
52 | result.Reset()
53 | return result
54 | }
55 |
56 | func (d *digest) Size() int { return Size }
57 |
58 | func (d *digest) BlockSize() int { return BlockSize }
59 |
60 | func (d *digest) Write(p []byte) (nn int, err error) {
61 | nn = len(p)
62 | d.tc += uint64(nn)
63 | if d.nx > 0 {
64 | n := len(p)
65 | if n > BlockSize-d.nx {
66 | n = BlockSize - d.nx
67 | }
68 | for i := 0; i < n; i++ {
69 | d.x[d.nx+i] = p[i]
70 | }
71 | d.nx += n
72 | if d.nx == BlockSize {
73 | _Block(d, d.x[0:])
74 | d.nx = 0
75 | }
76 | p = p[n:]
77 | }
78 | n := _Block(d, p)
79 | p = p[n:]
80 | if len(p) > 0 {
81 | d.nx = copy(d.x[:], p)
82 | }
83 | return
84 | }
85 |
86 | func (d0 *digest) Sum(in []byte) []byte {
87 | // Make a copy of d0 so that caller can keep writing and summing.
88 | d := *d0
89 |
90 | // Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
91 | tc := d.tc
92 | var tmp [64]byte
93 | tmp[0] = 0x80
94 | if tc%64 < 56 {
95 | d.Write(tmp[0 : 56-tc%64])
96 | } else {
97 | d.Write(tmp[0 : 64+56-tc%64])
98 | }
99 |
100 | // Length in bits.
101 | tc <<= 3
102 | for i := uint(0); i < 8; i++ {
103 | tmp[i] = byte(tc >> (8 * i))
104 | }
105 | d.Write(tmp[0:8])
106 |
107 | if d.nx != 0 {
108 | panic("d.nx != 0")
109 | }
110 |
111 | var digest [Size]byte
112 | for i, s := range d.s {
113 | digest[i*4] = byte(s)
114 | digest[i*4+1] = byte(s >> 8)
115 | digest[i*4+2] = byte(s >> 16)
116 | digest[i*4+3] = byte(s >> 24)
117 | }
118 |
119 | return append(in, digest[:]...)
120 | }
121 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/ripemd160/ripemd160_test.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 | package ripemd160
6 |
7 | // Test vectors are from:
8 | // http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
9 |
10 | import (
11 | "fmt"
12 | "io"
13 | "testing"
14 | )
15 |
16 | type mdTest struct {
17 | out string
18 | in string
19 | }
20 |
21 | var vectors = [...]mdTest{
22 | {"9c1185a5c5e9fc54612808977ee8f548b2258d31", ""},
23 | {"0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", "a"},
24 | {"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", "abc"},
25 | {"5d0689ef49d2fae572b881b123a85ffa21595f36", "message digest"},
26 | {"f71c27109c692c1b56bbdceb5b9d2865b3708dbc", "abcdefghijklmnopqrstuvwxyz"},
27 | {"12a053384a9c0c88e405a06c27dcf49ada62eb2b", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"},
28 | {"b0e20b6e3116640286ed3a87a5713079b21f5189", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"},
29 | {"9b752e45573d4b39f4dbd3323cab82bf63326bfb", "12345678901234567890123456789012345678901234567890123456789012345678901234567890"},
30 | }
31 |
32 | func TestVectors(t *testing.T) {
33 | for i := 0; i < len(vectors); i++ {
34 | tv := vectors[i]
35 | md := New()
36 | for j := 0; j < 3; j++ {
37 | if j < 2 {
38 | io.WriteString(md, tv.in)
39 | } else {
40 | io.WriteString(md, tv.in[0:len(tv.in)/2])
41 | md.Sum(nil)
42 | io.WriteString(md, tv.in[len(tv.in)/2:])
43 | }
44 | s := fmt.Sprintf("%x", md.Sum(nil))
45 | if s != tv.out {
46 | t.Fatalf("RIPEMD-160[%d](%s) = %s, expected %s", j, tv.in, s, tv.out)
47 | }
48 | md.Reset()
49 | }
50 | }
51 | }
52 |
53 | func TestMillionA(t *testing.T) {
54 | md := New()
55 | for i := 0; i < 100000; i++ {
56 | io.WriteString(md, "aaaaaaaaaa")
57 | }
58 | out := "52783243c1697bdbe16d37f97f68f08325dc1528"
59 | s := fmt.Sprintf("%x", md.Sum(nil))
60 | if s != out {
61 | t.Fatalf("RIPEMD-160 (1 million 'a') = %s, expected %s", s, out)
62 | }
63 | md.Reset()
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/ripemd160/ripemd160block.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 | // RIPEMD-160 block step.
6 | // In its own file so that a faster assembly or C version
7 | // can be substituted easily.
8 |
9 | package ripemd160
10 |
11 | // work buffer indices and roll amounts for one line
12 | var _n = [80]uint{
13 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
14 | 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
15 | 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
16 | 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
17 | 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13,
18 | }
19 |
20 | var _r = [80]uint{
21 | 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
22 | 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
23 | 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
24 | 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
25 | 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6,
26 | }
27 |
28 | // same for the other parallel one
29 | var n_ = [80]uint{
30 | 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
31 | 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
32 | 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
33 | 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
34 | 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11,
35 | }
36 |
37 | var r_ = [80]uint{
38 | 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
39 | 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
40 | 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
41 | 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
42 | 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11,
43 | }
44 |
45 | func _Block(md *digest, p []byte) int {
46 | n := 0
47 | var x [16]uint32
48 | var alpha, beta uint32
49 | for len(p) >= BlockSize {
50 | a, b, c, d, e := md.s[0], md.s[1], md.s[2], md.s[3], md.s[4]
51 | aa, bb, cc, dd, ee := a, b, c, d, e
52 | j := 0
53 | for i := 0; i < 16; i++ {
54 | x[i] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24
55 | j += 4
56 | }
57 |
58 | // round 1
59 | i := 0
60 | for i < 16 {
61 | alpha = a + (b ^ c ^ d) + x[_n[i]]
62 | s := _r[i]
63 | alpha = (alpha<>(32-s)) + e
64 | beta = c<<10 | c>>22
65 | a, b, c, d, e = e, alpha, b, beta, d
66 |
67 | // parallel line
68 | alpha = aa + (bb ^ (cc | ^dd)) + x[n_[i]] + 0x50a28be6
69 | s = r_[i]
70 | alpha = (alpha<>(32-s)) + ee
71 | beta = cc<<10 | cc>>22
72 | aa, bb, cc, dd, ee = ee, alpha, bb, beta, dd
73 |
74 | i++
75 | }
76 |
77 | // round 2
78 | for i < 32 {
79 | alpha = a + (b&c | ^b&d) + x[_n[i]] + 0x5a827999
80 | s := _r[i]
81 | alpha = (alpha<>(32-s)) + e
82 | beta = c<<10 | c>>22
83 | a, b, c, d, e = e, alpha, b, beta, d
84 |
85 | // parallel line
86 | alpha = aa + (bb&dd | cc&^dd) + x[n_[i]] + 0x5c4dd124
87 | s = r_[i]
88 | alpha = (alpha<>(32-s)) + ee
89 | beta = cc<<10 | cc>>22
90 | aa, bb, cc, dd, ee = ee, alpha, bb, beta, dd
91 |
92 | i++
93 | }
94 |
95 | // round 3
96 | for i < 48 {
97 | alpha = a + (b | ^c ^ d) + x[_n[i]] + 0x6ed9eba1
98 | s := _r[i]
99 | alpha = (alpha<>(32-s)) + e
100 | beta = c<<10 | c>>22
101 | a, b, c, d, e = e, alpha, b, beta, d
102 |
103 | // parallel line
104 | alpha = aa + (bb | ^cc ^ dd) + x[n_[i]] + 0x6d703ef3
105 | s = r_[i]
106 | alpha = (alpha<>(32-s)) + ee
107 | beta = cc<<10 | cc>>22
108 | aa, bb, cc, dd, ee = ee, alpha, bb, beta, dd
109 |
110 | i++
111 | }
112 |
113 | // round 4
114 | for i < 64 {
115 | alpha = a + (b&d | c&^d) + x[_n[i]] + 0x8f1bbcdc
116 | s := _r[i]
117 | alpha = (alpha<>(32-s)) + e
118 | beta = c<<10 | c>>22
119 | a, b, c, d, e = e, alpha, b, beta, d
120 |
121 | // parallel line
122 | alpha = aa + (bb&cc | ^bb&dd) + x[n_[i]] + 0x7a6d76e9
123 | s = r_[i]
124 | alpha = (alpha<>(32-s)) + ee
125 | beta = cc<<10 | cc>>22
126 | aa, bb, cc, dd, ee = ee, alpha, bb, beta, dd
127 |
128 | i++
129 | }
130 |
131 | // round 5
132 | for i < 80 {
133 | alpha = a + (b ^ (c | ^d)) + x[_n[i]] + 0xa953fd4e
134 | s := _r[i]
135 | alpha = (alpha<>(32-s)) + e
136 | beta = c<<10 | c>>22
137 | a, b, c, d, e = e, alpha, b, beta, d
138 |
139 | // parallel line
140 | alpha = aa + (bb ^ cc ^ dd) + x[n_[i]]
141 | s = r_[i]
142 | alpha = (alpha<>(32-s)) + ee
143 | beta = cc<<10 | cc>>22
144 | aa, bb, cc, dd, ee = ee, alpha, bb, beta, dd
145 |
146 | i++
147 | }
148 |
149 | // combine results
150 | dd += c + md.s[1]
151 | md.s[1] = md.s[2] + d + ee
152 | md.s[2] = md.s[3] + e + aa
153 | md.s[3] = md.s[4] + a + bb
154 | md.s[4] = md.s[0] + b + cc
155 | md.s[0] = dd
156 |
157 | p = p[BlockSize:]
158 | n += BlockSize
159 | }
160 | return n
161 | }
162 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/scrypt/scrypt_test.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 | package scrypt
6 |
7 | import (
8 | "bytes"
9 | "testing"
10 | )
11 |
12 | type testVector struct {
13 | password string
14 | salt string
15 | N, r, p int
16 | output []byte
17 | }
18 |
19 | var good = []testVector{
20 | {
21 | "password",
22 | "salt",
23 | 2, 10, 10,
24 | []byte{
25 | 0x48, 0x2c, 0x85, 0x8e, 0x22, 0x90, 0x55, 0xe6, 0x2f,
26 | 0x41, 0xe0, 0xec, 0x81, 0x9a, 0x5e, 0xe1, 0x8b, 0xdb,
27 | 0x87, 0x25, 0x1a, 0x53, 0x4f, 0x75, 0xac, 0xd9, 0x5a,
28 | 0xc5, 0xe5, 0xa, 0xa1, 0x5f,
29 | },
30 | },
31 | {
32 | "password",
33 | "salt",
34 | 16, 100, 100,
35 | []byte{
36 | 0x88, 0xbd, 0x5e, 0xdb, 0x52, 0xd1, 0xdd, 0x0, 0x18,
37 | 0x87, 0x72, 0xad, 0x36, 0x17, 0x12, 0x90, 0x22, 0x4e,
38 | 0x74, 0x82, 0x95, 0x25, 0xb1, 0x8d, 0x73, 0x23, 0xa5,
39 | 0x7f, 0x91, 0x96, 0x3c, 0x37,
40 | },
41 | },
42 | {
43 | "this is a long \000 password",
44 | "and this is a long \000 salt",
45 | 16384, 8, 1,
46 | []byte{
47 | 0xc3, 0xf1, 0x82, 0xee, 0x2d, 0xec, 0x84, 0x6e, 0x70,
48 | 0xa6, 0x94, 0x2f, 0xb5, 0x29, 0x98, 0x5a, 0x3a, 0x09,
49 | 0x76, 0x5e, 0xf0, 0x4c, 0x61, 0x29, 0x23, 0xb1, 0x7f,
50 | 0x18, 0x55, 0x5a, 0x37, 0x07, 0x6d, 0xeb, 0x2b, 0x98,
51 | 0x30, 0xd6, 0x9d, 0xe5, 0x49, 0x26, 0x51, 0xe4, 0x50,
52 | 0x6a, 0xe5, 0x77, 0x6d, 0x96, 0xd4, 0x0f, 0x67, 0xaa,
53 | 0xee, 0x37, 0xe1, 0x77, 0x7b, 0x8a, 0xd5, 0xc3, 0x11,
54 | 0x14, 0x32, 0xbb, 0x3b, 0x6f, 0x7e, 0x12, 0x64, 0x40,
55 | 0x18, 0x79, 0xe6, 0x41, 0xae,
56 | },
57 | },
58 | {
59 | "p",
60 | "s",
61 | 2, 1, 1,
62 | []byte{
63 | 0x48, 0xb0, 0xd2, 0xa8, 0xa3, 0x27, 0x26, 0x11, 0x98,
64 | 0x4c, 0x50, 0xeb, 0xd6, 0x30, 0xaf, 0x52,
65 | },
66 | },
67 |
68 | {
69 | "",
70 | "",
71 | 16, 1, 1,
72 | []byte{
73 | 0x77, 0xd6, 0x57, 0x62, 0x38, 0x65, 0x7b, 0x20, 0x3b,
74 | 0x19, 0xca, 0x42, 0xc1, 0x8a, 0x04, 0x97, 0xf1, 0x6b,
75 | 0x48, 0x44, 0xe3, 0x07, 0x4a, 0xe8, 0xdf, 0xdf, 0xfa,
76 | 0x3f, 0xed, 0xe2, 0x14, 0x42, 0xfc, 0xd0, 0x06, 0x9d,
77 | 0xed, 0x09, 0x48, 0xf8, 0x32, 0x6a, 0x75, 0x3a, 0x0f,
78 | 0xc8, 0x1f, 0x17, 0xe8, 0xd3, 0xe0, 0xfb, 0x2e, 0x0d,
79 | 0x36, 0x28, 0xcf, 0x35, 0xe2, 0x0c, 0x38, 0xd1, 0x89,
80 | 0x06,
81 | },
82 | },
83 | {
84 | "password",
85 | "NaCl",
86 | 1024, 8, 16,
87 | []byte{
88 | 0xfd, 0xba, 0xbe, 0x1c, 0x9d, 0x34, 0x72, 0x00, 0x78,
89 | 0x56, 0xe7, 0x19, 0x0d, 0x01, 0xe9, 0xfe, 0x7c, 0x6a,
90 | 0xd7, 0xcb, 0xc8, 0x23, 0x78, 0x30, 0xe7, 0x73, 0x76,
91 | 0x63, 0x4b, 0x37, 0x31, 0x62, 0x2e, 0xaf, 0x30, 0xd9,
92 | 0x2e, 0x22, 0xa3, 0x88, 0x6f, 0xf1, 0x09, 0x27, 0x9d,
93 | 0x98, 0x30, 0xda, 0xc7, 0x27, 0xaf, 0xb9, 0x4a, 0x83,
94 | 0xee, 0x6d, 0x83, 0x60, 0xcb, 0xdf, 0xa2, 0xcc, 0x06,
95 | 0x40,
96 | },
97 | },
98 | {
99 | "pleaseletmein", "SodiumChloride",
100 | 16384, 8, 1,
101 | []byte{
102 | 0x70, 0x23, 0xbd, 0xcb, 0x3a, 0xfd, 0x73, 0x48, 0x46,
103 | 0x1c, 0x06, 0xcd, 0x81, 0xfd, 0x38, 0xeb, 0xfd, 0xa8,
104 | 0xfb, 0xba, 0x90, 0x4f, 0x8e, 0x3e, 0xa9, 0xb5, 0x43,
105 | 0xf6, 0x54, 0x5d, 0xa1, 0xf2, 0xd5, 0x43, 0x29, 0x55,
106 | 0x61, 0x3f, 0x0f, 0xcf, 0x62, 0xd4, 0x97, 0x05, 0x24,
107 | 0x2a, 0x9a, 0xf9, 0xe6, 0x1e, 0x85, 0xdc, 0x0d, 0x65,
108 | 0x1e, 0x40, 0xdf, 0xcf, 0x01, 0x7b, 0x45, 0x57, 0x58,
109 | 0x87,
110 | },
111 | },
112 | /*
113 | // Disabled: needs 1 GiB RAM and takes too long for a simple test.
114 | {
115 | "pleaseletmein", "SodiumChloride",
116 | 1048576, 8, 1,
117 | []byte{
118 | 0x21, 0x01, 0xcb, 0x9b, 0x6a, 0x51, 0x1a, 0xae, 0xad,
119 | 0xdb, 0xbe, 0x09, 0xcf, 0x70, 0xf8, 0x81, 0xec, 0x56,
120 | 0x8d, 0x57, 0x4a, 0x2f, 0xfd, 0x4d, 0xab, 0xe5, 0xee,
121 | 0x98, 0x20, 0xad, 0xaa, 0x47, 0x8e, 0x56, 0xfd, 0x8f,
122 | 0x4b, 0xa5, 0xd0, 0x9f, 0xfa, 0x1c, 0x6d, 0x92, 0x7c,
123 | 0x40, 0xf4, 0xc3, 0x37, 0x30, 0x40, 0x49, 0xe8, 0xa9,
124 | 0x52, 0xfb, 0xcb, 0xf4, 0x5c, 0x6f, 0xa7, 0x7a, 0x41,
125 | 0xa4,
126 | },
127 | },
128 | */
129 | }
130 |
131 | var bad = []testVector{
132 | {"p", "s", 0, 1, 1, nil}, // N == 0
133 | {"p", "s", 1, 1, 1, nil}, // N == 1
134 | {"p", "s", 7, 8, 1, nil}, // N is not power of 2
135 | {"p", "s", 16, maxInt / 2, maxInt / 2, nil}, // p * r too large
136 | }
137 |
138 | func TestKey(t *testing.T) {
139 | for i, v := range good {
140 | k, err := Key([]byte(v.password), []byte(v.salt), v.N, v.r, v.p, len(v.output))
141 | if err != nil {
142 | t.Errorf("%d: got unexpected error: %s", i, err)
143 | }
144 | if !bytes.Equal(k, v.output) {
145 | t.Errorf("%d: expected %x, got %x", i, v.output, k)
146 | }
147 | }
148 | for i, v := range bad {
149 | _, err := Key([]byte(v.password), []byte(v.salt), v.N, v.r, v.p, 32)
150 | if err == nil {
151 | t.Errorf("%d: expected error, got nil", i)
152 | }
153 | }
154 | }
155 |
156 | func BenchmarkKey(b *testing.B) {
157 | for i := 0; i < b.N; i++ {
158 | Key([]byte("password"), []byte("salt"), 16384, 8, 1, 64)
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/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 | state *unix.Termios
18 | }
19 |
20 | // IsTerminal returns true if the given file descriptor is a terminal.
21 | func IsTerminal(fd int) bool {
22 | _, err := unix.IoctlGetTermio(fd, unix.TCGETA)
23 | return err == nil
24 | }
25 |
26 | // ReadPassword reads a line of input from a terminal without local echo. This
27 | // is commonly used for inputting passwords and other sensitive data. The slice
28 | // returned does not include the \n.
29 | func ReadPassword(fd int) ([]byte, error) {
30 | // see also: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libast/common/uwin/getpass.c
31 | val, err := unix.IoctlGetTermios(fd, unix.TCGETS)
32 | if err != nil {
33 | return nil, err
34 | }
35 | oldState := *val
36 |
37 | newState := oldState
38 | newState.Lflag &^= syscall.ECHO
39 | newState.Lflag |= syscall.ICANON | syscall.ISIG
40 | newState.Iflag |= syscall.ICRNL
41 | err = unix.IoctlSetTermios(fd, unix.TCSETS, &newState)
42 | if err != nil {
43 | return nil, err
44 | }
45 |
46 | defer unix.IoctlSetTermios(fd, unix.TCSETS, &oldState)
47 |
48 | var buf [16]byte
49 | var ret []byte
50 | for {
51 | n, err := syscall.Read(fd, buf[:])
52 | if err != nil {
53 | return nil, err
54 | }
55 | if n == 0 {
56 | if len(ret) == 0 {
57 | return nil, io.EOF
58 | }
59 | break
60 | }
61 | if buf[n-1] == '\n' {
62 | n--
63 | }
64 | ret = append(ret, buf[:n]...)
65 | if n < len(buf) {
66 | break
67 | }
68 | }
69 |
70 | return ret, nil
71 | }
72 |
73 | // MakeRaw puts the terminal connected to the given file descriptor into raw
74 | // mode and returns the previous state of the terminal so that it can be
75 | // restored.
76 | // see http://cr.illumos.org/~webrev/andy_js/1060/
77 | func MakeRaw(fd int) (*State, error) {
78 | oldTermiosPtr, err := unix.IoctlGetTermios(fd, unix.TCGETS)
79 | if err != nil {
80 | return nil, err
81 | }
82 | oldTermios := *oldTermiosPtr
83 |
84 | newTermios := oldTermios
85 | newTermios.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON
86 | newTermios.Oflag &^= syscall.OPOST
87 | newTermios.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN
88 | newTermios.Cflag &^= syscall.CSIZE | syscall.PARENB
89 | newTermios.Cflag |= syscall.CS8
90 | newTermios.Cc[unix.VMIN] = 1
91 | newTermios.Cc[unix.VTIME] = 0
92 |
93 | if err := unix.IoctlSetTermios(fd, unix.TCSETS, &newTermios); err != nil {
94 | return nil, err
95 | }
96 |
97 | return &State{
98 | state: oldTermiosPtr,
99 | }, nil
100 | }
101 |
102 | // Restore restores the terminal connected to the given file descriptor to a
103 | // previous state.
104 | func Restore(fd int, oldState *State) error {
105 | return unix.IoctlSetTermios(fd, unix.TCSETS, oldState.state)
106 | }
107 |
108 | // GetState returns the current state of a terminal which may be useful to
109 | // restore the terminal after a signal.
110 | func GetState(fd int) (*State, error) {
111 | oldTermiosPtr, err := unix.IoctlGetTermios(fd, unix.TCGETS)
112 | if err != nil {
113 | return nil, err
114 | }
115 |
116 | return &State{
117 | state: oldTermiosPtr,
118 | }, nil
119 | }
120 |
121 | // GetSize returns the dimensions of the given terminal.
122 | func GetSize(fd int) (width, height int, err error) {
123 | ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
124 | if err != nil {
125 | return 0, 0, err
126 | }
127 | return int(ws.Col), int(ws.Row), nil
128 | }
129 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/view/account.go:
--------------------------------------------------------------------------------
1 | package view
2 |
3 | import (
4 | "fmt"
5 | "sync"
6 | "time"
7 | ui "github.com/aiportal/termui"
8 | "gowallet/wallet"
9 | )
10 |
11 | type AccountView struct {
12 | GridView
13 | walletActiveRow int
14 | Data interface{}
15 | }
16 |
17 | func NewAccountView(ws []*wallet.Wallet) (v *AccountView) {
18 | v = new(AccountView)
19 | v.controls = []*GridViewControl{
20 | v.ctrlTitleBar(),
21 | v.ctrlWallets(ws),
22 | v.ctrlMenu(),
23 | }
24 | v.rows = []*ui.Row{
25 | ui.NewRow(ui.NewCol(12, 0, v.controls[0].Element.(ui.GridBufferer))),
26 | ui.NewRow(ui.NewCol(12, 0, v.controls[1].Element.(ui.GridBufferer))),
27 | ui.NewRow(ui.NewCol(12, 0, v.controls[2].Element.(ui.GridBufferer))),
28 | }
29 | return
30 | }
31 |
32 | func (v *AccountView) ctrlTitleBar() *GridViewControl {
33 | c := ui.NewGauge()
34 | c.Label = "GoWallet"
35 | c.Percent = 100
36 | c.Height = 3
37 | c.Border = false
38 | c.BarColor = ui.ColorBlue
39 | c.PercentColorHighlighted = ui.ColorYellow | ui.AttrBold
40 | return NewGridViewControl("title", c, nil)
41 | }
42 |
43 | // {Type:keyboard Path:/sys/kbd/v From:termbox To: Data:{KeyStr:v} Time:1501936747}
44 | // {Type:window Path:/sys/wnd/resize From:termbox To: Data:{Width:97 Height:18} Time:1501937946}
45 | func (v *AccountView) ctrlWallets(ws []*wallet.Wallet) *GridViewControl {
46 | rows := make([][]string, len(ws)+2)
47 | rows[0] = []string{"No", "Address", "Balance"}
48 | for i, w := range ws {
49 | rows[i+1] = []string{
50 | fmt.Sprintf("%d", w.No),
51 | w.Address,
52 | "loading...",
53 | }
54 | }
55 | maxRow := len(rows) - 1
56 | rows[maxRow] = []string{"", "Total", "computing..."}
57 | time.AfterFunc(time.Second, func() {
58 | v.loadBalance(ws, rows[1:])
59 | v.Update()
60 | })
61 |
62 | activeRow := 1
63 | activeRowFg := ui.ColorWhite | ui.AttrBold
64 | activeRowBg := ui.ColorGreen
65 |
66 | t := ui.NewTable()
67 | t.Rows = rows
68 | t.Height = 14
69 | t.FgColor = ui.ColorGreen
70 | t.BgColor = ui.ColorDefault
71 | t.TextAlign = ui.AlignRight
72 | t.Separator = false
73 | t.Analysis()
74 | t.FgColors[0] = ui.ColorGreen | ui.AttrBold | ui.AttrUnderline
75 | t.FgColors[1] = activeRowFg
76 | t.BgColors[1] = activeRowBg
77 | t.FgColors[maxRow] = ui.ColorGreen | ui.AttrBold
78 |
79 | m := make(HandlerMap)
80 | m["sys/kbd/"] = func(ui.Event) {
81 | count := len(t.FgColors) - 1
82 | for i := 1; i < count; i++ {
83 | t.FgColors[i] = t.FgColor
84 | t.BgColors[i] = t.BgColor
85 | }
86 | if activeRow > 1 {
87 | activeRow -= 1
88 | }
89 | t.FgColors[activeRow] = activeRowFg
90 | t.BgColors[activeRow] = activeRowBg
91 | v.Update()
92 | }
93 | m["sys/kbd/"] = func(ui.Event) {
94 | count := len(t.FgColors) - 2
95 | for i := 1; i < count; i++ {
96 | t.FgColors[i] = t.FgColor
97 | t.BgColors[i] = t.BgColor
98 | }
99 | if activeRow < count {
100 | activeRow += 1
101 | }
102 | t.FgColors[activeRow] = activeRowFg
103 | t.BgColors[activeRow] = activeRowBg
104 | v.Update()
105 | }
106 | m["sys/kbd/"] = func(ui.Event) {
107 | w := ws[activeRow-1]
108 | v.Data = w.Address
109 | ui.StopLoop()
110 | }
111 | return NewGridViewControl("wallets", t, m)
112 | }
113 |
114 | func (v *AccountView) loadBalance(ws []*wallet.Wallet, rows [][]string) {
115 | var wg sync.WaitGroup
116 | for i, w := range ws {
117 | wg.Add(1)
118 | go func(i int, w *wallet.Wallet) {
119 | defer wg.Done()
120 | w.LoadBalance()
121 | if w.Balance != nil {
122 | if w.Balance.Value() > 0 {
123 | rows[i][2] = fmt.Sprintf("%s", w.Balance.FmtBtc())
124 | } else {
125 | rows[i][2] = fmt.Sprintf("%s", w.Balance.FmtBtc())
126 | }
127 | } else {
128 | rows[i][2] = "Unkown"
129 | }
130 | v.Update()
131 | }(i, w)
132 | }
133 | wg.Wait()
134 |
135 | total := uint64(0)
136 | for _, w := range ws {
137 | if w.Balance != nil {
138 | total += w.Balance.Value()
139 | }
140 | }
141 | balance := wallet.NewBalance(total)
142 | rows[len(rows)-1][2] = balance.FmtBtc()
143 | v.Update()
144 | }
145 |
146 | func (v *AccountView) ctrlMenu() *GridViewControl {
147 |
148 | const AccountMenuFmt = "" +
149 | " [V](fg-bold,fg-underline)anity " +
150 | " [S](fg-bold,fg-underline)pend " +
151 | " [P](fg-bold,fg-underline)assword " +
152 | " [E](fg-bold,fg-underline)xport " +
153 | " [Q](fg-bold,fg-underline)uit "
154 |
155 | c := ui.NewPar(AccountMenuFmt)
156 | c.BorderTop = false
157 | c.BorderBottom = false
158 | c.Height = 1
159 | c.TextFgColor = ui.ColorMagenta
160 | c.TextBgColor = ui.ColorBlue
161 | c.Bg = ui.ColorBlue
162 |
163 | m := make(HandlerMap)
164 | m["sys/kbd/v"] = func(ui.Event) {
165 | v.Data = "vanity"
166 | ui.StopLoop()
167 | }
168 | m["sys/kbd/s"] = func(ui.Event) {
169 | v.Data = "spend"
170 | ui.StopLoop()
171 | }
172 | m["sys/kbd/p"] = func(ui.Event) {
173 | v.Data = "password"
174 | ui.StopLoop()
175 | }
176 | m["sys/kbd/e"] = func(ui.Event) {
177 | v.Data = "export"
178 | ui.StopLoop()
179 | }
180 | m["sys/kbd/q"] = func(ui.Event) {
181 | v.Data = "quit"
182 | ui.StopLoop()
183 | }
184 | return NewGridViewControl("menu", c, m)
185 | }
186 |
--------------------------------------------------------------------------------
/view/grid.go:
--------------------------------------------------------------------------------
1 | package view
2 |
3 | import (
4 | ui "github.com/aiportal/termui"
5 | )
6 |
7 | type GridView struct {
8 | controls []*GridViewControl
9 | rows []*ui.Row
10 | }
11 |
12 | func (v *GridView) Show() {
13 | if err := ui.Init(); err != nil {
14 | panic(err)
15 | }
16 | defer ui.Close()
17 |
18 | // build layout
19 | ui.Body.AddRows(v.rows...)
20 |
21 | ui.Body.Align()
22 | ui.Clear()
23 | ui.Render(ui.Body)
24 |
25 | for _, c := range v.controls {
26 | if c.Handlers == nil {
27 | continue
28 | }
29 | for k, v := range c.Handlers {
30 | ui.Handle(k, v)
31 | }
32 | }
33 |
34 | ui.Handle("sys/wnd/resize", func(e ui.Event) {
35 | evt := e.Data.(ui.EvtWnd)
36 | ui.Body.Width = evt.Width
37 | ui.Body.Align()
38 | ui.Clear()
39 | ui.Render(ui.Body)
40 | })
41 |
42 | ui.Loop()
43 | }
44 |
45 | func (v *GridView) Update() {
46 | ui.Body.Align()
47 | ui.Clear()
48 | ui.Render(ui.Body)
49 | }
50 |
51 | func (v *GridView) Control(name string) *GridViewControl {
52 | for _, c := range v.controls {
53 | if c.Name == name {
54 | return c
55 | }
56 | }
57 | return nil
58 | }
59 |
60 | type HandlerMap map[string]func(ui.Event)
61 |
62 | type GridViewControl struct {
63 | Name string
64 | Element interface{}
65 | Handlers HandlerMap
66 | Data interface{}
67 | }
68 |
69 | func NewGridViewControl(name string, element ui.GridBufferer, handlers HandlerMap) *GridViewControl {
70 | c := new(GridViewControl)
71 | c.Name = name
72 | c.Element = element
73 | c.Handlers = handlers
74 | return c
75 | }
76 |
--------------------------------------------------------------------------------
/view/param.go:
--------------------------------------------------------------------------------
1 | package view
2 |
3 | import (
4 | "encoding/hex"
5 | "errors"
6 | "os"
7 | "regexp"
8 |
9 | "github.com/fatih/color"
10 | "golang.org/x/crypto/ssh/terminal"
11 | )
12 |
13 | const (
14 | createWalletTip = `
15 | Creating wallet...
16 |
17 | `
18 | createSecretPrompt = "Enter secret phrase:"
19 | createSecretAgain = "Enter secret again:"
20 | createSaltePrompt = "Enter salt phrase:"
21 | createSalteAgain = "Enter salt again:"
22 |
23 | createErrSecretLength = "Secret at least 16 characters."
24 | createErrSaltLength = "Salt at least 16 characters."
25 | createErrSecretStrength = "Secret should containing uppercase letters, lowercase letters, numbers, and special characters."
26 | createErrInconsistencies = "Two input inconsistencies"
27 | )
28 |
29 | var ErrInput = errors.New("input error")
30 |
31 | type WalletParam struct {
32 | Secret string
33 | Salt string
34 | }
35 |
36 | func (wp *WalletParam) SecretBytes() []byte {
37 | return wp.escapeHexString(wp.Secret)
38 | }
39 |
40 | func (wp *WalletParam) SaltBytes() []byte{
41 | return wp.escapeHexString(wp.Salt)
42 | }
43 |
44 | func InputNewParameters(chance uint32) (wp *WalletParam, err error) {
45 |
46 | color.HiYellow(createWalletTip)
47 |
48 | wp = new(WalletParam)
49 | for i := uint32(0); i < chance; i++ {
50 | if err = wp.inputSecret(); err == nil {
51 | break
52 | }
53 | }
54 | if err != nil {
55 | return
56 | }
57 | for i := uint32(0); i < chance; i++ {
58 | if err = wp.inputSalt(); err == nil {
59 | break
60 | }
61 | }
62 | return
63 | }
64 |
65 | func (wp *WalletParam) inputSecret() (err error) {
66 |
67 | state, err := terminal.MakeRaw(int(os.Stdin.Fd()))
68 | if err != nil {
69 | return
70 | }
71 | t := terminal.NewTerminal(os.Stdin, "")
72 | defer terminal.Restore(int(os.Stdin.Fd()), state)
73 |
74 | // Secret
75 | print(createSecretPrompt)
76 | secret1, err := t.ReadPassword("")
77 | if err != nil {
78 | return
79 | }
80 | println("")
81 | if len(wp.escapeHexString(secret1)) < 16 {
82 | color.HiRed(createErrSecretLength)
83 | err = ErrInput
84 | return
85 | }
86 | if !wp.checkSecretStrength(secret1) {
87 | color.HiRed(createErrSecretStrength)
88 | err = ErrInput
89 | return
90 | }
91 |
92 | // Secret again
93 | print(createSecretAgain)
94 | secret2, err := t.ReadPassword("")
95 | if err != nil {
96 | return
97 | }
98 | println("")
99 | if secret1 != secret2 {
100 | color.HiRed(createErrInconsistencies)
101 | err = ErrInput
102 | return
103 | }
104 |
105 | wp.Secret = secret1
106 | return
107 | }
108 |
109 | func (wp *WalletParam) inputSalt() (err error) {
110 |
111 | state, err := terminal.MakeRaw(int(os.Stdin.Fd()))
112 | if err != nil {
113 | return
114 | }
115 | t := terminal.NewTerminal(os.Stdin, "")
116 | defer terminal.Restore(int(os.Stdin.Fd()), state)
117 |
118 | // Salt
119 | print(createSaltePrompt)
120 | salt1, err := t.ReadPassword("")
121 | if err != nil {
122 | return
123 | }
124 | println("")
125 | if len(wp.escapeHexString(salt1)) < 6 {
126 | color.HiRed(createErrSaltLength)
127 | err = ErrInput
128 | return
129 | }
130 |
131 | // Salt again
132 | print(createSalteAgain)
133 | salt2, err := t.ReadPassword("")
134 | if err != nil {
135 | return
136 | }
137 | println("")
138 | if salt1 != salt2 {
139 | color.HiRed(createErrInconsistencies)
140 | err = ErrInput
141 | return
142 | }
143 |
144 | wp.Salt = salt1
145 | return
146 | }
147 |
148 | // Converts a string like "\xF0" or "\x0f" into a byte
149 | func (wp *WalletParam) escapeHexString(str string) []byte {
150 |
151 | r, _ := regexp.Compile("\\\\x[0-9A-Fa-f]{2}")
152 | exists := r.MatchString(str)
153 | if !exists {
154 | return []byte(str)
155 | }
156 |
157 | key := r.ReplaceAllFunc([]byte(str), func(s []byte) []byte {
158 | v, _ := hex.DecodeString(string(s[2:]))
159 | return v
160 | })
161 |
162 | return key
163 | }
164 |
165 | //Check secret strength
166 | func (wp *WalletParam) checkSecretStrength(secret string) bool {
167 | number, _ := regexp.MatchString("[0-9]+", secret)
168 | lower, _ := regexp.MatchString("[a-z]+", secret)
169 | upper, _ := regexp.MatchString("[A-Z]+", secret)
170 | special, _ := regexp.MatchString("[^0-9a-zA-Z ]", secret)
171 | return number && lower && upper && special
172 | }
173 |
--------------------------------------------------------------------------------
/view/param_test.go:
--------------------------------------------------------------------------------
1 | package view
2 |
3 | import (
4 | "testing"
5 | "bytes"
6 | )
7 |
8 | func TestWalletParam(t *testing.T) {
9 | ts_data := [] struct {
10 | Secret string
11 | SecretBytes []byte
12 | Salt string
13 | SaltBytes []byte
14 | }{
15 | {
16 | Secret: `https://github.com/\x0aiport\x0al`,
17 | SecretBytes: append([]byte(`https://github.com/`), 0x0a, 'i', 'p', 'o', 'r', 't', 0x0a, 'l'),
18 | Salt: `gowall\x0et`,
19 | SaltBytes: append([]byte("gowall"), 0x0e, 't'),
20 | },
21 | {
22 | Secret: `www.aiportal.\x0n\x0et`,
23 | SecretBytes: append([]byte(`www.aiportal.\x0n`), 0x0e, 't'),
24 | Salt: `gow\x0all\x0et`,
25 | SaltBytes: []byte{'g', 'o', 'w', 0x0a, 'l', 'l', 0x0e, 't'},
26 | },
27 | }
28 |
29 | for _, v := range ts_data {
30 | wp := WalletParam { Secret:v.Secret, Salt:v.Salt }
31 | if !bytes.Equal(wp.SecretBytes(), v.SecretBytes) {
32 | t.Fatal("hex escape fail")
33 | }
34 | if !bytes.Equal(wp.SaltBytes(), v.SaltBytes) {
35 | t.Fatal("hex escape fail")
36 | }
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/view/splash.go:
--------------------------------------------------------------------------------
1 | package view
2 |
3 | import (
4 | ui "github.com/aiportal/termui"
5 | )
6 |
7 | func rowBlank(height int) *ui.Row {
8 | blank := ui.NewBlock()
9 | blank.Height = height
10 | blank.Border = false
11 | return ui.NewRow(ui.NewCol(12, 0, blank))
12 | }
13 |
14 | func rowTitle() *ui.Row {
15 | const splashTitleFmt = " \n GoWallet \n "
16 |
17 | title := ui.NewPar(splashTitleFmt)
18 | title.Height = 4
19 | title.Border = false
20 | title.TextFgColor = ui.ColorYellow | ui.AttrBold
21 | title.TextBgColor = ui.ColorBlue
22 | return ui.NewRow(ui.NewCol(3, 5, title))
23 | }
24 |
25 | func rowEnter() *ui.Row {
26 | const splashEnterFmt = " Press to continue."
27 |
28 | enter := ui.NewPar(splashEnterFmt)
29 | enter.Height = 2
30 | enter.Border = false
31 | enter.TextFgColor = ui.ColorRed | ui.AttrBold
32 | return ui.NewRow(ui.NewCol(12, 0, enter))
33 | }
34 |
35 | func rowStartTip() *ui.Row {
36 | const splashTipFmt = `
37 | GoWallet is a safe brain wallet for bitcoin.
38 | It uses a secret phrase and a salt phrase to generate wallets.
39 |
40 | It is recommended that use a more complex secret and put it on paper.
41 | It's also recommended that keep your salt in mind.`
42 |
43 | tip := ui.NewPar(splashTipFmt)
44 | tip.Height = 8
45 | tip.Border = false
46 | tip.TextFgColor = ui.ColorGreen | ui.AttrBold
47 | return ui.NewRow(ui.NewCol(12, 0, tip))
48 | }
49 |
50 | func rowProjectUrl() *ui.Row {
51 | const splashAddrFmt = " Project address: [https://github.com/aiportal/gowallet](fg-bold,fg-underline)"
52 |
53 | addr := ui.NewPar(splashAddrFmt)
54 | addr.Height = 2
55 | addr.Border = false
56 | addr.TextFgColor = ui.ColorWhite
57 | return ui.NewRow(ui.NewCol(12, 0, addr))
58 | }
59 |
60 | func rowCreateTip() *ui.Row {
61 | const splashCreateTipFmt = `
62 | Secret phrase at least 16 characters.
63 | Salt phrase at least 6 characters.
64 |
65 | Secret phrases should contain uppercase letters, lowercase letters, numbers, and special characters.
66 |
67 | Both secret phrases and salt phrases can use hexadecimal notation such as \xff or \xFF to represent a character.`
68 |
69 | tip := ui.NewPar(splashCreateTipFmt)
70 | tip.Height = 10
71 | tip.Border = false
72 | tip.TextFgColor = ui.ColorGreen | ui.AttrBold
73 | return ui.NewRow(ui.NewCol(12, 0, tip))
74 | }
75 |
76 | func rowCreateEnter() *ui.Row {
77 | const splashCreateNextFmt = " Press to create a wallet."
78 |
79 | next := ui.NewPar(splashCreateNextFmt)
80 | next.Height = 2
81 | next.Border = false
82 | next.TextFgColor = ui.ColorRed | ui.AttrBold
83 | return ui.NewRow(ui.NewCol(12, 0, next))
84 | }
85 |
86 | type SplashView []*ui.Row
87 |
88 | var SplashStartView = SplashView{ rowBlank(2), rowTitle(), rowStartTip(), rowProjectUrl(), rowEnter() }
89 | var SplashCreateView = SplashView{ rowBlank(2), rowTitle(), rowCreateTip(), rowCreateEnter() }
90 |
91 | func ShowSplashView(rows SplashView) {
92 | if err := ui.Init(); err != nil {
93 | panic(err)
94 | }
95 | defer ui.Close()
96 |
97 | // build layout
98 | ui.Body.AddRows(rows...)
99 |
100 | ui.Body.Align()
101 | ui.Clear()
102 | ui.Render(ui.Body)
103 |
104 | ui.Handle("sys/kbd/", func(ui.Event) {
105 | ui.StopLoop()
106 | })
107 |
108 | ui.Handle("/timer/1s", func(e ui.Event) {
109 | ui.Body.Width = ui.TermWidth()
110 | ui.Body.Align()
111 | ui.Clear()
112 | ui.Render(ui.Body)
113 | })
114 |
115 | ui.Loop()
116 | }
117 |
--------------------------------------------------------------------------------
/view/tip.go:
--------------------------------------------------------------------------------
1 | package view
2 |
3 | import (
4 | ui "github.com/aiportal/termui"
5 | "strings"
6 | "fmt"
7 | )
8 |
9 | func NewTipView(name string) (view *GridView) {
10 |
11 | if strings.HasPrefix(name, "1") {
12 | view = createTransTipView(name)
13 | return
14 | }
15 | switch name {
16 | case "vanity":
17 | view = createVanityTipView()
18 | case "password":
19 | view = createPasswordTipView()
20 | case "spend":
21 | view = createSpendTipView()
22 | case "export":
23 | view = createExportTipView()
24 | }
25 | return
26 | }
27 |
28 | func createTransTipView(address string) (view *GridView) {
29 | var splashTipFmt = fmt.Sprintf(`
30 | List transactions for address: [%s](bg-blue,fg-underline).
31 |
32 | This feature is not yet implemented.
33 |
34 | Your donation can accelerate the progress of project development.`, address)
35 |
36 | tip := ui.NewPar(splashTipFmt)
37 | tip.Height = 8
38 | tip.Border = false
39 | tip.TextFgColor = ui.ColorGreen | ui.AttrBold
40 |
41 | rowTip := ui.NewRow(ui.NewCol(12, 0, tip))
42 | view = new(GridView)
43 | view.rows = []*ui.Row{ rowBlank(2), rowTitle(), rowTip, rowProjectUrl(), rowEnter() }
44 | return
45 | }
46 |
47 | func createVanityTipView() (view *GridView) {
48 | const splashTipFmt = `
49 | Find [vainty address](bg-blue) in child wallets.
50 |
51 | This feature is not yet implemented.
52 |
53 | Your donation can accelerate the progress of project development.`
54 |
55 | tip := ui.NewPar(splashTipFmt)
56 | tip.Height = 8
57 | tip.Border = false
58 | tip.TextFgColor = ui.ColorGreen | ui.AttrBold
59 |
60 | rowTip := ui.NewRow(ui.NewCol(12, 0, tip))
61 | view = new(GridView)
62 | view.rows = []*ui.Row{ rowBlank(2), rowTitle(), rowTip, rowProjectUrl(), rowEnter() }
63 | return
64 | }
65 |
66 | func createPasswordTipView() (view *GridView) {
67 | const splashTipFmt = `
68 | Create or change [login password](bg-blue) for GoWallet.
69 |
70 | This feature is not yet implemented.
71 |
72 | Your donation can accelerate the progress of project development.`
73 |
74 | tip := ui.NewPar(splashTipFmt)
75 | tip.Height = 8
76 | tip.Border = false
77 | tip.TextFgColor = ui.ColorGreen | ui.AttrBold
78 |
79 | rowTip := ui.NewRow(ui.NewCol(12, 0, tip))
80 | view = new(GridView)
81 | view.rows = []*ui.Row{ rowBlank(2), rowTitle(), rowTip, rowProjectUrl(), rowEnter() }
82 | return
83 | }
84 |
85 | func createSpendTipView() (view *GridView) {
86 | const splashTipFmt = `
87 | [Send Bitcoin](bg-blue) to other addresses.
88 |
89 | This feature is not yet implemented.
90 |
91 | Your donation can accelerate the progress of project development.`
92 |
93 | tip := ui.NewPar(splashTipFmt)
94 | tip.Height = 8
95 | tip.Border = false
96 | tip.TextFgColor = ui.ColorGreen | ui.AttrBold
97 |
98 | rowTip := ui.NewRow(ui.NewCol(12, 0, tip))
99 | view = new(GridView)
100 | view.rows = []*ui.Row{ rowBlank(2), rowTitle(), rowTip, rowProjectUrl(), rowEnter() }
101 | return
102 | }
103 |
104 | func createExportTipView() (view *GridView) {
105 | const splashTipFmt = `
106 | Export Wallets [private key and address](bg-blue) to a plain text file.
107 |
108 | This feature is not yet implemented.
109 |
110 | Your donation can accelerate the progress of project development.`
111 |
112 | tip := ui.NewPar(splashTipFmt)
113 | tip.Height = 8
114 | tip.Border = false
115 | tip.TextFgColor = ui.ColorGreen | ui.AttrBold
116 |
117 | rowTip := ui.NewRow(ui.NewCol(12, 0, tip))
118 | view = new(GridView)
119 | view.rows = []*ui.Row{ rowBlank(2), rowTitle(), rowTip, rowProjectUrl(), rowEnter() }
120 | return
121 | }
122 |
--------------------------------------------------------------------------------
/wallet/account_test.go:
--------------------------------------------------------------------------------
1 | package wallet
2 |
3 | import (
4 | "fmt"
5 | "testing"
6 | )
7 |
8 | func TestAccountCreate(t *testing.T) {
9 | ts_data := []struct {
10 | Secret string
11 | Salt string
12 | PrivateKey string
13 | PublicKey string
14 | }{
15 | {
16 | Secret: "https://github.com/aiportal",
17 | Salt: "gowallet",
18 | PrivateKey: "xprv9yADpbnN26FEeubBCZfUbF261DY8AtVZLxsDnzJCSZkcwP31Vc7ipHRozKLjHLp8LE2Pbs5K6LbS7AmnC1Mr5GsMDHBKmaabRXuq8J4ruVJ",
19 | PublicKey: "xpub6C9aE7KFrToXsPfeJbCUxNxpZFNcaMDQiBnpbNhozuHbpBNA39RyN5kHqc4WPuc5Cx7WWnXLQ2WU99AdbZfUXbe3udiEwzLsDER85NK9Pa5",
20 | },
21 | {
22 | Secret: "http://www.aiportal.net",
23 | Salt: "gowallet",
24 | PrivateKey: "xprv9yF7QXAxyFqnrsxU7reHvRW1wGYSopJdyNSoar1FkTPJUrxAWiXP2GQz9HAgEJVJh5sC5Q662aycnbmqgeT3Ygyct954m3aVntV76WPNTYF",
25 | PublicKey: "xpub6CETp2hrodQ65N2wDtBJHZSkVJNwDH2VLbNQPEQsJnvHMfHK4Fqda4jTzXykBD4Fonwf7RtAXUdZdpxCrTtc6zRmUAyMPYtNfFTBcYQYEdX",
26 | },
27 | }
28 |
29 | for _, v := range ts_data {
30 | wa, err := NewWalletAccount([]byte(v.Secret), []byte(v.Salt))
31 | if err != nil {
32 | t.Fatal(err)
33 | }
34 | if (wa.PrivateKey != v.PrivateKey) || (wa.PublicKey != v.PublicKey) {
35 | t.Fatal("account create error.")
36 | }
37 | }
38 | }
39 |
40 | // BIP32
41 | // data from: https://bip32jp.github.io/english/
42 | // uncompressed data from: https://www.bitaddress.org/bitaddress.org-v2.4-SHA1-1d5951f6a04dd5a287ac925da4e626870ee58d60.html
43 | func TestAccountWallets(t *testing.T) {
44 | ts_data := []struct {
45 | MasterKey string
46 | Wallets []Wallet
47 | }{
48 | {
49 | MasterKey: "xprv9yADpbnN26FEeubBCZfUbF261DY8AtVZLxsDnzJCSZkcwP31Vc7ipHRozKLjHLp8LE2Pbs5K6LbS7AmnC1Mr5GsMDHBKmaabRXuq8J4ruVJ",
50 | Wallets: []Wallet{
51 | {
52 | No: 0,
53 | Private: "Kx66Sn5RYLs5YkZGBhHjEdP9wAUEb9cFDGazrNNiiko2gJzsd6c4",
54 | Address: "1AS3QxQrNWSE35tqdR3QRcCzXRistNE2Za",
55 | },
56 | {
57 | No: 1,
58 | Private: "KzfnUwJiqNYrjVkCYTvWAtTjxM2jGeN25cw8SLdpZdcX2hTLfm93",
59 | Address: "14tPBNhoPV1N8FTyPJT4nyPcMKiUaVK1JL",
60 | },
61 | {
62 | No: 2,
63 | Private: "Kzn1RBUx5QtrgZsmpBxASAWioGpo4SGd8j3Ujy3wZe1r1WXBGiga",
64 | Address: "1EWJJViJfEAPECgzdXEUC3433gy6XBbQb8",
65 | },
66 | {
67 | No: 123769097,
68 | Private: "KwMsFJU9VugNPpnuZ9fyLAFCqR58e65k1jWMSsTT8tZNy2s5ohvd",
69 | Address: "1EtyNou5TPKbqwEkLBbsxEwuTyHk36TYZ2",
70 | },
71 | {
72 | No: 76909722,
73 | Private: "KxFQpy5gGg7fukpdYzDf8UtCRi9Vnm9aHDha5mn9xtf16TLPmSfA",
74 | Address: "1MZ5X7CXVUhUF6FYTe1svqbeXcA5jvCx6u",
75 | },
76 | //{
77 | // "KxvQRoZ1fkurEPsxnbGd8gSHQcZbKQVdMkdgw6pGNgzDAUZxwEtg"
78 | // "1Mh3kzqUd7Sp6MGckeDGGJNuSQTY91WWkT"
79 | //No: 999,
80 | //Private: "5JCeUphnTuYTZVHz3dK3J9Uw1pUmw1nueKwz5Z8Y8BRHoeiXVoh",
81 | //Address: "1DswXkvXkEcCsP1vwDS8B32VL2JQXtSZjZ",
82 | //},
83 | },
84 | },
85 | {
86 | MasterKey: "xprv9yF7QXAxyFqnrsxU7reHvRW1wGYSopJdyNSoar1FkTPJUrxAWiXP2GQz9HAgEJVJh5sC5Q662aycnbmqgeT3Ygyct954m3aVntV76WPNTYF",
87 | Wallets: []Wallet{
88 | {
89 | No: 0,
90 | Private: "L56WbZfTm5ayLzRLKii7KQNpXBfSGBPFAYTmaZ6t3rWxVS7s4XBB",
91 | Address: "18Qva5nNFuybzJMWU8si4fjznyADzRrKeX",
92 | },
93 | {
94 | No: 1,
95 | Private: "L2dfjPScTQ8uibT6Uu9NFMga6sD3uSZ1uWZDPem3JgvrH6srj9U4",
96 | Address: "1K4ogXK9jSo37kQkYzQARxpFuyPGhqiz9Q",
97 | },
98 | {
99 | No: 2,
100 | Private: "Kyy4yvABd1JasfSC7VzRtcqVU2jXV4Yq8j9aW9dUc5MSjhZ8AaUg",
101 | Address: "1FBvnG5igTvdADukFVYeNaiuWD6Wo2HEdq",
102 | },
103 | {
104 | No: 2376909,
105 | Private: "KxRXpZW5MYmqCJxpwizUUc5VKKRidY62oXbExy8kUFXzjMDxLMQn",
106 | Address: "1Dd88sLQiE9mPwuZTyvici8q26C64Vpcoj",
107 | },
108 | {
109 | No: 237690921,
110 | Private: "KwLx7zWwb7uLY9w8BrH35gpXnprYZi1KVHCuwfshMFr7dQm5ojSd",
111 | Address: "1LeVgU7oSkrPF53p9N9Zs7iHUfM94gewFb",
112 | },
113 | },
114 | },
115 | }
116 |
117 | for _, v := range ts_data {
118 | wa := new(WalletAccount)
119 | err := wa.generateAccount(v.MasterKey, 0)
120 | if err != nil {
121 | t.Fatal(err)
122 | }
123 |
124 | for _, tw := range v.Wallets {
125 | ws, err := wa.GenerateWallets(uint32(tw.No), 1)
126 | if err != nil {
127 | t.Fatal(err)
128 | }
129 |
130 | w := ws[0]
131 | if w.Private != tw.Private {
132 | fmt.Printf("wallet (%d): \n", w.No)
133 | fmt.Println(" " + w.Private)
134 | fmt.Println(" " + w.Address)
135 | t.Fatal("wallet private error")
136 | }
137 | if w.Address != tw.Address {
138 | fmt.Printf("wallet (%d): \n", w.No)
139 | fmt.Println(" " + w.Private)
140 | fmt.Println(" " + w.Address)
141 | t.Fatal("wallet address error")
142 | }
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/wallet/balance.go:
--------------------------------------------------------------------------------
1 | package wallet
2 |
3 | import (
4 | "fmt"
5 | )
6 |
7 | type WalletBalance struct {
8 | Satoshi uint64
9 | }
10 |
11 | func NewBalance(satoshi uint64) *WalletBalance {
12 | b := new(WalletBalance)
13 | b.Satoshi = satoshi
14 | return b
15 | }
16 |
17 | func (wb *WalletBalance) Value() uint64 {
18 | return wb.Satoshi
19 | }
20 |
21 | func (wb *WalletBalance) FmtBtc() string {
22 | satoshi := wb.Satoshi
23 |
24 | if satoshi == 0 {
25 | return "0.000 BTC"
26 | }
27 | btc := float64(satoshi) / (100 * 1000 * 1000)
28 | if satoshi%(100*1000) == 0 {
29 | return fmt.Sprintf("%.3f BTC", btc)
30 | }
31 | if satoshi%100 == 0 {
32 | return fmt.Sprintf("%.6f BTC", btc)
33 | }
34 | return fmt.Sprintf("%.8f BTC", btc)
35 | }
36 |
--------------------------------------------------------------------------------
/wallet/balance_test.go:
--------------------------------------------------------------------------------
1 | package wallet
2 |
3 | import (
4 | "testing"
5 | "fmt"
6 | )
7 |
8 | func TestBalanceFmt(t *testing.T) {
9 | ts_data := [] struct {
10 | Satoshi uint64
11 | FmtBtc string
12 | }{
13 | {Satoshi: 0, FmtBtc: "0.000 BTC"},
14 | {Satoshi: 6*100*1000*1000, FmtBtc: "6.000 BTC"},
15 | {Satoshi: 1*100*1000*1000 + 18*100*1000, FmtBtc: "1.018 BTC"},
16 | {Satoshi: 3*100*1000*1000 + 88*100, FmtBtc: "3.000088 BTC"},
17 | {Satoshi: 9*100*1000*1000 + 88, FmtBtc: "9.00000088 BTC"},
18 | {Satoshi: 18*100*1000, FmtBtc: "0.018 BTC"},
19 | {Satoshi: 88*100, FmtBtc: "0.000088 BTC"},
20 | {Satoshi: 88, FmtBtc: "0.00000088 BTC"},
21 | {Satoshi: 69259423, FmtBtc: "0.69259423 BTC"},
22 | }
23 |
24 | for _, v := range ts_data {
25 | wb := NewBalance(v.Satoshi)
26 | if wb.FmtBtc() != v.FmtBtc {
27 | fmt.Printf("satoshi: %d, %q", v.Satoshi, wb.FmtBtc())
28 | t.Fatal("fomat error")
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/wallet/bip38.go:
--------------------------------------------------------------------------------
1 | package wallet
2 |
3 | import (
4 | "crypto/sha256"
5 | "crypto/aes"
6 | "github.com/btcsuite/btcd/chaincfg"
7 | "github.com/btcsuite/btcutil"
8 | "github.com/btcsuite/btcutil/base58"
9 | "golang.org/x/crypto/scrypt"
10 | )
11 |
12 | // BIP38 encrypt implement
13 | func EncryptKey(privateWif string, passKey []byte) (encryptWif string, err error) {
14 | // TODO: test compressed private WIF
15 |
16 | wif, err := btcutil.DecodeWIF(privateWif)
17 | if err != nil {
18 | return
19 | }
20 | wif.CompressPubKey = false
21 | pub, err := btcutil.NewAddressPubKey(wif.SerializePubKey(), &chaincfg.MainNetParams)
22 | if err != nil {
23 | return
24 | }
25 | sum := checkSum([]byte(pub.EncodeAddress()))
26 | key, err := scrypt.Key(passKey, sum, 16384, 8, 8, 64)
27 | if err != nil {
28 | return
29 | }
30 |
31 | data := encrypt(wif.PrivKey.Serialize(), key[:32], key[32:])
32 | buf := append([]byte{0x01, 0x42, 0xC0}, sum...)
33 | buf = append(buf, data...)
34 | buf = append(buf, checkSum(buf)...)
35 | encryptWif = base58.Encode(buf)
36 |
37 | return
38 | }
39 |
40 | func checkSum(buf []byte) []byte {
41 | h := sha256.Sum256(buf)
42 | h = sha256.Sum256(h[:])
43 | return h[:4]
44 | }
45 |
46 | func encrypt(pk, f1, f2 []byte) []byte {
47 | c, _ := aes.NewCipher(f2)
48 |
49 | for i, _ := range f1 {
50 | f1[i] ^= pk[i]
51 | }
52 |
53 | var dst = make([]byte, 48)
54 | c.Encrypt(dst, f1[:16])
55 | c.Encrypt(dst[16:], f1[16:])
56 | dst = dst[:32]
57 |
58 | return dst
59 | }
60 |
--------------------------------------------------------------------------------
/wallet/bip38_test.go:
--------------------------------------------------------------------------------
1 | package wallet
2 |
3 | import "testing"
4 |
5 | func TestEncryptKey(t *testing.T) {
6 |
7 | testEncrypt := []struct {
8 | label string
9 | pass string
10 | wif string
11 | secret string
12 | }{
13 | {
14 | label: "normal",
15 | pass : "TestingOneTwoThree",
16 | wif : "5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR",
17 | secret : "6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg",
18 | },
19 | {
20 | label: "normal",
21 | pass: "Satoshi",
22 | wif: "5HtasZ6ofTHP6HCwTqTkLDuLQisYPah7aUnSKfC7h4hMUVw2gi5",
23 | secret: "6PRNFFkZc2NZ6dJqFfhRoFNMR9Lnyj7dYGrzdgXXVMXcxoKTePPX1dWByq",
24 | },
25 | //{
26 | // label: "compressed",
27 | // pass: "TestingOneTwoThree",
28 | // wif: "L44B5gGEpqEDRS9vVPz7QT35jcBG2r3CZwSwQ4fCewXAhAhqGVpP",
29 | // secret: "6PYNKZ1EAgYgmQfmNVamxyXVWHzK5s6DGhwP4J5o44cvXdoY7sRzhtpUeo",
30 | //},
31 | //{
32 | // label: "compressed",
33 | // pass: "Satoshi",
34 | // wif: "KwYgW8gcxj1JWJXhPSu4Fqwzfhp5Yfi42mdYmMa4XqK7NJxXUSK7",
35 | // secret: "6PYLtMnXvfG3oJde97zRyLYFZCYizPU5T3LwgdYJz1fRhh16bU7u6PPmY7",
36 | //},
37 | }
38 |
39 | for _, v := range testEncrypt {
40 | encrypt, err := EncryptKey(v.wif, []byte(v.pass))
41 | if err != nil {
42 | t.Fatal(err)
43 | }
44 | if (encrypt != v.secret) {
45 | t.Fatal(v.label)
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/wallet/file.go:
--------------------------------------------------------------------------------
1 | package wallet
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 | "io/ioutil"
7 | "os"
8 | "os/user"
9 | )
10 |
11 | const WalletFileName = ".gowallet.w02" // version 0.2
12 |
13 | // check if user wallet file exists
14 | func IsFileExists() bool {
15 | u, err := user.Current()
16 | if err != nil {
17 | return false
18 | }
19 | filename := fmt.Sprintf("%s/%s", u.HomeDir, WalletFileName)
20 | f, err := os.Stat(filename)
21 | if err != nil {
22 | return false
23 | }
24 | if f.IsDir() {
25 | return false
26 | }
27 | return true
28 | }
29 |
30 | type WalletFile struct {
31 | Wallets []*Wallet
32 | }
33 |
34 | func NewWalletFile(ws []*Wallet) *WalletFile {
35 | wf := new(WalletFile)
36 | wf.Wallets = make([]*Wallet, len(ws))
37 | for i, v := range ws {
38 | w := NewWallet(v.No, "", v.Address)
39 | wf.Wallets[i] = w
40 | }
41 | return wf
42 | }
43 |
44 | func LoadWalletFile() (wf *WalletFile, err error) {
45 | u, err := user.Current()
46 | if err != nil {
47 | return
48 | }
49 | path := fmt.Sprintf("%s/%s", u.HomeDir, WalletFileName)
50 | _, err = os.Stat(path)
51 | if err != nil {
52 | return
53 | }
54 | bs, err := ioutil.ReadFile(path)
55 | if err != nil {
56 | return
57 | }
58 | wf = new(WalletFile)
59 | err = json.Unmarshal(bs, wf)
60 | if err != nil {
61 | return
62 | }
63 | return
64 | }
65 |
66 | func (wf *WalletFile) Save() (err error) {
67 | u, err := user.Current()
68 | if err != nil {
69 | return
70 | }
71 | path := fmt.Sprintf("%s/%s", u.HomeDir, WalletFileName)
72 |
73 | bs, err := json.Marshal(wf)
74 | if err != nil {
75 | return
76 | }
77 | err = ioutil.WriteFile(path, bs, os.ModeExclusive)
78 | if err != nil {
79 | return
80 | }
81 | return
82 | }
83 | //
84 | //func (wf *WalletFile) Wallets() (ws []*Wallet) {
85 | // ws = make([]*Wallet, len(wf.wallets))
86 | // for i, v := range wf.wallets {
87 | // ws[i] = v
88 | // }
89 | // return
90 | //}
--------------------------------------------------------------------------------
/wallet/wallet.go:
--------------------------------------------------------------------------------
1 | package wallet
2 |
3 | import (
4 | "fmt"
5 | "io/ioutil"
6 | "net/http"
7 | "strconv"
8 | "time"
9 | )
10 |
11 | const (
12 | balanceRequestTimeout = 5 * time.Second
13 | )
14 |
15 | type Wallet struct {
16 | No uint32
17 | Private string
18 | Address string
19 | Balance *WalletBalance
20 | }
21 |
22 | func NewWallet(seqNum uint32, private, address string) *Wallet {
23 | w := new(Wallet)
24 | w.No = seqNum
25 | w.Private = private
26 | w.Address = address
27 | return w
28 | }
29 |
30 | func (w *Wallet) LoadBalance() (err error) {
31 | //https://blockchain.info/q/addressbalance/1DogeKd9JrUNzFaLEyWAVxCVXSvWxe6sAm
32 | //https://blockexplorer.com/api/addr/
33 | //https://www.bitgo.com/api/v1/address/
34 | //https://bitcoin.toshi.io/api/v0/addresses/
35 | //https://chain.api.btc.com/v3/address/
36 | //https://api.blocktrail.com/v1/btc/address/1NcXPMRaanz43b1kokpPuYDdk6GGDvxT2T?api_key=MY_APIKEY
37 | //https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD/balance
38 | //https://api-r.bitcoinchain.com/v1/address/1Chain4asCYNnLVbvG6pgCLGBrtzh4Lx4b
39 | //https://api.kaiko.com/v1/addresses/3Nt1smucEdFks8uYQhyGvXGBuocTcMSmsT
40 | //https://chainflyer.bitflyer.jp/v1/address/1LDWeSRJukN7zWXDBpuvB2WGsMxYE7UTnQ
41 | //https://insight.bitpay.com/api/addr/1NcXPMRaanz43b1kokpPuYDdk6GGDvxT2T/?noTxList=1
42 | //https://api.coinprism.com/v1/addresses/1dice97ECuByXAvqXpaYzSaQuPVvrtmz6
43 | //http://btc.blockr.io/api/v1/address/info/
44 |
45 | _url := fmt.Sprintf("https://blockchain.info/q/addressbalance/%s", w.Address)
46 | client := &http.Client{
47 | Timeout: balanceRequestTimeout,
48 | }
49 | resp, err := client.Get(_url)
50 | if err != nil {
51 | return
52 | }
53 | bs, err := ioutil.ReadAll(resp.Body)
54 | if err != nil {
55 | return
56 | }
57 | satoshi, err := strconv.ParseUint(string(bs), 10, 64)
58 | if err != nil {
59 | return
60 | }
61 |
62 | w.Balance = NewBalance(satoshi)
63 | return
64 | }
65 |
--------------------------------------------------------------------------------
/wallet/wallet_test.go:
--------------------------------------------------------------------------------
1 | package wallet
2 |
3 | import (
4 | "testing"
5 | "fmt"
6 | )
7 |
8 | func TestWallet(t *testing.T) {
9 | ts_data := []struct {
10 | Address string
11 | Balance uint64
12 | }{
13 | {
14 | Address: "1DogeKd9JrUNzFaLEyWAVxCVXSvWxe6sAm",
15 | Balance: 69259423,
16 | },
17 | {
18 | Address: "1Bv8dN7pemC5N3urfMDdAFReibefrBqCaK",
19 | Balance: 4524469,
20 | },
21 | {
22 | Address: "1KtWutb75LqXrAd4BkcW2hqG7SWab2xJeB",
23 | Balance: 0,
24 | },
25 | {
26 | Address: "1Brn37oiWcDoTVqeP1EzbVtCz3dJ7W1Z57",
27 | Balance: 0,
28 | },
29 | }
30 |
31 | for _, v := range ts_data {
32 | w := Wallet{Address: v.Address}
33 | err := w.LoadBalance()
34 | if err != nil {
35 | t.Fatal(err)
36 | }
37 | if w.Balance == nil {
38 | t.Fatal("load balance error")
39 | }
40 | if w.Balance.Value() != v.Balance {
41 | t.Fatal(fmt.Sprintf("Balance: %d != %d", w.Balance.Value(), v.Balance))
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------