diff --git a/tools/bbbsupervisor/go.mod b/tools/bbbsupervisor/go.mod
index e0db52fb..b1886d6d 100644
--- a/tools/bbbsupervisor/go.mod
+++ b/tools/bbbsupervisor/go.mod
@@ -5,5 +5,5 @@ go 1.13
require (
github.com/digitalbitbox/bitbox-base/middleware v0.0.0-20191204153728-1128dd782517
github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191204135529-eb28ed7e9cbd
- github.com/tidwall/gjson v1.3.4
+ github.com/tidwall/gjson v1.9.3
)
diff --git a/tools/bbbsupervisor/go.sum b/tools/bbbsupervisor/go.sum
index 66174fd1..d2a33670 100644
--- a/tools/bbbsupervisor/go.sum
+++ b/tools/bbbsupervisor/go.sum
@@ -8,9 +8,7 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/digitalbitbox/bitbox-base/middleware v0.0.0-20191204153728-1128dd782517 h1:b34ka1KKniF6hzIW+5n7sDfBhEfzzAZAiE6srtmSnDM=
@@ -34,20 +32,21 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
-github.com/tidwall/gjson v1.3.4 h1:On5waDnyKKk3SWE4EthbjjirAWXp43xx5cKCUZY1eZw=
github.com/tidwall/gjson v1.3.4/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
-github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
+github.com/tidwall/gjson v1.9.3 h1:hqzS9wAHMO+KVBBkLxYdkEeeFHuqr95GfClRLKlgK0E=
+github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
-github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
+github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
+github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
+github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
+github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -60,12 +59,9 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191104094858-e8c54fb511f6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/LICENSE b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/LICENSE
new file mode 100644
index 00000000..dc82ccf8
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/LICENSE
@@ -0,0 +1,203 @@
+ Copyright 2019 Shift Cryptosecurity AG, Switzerland. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/keys.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/keys.go
new file mode 100644
index 00000000..d9f31aa2
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/keys.go
@@ -0,0 +1,23 @@
+package redis
+
+/* This file includes the redis keys used on the BitBoxBase */
+
+// BaseRedisKey is a string representing a Redis key used in the BitBoxBase.
+type BaseRedisKey string
+
+// BitBoxBase redis keys for configuration options.
+const (
+ BaseHostname BaseRedisKey = "base:hostname"
+ TorEnabled BaseRedisKey = "tor:base:enabled"
+ MiddlewareOnion BaseRedisKey = "tor:bbbmiddleware:onion"
+ BitcoindListen BaseRedisKey = "bitcoind:listen"
+ BaseVersion BaseRedisKey = "base:version"
+ BitcoindVersion BaseRedisKey = "bitcoind:version"
+ LightningdVersion BaseRedisKey = "lightningd:version"
+ ElectrsVersion BaseRedisKey = "electrs:version"
+ MiddlewarePasswordSet BaseRedisKey = "middleware:passwordSetup"
+ MiddlewareAuth BaseRedisKey = "middleware:auth"
+ BaseSetupDone BaseRedisKey = "base:setup"
+ BaseSSHDPasswordLogin BaseRedisKey = "base:sshd:passwordlogin"
+ BitcoindIBDClearnet BaseRedisKey = "bitcoind:ibd-clearnet"
+)
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/redis.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/redis.go
new file mode 100644
index 00000000..6a097c44
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/redis.go
@@ -0,0 +1,167 @@
+// Package redis implements a communication interface with the redis server
+// running on the BitBoxBase.
+package redis
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages"
+ "github.com/gomodule/redigo/redis"
+)
+
+// Redis is an interface representing a redis Client
+type Redis interface {
+ ConvertErrorToErrorResponse(error) rpcmessages.ErrorResponse
+ GetBool(key BaseRedisKey) (bool, error)
+ GetInt(BaseRedisKey) (int, error)
+ GetString(BaseRedisKey) (string, error)
+ SetString(BaseRedisKey, string) error
+ AddToSortedSet(BaseRedisKey, int, string) error
+ RemoveFromSortedSet(BaseRedisKey, string) error
+ GetTopFromSortedSet(BaseRedisKey) (string, error)
+}
+
+// Client is a redis client
+type Client struct {
+ pool *redis.Pool
+}
+
+// NewClient returns a new redis client.
+// It does not ensure that the client has connectivity.
+func NewClient(port string) (client Client) {
+ pool := newPool(port)
+
+ err := ping(pool.Get())
+ if err != nil {
+ // If the Redis server is not reachable on middleware start up the
+ // supervisor should take over and restart (i.e. fix) the Redis server.
+ log.Printf("Warning redis server connectivity could not be established: %s", err.Error())
+ }
+ return Client{pool: pool}
+}
+
+func newPool(port string) *redis.Pool {
+ return &redis.Pool{
+ MaxIdle: 80,
+ MaxActive: 12000,
+ Dial: func() (redis.Conn, error) {
+ conn, err := redis.Dial("tcp", "localhost"+":"+port)
+ if err != nil {
+ return nil, err
+ }
+ return conn, err
+ },
+ }
+}
+
+func ping(c redis.Conn) (err error) {
+ defer func() {
+ err := c.Close()
+ if err != nil {
+ log.Println("error when closing redis connection after ping. This is not critical and we can continue running")
+ }
+ }()
+ _, err = c.Do("PING")
+ if err != nil {
+ return
+ }
+ return
+}
+
+// getConnection gets a connection from the pool
+func (c Client) getConnection() redis.Conn {
+ return c.pool.Get()
+}
+
+// GetInt gets an integer value for a given key.
+func (c Client) GetInt(key BaseRedisKey) (val int, err error) {
+ conn := c.getConnection()
+ val, err = redis.Int(conn.Do("GET", key))
+ if err != nil {
+ return -1, fmt.Errorf("could not get key %s as integer: %s", key, err.Error())
+ }
+ return val, nil
+}
+
+// GetBool gets a boolean value for a given key.
+// Internally checks if the value for the given key is set to 1.
+// If so, then true is returned, else false.
+func (c Client) GetBool(key BaseRedisKey) (val bool, err error) {
+ conn := c.getConnection()
+ valAsInt, err := redis.Int(conn.Do("GET", key))
+ if err != nil {
+ return false, fmt.Errorf("could not get key %s as boolean: %s", key, err.Error())
+ }
+ return valAsInt == 1, nil
+}
+
+// GetString gets a string for a given key.
+func (c Client) GetString(key BaseRedisKey) (val string, err error) {
+ conn := c.getConnection()
+ val, err = redis.String(conn.Do("GET", key))
+ if err != nil {
+ return "", fmt.Errorf("could not get key %s as string: %s", key, err.Error())
+ }
+ return val, nil
+}
+
+// SetString sets a string for a given key.
+func (c Client) SetString(key BaseRedisKey, value string) error {
+ conn := c.getConnection()
+ _, err := conn.Do("SET", key, value)
+ if err != nil {
+ return fmt.Errorf("could not set key %s: %s", key, err.Error())
+ }
+ return nil
+}
+
+// AddToSortedSet adds a element to a redis sorted set. The interger score
+// defines the position in the sorted set.
+//
+// Note: Redis supports double precision for scores, but that's not implemented
+// here yet. Additionally Redis supports multiple insertions in one call. That's
+// not implemented here either.
+func (c Client) AddToSortedSet(key BaseRedisKey, score int, element string) error {
+ conn := c.getConnection()
+ _, err := conn.Do("ZADD", key, score, element)
+ if err != nil {
+ return fmt.Errorf("could not ZADD key %s: %w", key, err)
+ }
+ return nil
+}
+
+// RemoveFromSortedSet removes an element from a Redis sorted set if present.
+func (c Client) RemoveFromSortedSet(key BaseRedisKey, element string) error {
+ conn := c.getConnection()
+ _, err := conn.Do("ZREM", key, element)
+ if err != nil {
+ return fmt.Errorf("could not ZREM key %s element %s: %w", key, element, err)
+ }
+ return nil
+}
+
+// GetTopFromSortedSet gets the element with the hightest score from a Redis
+// sorted set.
+func (c Client) GetTopFromSortedSet(key BaseRedisKey) (string, error) {
+ conn := c.getConnection()
+ elements, err := redis.Strings(conn.Do("ZREVRANGE", key, 0, 0))
+ if err != nil {
+ return "", fmt.Errorf("could not ZREVRANGE key %s: %w", key, err)
+ }
+ // The redis call should only ever return one element for `ZREVRANGE 0 0`
+ if len(elements) != 1 {
+ return "", fmt.Errorf("expected exactly one element, but got %d", len(elements))
+ }
+
+ return elements[0], nil
+}
+
+// ConvertErrorToErrorResponse converts an error returned by Redis to an ErrorResponse
+func (c Client) ConvertErrorToErrorResponse(err error) rpcmessages.ErrorResponse {
+ return rpcmessages.ErrorResponse{
+ Success: false,
+ Message: err.Error(),
+ Code: rpcmessages.ErrorRedisError,
+ }
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/redis_mock.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/redis_mock.go
new file mode 100644
index 00000000..8d236f45
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/redis/redis_mock.go
@@ -0,0 +1,102 @@
+package redis
+
+import (
+ "log"
+ "strconv"
+
+ "github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages"
+)
+
+// MockClient is a mock redis client
+type MockClient struct {
+ mockRedisMap map[string]string
+}
+
+// NewMockClient returns a new redis client.
+// It does not ensure that the client has connectivity.
+func NewMockClient(port string) (mockClient *MockClient) {
+ mockRedisMap := setupTestData()
+ return &MockClient{mockRedisMap: mockRedisMap}
+}
+
+// SetString sets a mock value to given key.
+func (mc *MockClient) SetString(key BaseRedisKey, value string) error {
+ mc.mockRedisMap[string(key)] = value
+ return nil
+}
+
+// GetInt gets an integer value for a given key.
+func (mc *MockClient) GetInt(key BaseRedisKey) (val int, err error) {
+ s := mc.mockRedisMap[string(key)]
+ val, err = strconv.Atoi(s)
+ return
+}
+
+// GetBool gets a boolean value for a given key.
+// Internally checks if the value for the given key is set to 1.
+// If so, then true is returned, else false.
+// GetInt gets an integer value for a given key.
+func (mc *MockClient) GetBool(key BaseRedisKey) (val bool, err error) {
+ s := mc.mockRedisMap[string(key)]
+ valAsInt, err := strconv.Atoi(s)
+ return valAsInt == 1, err
+}
+
+// AddToSortedSet is a dummy that does nothing but printing the arguments.
+func (mc *MockClient) AddToSortedSet(key BaseRedisKey, score int, element string) error {
+ log.Printf("AddToSortedSet dummy: key %q, score %q, element %q", key, score, element)
+ return nil
+}
+
+// RemoveFromSortedSet is a dummy that does nothing but printing the arguments.
+func (mc *MockClient) RemoveFromSortedSet(key BaseRedisKey, element string) error {
+ log.Printf("RemoveFromSortedSet dummy: key %q, element %q", key, element)
+ return nil
+}
+
+// GetTopFromSortedSet is a dummy that does nothing but printing the arguments.
+func (mc *MockClient) GetTopFromSortedSet(key BaseRedisKey) (string, error) {
+ log.Printf("GetTopFromSortedSet dummy: key %q", key)
+ return "dummy mock", nil
+}
+
+// GetString gets an string for a given key.
+func (mc *MockClient) GetString(key BaseRedisKey) (val string, err error) {
+ return mc.mockRedisMap[string(key)], nil
+}
+
+func setupTestData() map[string]string {
+ mockRedisMap := make(map[string]string)
+
+ // General mock data
+ mockRedisMap[string(BaseVersion)] = "0.0.1"
+ mockRedisMap[string(BaseHostname)] = "bitbox-base-redis-mock"
+ mockRedisMap[string(TorEnabled)] = "1"
+ mockRedisMap[string(BitcoindListen)] = "1"
+ mockRedisMap[string(MiddlewarePasswordSet)] = "0"
+ mockRedisMap[string(BaseSetupDone)] = "0"
+ mockRedisMap[string(MiddlewareAuth)] = `{"admin":{"password":"ICanHasPasword?","role":"admin"}}`
+
+ // Specific test values for testing util.go getBooleanFromRedis()
+ // TestGetBooleanFromRedis() in util_test.go
+ mockRedisMap["test:getBooleanFromRedis:true"] = "1"
+ mockRedisMap["test:getBooleanFromRedis:false1"] = "0"
+ mockRedisMap["test:getBooleanFromRedis:false2"] = "3"
+ mockRedisMap["test:getBooleanFromRedis:false3"] = "abc"
+
+ // Specific test values for testing util.go getStringFromRedis()
+ // TestGetStringFromRedis() in util_test.go
+ mockRedisMap["test:getStringFromRedis:abc"] = "abc"
+ mockRedisMap["test:getStringFromRedis:empty"] = ""
+
+ return mockRedisMap
+}
+
+// ConvertErrorToErrorResponse converts an error returned by Redis to an ErrorResponse
+func (mc *MockClient) ConvertErrorToErrorResponse(err error) rpcmessages.ErrorResponse {
+ return rpcmessages.ErrorResponse{
+ Success: false,
+ Message: err.Error(),
+ Code: rpcmessages.ErrorRedisError,
+ }
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages/errorcodes.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages/errorcodes.go
new file mode 100644
index 00000000..1cfb53c5
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages/errorcodes.go
@@ -0,0 +1,177 @@
+package rpcmessages
+
+// ErrorCode is a unique and short string code represeting an Error
+type ErrorCode string
+
+// JSONWebTokenInvalid is thrown when the authentication with the provided token has failed. This can happen for both an expired token and
+// if the token is invalid.
+const JSONWebTokenInvalid ErrorCode = "JSONWEBTOKEN_INVALID"
+
+const (
+
+ // ExecutableNotFound is thrown when a executable is not found.
+ // This can for example be a script (e.g. bbb-cmd.sh or bbb-config.sh) or a executable like `reboot`
+ ExecutableNotFound ErrorCode = "EXECUTABLE_NOT_FOUND"
+
+ // ErrorScriptNotSuperuser is thrown if a run scripts need to be run as superuser.
+ ErrorScriptNotSuperuser ErrorCode = "SCRIPT_NOT_RUN_AS_SUPERUSER"
+
+ // ErrorScriptIncludesNotFound is thrown when a script includes other bash functions, but the inclusion path (in the script) is invalid.
+ ErrorScriptIncludesNotFound = "SCRIPT_INCLUDES_NOT_FOUND"
+
+ // ErrorRedisError is a general Redis related error.
+ // There is no differentiation of Redis errors because the front-end most likely handles them similar.
+ ErrorRedisError ErrorCode = "REDIS_ERROR"
+
+ // ErrorPrometheusError is a general Prometheus related error.
+ // There is no differentiation of Prometheus errors because the front-end most likely handles them similar.
+ ErrorPrometheusError ErrorCode = "PROMETHEUS_ERROR"
+
+ // ErrorUnexpected is thrown when a a unknown/unhandled/unexpected error occurs.
+ // It's a catch-all error.
+ ErrorUnexpected ErrorCode = "UNEXPECTED_ERROR"
+)
+
+const (
+
+ // ErrorCmdScriptInvalidArg is thrown if the argument for the bbb-cmd.sh script is not known.
+ // Not to be confused with ErrorConfigScriptInvalidArg which is for the bbb-config.sh.
+ ErrorCmdScriptInvalidArg ErrorCode = "CMD_SCRIPT_INVALID_ARG"
+
+ /* bbb-cmd.sh flashdrive check
+ -------------------------------*/
+
+ // ErrorFlashdriveCheckMultiple is thrown if multiple USB flashdrives are found. Needs exactly one.
+ ErrorFlashdriveCheckMultiple ErrorCode = "FLASHDRIVE_CHECK_MULTI"
+ // ErrorFlashdriveCheckNone is thrown if no USB flashdrive is found.
+ ErrorFlashdriveCheckNone ErrorCode = "FLASHDRIVE_CHECK_NONE"
+
+ /* bbb-cmd.sh flashdrive mount
+ -------------------------------------*/
+
+ // ErrorFlashdriveMountNotFound is thrown if no flashdrive found on the passed .
+ ErrorFlashdriveMountNotFound ErrorCode = "FLASHDRIVE_MOUNT_NOT_FOUND"
+ // ErrorFlashdriveMountNotUnique is thrown if the passed does not uniquely identify a flashdrive.
+ ErrorFlashdriveMountNotUnique ErrorCode = "FLASHDRIVE_MOUNT_NOT_UNIQUE"
+ // ErrorFlashdriveMountNotSupported is thrown if the flashdrive is either bigger than 64GB or the filesystem is not supported.
+ ErrorFlashdriveMountNotSupported ErrorCode = "FLASHDRIVE_MOUNT_NOT_SUPPORTED"
+
+ /* bbb-cmd.sh flashdrive unmount
+ ---------------------------------*/
+
+ // ErrorFlashdriveUnmountNotMounted is thrown if there is no flashdrive to unmount at /mnt/backup.
+ ErrorFlashdriveUnmountNotMounted ErrorCode = "FLASHDRIVE_UNMOUNT_NOT_MOUNTED"
+
+ /* bbb-cmd.sh backup sysconfig
+ -------------------------------*/
+
+ // ErrorBackupSysconfigNotAMountpoint is thrown if /mnt/backup is no mountpoint. It's needed to backup the sysconfig.
+ ErrorBackupSysconfigNotAMountpoint ErrorCode = "BACKUP_SYSCONFIG_NOT_A_MOUNTPOINT"
+
+ /* bbb-cmd.sh restore sysconfig
+ --------------------------------*/
+
+ // ErrorRestoreSysconfigBackupNotFound is thrown if the backup file /mnt/backup/bbb-backup.rdb is not found.
+ ErrorRestoreSysconfigBackupNotFound ErrorCode = "RESTORE_SYSCONFIG_BACKUP_NOT_FOUND"
+
+ /* bbb-cmd.sh mender-update
+ ----------------------------*/
+
+ // ErrorMenderUpdateImageNotMenderEnabled is thrown if the image is not mender enabled.
+ ErrorMenderUpdateImageNotMenderEnabled ErrorCode = "MENDER_UPDATE_IMAGE_NOT_MENDER_ENABLED"
+
+ /* bbb-cmd.sh mender-update install
+ ------------------------------------*/
+
+ // ErrorMenderUpdateInstallFailed is thrown if `mender -install` failed.
+ ErrorMenderUpdateInstallFailed ErrorCode = "MENDER_UPDATE_INSTALL_FAILED"
+
+ // ErrorMenderUpdateNoVersion thrown if no Base image version passed to the script.
+ ErrorMenderUpdateNoVersion ErrorCode = "MENDER_UPDATE_NO_VERSION"
+
+ // ErrorMenderUpdateInvalidVersion is thrown if an invalid Base image version passed to the script.
+ ErrorMenderUpdateInvalidVersion ErrorCode = "MENDER_UPDATE_INVALID_VERSION"
+
+ // ErrorMenderUpdateAlreadyInProgress is thrown by the middleware, if an update is already in progress.
+ ErrorMenderUpdateAlreadyInProgress ErrorCode = "MENDER_UPDATE_ALREADY_IN_PROGRESS"
+
+ /* bbb-cmd.sh mender-update commit
+ -----------------------------------*/
+
+ // ErrorMenderUpdateCommitFailed is thrown if `mender -commit` failed.
+ ErrorMenderUpdateCommitFailed ErrorCode = "MENDER_UPDATE_COMMIT_FAILED"
+)
+
+const (
+
+ // ErrorConfigScriptInvalidArg is thrown if the argument for the bbb-config.sh script is not known.
+ // Not to be confused with ErrorCmdScriptInvalidArg for the bbb-cmd script.
+ ErrorConfigScriptInvalidArg ErrorCode = "CONFIG_SCRIPT_INVALID_ARG"
+
+ /* bbb-config.sh set
+ -----------------------------------*/
+
+ // ErrorSetNeedsTwoArguments is thrown if `bbb-config.sh set ` is thrown with not exactly two arguments.
+ ErrorSetNeedsTwoArguments ErrorCode = "SET_NEEDS_TWO_ARGUMENTS"
+
+ /* bbb-config.sh set bitcoin_network
+ --------------------------------------------*/
+
+ // ErrorSetBitcoinNetworkInvalidValue is thrown if the set is not "testnet" or "mainnet".
+ ErrorSetBitcoinNetworkInvalidValue ErrorCode = "SET_BITCOINETWORK_INVALID_VALUE"
+
+ /* bbb-config.sh set bitcoin_dbcache
+ ---------------------------------------------*/
+
+ // ErrorSetBitcoinDBCacheInvalidValue is thrown if the is not an integer in MB between 50 and 3000.
+ ErrorSetBitcoinDBCacheInvalidValue ErrorCode = "SET_BITCOINDBCACHE_INVALID_VALUE"
+
+ /* bbb-config.sh set hostname
+ ---------------------------------------*/
+
+ // ErrorSetHostnameInvalidValue is thrown if the is an invalid hostname according to this regex '^[a-z][a-z0-9-]{0,22}[a-z0-9]$'.
+ ErrorSetHostnameInvalidValue ErrorCode = "SET_HOSTNAME_INVALID_VALUE"
+)
+
+const (
+
+ /* bbb-systemctl.sh start-bitcoin-services
+ ---------------------------------------*/
+
+ // ErrorSystemdServiceStartFailed is thrown when a systemd service cannot be
+ // started.
+ ErrorSystemdServiceStartFailed ErrorCode = "SYSTEMD_SERVICESTART_FAILED"
+)
+
+const (
+ // ErrorInitialAuthenticationNotSuccessful is thrown if the initial authentication with default username and password is not successful.
+ ErrorInitialAuthenticationNotSuccessful ErrorCode = "INITIAL_AUTHENTICATION_NOT_SUCCESSFUL"
+
+ // ErrorAuthenticationPasswordIncorrect is thrown if the authentication is not successful.
+ ErrorAuthenticationPasswordIncorrect ErrorCode = "AUTHENTICATION_PASSWORD_INCORRECT"
+
+ // ErrorAuthenticationFailed is thrown if the authentication is not successful, because of a generic error
+ ErrorAuthenticationFailed ErrorCode = "AUTHENTICATION_FAILED"
+
+ // ErrorAuthenticationUsernameNotFound is thrown if the given username does not exist.
+ ErrorAuthenticationUsernameNotFound ErrorCode = "AUTHENTICATION_USERNAME_NOEXIST"
+)
+
+const (
+ // ErrorPasswordTooShort is thrown if the provided password is too short.
+ ErrorPasswordTooShort ErrorCode = "CHANGEPASSWORD_TOO_SHORT"
+
+ // ErrorPasswordChangeFailed is thrown if the there is an internal system error with e.g. redis or json parsing
+ ErrorPasswordChangeFailed ErrorCode = "CHANGEPASSWORD_FAILED"
+
+ // ErrorPasswordChangeUsernameNotExist is thrown if the given username does not exist
+ ErrorPasswordChangeUsernameNotExist ErrorCode = "CHANGEPASSWORD_USERNAME_NOEXIST"
+
+ // ErrorPasswordChangePasswordIncorrect is thrown is the given password does not match the bcrypted password from redis
+ ErrorPasswordChangePasswordIncorrect ErrorCode = "CHANGEPASSWORD_PASSWORD_INCORRECT"
+)
+
+const (
+ // ErrorSetLoginPasswordTooShort is thrown if the provided root password is too short.
+ ErrorSetLoginPasswordTooShort ErrorCode = "SET_LOGINPASSWORD_PASSWORD_TOO_SHORT"
+)
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages/rpcmessages.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages/rpcmessages.go
new file mode 100644
index 00000000..2b928d5f
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages/rpcmessages.go
@@ -0,0 +1,185 @@
+package rpcmessages
+
+import "fmt"
+
+/*
+Put notification constants here. Notifications for new rpc data should have the format 'OpUCanHas' + 'RPC Method Name'.
+*/
+const (
+ // OpRPCCall is prepended to every rpc response messages, to indicate that the message is rpc response and not a notification.
+ OpRPCCall = "r"
+ // OpServiceInfoChanged notifies when the GetServiceInfo data changed.
+ OpServiceInfoChanged = "s"
+ // OpBaseUpdateProgressChanged notifies when the BaseUpdateProgress changes while performing a Base Update.
+ OpBaseUpdateProgressChanged = "u"
+ // OpBaseUpdateIsAvailable notifies when a image update is available for the Base.
+ OpBaseUpdateIsAvailable = "x"
+ // OpBaseUpdateSuccess notifies when the Base image update succeeded.
+ OpBaseUpdateSuccess = "a"
+ // OpBaseUpdateFailure notifies when the Base image update failed.
+ OpBaseUpdateFailure = "b"
+)
+
+/*
+Put Incoming Args below this line. They should have the format of 'RPC Method Name' + 'Args'.
+*/
+
+// UserAuthenticateArgs is an struct that holds the arguments for the UserAuthenticate RPC call
+type UserAuthenticateArgs struct {
+ Username string
+ Password string
+}
+
+// AuthGenericRequest is a struct that acts as a generic request struct
+type AuthGenericRequest struct {
+ Token string
+}
+
+// UserChangePasswordArgs is an struct that holds the arguments for the UserChangePassword RPC call
+type UserChangePasswordArgs struct {
+ Username string
+ Password string
+ NewPassword string
+ Token string
+}
+
+// SetHostnameArgs is a struct that holds the to be set hostname
+type SetHostnameArgs struct {
+ Hostname string
+ Token string
+}
+
+// SetLoginPasswordArgs is a struct that holds the to be set login password
+type SetLoginPasswordArgs struct {
+ LoginPassword string
+ Token string
+}
+
+// ToggleSettingArgs is a generic message for settings that can be enabled or disabled
+type ToggleSettingArgs struct {
+ ToggleSetting bool
+ Token string
+}
+
+// UpdateBaseArgs is a struct that holds the Base version that should be updated to
+type UpdateBaseArgs struct {
+ Version string
+ Token string
+}
+
+/*
+Put Response structs below this line. They should have the format of 'RPC Method Name' + 'Response'.
+*/
+
+// SetupStatusResponse is the struct that gets sent by the rpc server during a SetupStatus rpc call.
+// This call is not authenticated and serves as indicator for what to show during the base setup wizzard.
+type SetupStatusResponse struct {
+ MiddlewarePasswordSet bool
+ BaseSetup bool
+}
+
+// UserAuthenticateResponse is the struct that gets sent by the rpc server during a UserAuthenticate call. It contains the session's jwt token.
+type UserAuthenticateResponse struct {
+ ErrorResponse *ErrorResponse
+ Token string
+}
+
+// GetEnvResponse is the struct that gets sent by the rpc server during a GetSystemEnv call
+type GetEnvResponse struct {
+ Network string
+ ElectrsRPCPort string
+}
+
+// UpdateInfo holds information about a available Base image update
+type UpdateInfo struct {
+ Description string `json:"description"`
+ Version string `json:"version"`
+ Severity string `json:"severity"`
+}
+
+// IsBaseUpdateAvailableResponse is returned as an response for an IsBaseUpdateAvailable RPC call.
+type IsBaseUpdateAvailableResponse struct {
+ ErrorResponse *ErrorResponse
+ UpdateAvailable bool `json:"available"`
+ UpdateInfo UpdateInfo `json:"info"`
+}
+
+// BaseUpdateState is the used to hold the current state for a Base update.
+type BaseUpdateState int
+
+// The possible values of BaseUpdateState.
+// Representing the states that can be reached in a BaseUpdate RPC call.
+const (
+ UpdateNotInProgress BaseUpdateState = iota + 1
+ UpdateDownloading
+ UpdateFailed
+ UpdateApplying
+ UpdateRebooting
+)
+
+// GetBaseUpdateProgressResponse is the response to a GetBaseUpdateProgress RPC call.
+// The app is notified over a changed middleware state calls the GetBaseUpdateProgress
+// RPC which returns GetBaseUpdateProgressResponse.
+type GetBaseUpdateProgressResponse struct {
+ ErrorResponse *ErrorResponse
+ State BaseUpdateState
+ ProgressPercentage int
+ ProgressDownloadedKiB int
+}
+
+// GetBaseInfoResponse is the struct that gets sent by the RPC server during a GetBaseInfo RPC call
+type GetBaseInfoResponse struct {
+ ErrorResponse *ErrorResponse
+ Status string `json:"status"`
+ Hostname string `json:"hostname"`
+ MiddlewareLocalIP string `json:"middlewareLocalIP"`
+ MiddlewarePort string `json:"middlewarePort"`
+ MiddlewareTorOnion string `json:"middlewareTorOnion"`
+ IsTorEnabled bool `json:"isTorEnabled"`
+ IsBitcoindListening bool `json:"isBitcoindListening"`
+ IsSSHPasswordLoginEnabled bool `json:"IsSSHPasswordLoginEnabled"`
+ FreeDiskspace int64 `json:"freeDiskspace"` // in Byte
+ TotalDiskspace int64 `json:"totalDiskspace"` // in Byte
+ BaseVersion string `json:"baseVersion"`
+ BitcoindVersion string `json:"bitcoindVersion"`
+ LightningdVersion string `json:"lightningdVersion"`
+ ElectrsVersion string `json:"electrsVersion"`
+}
+
+// GetServiceInfoResponse is the struct that gets sent by the RPC server during a GetServiceInfo RPC call
+type GetServiceInfoResponse struct {
+ ErrorResponse *ErrorResponse `json:"errorResponse"`
+ BitcoindBlocks int64 `json:"bitcoindBlocks"`
+ BitcoindHeaders int64 `json:"bitcoindHeaders"`
+ BitcoindVerificationProgress float64 `json:"bitcoindVerificationProgress"`
+ BitcoindPeers int64 `json:"bitcoindPeers"`
+ BitcoindIBD bool `json:"bitcoindIBD"`
+ LightningdBlocks int64 `json:"lightningdBlocks"`
+ LightningActiveChannels int64 `json:"lightningActiveChannels"`
+ ElectrsBlocks int64 `json:"electrsBlocks"`
+}
+
+// ErrorResponse is a generic RPC response indicating if a RPC call was successful or not.
+// It can be embedded into other RPC responses that return values.
+// In any case the ErrorResponse should be checked first, so that, if an error is returned, we ignore everything else in the response.
+type ErrorResponse struct {
+ Success bool
+ Code ErrorCode
+ Message string
+}
+
+// Error formats the ErrorResponse in the following two formats:
+// If no error occurred:
+// ErrorResponse: Success: true
+//
+// If an error occurred:
+// ErrorResponse:
+// Success: false
+// Code:
+// Message:
+func (err *ErrorResponse) Error() string {
+ if err.Success {
+ return fmt.Sprintf("ErrorResponse: Success: %t \n", err.Success)
+ }
+ return fmt.Sprintf("ErrorResponse:\n\tSuccess: %t \n\tCode: %s \n\tMessage: %s\n", err.Success, err.Code, err.Message)
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/LICENSE b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/LICENSE
new file mode 100644
index 00000000..3b3afac4
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/LICENSE
@@ -0,0 +1,211 @@
+Copyright 2018-2019 Shift Cryptosecurity AG, Switzerland. All rights reserved.
+
+The rights to all images (.svg, .png, .jpg, .ico and similar files) and
+stylesheets (.css files) in this repository are reserved for Shift Devices
+AG. If you fork this project, please change the visual appearance of your
+application so that users cannot mistake it for ours.
+
+All other files are licensed under the Apache License Version 2.0 License:
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/backup_commands.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/backup_commands.pb.go
new file mode 100644
index 00000000..8a91a9f3
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/backup_commands.pb.go
@@ -0,0 +1,361 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: backup_commands.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type CheckBackupRequest struct {
+ Silent bool `protobuf:"varint,1,opt,name=silent,proto3" json:"silent,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *CheckBackupRequest) Reset() { *m = CheckBackupRequest{} }
+func (m *CheckBackupRequest) String() string { return proto.CompactTextString(m) }
+func (*CheckBackupRequest) ProtoMessage() {}
+func (*CheckBackupRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8233e97e1da7717c, []int{0}
+}
+
+func (m *CheckBackupRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_CheckBackupRequest.Unmarshal(m, b)
+}
+func (m *CheckBackupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_CheckBackupRequest.Marshal(b, m, deterministic)
+}
+func (m *CheckBackupRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_CheckBackupRequest.Merge(m, src)
+}
+func (m *CheckBackupRequest) XXX_Size() int {
+ return xxx_messageInfo_CheckBackupRequest.Size(m)
+}
+func (m *CheckBackupRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_CheckBackupRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_CheckBackupRequest proto.InternalMessageInfo
+
+func (m *CheckBackupRequest) GetSilent() bool {
+ if m != nil {
+ return m.Silent
+ }
+ return false
+}
+
+type CheckBackupResponse struct {
+ Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *CheckBackupResponse) Reset() { *m = CheckBackupResponse{} }
+func (m *CheckBackupResponse) String() string { return proto.CompactTextString(m) }
+func (*CheckBackupResponse) ProtoMessage() {}
+func (*CheckBackupResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8233e97e1da7717c, []int{1}
+}
+
+func (m *CheckBackupResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_CheckBackupResponse.Unmarshal(m, b)
+}
+func (m *CheckBackupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_CheckBackupResponse.Marshal(b, m, deterministic)
+}
+func (m *CheckBackupResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_CheckBackupResponse.Merge(m, src)
+}
+func (m *CheckBackupResponse) XXX_Size() int {
+ return xxx_messageInfo_CheckBackupResponse.Size(m)
+}
+func (m *CheckBackupResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_CheckBackupResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_CheckBackupResponse proto.InternalMessageInfo
+
+func (m *CheckBackupResponse) GetId() string {
+ if m != nil {
+ return m.Id
+ }
+ return ""
+}
+
+// Timestamp must be in UTC
+type CreateBackupRequest struct {
+ Timestamp uint32 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ TimezoneOffset int32 `protobuf:"varint,2,opt,name=timezone_offset,json=timezoneOffset,proto3" json:"timezone_offset,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *CreateBackupRequest) Reset() { *m = CreateBackupRequest{} }
+func (m *CreateBackupRequest) String() string { return proto.CompactTextString(m) }
+func (*CreateBackupRequest) ProtoMessage() {}
+func (*CreateBackupRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8233e97e1da7717c, []int{2}
+}
+
+func (m *CreateBackupRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_CreateBackupRequest.Unmarshal(m, b)
+}
+func (m *CreateBackupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_CreateBackupRequest.Marshal(b, m, deterministic)
+}
+func (m *CreateBackupRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_CreateBackupRequest.Merge(m, src)
+}
+func (m *CreateBackupRequest) XXX_Size() int {
+ return xxx_messageInfo_CreateBackupRequest.Size(m)
+}
+func (m *CreateBackupRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_CreateBackupRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_CreateBackupRequest proto.InternalMessageInfo
+
+func (m *CreateBackupRequest) GetTimestamp() uint32 {
+ if m != nil {
+ return m.Timestamp
+ }
+ return 0
+}
+
+func (m *CreateBackupRequest) GetTimezoneOffset() int32 {
+ if m != nil {
+ return m.TimezoneOffset
+ }
+ return 0
+}
+
+type ListBackupsRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ListBackupsRequest) Reset() { *m = ListBackupsRequest{} }
+func (m *ListBackupsRequest) String() string { return proto.CompactTextString(m) }
+func (*ListBackupsRequest) ProtoMessage() {}
+func (*ListBackupsRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8233e97e1da7717c, []int{3}
+}
+
+func (m *ListBackupsRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ListBackupsRequest.Unmarshal(m, b)
+}
+func (m *ListBackupsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ListBackupsRequest.Marshal(b, m, deterministic)
+}
+func (m *ListBackupsRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ListBackupsRequest.Merge(m, src)
+}
+func (m *ListBackupsRequest) XXX_Size() int {
+ return xxx_messageInfo_ListBackupsRequest.Size(m)
+}
+func (m *ListBackupsRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_ListBackupsRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ListBackupsRequest proto.InternalMessageInfo
+
+type BackupInfo struct {
+ Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
+ Timestamp uint32 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ // uint32 timezone_offset = 3;
+ Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BackupInfo) Reset() { *m = BackupInfo{} }
+func (m *BackupInfo) String() string { return proto.CompactTextString(m) }
+func (*BackupInfo) ProtoMessage() {}
+func (*BackupInfo) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8233e97e1da7717c, []int{4}
+}
+
+func (m *BackupInfo) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BackupInfo.Unmarshal(m, b)
+}
+func (m *BackupInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BackupInfo.Marshal(b, m, deterministic)
+}
+func (m *BackupInfo) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BackupInfo.Merge(m, src)
+}
+func (m *BackupInfo) XXX_Size() int {
+ return xxx_messageInfo_BackupInfo.Size(m)
+}
+func (m *BackupInfo) XXX_DiscardUnknown() {
+ xxx_messageInfo_BackupInfo.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BackupInfo proto.InternalMessageInfo
+
+func (m *BackupInfo) GetId() string {
+ if m != nil {
+ return m.Id
+ }
+ return ""
+}
+
+func (m *BackupInfo) GetTimestamp() uint32 {
+ if m != nil {
+ return m.Timestamp
+ }
+ return 0
+}
+
+func (m *BackupInfo) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+type ListBackupsResponse struct {
+ Info []*BackupInfo `protobuf:"bytes,1,rep,name=info,proto3" json:"info,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ListBackupsResponse) Reset() { *m = ListBackupsResponse{} }
+func (m *ListBackupsResponse) String() string { return proto.CompactTextString(m) }
+func (*ListBackupsResponse) ProtoMessage() {}
+func (*ListBackupsResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8233e97e1da7717c, []int{5}
+}
+
+func (m *ListBackupsResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ListBackupsResponse.Unmarshal(m, b)
+}
+func (m *ListBackupsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ListBackupsResponse.Marshal(b, m, deterministic)
+}
+func (m *ListBackupsResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ListBackupsResponse.Merge(m, src)
+}
+func (m *ListBackupsResponse) XXX_Size() int {
+ return xxx_messageInfo_ListBackupsResponse.Size(m)
+}
+func (m *ListBackupsResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_ListBackupsResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ListBackupsResponse proto.InternalMessageInfo
+
+func (m *ListBackupsResponse) GetInfo() []*BackupInfo {
+ if m != nil {
+ return m.Info
+ }
+ return nil
+}
+
+type RestoreBackupRequest struct {
+ Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
+ Timestamp uint32 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ TimezoneOffset int32 `protobuf:"varint,3,opt,name=timezone_offset,json=timezoneOffset,proto3" json:"timezone_offset,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *RestoreBackupRequest) Reset() { *m = RestoreBackupRequest{} }
+func (m *RestoreBackupRequest) String() string { return proto.CompactTextString(m) }
+func (*RestoreBackupRequest) ProtoMessage() {}
+func (*RestoreBackupRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8233e97e1da7717c, []int{6}
+}
+
+func (m *RestoreBackupRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_RestoreBackupRequest.Unmarshal(m, b)
+}
+func (m *RestoreBackupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_RestoreBackupRequest.Marshal(b, m, deterministic)
+}
+func (m *RestoreBackupRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_RestoreBackupRequest.Merge(m, src)
+}
+func (m *RestoreBackupRequest) XXX_Size() int {
+ return xxx_messageInfo_RestoreBackupRequest.Size(m)
+}
+func (m *RestoreBackupRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_RestoreBackupRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_RestoreBackupRequest proto.InternalMessageInfo
+
+func (m *RestoreBackupRequest) GetId() string {
+ if m != nil {
+ return m.Id
+ }
+ return ""
+}
+
+func (m *RestoreBackupRequest) GetTimestamp() uint32 {
+ if m != nil {
+ return m.Timestamp
+ }
+ return 0
+}
+
+func (m *RestoreBackupRequest) GetTimezoneOffset() int32 {
+ if m != nil {
+ return m.TimezoneOffset
+ }
+ return 0
+}
+
+func init() {
+ proto.RegisterType((*CheckBackupRequest)(nil), "CheckBackupRequest")
+ proto.RegisterType((*CheckBackupResponse)(nil), "CheckBackupResponse")
+ proto.RegisterType((*CreateBackupRequest)(nil), "CreateBackupRequest")
+ proto.RegisterType((*ListBackupsRequest)(nil), "ListBackupsRequest")
+ proto.RegisterType((*BackupInfo)(nil), "BackupInfo")
+ proto.RegisterType((*ListBackupsResponse)(nil), "ListBackupsResponse")
+ proto.RegisterType((*RestoreBackupRequest)(nil), "RestoreBackupRequest")
+}
+
+func init() { proto.RegisterFile("backup_commands.proto", fileDescriptor_8233e97e1da7717c) }
+
+var fileDescriptor_8233e97e1da7717c = []byte{
+ // 261 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x41, 0x4b, 0xc3, 0x40,
+ 0x10, 0x85, 0x49, 0x1a, 0x8b, 0x9d, 0x62, 0x85, 0x4d, 0x95, 0x1c, 0x04, 0xc3, 0x82, 0x98, 0x83,
+ 0xf4, 0xa0, 0xe0, 0x0f, 0xb0, 0x27, 0x41, 0x14, 0xf6, 0x2c, 0x94, 0x6d, 0x32, 0xc1, 0xa5, 0xee,
+ 0x6e, 0xcc, 0x4c, 0x2f, 0xfe, 0x7a, 0x71, 0x1b, 0x29, 0x09, 0xb9, 0x78, 0xdb, 0x79, 0xf3, 0x78,
+ 0xdf, 0xcc, 0x2c, 0x5c, 0x6c, 0x75, 0xb9, 0xdb, 0x37, 0x9b, 0xd2, 0x5b, 0xab, 0x5d, 0x45, 0xab,
+ 0xa6, 0xf5, 0xec, 0xe5, 0x1d, 0x88, 0xf5, 0x07, 0x96, 0xbb, 0xa7, 0xd0, 0x55, 0xf8, 0xb5, 0x47,
+ 0x62, 0x71, 0x09, 0x53, 0x32, 0x9f, 0xe8, 0x38, 0x8b, 0xf2, 0xa8, 0x38, 0x55, 0x5d, 0x25, 0x6f,
+ 0x20, 0xed, 0xb9, 0xa9, 0xf1, 0x8e, 0x50, 0x2c, 0x20, 0x36, 0x55, 0xb0, 0xce, 0x54, 0x6c, 0x2a,
+ 0xf9, 0x0e, 0xe9, 0xba, 0x45, 0xcd, 0xd8, 0x4f, 0xbd, 0x82, 0x19, 0x1b, 0x8b, 0xc4, 0xda, 0x36,
+ 0xc1, 0x7d, 0xa6, 0x8e, 0x82, 0xb8, 0x85, 0xf3, 0xdf, 0xe2, 0xdb, 0x3b, 0xdc, 0xf8, 0xba, 0x26,
+ 0xe4, 0x2c, 0xce, 0xa3, 0xe2, 0x44, 0x2d, 0xfe, 0xe4, 0xb7, 0xa0, 0xca, 0x25, 0x88, 0x17, 0x43,
+ 0x7c, 0xc8, 0xa6, 0x2e, 0x5c, 0xbe, 0x02, 0x1c, 0x94, 0x67, 0x57, 0xfb, 0xe1, 0x44, 0x7d, 0x74,
+ 0x3c, 0x44, 0x0b, 0x48, 0x9c, 0xb6, 0x98, 0x25, 0xc1, 0x1f, 0xde, 0xf2, 0x11, 0xd2, 0x1e, 0xa5,
+ 0x5b, 0xf5, 0x1a, 0x12, 0xe3, 0x6a, 0x9f, 0x45, 0xf9, 0xa4, 0x98, 0xdf, 0xcf, 0x57, 0x47, 0xa6,
+ 0x0a, 0x0d, 0x69, 0x61, 0xa9, 0x90, 0xd8, 0xb7, 0x83, 0xe5, 0xff, 0x37, 0xd1, 0xc8, 0x31, 0x26,
+ 0x63, 0xc7, 0xd8, 0x4e, 0xc3, 0x37, 0x3e, 0xfc, 0x04, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x46, 0xe2,
+ 0xe4, 0xdf, 0x01, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/backup_commands.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/backup_commands.proto
new file mode 100644
index 00000000..deeb5bb6
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/backup_commands.proto
@@ -0,0 +1,51 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// This file is named backup_commands to avoid conflicting header files with top-most backup.proto
+
+syntax = "proto3";
+
+message CheckBackupRequest {
+ bool silent = 1;
+}
+
+message CheckBackupResponse {
+ string id = 1;
+}
+
+// Timestamp must be in UTC
+message CreateBackupRequest {
+ uint32 timestamp = 1;
+ int32 timezone_offset = 2;
+}
+
+message ListBackupsRequest {
+}
+
+message BackupInfo {
+ string id = 1;
+ uint32 timestamp = 2;
+ // uint32 timezone_offset = 3;
+ string name = 4;
+}
+
+message ListBackupsResponse {
+ repeated BackupInfo info = 1;
+}
+
+message RestoreBackupRequest {
+ string id = 1;
+ uint32 timestamp = 2;
+ int32 timezone_offset = 3;
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitbox02_system.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitbox02_system.pb.go
new file mode 100644
index 00000000..520278c3
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitbox02_system.pb.go
@@ -0,0 +1,449 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: bitbox02_system.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type InsertRemoveSDCardRequest_SDCardAction int32
+
+const (
+ InsertRemoveSDCardRequest_REMOVE_CARD InsertRemoveSDCardRequest_SDCardAction = 0
+ InsertRemoveSDCardRequest_INSERT_CARD InsertRemoveSDCardRequest_SDCardAction = 1
+)
+
+var InsertRemoveSDCardRequest_SDCardAction_name = map[int32]string{
+ 0: "REMOVE_CARD",
+ 1: "INSERT_CARD",
+}
+
+var InsertRemoveSDCardRequest_SDCardAction_value = map[string]int32{
+ "REMOVE_CARD": 0,
+ "INSERT_CARD": 1,
+}
+
+func (x InsertRemoveSDCardRequest_SDCardAction) String() string {
+ return proto.EnumName(InsertRemoveSDCardRequest_SDCardAction_name, int32(x))
+}
+
+func (InsertRemoveSDCardRequest_SDCardAction) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{4, 0}
+}
+
+type CheckSDCardRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *CheckSDCardRequest) Reset() { *m = CheckSDCardRequest{} }
+func (m *CheckSDCardRequest) String() string { return proto.CompactTextString(m) }
+func (*CheckSDCardRequest) ProtoMessage() {}
+func (*CheckSDCardRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{0}
+}
+
+func (m *CheckSDCardRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_CheckSDCardRequest.Unmarshal(m, b)
+}
+func (m *CheckSDCardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_CheckSDCardRequest.Marshal(b, m, deterministic)
+}
+func (m *CheckSDCardRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_CheckSDCardRequest.Merge(m, src)
+}
+func (m *CheckSDCardRequest) XXX_Size() int {
+ return xxx_messageInfo_CheckSDCardRequest.Size(m)
+}
+func (m *CheckSDCardRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_CheckSDCardRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_CheckSDCardRequest proto.InternalMessageInfo
+
+type CheckSDCardResponse struct {
+ Inserted bool `protobuf:"varint,1,opt,name=inserted,proto3" json:"inserted,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *CheckSDCardResponse) Reset() { *m = CheckSDCardResponse{} }
+func (m *CheckSDCardResponse) String() string { return proto.CompactTextString(m) }
+func (*CheckSDCardResponse) ProtoMessage() {}
+func (*CheckSDCardResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{1}
+}
+
+func (m *CheckSDCardResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_CheckSDCardResponse.Unmarshal(m, b)
+}
+func (m *CheckSDCardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_CheckSDCardResponse.Marshal(b, m, deterministic)
+}
+func (m *CheckSDCardResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_CheckSDCardResponse.Merge(m, src)
+}
+func (m *CheckSDCardResponse) XXX_Size() int {
+ return xxx_messageInfo_CheckSDCardResponse.Size(m)
+}
+func (m *CheckSDCardResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_CheckSDCardResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_CheckSDCardResponse proto.InternalMessageInfo
+
+func (m *CheckSDCardResponse) GetInserted() bool {
+ if m != nil {
+ return m.Inserted
+ }
+ return false
+}
+
+type DeviceInfoRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *DeviceInfoRequest) Reset() { *m = DeviceInfoRequest{} }
+func (m *DeviceInfoRequest) String() string { return proto.CompactTextString(m) }
+func (*DeviceInfoRequest) ProtoMessage() {}
+func (*DeviceInfoRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{2}
+}
+
+func (m *DeviceInfoRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_DeviceInfoRequest.Unmarshal(m, b)
+}
+func (m *DeviceInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_DeviceInfoRequest.Marshal(b, m, deterministic)
+}
+func (m *DeviceInfoRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_DeviceInfoRequest.Merge(m, src)
+}
+func (m *DeviceInfoRequest) XXX_Size() int {
+ return xxx_messageInfo_DeviceInfoRequest.Size(m)
+}
+func (m *DeviceInfoRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_DeviceInfoRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_DeviceInfoRequest proto.InternalMessageInfo
+
+type DeviceInfoResponse struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Initialized bool `protobuf:"varint,2,opt,name=initialized,proto3" json:"initialized,omitempty"`
+ Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
+ MnemonicPassphraseEnabled bool `protobuf:"varint,4,opt,name=mnemonic_passphrase_enabled,json=mnemonicPassphraseEnabled,proto3" json:"mnemonic_passphrase_enabled,omitempty"`
+ MonotonicIncrementsRemaining uint32 `protobuf:"varint,5,opt,name=monotonic_increments_remaining,json=monotonicIncrementsRemaining,proto3" json:"monotonic_increments_remaining,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *DeviceInfoResponse) Reset() { *m = DeviceInfoResponse{} }
+func (m *DeviceInfoResponse) String() string { return proto.CompactTextString(m) }
+func (*DeviceInfoResponse) ProtoMessage() {}
+func (*DeviceInfoResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{3}
+}
+
+func (m *DeviceInfoResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_DeviceInfoResponse.Unmarshal(m, b)
+}
+func (m *DeviceInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_DeviceInfoResponse.Marshal(b, m, deterministic)
+}
+func (m *DeviceInfoResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_DeviceInfoResponse.Merge(m, src)
+}
+func (m *DeviceInfoResponse) XXX_Size() int {
+ return xxx_messageInfo_DeviceInfoResponse.Size(m)
+}
+func (m *DeviceInfoResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_DeviceInfoResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_DeviceInfoResponse proto.InternalMessageInfo
+
+func (m *DeviceInfoResponse) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+func (m *DeviceInfoResponse) GetInitialized() bool {
+ if m != nil {
+ return m.Initialized
+ }
+ return false
+}
+
+func (m *DeviceInfoResponse) GetVersion() string {
+ if m != nil {
+ return m.Version
+ }
+ return ""
+}
+
+func (m *DeviceInfoResponse) GetMnemonicPassphraseEnabled() bool {
+ if m != nil {
+ return m.MnemonicPassphraseEnabled
+ }
+ return false
+}
+
+func (m *DeviceInfoResponse) GetMonotonicIncrementsRemaining() uint32 {
+ if m != nil {
+ return m.MonotonicIncrementsRemaining
+ }
+ return 0
+}
+
+type InsertRemoveSDCardRequest struct {
+ Action InsertRemoveSDCardRequest_SDCardAction `protobuf:"varint,1,opt,name=action,proto3,enum=InsertRemoveSDCardRequest_SDCardAction" json:"action,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *InsertRemoveSDCardRequest) Reset() { *m = InsertRemoveSDCardRequest{} }
+func (m *InsertRemoveSDCardRequest) String() string { return proto.CompactTextString(m) }
+func (*InsertRemoveSDCardRequest) ProtoMessage() {}
+func (*InsertRemoveSDCardRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{4}
+}
+
+func (m *InsertRemoveSDCardRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_InsertRemoveSDCardRequest.Unmarshal(m, b)
+}
+func (m *InsertRemoveSDCardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_InsertRemoveSDCardRequest.Marshal(b, m, deterministic)
+}
+func (m *InsertRemoveSDCardRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_InsertRemoveSDCardRequest.Merge(m, src)
+}
+func (m *InsertRemoveSDCardRequest) XXX_Size() int {
+ return xxx_messageInfo_InsertRemoveSDCardRequest.Size(m)
+}
+func (m *InsertRemoveSDCardRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_InsertRemoveSDCardRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_InsertRemoveSDCardRequest proto.InternalMessageInfo
+
+func (m *InsertRemoveSDCardRequest) GetAction() InsertRemoveSDCardRequest_SDCardAction {
+ if m != nil {
+ return m.Action
+ }
+ return InsertRemoveSDCardRequest_REMOVE_CARD
+}
+
+type ResetRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ResetRequest) Reset() { *m = ResetRequest{} }
+func (m *ResetRequest) String() string { return proto.CompactTextString(m) }
+func (*ResetRequest) ProtoMessage() {}
+func (*ResetRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{5}
+}
+
+func (m *ResetRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ResetRequest.Unmarshal(m, b)
+}
+func (m *ResetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ResetRequest.Marshal(b, m, deterministic)
+}
+func (m *ResetRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ResetRequest.Merge(m, src)
+}
+func (m *ResetRequest) XXX_Size() int {
+ return xxx_messageInfo_ResetRequest.Size(m)
+}
+func (m *ResetRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_ResetRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ResetRequest proto.InternalMessageInfo
+
+type SetDeviceLanguageRequest struct {
+ Language string `protobuf:"bytes,1,opt,name=language,proto3" json:"language,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SetDeviceLanguageRequest) Reset() { *m = SetDeviceLanguageRequest{} }
+func (m *SetDeviceLanguageRequest) String() string { return proto.CompactTextString(m) }
+func (*SetDeviceLanguageRequest) ProtoMessage() {}
+func (*SetDeviceLanguageRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{6}
+}
+
+func (m *SetDeviceLanguageRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SetDeviceLanguageRequest.Unmarshal(m, b)
+}
+func (m *SetDeviceLanguageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SetDeviceLanguageRequest.Marshal(b, m, deterministic)
+}
+func (m *SetDeviceLanguageRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SetDeviceLanguageRequest.Merge(m, src)
+}
+func (m *SetDeviceLanguageRequest) XXX_Size() int {
+ return xxx_messageInfo_SetDeviceLanguageRequest.Size(m)
+}
+func (m *SetDeviceLanguageRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_SetDeviceLanguageRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SetDeviceLanguageRequest proto.InternalMessageInfo
+
+func (m *SetDeviceLanguageRequest) GetLanguage() string {
+ if m != nil {
+ return m.Language
+ }
+ return ""
+}
+
+type SetDeviceNameRequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SetDeviceNameRequest) Reset() { *m = SetDeviceNameRequest{} }
+func (m *SetDeviceNameRequest) String() string { return proto.CompactTextString(m) }
+func (*SetDeviceNameRequest) ProtoMessage() {}
+func (*SetDeviceNameRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{7}
+}
+
+func (m *SetDeviceNameRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SetDeviceNameRequest.Unmarshal(m, b)
+}
+func (m *SetDeviceNameRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SetDeviceNameRequest.Marshal(b, m, deterministic)
+}
+func (m *SetDeviceNameRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SetDeviceNameRequest.Merge(m, src)
+}
+func (m *SetDeviceNameRequest) XXX_Size() int {
+ return xxx_messageInfo_SetDeviceNameRequest.Size(m)
+}
+func (m *SetDeviceNameRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_SetDeviceNameRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SetDeviceNameRequest proto.InternalMessageInfo
+
+func (m *SetDeviceNameRequest) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+type SetPasswordRequest struct {
+ Entropy []byte `protobuf:"bytes,1,opt,name=entropy,proto3" json:"entropy,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SetPasswordRequest) Reset() { *m = SetPasswordRequest{} }
+func (m *SetPasswordRequest) String() string { return proto.CompactTextString(m) }
+func (*SetPasswordRequest) ProtoMessage() {}
+func (*SetPasswordRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_7bdc3d941a731b17, []int{8}
+}
+
+func (m *SetPasswordRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SetPasswordRequest.Unmarshal(m, b)
+}
+func (m *SetPasswordRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SetPasswordRequest.Marshal(b, m, deterministic)
+}
+func (m *SetPasswordRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SetPasswordRequest.Merge(m, src)
+}
+func (m *SetPasswordRequest) XXX_Size() int {
+ return xxx_messageInfo_SetPasswordRequest.Size(m)
+}
+func (m *SetPasswordRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_SetPasswordRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SetPasswordRequest proto.InternalMessageInfo
+
+func (m *SetPasswordRequest) GetEntropy() []byte {
+ if m != nil {
+ return m.Entropy
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterEnum("InsertRemoveSDCardRequest_SDCardAction", InsertRemoveSDCardRequest_SDCardAction_name, InsertRemoveSDCardRequest_SDCardAction_value)
+ proto.RegisterType((*CheckSDCardRequest)(nil), "CheckSDCardRequest")
+ proto.RegisterType((*CheckSDCardResponse)(nil), "CheckSDCardResponse")
+ proto.RegisterType((*DeviceInfoRequest)(nil), "DeviceInfoRequest")
+ proto.RegisterType((*DeviceInfoResponse)(nil), "DeviceInfoResponse")
+ proto.RegisterType((*InsertRemoveSDCardRequest)(nil), "InsertRemoveSDCardRequest")
+ proto.RegisterType((*ResetRequest)(nil), "ResetRequest")
+ proto.RegisterType((*SetDeviceLanguageRequest)(nil), "SetDeviceLanguageRequest")
+ proto.RegisterType((*SetDeviceNameRequest)(nil), "SetDeviceNameRequest")
+ proto.RegisterType((*SetPasswordRequest)(nil), "SetPasswordRequest")
+}
+
+func init() { proto.RegisterFile("bitbox02_system.proto", fileDescriptor_7bdc3d941a731b17) }
+
+var fileDescriptor_7bdc3d941a731b17 = []byte{
+ // 399 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x5f, 0x6f, 0xd3, 0x30,
+ 0x14, 0xc5, 0x09, 0x8c, 0xad, 0xdc, 0x95, 0x01, 0xde, 0x90, 0xbc, 0x81, 0x50, 0xe5, 0x17, 0x26,
+ 0x1e, 0xaa, 0x31, 0x24, 0x1e, 0x41, 0x53, 0xdb, 0x87, 0x48, 0x30, 0x90, 0x83, 0x78, 0x8d, 0x9c,
+ 0xe4, 0xd2, 0x59, 0xd4, 0xd7, 0xc1, 0xf6, 0x0a, 0xe3, 0x43, 0xf0, 0x41, 0xf9, 0x14, 0x28, 0xce,
+ 0x1f, 0x5a, 0x09, 0xde, 0x72, 0x8e, 0x7e, 0xf7, 0xc8, 0xf7, 0x9e, 0xc0, 0xe3, 0x42, 0x87, 0xc2,
+ 0xfe, 0x38, 0x3b, 0xcf, 0xfd, 0x8d, 0x0f, 0x68, 0xa6, 0xb5, 0xb3, 0xc1, 0x8a, 0x23, 0x60, 0xb3,
+ 0x2b, 0x2c, 0xbf, 0x66, 0xf3, 0x99, 0x72, 0x95, 0xc4, 0x6f, 0xd7, 0xe8, 0x83, 0x78, 0x09, 0x87,
+ 0x5b, 0xae, 0xaf, 0x2d, 0x79, 0x64, 0x27, 0x30, 0xd2, 0xe4, 0xd1, 0x05, 0xac, 0x78, 0x32, 0x49,
+ 0x4e, 0x47, 0x72, 0xd0, 0xe2, 0x10, 0x1e, 0xcd, 0x71, 0xad, 0x4b, 0x4c, 0xe9, 0x8b, 0xed, 0x73,
+ 0x7e, 0x27, 0xc0, 0x36, 0xdd, 0x2e, 0x87, 0xc1, 0x0e, 0x29, 0x83, 0x31, 0xe3, 0x9e, 0x8c, 0xdf,
+ 0x6c, 0x02, 0xfb, 0x9a, 0x74, 0xd0, 0x6a, 0xa5, 0x7f, 0x62, 0xc5, 0x6f, 0xc7, 0xf8, 0x4d, 0x8b,
+ 0x71, 0xd8, 0x5b, 0xa3, 0xf3, 0xda, 0x12, 0xbf, 0x13, 0x07, 0x7b, 0xc9, 0xde, 0xc0, 0x13, 0x43,
+ 0x68, 0x2c, 0xe9, 0x32, 0xaf, 0x95, 0xf7, 0xf5, 0x95, 0x53, 0x1e, 0x73, 0x24, 0x55, 0xac, 0xb0,
+ 0xe2, 0x3b, 0x31, 0xeb, 0xb8, 0x47, 0x3e, 0x0e, 0xc4, 0xa2, 0x05, 0xd8, 0x1c, 0x9e, 0x19, 0x4b,
+ 0x36, 0xc4, 0x00, 0x4d, 0xa5, 0x43, 0x83, 0x14, 0x7c, 0xee, 0xd0, 0x28, 0x4d, 0x9a, 0x96, 0xfc,
+ 0xee, 0x24, 0x39, 0xbd, 0x2f, 0x9f, 0x0e, 0x54, 0x3a, 0x40, 0xb2, 0x67, 0xc4, 0xaf, 0x04, 0x8e,
+ 0xd3, 0x78, 0x0e, 0x89, 0xc6, 0xae, 0x71, 0xeb, 0xa4, 0xec, 0x2d, 0xec, 0xaa, 0x32, 0x34, 0x8f,
+ 0x6f, 0xb6, 0x3e, 0x38, 0x7f, 0x3e, 0xfd, 0x2f, 0x3b, 0x6d, 0xd5, 0x45, 0xc4, 0x65, 0x37, 0x26,
+ 0xce, 0x60, 0xbc, 0xe9, 0xb3, 0x07, 0xb0, 0x2f, 0x17, 0xef, 0x3f, 0x7c, 0x5e, 0xe4, 0xb3, 0x0b,
+ 0x39, 0x7f, 0x78, 0xab, 0x31, 0xd2, 0xcb, 0x6c, 0x21, 0x3f, 0xb5, 0x46, 0x22, 0x0e, 0x60, 0x2c,
+ 0xd1, 0x63, 0xe8, 0xdb, 0x78, 0x0d, 0x3c, 0xc3, 0xd0, 0xf6, 0xf1, 0x4e, 0xd1, 0xf2, 0x5a, 0x2d,
+ 0xb1, 0x7f, 0xde, 0x09, 0x8c, 0x56, 0x9d, 0xd5, 0xd5, 0x32, 0x68, 0xf1, 0x02, 0x8e, 0x86, 0xb9,
+ 0x4b, 0x65, 0x86, 0x99, 0x7f, 0xd4, 0x28, 0xa6, 0xc0, 0x32, 0x0c, 0xcd, 0x89, 0xbf, 0xdb, 0xbf,
+ 0xcb, 0x73, 0xd8, 0x43, 0x0a, 0xce, 0xd6, 0x37, 0x11, 0x1e, 0xcb, 0x5e, 0x16, 0xbb, 0xf1, 0x37,
+ 0x7c, 0xf5, 0x27, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xf7, 0xc9, 0x54, 0x9f, 0x02, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitbox02_system.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitbox02_system.proto
new file mode 100644
index 00000000..5b20a2bd
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitbox02_system.proto
@@ -0,0 +1,55 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+message CheckSDCardRequest {
+}
+
+message CheckSDCardResponse {
+ bool inserted = 1;
+}
+
+message DeviceInfoRequest {
+}
+
+message DeviceInfoResponse {
+ string name = 1;
+ bool initialized = 2;
+ string version = 3;
+ bool mnemonic_passphrase_enabled = 4;
+ uint32 monotonic_increments_remaining = 5;
+}
+
+message InsertRemoveSDCardRequest {
+ enum SDCardAction {
+ REMOVE_CARD = 0;
+ INSERT_CARD = 1;
+ }
+ SDCardAction action = 1;
+}
+
+message ResetRequest {}
+
+message SetDeviceLanguageRequest {
+ string language = 1;
+}
+
+message SetDeviceNameRequest {
+ string name = 1;
+}
+
+message SetPasswordRequest {
+ bytes entropy = 1;
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitboxbase.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitboxbase.pb.go
new file mode 100644
index 00000000..6073ef88
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitboxbase.pb.go
@@ -0,0 +1,555 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: bitboxbase.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type BitBoxBaseHeartbeatRequest_StateCode int32
+
+const (
+ BitBoxBaseHeartbeatRequest_IDLE BitBoxBaseHeartbeatRequest_StateCode = 0
+ BitBoxBaseHeartbeatRequest_WORKING BitBoxBaseHeartbeatRequest_StateCode = 1
+ BitBoxBaseHeartbeatRequest_WARNING BitBoxBaseHeartbeatRequest_StateCode = 2
+ BitBoxBaseHeartbeatRequest_ERROR BitBoxBaseHeartbeatRequest_StateCode = 3
+)
+
+var BitBoxBaseHeartbeatRequest_StateCode_name = map[int32]string{
+ 0: "IDLE",
+ 1: "WORKING",
+ 2: "WARNING",
+ 3: "ERROR",
+}
+
+var BitBoxBaseHeartbeatRequest_StateCode_value = map[string]int32{
+ "IDLE": 0,
+ "WORKING": 1,
+ "WARNING": 2,
+ "ERROR": 3,
+}
+
+func (x BitBoxBaseHeartbeatRequest_StateCode) String() string {
+ return proto.EnumName(BitBoxBaseHeartbeatRequest_StateCode_name, int32(x))
+}
+
+func (BitBoxBaseHeartbeatRequest_StateCode) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{0, 0}
+}
+
+type BitBoxBaseHeartbeatRequest_DescriptionCode int32
+
+const (
+ BitBoxBaseHeartbeatRequest_EMPTY BitBoxBaseHeartbeatRequest_DescriptionCode = 0
+ BitBoxBaseHeartbeatRequest_INITIAL_BLOCK_SYNC BitBoxBaseHeartbeatRequest_DescriptionCode = 1
+ BitBoxBaseHeartbeatRequest_DOWNLOAD_UPDATE BitBoxBaseHeartbeatRequest_DescriptionCode = 2
+ BitBoxBaseHeartbeatRequest_OUT_OF_DISK_SPACE BitBoxBaseHeartbeatRequest_DescriptionCode = 3
+ BitBoxBaseHeartbeatRequest_REDIS_ERROR BitBoxBaseHeartbeatRequest_DescriptionCode = 4
+ BitBoxBaseHeartbeatRequest_REBOOT BitBoxBaseHeartbeatRequest_DescriptionCode = 5
+ BitBoxBaseHeartbeatRequest_SHUTDOWN BitBoxBaseHeartbeatRequest_DescriptionCode = 6
+ BitBoxBaseHeartbeatRequest_UPDATE_FAILED BitBoxBaseHeartbeatRequest_DescriptionCode = 7
+ BitBoxBaseHeartbeatRequest_NO_NETWORK_CONNECTION BitBoxBaseHeartbeatRequest_DescriptionCode = 8
+)
+
+var BitBoxBaseHeartbeatRequest_DescriptionCode_name = map[int32]string{
+ 0: "EMPTY",
+ 1: "INITIAL_BLOCK_SYNC",
+ 2: "DOWNLOAD_UPDATE",
+ 3: "OUT_OF_DISK_SPACE",
+ 4: "REDIS_ERROR",
+ 5: "REBOOT",
+ 6: "SHUTDOWN",
+ 7: "UPDATE_FAILED",
+ 8: "NO_NETWORK_CONNECTION",
+}
+
+var BitBoxBaseHeartbeatRequest_DescriptionCode_value = map[string]int32{
+ "EMPTY": 0,
+ "INITIAL_BLOCK_SYNC": 1,
+ "DOWNLOAD_UPDATE": 2,
+ "OUT_OF_DISK_SPACE": 3,
+ "REDIS_ERROR": 4,
+ "REBOOT": 5,
+ "SHUTDOWN": 6,
+ "UPDATE_FAILED": 7,
+ "NO_NETWORK_CONNECTION": 8,
+}
+
+func (x BitBoxBaseHeartbeatRequest_DescriptionCode) String() string {
+ return proto.EnumName(BitBoxBaseHeartbeatRequest_DescriptionCode_name, int32(x))
+}
+
+func (BitBoxBaseHeartbeatRequest_DescriptionCode) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{0, 1}
+}
+
+type BitBoxBaseSetConfigRequest_StatusLedMode int32
+
+const (
+ BitBoxBaseSetConfigRequest_LED_ALWAYS BitBoxBaseSetConfigRequest_StatusLedMode = 0
+ BitBoxBaseSetConfigRequest_LED_ON_WORKING BitBoxBaseSetConfigRequest_StatusLedMode = 1
+ BitBoxBaseSetConfigRequest_LED_ON_WARNING BitBoxBaseSetConfigRequest_StatusLedMode = 2
+ BitBoxBaseSetConfigRequest_LED_ON_ERROR BitBoxBaseSetConfigRequest_StatusLedMode = 3
+)
+
+var BitBoxBaseSetConfigRequest_StatusLedMode_name = map[int32]string{
+ 0: "LED_ALWAYS",
+ 1: "LED_ON_WORKING",
+ 2: "LED_ON_WARNING",
+ 3: "LED_ON_ERROR",
+}
+
+var BitBoxBaseSetConfigRequest_StatusLedMode_value = map[string]int32{
+ "LED_ALWAYS": 0,
+ "LED_ON_WORKING": 1,
+ "LED_ON_WARNING": 2,
+ "LED_ON_ERROR": 3,
+}
+
+func (x BitBoxBaseSetConfigRequest_StatusLedMode) String() string {
+ return proto.EnumName(BitBoxBaseSetConfigRequest_StatusLedMode_name, int32(x))
+}
+
+func (BitBoxBaseSetConfigRequest_StatusLedMode) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{2, 0}
+}
+
+type BitBoxBaseSetConfigRequest_StatusScreenMode int32
+
+const (
+ BitBoxBaseSetConfigRequest_SCREEN_ALWAYS BitBoxBaseSetConfigRequest_StatusScreenMode = 0
+ BitBoxBaseSetConfigRequest_SCREEN_ON_WORKING BitBoxBaseSetConfigRequest_StatusScreenMode = 1
+ BitBoxBaseSetConfigRequest_SCREEN_ON_WARNING BitBoxBaseSetConfigRequest_StatusScreenMode = 2
+ BitBoxBaseSetConfigRequest_SCREEN_ON_ERROR BitBoxBaseSetConfigRequest_StatusScreenMode = 3
+)
+
+var BitBoxBaseSetConfigRequest_StatusScreenMode_name = map[int32]string{
+ 0: "SCREEN_ALWAYS",
+ 1: "SCREEN_ON_WORKING",
+ 2: "SCREEN_ON_WARNING",
+ 3: "SCREEN_ON_ERROR",
+}
+
+var BitBoxBaseSetConfigRequest_StatusScreenMode_value = map[string]int32{
+ "SCREEN_ALWAYS": 0,
+ "SCREEN_ON_WORKING": 1,
+ "SCREEN_ON_WARNING": 2,
+ "SCREEN_ON_ERROR": 3,
+}
+
+func (x BitBoxBaseSetConfigRequest_StatusScreenMode) String() string {
+ return proto.EnumName(BitBoxBaseSetConfigRequest_StatusScreenMode_name, int32(x))
+}
+
+func (BitBoxBaseSetConfigRequest_StatusScreenMode) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{2, 1}
+}
+
+// Should be sent every X seconds (TBD) unless the firmware already is busy with a command.
+type BitBoxBaseHeartbeatRequest struct {
+ StateCode BitBoxBaseHeartbeatRequest_StateCode `protobuf:"varint,1,opt,name=state_code,json=stateCode,proto3,enum=BitBoxBaseHeartbeatRequest_StateCode" json:"state_code,omitempty"`
+ DescriptionCode BitBoxBaseHeartbeatRequest_DescriptionCode `protobuf:"varint,2,opt,name=description_code,json=descriptionCode,proto3,enum=BitBoxBaseHeartbeatRequest_DescriptionCode" json:"description_code,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BitBoxBaseHeartbeatRequest) Reset() { *m = BitBoxBaseHeartbeatRequest{} }
+func (m *BitBoxBaseHeartbeatRequest) String() string { return proto.CompactTextString(m) }
+func (*BitBoxBaseHeartbeatRequest) ProtoMessage() {}
+func (*BitBoxBaseHeartbeatRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{0}
+}
+
+func (m *BitBoxBaseHeartbeatRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BitBoxBaseHeartbeatRequest.Unmarshal(m, b)
+}
+func (m *BitBoxBaseHeartbeatRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BitBoxBaseHeartbeatRequest.Marshal(b, m, deterministic)
+}
+func (m *BitBoxBaseHeartbeatRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BitBoxBaseHeartbeatRequest.Merge(m, src)
+}
+func (m *BitBoxBaseHeartbeatRequest) XXX_Size() int {
+ return xxx_messageInfo_BitBoxBaseHeartbeatRequest.Size(m)
+}
+func (m *BitBoxBaseHeartbeatRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BitBoxBaseHeartbeatRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BitBoxBaseHeartbeatRequest proto.InternalMessageInfo
+
+func (m *BitBoxBaseHeartbeatRequest) GetStateCode() BitBoxBaseHeartbeatRequest_StateCode {
+ if m != nil {
+ return m.StateCode
+ }
+ return BitBoxBaseHeartbeatRequest_IDLE
+}
+
+func (m *BitBoxBaseHeartbeatRequest) GetDescriptionCode() BitBoxBaseHeartbeatRequest_DescriptionCode {
+ if m != nil {
+ return m.DescriptionCode
+ }
+ return BitBoxBaseHeartbeatRequest_EMPTY
+}
+
+// This will display the first 20 characters of the base32 encoded version of
+// the provided msg
+type BitBoxBaseConfirmPairingRequest struct {
+ Msg []byte `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BitBoxBaseConfirmPairingRequest) Reset() { *m = BitBoxBaseConfirmPairingRequest{} }
+func (m *BitBoxBaseConfirmPairingRequest) String() string { return proto.CompactTextString(m) }
+func (*BitBoxBaseConfirmPairingRequest) ProtoMessage() {}
+func (*BitBoxBaseConfirmPairingRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{1}
+}
+
+func (m *BitBoxBaseConfirmPairingRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BitBoxBaseConfirmPairingRequest.Unmarshal(m, b)
+}
+func (m *BitBoxBaseConfirmPairingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BitBoxBaseConfirmPairingRequest.Marshal(b, m, deterministic)
+}
+func (m *BitBoxBaseConfirmPairingRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BitBoxBaseConfirmPairingRequest.Merge(m, src)
+}
+func (m *BitBoxBaseConfirmPairingRequest) XXX_Size() int {
+ return xxx_messageInfo_BitBoxBaseConfirmPairingRequest.Size(m)
+}
+func (m *BitBoxBaseConfirmPairingRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BitBoxBaseConfirmPairingRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BitBoxBaseConfirmPairingRequest proto.InternalMessageInfo
+
+func (m *BitBoxBaseConfirmPairingRequest) GetMsg() []byte {
+ if m != nil {
+ return m.Msg
+ }
+ return nil
+}
+
+// Optional fields can be represented by a "oneof" with only one field in it.
+// All fields are technically optional. But in reality the default value for the type will be set.
+// It is therefore impossible to distinguish between the default value and if the value wasn't set.
+// So any fields that have a default value which also is a valid value can use this method to send
+// an empty value.
+type BitBoxBaseSetConfigRequest struct {
+ StatusLedMode BitBoxBaseSetConfigRequest_StatusLedMode `protobuf:"varint,1,opt,name=status_led_mode,json=statusLedMode,proto3,enum=BitBoxBaseSetConfigRequest_StatusLedMode" json:"status_led_mode,omitempty"`
+ StatusScreenMode BitBoxBaseSetConfigRequest_StatusScreenMode `protobuf:"varint,2,opt,name=status_screen_mode,json=statusScreenMode,proto3,enum=BitBoxBaseSetConfigRequest_StatusScreenMode" json:"status_screen_mode,omitempty"`
+ // 0.0.0.0 which is the default value of ip is also a valid IP, use the oneof-trick to determine
+ // if IP wasn't set in the message.
+ //
+ // Types that are valid to be assigned to IpOption:
+ // *BitBoxBaseSetConfigRequest_Ip
+ IpOption isBitBoxBaseSetConfigRequest_IpOption `protobuf_oneof:"ip_option"`
+ Hostname string `protobuf:"bytes,4,opt,name=hostname,proto3" json:"hostname,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BitBoxBaseSetConfigRequest) Reset() { *m = BitBoxBaseSetConfigRequest{} }
+func (m *BitBoxBaseSetConfigRequest) String() string { return proto.CompactTextString(m) }
+func (*BitBoxBaseSetConfigRequest) ProtoMessage() {}
+func (*BitBoxBaseSetConfigRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{2}
+}
+
+func (m *BitBoxBaseSetConfigRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BitBoxBaseSetConfigRequest.Unmarshal(m, b)
+}
+func (m *BitBoxBaseSetConfigRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BitBoxBaseSetConfigRequest.Marshal(b, m, deterministic)
+}
+func (m *BitBoxBaseSetConfigRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BitBoxBaseSetConfigRequest.Merge(m, src)
+}
+func (m *BitBoxBaseSetConfigRequest) XXX_Size() int {
+ return xxx_messageInfo_BitBoxBaseSetConfigRequest.Size(m)
+}
+func (m *BitBoxBaseSetConfigRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BitBoxBaseSetConfigRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BitBoxBaseSetConfigRequest proto.InternalMessageInfo
+
+func (m *BitBoxBaseSetConfigRequest) GetStatusLedMode() BitBoxBaseSetConfigRequest_StatusLedMode {
+ if m != nil {
+ return m.StatusLedMode
+ }
+ return BitBoxBaseSetConfigRequest_LED_ALWAYS
+}
+
+func (m *BitBoxBaseSetConfigRequest) GetStatusScreenMode() BitBoxBaseSetConfigRequest_StatusScreenMode {
+ if m != nil {
+ return m.StatusScreenMode
+ }
+ return BitBoxBaseSetConfigRequest_SCREEN_ALWAYS
+}
+
+type isBitBoxBaseSetConfigRequest_IpOption interface {
+ isBitBoxBaseSetConfigRequest_IpOption()
+}
+
+type BitBoxBaseSetConfigRequest_Ip struct {
+ Ip []byte `protobuf:"bytes,3,opt,name=ip,proto3,oneof"`
+}
+
+func (*BitBoxBaseSetConfigRequest_Ip) isBitBoxBaseSetConfigRequest_IpOption() {}
+
+func (m *BitBoxBaseSetConfigRequest) GetIpOption() isBitBoxBaseSetConfigRequest_IpOption {
+ if m != nil {
+ return m.IpOption
+ }
+ return nil
+}
+
+func (m *BitBoxBaseSetConfigRequest) GetIp() []byte {
+ if x, ok := m.GetIpOption().(*BitBoxBaseSetConfigRequest_Ip); ok {
+ return x.Ip
+ }
+ return nil
+}
+
+func (m *BitBoxBaseSetConfigRequest) GetHostname() string {
+ if m != nil {
+ return m.Hostname
+ }
+ return ""
+}
+
+// XXX_OneofWrappers is for the internal use of the proto package.
+func (*BitBoxBaseSetConfigRequest) XXX_OneofWrappers() []interface{} {
+ return []interface{}{
+ (*BitBoxBaseSetConfigRequest_Ip)(nil),
+ }
+}
+
+type BitBoxBaseDisplayStatusRequest struct {
+ Duration uint32 `protobuf:"varint,1,opt,name=duration,proto3" json:"duration,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BitBoxBaseDisplayStatusRequest) Reset() { *m = BitBoxBaseDisplayStatusRequest{} }
+func (m *BitBoxBaseDisplayStatusRequest) String() string { return proto.CompactTextString(m) }
+func (*BitBoxBaseDisplayStatusRequest) ProtoMessage() {}
+func (*BitBoxBaseDisplayStatusRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{3}
+}
+
+func (m *BitBoxBaseDisplayStatusRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BitBoxBaseDisplayStatusRequest.Unmarshal(m, b)
+}
+func (m *BitBoxBaseDisplayStatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BitBoxBaseDisplayStatusRequest.Marshal(b, m, deterministic)
+}
+func (m *BitBoxBaseDisplayStatusRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BitBoxBaseDisplayStatusRequest.Merge(m, src)
+}
+func (m *BitBoxBaseDisplayStatusRequest) XXX_Size() int {
+ return xxx_messageInfo_BitBoxBaseDisplayStatusRequest.Size(m)
+}
+func (m *BitBoxBaseDisplayStatusRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BitBoxBaseDisplayStatusRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BitBoxBaseDisplayStatusRequest proto.InternalMessageInfo
+
+func (m *BitBoxBaseDisplayStatusRequest) GetDuration() uint32 {
+ if m != nil {
+ return m.Duration
+ }
+ return 0
+}
+
+type BitBoxBaseRequest struct {
+ // Types that are valid to be assigned to Request:
+ // *BitBoxBaseRequest_Heartbeat
+ // *BitBoxBaseRequest_SetConfig
+ // *BitBoxBaseRequest_ConfirmPairing
+ // *BitBoxBaseRequest_DisplayStatus
+ Request isBitBoxBaseRequest_Request `protobuf_oneof:"request"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BitBoxBaseRequest) Reset() { *m = BitBoxBaseRequest{} }
+func (m *BitBoxBaseRequest) String() string { return proto.CompactTextString(m) }
+func (*BitBoxBaseRequest) ProtoMessage() {}
+func (*BitBoxBaseRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_9c0d283a3459010a, []int{4}
+}
+
+func (m *BitBoxBaseRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BitBoxBaseRequest.Unmarshal(m, b)
+}
+func (m *BitBoxBaseRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BitBoxBaseRequest.Marshal(b, m, deterministic)
+}
+func (m *BitBoxBaseRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BitBoxBaseRequest.Merge(m, src)
+}
+func (m *BitBoxBaseRequest) XXX_Size() int {
+ return xxx_messageInfo_BitBoxBaseRequest.Size(m)
+}
+func (m *BitBoxBaseRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BitBoxBaseRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BitBoxBaseRequest proto.InternalMessageInfo
+
+type isBitBoxBaseRequest_Request interface {
+ isBitBoxBaseRequest_Request()
+}
+
+type BitBoxBaseRequest_Heartbeat struct {
+ Heartbeat *BitBoxBaseHeartbeatRequest `protobuf:"bytes,1,opt,name=heartbeat,proto3,oneof"`
+}
+
+type BitBoxBaseRequest_SetConfig struct {
+ SetConfig *BitBoxBaseSetConfigRequest `protobuf:"bytes,2,opt,name=set_config,json=setConfig,proto3,oneof"`
+}
+
+type BitBoxBaseRequest_ConfirmPairing struct {
+ ConfirmPairing *BitBoxBaseConfirmPairingRequest `protobuf:"bytes,3,opt,name=confirm_pairing,json=confirmPairing,proto3,oneof"`
+}
+
+type BitBoxBaseRequest_DisplayStatus struct {
+ DisplayStatus *BitBoxBaseDisplayStatusRequest `protobuf:"bytes,4,opt,name=display_status,json=displayStatus,proto3,oneof"`
+}
+
+func (*BitBoxBaseRequest_Heartbeat) isBitBoxBaseRequest_Request() {}
+
+func (*BitBoxBaseRequest_SetConfig) isBitBoxBaseRequest_Request() {}
+
+func (*BitBoxBaseRequest_ConfirmPairing) isBitBoxBaseRequest_Request() {}
+
+func (*BitBoxBaseRequest_DisplayStatus) isBitBoxBaseRequest_Request() {}
+
+func (m *BitBoxBaseRequest) GetRequest() isBitBoxBaseRequest_Request {
+ if m != nil {
+ return m.Request
+ }
+ return nil
+}
+
+func (m *BitBoxBaseRequest) GetHeartbeat() *BitBoxBaseHeartbeatRequest {
+ if x, ok := m.GetRequest().(*BitBoxBaseRequest_Heartbeat); ok {
+ return x.Heartbeat
+ }
+ return nil
+}
+
+func (m *BitBoxBaseRequest) GetSetConfig() *BitBoxBaseSetConfigRequest {
+ if x, ok := m.GetRequest().(*BitBoxBaseRequest_SetConfig); ok {
+ return x.SetConfig
+ }
+ return nil
+}
+
+func (m *BitBoxBaseRequest) GetConfirmPairing() *BitBoxBaseConfirmPairingRequest {
+ if x, ok := m.GetRequest().(*BitBoxBaseRequest_ConfirmPairing); ok {
+ return x.ConfirmPairing
+ }
+ return nil
+}
+
+func (m *BitBoxBaseRequest) GetDisplayStatus() *BitBoxBaseDisplayStatusRequest {
+ if x, ok := m.GetRequest().(*BitBoxBaseRequest_DisplayStatus); ok {
+ return x.DisplayStatus
+ }
+ return nil
+}
+
+// XXX_OneofWrappers is for the internal use of the proto package.
+func (*BitBoxBaseRequest) XXX_OneofWrappers() []interface{} {
+ return []interface{}{
+ (*BitBoxBaseRequest_Heartbeat)(nil),
+ (*BitBoxBaseRequest_SetConfig)(nil),
+ (*BitBoxBaseRequest_ConfirmPairing)(nil),
+ (*BitBoxBaseRequest_DisplayStatus)(nil),
+ }
+}
+
+func init() {
+ proto.RegisterEnum("BitBoxBaseHeartbeatRequest_StateCode", BitBoxBaseHeartbeatRequest_StateCode_name, BitBoxBaseHeartbeatRequest_StateCode_value)
+ proto.RegisterEnum("BitBoxBaseHeartbeatRequest_DescriptionCode", BitBoxBaseHeartbeatRequest_DescriptionCode_name, BitBoxBaseHeartbeatRequest_DescriptionCode_value)
+ proto.RegisterEnum("BitBoxBaseSetConfigRequest_StatusLedMode", BitBoxBaseSetConfigRequest_StatusLedMode_name, BitBoxBaseSetConfigRequest_StatusLedMode_value)
+ proto.RegisterEnum("BitBoxBaseSetConfigRequest_StatusScreenMode", BitBoxBaseSetConfigRequest_StatusScreenMode_name, BitBoxBaseSetConfigRequest_StatusScreenMode_value)
+ proto.RegisterType((*BitBoxBaseHeartbeatRequest)(nil), "BitBoxBaseHeartbeatRequest")
+ proto.RegisterType((*BitBoxBaseConfirmPairingRequest)(nil), "BitBoxBaseConfirmPairingRequest")
+ proto.RegisterType((*BitBoxBaseSetConfigRequest)(nil), "BitBoxBaseSetConfigRequest")
+ proto.RegisterType((*BitBoxBaseDisplayStatusRequest)(nil), "BitBoxBaseDisplayStatusRequest")
+ proto.RegisterType((*BitBoxBaseRequest)(nil), "BitBoxBaseRequest")
+}
+
+func init() { proto.RegisterFile("bitboxbase.proto", fileDescriptor_9c0d283a3459010a) }
+
+var fileDescriptor_9c0d283a3459010a = []byte{
+ // 669 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x4d, 0x4f, 0xdb, 0x4a,
+ 0x14, 0xcd, 0x07, 0x1f, 0xc9, 0x0d, 0x49, 0x26, 0x83, 0x78, 0xe2, 0xf1, 0xa4, 0x07, 0xb2, 0x54,
+ 0x89, 0xaa, 0x55, 0x16, 0x61, 0xd7, 0xb2, 0xf1, 0x17, 0xb5, 0x15, 0x63, 0xa7, 0x63, 0x53, 0x94,
+ 0x6e, 0x46, 0x4e, 0x3c, 0x05, 0x4b, 0x24, 0x76, 0x3d, 0x8e, 0x44, 0xff, 0x55, 0xd5, 0x5d, 0x7f,
+ 0x43, 0xff, 0x54, 0xe5, 0x71, 0x1c, 0xe3, 0x48, 0xc0, 0xce, 0xf7, 0xcc, 0x9c, 0x73, 0x67, 0xee,
+ 0x39, 0x63, 0x40, 0xb3, 0x30, 0x9d, 0x45, 0x8f, 0x33, 0x9f, 0xb3, 0x61, 0x9c, 0x44, 0x69, 0x24,
+ 0xfd, 0x6a, 0xc2, 0x89, 0x12, 0xa6, 0x4a, 0xf4, 0xa8, 0xf8, 0x9c, 0x19, 0xcc, 0x4f, 0xd2, 0x19,
+ 0xf3, 0x53, 0xc2, 0xbe, 0xaf, 0x18, 0x4f, 0xb1, 0x06, 0xc0, 0x53, 0x3f, 0x65, 0x74, 0x1e, 0x05,
+ 0xec, 0xb8, 0x7e, 0x56, 0x3f, 0xef, 0x8d, 0xde, 0x0c, 0x9f, 0x27, 0x0c, 0xdd, 0x6c, 0xb7, 0x1a,
+ 0x05, 0x8c, 0xb4, 0x79, 0xf1, 0x89, 0xbf, 0x00, 0x0a, 0x18, 0x9f, 0x27, 0x61, 0x9c, 0x86, 0xd1,
+ 0x32, 0xd7, 0x6a, 0x08, 0xad, 0x77, 0x2f, 0x69, 0x69, 0x25, 0x47, 0x28, 0xf6, 0x83, 0x2a, 0x20,
+ 0x7d, 0x80, 0xf6, 0xa6, 0x1f, 0x6e, 0xc1, 0x8e, 0xa9, 0x59, 0x3a, 0xaa, 0xe1, 0x0e, 0xec, 0xdf,
+ 0x3a, 0x64, 0x6c, 0xda, 0x9f, 0x50, 0x5d, 0x14, 0x32, 0xb1, 0xb3, 0xa2, 0x81, 0xdb, 0xb0, 0xab,
+ 0x13, 0xe2, 0x10, 0xd4, 0x94, 0x7e, 0xd7, 0xa1, 0xbf, 0xd5, 0x40, 0x2c, 0x5f, 0x4f, 0xbc, 0x29,
+ 0xaa, 0xe1, 0x7f, 0x00, 0x9b, 0xb6, 0xe9, 0x99, 0xb2, 0x45, 0x15, 0xcb, 0x51, 0xc7, 0xd4, 0x9d,
+ 0xda, 0x2a, 0xaa, 0xe3, 0x43, 0xe8, 0x6b, 0xce, 0xad, 0x6d, 0x39, 0xb2, 0x46, 0x6f, 0x26, 0x9a,
+ 0xec, 0xe9, 0xa8, 0x81, 0x8f, 0x60, 0xe0, 0xdc, 0x78, 0xd4, 0xb9, 0xa2, 0x9a, 0xe9, 0x8e, 0xa9,
+ 0x3b, 0x91, 0x55, 0x1d, 0x35, 0x71, 0x1f, 0x3a, 0x44, 0xd7, 0x4c, 0x97, 0xe6, 0x3d, 0x77, 0x30,
+ 0xc0, 0x1e, 0xd1, 0x15, 0xc7, 0xf1, 0xd0, 0x2e, 0x3e, 0x80, 0x96, 0x6b, 0xdc, 0x78, 0x99, 0x18,
+ 0xda, 0xc3, 0x03, 0xe8, 0xe6, 0x6a, 0xf4, 0x4a, 0x36, 0x2d, 0x5d, 0x43, 0xfb, 0xf8, 0x5f, 0x38,
+ 0xb2, 0x1d, 0x6a, 0xeb, 0x5e, 0x76, 0x17, 0xaa, 0x3a, 0xb6, 0xad, 0xab, 0x9e, 0xe9, 0xd8, 0xa8,
+ 0x25, 0x5d, 0xc0, 0x69, 0x39, 0x36, 0x35, 0x5a, 0x7e, 0x0b, 0x93, 0xc5, 0xc4, 0x0f, 0x93, 0x70,
+ 0x79, 0x57, 0x18, 0x87, 0xa0, 0xb9, 0xe0, 0x77, 0xc2, 0xb1, 0x03, 0x92, 0x7d, 0x4a, 0x7f, 0x2a,
+ 0x4e, 0xbb, 0x2c, 0x15, 0xc4, 0x0d, 0xe1, 0x33, 0xf4, 0x33, 0xc3, 0x56, 0x9c, 0x3e, 0xb0, 0x80,
+ 0x2e, 0x4a, 0xbb, 0xdf, 0x0e, 0x9f, 0x67, 0x09, 0xbb, 0x57, 0xdc, 0x62, 0xc1, 0x75, 0x66, 0x50,
+ 0x97, 0x3f, 0x2d, 0xf1, 0x57, 0xc0, 0x6b, 0x49, 0x3e, 0x4f, 0x18, 0x5b, 0xe6, 0xaa, 0xb9, 0xf1,
+ 0xef, 0x5f, 0x57, 0x75, 0x05, 0x49, 0x08, 0x23, 0xbe, 0x85, 0x60, 0x04, 0x8d, 0x30, 0x3e, 0x6e,
+ 0x66, 0xd7, 0x33, 0x6a, 0xa4, 0x11, 0xc6, 0xf8, 0x04, 0x5a, 0xf7, 0x11, 0x4f, 0x97, 0xfe, 0x82,
+ 0x1d, 0xef, 0x9c, 0xd5, 0xcf, 0xdb, 0x64, 0x53, 0x4b, 0x53, 0xe8, 0x56, 0x4e, 0x8a, 0x7b, 0x00,
+ 0x96, 0xae, 0x51, 0xd9, 0xba, 0x95, 0xa7, 0x2e, 0xaa, 0x61, 0x0c, 0xbd, 0xac, 0x76, 0x6c, 0x5a,
+ 0x26, 0xe7, 0x09, 0xb6, 0x09, 0x10, 0x82, 0x83, 0x35, 0x56, 0xe4, 0xe8, 0x1e, 0xd0, 0xf6, 0x71,
+ 0x33, 0x37, 0x5d, 0x95, 0xe8, 0xba, 0x5d, 0x36, 0x38, 0x82, 0xc1, 0x1a, 0xaa, 0xf4, 0xa8, 0xc2,
+ 0x9b, 0x36, 0x87, 0xd0, 0x2f, 0xe1, 0x75, 0x27, 0xa5, 0x03, 0xed, 0x30, 0xa6, 0x91, 0x88, 0xab,
+ 0x74, 0x09, 0xff, 0x97, 0x03, 0xd4, 0x42, 0x1e, 0x3f, 0xf8, 0x3f, 0xf2, 0x73, 0x14, 0x86, 0x9e,
+ 0x40, 0x2b, 0x58, 0x25, 0x7e, 0xb6, 0x5b, 0x38, 0xd9, 0x25, 0x9b, 0x5a, 0xfa, 0xd9, 0x80, 0x41,
+ 0x49, 0x2f, 0x18, 0x1f, 0xa1, 0x7d, 0x5f, 0xbc, 0x41, 0x41, 0xe9, 0x8c, 0xfe, 0x7b, 0xe1, 0x7d,
+ 0x1a, 0x35, 0x52, 0xee, 0xc7, 0x97, 0x00, 0x9c, 0xa5, 0x74, 0x2e, 0x8c, 0x14, 0x26, 0x57, 0xd9,
+ 0xdb, 0x26, 0x67, 0x6c, 0x5e, 0x60, 0x78, 0x0c, 0xfd, 0x79, 0x9e, 0x63, 0x1a, 0xe7, 0x41, 0x16,
+ 0xde, 0x76, 0x46, 0x67, 0xc3, 0x57, 0x92, 0x6e, 0xd4, 0x48, 0x6f, 0x5e, 0x59, 0xc0, 0x06, 0xf4,
+ 0x82, 0x7c, 0x22, 0x34, 0xcf, 0x8d, 0xc8, 0x43, 0x67, 0x74, 0x3a, 0x7c, 0x79, 0x64, 0x46, 0x8d,
+ 0x74, 0x83, 0xa7, 0xb8, 0xd2, 0x86, 0xfd, 0x24, 0x5f, 0x9b, 0xed, 0x89, 0xff, 0xe5, 0xc5, 0xdf,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0x61, 0x9c, 0x95, 0x58, 0x43, 0x05, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitboxbase.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitboxbase.proto
new file mode 100644
index 00000000..3272ce97
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/bitboxbase.proto
@@ -0,0 +1,87 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+// Should be sent every X seconds (TBD) unless the firmware already is busy with a command.
+message BitBoxBaseHeartbeatRequest {
+ enum StateCode {
+ IDLE = 0;
+ WORKING = 1;
+ WARNING = 2;
+ ERROR = 3;
+ };
+ enum DescriptionCode {
+ EMPTY = 0;
+ INITIAL_BLOCK_SYNC = 1;
+ DOWNLOAD_UPDATE = 2;
+ OUT_OF_DISK_SPACE = 3;
+ REDIS_ERROR = 4;
+ REBOOT = 5;
+ SHUTDOWN = 6;
+ UPDATE_FAILED = 7;
+ NO_NETWORK_CONNECTION = 8;
+ };
+
+ StateCode state_code = 1;
+ DescriptionCode description_code = 2;
+}
+
+// This will display the first 20 characters of the base32 encoded version of
+// the provided msg
+message BitBoxBaseConfirmPairingRequest {
+ bytes msg = 1;
+}
+
+// Optional fields can be represented by a "oneof" with only one field in it.
+// All fields are technically optional. But in reality the default value for the type will be set.
+// It is therefore impossible to distinguish between the default value and if the value wasn't set.
+// So any fields that have a default value which also is a valid value can use this method to send
+// an empty value.
+message BitBoxBaseSetConfigRequest {
+ enum StatusLedMode {
+ LED_ALWAYS = 0; // display on led when status is IDLE, WORKING, WARNING and ERROR
+ LED_ON_WORKING = 1; // display on led when status is WORKING, WARNING and ERROR
+ LED_ON_WARNING = 2; // display on led when status is WARNING and ERROR
+ LED_ON_ERROR = 3; // display on led when status is ERROR
+ }
+ enum StatusScreenMode {
+ SCREEN_ALWAYS = 0; // display on screen when status is IDLE, WORKING, WARNING and ERROR
+ SCREEN_ON_WORKING = 1; // display on screen when status is WORKING, WARNING and ERROR
+ SCREEN_ON_WARNING = 2; // display on screen when status is WARNING and ERROR
+ SCREEN_ON_ERROR = 3; // display on screen when status is ERROR
+ }
+
+ StatusLedMode status_led_mode = 1;
+ StatusScreenMode status_screen_mode = 2;
+ // 0.0.0.0 which is the default value of ip is also a valid IP, use the oneof-trick to determine
+ // if IP wasn't set in the message.
+ oneof ip_option {
+ bytes ip = 3;
+ }
+ string hostname = 4; // Empty string means unsetting the hostname
+}
+
+message BitBoxBaseDisplayStatusRequest {
+ uint32 duration = 1;
+}
+
+message BitBoxBaseRequest {
+ oneof request {
+ BitBoxBaseHeartbeatRequest heartbeat = 1;
+ BitBoxBaseSetConfigRequest set_config = 2;
+ BitBoxBaseConfirmPairingRequest confirm_pairing = 3;
+ BitBoxBaseDisplayStatusRequest display_status = 4;
+ }
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/btc.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/btc.pb.go
new file mode 100644
index 00000000..bca85e5a
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/btc.pb.go
@@ -0,0 +1,605 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: btc.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type BTCCoin int32
+
+const (
+ BTCCoin_BTC BTCCoin = 0
+ BTCCoin_TBTC BTCCoin = 1
+ BTCCoin_LTC BTCCoin = 2
+ BTCCoin_TLTC BTCCoin = 3
+)
+
+var BTCCoin_name = map[int32]string{
+ 0: "BTC",
+ 1: "TBTC",
+ 2: "LTC",
+ 3: "TLTC",
+}
+
+var BTCCoin_value = map[string]int32{
+ "BTC": 0,
+ "TBTC": 1,
+ "LTC": 2,
+ "TLTC": 3,
+}
+
+func (x BTCCoin) String() string {
+ return proto.EnumName(BTCCoin_name, int32(x))
+}
+
+func (BTCCoin) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{0}
+}
+
+type BTCScriptType int32
+
+const (
+ BTCScriptType_SCRIPT_UNKNOWN BTCScriptType = 0
+ BTCScriptType_SCRIPT_P2PKH BTCScriptType = 1
+ BTCScriptType_SCRIPT_P2WPKH_P2SH BTCScriptType = 2
+ BTCScriptType_SCRIPT_P2WPKH BTCScriptType = 3
+)
+
+var BTCScriptType_name = map[int32]string{
+ 0: "SCRIPT_UNKNOWN",
+ 1: "SCRIPT_P2PKH",
+ 2: "SCRIPT_P2WPKH_P2SH",
+ 3: "SCRIPT_P2WPKH",
+}
+
+var BTCScriptType_value = map[string]int32{
+ "SCRIPT_UNKNOWN": 0,
+ "SCRIPT_P2PKH": 1,
+ "SCRIPT_P2WPKH_P2SH": 2,
+ "SCRIPT_P2WPKH": 3,
+}
+
+func (x BTCScriptType) String() string {
+ return proto.EnumName(BTCScriptType_name, int32(x))
+}
+
+func (BTCScriptType) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{1}
+}
+
+type BTCOutputType int32
+
+const (
+ BTCOutputType_UNKNOWN BTCOutputType = 0
+ BTCOutputType_P2PKH BTCOutputType = 1
+ BTCOutputType_P2SH BTCOutputType = 2
+ BTCOutputType_P2WPKH BTCOutputType = 3
+ BTCOutputType_P2WSH BTCOutputType = 4
+)
+
+var BTCOutputType_name = map[int32]string{
+ 0: "UNKNOWN",
+ 1: "P2PKH",
+ 2: "P2SH",
+ 3: "P2WPKH",
+ 4: "P2WSH",
+}
+
+var BTCOutputType_value = map[string]int32{
+ "UNKNOWN": 0,
+ "P2PKH": 1,
+ "P2SH": 2,
+ "P2WPKH": 3,
+ "P2WSH": 4,
+}
+
+func (x BTCOutputType) String() string {
+ return proto.EnumName(BTCOutputType_name, int32(x))
+}
+
+func (BTCOutputType) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{2}
+}
+
+type BTCPubRequest_OutputType int32
+
+const (
+ BTCPubRequest_TPUB BTCPubRequest_OutputType = 0
+ BTCPubRequest_XPUB BTCPubRequest_OutputType = 1
+ BTCPubRequest_YPUB BTCPubRequest_OutputType = 2
+ BTCPubRequest_ZPUB BTCPubRequest_OutputType = 3
+ BTCPubRequest_ADDRESS BTCPubRequest_OutputType = 4
+)
+
+var BTCPubRequest_OutputType_name = map[int32]string{
+ 0: "TPUB",
+ 1: "XPUB",
+ 2: "YPUB",
+ 3: "ZPUB",
+ 4: "ADDRESS",
+}
+
+var BTCPubRequest_OutputType_value = map[string]int32{
+ "TPUB": 0,
+ "XPUB": 1,
+ "YPUB": 2,
+ "ZPUB": 3,
+ "ADDRESS": 4,
+}
+
+func (x BTCPubRequest_OutputType) String() string {
+ return proto.EnumName(BTCPubRequest_OutputType_name, int32(x))
+}
+
+func (BTCPubRequest_OutputType) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{0, 0}
+}
+
+type BTCSignNextResponse_Type int32
+
+const (
+ BTCSignNextResponse_INPUT BTCSignNextResponse_Type = 0
+ BTCSignNextResponse_OUTPUT BTCSignNextResponse_Type = 1
+ BTCSignNextResponse_DONE BTCSignNextResponse_Type = 2
+)
+
+var BTCSignNextResponse_Type_name = map[int32]string{
+ 0: "INPUT",
+ 1: "OUTPUT",
+ 2: "DONE",
+}
+
+var BTCSignNextResponse_Type_value = map[string]int32{
+ "INPUT": 0,
+ "OUTPUT": 1,
+ "DONE": 2,
+}
+
+func (x BTCSignNextResponse_Type) String() string {
+ return proto.EnumName(BTCSignNextResponse_Type_name, int32(x))
+}
+
+func (BTCSignNextResponse_Type) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{2, 0}
+}
+
+type BTCPubRequest struct {
+ Keypath []uint32 `protobuf:"varint,1,rep,packed,name=keypath,proto3" json:"keypath,omitempty"`
+ ScriptType BTCScriptType `protobuf:"varint,2,opt,name=script_type,json=scriptType,proto3,enum=BTCScriptType" json:"script_type,omitempty"`
+ Coin BTCCoin `protobuf:"varint,3,opt,name=coin,proto3,enum=BTCCoin" json:"coin,omitempty"`
+ OutputType BTCPubRequest_OutputType `protobuf:"varint,4,opt,name=output_type,json=outputType,proto3,enum=BTCPubRequest_OutputType" json:"output_type,omitempty"`
+ Display bool `protobuf:"varint,5,opt,name=display,proto3" json:"display,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BTCPubRequest) Reset() { *m = BTCPubRequest{} }
+func (m *BTCPubRequest) String() string { return proto.CompactTextString(m) }
+func (*BTCPubRequest) ProtoMessage() {}
+func (*BTCPubRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{0}
+}
+
+func (m *BTCPubRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BTCPubRequest.Unmarshal(m, b)
+}
+func (m *BTCPubRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BTCPubRequest.Marshal(b, m, deterministic)
+}
+func (m *BTCPubRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BTCPubRequest.Merge(m, src)
+}
+func (m *BTCPubRequest) XXX_Size() int {
+ return xxx_messageInfo_BTCPubRequest.Size(m)
+}
+func (m *BTCPubRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BTCPubRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BTCPubRequest proto.InternalMessageInfo
+
+func (m *BTCPubRequest) GetKeypath() []uint32 {
+ if m != nil {
+ return m.Keypath
+ }
+ return nil
+}
+
+func (m *BTCPubRequest) GetScriptType() BTCScriptType {
+ if m != nil {
+ return m.ScriptType
+ }
+ return BTCScriptType_SCRIPT_UNKNOWN
+}
+
+func (m *BTCPubRequest) GetCoin() BTCCoin {
+ if m != nil {
+ return m.Coin
+ }
+ return BTCCoin_BTC
+}
+
+func (m *BTCPubRequest) GetOutputType() BTCPubRequest_OutputType {
+ if m != nil {
+ return m.OutputType
+ }
+ return BTCPubRequest_TPUB
+}
+
+func (m *BTCPubRequest) GetDisplay() bool {
+ if m != nil {
+ return m.Display
+ }
+ return false
+}
+
+type BTCSignInitRequest struct {
+ Coin BTCCoin `protobuf:"varint,1,opt,name=coin,proto3,enum=BTCCoin" json:"coin,omitempty"`
+ ScriptType BTCScriptType `protobuf:"varint,2,opt,name=script_type,json=scriptType,proto3,enum=BTCScriptType" json:"script_type,omitempty"`
+ Bip44Account uint32 `protobuf:"varint,3,opt,name=bip44_account,json=bip44Account,proto3" json:"bip44_account,omitempty"`
+ Version uint32 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"`
+ NumInputs uint32 `protobuf:"varint,5,opt,name=num_inputs,json=numInputs,proto3" json:"num_inputs,omitempty"`
+ NumOutputs uint32 `protobuf:"varint,6,opt,name=num_outputs,json=numOutputs,proto3" json:"num_outputs,omitempty"`
+ Locktime uint32 `protobuf:"varint,7,opt,name=locktime,proto3" json:"locktime,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BTCSignInitRequest) Reset() { *m = BTCSignInitRequest{} }
+func (m *BTCSignInitRequest) String() string { return proto.CompactTextString(m) }
+func (*BTCSignInitRequest) ProtoMessage() {}
+func (*BTCSignInitRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{1}
+}
+
+func (m *BTCSignInitRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BTCSignInitRequest.Unmarshal(m, b)
+}
+func (m *BTCSignInitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BTCSignInitRequest.Marshal(b, m, deterministic)
+}
+func (m *BTCSignInitRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BTCSignInitRequest.Merge(m, src)
+}
+func (m *BTCSignInitRequest) XXX_Size() int {
+ return xxx_messageInfo_BTCSignInitRequest.Size(m)
+}
+func (m *BTCSignInitRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BTCSignInitRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BTCSignInitRequest proto.InternalMessageInfo
+
+func (m *BTCSignInitRequest) GetCoin() BTCCoin {
+ if m != nil {
+ return m.Coin
+ }
+ return BTCCoin_BTC
+}
+
+func (m *BTCSignInitRequest) GetScriptType() BTCScriptType {
+ if m != nil {
+ return m.ScriptType
+ }
+ return BTCScriptType_SCRIPT_UNKNOWN
+}
+
+func (m *BTCSignInitRequest) GetBip44Account() uint32 {
+ if m != nil {
+ return m.Bip44Account
+ }
+ return 0
+}
+
+func (m *BTCSignInitRequest) GetVersion() uint32 {
+ if m != nil {
+ return m.Version
+ }
+ return 0
+}
+
+func (m *BTCSignInitRequest) GetNumInputs() uint32 {
+ if m != nil {
+ return m.NumInputs
+ }
+ return 0
+}
+
+func (m *BTCSignInitRequest) GetNumOutputs() uint32 {
+ if m != nil {
+ return m.NumOutputs
+ }
+ return 0
+}
+
+func (m *BTCSignInitRequest) GetLocktime() uint32 {
+ if m != nil {
+ return m.Locktime
+ }
+ return 0
+}
+
+type BTCSignNextResponse struct {
+ Type BTCSignNextResponse_Type `protobuf:"varint,1,opt,name=type,proto3,enum=BTCSignNextResponse_Type" json:"type,omitempty"`
+ Index uint32 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
+ HasSignature bool `protobuf:"varint,3,opt,name=has_signature,json=hasSignature,proto3" json:"has_signature,omitempty"`
+ // 64 bytes (32 bytes big endian R, 32 bytes big endian S). Only if has_signature is true.
+ Signature []byte `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BTCSignNextResponse) Reset() { *m = BTCSignNextResponse{} }
+func (m *BTCSignNextResponse) String() string { return proto.CompactTextString(m) }
+func (*BTCSignNextResponse) ProtoMessage() {}
+func (*BTCSignNextResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{2}
+}
+
+func (m *BTCSignNextResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BTCSignNextResponse.Unmarshal(m, b)
+}
+func (m *BTCSignNextResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BTCSignNextResponse.Marshal(b, m, deterministic)
+}
+func (m *BTCSignNextResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BTCSignNextResponse.Merge(m, src)
+}
+func (m *BTCSignNextResponse) XXX_Size() int {
+ return xxx_messageInfo_BTCSignNextResponse.Size(m)
+}
+func (m *BTCSignNextResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_BTCSignNextResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BTCSignNextResponse proto.InternalMessageInfo
+
+func (m *BTCSignNextResponse) GetType() BTCSignNextResponse_Type {
+ if m != nil {
+ return m.Type
+ }
+ return BTCSignNextResponse_INPUT
+}
+
+func (m *BTCSignNextResponse) GetIndex() uint32 {
+ if m != nil {
+ return m.Index
+ }
+ return 0
+}
+
+func (m *BTCSignNextResponse) GetHasSignature() bool {
+ if m != nil {
+ return m.HasSignature
+ }
+ return false
+}
+
+func (m *BTCSignNextResponse) GetSignature() []byte {
+ if m != nil {
+ return m.Signature
+ }
+ return nil
+}
+
+type BTCSignInputRequest struct {
+ PrevOutHash []byte `protobuf:"bytes,1,opt,name=prevOutHash,proto3" json:"prevOutHash,omitempty"`
+ PrevOutIndex uint32 `protobuf:"varint,2,opt,name=prevOutIndex,proto3" json:"prevOutIndex,omitempty"`
+ PrevOutValue uint64 `protobuf:"varint,3,opt,name=prevOutValue,proto3" json:"prevOutValue,omitempty"`
+ Sequence uint32 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"`
+ Keypath []uint32 `protobuf:"varint,6,rep,packed,name=keypath,proto3" json:"keypath,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BTCSignInputRequest) Reset() { *m = BTCSignInputRequest{} }
+func (m *BTCSignInputRequest) String() string { return proto.CompactTextString(m) }
+func (*BTCSignInputRequest) ProtoMessage() {}
+func (*BTCSignInputRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{3}
+}
+
+func (m *BTCSignInputRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BTCSignInputRequest.Unmarshal(m, b)
+}
+func (m *BTCSignInputRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BTCSignInputRequest.Marshal(b, m, deterministic)
+}
+func (m *BTCSignInputRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BTCSignInputRequest.Merge(m, src)
+}
+func (m *BTCSignInputRequest) XXX_Size() int {
+ return xxx_messageInfo_BTCSignInputRequest.Size(m)
+}
+func (m *BTCSignInputRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BTCSignInputRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BTCSignInputRequest proto.InternalMessageInfo
+
+func (m *BTCSignInputRequest) GetPrevOutHash() []byte {
+ if m != nil {
+ return m.PrevOutHash
+ }
+ return nil
+}
+
+func (m *BTCSignInputRequest) GetPrevOutIndex() uint32 {
+ if m != nil {
+ return m.PrevOutIndex
+ }
+ return 0
+}
+
+func (m *BTCSignInputRequest) GetPrevOutValue() uint64 {
+ if m != nil {
+ return m.PrevOutValue
+ }
+ return 0
+}
+
+func (m *BTCSignInputRequest) GetSequence() uint32 {
+ if m != nil {
+ return m.Sequence
+ }
+ return 0
+}
+
+func (m *BTCSignInputRequest) GetKeypath() []uint32 {
+ if m != nil {
+ return m.Keypath
+ }
+ return nil
+}
+
+type BTCSignOutputRequest struct {
+ Ours bool `protobuf:"varint,1,opt,name=ours,proto3" json:"ours,omitempty"`
+ Type BTCOutputType `protobuf:"varint,2,opt,name=type,proto3,enum=BTCOutputType" json:"type,omitempty"`
+ // 20 bytes for p2pkh, p2sh, pw2wpkh. 32 bytes for p2wsh.
+ Value uint64 `protobuf:"varint,3,opt,name=value,proto3" json:"value,omitempty"`
+ Hash []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"`
+ Keypath []uint32 `protobuf:"varint,5,rep,packed,name=keypath,proto3" json:"keypath,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *BTCSignOutputRequest) Reset() { *m = BTCSignOutputRequest{} }
+func (m *BTCSignOutputRequest) String() string { return proto.CompactTextString(m) }
+func (*BTCSignOutputRequest) ProtoMessage() {}
+func (*BTCSignOutputRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_a38f9ffa5c78f451, []int{4}
+}
+
+func (m *BTCSignOutputRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_BTCSignOutputRequest.Unmarshal(m, b)
+}
+func (m *BTCSignOutputRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_BTCSignOutputRequest.Marshal(b, m, deterministic)
+}
+func (m *BTCSignOutputRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_BTCSignOutputRequest.Merge(m, src)
+}
+func (m *BTCSignOutputRequest) XXX_Size() int {
+ return xxx_messageInfo_BTCSignOutputRequest.Size(m)
+}
+func (m *BTCSignOutputRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_BTCSignOutputRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_BTCSignOutputRequest proto.InternalMessageInfo
+
+func (m *BTCSignOutputRequest) GetOurs() bool {
+ if m != nil {
+ return m.Ours
+ }
+ return false
+}
+
+func (m *BTCSignOutputRequest) GetType() BTCOutputType {
+ if m != nil {
+ return m.Type
+ }
+ return BTCOutputType_UNKNOWN
+}
+
+func (m *BTCSignOutputRequest) GetValue() uint64 {
+ if m != nil {
+ return m.Value
+ }
+ return 0
+}
+
+func (m *BTCSignOutputRequest) GetHash() []byte {
+ if m != nil {
+ return m.Hash
+ }
+ return nil
+}
+
+func (m *BTCSignOutputRequest) GetKeypath() []uint32 {
+ if m != nil {
+ return m.Keypath
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterEnum("BTCCoin", BTCCoin_name, BTCCoin_value)
+ proto.RegisterEnum("BTCScriptType", BTCScriptType_name, BTCScriptType_value)
+ proto.RegisterEnum("BTCOutputType", BTCOutputType_name, BTCOutputType_value)
+ proto.RegisterEnum("BTCPubRequest_OutputType", BTCPubRequest_OutputType_name, BTCPubRequest_OutputType_value)
+ proto.RegisterEnum("BTCSignNextResponse_Type", BTCSignNextResponse_Type_name, BTCSignNextResponse_Type_value)
+ proto.RegisterType((*BTCPubRequest)(nil), "BTCPubRequest")
+ proto.RegisterType((*BTCSignInitRequest)(nil), "BTCSignInitRequest")
+ proto.RegisterType((*BTCSignNextResponse)(nil), "BTCSignNextResponse")
+ proto.RegisterType((*BTCSignInputRequest)(nil), "BTCSignInputRequest")
+ proto.RegisterType((*BTCSignOutputRequest)(nil), "BTCSignOutputRequest")
+}
+
+func init() { proto.RegisterFile("btc.proto", fileDescriptor_a38f9ffa5c78f451) }
+
+var fileDescriptor_a38f9ffa5c78f451 = []byte{
+ // 666 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x40,
+ 0x10, 0xad, 0x13, 0x27, 0x71, 0x26, 0x71, 0x65, 0x96, 0x0a, 0x19, 0x54, 0x44, 0x64, 0x0e, 0x54,
+ 0x95, 0x48, 0xa5, 0xd2, 0x13, 0xb7, 0x26, 0xad, 0x94, 0xa8, 0x28, 0xb1, 0xd6, 0x0e, 0x05, 0x2e,
+ 0xc1, 0x71, 0x57, 0x8d, 0xd5, 0x76, 0x6d, 0xb2, 0xeb, 0xa8, 0xf9, 0x0c, 0xf8, 0x17, 0x7e, 0x81,
+ 0xcf, 0x42, 0x68, 0xc7, 0x76, 0xec, 0x20, 0x2e, 0xdc, 0xde, 0xbc, 0x9d, 0x1d, 0xcf, 0x7b, 0xb3,
+ 0x63, 0x68, 0x2f, 0x64, 0xd8, 0x4f, 0x56, 0xb1, 0x8c, 0x9d, 0xef, 0x35, 0x30, 0x07, 0xfe, 0xd0,
+ 0x4d, 0x17, 0x94, 0x7d, 0x4b, 0x99, 0x90, 0xc4, 0x86, 0xd6, 0x1d, 0xdb, 0x24, 0x81, 0x5c, 0xda,
+ 0x5a, 0xaf, 0x7e, 0x64, 0xd2, 0x22, 0x24, 0x27, 0xd0, 0x11, 0xe1, 0x2a, 0x4a, 0xe4, 0x5c, 0x6e,
+ 0x12, 0x66, 0xd7, 0x7a, 0xda, 0xd1, 0xfe, 0xe9, 0x7e, 0x7f, 0xe0, 0x0f, 0x3d, 0xa4, 0xfd, 0x4d,
+ 0xc2, 0x28, 0x88, 0x2d, 0x26, 0x87, 0xa0, 0x87, 0x71, 0xc4, 0xed, 0x3a, 0x66, 0x1a, 0x2a, 0x73,
+ 0x18, 0x47, 0x9c, 0x22, 0x4b, 0xde, 0x43, 0x27, 0x4e, 0x65, 0x92, 0xe6, 0xe5, 0x74, 0x4c, 0x7a,
+ 0xde, 0xdf, 0xe9, 0xa6, 0x3f, 0xc5, 0x8c, 0xac, 0x72, 0xbc, 0xc5, 0xaa, 0xc9, 0x9b, 0x48, 0x24,
+ 0xf7, 0xc1, 0xc6, 0x6e, 0xf4, 0xb4, 0x23, 0x83, 0x16, 0xa1, 0x73, 0x0e, 0x50, 0xde, 0x21, 0x06,
+ 0xe8, 0xbe, 0x3b, 0x1b, 0x58, 0x7b, 0x0a, 0x7d, 0x52, 0x48, 0x53, 0xe8, 0xb3, 0x42, 0x35, 0x85,
+ 0xbe, 0x28, 0x54, 0x27, 0x1d, 0x68, 0x9d, 0x5f, 0x5c, 0xd0, 0x4b, 0xcf, 0xb3, 0x74, 0xe7, 0xb7,
+ 0x06, 0x44, 0x89, 0x8a, 0x6e, 0xf9, 0x98, 0x47, 0xb2, 0x30, 0xa6, 0x50, 0xa3, 0xfd, 0x53, 0xcd,
+ 0x7f, 0x9b, 0xf3, 0x1a, 0xcc, 0x45, 0x94, 0x9c, 0x9d, 0xcd, 0x83, 0x30, 0x8c, 0x53, 0x2e, 0xd1,
+ 0x25, 0x93, 0x76, 0x91, 0x3c, 0xcf, 0x38, 0xa5, 0x73, 0xcd, 0x56, 0x22, 0x8a, 0x39, 0xfa, 0x63,
+ 0xd2, 0x22, 0x24, 0x2f, 0x01, 0x78, 0xfa, 0x30, 0x8f, 0x78, 0x92, 0x4a, 0x81, 0x26, 0x98, 0xb4,
+ 0xcd, 0xd3, 0x87, 0x31, 0x12, 0xe4, 0x15, 0x74, 0xd4, 0x71, 0x66, 0x99, 0xb0, 0x9b, 0x78, 0xae,
+ 0x6e, 0x64, 0xe6, 0x08, 0xf2, 0x02, 0x8c, 0xfb, 0x38, 0xbc, 0x93, 0xd1, 0x03, 0xb3, 0x5b, 0x78,
+ 0xba, 0x8d, 0x9d, 0x5f, 0x1a, 0x3c, 0xcd, 0x0d, 0x98, 0xb0, 0x47, 0x49, 0x99, 0x48, 0x62, 0x2e,
+ 0x18, 0x79, 0x0b, 0x3a, 0x8a, 0xd3, 0xca, 0x51, 0xfd, 0x9d, 0xd3, 0x47, 0x9d, 0x98, 0x46, 0x0e,
+ 0xa0, 0x11, 0xf1, 0x1b, 0xf6, 0x88, 0x66, 0x98, 0x34, 0x0b, 0x94, 0xee, 0x65, 0x20, 0xe6, 0x22,
+ 0xba, 0xe5, 0x81, 0x4c, 0x57, 0x0c, 0x75, 0x1b, 0xb4, 0xbb, 0x0c, 0x84, 0x57, 0x70, 0xe4, 0x10,
+ 0xda, 0x65, 0x82, 0x52, 0xde, 0xa5, 0x25, 0xe1, 0xbc, 0x01, 0x1d, 0x2d, 0x6c, 0x43, 0x63, 0x3c,
+ 0x71, 0x67, 0xbe, 0xb5, 0x47, 0x00, 0x9a, 0xd3, 0x99, 0xaf, 0x30, 0x0e, 0xf8, 0x62, 0x3a, 0xb9,
+ 0xb4, 0x6a, 0xce, 0xcf, 0x52, 0x08, 0xfa, 0x52, 0x8c, 0xb2, 0x07, 0x9d, 0x64, 0xc5, 0xd6, 0xd3,
+ 0x54, 0x8e, 0x02, 0xb1, 0x44, 0x3d, 0x5d, 0x5a, 0xa5, 0x88, 0x03, 0xdd, 0x3c, 0x1c, 0x57, 0x24,
+ 0xec, 0x70, 0x95, 0x9c, 0x8f, 0xc1, 0x7d, 0x9a, 0x09, 0xd1, 0xe9, 0x0e, 0xa7, 0x6c, 0x16, 0xea,
+ 0xa3, 0x3c, 0x64, 0xf9, 0x04, 0xb7, 0x71, 0x75, 0xd3, 0x9a, 0x3b, 0x9b, 0xe6, 0xfc, 0xd0, 0xe0,
+ 0x20, 0xef, 0x3b, 0x9b, 0x57, 0xd1, 0x38, 0x01, 0x3d, 0x4e, 0x57, 0x02, 0x3b, 0x36, 0x28, 0x62,
+ 0xe2, 0xe4, 0x53, 0xa9, 0x3c, 0xb9, 0xca, 0xd6, 0x6c, 0x47, 0xb1, 0xae, 0xf4, 0x98, 0x05, 0xaa,
+ 0xda, 0x52, 0xe9, 0xcf, 0x0c, 0x46, 0x5c, 0x6d, 0xaa, 0xb1, 0xd3, 0xd4, 0xf1, 0x09, 0xb4, 0xf2,
+ 0x27, 0x4f, 0x5a, 0x50, 0x1f, 0xf8, 0xc3, 0x6c, 0xab, 0x7c, 0x85, 0x34, 0x45, 0x7d, 0xf0, 0x87,
+ 0xd9, 0x52, 0xf9, 0x0a, 0xd5, 0x8f, 0xbf, 0xe2, 0xaf, 0xa5, 0x7c, 0xfe, 0x84, 0xc0, 0xbe, 0x37,
+ 0xa4, 0x63, 0xd7, 0x9f, 0xcf, 0x26, 0x57, 0x93, 0xe9, 0xf5, 0xc4, 0xda, 0x23, 0x16, 0x74, 0x73,
+ 0xce, 0x3d, 0x75, 0xaf, 0x46, 0x96, 0x46, 0x9e, 0x01, 0xd9, 0x32, 0xd7, 0xee, 0xd5, 0x68, 0xee,
+ 0x9e, 0x7a, 0x23, 0xab, 0x46, 0x9e, 0x80, 0xb9, 0xc3, 0x5b, 0xf5, 0xe3, 0x11, 0x7e, 0xa1, 0xb2,
+ 0xef, 0x1d, 0x68, 0x95, 0xa5, 0xdb, 0xd0, 0x28, 0x6a, 0x1a, 0xa0, 0xe7, 0x55, 0x00, 0x9a, 0xc5,
+ 0xf5, 0x2c, 0xe1, 0xda, 0x1b, 0x59, 0xfa, 0xa2, 0x89, 0xbf, 0xc3, 0x77, 0x7f, 0x02, 0x00, 0x00,
+ 0xff, 0xff, 0x30, 0xce, 0x1a, 0xda, 0x1b, 0x05, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/btc.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/btc.proto
new file mode 100644
index 00000000..aa46334b
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/btc.proto
@@ -0,0 +1,94 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+enum BTCCoin {
+ BTC = 0;
+ TBTC = 1;
+ LTC = 2;
+ TLTC = 3;
+};
+
+enum BTCScriptType {
+ SCRIPT_UNKNOWN = 0;
+ SCRIPT_P2PKH = 1;
+ SCRIPT_P2WPKH_P2SH = 2;
+ SCRIPT_P2WPKH = 3;
+}
+
+message BTCPubRequest {
+ repeated uint32 keypath = 1;
+ enum OutputType {
+ TPUB = 0;
+ XPUB = 1;
+ YPUB = 2;
+ ZPUB = 3;
+ ADDRESS = 4;
+ }
+ BTCScriptType script_type = 2; // only applies for ADDRESS
+ BTCCoin coin = 3;
+ OutputType output_type = 4;
+ bool display = 5;
+}
+
+
+message BTCSignInitRequest {
+ BTCCoin coin = 1;
+ BTCScriptType script_type = 2; // script type for inputs and changes
+ uint32 bip44_account = 3;
+ uint32 version = 4; // reserved, must be 1
+ uint32 num_inputs = 5;
+ uint32 num_outputs = 6;
+ uint32 locktime = 7; // reserved, must be 0
+}
+
+message BTCSignNextResponse {
+ enum Type {
+ INPUT = 0;
+ OUTPUT = 1;
+ DONE = 2;
+ }
+ Type type = 1;
+ uint32 index = 2;
+ bool has_signature = 3; // only as a response to BTCSignInputRequest
+ // 64 bytes (32 bytes big endian R, 32 bytes big endian S). Only if has_signature is true.
+ bytes signature = 4;
+}
+
+message BTCSignInputRequest {
+ bytes prevOutHash = 1;
+ uint32 prevOutIndex = 2;
+ uint64 prevOutValue = 3;
+ uint32 sequence = 4; // reserved, must be 0xffffffff
+ repeated uint32 keypath = 6; // all inputs must be ours.
+}
+
+enum BTCOutputType {
+ UNKNOWN = 0;
+ P2PKH = 1;
+ P2SH = 2;
+ P2WPKH = 3;
+ P2WSH = 4;
+}
+
+message BTCSignOutputRequest {
+ bool ours = 1;
+ BTCOutputType type = 2; // if ours is false
+ // 20 bytes for p2pkh, p2sh, pw2wpkh. 32 bytes for p2wsh.
+ uint64 value = 3;
+ bytes hash = 4; // if ours is false
+ repeated uint32 keypath = 5; // if ours is true
+}
+
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/common.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/common.pb.go
new file mode 100644
index 00000000..ac7061f1
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/common.pb.go
@@ -0,0 +1,75 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: common.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type PubResponse struct {
+ Pub string `protobuf:"bytes,1,opt,name=pub,proto3" json:"pub,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *PubResponse) Reset() { *m = PubResponse{} }
+func (m *PubResponse) String() string { return proto.CompactTextString(m) }
+func (*PubResponse) ProtoMessage() {}
+func (*PubResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_555bd8c177793206, []int{0}
+}
+
+func (m *PubResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_PubResponse.Unmarshal(m, b)
+}
+func (m *PubResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_PubResponse.Marshal(b, m, deterministic)
+}
+func (m *PubResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_PubResponse.Merge(m, src)
+}
+func (m *PubResponse) XXX_Size() int {
+ return xxx_messageInfo_PubResponse.Size(m)
+}
+func (m *PubResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_PubResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_PubResponse proto.InternalMessageInfo
+
+func (m *PubResponse) GetPub() string {
+ if m != nil {
+ return m.Pub
+ }
+ return ""
+}
+
+func init() {
+ proto.RegisterType((*PubResponse)(nil), "PubResponse")
+}
+
+func init() { proto.RegisterFile("common.proto", fileDescriptor_555bd8c177793206) }
+
+var fileDescriptor_555bd8c177793206 = []byte{
+ // 74 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0xce, 0xcf, 0xcd,
+ 0xcd, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57, 0x92, 0xe7, 0xe2, 0x0e, 0x28, 0x4d, 0x0a,
+ 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x15, 0x12, 0xe0, 0x62, 0x2e, 0x28, 0x4d, 0x92, 0x60,
+ 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0x31, 0x93, 0xd8, 0xc0, 0xea, 0x8c, 0x01, 0x01, 0x00, 0x00,
+ 0xff, 0xff, 0xee, 0x8d, 0x87, 0xf0, 0x37, 0x00, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/common.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/common.proto
new file mode 100644
index 00000000..c0354b8b
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/common.proto
@@ -0,0 +1,19 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+message PubResponse {
+ string pub = 1;
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/eth.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/eth.pb.go
new file mode 100644
index 00000000..5364eb3f
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/eth.pb.go
@@ -0,0 +1,484 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: eth.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type ETHCoin int32
+
+const (
+ ETHCoin_ETH ETHCoin = 0
+ ETHCoin_RopstenETH ETHCoin = 1
+ ETHCoin_RinkebyETH ETHCoin = 2
+)
+
+var ETHCoin_name = map[int32]string{
+ 0: "ETH",
+ 1: "RopstenETH",
+ 2: "RinkebyETH",
+}
+
+var ETHCoin_value = map[string]int32{
+ "ETH": 0,
+ "RopstenETH": 1,
+ "RinkebyETH": 2,
+}
+
+func (x ETHCoin) String() string {
+ return proto.EnumName(ETHCoin_name, int32(x))
+}
+
+func (ETHCoin) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_d980f775760351f6, []int{0}
+}
+
+type ETHPubRequest_OutputType int32
+
+const (
+ ETHPubRequest_ADDRESS ETHPubRequest_OutputType = 0
+ ETHPubRequest_XPUB ETHPubRequest_OutputType = 1
+)
+
+var ETHPubRequest_OutputType_name = map[int32]string{
+ 0: "ADDRESS",
+ 1: "XPUB",
+}
+
+var ETHPubRequest_OutputType_value = map[string]int32{
+ "ADDRESS": 0,
+ "XPUB": 1,
+}
+
+func (x ETHPubRequest_OutputType) String() string {
+ return proto.EnumName(ETHPubRequest_OutputType_name, int32(x))
+}
+
+func (ETHPubRequest_OutputType) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_d980f775760351f6, []int{0, 0}
+}
+
+type ETHPubRequest struct {
+ Keypath []uint32 `protobuf:"varint,1,rep,packed,name=keypath,proto3" json:"keypath,omitempty"`
+ Coin ETHCoin `protobuf:"varint,2,opt,name=coin,proto3,enum=ETHCoin" json:"coin,omitempty"`
+ OutputType ETHPubRequest_OutputType `protobuf:"varint,3,opt,name=output_type,json=outputType,proto3,enum=ETHPubRequest_OutputType" json:"output_type,omitempty"`
+ Display bool `protobuf:"varint,4,opt,name=display,proto3" json:"display,omitempty"`
+ ContractAddress []byte `protobuf:"bytes,5,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ETHPubRequest) Reset() { *m = ETHPubRequest{} }
+func (m *ETHPubRequest) String() string { return proto.CompactTextString(m) }
+func (*ETHPubRequest) ProtoMessage() {}
+func (*ETHPubRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_d980f775760351f6, []int{0}
+}
+
+func (m *ETHPubRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ETHPubRequest.Unmarshal(m, b)
+}
+func (m *ETHPubRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ETHPubRequest.Marshal(b, m, deterministic)
+}
+func (m *ETHPubRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ETHPubRequest.Merge(m, src)
+}
+func (m *ETHPubRequest) XXX_Size() int {
+ return xxx_messageInfo_ETHPubRequest.Size(m)
+}
+func (m *ETHPubRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_ETHPubRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ETHPubRequest proto.InternalMessageInfo
+
+func (m *ETHPubRequest) GetKeypath() []uint32 {
+ if m != nil {
+ return m.Keypath
+ }
+ return nil
+}
+
+func (m *ETHPubRequest) GetCoin() ETHCoin {
+ if m != nil {
+ return m.Coin
+ }
+ return ETHCoin_ETH
+}
+
+func (m *ETHPubRequest) GetOutputType() ETHPubRequest_OutputType {
+ if m != nil {
+ return m.OutputType
+ }
+ return ETHPubRequest_ADDRESS
+}
+
+func (m *ETHPubRequest) GetDisplay() bool {
+ if m != nil {
+ return m.Display
+ }
+ return false
+}
+
+func (m *ETHPubRequest) GetContractAddress() []byte {
+ if m != nil {
+ return m.ContractAddress
+ }
+ return nil
+}
+
+type ETHSignRequest struct {
+ Coin ETHCoin `protobuf:"varint,1,opt,name=coin,proto3,enum=ETHCoin" json:"coin,omitempty"`
+ Keypath []uint32 `protobuf:"varint,2,rep,packed,name=keypath,proto3" json:"keypath,omitempty"`
+ Nonce []byte `protobuf:"bytes,3,opt,name=nonce,proto3" json:"nonce,omitempty"`
+ GasPrice []byte `protobuf:"bytes,4,opt,name=gas_price,json=gasPrice,proto3" json:"gas_price,omitempty"`
+ GasLimit []byte `protobuf:"bytes,5,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"`
+ Recipient []byte `protobuf:"bytes,6,opt,name=recipient,proto3" json:"recipient,omitempty"`
+ Value []byte `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"`
+ Data []byte `protobuf:"bytes,8,opt,name=data,proto3" json:"data,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ETHSignRequest) Reset() { *m = ETHSignRequest{} }
+func (m *ETHSignRequest) String() string { return proto.CompactTextString(m) }
+func (*ETHSignRequest) ProtoMessage() {}
+func (*ETHSignRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_d980f775760351f6, []int{1}
+}
+
+func (m *ETHSignRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ETHSignRequest.Unmarshal(m, b)
+}
+func (m *ETHSignRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ETHSignRequest.Marshal(b, m, deterministic)
+}
+func (m *ETHSignRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ETHSignRequest.Merge(m, src)
+}
+func (m *ETHSignRequest) XXX_Size() int {
+ return xxx_messageInfo_ETHSignRequest.Size(m)
+}
+func (m *ETHSignRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_ETHSignRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ETHSignRequest proto.InternalMessageInfo
+
+func (m *ETHSignRequest) GetCoin() ETHCoin {
+ if m != nil {
+ return m.Coin
+ }
+ return ETHCoin_ETH
+}
+
+func (m *ETHSignRequest) GetKeypath() []uint32 {
+ if m != nil {
+ return m.Keypath
+ }
+ return nil
+}
+
+func (m *ETHSignRequest) GetNonce() []byte {
+ if m != nil {
+ return m.Nonce
+ }
+ return nil
+}
+
+func (m *ETHSignRequest) GetGasPrice() []byte {
+ if m != nil {
+ return m.GasPrice
+ }
+ return nil
+}
+
+func (m *ETHSignRequest) GetGasLimit() []byte {
+ if m != nil {
+ return m.GasLimit
+ }
+ return nil
+}
+
+func (m *ETHSignRequest) GetRecipient() []byte {
+ if m != nil {
+ return m.Recipient
+ }
+ return nil
+}
+
+func (m *ETHSignRequest) GetValue() []byte {
+ if m != nil {
+ return m.Value
+ }
+ return nil
+}
+
+func (m *ETHSignRequest) GetData() []byte {
+ if m != nil {
+ return m.Data
+ }
+ return nil
+}
+
+type ETHSignResponse struct {
+ Signature []byte `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ETHSignResponse) Reset() { *m = ETHSignResponse{} }
+func (m *ETHSignResponse) String() string { return proto.CompactTextString(m) }
+func (*ETHSignResponse) ProtoMessage() {}
+func (*ETHSignResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_d980f775760351f6, []int{2}
+}
+
+func (m *ETHSignResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ETHSignResponse.Unmarshal(m, b)
+}
+func (m *ETHSignResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ETHSignResponse.Marshal(b, m, deterministic)
+}
+func (m *ETHSignResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ETHSignResponse.Merge(m, src)
+}
+func (m *ETHSignResponse) XXX_Size() int {
+ return xxx_messageInfo_ETHSignResponse.Size(m)
+}
+func (m *ETHSignResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_ETHSignResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ETHSignResponse proto.InternalMessageInfo
+
+func (m *ETHSignResponse) GetSignature() []byte {
+ if m != nil {
+ return m.Signature
+ }
+ return nil
+}
+
+type ETHRequest struct {
+ // Types that are valid to be assigned to Request:
+ // *ETHRequest_Pub
+ // *ETHRequest_Sign
+ Request isETHRequest_Request `protobuf_oneof:"request"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ETHRequest) Reset() { *m = ETHRequest{} }
+func (m *ETHRequest) String() string { return proto.CompactTextString(m) }
+func (*ETHRequest) ProtoMessage() {}
+func (*ETHRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_d980f775760351f6, []int{3}
+}
+
+func (m *ETHRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ETHRequest.Unmarshal(m, b)
+}
+func (m *ETHRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ETHRequest.Marshal(b, m, deterministic)
+}
+func (m *ETHRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ETHRequest.Merge(m, src)
+}
+func (m *ETHRequest) XXX_Size() int {
+ return xxx_messageInfo_ETHRequest.Size(m)
+}
+func (m *ETHRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_ETHRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ETHRequest proto.InternalMessageInfo
+
+type isETHRequest_Request interface {
+ isETHRequest_Request()
+}
+
+type ETHRequest_Pub struct {
+ Pub *ETHPubRequest `protobuf:"bytes,1,opt,name=pub,proto3,oneof"`
+}
+
+type ETHRequest_Sign struct {
+ Sign *ETHSignRequest `protobuf:"bytes,2,opt,name=sign,proto3,oneof"`
+}
+
+func (*ETHRequest_Pub) isETHRequest_Request() {}
+
+func (*ETHRequest_Sign) isETHRequest_Request() {}
+
+func (m *ETHRequest) GetRequest() isETHRequest_Request {
+ if m != nil {
+ return m.Request
+ }
+ return nil
+}
+
+func (m *ETHRequest) GetPub() *ETHPubRequest {
+ if x, ok := m.GetRequest().(*ETHRequest_Pub); ok {
+ return x.Pub
+ }
+ return nil
+}
+
+func (m *ETHRequest) GetSign() *ETHSignRequest {
+ if x, ok := m.GetRequest().(*ETHRequest_Sign); ok {
+ return x.Sign
+ }
+ return nil
+}
+
+// XXX_OneofWrappers is for the internal use of the proto package.
+func (*ETHRequest) XXX_OneofWrappers() []interface{} {
+ return []interface{}{
+ (*ETHRequest_Pub)(nil),
+ (*ETHRequest_Sign)(nil),
+ }
+}
+
+type ETHResponse struct {
+ // Types that are valid to be assigned to Response:
+ // *ETHResponse_Pub
+ // *ETHResponse_Sign
+ Response isETHResponse_Response `protobuf_oneof:"response"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ETHResponse) Reset() { *m = ETHResponse{} }
+func (m *ETHResponse) String() string { return proto.CompactTextString(m) }
+func (*ETHResponse) ProtoMessage() {}
+func (*ETHResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_d980f775760351f6, []int{4}
+}
+
+func (m *ETHResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ETHResponse.Unmarshal(m, b)
+}
+func (m *ETHResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ETHResponse.Marshal(b, m, deterministic)
+}
+func (m *ETHResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ETHResponse.Merge(m, src)
+}
+func (m *ETHResponse) XXX_Size() int {
+ return xxx_messageInfo_ETHResponse.Size(m)
+}
+func (m *ETHResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_ETHResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ETHResponse proto.InternalMessageInfo
+
+type isETHResponse_Response interface {
+ isETHResponse_Response()
+}
+
+type ETHResponse_Pub struct {
+ Pub *PubResponse `protobuf:"bytes,1,opt,name=pub,proto3,oneof"`
+}
+
+type ETHResponse_Sign struct {
+ Sign *ETHSignResponse `protobuf:"bytes,2,opt,name=sign,proto3,oneof"`
+}
+
+func (*ETHResponse_Pub) isETHResponse_Response() {}
+
+func (*ETHResponse_Sign) isETHResponse_Response() {}
+
+func (m *ETHResponse) GetResponse() isETHResponse_Response {
+ if m != nil {
+ return m.Response
+ }
+ return nil
+}
+
+func (m *ETHResponse) GetPub() *PubResponse {
+ if x, ok := m.GetResponse().(*ETHResponse_Pub); ok {
+ return x.Pub
+ }
+ return nil
+}
+
+func (m *ETHResponse) GetSign() *ETHSignResponse {
+ if x, ok := m.GetResponse().(*ETHResponse_Sign); ok {
+ return x.Sign
+ }
+ return nil
+}
+
+// XXX_OneofWrappers is for the internal use of the proto package.
+func (*ETHResponse) XXX_OneofWrappers() []interface{} {
+ return []interface{}{
+ (*ETHResponse_Pub)(nil),
+ (*ETHResponse_Sign)(nil),
+ }
+}
+
+func init() {
+ proto.RegisterEnum("ETHCoin", ETHCoin_name, ETHCoin_value)
+ proto.RegisterEnum("ETHPubRequest_OutputType", ETHPubRequest_OutputType_name, ETHPubRequest_OutputType_value)
+ proto.RegisterType((*ETHPubRequest)(nil), "ETHPubRequest")
+ proto.RegisterType((*ETHSignRequest)(nil), "ETHSignRequest")
+ proto.RegisterType((*ETHSignResponse)(nil), "ETHSignResponse")
+ proto.RegisterType((*ETHRequest)(nil), "ETHRequest")
+ proto.RegisterType((*ETHResponse)(nil), "ETHResponse")
+}
+
+func init() { proto.RegisterFile("eth.proto", fileDescriptor_d980f775760351f6) }
+
+var fileDescriptor_d980f775760351f6 = []byte{
+ // 463 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0x41, 0x6f, 0x9b, 0x30,
+ 0x1c, 0xc5, 0x43, 0x92, 0x16, 0xf2, 0x87, 0x26, 0xc8, 0xda, 0x81, 0x6d, 0x3d, 0x20, 0xa6, 0x4d,
+ 0xd9, 0x0e, 0x4c, 0xca, 0x6e, 0xbb, 0xb5, 0x2b, 0x12, 0x87, 0x49, 0x8b, 0x1c, 0x26, 0xed, 0x16,
+ 0x19, 0x62, 0xa5, 0x56, 0x13, 0xdb, 0xc3, 0x66, 0x12, 0xdf, 0x76, 0x5f, 0x60, 0xdf, 0x61, 0xb2,
+ 0x09, 0x49, 0x99, 0x76, 0xf3, 0xef, 0x3d, 0xe3, 0xc7, 0xfb, 0x1b, 0x60, 0x46, 0xf5, 0x63, 0x2a,
+ 0x6b, 0xa1, 0xc5, 0xab, 0xa0, 0x12, 0xc7, 0xa3, 0xe0, 0x1d, 0x25, 0x7f, 0x1c, 0xb8, 0xc9, 0x8a,
+ 0x7c, 0xdd, 0x94, 0x98, 0xfe, 0x6c, 0xa8, 0xd2, 0x28, 0x02, 0xf7, 0x89, 0xb6, 0x92, 0xe8, 0xc7,
+ 0xc8, 0x89, 0x27, 0xcb, 0x1b, 0xdc, 0x23, 0xba, 0x85, 0x69, 0x25, 0x18, 0x8f, 0xc6, 0xb1, 0xb3,
+ 0x9c, 0xaf, 0xbc, 0x34, 0x2b, 0xf2, 0x2f, 0x82, 0x71, 0x6c, 0x55, 0xf4, 0x19, 0x7c, 0xd1, 0x68,
+ 0xd9, 0xe8, 0xad, 0x6e, 0x25, 0x8d, 0x26, 0x76, 0xd3, 0xcb, 0x74, 0x70, 0x78, 0xfa, 0xcd, 0xee,
+ 0x28, 0x5a, 0x49, 0x31, 0x88, 0xf3, 0xda, 0x64, 0xee, 0x98, 0x92, 0x07, 0xd2, 0x46, 0xd3, 0xd8,
+ 0x59, 0x7a, 0xb8, 0x47, 0xf4, 0x1e, 0xc2, 0x4a, 0x70, 0x5d, 0x93, 0x4a, 0x6f, 0xc9, 0x6e, 0x57,
+ 0x53, 0xa5, 0xa2, 0xab, 0xd8, 0x59, 0x06, 0x78, 0xd1, 0xeb, 0x77, 0x9d, 0x9c, 0xbc, 0x01, 0xb8,
+ 0x1c, 0x8f, 0x7c, 0x70, 0xef, 0x1e, 0x1e, 0x70, 0xb6, 0xd9, 0x84, 0x23, 0xe4, 0xc1, 0xf4, 0xc7,
+ 0xfa, 0xfb, 0x7d, 0xe8, 0x24, 0xbf, 0x1d, 0x98, 0x67, 0x45, 0xbe, 0x61, 0x7b, 0xde, 0x17, 0xee,
+ 0x6b, 0x39, 0xff, 0xad, 0xf5, 0x6c, 0x1c, 0xe3, 0xe1, 0x38, 0x5e, 0xc0, 0x15, 0x17, 0xbc, 0xea,
+ 0xaa, 0x06, 0xb8, 0x03, 0xf4, 0x1a, 0x66, 0x7b, 0xa2, 0xb6, 0xb2, 0x66, 0x15, 0xb5, 0x65, 0x02,
+ 0xec, 0xed, 0x89, 0x5a, 0x1b, 0xee, 0xcd, 0x03, 0x3b, 0x32, 0x7d, 0xaa, 0x61, 0xcc, 0xaf, 0x86,
+ 0xd1, 0x2d, 0xcc, 0x6a, 0x5a, 0x31, 0xc9, 0x28, 0xd7, 0xd1, 0xb5, 0x35, 0x2f, 0x82, 0x49, 0xfb,
+ 0x45, 0x0e, 0x0d, 0x8d, 0xdc, 0x2e, 0xcd, 0x02, 0x42, 0x30, 0xdd, 0x11, 0x4d, 0x22, 0xcf, 0x8a,
+ 0x76, 0x9d, 0x7c, 0x84, 0xc5, 0xb9, 0xa1, 0x92, 0x82, 0x2b, 0x6a, 0x8e, 0x56, 0x6c, 0xcf, 0x89,
+ 0x6e, 0x6a, 0x6a, 0x7b, 0x06, 0xf8, 0x22, 0x24, 0x25, 0x40, 0x56, 0xe4, 0xfd, 0x38, 0x12, 0x98,
+ 0xc8, 0xa6, 0xb4, 0xbb, 0xfc, 0xd5, 0x7c, 0x78, 0x7f, 0xf9, 0x08, 0x1b, 0x13, 0xbd, 0x85, 0xa9,
+ 0x79, 0xdc, 0x7e, 0x09, 0xfe, 0x6a, 0x91, 0x0e, 0x27, 0x9a, 0x8f, 0xb0, 0xb5, 0xef, 0x67, 0xe0,
+ 0xd6, 0x9d, 0x94, 0x54, 0xe0, 0xdb, 0x8c, 0xd3, 0x0b, 0xc5, 0xcf, 0x43, 0x82, 0xd4, 0x26, 0x74,
+ 0x56, 0x1f, 0xf1, 0x6e, 0x10, 0x11, 0xa6, 0xff, 0x54, 0x3a, 0x67, 0x00, 0x78, 0xf5, 0x49, 0xfb,
+ 0xb0, 0x02, 0xf7, 0x74, 0x79, 0xc8, 0x85, 0x49, 0x56, 0xe4, 0xe1, 0x08, 0xcd, 0x01, 0xb0, 0x90,
+ 0x4a, 0x53, 0x6e, 0xd8, 0xb1, 0xcc, 0xf8, 0x13, 0x2d, 0x5b, 0xc3, 0xe3, 0xf2, 0xda, 0xfe, 0x07,
+ 0x9f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x3a, 0x21, 0xef, 0x76, 0x22, 0x03, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/eth.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/eth.proto
new file mode 100644
index 00000000..98c49d5f
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/eth.proto
@@ -0,0 +1,64 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+import "common.proto";
+
+enum ETHCoin {
+ ETH = 0;
+ RopstenETH = 1;
+ RinkebyETH = 2;
+}
+
+message ETHPubRequest {
+ repeated uint32 keypath = 1;
+ ETHCoin coin = 2;
+ enum OutputType {
+ ADDRESS = 0;
+ XPUB = 1;
+ }
+ OutputType output_type = 3;
+ bool display = 4;
+ bytes contract_address = 5;
+}
+
+message ETHSignRequest {
+ ETHCoin coin = 1;
+ repeated uint32 keypath = 2;
+ bytes nonce = 3; // smallest big endian serialization, max. 16 bytes
+ bytes gas_price = 4; // smallest big endian serialization, max. 16 bytes
+ bytes gas_limit = 5; // smallest big endian serialization, max. 16 bytes
+ bytes recipient = 6; // 20 byte recipient
+ bytes value = 7; // smallest big endian serialization, max. 32 bytes
+ bytes data = 8;
+}
+
+message ETHSignResponse {
+ bytes signature = 1; // 65 bytes, last byte is the recid
+}
+
+message ETHRequest {
+ oneof request {
+ ETHPubRequest pub = 1;
+ ETHSignRequest sign = 2;
+ }
+}
+
+message ETHResponse {
+ oneof response {
+ PubResponse pub = 1;
+ ETHSignResponse sign = 2;
+ }
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/hww.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/hww.pb.go
new file mode 100644
index 00000000..ce505f93
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/hww.pb.go
@@ -0,0 +1,781 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: hww.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type Error struct {
+ Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
+ Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Error) Reset() { *m = Error{} }
+func (m *Error) String() string { return proto.CompactTextString(m) }
+func (*Error) ProtoMessage() {}
+func (*Error) Descriptor() ([]byte, []int) {
+ return fileDescriptor_c12bd9e6412b8a05, []int{0}
+}
+
+func (m *Error) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Error.Unmarshal(m, b)
+}
+func (m *Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Error.Marshal(b, m, deterministic)
+}
+func (m *Error) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Error.Merge(m, src)
+}
+func (m *Error) XXX_Size() int {
+ return xxx_messageInfo_Error.Size(m)
+}
+func (m *Error) XXX_DiscardUnknown() {
+ xxx_messageInfo_Error.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Error proto.InternalMessageInfo
+
+func (m *Error) GetCode() int32 {
+ if m != nil {
+ return m.Code
+ }
+ return 0
+}
+
+func (m *Error) GetMessage() string {
+ if m != nil {
+ return m.Message
+ }
+ return ""
+}
+
+type Success struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Success) Reset() { *m = Success{} }
+func (m *Success) String() string { return proto.CompactTextString(m) }
+func (*Success) ProtoMessage() {}
+func (*Success) Descriptor() ([]byte, []int) {
+ return fileDescriptor_c12bd9e6412b8a05, []int{1}
+}
+
+func (m *Success) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Success.Unmarshal(m, b)
+}
+func (m *Success) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Success.Marshal(b, m, deterministic)
+}
+func (m *Success) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Success.Merge(m, src)
+}
+func (m *Success) XXX_Size() int {
+ return xxx_messageInfo_Success.Size(m)
+}
+func (m *Success) XXX_DiscardUnknown() {
+ xxx_messageInfo_Success.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Success proto.InternalMessageInfo
+
+type Request struct {
+ // Types that are valid to be assigned to Request:
+ // *Request_RandomNumber
+ // *Request_DeviceName
+ // *Request_DeviceLanguage
+ // *Request_DeviceInfo
+ // *Request_SetPassword
+ // *Request_CreateBackup
+ // *Request_ShowMnemonic
+ // *Request_BtcPub
+ // *Request_BtcSignInit
+ // *Request_BtcSignInput
+ // *Request_BtcSignOutput
+ // *Request_InsertRemoveSdcard
+ // *Request_CheckSdcard
+ // *Request_SetMnemonicPassphraseEnabled
+ // *Request_ListBackups
+ // *Request_RestoreBackup
+ // *Request_PerformAttestation
+ // *Request_Reboot
+ // *Request_CheckBackup
+ // *Request_Eth
+ // *Request_Reset_
+ // *Request_RestoreFromMnemonic
+ // *Request_Bitboxbase
+ Request isRequest_Request `protobuf_oneof:"request"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Request) Reset() { *m = Request{} }
+func (m *Request) String() string { return proto.CompactTextString(m) }
+func (*Request) ProtoMessage() {}
+func (*Request) Descriptor() ([]byte, []int) {
+ return fileDescriptor_c12bd9e6412b8a05, []int{2}
+}
+
+func (m *Request) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Request.Unmarshal(m, b)
+}
+func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Request.Marshal(b, m, deterministic)
+}
+func (m *Request) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Request.Merge(m, src)
+}
+func (m *Request) XXX_Size() int {
+ return xxx_messageInfo_Request.Size(m)
+}
+func (m *Request) XXX_DiscardUnknown() {
+ xxx_messageInfo_Request.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Request proto.InternalMessageInfo
+
+type isRequest_Request interface {
+ isRequest_Request()
+}
+
+type Request_RandomNumber struct {
+ RandomNumber *RandomNumberRequest `protobuf:"bytes,1,opt,name=random_number,json=randomNumber,proto3,oneof"`
+}
+
+type Request_DeviceName struct {
+ DeviceName *SetDeviceNameRequest `protobuf:"bytes,2,opt,name=device_name,json=deviceName,proto3,oneof"`
+}
+
+type Request_DeviceLanguage struct {
+ DeviceLanguage *SetDeviceLanguageRequest `protobuf:"bytes,3,opt,name=device_language,json=deviceLanguage,proto3,oneof"`
+}
+
+type Request_DeviceInfo struct {
+ DeviceInfo *DeviceInfoRequest `protobuf:"bytes,4,opt,name=device_info,json=deviceInfo,proto3,oneof"`
+}
+
+type Request_SetPassword struct {
+ SetPassword *SetPasswordRequest `protobuf:"bytes,5,opt,name=set_password,json=setPassword,proto3,oneof"`
+}
+
+type Request_CreateBackup struct {
+ CreateBackup *CreateBackupRequest `protobuf:"bytes,6,opt,name=create_backup,json=createBackup,proto3,oneof"`
+}
+
+type Request_ShowMnemonic struct {
+ ShowMnemonic *ShowMnemonicRequest `protobuf:"bytes,7,opt,name=show_mnemonic,json=showMnemonic,proto3,oneof"`
+}
+
+type Request_BtcPub struct {
+ BtcPub *BTCPubRequest `protobuf:"bytes,8,opt,name=btc_pub,json=btcPub,proto3,oneof"`
+}
+
+type Request_BtcSignInit struct {
+ BtcSignInit *BTCSignInitRequest `protobuf:"bytes,9,opt,name=btc_sign_init,json=btcSignInit,proto3,oneof"`
+}
+
+type Request_BtcSignInput struct {
+ BtcSignInput *BTCSignInputRequest `protobuf:"bytes,10,opt,name=btc_sign_input,json=btcSignInput,proto3,oneof"`
+}
+
+type Request_BtcSignOutput struct {
+ BtcSignOutput *BTCSignOutputRequest `protobuf:"bytes,11,opt,name=btc_sign_output,json=btcSignOutput,proto3,oneof"`
+}
+
+type Request_InsertRemoveSdcard struct {
+ InsertRemoveSdcard *InsertRemoveSDCardRequest `protobuf:"bytes,12,opt,name=insert_remove_sdcard,json=insertRemoveSdcard,proto3,oneof"`
+}
+
+type Request_CheckSdcard struct {
+ CheckSdcard *CheckSDCardRequest `protobuf:"bytes,13,opt,name=check_sdcard,json=checkSdcard,proto3,oneof"`
+}
+
+type Request_SetMnemonicPassphraseEnabled struct {
+ SetMnemonicPassphraseEnabled *SetMnemonicPassphraseEnabledRequest `protobuf:"bytes,14,opt,name=set_mnemonic_passphrase_enabled,json=setMnemonicPassphraseEnabled,proto3,oneof"`
+}
+
+type Request_ListBackups struct {
+ ListBackups *ListBackupsRequest `protobuf:"bytes,15,opt,name=list_backups,json=listBackups,proto3,oneof"`
+}
+
+type Request_RestoreBackup struct {
+ RestoreBackup *RestoreBackupRequest `protobuf:"bytes,16,opt,name=restore_backup,json=restoreBackup,proto3,oneof"`
+}
+
+type Request_PerformAttestation struct {
+ PerformAttestation *PerformAttestationRequest `protobuf:"bytes,17,opt,name=perform_attestation,json=performAttestation,proto3,oneof"`
+}
+
+type Request_Reboot struct {
+ Reboot *RebootRequest `protobuf:"bytes,18,opt,name=reboot,proto3,oneof"`
+}
+
+type Request_CheckBackup struct {
+ CheckBackup *CheckBackupRequest `protobuf:"bytes,19,opt,name=check_backup,json=checkBackup,proto3,oneof"`
+}
+
+type Request_Eth struct {
+ Eth *ETHRequest `protobuf:"bytes,20,opt,name=eth,proto3,oneof"`
+}
+
+type Request_Reset_ struct {
+ Reset_ *ResetRequest `protobuf:"bytes,21,opt,name=reset,proto3,oneof"`
+}
+
+type Request_RestoreFromMnemonic struct {
+ RestoreFromMnemonic *RestoreFromMnemonicRequest `protobuf:"bytes,22,opt,name=restore_from_mnemonic,json=restoreFromMnemonic,proto3,oneof"`
+}
+
+type Request_Bitboxbase struct {
+ Bitboxbase *BitBoxBaseRequest `protobuf:"bytes,23,opt,name=bitboxbase,proto3,oneof"`
+}
+
+func (*Request_RandomNumber) isRequest_Request() {}
+
+func (*Request_DeviceName) isRequest_Request() {}
+
+func (*Request_DeviceLanguage) isRequest_Request() {}
+
+func (*Request_DeviceInfo) isRequest_Request() {}
+
+func (*Request_SetPassword) isRequest_Request() {}
+
+func (*Request_CreateBackup) isRequest_Request() {}
+
+func (*Request_ShowMnemonic) isRequest_Request() {}
+
+func (*Request_BtcPub) isRequest_Request() {}
+
+func (*Request_BtcSignInit) isRequest_Request() {}
+
+func (*Request_BtcSignInput) isRequest_Request() {}
+
+func (*Request_BtcSignOutput) isRequest_Request() {}
+
+func (*Request_InsertRemoveSdcard) isRequest_Request() {}
+
+func (*Request_CheckSdcard) isRequest_Request() {}
+
+func (*Request_SetMnemonicPassphraseEnabled) isRequest_Request() {}
+
+func (*Request_ListBackups) isRequest_Request() {}
+
+func (*Request_RestoreBackup) isRequest_Request() {}
+
+func (*Request_PerformAttestation) isRequest_Request() {}
+
+func (*Request_Reboot) isRequest_Request() {}
+
+func (*Request_CheckBackup) isRequest_Request() {}
+
+func (*Request_Eth) isRequest_Request() {}
+
+func (*Request_Reset_) isRequest_Request() {}
+
+func (*Request_RestoreFromMnemonic) isRequest_Request() {}
+
+func (*Request_Bitboxbase) isRequest_Request() {}
+
+func (m *Request) GetRequest() isRequest_Request {
+ if m != nil {
+ return m.Request
+ }
+ return nil
+}
+
+func (m *Request) GetRandomNumber() *RandomNumberRequest {
+ if x, ok := m.GetRequest().(*Request_RandomNumber); ok {
+ return x.RandomNumber
+ }
+ return nil
+}
+
+func (m *Request) GetDeviceName() *SetDeviceNameRequest {
+ if x, ok := m.GetRequest().(*Request_DeviceName); ok {
+ return x.DeviceName
+ }
+ return nil
+}
+
+func (m *Request) GetDeviceLanguage() *SetDeviceLanguageRequest {
+ if x, ok := m.GetRequest().(*Request_DeviceLanguage); ok {
+ return x.DeviceLanguage
+ }
+ return nil
+}
+
+func (m *Request) GetDeviceInfo() *DeviceInfoRequest {
+ if x, ok := m.GetRequest().(*Request_DeviceInfo); ok {
+ return x.DeviceInfo
+ }
+ return nil
+}
+
+func (m *Request) GetSetPassword() *SetPasswordRequest {
+ if x, ok := m.GetRequest().(*Request_SetPassword); ok {
+ return x.SetPassword
+ }
+ return nil
+}
+
+func (m *Request) GetCreateBackup() *CreateBackupRequest {
+ if x, ok := m.GetRequest().(*Request_CreateBackup); ok {
+ return x.CreateBackup
+ }
+ return nil
+}
+
+func (m *Request) GetShowMnemonic() *ShowMnemonicRequest {
+ if x, ok := m.GetRequest().(*Request_ShowMnemonic); ok {
+ return x.ShowMnemonic
+ }
+ return nil
+}
+
+func (m *Request) GetBtcPub() *BTCPubRequest {
+ if x, ok := m.GetRequest().(*Request_BtcPub); ok {
+ return x.BtcPub
+ }
+ return nil
+}
+
+func (m *Request) GetBtcSignInit() *BTCSignInitRequest {
+ if x, ok := m.GetRequest().(*Request_BtcSignInit); ok {
+ return x.BtcSignInit
+ }
+ return nil
+}
+
+func (m *Request) GetBtcSignInput() *BTCSignInputRequest {
+ if x, ok := m.GetRequest().(*Request_BtcSignInput); ok {
+ return x.BtcSignInput
+ }
+ return nil
+}
+
+func (m *Request) GetBtcSignOutput() *BTCSignOutputRequest {
+ if x, ok := m.GetRequest().(*Request_BtcSignOutput); ok {
+ return x.BtcSignOutput
+ }
+ return nil
+}
+
+func (m *Request) GetInsertRemoveSdcard() *InsertRemoveSDCardRequest {
+ if x, ok := m.GetRequest().(*Request_InsertRemoveSdcard); ok {
+ return x.InsertRemoveSdcard
+ }
+ return nil
+}
+
+func (m *Request) GetCheckSdcard() *CheckSDCardRequest {
+ if x, ok := m.GetRequest().(*Request_CheckSdcard); ok {
+ return x.CheckSdcard
+ }
+ return nil
+}
+
+func (m *Request) GetSetMnemonicPassphraseEnabled() *SetMnemonicPassphraseEnabledRequest {
+ if x, ok := m.GetRequest().(*Request_SetMnemonicPassphraseEnabled); ok {
+ return x.SetMnemonicPassphraseEnabled
+ }
+ return nil
+}
+
+func (m *Request) GetListBackups() *ListBackupsRequest {
+ if x, ok := m.GetRequest().(*Request_ListBackups); ok {
+ return x.ListBackups
+ }
+ return nil
+}
+
+func (m *Request) GetRestoreBackup() *RestoreBackupRequest {
+ if x, ok := m.GetRequest().(*Request_RestoreBackup); ok {
+ return x.RestoreBackup
+ }
+ return nil
+}
+
+func (m *Request) GetPerformAttestation() *PerformAttestationRequest {
+ if x, ok := m.GetRequest().(*Request_PerformAttestation); ok {
+ return x.PerformAttestation
+ }
+ return nil
+}
+
+func (m *Request) GetReboot() *RebootRequest {
+ if x, ok := m.GetRequest().(*Request_Reboot); ok {
+ return x.Reboot
+ }
+ return nil
+}
+
+func (m *Request) GetCheckBackup() *CheckBackupRequest {
+ if x, ok := m.GetRequest().(*Request_CheckBackup); ok {
+ return x.CheckBackup
+ }
+ return nil
+}
+
+func (m *Request) GetEth() *ETHRequest {
+ if x, ok := m.GetRequest().(*Request_Eth); ok {
+ return x.Eth
+ }
+ return nil
+}
+
+func (m *Request) GetReset_() *ResetRequest {
+ if x, ok := m.GetRequest().(*Request_Reset_); ok {
+ return x.Reset_
+ }
+ return nil
+}
+
+func (m *Request) GetRestoreFromMnemonic() *RestoreFromMnemonicRequest {
+ if x, ok := m.GetRequest().(*Request_RestoreFromMnemonic); ok {
+ return x.RestoreFromMnemonic
+ }
+ return nil
+}
+
+func (m *Request) GetBitboxbase() *BitBoxBaseRequest {
+ if x, ok := m.GetRequest().(*Request_Bitboxbase); ok {
+ return x.Bitboxbase
+ }
+ return nil
+}
+
+// XXX_OneofWrappers is for the internal use of the proto package.
+func (*Request) XXX_OneofWrappers() []interface{} {
+ return []interface{}{
+ (*Request_RandomNumber)(nil),
+ (*Request_DeviceName)(nil),
+ (*Request_DeviceLanguage)(nil),
+ (*Request_DeviceInfo)(nil),
+ (*Request_SetPassword)(nil),
+ (*Request_CreateBackup)(nil),
+ (*Request_ShowMnemonic)(nil),
+ (*Request_BtcPub)(nil),
+ (*Request_BtcSignInit)(nil),
+ (*Request_BtcSignInput)(nil),
+ (*Request_BtcSignOutput)(nil),
+ (*Request_InsertRemoveSdcard)(nil),
+ (*Request_CheckSdcard)(nil),
+ (*Request_SetMnemonicPassphraseEnabled)(nil),
+ (*Request_ListBackups)(nil),
+ (*Request_RestoreBackup)(nil),
+ (*Request_PerformAttestation)(nil),
+ (*Request_Reboot)(nil),
+ (*Request_CheckBackup)(nil),
+ (*Request_Eth)(nil),
+ (*Request_Reset_)(nil),
+ (*Request_RestoreFromMnemonic)(nil),
+ (*Request_Bitboxbase)(nil),
+ }
+}
+
+type Response struct {
+ // Types that are valid to be assigned to Response:
+ // *Response_Success
+ // *Response_Error
+ // *Response_RandomNumber
+ // *Response_DeviceInfo
+ // *Response_Pub
+ // *Response_BtcSignNext
+ // *Response_ListBackups
+ // *Response_CheckBackup
+ // *Response_PerformAttestation
+ // *Response_CheckSdcard
+ // *Response_Eth
+ Response isResponse_Response `protobuf_oneof:"response"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Response) Reset() { *m = Response{} }
+func (m *Response) String() string { return proto.CompactTextString(m) }
+func (*Response) ProtoMessage() {}
+func (*Response) Descriptor() ([]byte, []int) {
+ return fileDescriptor_c12bd9e6412b8a05, []int{3}
+}
+
+func (m *Response) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Response.Unmarshal(m, b)
+}
+func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Response.Marshal(b, m, deterministic)
+}
+func (m *Response) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Response.Merge(m, src)
+}
+func (m *Response) XXX_Size() int {
+ return xxx_messageInfo_Response.Size(m)
+}
+func (m *Response) XXX_DiscardUnknown() {
+ xxx_messageInfo_Response.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Response proto.InternalMessageInfo
+
+type isResponse_Response interface {
+ isResponse_Response()
+}
+
+type Response_Success struct {
+ Success *Success `protobuf:"bytes,1,opt,name=success,proto3,oneof"`
+}
+
+type Response_Error struct {
+ Error *Error `protobuf:"bytes,2,opt,name=error,proto3,oneof"`
+}
+
+type Response_RandomNumber struct {
+ RandomNumber *RandomNumberResponse `protobuf:"bytes,3,opt,name=random_number,json=randomNumber,proto3,oneof"`
+}
+
+type Response_DeviceInfo struct {
+ DeviceInfo *DeviceInfoResponse `protobuf:"bytes,4,opt,name=device_info,json=deviceInfo,proto3,oneof"`
+}
+
+type Response_Pub struct {
+ Pub *PubResponse `protobuf:"bytes,5,opt,name=pub,proto3,oneof"`
+}
+
+type Response_BtcSignNext struct {
+ BtcSignNext *BTCSignNextResponse `protobuf:"bytes,6,opt,name=btc_sign_next,json=btcSignNext,proto3,oneof"`
+}
+
+type Response_ListBackups struct {
+ ListBackups *ListBackupsResponse `protobuf:"bytes,7,opt,name=list_backups,json=listBackups,proto3,oneof"`
+}
+
+type Response_CheckBackup struct {
+ CheckBackup *CheckBackupResponse `protobuf:"bytes,8,opt,name=check_backup,json=checkBackup,proto3,oneof"`
+}
+
+type Response_PerformAttestation struct {
+ PerformAttestation *PerformAttestationResponse `protobuf:"bytes,9,opt,name=perform_attestation,json=performAttestation,proto3,oneof"`
+}
+
+type Response_CheckSdcard struct {
+ CheckSdcard *CheckSDCardResponse `protobuf:"bytes,10,opt,name=check_sdcard,json=checkSdcard,proto3,oneof"`
+}
+
+type Response_Eth struct {
+ Eth *ETHResponse `protobuf:"bytes,11,opt,name=eth,proto3,oneof"`
+}
+
+func (*Response_Success) isResponse_Response() {}
+
+func (*Response_Error) isResponse_Response() {}
+
+func (*Response_RandomNumber) isResponse_Response() {}
+
+func (*Response_DeviceInfo) isResponse_Response() {}
+
+func (*Response_Pub) isResponse_Response() {}
+
+func (*Response_BtcSignNext) isResponse_Response() {}
+
+func (*Response_ListBackups) isResponse_Response() {}
+
+func (*Response_CheckBackup) isResponse_Response() {}
+
+func (*Response_PerformAttestation) isResponse_Response() {}
+
+func (*Response_CheckSdcard) isResponse_Response() {}
+
+func (*Response_Eth) isResponse_Response() {}
+
+func (m *Response) GetResponse() isResponse_Response {
+ if m != nil {
+ return m.Response
+ }
+ return nil
+}
+
+func (m *Response) GetSuccess() *Success {
+ if x, ok := m.GetResponse().(*Response_Success); ok {
+ return x.Success
+ }
+ return nil
+}
+
+func (m *Response) GetError() *Error {
+ if x, ok := m.GetResponse().(*Response_Error); ok {
+ return x.Error
+ }
+ return nil
+}
+
+func (m *Response) GetRandomNumber() *RandomNumberResponse {
+ if x, ok := m.GetResponse().(*Response_RandomNumber); ok {
+ return x.RandomNumber
+ }
+ return nil
+}
+
+func (m *Response) GetDeviceInfo() *DeviceInfoResponse {
+ if x, ok := m.GetResponse().(*Response_DeviceInfo); ok {
+ return x.DeviceInfo
+ }
+ return nil
+}
+
+func (m *Response) GetPub() *PubResponse {
+ if x, ok := m.GetResponse().(*Response_Pub); ok {
+ return x.Pub
+ }
+ return nil
+}
+
+func (m *Response) GetBtcSignNext() *BTCSignNextResponse {
+ if x, ok := m.GetResponse().(*Response_BtcSignNext); ok {
+ return x.BtcSignNext
+ }
+ return nil
+}
+
+func (m *Response) GetListBackups() *ListBackupsResponse {
+ if x, ok := m.GetResponse().(*Response_ListBackups); ok {
+ return x.ListBackups
+ }
+ return nil
+}
+
+func (m *Response) GetCheckBackup() *CheckBackupResponse {
+ if x, ok := m.GetResponse().(*Response_CheckBackup); ok {
+ return x.CheckBackup
+ }
+ return nil
+}
+
+func (m *Response) GetPerformAttestation() *PerformAttestationResponse {
+ if x, ok := m.GetResponse().(*Response_PerformAttestation); ok {
+ return x.PerformAttestation
+ }
+ return nil
+}
+
+func (m *Response) GetCheckSdcard() *CheckSDCardResponse {
+ if x, ok := m.GetResponse().(*Response_CheckSdcard); ok {
+ return x.CheckSdcard
+ }
+ return nil
+}
+
+func (m *Response) GetEth() *ETHResponse {
+ if x, ok := m.GetResponse().(*Response_Eth); ok {
+ return x.Eth
+ }
+ return nil
+}
+
+// XXX_OneofWrappers is for the internal use of the proto package.
+func (*Response) XXX_OneofWrappers() []interface{} {
+ return []interface{}{
+ (*Response_Success)(nil),
+ (*Response_Error)(nil),
+ (*Response_RandomNumber)(nil),
+ (*Response_DeviceInfo)(nil),
+ (*Response_Pub)(nil),
+ (*Response_BtcSignNext)(nil),
+ (*Response_ListBackups)(nil),
+ (*Response_CheckBackup)(nil),
+ (*Response_PerformAttestation)(nil),
+ (*Response_CheckSdcard)(nil),
+ (*Response_Eth)(nil),
+ }
+}
+
+func init() {
+ proto.RegisterType((*Error)(nil), "Error")
+ proto.RegisterType((*Success)(nil), "Success")
+ proto.RegisterType((*Request)(nil), "Request")
+ proto.RegisterType((*Response)(nil), "Response")
+}
+
+func init() { proto.RegisterFile("hww.proto", fileDescriptor_c12bd9e6412b8a05) }
+
+var fileDescriptor_c12bd9e6412b8a05 = []byte{
+ // 937 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x56, 0x6b, 0x6f, 0x1c, 0x35,
+ 0x14, 0x6d, 0x48, 0xf6, 0xe5, 0x7d, 0xa4, 0x78, 0x13, 0x70, 0x0b, 0xa2, 0x51, 0x54, 0xa4, 0xf0,
+ 0x65, 0x84, 0x02, 0x45, 0x0d, 0x54, 0x20, 0x76, 0x13, 0x94, 0x48, 0xed, 0xb2, 0xcc, 0xe6, 0xfb,
+ 0x68, 0x1e, 0x37, 0xd9, 0x51, 0x33, 0xf6, 0x60, 0x7b, 0xb2, 0xe1, 0x9f, 0xf0, 0xbf, 0xf8, 0x43,
+ 0xc8, 0x1e, 0x7b, 0xec, 0x7d, 0xa8, 0xdf, 0x76, 0xce, 0xbd, 0xe7, 0xfa, 0xce, 0xf5, 0xb9, 0x67,
+ 0x16, 0xf5, 0x96, 0xab, 0x55, 0x50, 0x72, 0x26, 0xd9, 0xcb, 0x41, 0xca, 0x8a, 0x82, 0x51, 0xf3,
+ 0x74, 0x9c, 0xc4, 0xe9, 0xc7, 0xaa, 0x8c, 0x14, 0x18, 0xd3, 0x4c, 0x34, 0x70, 0x2e, 0x13, 0xf6,
+ 0xf4, 0xfd, 0x79, 0x24, 0xfe, 0x11, 0x12, 0x0a, 0x03, 0x3f, 0xaf, 0xe1, 0x24, 0x16, 0x60, 0x90,
+ 0x5e, 0x22, 0x53, 0xfb, 0x13, 0xe4, 0xd2, 0xfc, 0x1c, 0x15, 0x14, 0x0a, 0x46, 0x73, 0x1b, 0x1a,
+ 0xf3, 0x98, 0x66, 0xac, 0x88, 0x68, 0x55, 0x24, 0xc0, 0x6d, 0x23, 0x6b, 0xa5, 0x5f, 0x94, 0xc0,
+ 0xef, 0x18, 0x2f, 0xa2, 0x58, 0x4a, 0x10, 0x32, 0x96, 0xb9, 0xed, 0xf1, 0xf4, 0x0d, 0x6a, 0x5d,
+ 0x71, 0xce, 0x38, 0xc6, 0xe8, 0x20, 0x65, 0x19, 0x90, 0xbd, 0x93, 0xbd, 0xb3, 0x56, 0xa8, 0x7f,
+ 0x63, 0x82, 0x3a, 0x05, 0x08, 0x11, 0xdf, 0x03, 0xf9, 0xec, 0x64, 0xef, 0xac, 0x17, 0xda, 0xc7,
+ 0xd3, 0x1e, 0xea, 0x2c, 0xaa, 0x34, 0x05, 0x21, 0x4e, 0xff, 0xed, 0xa3, 0x4e, 0x08, 0x7f, 0x57,
+ 0x20, 0x24, 0xfe, 0x05, 0x0d, 0xd7, 0xba, 0xd1, 0xd5, 0xfa, 0xe7, 0x47, 0x41, 0xa8, 0xd1, 0x99,
+ 0x06, 0x4d, 0xf2, 0xf5, 0xb3, 0x70, 0xc0, 0x3d, 0x18, 0xbf, 0x45, 0xfd, 0x0c, 0x1e, 0xf3, 0x14,
+ 0x22, 0x1a, 0x17, 0xf5, 0x89, 0xfd, 0xf3, 0xe3, 0x60, 0x01, 0xf2, 0x52, 0xc3, 0xb3, 0xb8, 0x00,
+ 0xc7, 0x45, 0x59, 0x03, 0xe2, 0x4b, 0x74, 0x68, 0x98, 0x0f, 0x31, 0xbd, 0xaf, 0x54, 0xbf, 0xfb,
+ 0x9a, 0xfd, 0xc2, 0xb1, 0xdf, 0x9b, 0x88, 0xab, 0x30, 0xca, 0xd6, 0x02, 0xf8, 0x4d, 0x73, 0x7e,
+ 0x4e, 0xef, 0x18, 0x39, 0xd0, 0x15, 0x70, 0x50, 0xd3, 0x6f, 0xe8, 0x1d, 0xdb, 0x3a, 0x5c, 0x81,
+ 0xf8, 0x2d, 0x1a, 0x08, 0x90, 0x51, 0x19, 0x0b, 0xb1, 0x62, 0x3c, 0x23, 0x2d, 0xcd, 0x1b, 0xab,
+ 0x93, 0xe7, 0x06, 0x73, 0xc4, 0xbe, 0x70, 0xa8, 0x9a, 0x56, 0xca, 0x21, 0x96, 0x10, 0xd5, 0x42,
+ 0x21, 0x6d, 0x33, 0xad, 0xa9, 0x46, 0x27, 0x1a, 0xf4, 0xa6, 0x95, 0x7a, 0xb0, 0x22, 0x8b, 0x25,
+ 0x5b, 0x45, 0x56, 0x0d, 0xa4, 0x63, 0xc8, 0x8b, 0x25, 0x5b, 0x7d, 0x30, 0xa0, 0x47, 0x16, 0x1e,
+ 0x8c, 0xbf, 0x43, 0x9d, 0x44, 0xa6, 0x51, 0x59, 0x25, 0xa4, 0xab, 0x69, 0xa3, 0x60, 0x72, 0x3b,
+ 0x9d, 0x57, 0x89, 0x23, 0xb4, 0x13, 0x99, 0xce, 0xab, 0x04, 0x5f, 0xa0, 0xa1, 0x4a, 0x15, 0xf9,
+ 0x3d, 0x8d, 0x72, 0x9a, 0x4b, 0xd2, 0x33, 0xef, 0x37, 0xb9, 0x9d, 0x2e, 0xf2, 0x7b, 0x7a, 0x43,
+ 0x73, 0xe9, 0xbd, 0x5f, 0x22, 0x53, 0x8b, 0xe2, 0x77, 0x68, 0xe4, 0x51, 0xcb, 0x4a, 0x12, 0x64,
+ 0x7a, 0x6c, 0xb8, 0x65, 0xe5, 0x91, 0x07, 0x0d, 0xb9, 0xac, 0x24, 0xfe, 0x0d, 0x1d, 0x36, 0x6c,
+ 0x56, 0x49, 0x45, 0xef, 0x1b, 0x49, 0x18, 0xfa, 0x9f, 0x1a, 0x75, 0xfc, 0xa1, 0xe1, 0xd7, 0x38,
+ 0x9e, 0xa1, 0xa3, 0x9c, 0x0a, 0xe0, 0x32, 0xe2, 0x50, 0xb0, 0x47, 0x88, 0x44, 0x96, 0xc6, 0x3c,
+ 0x23, 0x03, 0x5d, 0xe5, 0x65, 0x70, 0xa3, 0x83, 0xa1, 0x8e, 0x2d, 0x2e, 0xa7, 0xb1, 0x7f, 0x4f,
+ 0x38, 0xf7, 0x83, 0x9a, 0xa7, 0x2e, 0x3a, 0x5d, 0x42, 0xfa, 0xd1, 0xd6, 0x19, 0x9a, 0x41, 0x4c,
+ 0x15, 0xb8, 0x59, 0xa0, 0xaf, 0x53, 0x0d, 0xb3, 0x40, 0xaf, 0x94, 0x44, 0xec, 0x55, 0x69, 0xad,
+ 0x94, 0x4b, 0x1e, 0x0b, 0x88, 0x80, 0xc6, 0xc9, 0x03, 0x64, 0x64, 0xa4, 0x8b, 0xbd, 0x56, 0xaa,
+ 0xb1, 0xb7, 0x34, 0x6f, 0xb2, 0xae, 0xea, 0x24, 0x57, 0xfd, 0x6b, 0xf1, 0x89, 0x34, 0xd5, 0xe8,
+ 0x43, 0x2e, 0xa4, 0x51, 0x95, 0x20, 0x87, 0xa6, 0xd1, 0xf7, 0xb9, 0x90, 0xb5, 0x7a, 0x84, 0xd7,
+ 0xe8, 0x83, 0x43, 0xf1, 0xaf, 0x68, 0xc4, 0x41, 0x48, 0xc6, 0x1b, 0x49, 0x3e, 0x37, 0x23, 0x0f,
+ 0x6b, 0x78, 0x53, 0x93, 0x43, 0xee, 0xe3, 0xf8, 0x03, 0x1a, 0xef, 0xb0, 0x1a, 0xf2, 0xb9, 0x99,
+ 0xf8, 0xbc, 0x8e, 0xfd, 0xee, 0x42, 0xde, 0xc4, 0xcb, 0xad, 0x20, 0x3e, 0x43, 0x6d, 0x0e, 0x09,
+ 0x63, 0x92, 0x60, 0xa3, 0xd2, 0x50, 0x3f, 0x7a, 0x2a, 0xad, 0xe3, 0xee, 0x6e, 0x4c, 0xdb, 0x63,
+ 0xff, 0x6e, 0x36, 0x9b, 0xae, 0xef, 0xc6, 0xb4, 0xfc, 0x0a, 0xed, 0x83, 0x5c, 0x92, 0x23, 0x4d,
+ 0xe8, 0x07, 0x57, 0xb7, 0xd7, 0x2e, 0x51, 0x45, 0xf0, 0xb7, 0xa8, 0xc5, 0x41, 0x80, 0x24, 0xc7,
+ 0x3a, 0x65, 0xa8, 0x46, 0x01, 0x5e, 0x0b, 0x75, 0x14, 0xff, 0x85, 0x8e, 0xed, 0xe8, 0xee, 0x38,
+ 0x2b, 0xdc, 0x5e, 0x7e, 0xa1, 0x69, 0x5f, 0xd9, 0x09, 0xfe, 0xc1, 0x59, 0xb1, 0xbd, 0x9e, 0x63,
+ 0xbe, 0x1d, 0xc5, 0x3f, 0x22, 0xe4, 0xbe, 0x09, 0xe4, 0x4b, 0xe3, 0x47, 0x93, 0x5c, 0x4e, 0xd8,
+ 0xd3, 0x24, 0x16, 0xbe, 0x19, 0xba, 0xbc, 0x49, 0x0f, 0x75, 0x78, 0x1d, 0x38, 0xfd, 0xef, 0x00,
+ 0x75, 0x43, 0x10, 0x25, 0xa3, 0x02, 0xf0, 0x6b, 0xd4, 0x11, 0xb5, 0x65, 0x1b, 0x57, 0xee, 0x06,
+ 0xc6, 0xc2, 0xaf, 0x9f, 0x85, 0x36, 0x84, 0xbf, 0x41, 0x2d, 0x50, 0xdf, 0x03, 0x63, 0xbf, 0xed,
+ 0x40, 0x7f, 0x1d, 0xd4, 0x6b, 0x6a, 0x18, 0xbf, 0xdb, 0x74, 0xf8, 0x7d, 0x2b, 0x90, 0x35, 0x87,
+ 0xaf, 0xcf, 0xdc, 0xb2, 0xf8, 0x9f, 0x76, 0x59, 0xec, 0x78, 0xcd, 0x62, 0x1b, 0xa6, 0xef, 0xb1,
+ 0x27, 0x68, 0x5f, 0x79, 0x55, 0x6d, 0xad, 0x83, 0x40, 0x1b, 0x55, 0x93, 0xa8, 0x42, 0xf8, 0x67,
+ 0xcf, 0xa6, 0x28, 0x3c, 0xc9, 0xc6, 0x4b, 0x8d, 0x57, 0xcc, 0xe0, 0x49, 0x7a, 0x1c, 0xeb, 0x53,
+ 0x0a, 0xc6, 0x17, 0x1b, 0xfb, 0x62, 0x9d, 0x74, 0x6d, 0x5f, 0x1c, 0xd5, 0x5f, 0x98, 0x8b, 0x0d,
+ 0xdd, 0x75, 0xad, 0x83, 0xfb, 0xba, 0x73, 0x54, 0x5f, 0x78, 0xb3, 0xdd, 0xbb, 0xd2, 0x33, 0x72,
+ 0xd9, 0xb5, 0x2b, 0x4d, 0xa1, 0x5d, 0xcb, 0x72, 0xb1, 0x61, 0x4f, 0xc8, 0x6f, 0xc5, 0xda, 0xd3,
+ 0x46, 0x2b, 0xc6, 0x9f, 0x4e, 0xea, 0x1d, 0xe8, 0x9b, 0xf1, 0xea, 0x1d, 0x70, 0xe3, 0x05, 0xb9,
+ 0x9c, 0x20, 0xd4, 0xe5, 0x06, 0x4a, 0xda, 0xfa, 0x9f, 0xc3, 0x0f, 0xff, 0x07, 0x00, 0x00, 0xff,
+ 0xff, 0x60, 0xcb, 0x4b, 0xd0, 0xf8, 0x08, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/hww.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/hww.proto
new file mode 100644
index 00000000..8b951dc6
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/hww.proto
@@ -0,0 +1,80 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+import "common.proto";
+
+import "backup_commands.proto";
+import "bitbox02_system.proto";
+import "bitboxbase.proto";
+import "btc.proto";
+import "eth.proto";
+import "mnemonic.proto";
+import "random_number.proto";
+import "system.proto";
+
+import "perform_attestation.proto";
+
+message Error {
+ int32 code = 1;
+ string message = 2;
+}
+
+message Success {
+}
+
+message Request {
+ oneof request {
+ RandomNumberRequest random_number = 1;
+ SetDeviceNameRequest device_name = 2;
+ SetDeviceLanguageRequest device_language = 3;
+ DeviceInfoRequest device_info = 4;
+ SetPasswordRequest set_password = 5;
+ CreateBackupRequest create_backup = 6;
+ ShowMnemonicRequest show_mnemonic = 7;
+ BTCPubRequest btc_pub = 8;
+ BTCSignInitRequest btc_sign_init = 9;
+ BTCSignInputRequest btc_sign_input = 10;
+ BTCSignOutputRequest btc_sign_output = 11;
+ InsertRemoveSDCardRequest insert_remove_sdcard = 12;
+ CheckSDCardRequest check_sdcard = 13;
+ SetMnemonicPassphraseEnabledRequest set_mnemonic_passphrase_enabled = 14;
+ ListBackupsRequest list_backups = 15;
+ RestoreBackupRequest restore_backup = 16;
+ PerformAttestationRequest perform_attestation = 17;
+ RebootRequest reboot = 18;
+ CheckBackupRequest check_backup = 19;
+ ETHRequest eth = 20;
+ ResetRequest reset = 21;
+ RestoreFromMnemonicRequest restore_from_mnemonic = 22;
+ BitBoxBaseRequest bitboxbase = 23;
+ }
+}
+
+message Response {
+ oneof response {
+ Success success = 1;
+ Error error = 2;
+ RandomNumberResponse random_number = 3;
+ DeviceInfoResponse device_info = 4;
+ PubResponse pub = 5;
+ BTCSignNextResponse btc_sign_next = 6;
+ ListBackupsResponse list_backups = 7;
+ CheckBackupResponse check_backup = 8;
+ PerformAttestationResponse perform_attestation = 9;
+ CheckSDCardResponse check_sdcard = 10;
+ ETHResponse eth = 11;
+ }
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/mnemonic.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/mnemonic.pb.go
new file mode 100644
index 00000000..70a75155
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/mnemonic.pb.go
@@ -0,0 +1,161 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: mnemonic.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type ShowMnemonicRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ShowMnemonicRequest) Reset() { *m = ShowMnemonicRequest{} }
+func (m *ShowMnemonicRequest) String() string { return proto.CompactTextString(m) }
+func (*ShowMnemonicRequest) ProtoMessage() {}
+func (*ShowMnemonicRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_4888928040813ede, []int{0}
+}
+
+func (m *ShowMnemonicRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ShowMnemonicRequest.Unmarshal(m, b)
+}
+func (m *ShowMnemonicRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ShowMnemonicRequest.Marshal(b, m, deterministic)
+}
+func (m *ShowMnemonicRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ShowMnemonicRequest.Merge(m, src)
+}
+func (m *ShowMnemonicRequest) XXX_Size() int {
+ return xxx_messageInfo_ShowMnemonicRequest.Size(m)
+}
+func (m *ShowMnemonicRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_ShowMnemonicRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ShowMnemonicRequest proto.InternalMessageInfo
+
+type RestoreFromMnemonicRequest struct {
+ Timestamp uint32 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+ TimezoneOffset int32 `protobuf:"varint,2,opt,name=timezone_offset,json=timezoneOffset,proto3" json:"timezone_offset,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *RestoreFromMnemonicRequest) Reset() { *m = RestoreFromMnemonicRequest{} }
+func (m *RestoreFromMnemonicRequest) String() string { return proto.CompactTextString(m) }
+func (*RestoreFromMnemonicRequest) ProtoMessage() {}
+func (*RestoreFromMnemonicRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_4888928040813ede, []int{1}
+}
+
+func (m *RestoreFromMnemonicRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_RestoreFromMnemonicRequest.Unmarshal(m, b)
+}
+func (m *RestoreFromMnemonicRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_RestoreFromMnemonicRequest.Marshal(b, m, deterministic)
+}
+func (m *RestoreFromMnemonicRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_RestoreFromMnemonicRequest.Merge(m, src)
+}
+func (m *RestoreFromMnemonicRequest) XXX_Size() int {
+ return xxx_messageInfo_RestoreFromMnemonicRequest.Size(m)
+}
+func (m *RestoreFromMnemonicRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_RestoreFromMnemonicRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_RestoreFromMnemonicRequest proto.InternalMessageInfo
+
+func (m *RestoreFromMnemonicRequest) GetTimestamp() uint32 {
+ if m != nil {
+ return m.Timestamp
+ }
+ return 0
+}
+
+func (m *RestoreFromMnemonicRequest) GetTimezoneOffset() int32 {
+ if m != nil {
+ return m.TimezoneOffset
+ }
+ return 0
+}
+
+type SetMnemonicPassphraseEnabledRequest struct {
+ Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SetMnemonicPassphraseEnabledRequest) Reset() { *m = SetMnemonicPassphraseEnabledRequest{} }
+func (m *SetMnemonicPassphraseEnabledRequest) String() string { return proto.CompactTextString(m) }
+func (*SetMnemonicPassphraseEnabledRequest) ProtoMessage() {}
+func (*SetMnemonicPassphraseEnabledRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_4888928040813ede, []int{2}
+}
+
+func (m *SetMnemonicPassphraseEnabledRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SetMnemonicPassphraseEnabledRequest.Unmarshal(m, b)
+}
+func (m *SetMnemonicPassphraseEnabledRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SetMnemonicPassphraseEnabledRequest.Marshal(b, m, deterministic)
+}
+func (m *SetMnemonicPassphraseEnabledRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SetMnemonicPassphraseEnabledRequest.Merge(m, src)
+}
+func (m *SetMnemonicPassphraseEnabledRequest) XXX_Size() int {
+ return xxx_messageInfo_SetMnemonicPassphraseEnabledRequest.Size(m)
+}
+func (m *SetMnemonicPassphraseEnabledRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_SetMnemonicPassphraseEnabledRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SetMnemonicPassphraseEnabledRequest proto.InternalMessageInfo
+
+func (m *SetMnemonicPassphraseEnabledRequest) GetEnabled() bool {
+ if m != nil {
+ return m.Enabled
+ }
+ return false
+}
+
+func init() {
+ proto.RegisterType((*ShowMnemonicRequest)(nil), "ShowMnemonicRequest")
+ proto.RegisterType((*RestoreFromMnemonicRequest)(nil), "RestoreFromMnemonicRequest")
+ proto.RegisterType((*SetMnemonicPassphraseEnabledRequest)(nil), "SetMnemonicPassphraseEnabledRequest")
+}
+
+func init() { proto.RegisterFile("mnemonic.proto", fileDescriptor_4888928040813ede) }
+
+var fileDescriptor_4888928040813ede = []byte{
+ // 172 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0xcd, 0x4b, 0xcd,
+ 0xcd, 0xcf, 0xcb, 0x4c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57, 0x12, 0xe5, 0x12, 0x0e, 0xce,
+ 0xc8, 0x2f, 0xf7, 0x85, 0x8a, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x28, 0x25, 0x73, 0x49,
+ 0x05, 0xa5, 0x16, 0x97, 0xe4, 0x17, 0xa5, 0xba, 0x15, 0xe5, 0xe7, 0xa2, 0xc9, 0x0a, 0xc9, 0x70,
+ 0x71, 0x96, 0x64, 0xe6, 0xa6, 0x16, 0x97, 0x24, 0xe6, 0x16, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0xf0,
+ 0x06, 0x21, 0x04, 0x84, 0xd4, 0xb9, 0xf8, 0x41, 0x9c, 0xaa, 0xfc, 0xbc, 0xd4, 0xf8, 0xfc, 0xb4,
+ 0xb4, 0xe2, 0xd4, 0x12, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xd6, 0x20, 0x3e, 0x98, 0xb0, 0x3f, 0x58,
+ 0x54, 0xc9, 0x9e, 0x4b, 0x39, 0x38, 0xb5, 0x04, 0x66, 0x78, 0x40, 0x62, 0x71, 0x71, 0x41, 0x46,
+ 0x51, 0x62, 0x71, 0xaa, 0x6b, 0x5e, 0x62, 0x52, 0x4e, 0x6a, 0x0a, 0xcc, 0x36, 0x09, 0x2e, 0xf6,
+ 0x54, 0x88, 0x08, 0xd8, 0x2e, 0x8e, 0x20, 0x18, 0x37, 0x89, 0x0d, 0xec, 0x07, 0x63, 0x40, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x48, 0xde, 0xc0, 0xca, 0xd5, 0x00, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/mnemonic.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/mnemonic.proto
new file mode 100644
index 00000000..415eb127
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/mnemonic.proto
@@ -0,0 +1,25 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+message ShowMnemonicRequest {
+}
+message RestoreFromMnemonicRequest {
+ uint32 timestamp = 1;
+ int32 timezone_offset = 2;
+}
+message SetMnemonicPassphraseEnabledRequest {
+ bool enabled = 1;
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/perform_attestation.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/perform_attestation.pb.go
new file mode 100644
index 00000000..bff60f5d
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/perform_attestation.pb.go
@@ -0,0 +1,160 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: perform_attestation.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+// Deprecated, last used in v1.0.0
+type PerformAttestationRequest struct {
+ // 32 bytes challenge.
+ Challenge []byte `protobuf:"bytes,1,opt,name=challenge,proto3" json:"challenge,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *PerformAttestationRequest) Reset() { *m = PerformAttestationRequest{} }
+func (m *PerformAttestationRequest) String() string { return proto.CompactTextString(m) }
+func (*PerformAttestationRequest) ProtoMessage() {}
+func (*PerformAttestationRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_174e824e996c9fb5, []int{0}
+}
+
+func (m *PerformAttestationRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_PerformAttestationRequest.Unmarshal(m, b)
+}
+func (m *PerformAttestationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_PerformAttestationRequest.Marshal(b, m, deterministic)
+}
+func (m *PerformAttestationRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_PerformAttestationRequest.Merge(m, src)
+}
+func (m *PerformAttestationRequest) XXX_Size() int {
+ return xxx_messageInfo_PerformAttestationRequest.Size(m)
+}
+func (m *PerformAttestationRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_PerformAttestationRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_PerformAttestationRequest proto.InternalMessageInfo
+
+func (m *PerformAttestationRequest) GetChallenge() []byte {
+ if m != nil {
+ return m.Challenge
+ }
+ return nil
+}
+
+// Deprecated, last used in v1.0.0
+type PerformAttestationResponse struct {
+ BootloaderHash []byte `protobuf:"bytes,1,opt,name=bootloader_hash,json=bootloaderHash,proto3" json:"bootloader_hash,omitempty"`
+ DevicePubkey []byte `protobuf:"bytes,2,opt,name=device_pubkey,json=devicePubkey,proto3" json:"device_pubkey,omitempty"`
+ Certificate []byte `protobuf:"bytes,3,opt,name=certificate,proto3" json:"certificate,omitempty"`
+ RootPubkeyIdentifier []byte `protobuf:"bytes,4,opt,name=root_pubkey_identifier,json=rootPubkeyIdentifier,proto3" json:"root_pubkey_identifier,omitempty"`
+ ChallengeSignature []byte `protobuf:"bytes,5,opt,name=challenge_signature,json=challengeSignature,proto3" json:"challenge_signature,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *PerformAttestationResponse) Reset() { *m = PerformAttestationResponse{} }
+func (m *PerformAttestationResponse) String() string { return proto.CompactTextString(m) }
+func (*PerformAttestationResponse) ProtoMessage() {}
+func (*PerformAttestationResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_174e824e996c9fb5, []int{1}
+}
+
+func (m *PerformAttestationResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_PerformAttestationResponse.Unmarshal(m, b)
+}
+func (m *PerformAttestationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_PerformAttestationResponse.Marshal(b, m, deterministic)
+}
+func (m *PerformAttestationResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_PerformAttestationResponse.Merge(m, src)
+}
+func (m *PerformAttestationResponse) XXX_Size() int {
+ return xxx_messageInfo_PerformAttestationResponse.Size(m)
+}
+func (m *PerformAttestationResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_PerformAttestationResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_PerformAttestationResponse proto.InternalMessageInfo
+
+func (m *PerformAttestationResponse) GetBootloaderHash() []byte {
+ if m != nil {
+ return m.BootloaderHash
+ }
+ return nil
+}
+
+func (m *PerformAttestationResponse) GetDevicePubkey() []byte {
+ if m != nil {
+ return m.DevicePubkey
+ }
+ return nil
+}
+
+func (m *PerformAttestationResponse) GetCertificate() []byte {
+ if m != nil {
+ return m.Certificate
+ }
+ return nil
+}
+
+func (m *PerformAttestationResponse) GetRootPubkeyIdentifier() []byte {
+ if m != nil {
+ return m.RootPubkeyIdentifier
+ }
+ return nil
+}
+
+func (m *PerformAttestationResponse) GetChallengeSignature() []byte {
+ if m != nil {
+ return m.ChallengeSignature
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterType((*PerformAttestationRequest)(nil), "PerformAttestationRequest")
+ proto.RegisterType((*PerformAttestationResponse)(nil), "PerformAttestationResponse")
+}
+
+func init() { proto.RegisterFile("perform_attestation.proto", fileDescriptor_174e824e996c9fb5) }
+
+var fileDescriptor_174e824e996c9fb5 = []byte{
+ // 233 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xbd, 0x4e, 0xc3, 0x30,
+ 0x14, 0x85, 0x15, 0xfe, 0x24, 0x2e, 0x05, 0x24, 0x83, 0x90, 0x8b, 0x18, 0xaa, 0x32, 0xc0, 0x04,
+ 0x03, 0x2c, 0x8c, 0x6c, 0xb0, 0x55, 0xe5, 0x01, 0x2c, 0x27, 0x39, 0x6d, 0x2c, 0x82, 0x6f, 0xb0,
+ 0x6f, 0x90, 0x78, 0x6e, 0x5e, 0x00, 0xd5, 0x09, 0x09, 0x43, 0xd7, 0xef, 0x3b, 0xe7, 0x48, 0xf7,
+ 0xd2, 0xb4, 0x41, 0x58, 0x71, 0xf8, 0x30, 0x56, 0x04, 0x51, 0xac, 0x38, 0xf6, 0x77, 0x4d, 0x60,
+ 0xe1, 0xf9, 0x13, 0x4d, 0x17, 0x9d, 0x7c, 0x1e, 0xdd, 0x12, 0x9f, 0x2d, 0xa2, 0xa8, 0x2b, 0x3a,
+ 0x2c, 0x2a, 0x5b, 0xd7, 0xf0, 0x6b, 0xe8, 0x6c, 0x96, 0xdd, 0x4e, 0x96, 0x23, 0x98, 0xff, 0x64,
+ 0x74, 0xb9, 0xad, 0x1b, 0x1b, 0xf6, 0x11, 0xea, 0x86, 0x4e, 0x73, 0x66, 0xa9, 0xd9, 0x96, 0x08,
+ 0xa6, 0xb2, 0xb1, 0xea, 0x27, 0x4e, 0x46, 0xfc, 0x62, 0x63, 0xa5, 0xae, 0xe9, 0xb8, 0xc4, 0x97,
+ 0x2b, 0x60, 0x9a, 0x36, 0x7f, 0xc7, 0xb7, 0xde, 0x49, 0xb1, 0x49, 0x07, 0x17, 0x89, 0xa9, 0x19,
+ 0x1d, 0x15, 0x08, 0xe2, 0x56, 0xae, 0xb0, 0x02, 0xbd, 0x9b, 0x22, 0xff, 0x91, 0x7a, 0xa4, 0x8b,
+ 0xc0, 0x2c, 0xfd, 0x88, 0x71, 0x25, 0xfc, 0xc6, 0x21, 0xe8, 0xbd, 0x14, 0x3e, 0xdf, 0xd8, 0x6e,
+ 0xed, 0x75, 0x70, 0xea, 0x9e, 0xce, 0x86, 0x8b, 0x4c, 0x74, 0x6b, 0x6f, 0xa5, 0x0d, 0xd0, 0xfb,
+ 0xa9, 0xa2, 0x06, 0xf5, 0xf6, 0x67, 0xf2, 0x83, 0xf4, 0xb7, 0x87, 0xdf, 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0x25, 0xdc, 0x24, 0x46, 0x54, 0x01, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/perform_attestation.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/perform_attestation.proto
new file mode 100644
index 00000000..a6418d4b
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/perform_attestation.proto
@@ -0,0 +1,17 @@
+
+syntax = "proto3";
+
+// Deprecated, last used in v1.0.0
+message PerformAttestationRequest {
+ // 32 bytes challenge.
+ bytes challenge = 1;
+}
+
+// Deprecated, last used in v1.0.0
+message PerformAttestationResponse {
+ bytes bootloader_hash = 1;
+ bytes device_pubkey = 2;
+ bytes certificate = 3;
+ bytes root_pubkey_identifier = 4;
+ bytes challenge_signature = 5;
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/random_number.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/random_number.pb.go
new file mode 100644
index 00000000..30cd5f8f
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/random_number.pb.go
@@ -0,0 +1,108 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: random_number.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type RandomNumberResponse struct {
+ Number []byte `protobuf:"bytes,1,opt,name=number,proto3" json:"number,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *RandomNumberResponse) Reset() { *m = RandomNumberResponse{} }
+func (m *RandomNumberResponse) String() string { return proto.CompactTextString(m) }
+func (*RandomNumberResponse) ProtoMessage() {}
+func (*RandomNumberResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_522c02bfcae4ed2a, []int{0}
+}
+
+func (m *RandomNumberResponse) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_RandomNumberResponse.Unmarshal(m, b)
+}
+func (m *RandomNumberResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_RandomNumberResponse.Marshal(b, m, deterministic)
+}
+func (m *RandomNumberResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_RandomNumberResponse.Merge(m, src)
+}
+func (m *RandomNumberResponse) XXX_Size() int {
+ return xxx_messageInfo_RandomNumberResponse.Size(m)
+}
+func (m *RandomNumberResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_RandomNumberResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_RandomNumberResponse proto.InternalMessageInfo
+
+func (m *RandomNumberResponse) GetNumber() []byte {
+ if m != nil {
+ return m.Number
+ }
+ return nil
+}
+
+type RandomNumberRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *RandomNumberRequest) Reset() { *m = RandomNumberRequest{} }
+func (m *RandomNumberRequest) String() string { return proto.CompactTextString(m) }
+func (*RandomNumberRequest) ProtoMessage() {}
+func (*RandomNumberRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_522c02bfcae4ed2a, []int{1}
+}
+
+func (m *RandomNumberRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_RandomNumberRequest.Unmarshal(m, b)
+}
+func (m *RandomNumberRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_RandomNumberRequest.Marshal(b, m, deterministic)
+}
+func (m *RandomNumberRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_RandomNumberRequest.Merge(m, src)
+}
+func (m *RandomNumberRequest) XXX_Size() int {
+ return xxx_messageInfo_RandomNumberRequest.Size(m)
+}
+func (m *RandomNumberRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_RandomNumberRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_RandomNumberRequest proto.InternalMessageInfo
+
+func init() {
+ proto.RegisterType((*RandomNumberResponse)(nil), "RandomNumberResponse")
+ proto.RegisterType((*RandomNumberRequest)(nil), "RandomNumberRequest")
+}
+
+func init() { proto.RegisterFile("random_number.proto", fileDescriptor_522c02bfcae4ed2a) }
+
+var fileDescriptor_522c02bfcae4ed2a = []byte{
+ // 94 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0x4a, 0xcc, 0x4b,
+ 0xc9, 0xcf, 0x8d, 0xcf, 0x2b, 0xcd, 0x4d, 0x4a, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57,
+ 0xd2, 0xe3, 0x12, 0x09, 0x02, 0x0b, 0xfb, 0x81, 0x45, 0x83, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a,
+ 0x53, 0x85, 0xc4, 0xb8, 0xd8, 0x20, 0xea, 0x24, 0x18, 0x15, 0x18, 0x35, 0x78, 0x82, 0xa0, 0x3c,
+ 0x25, 0x51, 0x2e, 0x61, 0x54, 0xf5, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x49, 0x6c, 0x60, 0xd3, 0x8c,
+ 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x2e, 0x38, 0x84, 0x64, 0x00, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/random_number.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/random_number.proto
new file mode 100644
index 00000000..7c7cd3e7
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/random_number.proto
@@ -0,0 +1,23 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+message RandomNumberResponse {
+ bytes number = 1;
+}
+
+message RandomNumberRequest {
+}
+
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/system.pb.go b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/system.pb.go
new file mode 100644
index 00000000..5d241742
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/system.pb.go
@@ -0,0 +1,66 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: system.proto
+
+package messages
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type RebootRequest struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *RebootRequest) Reset() { *m = RebootRequest{} }
+func (m *RebootRequest) String() string { return proto.CompactTextString(m) }
+func (*RebootRequest) ProtoMessage() {}
+func (*RebootRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_86a7260ebdc12f47, []int{0}
+}
+
+func (m *RebootRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_RebootRequest.Unmarshal(m, b)
+}
+func (m *RebootRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_RebootRequest.Marshal(b, m, deterministic)
+}
+func (m *RebootRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_RebootRequest.Merge(m, src)
+}
+func (m *RebootRequest) XXX_Size() int {
+ return xxx_messageInfo_RebootRequest.Size(m)
+}
+func (m *RebootRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_RebootRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_RebootRequest proto.InternalMessageInfo
+
+func init() {
+ proto.RegisterType((*RebootRequest)(nil), "RebootRequest")
+}
+
+func init() { proto.RegisterFile("system.proto", fileDescriptor_86a7260ebdc12f47) }
+
+var fileDescriptor_86a7260ebdc12f47 = []byte{
+ // 60 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0xae, 0x2c, 0x2e,
+ 0x49, 0xcd, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x57, 0xe2, 0xe7, 0xe2, 0x0d, 0x4a, 0x4d, 0xca,
+ 0xcf, 0x2f, 0x09, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x49, 0x62, 0x03, 0x8b, 0x1b, 0x03, 0x02,
+ 0x00, 0x00, 0xff, 0xff, 0xc7, 0xb2, 0x4f, 0x0d, 0x27, 0x00, 0x00, 0x00,
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/system.proto b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/system.proto
new file mode 100644
index 00000000..1818084d
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages/system.proto
@@ -0,0 +1,19 @@
+// Copyright 2019 Shift Cryptosecurity AG
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+message RebootRequest {
+
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/AUTHORS b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/AUTHORS
new file mode 100644
index 00000000..15167cd7
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/AUTHORS
@@ -0,0 +1,3 @@
+# This source code refers to The Go Authors for copyright purposes.
+# The master list of authors is in the main Go distribution,
+# visible at http://tip.golang.org/AUTHORS.
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/CONTRIBUTORS b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/CONTRIBUTORS
new file mode 100644
index 00000000..1c4577e9
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/CONTRIBUTORS
@@ -0,0 +1,3 @@
+# This source code was written by the Go contributors.
+# The master list of contributors is in the main Go distribution,
+# visible at http://tip.golang.org/CONTRIBUTORS.
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/LICENSE b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/LICENSE
new file mode 100644
index 00000000..0f646931
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/LICENSE
@@ -0,0 +1,28 @@
+Copyright 2010 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/clone.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/clone.go
new file mode 100644
index 00000000..3cd3249f
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/clone.go
@@ -0,0 +1,253 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2011 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Protocol buffer deep copy and merge.
+// TODO: RawMessage.
+
+package proto
+
+import (
+ "fmt"
+ "log"
+ "reflect"
+ "strings"
+)
+
+// Clone returns a deep copy of a protocol buffer.
+func Clone(src Message) Message {
+ in := reflect.ValueOf(src)
+ if in.IsNil() {
+ return src
+ }
+ out := reflect.New(in.Type().Elem())
+ dst := out.Interface().(Message)
+ Merge(dst, src)
+ return dst
+}
+
+// Merger is the interface representing objects that can merge messages of the same type.
+type Merger interface {
+ // Merge merges src into this message.
+ // Required and optional fields that are set in src will be set to that value in dst.
+ // Elements of repeated fields will be appended.
+ //
+ // Merge may panic if called with a different argument type than the receiver.
+ Merge(src Message)
+}
+
+// generatedMerger is the custom merge method that generated protos will have.
+// We must add this method since a generate Merge method will conflict with
+// many existing protos that have a Merge data field already defined.
+type generatedMerger interface {
+ XXX_Merge(src Message)
+}
+
+// Merge merges src into dst.
+// Required and optional fields that are set in src will be set to that value in dst.
+// Elements of repeated fields will be appended.
+// Merge panics if src and dst are not the same type, or if dst is nil.
+func Merge(dst, src Message) {
+ if m, ok := dst.(Merger); ok {
+ m.Merge(src)
+ return
+ }
+
+ in := reflect.ValueOf(src)
+ out := reflect.ValueOf(dst)
+ if out.IsNil() {
+ panic("proto: nil destination")
+ }
+ if in.Type() != out.Type() {
+ panic(fmt.Sprintf("proto.Merge(%T, %T) type mismatch", dst, src))
+ }
+ if in.IsNil() {
+ return // Merge from nil src is a noop
+ }
+ if m, ok := dst.(generatedMerger); ok {
+ m.XXX_Merge(src)
+ return
+ }
+ mergeStruct(out.Elem(), in.Elem())
+}
+
+func mergeStruct(out, in reflect.Value) {
+ sprop := GetProperties(in.Type())
+ for i := 0; i < in.NumField(); i++ {
+ f := in.Type().Field(i)
+ if strings.HasPrefix(f.Name, "XXX_") {
+ continue
+ }
+ mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i])
+ }
+
+ if emIn, err := extendable(in.Addr().Interface()); err == nil {
+ emOut, _ := extendable(out.Addr().Interface())
+ mIn, muIn := emIn.extensionsRead()
+ if mIn != nil {
+ mOut := emOut.extensionsWrite()
+ muIn.Lock()
+ mergeExtension(mOut, mIn)
+ muIn.Unlock()
+ }
+ }
+
+ uf := in.FieldByName("XXX_unrecognized")
+ if !uf.IsValid() {
+ return
+ }
+ uin := uf.Bytes()
+ if len(uin) > 0 {
+ out.FieldByName("XXX_unrecognized").SetBytes(append([]byte(nil), uin...))
+ }
+}
+
+// mergeAny performs a merge between two values of the same type.
+// viaPtr indicates whether the values were indirected through a pointer (implying proto2).
+// prop is set if this is a struct field (it may be nil).
+func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) {
+ if in.Type() == protoMessageType {
+ if !in.IsNil() {
+ if out.IsNil() {
+ out.Set(reflect.ValueOf(Clone(in.Interface().(Message))))
+ } else {
+ Merge(out.Interface().(Message), in.Interface().(Message))
+ }
+ }
+ return
+ }
+ switch in.Kind() {
+ case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64,
+ reflect.String, reflect.Uint32, reflect.Uint64:
+ if !viaPtr && isProto3Zero(in) {
+ return
+ }
+ out.Set(in)
+ case reflect.Interface:
+ // Probably a oneof field; copy non-nil values.
+ if in.IsNil() {
+ return
+ }
+ // Allocate destination if it is not set, or set to a different type.
+ // Otherwise we will merge as normal.
+ if out.IsNil() || out.Elem().Type() != in.Elem().Type() {
+ out.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T)
+ }
+ mergeAny(out.Elem(), in.Elem(), false, nil)
+ case reflect.Map:
+ if in.Len() == 0 {
+ return
+ }
+ if out.IsNil() {
+ out.Set(reflect.MakeMap(in.Type()))
+ }
+ // For maps with value types of *T or []byte we need to deep copy each value.
+ elemKind := in.Type().Elem().Kind()
+ for _, key := range in.MapKeys() {
+ var val reflect.Value
+ switch elemKind {
+ case reflect.Ptr:
+ val = reflect.New(in.Type().Elem().Elem())
+ mergeAny(val, in.MapIndex(key), false, nil)
+ case reflect.Slice:
+ val = in.MapIndex(key)
+ val = reflect.ValueOf(append([]byte{}, val.Bytes()...))
+ default:
+ val = in.MapIndex(key)
+ }
+ out.SetMapIndex(key, val)
+ }
+ case reflect.Ptr:
+ if in.IsNil() {
+ return
+ }
+ if out.IsNil() {
+ out.Set(reflect.New(in.Elem().Type()))
+ }
+ mergeAny(out.Elem(), in.Elem(), true, nil)
+ case reflect.Slice:
+ if in.IsNil() {
+ return
+ }
+ if in.Type().Elem().Kind() == reflect.Uint8 {
+ // []byte is a scalar bytes field, not a repeated field.
+
+ // Edge case: if this is in a proto3 message, a zero length
+ // bytes field is considered the zero value, and should not
+ // be merged.
+ if prop != nil && prop.proto3 && in.Len() == 0 {
+ return
+ }
+
+ // Make a deep copy.
+ // Append to []byte{} instead of []byte(nil) so that we never end up
+ // with a nil result.
+ out.SetBytes(append([]byte{}, in.Bytes()...))
+ return
+ }
+ n := in.Len()
+ if out.IsNil() {
+ out.Set(reflect.MakeSlice(in.Type(), 0, n))
+ }
+ switch in.Type().Elem().Kind() {
+ case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64,
+ reflect.String, reflect.Uint32, reflect.Uint64:
+ out.Set(reflect.AppendSlice(out, in))
+ default:
+ for i := 0; i < n; i++ {
+ x := reflect.Indirect(reflect.New(in.Type().Elem()))
+ mergeAny(x, in.Index(i), false, nil)
+ out.Set(reflect.Append(out, x))
+ }
+ }
+ case reflect.Struct:
+ mergeStruct(out, in)
+ default:
+ // unknown type, so not a protocol buffer
+ log.Printf("proto: don't know how to copy %v", in)
+ }
+}
+
+func mergeExtension(out, in map[int32]Extension) {
+ for extNum, eIn := range in {
+ eOut := Extension{desc: eIn.desc}
+ if eIn.value != nil {
+ v := reflect.New(reflect.TypeOf(eIn.value)).Elem()
+ mergeAny(v, reflect.ValueOf(eIn.value), false, nil)
+ eOut.value = v.Interface()
+ }
+ if eIn.enc != nil {
+ eOut.enc = make([]byte, len(eIn.enc))
+ copy(eOut.enc, eIn.enc)
+ }
+
+ out[extNum] = eOut
+ }
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/decode.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/decode.go
new file mode 100644
index 00000000..63b0f08b
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/decode.go
@@ -0,0 +1,427 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+/*
+ * Routines for decoding protocol buffer data to construct in-memory representations.
+ */
+
+import (
+ "errors"
+ "fmt"
+ "io"
+)
+
+// errOverflow is returned when an integer is too large to be represented.
+var errOverflow = errors.New("proto: integer overflow")
+
+// ErrInternalBadWireType is returned by generated code when an incorrect
+// wire type is encountered. It does not get returned to user code.
+var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")
+
+// DecodeVarint reads a varint-encoded integer from the slice.
+// It returns the integer and the number of bytes consumed, or
+// zero if there is not enough.
+// This is the format for the
+// int32, int64, uint32, uint64, bool, and enum
+// protocol buffer types.
+func DecodeVarint(buf []byte) (x uint64, n int) {
+ for shift := uint(0); shift < 64; shift += 7 {
+ if n >= len(buf) {
+ return 0, 0
+ }
+ b := uint64(buf[n])
+ n++
+ x |= (b & 0x7F) << shift
+ if (b & 0x80) == 0 {
+ return x, n
+ }
+ }
+
+ // The number is too large to represent in a 64-bit value.
+ return 0, 0
+}
+
+func (p *Buffer) decodeVarintSlow() (x uint64, err error) {
+ i := p.index
+ l := len(p.buf)
+
+ for shift := uint(0); shift < 64; shift += 7 {
+ if i >= l {
+ err = io.ErrUnexpectedEOF
+ return
+ }
+ b := p.buf[i]
+ i++
+ x |= (uint64(b) & 0x7F) << shift
+ if b < 0x80 {
+ p.index = i
+ return
+ }
+ }
+
+ // The number is too large to represent in a 64-bit value.
+ err = errOverflow
+ return
+}
+
+// DecodeVarint reads a varint-encoded integer from the Buffer.
+// This is the format for the
+// int32, int64, uint32, uint64, bool, and enum
+// protocol buffer types.
+func (p *Buffer) DecodeVarint() (x uint64, err error) {
+ i := p.index
+ buf := p.buf
+
+ if i >= len(buf) {
+ return 0, io.ErrUnexpectedEOF
+ } else if buf[i] < 0x80 {
+ p.index++
+ return uint64(buf[i]), nil
+ } else if len(buf)-i < 10 {
+ return p.decodeVarintSlow()
+ }
+
+ var b uint64
+ // we already checked the first byte
+ x = uint64(buf[i]) - 0x80
+ i++
+
+ b = uint64(buf[i])
+ i++
+ x += b << 7
+ if b&0x80 == 0 {
+ goto done
+ }
+ x -= 0x80 << 7
+
+ b = uint64(buf[i])
+ i++
+ x += b << 14
+ if b&0x80 == 0 {
+ goto done
+ }
+ x -= 0x80 << 14
+
+ b = uint64(buf[i])
+ i++
+ x += b << 21
+ if b&0x80 == 0 {
+ goto done
+ }
+ x -= 0x80 << 21
+
+ b = uint64(buf[i])
+ i++
+ x += b << 28
+ if b&0x80 == 0 {
+ goto done
+ }
+ x -= 0x80 << 28
+
+ b = uint64(buf[i])
+ i++
+ x += b << 35
+ if b&0x80 == 0 {
+ goto done
+ }
+ x -= 0x80 << 35
+
+ b = uint64(buf[i])
+ i++
+ x += b << 42
+ if b&0x80 == 0 {
+ goto done
+ }
+ x -= 0x80 << 42
+
+ b = uint64(buf[i])
+ i++
+ x += b << 49
+ if b&0x80 == 0 {
+ goto done
+ }
+ x -= 0x80 << 49
+
+ b = uint64(buf[i])
+ i++
+ x += b << 56
+ if b&0x80 == 0 {
+ goto done
+ }
+ x -= 0x80 << 56
+
+ b = uint64(buf[i])
+ i++
+ x += b << 63
+ if b&0x80 == 0 {
+ goto done
+ }
+
+ return 0, errOverflow
+
+done:
+ p.index = i
+ return x, nil
+}
+
+// DecodeFixed64 reads a 64-bit integer from the Buffer.
+// This is the format for the
+// fixed64, sfixed64, and double protocol buffer types.
+func (p *Buffer) DecodeFixed64() (x uint64, err error) {
+ // x, err already 0
+ i := p.index + 8
+ if i < 0 || i > len(p.buf) {
+ err = io.ErrUnexpectedEOF
+ return
+ }
+ p.index = i
+
+ x = uint64(p.buf[i-8])
+ x |= uint64(p.buf[i-7]) << 8
+ x |= uint64(p.buf[i-6]) << 16
+ x |= uint64(p.buf[i-5]) << 24
+ x |= uint64(p.buf[i-4]) << 32
+ x |= uint64(p.buf[i-3]) << 40
+ x |= uint64(p.buf[i-2]) << 48
+ x |= uint64(p.buf[i-1]) << 56
+ return
+}
+
+// DecodeFixed32 reads a 32-bit integer from the Buffer.
+// This is the format for the
+// fixed32, sfixed32, and float protocol buffer types.
+func (p *Buffer) DecodeFixed32() (x uint64, err error) {
+ // x, err already 0
+ i := p.index + 4
+ if i < 0 || i > len(p.buf) {
+ err = io.ErrUnexpectedEOF
+ return
+ }
+ p.index = i
+
+ x = uint64(p.buf[i-4])
+ x |= uint64(p.buf[i-3]) << 8
+ x |= uint64(p.buf[i-2]) << 16
+ x |= uint64(p.buf[i-1]) << 24
+ return
+}
+
+// DecodeZigzag64 reads a zigzag-encoded 64-bit integer
+// from the Buffer.
+// This is the format used for the sint64 protocol buffer type.
+func (p *Buffer) DecodeZigzag64() (x uint64, err error) {
+ x, err = p.DecodeVarint()
+ if err != nil {
+ return
+ }
+ x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63)
+ return
+}
+
+// DecodeZigzag32 reads a zigzag-encoded 32-bit integer
+// from the Buffer.
+// This is the format used for the sint32 protocol buffer type.
+func (p *Buffer) DecodeZigzag32() (x uint64, err error) {
+ x, err = p.DecodeVarint()
+ if err != nil {
+ return
+ }
+ x = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31))
+ return
+}
+
+// DecodeRawBytes reads a count-delimited byte buffer from the Buffer.
+// This is the format used for the bytes protocol buffer
+// type and for embedded messages.
+func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) {
+ n, err := p.DecodeVarint()
+ if err != nil {
+ return nil, err
+ }
+
+ nb := int(n)
+ if nb < 0 {
+ return nil, fmt.Errorf("proto: bad byte length %d", nb)
+ }
+ end := p.index + nb
+ if end < p.index || end > len(p.buf) {
+ return nil, io.ErrUnexpectedEOF
+ }
+
+ if !alloc {
+ // todo: check if can get more uses of alloc=false
+ buf = p.buf[p.index:end]
+ p.index += nb
+ return
+ }
+
+ buf = make([]byte, nb)
+ copy(buf, p.buf[p.index:])
+ p.index += nb
+ return
+}
+
+// DecodeStringBytes reads an encoded string from the Buffer.
+// This is the format used for the proto2 string type.
+func (p *Buffer) DecodeStringBytes() (s string, err error) {
+ buf, err := p.DecodeRawBytes(false)
+ if err != nil {
+ return
+ }
+ return string(buf), nil
+}
+
+// Unmarshaler is the interface representing objects that can
+// unmarshal themselves. The argument points to data that may be
+// overwritten, so implementations should not keep references to the
+// buffer.
+// Unmarshal implementations should not clear the receiver.
+// Any unmarshaled data should be merged into the receiver.
+// Callers of Unmarshal that do not want to retain existing data
+// should Reset the receiver before calling Unmarshal.
+type Unmarshaler interface {
+ Unmarshal([]byte) error
+}
+
+// newUnmarshaler is the interface representing objects that can
+// unmarshal themselves. The semantics are identical to Unmarshaler.
+//
+// This exists to support protoc-gen-go generated messages.
+// The proto package will stop type-asserting to this interface in the future.
+//
+// DO NOT DEPEND ON THIS.
+type newUnmarshaler interface {
+ XXX_Unmarshal([]byte) error
+}
+
+// Unmarshal parses the protocol buffer representation in buf and places the
+// decoded result in pb. If the struct underlying pb does not match
+// the data in buf, the results can be unpredictable.
+//
+// Unmarshal resets pb before starting to unmarshal, so any
+// existing data in pb is always removed. Use UnmarshalMerge
+// to preserve and append to existing data.
+func Unmarshal(buf []byte, pb Message) error {
+ pb.Reset()
+ if u, ok := pb.(newUnmarshaler); ok {
+ return u.XXX_Unmarshal(buf)
+ }
+ if u, ok := pb.(Unmarshaler); ok {
+ return u.Unmarshal(buf)
+ }
+ return NewBuffer(buf).Unmarshal(pb)
+}
+
+// UnmarshalMerge parses the protocol buffer representation in buf and
+// writes the decoded result to pb. If the struct underlying pb does not match
+// the data in buf, the results can be unpredictable.
+//
+// UnmarshalMerge merges into existing data in pb.
+// Most code should use Unmarshal instead.
+func UnmarshalMerge(buf []byte, pb Message) error {
+ if u, ok := pb.(newUnmarshaler); ok {
+ return u.XXX_Unmarshal(buf)
+ }
+ if u, ok := pb.(Unmarshaler); ok {
+ // NOTE: The history of proto have unfortunately been inconsistent
+ // whether Unmarshaler should or should not implicitly clear itself.
+ // Some implementations do, most do not.
+ // Thus, calling this here may or may not do what people want.
+ //
+ // See https://github.com/golang/protobuf/issues/424
+ return u.Unmarshal(buf)
+ }
+ return NewBuffer(buf).Unmarshal(pb)
+}
+
+// DecodeMessage reads a count-delimited message from the Buffer.
+func (p *Buffer) DecodeMessage(pb Message) error {
+ enc, err := p.DecodeRawBytes(false)
+ if err != nil {
+ return err
+ }
+ return NewBuffer(enc).Unmarshal(pb)
+}
+
+// DecodeGroup reads a tag-delimited group from the Buffer.
+// StartGroup tag is already consumed. This function consumes
+// EndGroup tag.
+func (p *Buffer) DecodeGroup(pb Message) error {
+ b := p.buf[p.index:]
+ x, y := findEndGroup(b)
+ if x < 0 {
+ return io.ErrUnexpectedEOF
+ }
+ err := Unmarshal(b[:x], pb)
+ p.index += y
+ return err
+}
+
+// Unmarshal parses the protocol buffer representation in the
+// Buffer and places the decoded result in pb. If the struct
+// underlying pb does not match the data in the buffer, the results can be
+// unpredictable.
+//
+// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal.
+func (p *Buffer) Unmarshal(pb Message) error {
+ // If the object can unmarshal itself, let it.
+ if u, ok := pb.(newUnmarshaler); ok {
+ err := u.XXX_Unmarshal(p.buf[p.index:])
+ p.index = len(p.buf)
+ return err
+ }
+ if u, ok := pb.(Unmarshaler); ok {
+ // NOTE: The history of proto have unfortunately been inconsistent
+ // whether Unmarshaler should or should not implicitly clear itself.
+ // Some implementations do, most do not.
+ // Thus, calling this here may or may not do what people want.
+ //
+ // See https://github.com/golang/protobuf/issues/424
+ err := u.Unmarshal(p.buf[p.index:])
+ p.index = len(p.buf)
+ return err
+ }
+
+ // Slow workaround for messages that aren't Unmarshalers.
+ // This includes some hand-coded .pb.go files and
+ // bootstrap protos.
+ // TODO: fix all of those and then add Unmarshal to
+ // the Message interface. Then:
+ // The cast above and code below can be deleted.
+ // The old unmarshaler can be deleted.
+ // Clients can call Unmarshal directly (can already do that, actually).
+ var info InternalMessageInfo
+ err := info.Unmarshal(pb, p.buf[p.index:])
+ p.index = len(p.buf)
+ return err
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/deprecated.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/deprecated.go
new file mode 100644
index 00000000..35b882c0
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/deprecated.go
@@ -0,0 +1,63 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2018 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+import "errors"
+
+// Deprecated: do not use.
+type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 }
+
+// Deprecated: do not use.
+func GetStats() Stats { return Stats{} }
+
+// Deprecated: do not use.
+func MarshalMessageSet(interface{}) ([]byte, error) {
+ return nil, errors.New("proto: not implemented")
+}
+
+// Deprecated: do not use.
+func UnmarshalMessageSet([]byte, interface{}) error {
+ return errors.New("proto: not implemented")
+}
+
+// Deprecated: do not use.
+func MarshalMessageSetJSON(interface{}) ([]byte, error) {
+ return nil, errors.New("proto: not implemented")
+}
+
+// Deprecated: do not use.
+func UnmarshalMessageSetJSON([]byte, interface{}) error {
+ return errors.New("proto: not implemented")
+}
+
+// Deprecated: do not use.
+func RegisterMessageSetType(Message, int32, string) {}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/discard.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/discard.go
new file mode 100644
index 00000000..dea2617c
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/discard.go
@@ -0,0 +1,350 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2017 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+import (
+ "fmt"
+ "reflect"
+ "strings"
+ "sync"
+ "sync/atomic"
+)
+
+type generatedDiscarder interface {
+ XXX_DiscardUnknown()
+}
+
+// DiscardUnknown recursively discards all unknown fields from this message
+// and all embedded messages.
+//
+// When unmarshaling a message with unrecognized fields, the tags and values
+// of such fields are preserved in the Message. This allows a later call to
+// marshal to be able to produce a message that continues to have those
+// unrecognized fields. To avoid this, DiscardUnknown is used to
+// explicitly clear the unknown fields after unmarshaling.
+//
+// For proto2 messages, the unknown fields of message extensions are only
+// discarded from messages that have been accessed via GetExtension.
+func DiscardUnknown(m Message) {
+ if m, ok := m.(generatedDiscarder); ok {
+ m.XXX_DiscardUnknown()
+ return
+ }
+ // TODO: Dynamically populate a InternalMessageInfo for legacy messages,
+ // but the master branch has no implementation for InternalMessageInfo,
+ // so it would be more work to replicate that approach.
+ discardLegacy(m)
+}
+
+// DiscardUnknown recursively discards all unknown fields.
+func (a *InternalMessageInfo) DiscardUnknown(m Message) {
+ di := atomicLoadDiscardInfo(&a.discard)
+ if di == nil {
+ di = getDiscardInfo(reflect.TypeOf(m).Elem())
+ atomicStoreDiscardInfo(&a.discard, di)
+ }
+ di.discard(toPointer(&m))
+}
+
+type discardInfo struct {
+ typ reflect.Type
+
+ initialized int32 // 0: only typ is valid, 1: everything is valid
+ lock sync.Mutex
+
+ fields []discardFieldInfo
+ unrecognized field
+}
+
+type discardFieldInfo struct {
+ field field // Offset of field, guaranteed to be valid
+ discard func(src pointer)
+}
+
+var (
+ discardInfoMap = map[reflect.Type]*discardInfo{}
+ discardInfoLock sync.Mutex
+)
+
+func getDiscardInfo(t reflect.Type) *discardInfo {
+ discardInfoLock.Lock()
+ defer discardInfoLock.Unlock()
+ di := discardInfoMap[t]
+ if di == nil {
+ di = &discardInfo{typ: t}
+ discardInfoMap[t] = di
+ }
+ return di
+}
+
+func (di *discardInfo) discard(src pointer) {
+ if src.isNil() {
+ return // Nothing to do.
+ }
+
+ if atomic.LoadInt32(&di.initialized) == 0 {
+ di.computeDiscardInfo()
+ }
+
+ for _, fi := range di.fields {
+ sfp := src.offset(fi.field)
+ fi.discard(sfp)
+ }
+
+ // For proto2 messages, only discard unknown fields in message extensions
+ // that have been accessed via GetExtension.
+ if em, err := extendable(src.asPointerTo(di.typ).Interface()); err == nil {
+ // Ignore lock since DiscardUnknown is not concurrency safe.
+ emm, _ := em.extensionsRead()
+ for _, mx := range emm {
+ if m, ok := mx.value.(Message); ok {
+ DiscardUnknown(m)
+ }
+ }
+ }
+
+ if di.unrecognized.IsValid() {
+ *src.offset(di.unrecognized).toBytes() = nil
+ }
+}
+
+func (di *discardInfo) computeDiscardInfo() {
+ di.lock.Lock()
+ defer di.lock.Unlock()
+ if di.initialized != 0 {
+ return
+ }
+ t := di.typ
+ n := t.NumField()
+
+ for i := 0; i < n; i++ {
+ f := t.Field(i)
+ if strings.HasPrefix(f.Name, "XXX_") {
+ continue
+ }
+
+ dfi := discardFieldInfo{field: toField(&f)}
+ tf := f.Type
+
+ // Unwrap tf to get its most basic type.
+ var isPointer, isSlice bool
+ if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
+ isSlice = true
+ tf = tf.Elem()
+ }
+ if tf.Kind() == reflect.Ptr {
+ isPointer = true
+ tf = tf.Elem()
+ }
+ if isPointer && isSlice && tf.Kind() != reflect.Struct {
+ panic(fmt.Sprintf("%v.%s cannot be a slice of pointers to primitive types", t, f.Name))
+ }
+
+ switch tf.Kind() {
+ case reflect.Struct:
+ switch {
+ case !isPointer:
+ panic(fmt.Sprintf("%v.%s cannot be a direct struct value", t, f.Name))
+ case isSlice: // E.g., []*pb.T
+ di := getDiscardInfo(tf)
+ dfi.discard = func(src pointer) {
+ sps := src.getPointerSlice()
+ for _, sp := range sps {
+ if !sp.isNil() {
+ di.discard(sp)
+ }
+ }
+ }
+ default: // E.g., *pb.T
+ di := getDiscardInfo(tf)
+ dfi.discard = func(src pointer) {
+ sp := src.getPointer()
+ if !sp.isNil() {
+ di.discard(sp)
+ }
+ }
+ }
+ case reflect.Map:
+ switch {
+ case isPointer || isSlice:
+ panic(fmt.Sprintf("%v.%s cannot be a pointer to a map or a slice of map values", t, f.Name))
+ default: // E.g., map[K]V
+ if tf.Elem().Kind() == reflect.Ptr { // Proto struct (e.g., *T)
+ dfi.discard = func(src pointer) {
+ sm := src.asPointerTo(tf).Elem()
+ if sm.Len() == 0 {
+ return
+ }
+ for _, key := range sm.MapKeys() {
+ val := sm.MapIndex(key)
+ DiscardUnknown(val.Interface().(Message))
+ }
+ }
+ } else {
+ dfi.discard = func(pointer) {} // Noop
+ }
+ }
+ case reflect.Interface:
+ // Must be oneof field.
+ switch {
+ case isPointer || isSlice:
+ panic(fmt.Sprintf("%v.%s cannot be a pointer to a interface or a slice of interface values", t, f.Name))
+ default: // E.g., interface{}
+ // TODO: Make this faster?
+ dfi.discard = func(src pointer) {
+ su := src.asPointerTo(tf).Elem()
+ if !su.IsNil() {
+ sv := su.Elem().Elem().Field(0)
+ if sv.Kind() == reflect.Ptr && sv.IsNil() {
+ return
+ }
+ switch sv.Type().Kind() {
+ case reflect.Ptr: // Proto struct (e.g., *T)
+ DiscardUnknown(sv.Interface().(Message))
+ }
+ }
+ }
+ }
+ default:
+ continue
+ }
+ di.fields = append(di.fields, dfi)
+ }
+
+ di.unrecognized = invalidField
+ if f, ok := t.FieldByName("XXX_unrecognized"); ok {
+ if f.Type != reflect.TypeOf([]byte{}) {
+ panic("expected XXX_unrecognized to be of type []byte")
+ }
+ di.unrecognized = toField(&f)
+ }
+
+ atomic.StoreInt32(&di.initialized, 1)
+}
+
+func discardLegacy(m Message) {
+ v := reflect.ValueOf(m)
+ if v.Kind() != reflect.Ptr || v.IsNil() {
+ return
+ }
+ v = v.Elem()
+ if v.Kind() != reflect.Struct {
+ return
+ }
+ t := v.Type()
+
+ for i := 0; i < v.NumField(); i++ {
+ f := t.Field(i)
+ if strings.HasPrefix(f.Name, "XXX_") {
+ continue
+ }
+ vf := v.Field(i)
+ tf := f.Type
+
+ // Unwrap tf to get its most basic type.
+ var isPointer, isSlice bool
+ if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
+ isSlice = true
+ tf = tf.Elem()
+ }
+ if tf.Kind() == reflect.Ptr {
+ isPointer = true
+ tf = tf.Elem()
+ }
+ if isPointer && isSlice && tf.Kind() != reflect.Struct {
+ panic(fmt.Sprintf("%T.%s cannot be a slice of pointers to primitive types", m, f.Name))
+ }
+
+ switch tf.Kind() {
+ case reflect.Struct:
+ switch {
+ case !isPointer:
+ panic(fmt.Sprintf("%T.%s cannot be a direct struct value", m, f.Name))
+ case isSlice: // E.g., []*pb.T
+ for j := 0; j < vf.Len(); j++ {
+ discardLegacy(vf.Index(j).Interface().(Message))
+ }
+ default: // E.g., *pb.T
+ discardLegacy(vf.Interface().(Message))
+ }
+ case reflect.Map:
+ switch {
+ case isPointer || isSlice:
+ panic(fmt.Sprintf("%T.%s cannot be a pointer to a map or a slice of map values", m, f.Name))
+ default: // E.g., map[K]V
+ tv := vf.Type().Elem()
+ if tv.Kind() == reflect.Ptr && tv.Implements(protoMessageType) { // Proto struct (e.g., *T)
+ for _, key := range vf.MapKeys() {
+ val := vf.MapIndex(key)
+ discardLegacy(val.Interface().(Message))
+ }
+ }
+ }
+ case reflect.Interface:
+ // Must be oneof field.
+ switch {
+ case isPointer || isSlice:
+ panic(fmt.Sprintf("%T.%s cannot be a pointer to a interface or a slice of interface values", m, f.Name))
+ default: // E.g., test_proto.isCommunique_Union interface
+ if !vf.IsNil() && f.Tag.Get("protobuf_oneof") != "" {
+ vf = vf.Elem() // E.g., *test_proto.Communique_Msg
+ if !vf.IsNil() {
+ vf = vf.Elem() // E.g., test_proto.Communique_Msg
+ vf = vf.Field(0) // E.g., Proto struct (e.g., *T) or primitive value
+ if vf.Kind() == reflect.Ptr {
+ discardLegacy(vf.Interface().(Message))
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if vf := v.FieldByName("XXX_unrecognized"); vf.IsValid() {
+ if vf.Type() != reflect.TypeOf([]byte{}) {
+ panic("expected XXX_unrecognized to be of type []byte")
+ }
+ vf.Set(reflect.ValueOf([]byte(nil)))
+ }
+
+ // For proto2 messages, only discard unknown fields in message extensions
+ // that have been accessed via GetExtension.
+ if em, err := extendable(m); err == nil {
+ // Ignore lock since discardLegacy is not concurrency safe.
+ emm, _ := em.extensionsRead()
+ for _, mx := range emm {
+ if m, ok := mx.value.(Message); ok {
+ discardLegacy(m)
+ }
+ }
+ }
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/encode.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/encode.go
new file mode 100644
index 00000000..3abfed2c
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/encode.go
@@ -0,0 +1,203 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+/*
+ * Routines for encoding data into the wire format for protocol buffers.
+ */
+
+import (
+ "errors"
+ "reflect"
+)
+
+var (
+ // errRepeatedHasNil is the error returned if Marshal is called with
+ // a struct with a repeated field containing a nil element.
+ errRepeatedHasNil = errors.New("proto: repeated field has nil element")
+
+ // errOneofHasNil is the error returned if Marshal is called with
+ // a struct with a oneof field containing a nil element.
+ errOneofHasNil = errors.New("proto: oneof field has nil value")
+
+ // ErrNil is the error returned if Marshal is called with nil.
+ ErrNil = errors.New("proto: Marshal called with nil")
+
+ // ErrTooLarge is the error returned if Marshal is called with a
+ // message that encodes to >2GB.
+ ErrTooLarge = errors.New("proto: message encodes to over 2 GB")
+)
+
+// The fundamental encoders that put bytes on the wire.
+// Those that take integer types all accept uint64 and are
+// therefore of type valueEncoder.
+
+const maxVarintBytes = 10 // maximum length of a varint
+
+// EncodeVarint returns the varint encoding of x.
+// This is the format for the
+// int32, int64, uint32, uint64, bool, and enum
+// protocol buffer types.
+// Not used by the package itself, but helpful to clients
+// wishing to use the same encoding.
+func EncodeVarint(x uint64) []byte {
+ var buf [maxVarintBytes]byte
+ var n int
+ for n = 0; x > 127; n++ {
+ buf[n] = 0x80 | uint8(x&0x7F)
+ x >>= 7
+ }
+ buf[n] = uint8(x)
+ n++
+ return buf[0:n]
+}
+
+// EncodeVarint writes a varint-encoded integer to the Buffer.
+// This is the format for the
+// int32, int64, uint32, uint64, bool, and enum
+// protocol buffer types.
+func (p *Buffer) EncodeVarint(x uint64) error {
+ for x >= 1<<7 {
+ p.buf = append(p.buf, uint8(x&0x7f|0x80))
+ x >>= 7
+ }
+ p.buf = append(p.buf, uint8(x))
+ return nil
+}
+
+// SizeVarint returns the varint encoding size of an integer.
+func SizeVarint(x uint64) int {
+ switch {
+ case x < 1<<7:
+ return 1
+ case x < 1<<14:
+ return 2
+ case x < 1<<21:
+ return 3
+ case x < 1<<28:
+ return 4
+ case x < 1<<35:
+ return 5
+ case x < 1<<42:
+ return 6
+ case x < 1<<49:
+ return 7
+ case x < 1<<56:
+ return 8
+ case x < 1<<63:
+ return 9
+ }
+ return 10
+}
+
+// EncodeFixed64 writes a 64-bit integer to the Buffer.
+// This is the format for the
+// fixed64, sfixed64, and double protocol buffer types.
+func (p *Buffer) EncodeFixed64(x uint64) error {
+ p.buf = append(p.buf,
+ uint8(x),
+ uint8(x>>8),
+ uint8(x>>16),
+ uint8(x>>24),
+ uint8(x>>32),
+ uint8(x>>40),
+ uint8(x>>48),
+ uint8(x>>56))
+ return nil
+}
+
+// EncodeFixed32 writes a 32-bit integer to the Buffer.
+// This is the format for the
+// fixed32, sfixed32, and float protocol buffer types.
+func (p *Buffer) EncodeFixed32(x uint64) error {
+ p.buf = append(p.buf,
+ uint8(x),
+ uint8(x>>8),
+ uint8(x>>16),
+ uint8(x>>24))
+ return nil
+}
+
+// EncodeZigzag64 writes a zigzag-encoded 64-bit integer
+// to the Buffer.
+// This is the format used for the sint64 protocol buffer type.
+func (p *Buffer) EncodeZigzag64(x uint64) error {
+ // use signed number to get arithmetic right shift.
+ return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+}
+
+// EncodeZigzag32 writes a zigzag-encoded 32-bit integer
+// to the Buffer.
+// This is the format used for the sint32 protocol buffer type.
+func (p *Buffer) EncodeZigzag32(x uint64) error {
+ // use signed number to get arithmetic right shift.
+ return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31))))
+}
+
+// EncodeRawBytes writes a count-delimited byte buffer to the Buffer.
+// This is the format used for the bytes protocol buffer
+// type and for embedded messages.
+func (p *Buffer) EncodeRawBytes(b []byte) error {
+ p.EncodeVarint(uint64(len(b)))
+ p.buf = append(p.buf, b...)
+ return nil
+}
+
+// EncodeStringBytes writes an encoded string to the Buffer.
+// This is the format used for the proto2 string type.
+func (p *Buffer) EncodeStringBytes(s string) error {
+ p.EncodeVarint(uint64(len(s)))
+ p.buf = append(p.buf, s...)
+ return nil
+}
+
+// Marshaler is the interface representing objects that can marshal themselves.
+type Marshaler interface {
+ Marshal() ([]byte, error)
+}
+
+// EncodeMessage writes the protocol buffer to the Buffer,
+// prefixed by a varint-encoded length.
+func (p *Buffer) EncodeMessage(pb Message) error {
+ siz := Size(pb)
+ p.EncodeVarint(uint64(siz))
+ return p.Marshal(pb)
+}
+
+// All protocol buffer fields are nillable, but be careful.
+func isNil(v reflect.Value) bool {
+ switch v.Kind() {
+ case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
+ return v.IsNil()
+ }
+ return false
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/equal.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/equal.go
new file mode 100644
index 00000000..f9b6e41b
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/equal.go
@@ -0,0 +1,301 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2011 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Protocol buffer comparison.
+
+package proto
+
+import (
+ "bytes"
+ "log"
+ "reflect"
+ "strings"
+)
+
+/*
+Equal returns true iff protocol buffers a and b are equal.
+The arguments must both be pointers to protocol buffer structs.
+
+Equality is defined in this way:
+ - Two messages are equal iff they are the same type,
+ corresponding fields are equal, unknown field sets
+ are equal, and extensions sets are equal.
+ - Two set scalar fields are equal iff their values are equal.
+ If the fields are of a floating-point type, remember that
+ NaN != x for all x, including NaN. If the message is defined
+ in a proto3 .proto file, fields are not "set"; specifically,
+ zero length proto3 "bytes" fields are equal (nil == {}).
+ - Two repeated fields are equal iff their lengths are the same,
+ and their corresponding elements are equal. Note a "bytes" field,
+ although represented by []byte, is not a repeated field and the
+ rule for the scalar fields described above applies.
+ - Two unset fields are equal.
+ - Two unknown field sets are equal if their current
+ encoded state is equal.
+ - Two extension sets are equal iff they have corresponding
+ elements that are pairwise equal.
+ - Two map fields are equal iff their lengths are the same,
+ and they contain the same set of elements. Zero-length map
+ fields are equal.
+ - Every other combination of things are not equal.
+
+The return value is undefined if a and b are not protocol buffers.
+*/
+func Equal(a, b Message) bool {
+ if a == nil || b == nil {
+ return a == b
+ }
+ v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b)
+ if v1.Type() != v2.Type() {
+ return false
+ }
+ if v1.Kind() == reflect.Ptr {
+ if v1.IsNil() {
+ return v2.IsNil()
+ }
+ if v2.IsNil() {
+ return false
+ }
+ v1, v2 = v1.Elem(), v2.Elem()
+ }
+ if v1.Kind() != reflect.Struct {
+ return false
+ }
+ return equalStruct(v1, v2)
+}
+
+// v1 and v2 are known to have the same type.
+func equalStruct(v1, v2 reflect.Value) bool {
+ sprop := GetProperties(v1.Type())
+ for i := 0; i < v1.NumField(); i++ {
+ f := v1.Type().Field(i)
+ if strings.HasPrefix(f.Name, "XXX_") {
+ continue
+ }
+ f1, f2 := v1.Field(i), v2.Field(i)
+ if f.Type.Kind() == reflect.Ptr {
+ if n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 {
+ // both unset
+ continue
+ } else if n1 != n2 {
+ // set/unset mismatch
+ return false
+ }
+ f1, f2 = f1.Elem(), f2.Elem()
+ }
+ if !equalAny(f1, f2, sprop.Prop[i]) {
+ return false
+ }
+ }
+
+ if em1 := v1.FieldByName("XXX_InternalExtensions"); em1.IsValid() {
+ em2 := v2.FieldByName("XXX_InternalExtensions")
+ if !equalExtensions(v1.Type(), em1.Interface().(XXX_InternalExtensions), em2.Interface().(XXX_InternalExtensions)) {
+ return false
+ }
+ }
+
+ if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() {
+ em2 := v2.FieldByName("XXX_extensions")
+ if !equalExtMap(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) {
+ return false
+ }
+ }
+
+ uf := v1.FieldByName("XXX_unrecognized")
+ if !uf.IsValid() {
+ return true
+ }
+
+ u1 := uf.Bytes()
+ u2 := v2.FieldByName("XXX_unrecognized").Bytes()
+ return bytes.Equal(u1, u2)
+}
+
+// v1 and v2 are known to have the same type.
+// prop may be nil.
+func equalAny(v1, v2 reflect.Value, prop *Properties) bool {
+ if v1.Type() == protoMessageType {
+ m1, _ := v1.Interface().(Message)
+ m2, _ := v2.Interface().(Message)
+ return Equal(m1, m2)
+ }
+ switch v1.Kind() {
+ case reflect.Bool:
+ return v1.Bool() == v2.Bool()
+ case reflect.Float32, reflect.Float64:
+ return v1.Float() == v2.Float()
+ case reflect.Int32, reflect.Int64:
+ return v1.Int() == v2.Int()
+ case reflect.Interface:
+ // Probably a oneof field; compare the inner values.
+ n1, n2 := v1.IsNil(), v2.IsNil()
+ if n1 || n2 {
+ return n1 == n2
+ }
+ e1, e2 := v1.Elem(), v2.Elem()
+ if e1.Type() != e2.Type() {
+ return false
+ }
+ return equalAny(e1, e2, nil)
+ case reflect.Map:
+ if v1.Len() != v2.Len() {
+ return false
+ }
+ for _, key := range v1.MapKeys() {
+ val2 := v2.MapIndex(key)
+ if !val2.IsValid() {
+ // This key was not found in the second map.
+ return false
+ }
+ if !equalAny(v1.MapIndex(key), val2, nil) {
+ return false
+ }
+ }
+ return true
+ case reflect.Ptr:
+ // Maps may have nil values in them, so check for nil.
+ if v1.IsNil() && v2.IsNil() {
+ return true
+ }
+ if v1.IsNil() != v2.IsNil() {
+ return false
+ }
+ return equalAny(v1.Elem(), v2.Elem(), prop)
+ case reflect.Slice:
+ if v1.Type().Elem().Kind() == reflect.Uint8 {
+ // short circuit: []byte
+
+ // Edge case: if this is in a proto3 message, a zero length
+ // bytes field is considered the zero value.
+ if prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 {
+ return true
+ }
+ if v1.IsNil() != v2.IsNil() {
+ return false
+ }
+ return bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte))
+ }
+
+ if v1.Len() != v2.Len() {
+ return false
+ }
+ for i := 0; i < v1.Len(); i++ {
+ if !equalAny(v1.Index(i), v2.Index(i), prop) {
+ return false
+ }
+ }
+ return true
+ case reflect.String:
+ return v1.Interface().(string) == v2.Interface().(string)
+ case reflect.Struct:
+ return equalStruct(v1, v2)
+ case reflect.Uint32, reflect.Uint64:
+ return v1.Uint() == v2.Uint()
+ }
+
+ // unknown type, so not a protocol buffer
+ log.Printf("proto: don't know how to compare %v", v1)
+ return false
+}
+
+// base is the struct type that the extensions are based on.
+// x1 and x2 are InternalExtensions.
+func equalExtensions(base reflect.Type, x1, x2 XXX_InternalExtensions) bool {
+ em1, _ := x1.extensionsRead()
+ em2, _ := x2.extensionsRead()
+ return equalExtMap(base, em1, em2)
+}
+
+func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {
+ if len(em1) != len(em2) {
+ return false
+ }
+
+ for extNum, e1 := range em1 {
+ e2, ok := em2[extNum]
+ if !ok {
+ return false
+ }
+
+ m1 := extensionAsLegacyType(e1.value)
+ m2 := extensionAsLegacyType(e2.value)
+
+ if m1 == nil && m2 == nil {
+ // Both have only encoded form.
+ if bytes.Equal(e1.enc, e2.enc) {
+ continue
+ }
+ // The bytes are different, but the extensions might still be
+ // equal. We need to decode them to compare.
+ }
+
+ if m1 != nil && m2 != nil {
+ // Both are unencoded.
+ if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {
+ return false
+ }
+ continue
+ }
+
+ // At least one is encoded. To do a semantically correct comparison
+ // we need to unmarshal them first.
+ var desc *ExtensionDesc
+ if m := extensionMaps[base]; m != nil {
+ desc = m[extNum]
+ }
+ if desc == nil {
+ // If both have only encoded form and the bytes are the same,
+ // it is handled above. We get here when the bytes are different.
+ // We don't know how to decode it, so just compare them as byte
+ // slices.
+ log.Printf("proto: don't know how to compare extension %d of %v", extNum, base)
+ return false
+ }
+ var err error
+ if m1 == nil {
+ m1, err = decodeExtension(e1.enc, desc)
+ }
+ if m2 == nil && err == nil {
+ m2, err = decodeExtension(e2.enc, desc)
+ }
+ if err != nil {
+ // The encoded form is invalid.
+ log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err)
+ return false
+ }
+ if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {
+ return false
+ }
+ }
+
+ return true
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/extensions.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/extensions.go
new file mode 100644
index 00000000..fa88add3
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/extensions.go
@@ -0,0 +1,607 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+/*
+ * Types and routines for supporting protocol buffer extensions.
+ */
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "reflect"
+ "strconv"
+ "sync"
+)
+
+// ErrMissingExtension is the error returned by GetExtension if the named extension is not in the message.
+var ErrMissingExtension = errors.New("proto: missing extension")
+
+// ExtensionRange represents a range of message extensions for a protocol buffer.
+// Used in code generated by the protocol compiler.
+type ExtensionRange struct {
+ Start, End int32 // both inclusive
+}
+
+// extendableProto is an interface implemented by any protocol buffer generated by the current
+// proto compiler that may be extended.
+type extendableProto interface {
+ Message
+ ExtensionRangeArray() []ExtensionRange
+ extensionsWrite() map[int32]Extension
+ extensionsRead() (map[int32]Extension, sync.Locker)
+}
+
+// extendableProtoV1 is an interface implemented by a protocol buffer generated by the previous
+// version of the proto compiler that may be extended.
+type extendableProtoV1 interface {
+ Message
+ ExtensionRangeArray() []ExtensionRange
+ ExtensionMap() map[int32]Extension
+}
+
+// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto.
+type extensionAdapter struct {
+ extendableProtoV1
+}
+
+func (e extensionAdapter) extensionsWrite() map[int32]Extension {
+ return e.ExtensionMap()
+}
+
+func (e extensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) {
+ return e.ExtensionMap(), notLocker{}
+}
+
+// notLocker is a sync.Locker whose Lock and Unlock methods are nops.
+type notLocker struct{}
+
+func (n notLocker) Lock() {}
+func (n notLocker) Unlock() {}
+
+// extendable returns the extendableProto interface for the given generated proto message.
+// If the proto message has the old extension format, it returns a wrapper that implements
+// the extendableProto interface.
+func extendable(p interface{}) (extendableProto, error) {
+ switch p := p.(type) {
+ case extendableProto:
+ if isNilPtr(p) {
+ return nil, fmt.Errorf("proto: nil %T is not extendable", p)
+ }
+ return p, nil
+ case extendableProtoV1:
+ if isNilPtr(p) {
+ return nil, fmt.Errorf("proto: nil %T is not extendable", p)
+ }
+ return extensionAdapter{p}, nil
+ }
+ // Don't allocate a specific error containing %T:
+ // this is the hot path for Clone and MarshalText.
+ return nil, errNotExtendable
+}
+
+var errNotExtendable = errors.New("proto: not an extendable proto.Message")
+
+func isNilPtr(x interface{}) bool {
+ v := reflect.ValueOf(x)
+ return v.Kind() == reflect.Ptr && v.IsNil()
+}
+
+// XXX_InternalExtensions is an internal representation of proto extensions.
+//
+// Each generated message struct type embeds an anonymous XXX_InternalExtensions field,
+// thus gaining the unexported 'extensions' method, which can be called only from the proto package.
+//
+// The methods of XXX_InternalExtensions are not concurrency safe in general,
+// but calls to logically read-only methods such as has and get may be executed concurrently.
+type XXX_InternalExtensions struct {
+ // The struct must be indirect so that if a user inadvertently copies a
+ // generated message and its embedded XXX_InternalExtensions, they
+ // avoid the mayhem of a copied mutex.
+ //
+ // The mutex serializes all logically read-only operations to p.extensionMap.
+ // It is up to the client to ensure that write operations to p.extensionMap are
+ // mutually exclusive with other accesses.
+ p *struct {
+ mu sync.Mutex
+ extensionMap map[int32]Extension
+ }
+}
+
+// extensionsWrite returns the extension map, creating it on first use.
+func (e *XXX_InternalExtensions) extensionsWrite() map[int32]Extension {
+ if e.p == nil {
+ e.p = new(struct {
+ mu sync.Mutex
+ extensionMap map[int32]Extension
+ })
+ e.p.extensionMap = make(map[int32]Extension)
+ }
+ return e.p.extensionMap
+}
+
+// extensionsRead returns the extensions map for read-only use. It may be nil.
+// The caller must hold the returned mutex's lock when accessing Elements within the map.
+func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Locker) {
+ if e.p == nil {
+ return nil, nil
+ }
+ return e.p.extensionMap, &e.p.mu
+}
+
+// ExtensionDesc represents an extension specification.
+// Used in generated code from the protocol compiler.
+type ExtensionDesc struct {
+ ExtendedType Message // nil pointer to the type that is being extended
+ ExtensionType interface{} // nil pointer to the extension type
+ Field int32 // field number
+ Name string // fully-qualified name of extension, for text formatting
+ Tag string // protobuf tag style
+ Filename string // name of the file in which the extension is defined
+}
+
+func (ed *ExtensionDesc) repeated() bool {
+ t := reflect.TypeOf(ed.ExtensionType)
+ return t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8
+}
+
+// Extension represents an extension in a message.
+type Extension struct {
+ // When an extension is stored in a message using SetExtension
+ // only desc and value are set. When the message is marshaled
+ // enc will be set to the encoded form of the message.
+ //
+ // When a message is unmarshaled and contains extensions, each
+ // extension will have only enc set. When such an extension is
+ // accessed using GetExtension (or GetExtensions) desc and value
+ // will be set.
+ desc *ExtensionDesc
+
+ // value is a concrete value for the extension field. Let the type of
+ // desc.ExtensionType be the "API type" and the type of Extension.value
+ // be the "storage type". The API type and storage type are the same except:
+ // * For scalars (except []byte), the API type uses *T,
+ // while the storage type uses T.
+ // * For repeated fields, the API type uses []T, while the storage type
+ // uses *[]T.
+ //
+ // The reason for the divergence is so that the storage type more naturally
+ // matches what is expected of when retrieving the values through the
+ // protobuf reflection APIs.
+ //
+ // The value may only be populated if desc is also populated.
+ value interface{}
+
+ // enc is the raw bytes for the extension field.
+ enc []byte
+}
+
+// SetRawExtension is for testing only.
+func SetRawExtension(base Message, id int32, b []byte) {
+ epb, err := extendable(base)
+ if err != nil {
+ return
+ }
+ extmap := epb.extensionsWrite()
+ extmap[id] = Extension{enc: b}
+}
+
+// isExtensionField returns true iff the given field number is in an extension range.
+func isExtensionField(pb extendableProto, field int32) bool {
+ for _, er := range pb.ExtensionRangeArray() {
+ if er.Start <= field && field <= er.End {
+ return true
+ }
+ }
+ return false
+}
+
+// checkExtensionTypes checks that the given extension is valid for pb.
+func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error {
+ var pbi interface{} = pb
+ // Check the extended type.
+ if ea, ok := pbi.(extensionAdapter); ok {
+ pbi = ea.extendableProtoV1
+ }
+ if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {
+ return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a)
+ }
+ // Check the range.
+ if !isExtensionField(pb, extension.Field) {
+ return errors.New("proto: bad extension number; not in declared ranges")
+ }
+ return nil
+}
+
+// extPropKey is sufficient to uniquely identify an extension.
+type extPropKey struct {
+ base reflect.Type
+ field int32
+}
+
+var extProp = struct {
+ sync.RWMutex
+ m map[extPropKey]*Properties
+}{
+ m: make(map[extPropKey]*Properties),
+}
+
+func extensionProperties(ed *ExtensionDesc) *Properties {
+ key := extPropKey{base: reflect.TypeOf(ed.ExtendedType), field: ed.Field}
+
+ extProp.RLock()
+ if prop, ok := extProp.m[key]; ok {
+ extProp.RUnlock()
+ return prop
+ }
+ extProp.RUnlock()
+
+ extProp.Lock()
+ defer extProp.Unlock()
+ // Check again.
+ if prop, ok := extProp.m[key]; ok {
+ return prop
+ }
+
+ prop := new(Properties)
+ prop.Init(reflect.TypeOf(ed.ExtensionType), "unknown_name", ed.Tag, nil)
+ extProp.m[key] = prop
+ return prop
+}
+
+// HasExtension returns whether the given extension is present in pb.
+func HasExtension(pb Message, extension *ExtensionDesc) bool {
+ // TODO: Check types, field numbers, etc.?
+ epb, err := extendable(pb)
+ if err != nil {
+ return false
+ }
+ extmap, mu := epb.extensionsRead()
+ if extmap == nil {
+ return false
+ }
+ mu.Lock()
+ _, ok := extmap[extension.Field]
+ mu.Unlock()
+ return ok
+}
+
+// ClearExtension removes the given extension from pb.
+func ClearExtension(pb Message, extension *ExtensionDesc) {
+ epb, err := extendable(pb)
+ if err != nil {
+ return
+ }
+ // TODO: Check types, field numbers, etc.?
+ extmap := epb.extensionsWrite()
+ delete(extmap, extension.Field)
+}
+
+// GetExtension retrieves a proto2 extended field from pb.
+//
+// If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil),
+// then GetExtension parses the encoded field and returns a Go value of the specified type.
+// If the field is not present, then the default value is returned (if one is specified),
+// otherwise ErrMissingExtension is reported.
+//
+// If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil),
+// then GetExtension returns the raw encoded bytes of the field extension.
+func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
+ epb, err := extendable(pb)
+ if err != nil {
+ return nil, err
+ }
+
+ if extension.ExtendedType != nil {
+ // can only check type if this is a complete descriptor
+ if err := checkExtensionTypes(epb, extension); err != nil {
+ return nil, err
+ }
+ }
+
+ emap, mu := epb.extensionsRead()
+ if emap == nil {
+ return defaultExtensionValue(extension)
+ }
+ mu.Lock()
+ defer mu.Unlock()
+ e, ok := emap[extension.Field]
+ if !ok {
+ // defaultExtensionValue returns the default value or
+ // ErrMissingExtension if there is no default.
+ return defaultExtensionValue(extension)
+ }
+
+ if e.value != nil {
+ // Already decoded. Check the descriptor, though.
+ if e.desc != extension {
+ // This shouldn't happen. If it does, it means that
+ // GetExtension was called twice with two different
+ // descriptors with the same field number.
+ return nil, errors.New("proto: descriptor conflict")
+ }
+ return extensionAsLegacyType(e.value), nil
+ }
+
+ if extension.ExtensionType == nil {
+ // incomplete descriptor
+ return e.enc, nil
+ }
+
+ v, err := decodeExtension(e.enc, extension)
+ if err != nil {
+ return nil, err
+ }
+
+ // Remember the decoded version and drop the encoded version.
+ // That way it is safe to mutate what we return.
+ e.value = extensionAsStorageType(v)
+ e.desc = extension
+ e.enc = nil
+ emap[extension.Field] = e
+ return extensionAsLegacyType(e.value), nil
+}
+
+// defaultExtensionValue returns the default value for extension.
+// If no default for an extension is defined ErrMissingExtension is returned.
+func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
+ if extension.ExtensionType == nil {
+ // incomplete descriptor, so no default
+ return nil, ErrMissingExtension
+ }
+
+ t := reflect.TypeOf(extension.ExtensionType)
+ props := extensionProperties(extension)
+
+ sf, _, err := fieldDefault(t, props)
+ if err != nil {
+ return nil, err
+ }
+
+ if sf == nil || sf.value == nil {
+ // There is no default value.
+ return nil, ErrMissingExtension
+ }
+
+ if t.Kind() != reflect.Ptr {
+ // We do not need to return a Ptr, we can directly return sf.value.
+ return sf.value, nil
+ }
+
+ // We need to return an interface{} that is a pointer to sf.value.
+ value := reflect.New(t).Elem()
+ value.Set(reflect.New(value.Type().Elem()))
+ if sf.kind == reflect.Int32 {
+ // We may have an int32 or an enum, but the underlying data is int32.
+ // Since we can't set an int32 into a non int32 reflect.value directly
+ // set it as a int32.
+ value.Elem().SetInt(int64(sf.value.(int32)))
+ } else {
+ value.Elem().Set(reflect.ValueOf(sf.value))
+ }
+ return value.Interface(), nil
+}
+
+// decodeExtension decodes an extension encoded in b.
+func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
+ t := reflect.TypeOf(extension.ExtensionType)
+ unmarshal := typeUnmarshaler(t, extension.Tag)
+
+ // t is a pointer to a struct, pointer to basic type or a slice.
+ // Allocate space to store the pointer/slice.
+ value := reflect.New(t).Elem()
+
+ var err error
+ for {
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ wire := int(x) & 7
+
+ b, err = unmarshal(b, valToPointer(value.Addr()), wire)
+ if err != nil {
+ return nil, err
+ }
+
+ if len(b) == 0 {
+ break
+ }
+ }
+ return value.Interface(), nil
+}
+
+// GetExtensions returns a slice of the extensions present in pb that are also listed in es.
+// The returned slice has the same length as es; missing extensions will appear as nil elements.
+func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {
+ epb, err := extendable(pb)
+ if err != nil {
+ return nil, err
+ }
+ extensions = make([]interface{}, len(es))
+ for i, e := range es {
+ extensions[i], err = GetExtension(epb, e)
+ if err == ErrMissingExtension {
+ err = nil
+ }
+ if err != nil {
+ return
+ }
+ }
+ return
+}
+
+// ExtensionDescs returns a new slice containing pb's extension descriptors, in undefined order.
+// For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing
+// just the Field field, which defines the extension's field number.
+func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
+ epb, err := extendable(pb)
+ if err != nil {
+ return nil, err
+ }
+ registeredExtensions := RegisteredExtensions(pb)
+
+ emap, mu := epb.extensionsRead()
+ if emap == nil {
+ return nil, nil
+ }
+ mu.Lock()
+ defer mu.Unlock()
+ extensions := make([]*ExtensionDesc, 0, len(emap))
+ for extid, e := range emap {
+ desc := e.desc
+ if desc == nil {
+ desc = registeredExtensions[extid]
+ if desc == nil {
+ desc = &ExtensionDesc{Field: extid}
+ }
+ }
+
+ extensions = append(extensions, desc)
+ }
+ return extensions, nil
+}
+
+// SetExtension sets the specified extension of pb to the specified value.
+func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error {
+ epb, err := extendable(pb)
+ if err != nil {
+ return err
+ }
+ if err := checkExtensionTypes(epb, extension); err != nil {
+ return err
+ }
+ typ := reflect.TypeOf(extension.ExtensionType)
+ if typ != reflect.TypeOf(value) {
+ return fmt.Errorf("proto: bad extension value type. got: %T, want: %T", value, extension.ExtensionType)
+ }
+ // nil extension values need to be caught early, because the
+ // encoder can't distinguish an ErrNil due to a nil extension
+ // from an ErrNil due to a missing field. Extensions are
+ // always optional, so the encoder would just swallow the error
+ // and drop all the extensions from the encoded message.
+ if reflect.ValueOf(value).IsNil() {
+ return fmt.Errorf("proto: SetExtension called with nil value of type %T", value)
+ }
+
+ extmap := epb.extensionsWrite()
+ extmap[extension.Field] = Extension{desc: extension, value: extensionAsStorageType(value)}
+ return nil
+}
+
+// ClearAllExtensions clears all extensions from pb.
+func ClearAllExtensions(pb Message) {
+ epb, err := extendable(pb)
+ if err != nil {
+ return
+ }
+ m := epb.extensionsWrite()
+ for k := range m {
+ delete(m, k)
+ }
+}
+
+// A global registry of extensions.
+// The generated code will register the generated descriptors by calling RegisterExtension.
+
+var extensionMaps = make(map[reflect.Type]map[int32]*ExtensionDesc)
+
+// RegisterExtension is called from the generated code.
+func RegisterExtension(desc *ExtensionDesc) {
+ st := reflect.TypeOf(desc.ExtendedType).Elem()
+ m := extensionMaps[st]
+ if m == nil {
+ m = make(map[int32]*ExtensionDesc)
+ extensionMaps[st] = m
+ }
+ if _, ok := m[desc.Field]; ok {
+ panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(desc.Field)))
+ }
+ m[desc.Field] = desc
+}
+
+// RegisteredExtensions returns a map of the registered extensions of a
+// protocol buffer struct, indexed by the extension number.
+// The argument pb should be a nil pointer to the struct type.
+func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc {
+ return extensionMaps[reflect.TypeOf(pb).Elem()]
+}
+
+// extensionAsLegacyType converts an value in the storage type as the API type.
+// See Extension.value.
+func extensionAsLegacyType(v interface{}) interface{} {
+ switch rv := reflect.ValueOf(v); rv.Kind() {
+ case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String:
+ // Represent primitive types as a pointer to the value.
+ rv2 := reflect.New(rv.Type())
+ rv2.Elem().Set(rv)
+ v = rv2.Interface()
+ case reflect.Ptr:
+ // Represent slice types as the value itself.
+ switch rv.Type().Elem().Kind() {
+ case reflect.Slice:
+ if rv.IsNil() {
+ v = reflect.Zero(rv.Type().Elem()).Interface()
+ } else {
+ v = rv.Elem().Interface()
+ }
+ }
+ }
+ return v
+}
+
+// extensionAsStorageType converts an value in the API type as the storage type.
+// See Extension.value.
+func extensionAsStorageType(v interface{}) interface{} {
+ switch rv := reflect.ValueOf(v); rv.Kind() {
+ case reflect.Ptr:
+ // Represent slice types as the value itself.
+ switch rv.Type().Elem().Kind() {
+ case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String:
+ if rv.IsNil() {
+ v = reflect.Zero(rv.Type().Elem()).Interface()
+ } else {
+ v = rv.Elem().Interface()
+ }
+ }
+ case reflect.Slice:
+ // Represent slice types as a pointer to the value.
+ if rv.Type().Elem().Kind() != reflect.Uint8 {
+ rv2 := reflect.New(rv.Type())
+ rv2.Elem().Set(rv)
+ v = rv2.Interface()
+ }
+ }
+ return v
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/lib.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/lib.go
new file mode 100644
index 00000000..fdd328bb
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/lib.go
@@ -0,0 +1,965 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/*
+Package proto converts data structures to and from the wire format of
+protocol buffers. It works in concert with the Go source code generated
+for .proto files by the protocol compiler.
+
+A summary of the properties of the protocol buffer interface
+for a protocol buffer variable v:
+
+ - Names are turned from camel_case to CamelCase for export.
+ - There are no methods on v to set fields; just treat
+ them as structure fields.
+ - There are getters that return a field's value if set,
+ and return the field's default value if unset.
+ The getters work even if the receiver is a nil message.
+ - The zero value for a struct is its correct initialization state.
+ All desired fields must be set before marshaling.
+ - A Reset() method will restore a protobuf struct to its zero state.
+ - Non-repeated fields are pointers to the values; nil means unset.
+ That is, optional or required field int32 f becomes F *int32.
+ - Repeated fields are slices.
+ - Helper functions are available to aid the setting of fields.
+ msg.Foo = proto.String("hello") // set field
+ - Constants are defined to hold the default values of all fields that
+ have them. They have the form Default_StructName_FieldName.
+ Because the getter methods handle defaulted values,
+ direct use of these constants should be rare.
+ - Enums are given type names and maps from names to values.
+ Enum values are prefixed by the enclosing message's name, or by the
+ enum's type name if it is a top-level enum. Enum types have a String
+ method, and a Enum method to assist in message construction.
+ - Nested messages, groups and enums have type names prefixed with the name of
+ the surrounding message type.
+ - Extensions are given descriptor names that start with E_,
+ followed by an underscore-delimited list of the nested messages
+ that contain it (if any) followed by the CamelCased name of the
+ extension field itself. HasExtension, ClearExtension, GetExtension
+ and SetExtension are functions for manipulating extensions.
+ - Oneof field sets are given a single field in their message,
+ with distinguished wrapper types for each possible field value.
+ - Marshal and Unmarshal are functions to encode and decode the wire format.
+
+When the .proto file specifies `syntax="proto3"`, there are some differences:
+
+ - Non-repeated fields of non-message type are values instead of pointers.
+ - Enum types do not get an Enum method.
+
+The simplest way to describe this is to see an example.
+Given file test.proto, containing
+
+ package example;
+
+ enum FOO { X = 17; }
+
+ message Test {
+ required string label = 1;
+ optional int32 type = 2 [default=77];
+ repeated int64 reps = 3;
+ optional group OptionalGroup = 4 {
+ required string RequiredField = 5;
+ }
+ oneof union {
+ int32 number = 6;
+ string name = 7;
+ }
+ }
+
+The resulting file, test.pb.go, is:
+
+ package example
+
+ import proto "github.com/golang/protobuf/proto"
+ import math "math"
+
+ type FOO int32
+ const (
+ FOO_X FOO = 17
+ )
+ var FOO_name = map[int32]string{
+ 17: "X",
+ }
+ var FOO_value = map[string]int32{
+ "X": 17,
+ }
+
+ func (x FOO) Enum() *FOO {
+ p := new(FOO)
+ *p = x
+ return p
+ }
+ func (x FOO) String() string {
+ return proto.EnumName(FOO_name, int32(x))
+ }
+ func (x *FOO) UnmarshalJSON(data []byte) error {
+ value, err := proto.UnmarshalJSONEnum(FOO_value, data)
+ if err != nil {
+ return err
+ }
+ *x = FOO(value)
+ return nil
+ }
+
+ type Test struct {
+ Label *string `protobuf:"bytes,1,req,name=label" json:"label,omitempty"`
+ Type *int32 `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"`
+ Reps []int64 `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"`
+ Optionalgroup *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup" json:"optionalgroup,omitempty"`
+ // Types that are valid to be assigned to Union:
+ // *Test_Number
+ // *Test_Name
+ Union isTest_Union `protobuf_oneof:"union"`
+ XXX_unrecognized []byte `json:"-"`
+ }
+ func (m *Test) Reset() { *m = Test{} }
+ func (m *Test) String() string { return proto.CompactTextString(m) }
+ func (*Test) ProtoMessage() {}
+
+ type isTest_Union interface {
+ isTest_Union()
+ }
+
+ type Test_Number struct {
+ Number int32 `protobuf:"varint,6,opt,name=number"`
+ }
+ type Test_Name struct {
+ Name string `protobuf:"bytes,7,opt,name=name"`
+ }
+
+ func (*Test_Number) isTest_Union() {}
+ func (*Test_Name) isTest_Union() {}
+
+ func (m *Test) GetUnion() isTest_Union {
+ if m != nil {
+ return m.Union
+ }
+ return nil
+ }
+ const Default_Test_Type int32 = 77
+
+ func (m *Test) GetLabel() string {
+ if m != nil && m.Label != nil {
+ return *m.Label
+ }
+ return ""
+ }
+
+ func (m *Test) GetType() int32 {
+ if m != nil && m.Type != nil {
+ return *m.Type
+ }
+ return Default_Test_Type
+ }
+
+ func (m *Test) GetOptionalgroup() *Test_OptionalGroup {
+ if m != nil {
+ return m.Optionalgroup
+ }
+ return nil
+ }
+
+ type Test_OptionalGroup struct {
+ RequiredField *string `protobuf:"bytes,5,req" json:"RequiredField,omitempty"`
+ }
+ func (m *Test_OptionalGroup) Reset() { *m = Test_OptionalGroup{} }
+ func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) }
+
+ func (m *Test_OptionalGroup) GetRequiredField() string {
+ if m != nil && m.RequiredField != nil {
+ return *m.RequiredField
+ }
+ return ""
+ }
+
+ func (m *Test) GetNumber() int32 {
+ if x, ok := m.GetUnion().(*Test_Number); ok {
+ return x.Number
+ }
+ return 0
+ }
+
+ func (m *Test) GetName() string {
+ if x, ok := m.GetUnion().(*Test_Name); ok {
+ return x.Name
+ }
+ return ""
+ }
+
+ func init() {
+ proto.RegisterEnum("example.FOO", FOO_name, FOO_value)
+ }
+
+To create and play with a Test object:
+
+ package main
+
+ import (
+ "log"
+
+ "github.com/golang/protobuf/proto"
+ pb "./example.pb"
+ )
+
+ func main() {
+ test := &pb.Test{
+ Label: proto.String("hello"),
+ Type: proto.Int32(17),
+ Reps: []int64{1, 2, 3},
+ Optionalgroup: &pb.Test_OptionalGroup{
+ RequiredField: proto.String("good bye"),
+ },
+ Union: &pb.Test_Name{"fred"},
+ }
+ data, err := proto.Marshal(test)
+ if err != nil {
+ log.Fatal("marshaling error: ", err)
+ }
+ newTest := &pb.Test{}
+ err = proto.Unmarshal(data, newTest)
+ if err != nil {
+ log.Fatal("unmarshaling error: ", err)
+ }
+ // Now test and newTest contain the same data.
+ if test.GetLabel() != newTest.GetLabel() {
+ log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel())
+ }
+ // Use a type switch to determine which oneof was set.
+ switch u := test.Union.(type) {
+ case *pb.Test_Number: // u.Number contains the number.
+ case *pb.Test_Name: // u.Name contains the string.
+ }
+ // etc.
+ }
+*/
+package proto
+
+import (
+ "encoding/json"
+ "fmt"
+ "log"
+ "reflect"
+ "sort"
+ "strconv"
+ "sync"
+)
+
+// RequiredNotSetError is an error type returned by either Marshal or Unmarshal.
+// Marshal reports this when a required field is not initialized.
+// Unmarshal reports this when a required field is missing from the wire data.
+type RequiredNotSetError struct{ field string }
+
+func (e *RequiredNotSetError) Error() string {
+ if e.field == "" {
+ return fmt.Sprintf("proto: required field not set")
+ }
+ return fmt.Sprintf("proto: required field %q not set", e.field)
+}
+func (e *RequiredNotSetError) RequiredNotSet() bool {
+ return true
+}
+
+type invalidUTF8Error struct{ field string }
+
+func (e *invalidUTF8Error) Error() string {
+ if e.field == "" {
+ return "proto: invalid UTF-8 detected"
+ }
+ return fmt.Sprintf("proto: field %q contains invalid UTF-8", e.field)
+}
+func (e *invalidUTF8Error) InvalidUTF8() bool {
+ return true
+}
+
+// errInvalidUTF8 is a sentinel error to identify fields with invalid UTF-8.
+// This error should not be exposed to the external API as such errors should
+// be recreated with the field information.
+var errInvalidUTF8 = &invalidUTF8Error{}
+
+// isNonFatal reports whether the error is either a RequiredNotSet error
+// or a InvalidUTF8 error.
+func isNonFatal(err error) bool {
+ if re, ok := err.(interface{ RequiredNotSet() bool }); ok && re.RequiredNotSet() {
+ return true
+ }
+ if re, ok := err.(interface{ InvalidUTF8() bool }); ok && re.InvalidUTF8() {
+ return true
+ }
+ return false
+}
+
+type nonFatal struct{ E error }
+
+// Merge merges err into nf and reports whether it was successful.
+// Otherwise it returns false for any fatal non-nil errors.
+func (nf *nonFatal) Merge(err error) (ok bool) {
+ if err == nil {
+ return true // not an error
+ }
+ if !isNonFatal(err) {
+ return false // fatal error
+ }
+ if nf.E == nil {
+ nf.E = err // store first instance of non-fatal error
+ }
+ return true
+}
+
+// Message is implemented by generated protocol buffer messages.
+type Message interface {
+ Reset()
+ String() string
+ ProtoMessage()
+}
+
+// A Buffer is a buffer manager for marshaling and unmarshaling
+// protocol buffers. It may be reused between invocations to
+// reduce memory usage. It is not necessary to use a Buffer;
+// the global functions Marshal and Unmarshal create a
+// temporary Buffer and are fine for most applications.
+type Buffer struct {
+ buf []byte // encode/decode byte stream
+ index int // read point
+
+ deterministic bool
+}
+
+// NewBuffer allocates a new Buffer and initializes its internal data to
+// the contents of the argument slice.
+func NewBuffer(e []byte) *Buffer {
+ return &Buffer{buf: e}
+}
+
+// Reset resets the Buffer, ready for marshaling a new protocol buffer.
+func (p *Buffer) Reset() {
+ p.buf = p.buf[0:0] // for reading/writing
+ p.index = 0 // for reading
+}
+
+// SetBuf replaces the internal buffer with the slice,
+// ready for unmarshaling the contents of the slice.
+func (p *Buffer) SetBuf(s []byte) {
+ p.buf = s
+ p.index = 0
+}
+
+// Bytes returns the contents of the Buffer.
+func (p *Buffer) Bytes() []byte { return p.buf }
+
+// SetDeterministic sets whether to use deterministic serialization.
+//
+// Deterministic serialization guarantees that for a given binary, equal
+// messages will always be serialized to the same bytes. This implies:
+//
+// - Repeated serialization of a message will return the same bytes.
+// - Different processes of the same binary (which may be executing on
+// different machines) will serialize equal messages to the same bytes.
+//
+// Note that the deterministic serialization is NOT canonical across
+// languages. It is not guaranteed to remain stable over time. It is unstable
+// across different builds with schema changes due to unknown fields.
+// Users who need canonical serialization (e.g., persistent storage in a
+// canonical form, fingerprinting, etc.) should define their own
+// canonicalization specification and implement their own serializer rather
+// than relying on this API.
+//
+// If deterministic serialization is requested, map entries will be sorted
+// by keys in lexographical order. This is an implementation detail and
+// subject to change.
+func (p *Buffer) SetDeterministic(deterministic bool) {
+ p.deterministic = deterministic
+}
+
+/*
+ * Helper routines for simplifying the creation of optional fields of basic type.
+ */
+
+// Bool is a helper routine that allocates a new bool value
+// to store v and returns a pointer to it.
+func Bool(v bool) *bool {
+ return &v
+}
+
+// Int32 is a helper routine that allocates a new int32 value
+// to store v and returns a pointer to it.
+func Int32(v int32) *int32 {
+ return &v
+}
+
+// Int is a helper routine that allocates a new int32 value
+// to store v and returns a pointer to it, but unlike Int32
+// its argument value is an int.
+func Int(v int) *int32 {
+ p := new(int32)
+ *p = int32(v)
+ return p
+}
+
+// Int64 is a helper routine that allocates a new int64 value
+// to store v and returns a pointer to it.
+func Int64(v int64) *int64 {
+ return &v
+}
+
+// Float32 is a helper routine that allocates a new float32 value
+// to store v and returns a pointer to it.
+func Float32(v float32) *float32 {
+ return &v
+}
+
+// Float64 is a helper routine that allocates a new float64 value
+// to store v and returns a pointer to it.
+func Float64(v float64) *float64 {
+ return &v
+}
+
+// Uint32 is a helper routine that allocates a new uint32 value
+// to store v and returns a pointer to it.
+func Uint32(v uint32) *uint32 {
+ return &v
+}
+
+// Uint64 is a helper routine that allocates a new uint64 value
+// to store v and returns a pointer to it.
+func Uint64(v uint64) *uint64 {
+ return &v
+}
+
+// String is a helper routine that allocates a new string value
+// to store v and returns a pointer to it.
+func String(v string) *string {
+ return &v
+}
+
+// EnumName is a helper function to simplify printing protocol buffer enums
+// by name. Given an enum map and a value, it returns a useful string.
+func EnumName(m map[int32]string, v int32) string {
+ s, ok := m[v]
+ if ok {
+ return s
+ }
+ return strconv.Itoa(int(v))
+}
+
+// UnmarshalJSONEnum is a helper function to simplify recovering enum int values
+// from their JSON-encoded representation. Given a map from the enum's symbolic
+// names to its int values, and a byte buffer containing the JSON-encoded
+// value, it returns an int32 that can be cast to the enum type by the caller.
+//
+// The function can deal with both JSON representations, numeric and symbolic.
+func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) {
+ if data[0] == '"' {
+ // New style: enums are strings.
+ var repr string
+ if err := json.Unmarshal(data, &repr); err != nil {
+ return -1, err
+ }
+ val, ok := m[repr]
+ if !ok {
+ return 0, fmt.Errorf("unrecognized enum %s value %q", enumName, repr)
+ }
+ return val, nil
+ }
+ // Old style: enums are ints.
+ var val int32
+ if err := json.Unmarshal(data, &val); err != nil {
+ return 0, fmt.Errorf("cannot unmarshal %#q into enum %s", data, enumName)
+ }
+ return val, nil
+}
+
+// DebugPrint dumps the encoded data in b in a debugging format with a header
+// including the string s. Used in testing but made available for general debugging.
+func (p *Buffer) DebugPrint(s string, b []byte) {
+ var u uint64
+
+ obuf := p.buf
+ index := p.index
+ p.buf = b
+ p.index = 0
+ depth := 0
+
+ fmt.Printf("\n--- %s ---\n", s)
+
+out:
+ for {
+ for i := 0; i < depth; i++ {
+ fmt.Print(" ")
+ }
+
+ index := p.index
+ if index == len(p.buf) {
+ break
+ }
+
+ op, err := p.DecodeVarint()
+ if err != nil {
+ fmt.Printf("%3d: fetching op err %v\n", index, err)
+ break out
+ }
+ tag := op >> 3
+ wire := op & 7
+
+ switch wire {
+ default:
+ fmt.Printf("%3d: t=%3d unknown wire=%d\n",
+ index, tag, wire)
+ break out
+
+ case WireBytes:
+ var r []byte
+
+ r, err = p.DecodeRawBytes(false)
+ if err != nil {
+ break out
+ }
+ fmt.Printf("%3d: t=%3d bytes [%d]", index, tag, len(r))
+ if len(r) <= 6 {
+ for i := 0; i < len(r); i++ {
+ fmt.Printf(" %.2x", r[i])
+ }
+ } else {
+ for i := 0; i < 3; i++ {
+ fmt.Printf(" %.2x", r[i])
+ }
+ fmt.Printf(" ..")
+ for i := len(r) - 3; i < len(r); i++ {
+ fmt.Printf(" %.2x", r[i])
+ }
+ }
+ fmt.Printf("\n")
+
+ case WireFixed32:
+ u, err = p.DecodeFixed32()
+ if err != nil {
+ fmt.Printf("%3d: t=%3d fix32 err %v\n", index, tag, err)
+ break out
+ }
+ fmt.Printf("%3d: t=%3d fix32 %d\n", index, tag, u)
+
+ case WireFixed64:
+ u, err = p.DecodeFixed64()
+ if err != nil {
+ fmt.Printf("%3d: t=%3d fix64 err %v\n", index, tag, err)
+ break out
+ }
+ fmt.Printf("%3d: t=%3d fix64 %d\n", index, tag, u)
+
+ case WireVarint:
+ u, err = p.DecodeVarint()
+ if err != nil {
+ fmt.Printf("%3d: t=%3d varint err %v\n", index, tag, err)
+ break out
+ }
+ fmt.Printf("%3d: t=%3d varint %d\n", index, tag, u)
+
+ case WireStartGroup:
+ fmt.Printf("%3d: t=%3d start\n", index, tag)
+ depth++
+
+ case WireEndGroup:
+ depth--
+ fmt.Printf("%3d: t=%3d end\n", index, tag)
+ }
+ }
+
+ if depth != 0 {
+ fmt.Printf("%3d: start-end not balanced %d\n", p.index, depth)
+ }
+ fmt.Printf("\n")
+
+ p.buf = obuf
+ p.index = index
+}
+
+// SetDefaults sets unset protocol buffer fields to their default values.
+// It only modifies fields that are both unset and have defined defaults.
+// It recursively sets default values in any non-nil sub-messages.
+func SetDefaults(pb Message) {
+ setDefaults(reflect.ValueOf(pb), true, false)
+}
+
+// v is a pointer to a struct.
+func setDefaults(v reflect.Value, recur, zeros bool) {
+ v = v.Elem()
+
+ defaultMu.RLock()
+ dm, ok := defaults[v.Type()]
+ defaultMu.RUnlock()
+ if !ok {
+ dm = buildDefaultMessage(v.Type())
+ defaultMu.Lock()
+ defaults[v.Type()] = dm
+ defaultMu.Unlock()
+ }
+
+ for _, sf := range dm.scalars {
+ f := v.Field(sf.index)
+ if !f.IsNil() {
+ // field already set
+ continue
+ }
+ dv := sf.value
+ if dv == nil && !zeros {
+ // no explicit default, and don't want to set zeros
+ continue
+ }
+ fptr := f.Addr().Interface() // **T
+ // TODO: Consider batching the allocations we do here.
+ switch sf.kind {
+ case reflect.Bool:
+ b := new(bool)
+ if dv != nil {
+ *b = dv.(bool)
+ }
+ *(fptr.(**bool)) = b
+ case reflect.Float32:
+ f := new(float32)
+ if dv != nil {
+ *f = dv.(float32)
+ }
+ *(fptr.(**float32)) = f
+ case reflect.Float64:
+ f := new(float64)
+ if dv != nil {
+ *f = dv.(float64)
+ }
+ *(fptr.(**float64)) = f
+ case reflect.Int32:
+ // might be an enum
+ if ft := f.Type(); ft != int32PtrType {
+ // enum
+ f.Set(reflect.New(ft.Elem()))
+ if dv != nil {
+ f.Elem().SetInt(int64(dv.(int32)))
+ }
+ } else {
+ // int32 field
+ i := new(int32)
+ if dv != nil {
+ *i = dv.(int32)
+ }
+ *(fptr.(**int32)) = i
+ }
+ case reflect.Int64:
+ i := new(int64)
+ if dv != nil {
+ *i = dv.(int64)
+ }
+ *(fptr.(**int64)) = i
+ case reflect.String:
+ s := new(string)
+ if dv != nil {
+ *s = dv.(string)
+ }
+ *(fptr.(**string)) = s
+ case reflect.Uint8:
+ // exceptional case: []byte
+ var b []byte
+ if dv != nil {
+ db := dv.([]byte)
+ b = make([]byte, len(db))
+ copy(b, db)
+ } else {
+ b = []byte{}
+ }
+ *(fptr.(*[]byte)) = b
+ case reflect.Uint32:
+ u := new(uint32)
+ if dv != nil {
+ *u = dv.(uint32)
+ }
+ *(fptr.(**uint32)) = u
+ case reflect.Uint64:
+ u := new(uint64)
+ if dv != nil {
+ *u = dv.(uint64)
+ }
+ *(fptr.(**uint64)) = u
+ default:
+ log.Printf("proto: can't set default for field %v (sf.kind=%v)", f, sf.kind)
+ }
+ }
+
+ for _, ni := range dm.nested {
+ f := v.Field(ni)
+ // f is *T or []*T or map[T]*T
+ switch f.Kind() {
+ case reflect.Ptr:
+ if f.IsNil() {
+ continue
+ }
+ setDefaults(f, recur, zeros)
+
+ case reflect.Slice:
+ for i := 0; i < f.Len(); i++ {
+ e := f.Index(i)
+ if e.IsNil() {
+ continue
+ }
+ setDefaults(e, recur, zeros)
+ }
+
+ case reflect.Map:
+ for _, k := range f.MapKeys() {
+ e := f.MapIndex(k)
+ if e.IsNil() {
+ continue
+ }
+ setDefaults(e, recur, zeros)
+ }
+ }
+ }
+}
+
+var (
+ // defaults maps a protocol buffer struct type to a slice of the fields,
+ // with its scalar fields set to their proto-declared non-zero default values.
+ defaultMu sync.RWMutex
+ defaults = make(map[reflect.Type]defaultMessage)
+
+ int32PtrType = reflect.TypeOf((*int32)(nil))
+)
+
+// defaultMessage represents information about the default values of a message.
+type defaultMessage struct {
+ scalars []scalarField
+ nested []int // struct field index of nested messages
+}
+
+type scalarField struct {
+ index int // struct field index
+ kind reflect.Kind // element type (the T in *T or []T)
+ value interface{} // the proto-declared default value, or nil
+}
+
+// t is a struct type.
+func buildDefaultMessage(t reflect.Type) (dm defaultMessage) {
+ sprop := GetProperties(t)
+ for _, prop := range sprop.Prop {
+ fi, ok := sprop.decoderTags.get(prop.Tag)
+ if !ok {
+ // XXX_unrecognized
+ continue
+ }
+ ft := t.Field(fi).Type
+
+ sf, nested, err := fieldDefault(ft, prop)
+ switch {
+ case err != nil:
+ log.Print(err)
+ case nested:
+ dm.nested = append(dm.nested, fi)
+ case sf != nil:
+ sf.index = fi
+ dm.scalars = append(dm.scalars, *sf)
+ }
+ }
+
+ return dm
+}
+
+// fieldDefault returns the scalarField for field type ft.
+// sf will be nil if the field can not have a default.
+// nestedMessage will be true if this is a nested message.
+// Note that sf.index is not set on return.
+func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) {
+ var canHaveDefault bool
+ switch ft.Kind() {
+ case reflect.Ptr:
+ if ft.Elem().Kind() == reflect.Struct {
+ nestedMessage = true
+ } else {
+ canHaveDefault = true // proto2 scalar field
+ }
+
+ case reflect.Slice:
+ switch ft.Elem().Kind() {
+ case reflect.Ptr:
+ nestedMessage = true // repeated message
+ case reflect.Uint8:
+ canHaveDefault = true // bytes field
+ }
+
+ case reflect.Map:
+ if ft.Elem().Kind() == reflect.Ptr {
+ nestedMessage = true // map with message values
+ }
+ }
+
+ if !canHaveDefault {
+ if nestedMessage {
+ return nil, true, nil
+ }
+ return nil, false, nil
+ }
+
+ // We now know that ft is a pointer or slice.
+ sf = &scalarField{kind: ft.Elem().Kind()}
+
+ // scalar fields without defaults
+ if !prop.HasDefault {
+ return sf, false, nil
+ }
+
+ // a scalar field: either *T or []byte
+ switch ft.Elem().Kind() {
+ case reflect.Bool:
+ x, err := strconv.ParseBool(prop.Default)
+ if err != nil {
+ return nil, false, fmt.Errorf("proto: bad default bool %q: %v", prop.Default, err)
+ }
+ sf.value = x
+ case reflect.Float32:
+ x, err := strconv.ParseFloat(prop.Default, 32)
+ if err != nil {
+ return nil, false, fmt.Errorf("proto: bad default float32 %q: %v", prop.Default, err)
+ }
+ sf.value = float32(x)
+ case reflect.Float64:
+ x, err := strconv.ParseFloat(prop.Default, 64)
+ if err != nil {
+ return nil, false, fmt.Errorf("proto: bad default float64 %q: %v", prop.Default, err)
+ }
+ sf.value = x
+ case reflect.Int32:
+ x, err := strconv.ParseInt(prop.Default, 10, 32)
+ if err != nil {
+ return nil, false, fmt.Errorf("proto: bad default int32 %q: %v", prop.Default, err)
+ }
+ sf.value = int32(x)
+ case reflect.Int64:
+ x, err := strconv.ParseInt(prop.Default, 10, 64)
+ if err != nil {
+ return nil, false, fmt.Errorf("proto: bad default int64 %q: %v", prop.Default, err)
+ }
+ sf.value = x
+ case reflect.String:
+ sf.value = prop.Default
+ case reflect.Uint8:
+ // []byte (not *uint8)
+ sf.value = []byte(prop.Default)
+ case reflect.Uint32:
+ x, err := strconv.ParseUint(prop.Default, 10, 32)
+ if err != nil {
+ return nil, false, fmt.Errorf("proto: bad default uint32 %q: %v", prop.Default, err)
+ }
+ sf.value = uint32(x)
+ case reflect.Uint64:
+ x, err := strconv.ParseUint(prop.Default, 10, 64)
+ if err != nil {
+ return nil, false, fmt.Errorf("proto: bad default uint64 %q: %v", prop.Default, err)
+ }
+ sf.value = x
+ default:
+ return nil, false, fmt.Errorf("proto: unhandled def kind %v", ft.Elem().Kind())
+ }
+
+ return sf, false, nil
+}
+
+// mapKeys returns a sort.Interface to be used for sorting the map keys.
+// Map fields may have key types of non-float scalars, strings and enums.
+func mapKeys(vs []reflect.Value) sort.Interface {
+ s := mapKeySorter{vs: vs}
+
+ // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps.
+ if len(vs) == 0 {
+ return s
+ }
+ switch vs[0].Kind() {
+ case reflect.Int32, reflect.Int64:
+ s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() }
+ case reflect.Uint32, reflect.Uint64:
+ s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() }
+ case reflect.Bool:
+ s.less = func(a, b reflect.Value) bool { return !a.Bool() && b.Bool() } // false < true
+ case reflect.String:
+ s.less = func(a, b reflect.Value) bool { return a.String() < b.String() }
+ default:
+ panic(fmt.Sprintf("unsupported map key type: %v", vs[0].Kind()))
+ }
+
+ return s
+}
+
+type mapKeySorter struct {
+ vs []reflect.Value
+ less func(a, b reflect.Value) bool
+}
+
+func (s mapKeySorter) Len() int { return len(s.vs) }
+func (s mapKeySorter) Swap(i, j int) { s.vs[i], s.vs[j] = s.vs[j], s.vs[i] }
+func (s mapKeySorter) Less(i, j int) bool {
+ return s.less(s.vs[i], s.vs[j])
+}
+
+// isProto3Zero reports whether v is a zero proto3 value.
+func isProto3Zero(v reflect.Value) bool {
+ switch v.Kind() {
+ case reflect.Bool:
+ return !v.Bool()
+ case reflect.Int32, reflect.Int64:
+ return v.Int() == 0
+ case reflect.Uint32, reflect.Uint64:
+ return v.Uint() == 0
+ case reflect.Float32, reflect.Float64:
+ return v.Float() == 0
+ case reflect.String:
+ return v.String() == ""
+ }
+ return false
+}
+
+const (
+ // ProtoPackageIsVersion3 is referenced from generated protocol buffer files
+ // to assert that that code is compatible with this version of the proto package.
+ ProtoPackageIsVersion3 = true
+
+ // ProtoPackageIsVersion2 is referenced from generated protocol buffer files
+ // to assert that that code is compatible with this version of the proto package.
+ ProtoPackageIsVersion2 = true
+
+ // ProtoPackageIsVersion1 is referenced from generated protocol buffer files
+ // to assert that that code is compatible with this version of the proto package.
+ ProtoPackageIsVersion1 = true
+)
+
+// InternalMessageInfo is a type used internally by generated .pb.go files.
+// This type is not intended to be used by non-generated code.
+// This type is not subject to any compatibility guarantee.
+type InternalMessageInfo struct {
+ marshal *marshalInfo
+ unmarshal *unmarshalInfo
+ merge *mergeInfo
+ discard *discardInfo
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/message_set.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/message_set.go
new file mode 100644
index 00000000..f48a7567
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/message_set.go
@@ -0,0 +1,181 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+/*
+ * Support for message sets.
+ */
+
+import (
+ "errors"
+)
+
+// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID.
+// A message type ID is required for storing a protocol buffer in a message set.
+var errNoMessageTypeID = errors.New("proto does not have a message type ID")
+
+// The first two types (_MessageSet_Item and messageSet)
+// model what the protocol compiler produces for the following protocol message:
+// message MessageSet {
+// repeated group Item = 1 {
+// required int32 type_id = 2;
+// required string message = 3;
+// };
+// }
+// That is the MessageSet wire format. We can't use a proto to generate these
+// because that would introduce a circular dependency between it and this package.
+
+type _MessageSet_Item struct {
+ TypeId *int32 `protobuf:"varint,2,req,name=type_id"`
+ Message []byte `protobuf:"bytes,3,req,name=message"`
+}
+
+type messageSet struct {
+ Item []*_MessageSet_Item `protobuf:"group,1,rep"`
+ XXX_unrecognized []byte
+ // TODO: caching?
+}
+
+// Make sure messageSet is a Message.
+var _ Message = (*messageSet)(nil)
+
+// messageTypeIder is an interface satisfied by a protocol buffer type
+// that may be stored in a MessageSet.
+type messageTypeIder interface {
+ MessageTypeId() int32
+}
+
+func (ms *messageSet) find(pb Message) *_MessageSet_Item {
+ mti, ok := pb.(messageTypeIder)
+ if !ok {
+ return nil
+ }
+ id := mti.MessageTypeId()
+ for _, item := range ms.Item {
+ if *item.TypeId == id {
+ return item
+ }
+ }
+ return nil
+}
+
+func (ms *messageSet) Has(pb Message) bool {
+ return ms.find(pb) != nil
+}
+
+func (ms *messageSet) Unmarshal(pb Message) error {
+ if item := ms.find(pb); item != nil {
+ return Unmarshal(item.Message, pb)
+ }
+ if _, ok := pb.(messageTypeIder); !ok {
+ return errNoMessageTypeID
+ }
+ return nil // TODO: return error instead?
+}
+
+func (ms *messageSet) Marshal(pb Message) error {
+ msg, err := Marshal(pb)
+ if err != nil {
+ return err
+ }
+ if item := ms.find(pb); item != nil {
+ // reuse existing item
+ item.Message = msg
+ return nil
+ }
+
+ mti, ok := pb.(messageTypeIder)
+ if !ok {
+ return errNoMessageTypeID
+ }
+
+ mtid := mti.MessageTypeId()
+ ms.Item = append(ms.Item, &_MessageSet_Item{
+ TypeId: &mtid,
+ Message: msg,
+ })
+ return nil
+}
+
+func (ms *messageSet) Reset() { *ms = messageSet{} }
+func (ms *messageSet) String() string { return CompactTextString(ms) }
+func (*messageSet) ProtoMessage() {}
+
+// Support for the message_set_wire_format message option.
+
+func skipVarint(buf []byte) []byte {
+ i := 0
+ for ; buf[i]&0x80 != 0; i++ {
+ }
+ return buf[i+1:]
+}
+
+// unmarshalMessageSet decodes the extension map encoded in buf in the message set wire format.
+// It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option.
+func unmarshalMessageSet(buf []byte, exts interface{}) error {
+ var m map[int32]Extension
+ switch exts := exts.(type) {
+ case *XXX_InternalExtensions:
+ m = exts.extensionsWrite()
+ case map[int32]Extension:
+ m = exts
+ default:
+ return errors.New("proto: not an extension map")
+ }
+
+ ms := new(messageSet)
+ if err := Unmarshal(buf, ms); err != nil {
+ return err
+ }
+ for _, item := range ms.Item {
+ id := *item.TypeId
+ msg := item.Message
+
+ // Restore wire type and field number varint, plus length varint.
+ // Be careful to preserve duplicate items.
+ b := EncodeVarint(uint64(id)<<3 | WireBytes)
+ if ext, ok := m[id]; ok {
+ // Existing data; rip off the tag and length varint
+ // so we join the new data correctly.
+ // We can assume that ext.enc is set because we are unmarshaling.
+ o := ext.enc[len(b):] // skip wire type and field number
+ _, n := DecodeVarint(o) // calculate length of length varint
+ o = o[n:] // skip length varint
+ msg = append(o, msg...) // join old data and new data
+ }
+ b = append(b, EncodeVarint(uint64(len(msg)))...)
+ b = append(b, msg...)
+
+ m[id] = Extension{enc: b}
+ }
+ return nil
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/pointer_reflect.go
new file mode 100644
index 00000000..94fa9194
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/pointer_reflect.go
@@ -0,0 +1,360 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2012 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// +build purego appengine js
+
+// This file contains an implementation of proto field accesses using package reflect.
+// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
+// be used on App Engine.
+
+package proto
+
+import (
+ "reflect"
+ "sync"
+)
+
+const unsafeAllowed = false
+
+// A field identifies a field in a struct, accessible from a pointer.
+// In this implementation, a field is identified by the sequence of field indices
+// passed to reflect's FieldByIndex.
+type field []int
+
+// toField returns a field equivalent to the given reflect field.
+func toField(f *reflect.StructField) field {
+ return f.Index
+}
+
+// invalidField is an invalid field identifier.
+var invalidField = field(nil)
+
+// zeroField is a noop when calling pointer.offset.
+var zeroField = field([]int{})
+
+// IsValid reports whether the field identifier is valid.
+func (f field) IsValid() bool { return f != nil }
+
+// The pointer type is for the table-driven decoder.
+// The implementation here uses a reflect.Value of pointer type to
+// create a generic pointer. In pointer_unsafe.go we use unsafe
+// instead of reflect to implement the same (but faster) interface.
+type pointer struct {
+ v reflect.Value
+}
+
+// toPointer converts an interface of pointer type to a pointer
+// that points to the same target.
+func toPointer(i *Message) pointer {
+ return pointer{v: reflect.ValueOf(*i)}
+}
+
+// toAddrPointer converts an interface to a pointer that points to
+// the interface data.
+func toAddrPointer(i *interface{}, isptr, deref bool) pointer {
+ v := reflect.ValueOf(*i)
+ u := reflect.New(v.Type())
+ u.Elem().Set(v)
+ if deref {
+ u = u.Elem()
+ }
+ return pointer{v: u}
+}
+
+// valToPointer converts v to a pointer. v must be of pointer type.
+func valToPointer(v reflect.Value) pointer {
+ return pointer{v: v}
+}
+
+// offset converts from a pointer to a structure to a pointer to
+// one of its fields.
+func (p pointer) offset(f field) pointer {
+ return pointer{v: p.v.Elem().FieldByIndex(f).Addr()}
+}
+
+func (p pointer) isNil() bool {
+ return p.v.IsNil()
+}
+
+// grow updates the slice s in place to make it one element longer.
+// s must be addressable.
+// Returns the (addressable) new element.
+func grow(s reflect.Value) reflect.Value {
+ n, m := s.Len(), s.Cap()
+ if n < m {
+ s.SetLen(n + 1)
+ } else {
+ s.Set(reflect.Append(s, reflect.Zero(s.Type().Elem())))
+ }
+ return s.Index(n)
+}
+
+func (p pointer) toInt64() *int64 {
+ return p.v.Interface().(*int64)
+}
+func (p pointer) toInt64Ptr() **int64 {
+ return p.v.Interface().(**int64)
+}
+func (p pointer) toInt64Slice() *[]int64 {
+ return p.v.Interface().(*[]int64)
+}
+
+var int32ptr = reflect.TypeOf((*int32)(nil))
+
+func (p pointer) toInt32() *int32 {
+ return p.v.Convert(int32ptr).Interface().(*int32)
+}
+
+// The toInt32Ptr/Slice methods don't work because of enums.
+// Instead, we must use set/get methods for the int32ptr/slice case.
+/*
+ func (p pointer) toInt32Ptr() **int32 {
+ return p.v.Interface().(**int32)
+}
+ func (p pointer) toInt32Slice() *[]int32 {
+ return p.v.Interface().(*[]int32)
+}
+*/
+func (p pointer) getInt32Ptr() *int32 {
+ if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
+ // raw int32 type
+ return p.v.Elem().Interface().(*int32)
+ }
+ // an enum
+ return p.v.Elem().Convert(int32PtrType).Interface().(*int32)
+}
+func (p pointer) setInt32Ptr(v int32) {
+ // Allocate value in a *int32. Possibly convert that to a *enum.
+ // Then assign it to a **int32 or **enum.
+ // Note: we can convert *int32 to *enum, but we can't convert
+ // **int32 to **enum!
+ p.v.Elem().Set(reflect.ValueOf(&v).Convert(p.v.Type().Elem()))
+}
+
+// getInt32Slice copies []int32 from p as a new slice.
+// This behavior differs from the implementation in pointer_unsafe.go.
+func (p pointer) getInt32Slice() []int32 {
+ if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
+ // raw int32 type
+ return p.v.Elem().Interface().([]int32)
+ }
+ // an enum
+ // Allocate a []int32, then assign []enum's values into it.
+ // Note: we can't convert []enum to []int32.
+ slice := p.v.Elem()
+ s := make([]int32, slice.Len())
+ for i := 0; i < slice.Len(); i++ {
+ s[i] = int32(slice.Index(i).Int())
+ }
+ return s
+}
+
+// setInt32Slice copies []int32 into p as a new slice.
+// This behavior differs from the implementation in pointer_unsafe.go.
+func (p pointer) setInt32Slice(v []int32) {
+ if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
+ // raw int32 type
+ p.v.Elem().Set(reflect.ValueOf(v))
+ return
+ }
+ // an enum
+ // Allocate a []enum, then assign []int32's values into it.
+ // Note: we can't convert []enum to []int32.
+ slice := reflect.MakeSlice(p.v.Type().Elem(), len(v), cap(v))
+ for i, x := range v {
+ slice.Index(i).SetInt(int64(x))
+ }
+ p.v.Elem().Set(slice)
+}
+func (p pointer) appendInt32Slice(v int32) {
+ grow(p.v.Elem()).SetInt(int64(v))
+}
+
+func (p pointer) toUint64() *uint64 {
+ return p.v.Interface().(*uint64)
+}
+func (p pointer) toUint64Ptr() **uint64 {
+ return p.v.Interface().(**uint64)
+}
+func (p pointer) toUint64Slice() *[]uint64 {
+ return p.v.Interface().(*[]uint64)
+}
+func (p pointer) toUint32() *uint32 {
+ return p.v.Interface().(*uint32)
+}
+func (p pointer) toUint32Ptr() **uint32 {
+ return p.v.Interface().(**uint32)
+}
+func (p pointer) toUint32Slice() *[]uint32 {
+ return p.v.Interface().(*[]uint32)
+}
+func (p pointer) toBool() *bool {
+ return p.v.Interface().(*bool)
+}
+func (p pointer) toBoolPtr() **bool {
+ return p.v.Interface().(**bool)
+}
+func (p pointer) toBoolSlice() *[]bool {
+ return p.v.Interface().(*[]bool)
+}
+func (p pointer) toFloat64() *float64 {
+ return p.v.Interface().(*float64)
+}
+func (p pointer) toFloat64Ptr() **float64 {
+ return p.v.Interface().(**float64)
+}
+func (p pointer) toFloat64Slice() *[]float64 {
+ return p.v.Interface().(*[]float64)
+}
+func (p pointer) toFloat32() *float32 {
+ return p.v.Interface().(*float32)
+}
+func (p pointer) toFloat32Ptr() **float32 {
+ return p.v.Interface().(**float32)
+}
+func (p pointer) toFloat32Slice() *[]float32 {
+ return p.v.Interface().(*[]float32)
+}
+func (p pointer) toString() *string {
+ return p.v.Interface().(*string)
+}
+func (p pointer) toStringPtr() **string {
+ return p.v.Interface().(**string)
+}
+func (p pointer) toStringSlice() *[]string {
+ return p.v.Interface().(*[]string)
+}
+func (p pointer) toBytes() *[]byte {
+ return p.v.Interface().(*[]byte)
+}
+func (p pointer) toBytesSlice() *[][]byte {
+ return p.v.Interface().(*[][]byte)
+}
+func (p pointer) toExtensions() *XXX_InternalExtensions {
+ return p.v.Interface().(*XXX_InternalExtensions)
+}
+func (p pointer) toOldExtensions() *map[int32]Extension {
+ return p.v.Interface().(*map[int32]Extension)
+}
+func (p pointer) getPointer() pointer {
+ return pointer{v: p.v.Elem()}
+}
+func (p pointer) setPointer(q pointer) {
+ p.v.Elem().Set(q.v)
+}
+func (p pointer) appendPointer(q pointer) {
+ grow(p.v.Elem()).Set(q.v)
+}
+
+// getPointerSlice copies []*T from p as a new []pointer.
+// This behavior differs from the implementation in pointer_unsafe.go.
+func (p pointer) getPointerSlice() []pointer {
+ if p.v.IsNil() {
+ return nil
+ }
+ n := p.v.Elem().Len()
+ s := make([]pointer, n)
+ for i := 0; i < n; i++ {
+ s[i] = pointer{v: p.v.Elem().Index(i)}
+ }
+ return s
+}
+
+// setPointerSlice copies []pointer into p as a new []*T.
+// This behavior differs from the implementation in pointer_unsafe.go.
+func (p pointer) setPointerSlice(v []pointer) {
+ if v == nil {
+ p.v.Elem().Set(reflect.New(p.v.Elem().Type()).Elem())
+ return
+ }
+ s := reflect.MakeSlice(p.v.Elem().Type(), 0, len(v))
+ for _, p := range v {
+ s = reflect.Append(s, p.v)
+ }
+ p.v.Elem().Set(s)
+}
+
+// getInterfacePointer returns a pointer that points to the
+// interface data of the interface pointed by p.
+func (p pointer) getInterfacePointer() pointer {
+ if p.v.Elem().IsNil() {
+ return pointer{v: p.v.Elem()}
+ }
+ return pointer{v: p.v.Elem().Elem().Elem().Field(0).Addr()} // *interface -> interface -> *struct -> struct
+}
+
+func (p pointer) asPointerTo(t reflect.Type) reflect.Value {
+ // TODO: check that p.v.Type().Elem() == t?
+ return p.v
+}
+
+func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo {
+ atomicLock.Lock()
+ defer atomicLock.Unlock()
+ return *p
+}
+func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) {
+ atomicLock.Lock()
+ defer atomicLock.Unlock()
+ *p = v
+}
+func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo {
+ atomicLock.Lock()
+ defer atomicLock.Unlock()
+ return *p
+}
+func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) {
+ atomicLock.Lock()
+ defer atomicLock.Unlock()
+ *p = v
+}
+func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo {
+ atomicLock.Lock()
+ defer atomicLock.Unlock()
+ return *p
+}
+func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
+ atomicLock.Lock()
+ defer atomicLock.Unlock()
+ *p = v
+}
+func atomicLoadDiscardInfo(p **discardInfo) *discardInfo {
+ atomicLock.Lock()
+ defer atomicLock.Unlock()
+ return *p
+}
+func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) {
+ atomicLock.Lock()
+ defer atomicLock.Unlock()
+ *p = v
+}
+
+var atomicLock sync.Mutex
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go
new file mode 100644
index 00000000..dbfffe07
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go
@@ -0,0 +1,313 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2012 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// +build !purego,!appengine,!js
+
+// This file contains the implementation of the proto field accesses using package unsafe.
+
+package proto
+
+import (
+ "reflect"
+ "sync/atomic"
+ "unsafe"
+)
+
+const unsafeAllowed = true
+
+// A field identifies a field in a struct, accessible from a pointer.
+// In this implementation, a field is identified by its byte offset from the start of the struct.
+type field uintptr
+
+// toField returns a field equivalent to the given reflect field.
+func toField(f *reflect.StructField) field {
+ return field(f.Offset)
+}
+
+// invalidField is an invalid field identifier.
+const invalidField = ^field(0)
+
+// zeroField is a noop when calling pointer.offset.
+const zeroField = field(0)
+
+// IsValid reports whether the field identifier is valid.
+func (f field) IsValid() bool {
+ return f != invalidField
+}
+
+// The pointer type below is for the new table-driven encoder/decoder.
+// The implementation here uses unsafe.Pointer to create a generic pointer.
+// In pointer_reflect.go we use reflect instead of unsafe to implement
+// the same (but slower) interface.
+type pointer struct {
+ p unsafe.Pointer
+}
+
+// size of pointer
+var ptrSize = unsafe.Sizeof(uintptr(0))
+
+// toPointer converts an interface of pointer type to a pointer
+// that points to the same target.
+func toPointer(i *Message) pointer {
+ // Super-tricky - read pointer out of data word of interface value.
+ // Saves ~25ns over the equivalent:
+ // return valToPointer(reflect.ValueOf(*i))
+ return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
+}
+
+// toAddrPointer converts an interface to a pointer that points to
+// the interface data.
+func toAddrPointer(i *interface{}, isptr, deref bool) (p pointer) {
+ // Super-tricky - read or get the address of data word of interface value.
+ if isptr {
+ // The interface is of pointer type, thus it is a direct interface.
+ // The data word is the pointer data itself. We take its address.
+ p = pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)}
+ } else {
+ // The interface is not of pointer type. The data word is the pointer
+ // to the data.
+ p = pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
+ }
+ if deref {
+ p.p = *(*unsafe.Pointer)(p.p)
+ }
+ return p
+}
+
+// valToPointer converts v to a pointer. v must be of pointer type.
+func valToPointer(v reflect.Value) pointer {
+ return pointer{p: unsafe.Pointer(v.Pointer())}
+}
+
+// offset converts from a pointer to a structure to a pointer to
+// one of its fields.
+func (p pointer) offset(f field) pointer {
+ // For safety, we should panic if !f.IsValid, however calling panic causes
+ // this to no longer be inlineable, which is a serious performance cost.
+ /*
+ if !f.IsValid() {
+ panic("invalid field")
+ }
+ */
+ return pointer{p: unsafe.Pointer(uintptr(p.p) + uintptr(f))}
+}
+
+func (p pointer) isNil() bool {
+ return p.p == nil
+}
+
+func (p pointer) toInt64() *int64 {
+ return (*int64)(p.p)
+}
+func (p pointer) toInt64Ptr() **int64 {
+ return (**int64)(p.p)
+}
+func (p pointer) toInt64Slice() *[]int64 {
+ return (*[]int64)(p.p)
+}
+func (p pointer) toInt32() *int32 {
+ return (*int32)(p.p)
+}
+
+// See pointer_reflect.go for why toInt32Ptr/Slice doesn't exist.
+/*
+ func (p pointer) toInt32Ptr() **int32 {
+ return (**int32)(p.p)
+ }
+ func (p pointer) toInt32Slice() *[]int32 {
+ return (*[]int32)(p.p)
+ }
+*/
+func (p pointer) getInt32Ptr() *int32 {
+ return *(**int32)(p.p)
+}
+func (p pointer) setInt32Ptr(v int32) {
+ *(**int32)(p.p) = &v
+}
+
+// getInt32Slice loads a []int32 from p.
+// The value returned is aliased with the original slice.
+// This behavior differs from the implementation in pointer_reflect.go.
+func (p pointer) getInt32Slice() []int32 {
+ return *(*[]int32)(p.p)
+}
+
+// setInt32Slice stores a []int32 to p.
+// The value set is aliased with the input slice.
+// This behavior differs from the implementation in pointer_reflect.go.
+func (p pointer) setInt32Slice(v []int32) {
+ *(*[]int32)(p.p) = v
+}
+
+// TODO: Can we get rid of appendInt32Slice and use setInt32Slice instead?
+func (p pointer) appendInt32Slice(v int32) {
+ s := (*[]int32)(p.p)
+ *s = append(*s, v)
+}
+
+func (p pointer) toUint64() *uint64 {
+ return (*uint64)(p.p)
+}
+func (p pointer) toUint64Ptr() **uint64 {
+ return (**uint64)(p.p)
+}
+func (p pointer) toUint64Slice() *[]uint64 {
+ return (*[]uint64)(p.p)
+}
+func (p pointer) toUint32() *uint32 {
+ return (*uint32)(p.p)
+}
+func (p pointer) toUint32Ptr() **uint32 {
+ return (**uint32)(p.p)
+}
+func (p pointer) toUint32Slice() *[]uint32 {
+ return (*[]uint32)(p.p)
+}
+func (p pointer) toBool() *bool {
+ return (*bool)(p.p)
+}
+func (p pointer) toBoolPtr() **bool {
+ return (**bool)(p.p)
+}
+func (p pointer) toBoolSlice() *[]bool {
+ return (*[]bool)(p.p)
+}
+func (p pointer) toFloat64() *float64 {
+ return (*float64)(p.p)
+}
+func (p pointer) toFloat64Ptr() **float64 {
+ return (**float64)(p.p)
+}
+func (p pointer) toFloat64Slice() *[]float64 {
+ return (*[]float64)(p.p)
+}
+func (p pointer) toFloat32() *float32 {
+ return (*float32)(p.p)
+}
+func (p pointer) toFloat32Ptr() **float32 {
+ return (**float32)(p.p)
+}
+func (p pointer) toFloat32Slice() *[]float32 {
+ return (*[]float32)(p.p)
+}
+func (p pointer) toString() *string {
+ return (*string)(p.p)
+}
+func (p pointer) toStringPtr() **string {
+ return (**string)(p.p)
+}
+func (p pointer) toStringSlice() *[]string {
+ return (*[]string)(p.p)
+}
+func (p pointer) toBytes() *[]byte {
+ return (*[]byte)(p.p)
+}
+func (p pointer) toBytesSlice() *[][]byte {
+ return (*[][]byte)(p.p)
+}
+func (p pointer) toExtensions() *XXX_InternalExtensions {
+ return (*XXX_InternalExtensions)(p.p)
+}
+func (p pointer) toOldExtensions() *map[int32]Extension {
+ return (*map[int32]Extension)(p.p)
+}
+
+// getPointerSlice loads []*T from p as a []pointer.
+// The value returned is aliased with the original slice.
+// This behavior differs from the implementation in pointer_reflect.go.
+func (p pointer) getPointerSlice() []pointer {
+ // Super-tricky - p should point to a []*T where T is a
+ // message type. We load it as []pointer.
+ return *(*[]pointer)(p.p)
+}
+
+// setPointerSlice stores []pointer into p as a []*T.
+// The value set is aliased with the input slice.
+// This behavior differs from the implementation in pointer_reflect.go.
+func (p pointer) setPointerSlice(v []pointer) {
+ // Super-tricky - p should point to a []*T where T is a
+ // message type. We store it as []pointer.
+ *(*[]pointer)(p.p) = v
+}
+
+// getPointer loads the pointer at p and returns it.
+func (p pointer) getPointer() pointer {
+ return pointer{p: *(*unsafe.Pointer)(p.p)}
+}
+
+// setPointer stores the pointer q at p.
+func (p pointer) setPointer(q pointer) {
+ *(*unsafe.Pointer)(p.p) = q.p
+}
+
+// append q to the slice pointed to by p.
+func (p pointer) appendPointer(q pointer) {
+ s := (*[]unsafe.Pointer)(p.p)
+ *s = append(*s, q.p)
+}
+
+// getInterfacePointer returns a pointer that points to the
+// interface data of the interface pointed by p.
+func (p pointer) getInterfacePointer() pointer {
+ // Super-tricky - read pointer out of data word of interface value.
+ return pointer{p: (*(*[2]unsafe.Pointer)(p.p))[1]}
+}
+
+// asPointerTo returns a reflect.Value that is a pointer to an
+// object of type t stored at p.
+func (p pointer) asPointerTo(t reflect.Type) reflect.Value {
+ return reflect.NewAt(t, p.p)
+}
+
+func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo {
+ return (*unmarshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
+}
+func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) {
+ atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
+}
+func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo {
+ return (*marshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
+}
+func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) {
+ atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
+}
+func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo {
+ return (*mergeInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
+}
+func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
+ atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
+}
+func atomicLoadDiscardInfo(p **discardInfo) *discardInfo {
+ return (*discardInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
+}
+func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) {
+ atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/properties.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/properties.go
new file mode 100644
index 00000000..a4b8c0cd
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/properties.go
@@ -0,0 +1,544 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+/*
+ * Routines for encoding data into the wire format for protocol buffers.
+ */
+
+import (
+ "fmt"
+ "log"
+ "reflect"
+ "sort"
+ "strconv"
+ "strings"
+ "sync"
+)
+
+const debug bool = false
+
+// Constants that identify the encoding of a value on the wire.
+const (
+ WireVarint = 0
+ WireFixed64 = 1
+ WireBytes = 2
+ WireStartGroup = 3
+ WireEndGroup = 4
+ WireFixed32 = 5
+)
+
+// tagMap is an optimization over map[int]int for typical protocol buffer
+// use-cases. Encoded protocol buffers are often in tag order with small tag
+// numbers.
+type tagMap struct {
+ fastTags []int
+ slowTags map[int]int
+}
+
+// tagMapFastLimit is the upper bound on the tag number that will be stored in
+// the tagMap slice rather than its map.
+const tagMapFastLimit = 1024
+
+func (p *tagMap) get(t int) (int, bool) {
+ if t > 0 && t < tagMapFastLimit {
+ if t >= len(p.fastTags) {
+ return 0, false
+ }
+ fi := p.fastTags[t]
+ return fi, fi >= 0
+ }
+ fi, ok := p.slowTags[t]
+ return fi, ok
+}
+
+func (p *tagMap) put(t int, fi int) {
+ if t > 0 && t < tagMapFastLimit {
+ for len(p.fastTags) < t+1 {
+ p.fastTags = append(p.fastTags, -1)
+ }
+ p.fastTags[t] = fi
+ return
+ }
+ if p.slowTags == nil {
+ p.slowTags = make(map[int]int)
+ }
+ p.slowTags[t] = fi
+}
+
+// StructProperties represents properties for all the fields of a struct.
+// decoderTags and decoderOrigNames should only be used by the decoder.
+type StructProperties struct {
+ Prop []*Properties // properties for each field
+ reqCount int // required count
+ decoderTags tagMap // map from proto tag to struct field number
+ decoderOrigNames map[string]int // map from original name to struct field number
+ order []int // list of struct field numbers in tag order
+
+ // OneofTypes contains information about the oneof fields in this message.
+ // It is keyed by the original name of a field.
+ OneofTypes map[string]*OneofProperties
+}
+
+// OneofProperties represents information about a specific field in a oneof.
+type OneofProperties struct {
+ Type reflect.Type // pointer to generated struct type for this oneof field
+ Field int // struct field number of the containing oneof in the message
+ Prop *Properties
+}
+
+// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec.
+// See encode.go, (*Buffer).enc_struct.
+
+func (sp *StructProperties) Len() int { return len(sp.order) }
+func (sp *StructProperties) Less(i, j int) bool {
+ return sp.Prop[sp.order[i]].Tag < sp.Prop[sp.order[j]].Tag
+}
+func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order[j], sp.order[i] }
+
+// Properties represents the protocol-specific behavior of a single struct field.
+type Properties struct {
+ Name string // name of the field, for error messages
+ OrigName string // original name before protocol compiler (always set)
+ JSONName string // name to use for JSON; determined by protoc
+ Wire string
+ WireType int
+ Tag int
+ Required bool
+ Optional bool
+ Repeated bool
+ Packed bool // relevant for repeated primitives only
+ Enum string // set for enum types only
+ proto3 bool // whether this is known to be a proto3 field
+ oneof bool // whether this is a oneof field
+
+ Default string // default value
+ HasDefault bool // whether an explicit default was provided
+
+ stype reflect.Type // set for struct types only
+ sprop *StructProperties // set for struct types only
+
+ mtype reflect.Type // set for map types only
+ MapKeyProp *Properties // set for map types only
+ MapValProp *Properties // set for map types only
+}
+
+// String formats the properties in the protobuf struct field tag style.
+func (p *Properties) String() string {
+ s := p.Wire
+ s += ","
+ s += strconv.Itoa(p.Tag)
+ if p.Required {
+ s += ",req"
+ }
+ if p.Optional {
+ s += ",opt"
+ }
+ if p.Repeated {
+ s += ",rep"
+ }
+ if p.Packed {
+ s += ",packed"
+ }
+ s += ",name=" + p.OrigName
+ if p.JSONName != p.OrigName {
+ s += ",json=" + p.JSONName
+ }
+ if p.proto3 {
+ s += ",proto3"
+ }
+ if p.oneof {
+ s += ",oneof"
+ }
+ if len(p.Enum) > 0 {
+ s += ",enum=" + p.Enum
+ }
+ if p.HasDefault {
+ s += ",def=" + p.Default
+ }
+ return s
+}
+
+// Parse populates p by parsing a string in the protobuf struct field tag style.
+func (p *Properties) Parse(s string) {
+ // "bytes,49,opt,name=foo,def=hello!"
+ fields := strings.Split(s, ",") // breaks def=, but handled below.
+ if len(fields) < 2 {
+ log.Printf("proto: tag has too few fields: %q", s)
+ return
+ }
+
+ p.Wire = fields[0]
+ switch p.Wire {
+ case "varint":
+ p.WireType = WireVarint
+ case "fixed32":
+ p.WireType = WireFixed32
+ case "fixed64":
+ p.WireType = WireFixed64
+ case "zigzag32":
+ p.WireType = WireVarint
+ case "zigzag64":
+ p.WireType = WireVarint
+ case "bytes", "group":
+ p.WireType = WireBytes
+ // no numeric converter for non-numeric types
+ default:
+ log.Printf("proto: tag has unknown wire type: %q", s)
+ return
+ }
+
+ var err error
+ p.Tag, err = strconv.Atoi(fields[1])
+ if err != nil {
+ return
+ }
+
+outer:
+ for i := 2; i < len(fields); i++ {
+ f := fields[i]
+ switch {
+ case f == "req":
+ p.Required = true
+ case f == "opt":
+ p.Optional = true
+ case f == "rep":
+ p.Repeated = true
+ case f == "packed":
+ p.Packed = true
+ case strings.HasPrefix(f, "name="):
+ p.OrigName = f[5:]
+ case strings.HasPrefix(f, "json="):
+ p.JSONName = f[5:]
+ case strings.HasPrefix(f, "enum="):
+ p.Enum = f[5:]
+ case f == "proto3":
+ p.proto3 = true
+ case f == "oneof":
+ p.oneof = true
+ case strings.HasPrefix(f, "def="):
+ p.HasDefault = true
+ p.Default = f[4:] // rest of string
+ if i+1 < len(fields) {
+ // Commas aren't escaped, and def is always last.
+ p.Default += "," + strings.Join(fields[i+1:], ",")
+ break outer
+ }
+ }
+ }
+}
+
+var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem()
+
+// setFieldProps initializes the field properties for submessages and maps.
+func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) {
+ switch t1 := typ; t1.Kind() {
+ case reflect.Ptr:
+ if t1.Elem().Kind() == reflect.Struct {
+ p.stype = t1.Elem()
+ }
+
+ case reflect.Slice:
+ if t2 := t1.Elem(); t2.Kind() == reflect.Ptr && t2.Elem().Kind() == reflect.Struct {
+ p.stype = t2.Elem()
+ }
+
+ case reflect.Map:
+ p.mtype = t1
+ p.MapKeyProp = &Properties{}
+ p.MapKeyProp.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
+ p.MapValProp = &Properties{}
+ vtype := p.mtype.Elem()
+ if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {
+ // The value type is not a message (*T) or bytes ([]byte),
+ // so we need encoders for the pointer to this type.
+ vtype = reflect.PtrTo(vtype)
+ }
+ p.MapValProp.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
+ }
+
+ if p.stype != nil {
+ if lockGetProp {
+ p.sprop = GetProperties(p.stype)
+ } else {
+ p.sprop = getPropertiesLocked(p.stype)
+ }
+ }
+}
+
+var (
+ marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
+)
+
+// Init populates the properties from a protocol buffer struct tag.
+func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) {
+ p.init(typ, name, tag, f, true)
+}
+
+func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructField, lockGetProp bool) {
+ // "bytes,49,opt,def=hello!"
+ p.Name = name
+ p.OrigName = name
+ if tag == "" {
+ return
+ }
+ p.Parse(tag)
+ p.setFieldProps(typ, f, lockGetProp)
+}
+
+var (
+ propertiesMu sync.RWMutex
+ propertiesMap = make(map[reflect.Type]*StructProperties)
+)
+
+// GetProperties returns the list of properties for the type represented by t.
+// t must represent a generated struct type of a protocol message.
+func GetProperties(t reflect.Type) *StructProperties {
+ if t.Kind() != reflect.Struct {
+ panic("proto: type must have kind struct")
+ }
+
+ // Most calls to GetProperties in a long-running program will be
+ // retrieving details for types we have seen before.
+ propertiesMu.RLock()
+ sprop, ok := propertiesMap[t]
+ propertiesMu.RUnlock()
+ if ok {
+ return sprop
+ }
+
+ propertiesMu.Lock()
+ sprop = getPropertiesLocked(t)
+ propertiesMu.Unlock()
+ return sprop
+}
+
+type (
+ oneofFuncsIface interface {
+ XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
+ }
+ oneofWrappersIface interface {
+ XXX_OneofWrappers() []interface{}
+ }
+)
+
+// getPropertiesLocked requires that propertiesMu is held.
+func getPropertiesLocked(t reflect.Type) *StructProperties {
+ if prop, ok := propertiesMap[t]; ok {
+ return prop
+ }
+
+ prop := new(StructProperties)
+ // in case of recursive protos, fill this in now.
+ propertiesMap[t] = prop
+
+ // build properties
+ prop.Prop = make([]*Properties, t.NumField())
+ prop.order = make([]int, t.NumField())
+
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+ p := new(Properties)
+ name := f.Name
+ p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false)
+
+ oneof := f.Tag.Get("protobuf_oneof") // special case
+ if oneof != "" {
+ // Oneof fields don't use the traditional protobuf tag.
+ p.OrigName = oneof
+ }
+ prop.Prop[i] = p
+ prop.order[i] = i
+ if debug {
+ print(i, " ", f.Name, " ", t.String(), " ")
+ if p.Tag > 0 {
+ print(p.String())
+ }
+ print("\n")
+ }
+ }
+
+ // Re-order prop.order.
+ sort.Sort(prop)
+
+ var oots []interface{}
+ switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
+ case oneofFuncsIface:
+ _, _, _, oots = m.XXX_OneofFuncs()
+ case oneofWrappersIface:
+ oots = m.XXX_OneofWrappers()
+ }
+ if len(oots) > 0 {
+ // Interpret oneof metadata.
+ prop.OneofTypes = make(map[string]*OneofProperties)
+ for _, oot := range oots {
+ oop := &OneofProperties{
+ Type: reflect.ValueOf(oot).Type(), // *T
+ Prop: new(Properties),
+ }
+ sft := oop.Type.Elem().Field(0)
+ oop.Prop.Name = sft.Name
+ oop.Prop.Parse(sft.Tag.Get("protobuf"))
+ // There will be exactly one interface field that
+ // this new value is assignable to.
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+ if f.Type.Kind() != reflect.Interface {
+ continue
+ }
+ if !oop.Type.AssignableTo(f.Type) {
+ continue
+ }
+ oop.Field = i
+ break
+ }
+ prop.OneofTypes[oop.Prop.OrigName] = oop
+ }
+ }
+
+ // build required counts
+ // build tags
+ reqCount := 0
+ prop.decoderOrigNames = make(map[string]int)
+ for i, p := range prop.Prop {
+ if strings.HasPrefix(p.Name, "XXX_") {
+ // Internal fields should not appear in tags/origNames maps.
+ // They are handled specially when encoding and decoding.
+ continue
+ }
+ if p.Required {
+ reqCount++
+ }
+ prop.decoderTags.put(p.Tag, i)
+ prop.decoderOrigNames[p.OrigName] = i
+ }
+ prop.reqCount = reqCount
+
+ return prop
+}
+
+// A global registry of enum types.
+// The generated code will register the generated maps by calling RegisterEnum.
+
+var enumValueMaps = make(map[string]map[string]int32)
+
+// RegisterEnum is called from the generated code to install the enum descriptor
+// maps into the global table to aid parsing text format protocol buffers.
+func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) {
+ if _, ok := enumValueMaps[typeName]; ok {
+ panic("proto: duplicate enum registered: " + typeName)
+ }
+ enumValueMaps[typeName] = valueMap
+}
+
+// EnumValueMap returns the mapping from names to integers of the
+// enum type enumType, or a nil if not found.
+func EnumValueMap(enumType string) map[string]int32 {
+ return enumValueMaps[enumType]
+}
+
+// A registry of all linked message types.
+// The string is a fully-qualified proto name ("pkg.Message").
+var (
+ protoTypedNils = make(map[string]Message) // a map from proto names to typed nil pointers
+ protoMapTypes = make(map[string]reflect.Type) // a map from proto names to map types
+ revProtoTypes = make(map[reflect.Type]string)
+)
+
+// RegisterType is called from generated code and maps from the fully qualified
+// proto name to the type (pointer to struct) of the protocol buffer.
+func RegisterType(x Message, name string) {
+ if _, ok := protoTypedNils[name]; ok {
+ // TODO: Some day, make this a panic.
+ log.Printf("proto: duplicate proto type registered: %s", name)
+ return
+ }
+ t := reflect.TypeOf(x)
+ if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 {
+ // Generated code always calls RegisterType with nil x.
+ // This check is just for extra safety.
+ protoTypedNils[name] = x
+ } else {
+ protoTypedNils[name] = reflect.Zero(t).Interface().(Message)
+ }
+ revProtoTypes[t] = name
+}
+
+// RegisterMapType is called from generated code and maps from the fully qualified
+// proto name to the native map type of the proto map definition.
+func RegisterMapType(x interface{}, name string) {
+ if reflect.TypeOf(x).Kind() != reflect.Map {
+ panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name))
+ }
+ if _, ok := protoMapTypes[name]; ok {
+ log.Printf("proto: duplicate proto type registered: %s", name)
+ return
+ }
+ t := reflect.TypeOf(x)
+ protoMapTypes[name] = t
+ revProtoTypes[t] = name
+}
+
+// MessageName returns the fully-qualified proto name for the given message type.
+func MessageName(x Message) string {
+ type xname interface {
+ XXX_MessageName() string
+ }
+ if m, ok := x.(xname); ok {
+ return m.XXX_MessageName()
+ }
+ return revProtoTypes[reflect.TypeOf(x)]
+}
+
+// MessageType returns the message type (pointer to struct) for a named message.
+// The type is not guaranteed to implement proto.Message if the name refers to a
+// map entry.
+func MessageType(name string) reflect.Type {
+ if t, ok := protoTypedNils[name]; ok {
+ return reflect.TypeOf(t)
+ }
+ return protoMapTypes[name]
+}
+
+// A registry of all linked proto files.
+var (
+ protoFiles = make(map[string][]byte) // file name => fileDescriptor
+)
+
+// RegisterFile is called from generated code and maps from the
+// full file name of a .proto file to its compressed FileDescriptorProto.
+func RegisterFile(filename string, fileDescriptor []byte) {
+ protoFiles[filename] = fileDescriptor
+}
+
+// FileDescriptor returns the compressed FileDescriptorProto for a .proto file.
+func FileDescriptor(filename string) []byte { return protoFiles[filename] }
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_marshal.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_marshal.go
new file mode 100644
index 00000000..5cb11fa9
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_marshal.go
@@ -0,0 +1,2776 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2016 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+import (
+ "errors"
+ "fmt"
+ "math"
+ "reflect"
+ "sort"
+ "strconv"
+ "strings"
+ "sync"
+ "sync/atomic"
+ "unicode/utf8"
+)
+
+// a sizer takes a pointer to a field and the size of its tag, computes the size of
+// the encoded data.
+type sizer func(pointer, int) int
+
+// a marshaler takes a byte slice, a pointer to a field, and its tag (in wire format),
+// marshals the field to the end of the slice, returns the slice and error (if any).
+type marshaler func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error)
+
+// marshalInfo is the information used for marshaling a message.
+type marshalInfo struct {
+ typ reflect.Type
+ fields []*marshalFieldInfo
+ unrecognized field // offset of XXX_unrecognized
+ extensions field // offset of XXX_InternalExtensions
+ v1extensions field // offset of XXX_extensions
+ sizecache field // offset of XXX_sizecache
+ initialized int32 // 0 -- only typ is set, 1 -- fully initialized
+ messageset bool // uses message set wire format
+ hasmarshaler bool // has custom marshaler
+ sync.RWMutex // protect extElems map, also for initialization
+ extElems map[int32]*marshalElemInfo // info of extension elements
+}
+
+// marshalFieldInfo is the information used for marshaling a field of a message.
+type marshalFieldInfo struct {
+ field field
+ wiretag uint64 // tag in wire format
+ tagsize int // size of tag in wire format
+ sizer sizer
+ marshaler marshaler
+ isPointer bool
+ required bool // field is required
+ name string // name of the field, for error reporting
+ oneofElems map[reflect.Type]*marshalElemInfo // info of oneof elements
+}
+
+// marshalElemInfo is the information used for marshaling an extension or oneof element.
+type marshalElemInfo struct {
+ wiretag uint64 // tag in wire format
+ tagsize int // size of tag in wire format
+ sizer sizer
+ marshaler marshaler
+ isptr bool // elem is pointer typed, thus interface of this type is a direct interface (extension only)
+ deref bool // dereference the pointer before operating on it; implies isptr
+}
+
+var (
+ marshalInfoMap = map[reflect.Type]*marshalInfo{}
+ marshalInfoLock sync.Mutex
+)
+
+// getMarshalInfo returns the information to marshal a given type of message.
+// The info it returns may not necessarily initialized.
+// t is the type of the message (NOT the pointer to it).
+func getMarshalInfo(t reflect.Type) *marshalInfo {
+ marshalInfoLock.Lock()
+ u, ok := marshalInfoMap[t]
+ if !ok {
+ u = &marshalInfo{typ: t}
+ marshalInfoMap[t] = u
+ }
+ marshalInfoLock.Unlock()
+ return u
+}
+
+// Size is the entry point from generated code,
+// and should be ONLY called by generated code.
+// It computes the size of encoded data of msg.
+// a is a pointer to a place to store cached marshal info.
+func (a *InternalMessageInfo) Size(msg Message) int {
+ u := getMessageMarshalInfo(msg, a)
+ ptr := toPointer(&msg)
+ if ptr.isNil() {
+ // We get here if msg is a typed nil ((*SomeMessage)(nil)),
+ // so it satisfies the interface, and msg == nil wouldn't
+ // catch it. We don't want crash in this case.
+ return 0
+ }
+ return u.size(ptr)
+}
+
+// Marshal is the entry point from generated code,
+// and should be ONLY called by generated code.
+// It marshals msg to the end of b.
+// a is a pointer to a place to store cached marshal info.
+func (a *InternalMessageInfo) Marshal(b []byte, msg Message, deterministic bool) ([]byte, error) {
+ u := getMessageMarshalInfo(msg, a)
+ ptr := toPointer(&msg)
+ if ptr.isNil() {
+ // We get here if msg is a typed nil ((*SomeMessage)(nil)),
+ // so it satisfies the interface, and msg == nil wouldn't
+ // catch it. We don't want crash in this case.
+ return b, ErrNil
+ }
+ return u.marshal(b, ptr, deterministic)
+}
+
+func getMessageMarshalInfo(msg interface{}, a *InternalMessageInfo) *marshalInfo {
+ // u := a.marshal, but atomically.
+ // We use an atomic here to ensure memory consistency.
+ u := atomicLoadMarshalInfo(&a.marshal)
+ if u == nil {
+ // Get marshal information from type of message.
+ t := reflect.ValueOf(msg).Type()
+ if t.Kind() != reflect.Ptr {
+ panic(fmt.Sprintf("cannot handle non-pointer message type %v", t))
+ }
+ u = getMarshalInfo(t.Elem())
+ // Store it in the cache for later users.
+ // a.marshal = u, but atomically.
+ atomicStoreMarshalInfo(&a.marshal, u)
+ }
+ return u
+}
+
+// size is the main function to compute the size of the encoded data of a message.
+// ptr is the pointer to the message.
+func (u *marshalInfo) size(ptr pointer) int {
+ if atomic.LoadInt32(&u.initialized) == 0 {
+ u.computeMarshalInfo()
+ }
+
+ // If the message can marshal itself, let it do it, for compatibility.
+ // NOTE: This is not efficient.
+ if u.hasmarshaler {
+ m := ptr.asPointerTo(u.typ).Interface().(Marshaler)
+ b, _ := m.Marshal()
+ return len(b)
+ }
+
+ n := 0
+ for _, f := range u.fields {
+ if f.isPointer && ptr.offset(f.field).getPointer().isNil() {
+ // nil pointer always marshals to nothing
+ continue
+ }
+ n += f.sizer(ptr.offset(f.field), f.tagsize)
+ }
+ if u.extensions.IsValid() {
+ e := ptr.offset(u.extensions).toExtensions()
+ if u.messageset {
+ n += u.sizeMessageSet(e)
+ } else {
+ n += u.sizeExtensions(e)
+ }
+ }
+ if u.v1extensions.IsValid() {
+ m := *ptr.offset(u.v1extensions).toOldExtensions()
+ n += u.sizeV1Extensions(m)
+ }
+ if u.unrecognized.IsValid() {
+ s := *ptr.offset(u.unrecognized).toBytes()
+ n += len(s)
+ }
+ // cache the result for use in marshal
+ if u.sizecache.IsValid() {
+ atomic.StoreInt32(ptr.offset(u.sizecache).toInt32(), int32(n))
+ }
+ return n
+}
+
+// cachedsize gets the size from cache. If there is no cache (i.e. message is not generated),
+// fall back to compute the size.
+func (u *marshalInfo) cachedsize(ptr pointer) int {
+ if u.sizecache.IsValid() {
+ return int(atomic.LoadInt32(ptr.offset(u.sizecache).toInt32()))
+ }
+ return u.size(ptr)
+}
+
+// marshal is the main function to marshal a message. It takes a byte slice and appends
+// the encoded data to the end of the slice, returns the slice and error (if any).
+// ptr is the pointer to the message.
+// If deterministic is true, map is marshaled in deterministic order.
+func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte, error) {
+ if atomic.LoadInt32(&u.initialized) == 0 {
+ u.computeMarshalInfo()
+ }
+
+ // If the message can marshal itself, let it do it, for compatibility.
+ // NOTE: This is not efficient.
+ if u.hasmarshaler {
+ m := ptr.asPointerTo(u.typ).Interface().(Marshaler)
+ b1, err := m.Marshal()
+ b = append(b, b1...)
+ return b, err
+ }
+
+ var err, errLater error
+ // The old marshaler encodes extensions at beginning.
+ if u.extensions.IsValid() {
+ e := ptr.offset(u.extensions).toExtensions()
+ if u.messageset {
+ b, err = u.appendMessageSet(b, e, deterministic)
+ } else {
+ b, err = u.appendExtensions(b, e, deterministic)
+ }
+ if err != nil {
+ return b, err
+ }
+ }
+ if u.v1extensions.IsValid() {
+ m := *ptr.offset(u.v1extensions).toOldExtensions()
+ b, err = u.appendV1Extensions(b, m, deterministic)
+ if err != nil {
+ return b, err
+ }
+ }
+ for _, f := range u.fields {
+ if f.required {
+ if ptr.offset(f.field).getPointer().isNil() {
+ // Required field is not set.
+ // We record the error but keep going, to give a complete marshaling.
+ if errLater == nil {
+ errLater = &RequiredNotSetError{f.name}
+ }
+ continue
+ }
+ }
+ if f.isPointer && ptr.offset(f.field).getPointer().isNil() {
+ // nil pointer always marshals to nothing
+ continue
+ }
+ b, err = f.marshaler(b, ptr.offset(f.field), f.wiretag, deterministic)
+ if err != nil {
+ if err1, ok := err.(*RequiredNotSetError); ok {
+ // Required field in submessage is not set.
+ // We record the error but keep going, to give a complete marshaling.
+ if errLater == nil {
+ errLater = &RequiredNotSetError{f.name + "." + err1.field}
+ }
+ continue
+ }
+ if err == errRepeatedHasNil {
+ err = errors.New("proto: repeated field " + f.name + " has nil element")
+ }
+ if err == errInvalidUTF8 {
+ if errLater == nil {
+ fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name
+ errLater = &invalidUTF8Error{fullName}
+ }
+ continue
+ }
+ return b, err
+ }
+ }
+ if u.unrecognized.IsValid() {
+ s := *ptr.offset(u.unrecognized).toBytes()
+ b = append(b, s...)
+ }
+ return b, errLater
+}
+
+// computeMarshalInfo initializes the marshal info.
+func (u *marshalInfo) computeMarshalInfo() {
+ u.Lock()
+ defer u.Unlock()
+ if u.initialized != 0 { // non-atomic read is ok as it is protected by the lock
+ return
+ }
+
+ t := u.typ
+ u.unrecognized = invalidField
+ u.extensions = invalidField
+ u.v1extensions = invalidField
+ u.sizecache = invalidField
+
+ // If the message can marshal itself, let it do it, for compatibility.
+ // NOTE: This is not efficient.
+ if reflect.PtrTo(t).Implements(marshalerType) {
+ u.hasmarshaler = true
+ atomic.StoreInt32(&u.initialized, 1)
+ return
+ }
+
+ // get oneof implementers
+ var oneofImplementers []interface{}
+ switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
+ case oneofFuncsIface:
+ _, _, _, oneofImplementers = m.XXX_OneofFuncs()
+ case oneofWrappersIface:
+ oneofImplementers = m.XXX_OneofWrappers()
+ }
+
+ n := t.NumField()
+
+ // deal with XXX fields first
+ for i := 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+ if !strings.HasPrefix(f.Name, "XXX_") {
+ continue
+ }
+ switch f.Name {
+ case "XXX_sizecache":
+ u.sizecache = toField(&f)
+ case "XXX_unrecognized":
+ u.unrecognized = toField(&f)
+ case "XXX_InternalExtensions":
+ u.extensions = toField(&f)
+ u.messageset = f.Tag.Get("protobuf_messageset") == "1"
+ case "XXX_extensions":
+ u.v1extensions = toField(&f)
+ case "XXX_NoUnkeyedLiteral":
+ // nothing to do
+ default:
+ panic("unknown XXX field: " + f.Name)
+ }
+ n--
+ }
+
+ // normal fields
+ fields := make([]marshalFieldInfo, n) // batch allocation
+ u.fields = make([]*marshalFieldInfo, 0, n)
+ for i, j := 0, 0; i < t.NumField(); i++ {
+ f := t.Field(i)
+
+ if strings.HasPrefix(f.Name, "XXX_") {
+ continue
+ }
+ field := &fields[j]
+ j++
+ field.name = f.Name
+ u.fields = append(u.fields, field)
+ if f.Tag.Get("protobuf_oneof") != "" {
+ field.computeOneofFieldInfo(&f, oneofImplementers)
+ continue
+ }
+ if f.Tag.Get("protobuf") == "" {
+ // field has no tag (not in generated message), ignore it
+ u.fields = u.fields[:len(u.fields)-1]
+ j--
+ continue
+ }
+ field.computeMarshalFieldInfo(&f)
+ }
+
+ // fields are marshaled in tag order on the wire.
+ sort.Sort(byTag(u.fields))
+
+ atomic.StoreInt32(&u.initialized, 1)
+}
+
+// helper for sorting fields by tag
+type byTag []*marshalFieldInfo
+
+func (a byTag) Len() int { return len(a) }
+func (a byTag) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
+func (a byTag) Less(i, j int) bool { return a[i].wiretag < a[j].wiretag }
+
+// getExtElemInfo returns the information to marshal an extension element.
+// The info it returns is initialized.
+func (u *marshalInfo) getExtElemInfo(desc *ExtensionDesc) *marshalElemInfo {
+ // get from cache first
+ u.RLock()
+ e, ok := u.extElems[desc.Field]
+ u.RUnlock()
+ if ok {
+ return e
+ }
+
+ t := reflect.TypeOf(desc.ExtensionType) // pointer or slice to basic type or struct
+ tags := strings.Split(desc.Tag, ",")
+ tag, err := strconv.Atoi(tags[1])
+ if err != nil {
+ panic("tag is not an integer")
+ }
+ wt := wiretype(tags[0])
+ if t.Kind() == reflect.Ptr && t.Elem().Kind() != reflect.Struct {
+ t = t.Elem()
+ }
+ sizer, marshaler := typeMarshaler(t, tags, false, false)
+ var deref bool
+ if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 {
+ t = reflect.PtrTo(t)
+ deref = true
+ }
+ e = &marshalElemInfo{
+ wiretag: uint64(tag)<<3 | wt,
+ tagsize: SizeVarint(uint64(tag) << 3),
+ sizer: sizer,
+ marshaler: marshaler,
+ isptr: t.Kind() == reflect.Ptr,
+ deref: deref,
+ }
+
+ // update cache
+ u.Lock()
+ if u.extElems == nil {
+ u.extElems = make(map[int32]*marshalElemInfo)
+ }
+ u.extElems[desc.Field] = e
+ u.Unlock()
+ return e
+}
+
+// computeMarshalFieldInfo fills up the information to marshal a field.
+func (fi *marshalFieldInfo) computeMarshalFieldInfo(f *reflect.StructField) {
+ // parse protobuf tag of the field.
+ // tag has format of "bytes,49,opt,name=foo,def=hello!"
+ tags := strings.Split(f.Tag.Get("protobuf"), ",")
+ if tags[0] == "" {
+ return
+ }
+ tag, err := strconv.Atoi(tags[1])
+ if err != nil {
+ panic("tag is not an integer")
+ }
+ wt := wiretype(tags[0])
+ if tags[2] == "req" {
+ fi.required = true
+ }
+ fi.setTag(f, tag, wt)
+ fi.setMarshaler(f, tags)
+}
+
+func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) {
+ fi.field = toField(f)
+ fi.wiretag = math.MaxInt32 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire.
+ fi.isPointer = true
+ fi.sizer, fi.marshaler = makeOneOfMarshaler(fi, f)
+ fi.oneofElems = make(map[reflect.Type]*marshalElemInfo)
+
+ ityp := f.Type // interface type
+ for _, o := range oneofImplementers {
+ t := reflect.TypeOf(o)
+ if !t.Implements(ityp) {
+ continue
+ }
+ sf := t.Elem().Field(0) // oneof implementer is a struct with a single field
+ tags := strings.Split(sf.Tag.Get("protobuf"), ",")
+ tag, err := strconv.Atoi(tags[1])
+ if err != nil {
+ panic("tag is not an integer")
+ }
+ wt := wiretype(tags[0])
+ sizer, marshaler := typeMarshaler(sf.Type, tags, false, true) // oneof should not omit any zero value
+ fi.oneofElems[t.Elem()] = &marshalElemInfo{
+ wiretag: uint64(tag)<<3 | wt,
+ tagsize: SizeVarint(uint64(tag) << 3),
+ sizer: sizer,
+ marshaler: marshaler,
+ }
+ }
+}
+
+// wiretype returns the wire encoding of the type.
+func wiretype(encoding string) uint64 {
+ switch encoding {
+ case "fixed32":
+ return WireFixed32
+ case "fixed64":
+ return WireFixed64
+ case "varint", "zigzag32", "zigzag64":
+ return WireVarint
+ case "bytes":
+ return WireBytes
+ case "group":
+ return WireStartGroup
+ }
+ panic("unknown wire type " + encoding)
+}
+
+// setTag fills up the tag (in wire format) and its size in the info of a field.
+func (fi *marshalFieldInfo) setTag(f *reflect.StructField, tag int, wt uint64) {
+ fi.field = toField(f)
+ fi.wiretag = uint64(tag)<<3 | wt
+ fi.tagsize = SizeVarint(uint64(tag) << 3)
+}
+
+// setMarshaler fills up the sizer and marshaler in the info of a field.
+func (fi *marshalFieldInfo) setMarshaler(f *reflect.StructField, tags []string) {
+ switch f.Type.Kind() {
+ case reflect.Map:
+ // map field
+ fi.isPointer = true
+ fi.sizer, fi.marshaler = makeMapMarshaler(f)
+ return
+ case reflect.Ptr, reflect.Slice:
+ fi.isPointer = true
+ }
+ fi.sizer, fi.marshaler = typeMarshaler(f.Type, tags, true, false)
+}
+
+// typeMarshaler returns the sizer and marshaler of a given field.
+// t is the type of the field.
+// tags is the generated "protobuf" tag of the field.
+// If nozero is true, zero value is not marshaled to the wire.
+// If oneof is true, it is a oneof field.
+func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, marshaler) {
+ encoding := tags[0]
+
+ pointer := false
+ slice := false
+ if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 {
+ slice = true
+ t = t.Elem()
+ }
+ if t.Kind() == reflect.Ptr {
+ pointer = true
+ t = t.Elem()
+ }
+
+ packed := false
+ proto3 := false
+ validateUTF8 := true
+ for i := 2; i < len(tags); i++ {
+ if tags[i] == "packed" {
+ packed = true
+ }
+ if tags[i] == "proto3" {
+ proto3 = true
+ }
+ }
+ validateUTF8 = validateUTF8 && proto3
+
+ switch t.Kind() {
+ case reflect.Bool:
+ if pointer {
+ return sizeBoolPtr, appendBoolPtr
+ }
+ if slice {
+ if packed {
+ return sizeBoolPackedSlice, appendBoolPackedSlice
+ }
+ return sizeBoolSlice, appendBoolSlice
+ }
+ if nozero {
+ return sizeBoolValueNoZero, appendBoolValueNoZero
+ }
+ return sizeBoolValue, appendBoolValue
+ case reflect.Uint32:
+ switch encoding {
+ case "fixed32":
+ if pointer {
+ return sizeFixed32Ptr, appendFixed32Ptr
+ }
+ if slice {
+ if packed {
+ return sizeFixed32PackedSlice, appendFixed32PackedSlice
+ }
+ return sizeFixed32Slice, appendFixed32Slice
+ }
+ if nozero {
+ return sizeFixed32ValueNoZero, appendFixed32ValueNoZero
+ }
+ return sizeFixed32Value, appendFixed32Value
+ case "varint":
+ if pointer {
+ return sizeVarint32Ptr, appendVarint32Ptr
+ }
+ if slice {
+ if packed {
+ return sizeVarint32PackedSlice, appendVarint32PackedSlice
+ }
+ return sizeVarint32Slice, appendVarint32Slice
+ }
+ if nozero {
+ return sizeVarint32ValueNoZero, appendVarint32ValueNoZero
+ }
+ return sizeVarint32Value, appendVarint32Value
+ }
+ case reflect.Int32:
+ switch encoding {
+ case "fixed32":
+ if pointer {
+ return sizeFixedS32Ptr, appendFixedS32Ptr
+ }
+ if slice {
+ if packed {
+ return sizeFixedS32PackedSlice, appendFixedS32PackedSlice
+ }
+ return sizeFixedS32Slice, appendFixedS32Slice
+ }
+ if nozero {
+ return sizeFixedS32ValueNoZero, appendFixedS32ValueNoZero
+ }
+ return sizeFixedS32Value, appendFixedS32Value
+ case "varint":
+ if pointer {
+ return sizeVarintS32Ptr, appendVarintS32Ptr
+ }
+ if slice {
+ if packed {
+ return sizeVarintS32PackedSlice, appendVarintS32PackedSlice
+ }
+ return sizeVarintS32Slice, appendVarintS32Slice
+ }
+ if nozero {
+ return sizeVarintS32ValueNoZero, appendVarintS32ValueNoZero
+ }
+ return sizeVarintS32Value, appendVarintS32Value
+ case "zigzag32":
+ if pointer {
+ return sizeZigzag32Ptr, appendZigzag32Ptr
+ }
+ if slice {
+ if packed {
+ return sizeZigzag32PackedSlice, appendZigzag32PackedSlice
+ }
+ return sizeZigzag32Slice, appendZigzag32Slice
+ }
+ if nozero {
+ return sizeZigzag32ValueNoZero, appendZigzag32ValueNoZero
+ }
+ return sizeZigzag32Value, appendZigzag32Value
+ }
+ case reflect.Uint64:
+ switch encoding {
+ case "fixed64":
+ if pointer {
+ return sizeFixed64Ptr, appendFixed64Ptr
+ }
+ if slice {
+ if packed {
+ return sizeFixed64PackedSlice, appendFixed64PackedSlice
+ }
+ return sizeFixed64Slice, appendFixed64Slice
+ }
+ if nozero {
+ return sizeFixed64ValueNoZero, appendFixed64ValueNoZero
+ }
+ return sizeFixed64Value, appendFixed64Value
+ case "varint":
+ if pointer {
+ return sizeVarint64Ptr, appendVarint64Ptr
+ }
+ if slice {
+ if packed {
+ return sizeVarint64PackedSlice, appendVarint64PackedSlice
+ }
+ return sizeVarint64Slice, appendVarint64Slice
+ }
+ if nozero {
+ return sizeVarint64ValueNoZero, appendVarint64ValueNoZero
+ }
+ return sizeVarint64Value, appendVarint64Value
+ }
+ case reflect.Int64:
+ switch encoding {
+ case "fixed64":
+ if pointer {
+ return sizeFixedS64Ptr, appendFixedS64Ptr
+ }
+ if slice {
+ if packed {
+ return sizeFixedS64PackedSlice, appendFixedS64PackedSlice
+ }
+ return sizeFixedS64Slice, appendFixedS64Slice
+ }
+ if nozero {
+ return sizeFixedS64ValueNoZero, appendFixedS64ValueNoZero
+ }
+ return sizeFixedS64Value, appendFixedS64Value
+ case "varint":
+ if pointer {
+ return sizeVarintS64Ptr, appendVarintS64Ptr
+ }
+ if slice {
+ if packed {
+ return sizeVarintS64PackedSlice, appendVarintS64PackedSlice
+ }
+ return sizeVarintS64Slice, appendVarintS64Slice
+ }
+ if nozero {
+ return sizeVarintS64ValueNoZero, appendVarintS64ValueNoZero
+ }
+ return sizeVarintS64Value, appendVarintS64Value
+ case "zigzag64":
+ if pointer {
+ return sizeZigzag64Ptr, appendZigzag64Ptr
+ }
+ if slice {
+ if packed {
+ return sizeZigzag64PackedSlice, appendZigzag64PackedSlice
+ }
+ return sizeZigzag64Slice, appendZigzag64Slice
+ }
+ if nozero {
+ return sizeZigzag64ValueNoZero, appendZigzag64ValueNoZero
+ }
+ return sizeZigzag64Value, appendZigzag64Value
+ }
+ case reflect.Float32:
+ if pointer {
+ return sizeFloat32Ptr, appendFloat32Ptr
+ }
+ if slice {
+ if packed {
+ return sizeFloat32PackedSlice, appendFloat32PackedSlice
+ }
+ return sizeFloat32Slice, appendFloat32Slice
+ }
+ if nozero {
+ return sizeFloat32ValueNoZero, appendFloat32ValueNoZero
+ }
+ return sizeFloat32Value, appendFloat32Value
+ case reflect.Float64:
+ if pointer {
+ return sizeFloat64Ptr, appendFloat64Ptr
+ }
+ if slice {
+ if packed {
+ return sizeFloat64PackedSlice, appendFloat64PackedSlice
+ }
+ return sizeFloat64Slice, appendFloat64Slice
+ }
+ if nozero {
+ return sizeFloat64ValueNoZero, appendFloat64ValueNoZero
+ }
+ return sizeFloat64Value, appendFloat64Value
+ case reflect.String:
+ if validateUTF8 {
+ if pointer {
+ return sizeStringPtr, appendUTF8StringPtr
+ }
+ if slice {
+ return sizeStringSlice, appendUTF8StringSlice
+ }
+ if nozero {
+ return sizeStringValueNoZero, appendUTF8StringValueNoZero
+ }
+ return sizeStringValue, appendUTF8StringValue
+ }
+ if pointer {
+ return sizeStringPtr, appendStringPtr
+ }
+ if slice {
+ return sizeStringSlice, appendStringSlice
+ }
+ if nozero {
+ return sizeStringValueNoZero, appendStringValueNoZero
+ }
+ return sizeStringValue, appendStringValue
+ case reflect.Slice:
+ if slice {
+ return sizeBytesSlice, appendBytesSlice
+ }
+ if oneof {
+ // Oneof bytes field may also have "proto3" tag.
+ // We want to marshal it as a oneof field. Do this
+ // check before the proto3 check.
+ return sizeBytesOneof, appendBytesOneof
+ }
+ if proto3 {
+ return sizeBytes3, appendBytes3
+ }
+ return sizeBytes, appendBytes
+ case reflect.Struct:
+ switch encoding {
+ case "group":
+ if slice {
+ return makeGroupSliceMarshaler(getMarshalInfo(t))
+ }
+ return makeGroupMarshaler(getMarshalInfo(t))
+ case "bytes":
+ if slice {
+ return makeMessageSliceMarshaler(getMarshalInfo(t))
+ }
+ return makeMessageMarshaler(getMarshalInfo(t))
+ }
+ }
+ panic(fmt.Sprintf("unknown or mismatched type: type: %v, wire type: %v", t, encoding))
+}
+
+// Below are functions to size/marshal a specific type of a field.
+// They are stored in the field's info, and called by function pointers.
+// They have type sizer or marshaler.
+
+func sizeFixed32Value(_ pointer, tagsize int) int {
+ return 4 + tagsize
+}
+func sizeFixed32ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toUint32()
+ if v == 0 {
+ return 0
+ }
+ return 4 + tagsize
+}
+func sizeFixed32Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toUint32Ptr()
+ if p == nil {
+ return 0
+ }
+ return 4 + tagsize
+}
+func sizeFixed32Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toUint32Slice()
+ return (4 + tagsize) * len(s)
+}
+func sizeFixed32PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toUint32Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize
+}
+func sizeFixedS32Value(_ pointer, tagsize int) int {
+ return 4 + tagsize
+}
+func sizeFixedS32ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toInt32()
+ if v == 0 {
+ return 0
+ }
+ return 4 + tagsize
+}
+func sizeFixedS32Ptr(ptr pointer, tagsize int) int {
+ p := ptr.getInt32Ptr()
+ if p == nil {
+ return 0
+ }
+ return 4 + tagsize
+}
+func sizeFixedS32Slice(ptr pointer, tagsize int) int {
+ s := ptr.getInt32Slice()
+ return (4 + tagsize) * len(s)
+}
+func sizeFixedS32PackedSlice(ptr pointer, tagsize int) int {
+ s := ptr.getInt32Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize
+}
+func sizeFloat32Value(_ pointer, tagsize int) int {
+ return 4 + tagsize
+}
+func sizeFloat32ValueNoZero(ptr pointer, tagsize int) int {
+ v := math.Float32bits(*ptr.toFloat32())
+ if v == 0 {
+ return 0
+ }
+ return 4 + tagsize
+}
+func sizeFloat32Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toFloat32Ptr()
+ if p == nil {
+ return 0
+ }
+ return 4 + tagsize
+}
+func sizeFloat32Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toFloat32Slice()
+ return (4 + tagsize) * len(s)
+}
+func sizeFloat32PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toFloat32Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize
+}
+func sizeFixed64Value(_ pointer, tagsize int) int {
+ return 8 + tagsize
+}
+func sizeFixed64ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toUint64()
+ if v == 0 {
+ return 0
+ }
+ return 8 + tagsize
+}
+func sizeFixed64Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toUint64Ptr()
+ if p == nil {
+ return 0
+ }
+ return 8 + tagsize
+}
+func sizeFixed64Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toUint64Slice()
+ return (8 + tagsize) * len(s)
+}
+func sizeFixed64PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toUint64Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize
+}
+func sizeFixedS64Value(_ pointer, tagsize int) int {
+ return 8 + tagsize
+}
+func sizeFixedS64ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toInt64()
+ if v == 0 {
+ return 0
+ }
+ return 8 + tagsize
+}
+func sizeFixedS64Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toInt64Ptr()
+ if p == nil {
+ return 0
+ }
+ return 8 + tagsize
+}
+func sizeFixedS64Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toInt64Slice()
+ return (8 + tagsize) * len(s)
+}
+func sizeFixedS64PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toInt64Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize
+}
+func sizeFloat64Value(_ pointer, tagsize int) int {
+ return 8 + tagsize
+}
+func sizeFloat64ValueNoZero(ptr pointer, tagsize int) int {
+ v := math.Float64bits(*ptr.toFloat64())
+ if v == 0 {
+ return 0
+ }
+ return 8 + tagsize
+}
+func sizeFloat64Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toFloat64Ptr()
+ if p == nil {
+ return 0
+ }
+ return 8 + tagsize
+}
+func sizeFloat64Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toFloat64Slice()
+ return (8 + tagsize) * len(s)
+}
+func sizeFloat64PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toFloat64Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize
+}
+func sizeVarint32Value(ptr pointer, tagsize int) int {
+ v := *ptr.toUint32()
+ return SizeVarint(uint64(v)) + tagsize
+}
+func sizeVarint32ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toUint32()
+ if v == 0 {
+ return 0
+ }
+ return SizeVarint(uint64(v)) + tagsize
+}
+func sizeVarint32Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toUint32Ptr()
+ if p == nil {
+ return 0
+ }
+ return SizeVarint(uint64(*p)) + tagsize
+}
+func sizeVarint32Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toUint32Slice()
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v)) + tagsize
+ }
+ return n
+}
+func sizeVarint32PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toUint32Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v))
+ }
+ return n + SizeVarint(uint64(n)) + tagsize
+}
+func sizeVarintS32Value(ptr pointer, tagsize int) int {
+ v := *ptr.toInt32()
+ return SizeVarint(uint64(v)) + tagsize
+}
+func sizeVarintS32ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toInt32()
+ if v == 0 {
+ return 0
+ }
+ return SizeVarint(uint64(v)) + tagsize
+}
+func sizeVarintS32Ptr(ptr pointer, tagsize int) int {
+ p := ptr.getInt32Ptr()
+ if p == nil {
+ return 0
+ }
+ return SizeVarint(uint64(*p)) + tagsize
+}
+func sizeVarintS32Slice(ptr pointer, tagsize int) int {
+ s := ptr.getInt32Slice()
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v)) + tagsize
+ }
+ return n
+}
+func sizeVarintS32PackedSlice(ptr pointer, tagsize int) int {
+ s := ptr.getInt32Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v))
+ }
+ return n + SizeVarint(uint64(n)) + tagsize
+}
+func sizeVarint64Value(ptr pointer, tagsize int) int {
+ v := *ptr.toUint64()
+ return SizeVarint(v) + tagsize
+}
+func sizeVarint64ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toUint64()
+ if v == 0 {
+ return 0
+ }
+ return SizeVarint(v) + tagsize
+}
+func sizeVarint64Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toUint64Ptr()
+ if p == nil {
+ return 0
+ }
+ return SizeVarint(*p) + tagsize
+}
+func sizeVarint64Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toUint64Slice()
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(v) + tagsize
+ }
+ return n
+}
+func sizeVarint64PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toUint64Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(v)
+ }
+ return n + SizeVarint(uint64(n)) + tagsize
+}
+func sizeVarintS64Value(ptr pointer, tagsize int) int {
+ v := *ptr.toInt64()
+ return SizeVarint(uint64(v)) + tagsize
+}
+func sizeVarintS64ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toInt64()
+ if v == 0 {
+ return 0
+ }
+ return SizeVarint(uint64(v)) + tagsize
+}
+func sizeVarintS64Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toInt64Ptr()
+ if p == nil {
+ return 0
+ }
+ return SizeVarint(uint64(*p)) + tagsize
+}
+func sizeVarintS64Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toInt64Slice()
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v)) + tagsize
+ }
+ return n
+}
+func sizeVarintS64PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toInt64Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v))
+ }
+ return n + SizeVarint(uint64(n)) + tagsize
+}
+func sizeZigzag32Value(ptr pointer, tagsize int) int {
+ v := *ptr.toInt32()
+ return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize
+}
+func sizeZigzag32ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toInt32()
+ if v == 0 {
+ return 0
+ }
+ return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize
+}
+func sizeZigzag32Ptr(ptr pointer, tagsize int) int {
+ p := ptr.getInt32Ptr()
+ if p == nil {
+ return 0
+ }
+ v := *p
+ return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize
+}
+func sizeZigzag32Slice(ptr pointer, tagsize int) int {
+ s := ptr.getInt32Slice()
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize
+ }
+ return n
+}
+func sizeZigzag32PackedSlice(ptr pointer, tagsize int) int {
+ s := ptr.getInt32Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31))))
+ }
+ return n + SizeVarint(uint64(n)) + tagsize
+}
+func sizeZigzag64Value(ptr pointer, tagsize int) int {
+ v := *ptr.toInt64()
+ return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize
+}
+func sizeZigzag64ValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toInt64()
+ if v == 0 {
+ return 0
+ }
+ return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize
+}
+func sizeZigzag64Ptr(ptr pointer, tagsize int) int {
+ p := *ptr.toInt64Ptr()
+ if p == nil {
+ return 0
+ }
+ v := *p
+ return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize
+}
+func sizeZigzag64Slice(ptr pointer, tagsize int) int {
+ s := *ptr.toInt64Slice()
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize
+ }
+ return n
+}
+func sizeZigzag64PackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toInt64Slice()
+ if len(s) == 0 {
+ return 0
+ }
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v<<1) ^ uint64((int64(v) >> 63)))
+ }
+ return n + SizeVarint(uint64(n)) + tagsize
+}
+func sizeBoolValue(_ pointer, tagsize int) int {
+ return 1 + tagsize
+}
+func sizeBoolValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toBool()
+ if !v {
+ return 0
+ }
+ return 1 + tagsize
+}
+func sizeBoolPtr(ptr pointer, tagsize int) int {
+ p := *ptr.toBoolPtr()
+ if p == nil {
+ return 0
+ }
+ return 1 + tagsize
+}
+func sizeBoolSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toBoolSlice()
+ return (1 + tagsize) * len(s)
+}
+func sizeBoolPackedSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toBoolSlice()
+ if len(s) == 0 {
+ return 0
+ }
+ return len(s) + SizeVarint(uint64(len(s))) + tagsize
+}
+func sizeStringValue(ptr pointer, tagsize int) int {
+ v := *ptr.toString()
+ return len(v) + SizeVarint(uint64(len(v))) + tagsize
+}
+func sizeStringValueNoZero(ptr pointer, tagsize int) int {
+ v := *ptr.toString()
+ if v == "" {
+ return 0
+ }
+ return len(v) + SizeVarint(uint64(len(v))) + tagsize
+}
+func sizeStringPtr(ptr pointer, tagsize int) int {
+ p := *ptr.toStringPtr()
+ if p == nil {
+ return 0
+ }
+ v := *p
+ return len(v) + SizeVarint(uint64(len(v))) + tagsize
+}
+func sizeStringSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toStringSlice()
+ n := 0
+ for _, v := range s {
+ n += len(v) + SizeVarint(uint64(len(v))) + tagsize
+ }
+ return n
+}
+func sizeBytes(ptr pointer, tagsize int) int {
+ v := *ptr.toBytes()
+ if v == nil {
+ return 0
+ }
+ return len(v) + SizeVarint(uint64(len(v))) + tagsize
+}
+func sizeBytes3(ptr pointer, tagsize int) int {
+ v := *ptr.toBytes()
+ if len(v) == 0 {
+ return 0
+ }
+ return len(v) + SizeVarint(uint64(len(v))) + tagsize
+}
+func sizeBytesOneof(ptr pointer, tagsize int) int {
+ v := *ptr.toBytes()
+ return len(v) + SizeVarint(uint64(len(v))) + tagsize
+}
+func sizeBytesSlice(ptr pointer, tagsize int) int {
+ s := *ptr.toBytesSlice()
+ n := 0
+ for _, v := range s {
+ n += len(v) + SizeVarint(uint64(len(v))) + tagsize
+ }
+ return n
+}
+
+// appendFixed32 appends an encoded fixed32 to b.
+func appendFixed32(b []byte, v uint32) []byte {
+ b = append(b,
+ byte(v),
+ byte(v>>8),
+ byte(v>>16),
+ byte(v>>24))
+ return b
+}
+
+// appendFixed64 appends an encoded fixed64 to b.
+func appendFixed64(b []byte, v uint64) []byte {
+ b = append(b,
+ byte(v),
+ byte(v>>8),
+ byte(v>>16),
+ byte(v>>24),
+ byte(v>>32),
+ byte(v>>40),
+ byte(v>>48),
+ byte(v>>56))
+ return b
+}
+
+// appendVarint appends an encoded varint to b.
+func appendVarint(b []byte, v uint64) []byte {
+ // TODO: make 1-byte (maybe 2-byte) case inline-able, once we
+ // have non-leaf inliner.
+ switch {
+ case v < 1<<7:
+ b = append(b, byte(v))
+ case v < 1<<14:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte(v>>7))
+ case v < 1<<21:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte((v>>7)&0x7f|0x80),
+ byte(v>>14))
+ case v < 1<<28:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte((v>>7)&0x7f|0x80),
+ byte((v>>14)&0x7f|0x80),
+ byte(v>>21))
+ case v < 1<<35:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte((v>>7)&0x7f|0x80),
+ byte((v>>14)&0x7f|0x80),
+ byte((v>>21)&0x7f|0x80),
+ byte(v>>28))
+ case v < 1<<42:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte((v>>7)&0x7f|0x80),
+ byte((v>>14)&0x7f|0x80),
+ byte((v>>21)&0x7f|0x80),
+ byte((v>>28)&0x7f|0x80),
+ byte(v>>35))
+ case v < 1<<49:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte((v>>7)&0x7f|0x80),
+ byte((v>>14)&0x7f|0x80),
+ byte((v>>21)&0x7f|0x80),
+ byte((v>>28)&0x7f|0x80),
+ byte((v>>35)&0x7f|0x80),
+ byte(v>>42))
+ case v < 1<<56:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte((v>>7)&0x7f|0x80),
+ byte((v>>14)&0x7f|0x80),
+ byte((v>>21)&0x7f|0x80),
+ byte((v>>28)&0x7f|0x80),
+ byte((v>>35)&0x7f|0x80),
+ byte((v>>42)&0x7f|0x80),
+ byte(v>>49))
+ case v < 1<<63:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte((v>>7)&0x7f|0x80),
+ byte((v>>14)&0x7f|0x80),
+ byte((v>>21)&0x7f|0x80),
+ byte((v>>28)&0x7f|0x80),
+ byte((v>>35)&0x7f|0x80),
+ byte((v>>42)&0x7f|0x80),
+ byte((v>>49)&0x7f|0x80),
+ byte(v>>56))
+ default:
+ b = append(b,
+ byte(v&0x7f|0x80),
+ byte((v>>7)&0x7f|0x80),
+ byte((v>>14)&0x7f|0x80),
+ byte((v>>21)&0x7f|0x80),
+ byte((v>>28)&0x7f|0x80),
+ byte((v>>35)&0x7f|0x80),
+ byte((v>>42)&0x7f|0x80),
+ byte((v>>49)&0x7f|0x80),
+ byte((v>>56)&0x7f|0x80),
+ 1)
+ }
+ return b
+}
+
+func appendFixed32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toUint32()
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, v)
+ return b, nil
+}
+func appendFixed32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toUint32()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, v)
+ return b, nil
+}
+func appendFixed32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toUint32Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, *p)
+ return b, nil
+}
+func appendFixed32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toUint32Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, v)
+ }
+ return b, nil
+}
+func appendFixed32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toUint32Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ b = appendVarint(b, uint64(4*len(s)))
+ for _, v := range s {
+ b = appendFixed32(b, v)
+ }
+ return b, nil
+}
+func appendFixedS32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt32()
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, uint32(v))
+ return b, nil
+}
+func appendFixedS32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt32()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, uint32(v))
+ return b, nil
+}
+func appendFixedS32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := ptr.getInt32Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, uint32(*p))
+ return b, nil
+}
+func appendFixedS32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := ptr.getInt32Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, uint32(v))
+ }
+ return b, nil
+}
+func appendFixedS32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := ptr.getInt32Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ b = appendVarint(b, uint64(4*len(s)))
+ for _, v := range s {
+ b = appendFixed32(b, uint32(v))
+ }
+ return b, nil
+}
+func appendFloat32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := math.Float32bits(*ptr.toFloat32())
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, v)
+ return b, nil
+}
+func appendFloat32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := math.Float32bits(*ptr.toFloat32())
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, v)
+ return b, nil
+}
+func appendFloat32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toFloat32Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, math.Float32bits(*p))
+ return b, nil
+}
+func appendFloat32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toFloat32Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendFixed32(b, math.Float32bits(v))
+ }
+ return b, nil
+}
+func appendFloat32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toFloat32Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ b = appendVarint(b, uint64(4*len(s)))
+ for _, v := range s {
+ b = appendFixed32(b, math.Float32bits(v))
+ }
+ return b, nil
+}
+func appendFixed64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toUint64()
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, v)
+ return b, nil
+}
+func appendFixed64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toUint64()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, v)
+ return b, nil
+}
+func appendFixed64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toUint64Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, *p)
+ return b, nil
+}
+func appendFixed64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toUint64Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, v)
+ }
+ return b, nil
+}
+func appendFixed64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toUint64Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ b = appendVarint(b, uint64(8*len(s)))
+ for _, v := range s {
+ b = appendFixed64(b, v)
+ }
+ return b, nil
+}
+func appendFixedS64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt64()
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, uint64(v))
+ return b, nil
+}
+func appendFixedS64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt64()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, uint64(v))
+ return b, nil
+}
+func appendFixedS64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toInt64Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, uint64(*p))
+ return b, nil
+}
+func appendFixedS64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toInt64Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, uint64(v))
+ }
+ return b, nil
+}
+func appendFixedS64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toInt64Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ b = appendVarint(b, uint64(8*len(s)))
+ for _, v := range s {
+ b = appendFixed64(b, uint64(v))
+ }
+ return b, nil
+}
+func appendFloat64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := math.Float64bits(*ptr.toFloat64())
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, v)
+ return b, nil
+}
+func appendFloat64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := math.Float64bits(*ptr.toFloat64())
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, v)
+ return b, nil
+}
+func appendFloat64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toFloat64Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, math.Float64bits(*p))
+ return b, nil
+}
+func appendFloat64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toFloat64Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendFixed64(b, math.Float64bits(v))
+ }
+ return b, nil
+}
+func appendFloat64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toFloat64Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ b = appendVarint(b, uint64(8*len(s)))
+ for _, v := range s {
+ b = appendFixed64(b, math.Float64bits(v))
+ }
+ return b, nil
+}
+func appendVarint32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toUint32()
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ return b, nil
+}
+func appendVarint32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toUint32()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ return b, nil
+}
+func appendVarint32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toUint32Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(*p))
+ return b, nil
+}
+func appendVarint32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toUint32Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ }
+ return b, nil
+}
+func appendVarint32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toUint32Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ // compute size
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v))
+ }
+ b = appendVarint(b, uint64(n))
+ for _, v := range s {
+ b = appendVarint(b, uint64(v))
+ }
+ return b, nil
+}
+func appendVarintS32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt32()
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ return b, nil
+}
+func appendVarintS32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt32()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ return b, nil
+}
+func appendVarintS32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := ptr.getInt32Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(*p))
+ return b, nil
+}
+func appendVarintS32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := ptr.getInt32Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ }
+ return b, nil
+}
+func appendVarintS32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := ptr.getInt32Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ // compute size
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v))
+ }
+ b = appendVarint(b, uint64(n))
+ for _, v := range s {
+ b = appendVarint(b, uint64(v))
+ }
+ return b, nil
+}
+func appendVarint64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toUint64()
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, v)
+ return b, nil
+}
+func appendVarint64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toUint64()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, v)
+ return b, nil
+}
+func appendVarint64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toUint64Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, *p)
+ return b, nil
+}
+func appendVarint64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toUint64Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, v)
+ }
+ return b, nil
+}
+func appendVarint64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toUint64Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ // compute size
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(v)
+ }
+ b = appendVarint(b, uint64(n))
+ for _, v := range s {
+ b = appendVarint(b, v)
+ }
+ return b, nil
+}
+func appendVarintS64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt64()
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ return b, nil
+}
+func appendVarintS64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt64()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ return b, nil
+}
+func appendVarintS64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toInt64Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(*p))
+ return b, nil
+}
+func appendVarintS64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toInt64Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v))
+ }
+ return b, nil
+}
+func appendVarintS64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toInt64Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ // compute size
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v))
+ }
+ b = appendVarint(b, uint64(n))
+ for _, v := range s {
+ b = appendVarint(b, uint64(v))
+ }
+ return b, nil
+}
+func appendZigzag32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt32()
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
+ return b, nil
+}
+func appendZigzag32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt32()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
+ return b, nil
+}
+func appendZigzag32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := ptr.getInt32Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ v := *p
+ b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
+ return b, nil
+}
+func appendZigzag32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := ptr.getInt32Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
+ }
+ return b, nil
+}
+func appendZigzag32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := ptr.getInt32Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ // compute size
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31))))
+ }
+ b = appendVarint(b, uint64(n))
+ for _, v := range s {
+ b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
+ }
+ return b, nil
+}
+func appendZigzag64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt64()
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
+ return b, nil
+}
+func appendZigzag64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toInt64()
+ if v == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
+ return b, nil
+}
+func appendZigzag64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toInt64Ptr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ v := *p
+ b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
+ return b, nil
+}
+func appendZigzag64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toInt64Slice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
+ }
+ return b, nil
+}
+func appendZigzag64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toInt64Slice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ // compute size
+ n := 0
+ for _, v := range s {
+ n += SizeVarint(uint64(v<<1) ^ uint64((int64(v) >> 63)))
+ }
+ b = appendVarint(b, uint64(n))
+ for _, v := range s {
+ b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
+ }
+ return b, nil
+}
+func appendBoolValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toBool()
+ b = appendVarint(b, wiretag)
+ if v {
+ b = append(b, 1)
+ } else {
+ b = append(b, 0)
+ }
+ return b, nil
+}
+func appendBoolValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toBool()
+ if !v {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = append(b, 1)
+ return b, nil
+}
+
+func appendBoolPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toBoolPtr()
+ if p == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ if *p {
+ b = append(b, 1)
+ } else {
+ b = append(b, 0)
+ }
+ return b, nil
+}
+func appendBoolSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toBoolSlice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ if v {
+ b = append(b, 1)
+ } else {
+ b = append(b, 0)
+ }
+ }
+ return b, nil
+}
+func appendBoolPackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toBoolSlice()
+ if len(s) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag&^7|WireBytes)
+ b = appendVarint(b, uint64(len(s)))
+ for _, v := range s {
+ if v {
+ b = append(b, 1)
+ } else {
+ b = append(b, 0)
+ }
+ }
+ return b, nil
+}
+func appendStringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toString()
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ return b, nil
+}
+func appendStringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toString()
+ if v == "" {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ return b, nil
+}
+func appendStringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ p := *ptr.toStringPtr()
+ if p == nil {
+ return b, nil
+ }
+ v := *p
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ return b, nil
+}
+func appendStringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toStringSlice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ }
+ return b, nil
+}
+func appendUTF8StringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ var invalidUTF8 bool
+ v := *ptr.toString()
+ if !utf8.ValidString(v) {
+ invalidUTF8 = true
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ if invalidUTF8 {
+ return b, errInvalidUTF8
+ }
+ return b, nil
+}
+func appendUTF8StringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ var invalidUTF8 bool
+ v := *ptr.toString()
+ if v == "" {
+ return b, nil
+ }
+ if !utf8.ValidString(v) {
+ invalidUTF8 = true
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ if invalidUTF8 {
+ return b, errInvalidUTF8
+ }
+ return b, nil
+}
+func appendUTF8StringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ var invalidUTF8 bool
+ p := *ptr.toStringPtr()
+ if p == nil {
+ return b, nil
+ }
+ v := *p
+ if !utf8.ValidString(v) {
+ invalidUTF8 = true
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ if invalidUTF8 {
+ return b, errInvalidUTF8
+ }
+ return b, nil
+}
+func appendUTF8StringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ var invalidUTF8 bool
+ s := *ptr.toStringSlice()
+ for _, v := range s {
+ if !utf8.ValidString(v) {
+ invalidUTF8 = true
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ }
+ if invalidUTF8 {
+ return b, errInvalidUTF8
+ }
+ return b, nil
+}
+func appendBytes(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toBytes()
+ if v == nil {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ return b, nil
+}
+func appendBytes3(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toBytes()
+ if len(v) == 0 {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ return b, nil
+}
+func appendBytesOneof(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ v := *ptr.toBytes()
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ return b, nil
+}
+func appendBytesSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toBytesSlice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ }
+ return b, nil
+}
+
+// makeGroupMarshaler returns the sizer and marshaler for a group.
+// u is the marshal info of the underlying message.
+func makeGroupMarshaler(u *marshalInfo) (sizer, marshaler) {
+ return func(ptr pointer, tagsize int) int {
+ p := ptr.getPointer()
+ if p.isNil() {
+ return 0
+ }
+ return u.size(p) + 2*tagsize
+ },
+ func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
+ p := ptr.getPointer()
+ if p.isNil() {
+ return b, nil
+ }
+ var err error
+ b = appendVarint(b, wiretag) // start group
+ b, err = u.marshal(b, p, deterministic)
+ b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group
+ return b, err
+ }
+}
+
+// makeGroupSliceMarshaler returns the sizer and marshaler for a group slice.
+// u is the marshal info of the underlying message.
+func makeGroupSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
+ return func(ptr pointer, tagsize int) int {
+ s := ptr.getPointerSlice()
+ n := 0
+ for _, v := range s {
+ if v.isNil() {
+ continue
+ }
+ n += u.size(v) + 2*tagsize
+ }
+ return n
+ },
+ func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
+ s := ptr.getPointerSlice()
+ var err error
+ var nerr nonFatal
+ for _, v := range s {
+ if v.isNil() {
+ return b, errRepeatedHasNil
+ }
+ b = appendVarint(b, wiretag) // start group
+ b, err = u.marshal(b, v, deterministic)
+ b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group
+ if !nerr.Merge(err) {
+ if err == ErrNil {
+ err = errRepeatedHasNil
+ }
+ return b, err
+ }
+ }
+ return b, nerr.E
+ }
+}
+
+// makeMessageMarshaler returns the sizer and marshaler for a message field.
+// u is the marshal info of the message.
+func makeMessageMarshaler(u *marshalInfo) (sizer, marshaler) {
+ return func(ptr pointer, tagsize int) int {
+ p := ptr.getPointer()
+ if p.isNil() {
+ return 0
+ }
+ siz := u.size(p)
+ return siz + SizeVarint(uint64(siz)) + tagsize
+ },
+ func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
+ p := ptr.getPointer()
+ if p.isNil() {
+ return b, nil
+ }
+ b = appendVarint(b, wiretag)
+ siz := u.cachedsize(p)
+ b = appendVarint(b, uint64(siz))
+ return u.marshal(b, p, deterministic)
+ }
+}
+
+// makeMessageSliceMarshaler returns the sizer and marshaler for a message slice.
+// u is the marshal info of the message.
+func makeMessageSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
+ return func(ptr pointer, tagsize int) int {
+ s := ptr.getPointerSlice()
+ n := 0
+ for _, v := range s {
+ if v.isNil() {
+ continue
+ }
+ siz := u.size(v)
+ n += siz + SizeVarint(uint64(siz)) + tagsize
+ }
+ return n
+ },
+ func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
+ s := ptr.getPointerSlice()
+ var err error
+ var nerr nonFatal
+ for _, v := range s {
+ if v.isNil() {
+ return b, errRepeatedHasNil
+ }
+ b = appendVarint(b, wiretag)
+ siz := u.cachedsize(v)
+ b = appendVarint(b, uint64(siz))
+ b, err = u.marshal(b, v, deterministic)
+
+ if !nerr.Merge(err) {
+ if err == ErrNil {
+ err = errRepeatedHasNil
+ }
+ return b, err
+ }
+ }
+ return b, nerr.E
+ }
+}
+
+// makeMapMarshaler returns the sizer and marshaler for a map field.
+// f is the pointer to the reflect data structure of the field.
+func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) {
+ // figure out key and value type
+ t := f.Type
+ keyType := t.Key()
+ valType := t.Elem()
+ keyTags := strings.Split(f.Tag.Get("protobuf_key"), ",")
+ valTags := strings.Split(f.Tag.Get("protobuf_val"), ",")
+ keySizer, keyMarshaler := typeMarshaler(keyType, keyTags, false, false) // don't omit zero value in map
+ valSizer, valMarshaler := typeMarshaler(valType, valTags, false, false) // don't omit zero value in map
+ keyWireTag := 1<<3 | wiretype(keyTags[0])
+ valWireTag := 2<<3 | wiretype(valTags[0])
+
+ // We create an interface to get the addresses of the map key and value.
+ // If value is pointer-typed, the interface is a direct interface, the
+ // idata itself is the value. Otherwise, the idata is the pointer to the
+ // value.
+ // Key cannot be pointer-typed.
+ valIsPtr := valType.Kind() == reflect.Ptr
+
+ // If value is a message with nested maps, calling
+ // valSizer in marshal may be quadratic. We should use
+ // cached version in marshal (but not in size).
+ // If value is not message type, we don't have size cache,
+ // but it cannot be nested either. Just use valSizer.
+ valCachedSizer := valSizer
+ if valIsPtr && valType.Elem().Kind() == reflect.Struct {
+ u := getMarshalInfo(valType.Elem())
+ valCachedSizer = func(ptr pointer, tagsize int) int {
+ // Same as message sizer, but use cache.
+ p := ptr.getPointer()
+ if p.isNil() {
+ return 0
+ }
+ siz := u.cachedsize(p)
+ return siz + SizeVarint(uint64(siz)) + tagsize
+ }
+ }
+ return func(ptr pointer, tagsize int) int {
+ m := ptr.asPointerTo(t).Elem() // the map
+ n := 0
+ for _, k := range m.MapKeys() {
+ ki := k.Interface()
+ vi := m.MapIndex(k).Interface()
+ kaddr := toAddrPointer(&ki, false, false) // pointer to key
+ vaddr := toAddrPointer(&vi, valIsPtr, false) // pointer to value
+ siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1)
+ n += siz + SizeVarint(uint64(siz)) + tagsize
+ }
+ return n
+ },
+ func(b []byte, ptr pointer, tag uint64, deterministic bool) ([]byte, error) {
+ m := ptr.asPointerTo(t).Elem() // the map
+ var err error
+ keys := m.MapKeys()
+ if len(keys) > 1 && deterministic {
+ sort.Sort(mapKeys(keys))
+ }
+
+ var nerr nonFatal
+ for _, k := range keys {
+ ki := k.Interface()
+ vi := m.MapIndex(k).Interface()
+ kaddr := toAddrPointer(&ki, false, false) // pointer to key
+ vaddr := toAddrPointer(&vi, valIsPtr, false) // pointer to value
+ b = appendVarint(b, tag)
+ siz := keySizer(kaddr, 1) + valCachedSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1)
+ b = appendVarint(b, uint64(siz))
+ b, err = keyMarshaler(b, kaddr, keyWireTag, deterministic)
+ if !nerr.Merge(err) {
+ return b, err
+ }
+ b, err = valMarshaler(b, vaddr, valWireTag, deterministic)
+ if err != ErrNil && !nerr.Merge(err) { // allow nil value in map
+ return b, err
+ }
+ }
+ return b, nerr.E
+ }
+}
+
+// makeOneOfMarshaler returns the sizer and marshaler for a oneof field.
+// fi is the marshal info of the field.
+// f is the pointer to the reflect data structure of the field.
+func makeOneOfMarshaler(fi *marshalFieldInfo, f *reflect.StructField) (sizer, marshaler) {
+ // Oneof field is an interface. We need to get the actual data type on the fly.
+ t := f.Type
+ return func(ptr pointer, _ int) int {
+ p := ptr.getInterfacePointer()
+ if p.isNil() {
+ return 0
+ }
+ v := ptr.asPointerTo(t).Elem().Elem().Elem() // *interface -> interface -> *struct -> struct
+ telem := v.Type()
+ e := fi.oneofElems[telem]
+ return e.sizer(p, e.tagsize)
+ },
+ func(b []byte, ptr pointer, _ uint64, deterministic bool) ([]byte, error) {
+ p := ptr.getInterfacePointer()
+ if p.isNil() {
+ return b, nil
+ }
+ v := ptr.asPointerTo(t).Elem().Elem().Elem() // *interface -> interface -> *struct -> struct
+ telem := v.Type()
+ if telem.Field(0).Type.Kind() == reflect.Ptr && p.getPointer().isNil() {
+ return b, errOneofHasNil
+ }
+ e := fi.oneofElems[telem]
+ return e.marshaler(b, p, e.wiretag, deterministic)
+ }
+}
+
+// sizeExtensions computes the size of encoded data for a XXX_InternalExtensions field.
+func (u *marshalInfo) sizeExtensions(ext *XXX_InternalExtensions) int {
+ m, mu := ext.extensionsRead()
+ if m == nil {
+ return 0
+ }
+ mu.Lock()
+
+ n := 0
+ for _, e := range m {
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ n += len(e.enc)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+ ei := u.getExtElemInfo(e.desc)
+ v := e.value
+ p := toAddrPointer(&v, ei.isptr, ei.deref)
+ n += ei.sizer(p, ei.tagsize)
+ }
+ mu.Unlock()
+ return n
+}
+
+// appendExtensions marshals a XXX_InternalExtensions field to the end of byte slice b.
+func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) {
+ m, mu := ext.extensionsRead()
+ if m == nil {
+ return b, nil
+ }
+ mu.Lock()
+ defer mu.Unlock()
+
+ var err error
+ var nerr nonFatal
+
+ // Fast-path for common cases: zero or one extensions.
+ // Don't bother sorting the keys.
+ if len(m) <= 1 {
+ for _, e := range m {
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ b = append(b, e.enc...)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ ei := u.getExtElemInfo(e.desc)
+ v := e.value
+ p := toAddrPointer(&v, ei.isptr, ei.deref)
+ b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
+ if !nerr.Merge(err) {
+ return b, err
+ }
+ }
+ return b, nerr.E
+ }
+
+ // Sort the keys to provide a deterministic encoding.
+ // Not sure this is required, but the old code does it.
+ keys := make([]int, 0, len(m))
+ for k := range m {
+ keys = append(keys, int(k))
+ }
+ sort.Ints(keys)
+
+ for _, k := range keys {
+ e := m[int32(k)]
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ b = append(b, e.enc...)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ ei := u.getExtElemInfo(e.desc)
+ v := e.value
+ p := toAddrPointer(&v, ei.isptr, ei.deref)
+ b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
+ if !nerr.Merge(err) {
+ return b, err
+ }
+ }
+ return b, nerr.E
+}
+
+// message set format is:
+// message MessageSet {
+// repeated group Item = 1 {
+// required int32 type_id = 2;
+// required string message = 3;
+// };
+// }
+
+// sizeMessageSet computes the size of encoded data for a XXX_InternalExtensions field
+// in message set format (above).
+func (u *marshalInfo) sizeMessageSet(ext *XXX_InternalExtensions) int {
+ m, mu := ext.extensionsRead()
+ if m == nil {
+ return 0
+ }
+ mu.Lock()
+
+ n := 0
+ for id, e := range m {
+ n += 2 // start group, end group. tag = 1 (size=1)
+ n += SizeVarint(uint64(id)) + 1 // type_id, tag = 2 (size=1)
+
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint
+ siz := len(msgWithLen)
+ n += siz + 1 // message, tag = 3 (size=1)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ ei := u.getExtElemInfo(e.desc)
+ v := e.value
+ p := toAddrPointer(&v, ei.isptr, ei.deref)
+ n += ei.sizer(p, 1) // message, tag = 3 (size=1)
+ }
+ mu.Unlock()
+ return n
+}
+
+// appendMessageSet marshals a XXX_InternalExtensions field in message set format (above)
+// to the end of byte slice b.
+func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) {
+ m, mu := ext.extensionsRead()
+ if m == nil {
+ return b, nil
+ }
+ mu.Lock()
+ defer mu.Unlock()
+
+ var err error
+ var nerr nonFatal
+
+ // Fast-path for common cases: zero or one extensions.
+ // Don't bother sorting the keys.
+ if len(m) <= 1 {
+ for id, e := range m {
+ b = append(b, 1<<3|WireStartGroup)
+ b = append(b, 2<<3|WireVarint)
+ b = appendVarint(b, uint64(id))
+
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint
+ b = append(b, 3<<3|WireBytes)
+ b = append(b, msgWithLen...)
+ b = append(b, 1<<3|WireEndGroup)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ ei := u.getExtElemInfo(e.desc)
+ v := e.value
+ p := toAddrPointer(&v, ei.isptr, ei.deref)
+ b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
+ if !nerr.Merge(err) {
+ return b, err
+ }
+ b = append(b, 1<<3|WireEndGroup)
+ }
+ return b, nerr.E
+ }
+
+ // Sort the keys to provide a deterministic encoding.
+ keys := make([]int, 0, len(m))
+ for k := range m {
+ keys = append(keys, int(k))
+ }
+ sort.Ints(keys)
+
+ for _, id := range keys {
+ e := m[int32(id)]
+ b = append(b, 1<<3|WireStartGroup)
+ b = append(b, 2<<3|WireVarint)
+ b = appendVarint(b, uint64(id))
+
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint
+ b = append(b, 3<<3|WireBytes)
+ b = append(b, msgWithLen...)
+ b = append(b, 1<<3|WireEndGroup)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ ei := u.getExtElemInfo(e.desc)
+ v := e.value
+ p := toAddrPointer(&v, ei.isptr, ei.deref)
+ b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
+ b = append(b, 1<<3|WireEndGroup)
+ if !nerr.Merge(err) {
+ return b, err
+ }
+ }
+ return b, nerr.E
+}
+
+// sizeV1Extensions computes the size of encoded data for a V1-API extension field.
+func (u *marshalInfo) sizeV1Extensions(m map[int32]Extension) int {
+ if m == nil {
+ return 0
+ }
+
+ n := 0
+ for _, e := range m {
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ n += len(e.enc)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ ei := u.getExtElemInfo(e.desc)
+ v := e.value
+ p := toAddrPointer(&v, ei.isptr, ei.deref)
+ n += ei.sizer(p, ei.tagsize)
+ }
+ return n
+}
+
+// appendV1Extensions marshals a V1-API extension field to the end of byte slice b.
+func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, deterministic bool) ([]byte, error) {
+ if m == nil {
+ return b, nil
+ }
+
+ // Sort the keys to provide a deterministic encoding.
+ keys := make([]int, 0, len(m))
+ for k := range m {
+ keys = append(keys, int(k))
+ }
+ sort.Ints(keys)
+
+ var err error
+ var nerr nonFatal
+ for _, k := range keys {
+ e := m[int32(k)]
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ b = append(b, e.enc...)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ ei := u.getExtElemInfo(e.desc)
+ v := e.value
+ p := toAddrPointer(&v, ei.isptr, ei.deref)
+ b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
+ if !nerr.Merge(err) {
+ return b, err
+ }
+ }
+ return b, nerr.E
+}
+
+// newMarshaler is the interface representing objects that can marshal themselves.
+//
+// This exists to support protoc-gen-go generated messages.
+// The proto package will stop type-asserting to this interface in the future.
+//
+// DO NOT DEPEND ON THIS.
+type newMarshaler interface {
+ XXX_Size() int
+ XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
+}
+
+// Size returns the encoded size of a protocol buffer message.
+// This is the main entry point.
+func Size(pb Message) int {
+ if m, ok := pb.(newMarshaler); ok {
+ return m.XXX_Size()
+ }
+ if m, ok := pb.(Marshaler); ok {
+ // If the message can marshal itself, let it do it, for compatibility.
+ // NOTE: This is not efficient.
+ b, _ := m.Marshal()
+ return len(b)
+ }
+ // in case somehow we didn't generate the wrapper
+ if pb == nil {
+ return 0
+ }
+ var info InternalMessageInfo
+ return info.Size(pb)
+}
+
+// Marshal takes a protocol buffer message
+// and encodes it into the wire format, returning the data.
+// This is the main entry point.
+func Marshal(pb Message) ([]byte, error) {
+ if m, ok := pb.(newMarshaler); ok {
+ siz := m.XXX_Size()
+ b := make([]byte, 0, siz)
+ return m.XXX_Marshal(b, false)
+ }
+ if m, ok := pb.(Marshaler); ok {
+ // If the message can marshal itself, let it do it, for compatibility.
+ // NOTE: This is not efficient.
+ return m.Marshal()
+ }
+ // in case somehow we didn't generate the wrapper
+ if pb == nil {
+ return nil, ErrNil
+ }
+ var info InternalMessageInfo
+ siz := info.Size(pb)
+ b := make([]byte, 0, siz)
+ return info.Marshal(b, pb, false)
+}
+
+// Marshal takes a protocol buffer message
+// and encodes it into the wire format, writing the result to the
+// Buffer.
+// This is an alternative entry point. It is not necessary to use
+// a Buffer for most applications.
+func (p *Buffer) Marshal(pb Message) error {
+ var err error
+ if m, ok := pb.(newMarshaler); ok {
+ siz := m.XXX_Size()
+ p.grow(siz) // make sure buf has enough capacity
+ p.buf, err = m.XXX_Marshal(p.buf, p.deterministic)
+ return err
+ }
+ if m, ok := pb.(Marshaler); ok {
+ // If the message can marshal itself, let it do it, for compatibility.
+ // NOTE: This is not efficient.
+ b, err := m.Marshal()
+ p.buf = append(p.buf, b...)
+ return err
+ }
+ // in case somehow we didn't generate the wrapper
+ if pb == nil {
+ return ErrNil
+ }
+ var info InternalMessageInfo
+ siz := info.Size(pb)
+ p.grow(siz) // make sure buf has enough capacity
+ p.buf, err = info.Marshal(p.buf, pb, p.deterministic)
+ return err
+}
+
+// grow grows the buffer's capacity, if necessary, to guarantee space for
+// another n bytes. After grow(n), at least n bytes can be written to the
+// buffer without another allocation.
+func (p *Buffer) grow(n int) {
+ need := len(p.buf) + n
+ if need <= cap(p.buf) {
+ return
+ }
+ newCap := len(p.buf) * 2
+ if newCap < need {
+ newCap = need
+ }
+ p.buf = append(make([]byte, 0, newCap), p.buf...)
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_merge.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_merge.go
new file mode 100644
index 00000000..5525def6
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_merge.go
@@ -0,0 +1,654 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2016 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+import (
+ "fmt"
+ "reflect"
+ "strings"
+ "sync"
+ "sync/atomic"
+)
+
+// Merge merges the src message into dst.
+// This assumes that dst and src of the same type and are non-nil.
+func (a *InternalMessageInfo) Merge(dst, src Message) {
+ mi := atomicLoadMergeInfo(&a.merge)
+ if mi == nil {
+ mi = getMergeInfo(reflect.TypeOf(dst).Elem())
+ atomicStoreMergeInfo(&a.merge, mi)
+ }
+ mi.merge(toPointer(&dst), toPointer(&src))
+}
+
+type mergeInfo struct {
+ typ reflect.Type
+
+ initialized int32 // 0: only typ is valid, 1: everything is valid
+ lock sync.Mutex
+
+ fields []mergeFieldInfo
+ unrecognized field // Offset of XXX_unrecognized
+}
+
+type mergeFieldInfo struct {
+ field field // Offset of field, guaranteed to be valid
+
+ // isPointer reports whether the value in the field is a pointer.
+ // This is true for the following situations:
+ // * Pointer to struct
+ // * Pointer to basic type (proto2 only)
+ // * Slice (first value in slice header is a pointer)
+ // * String (first value in string header is a pointer)
+ isPointer bool
+
+ // basicWidth reports the width of the field assuming that it is directly
+ // embedded in the struct (as is the case for basic types in proto3).
+ // The possible values are:
+ // 0: invalid
+ // 1: bool
+ // 4: int32, uint32, float32
+ // 8: int64, uint64, float64
+ basicWidth int
+
+ // Where dst and src are pointers to the types being merged.
+ merge func(dst, src pointer)
+}
+
+var (
+ mergeInfoMap = map[reflect.Type]*mergeInfo{}
+ mergeInfoLock sync.Mutex
+)
+
+func getMergeInfo(t reflect.Type) *mergeInfo {
+ mergeInfoLock.Lock()
+ defer mergeInfoLock.Unlock()
+ mi := mergeInfoMap[t]
+ if mi == nil {
+ mi = &mergeInfo{typ: t}
+ mergeInfoMap[t] = mi
+ }
+ return mi
+}
+
+// merge merges src into dst assuming they are both of type *mi.typ.
+func (mi *mergeInfo) merge(dst, src pointer) {
+ if dst.isNil() {
+ panic("proto: nil destination")
+ }
+ if src.isNil() {
+ return // Nothing to do.
+ }
+
+ if atomic.LoadInt32(&mi.initialized) == 0 {
+ mi.computeMergeInfo()
+ }
+
+ for _, fi := range mi.fields {
+ sfp := src.offset(fi.field)
+
+ // As an optimization, we can avoid the merge function call cost
+ // if we know for sure that the source will have no effect
+ // by checking if it is the zero value.
+ if unsafeAllowed {
+ if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string
+ continue
+ }
+ if fi.basicWidth > 0 {
+ switch {
+ case fi.basicWidth == 1 && !*sfp.toBool():
+ continue
+ case fi.basicWidth == 4 && *sfp.toUint32() == 0:
+ continue
+ case fi.basicWidth == 8 && *sfp.toUint64() == 0:
+ continue
+ }
+ }
+ }
+
+ dfp := dst.offset(fi.field)
+ fi.merge(dfp, sfp)
+ }
+
+ // TODO: Make this faster?
+ out := dst.asPointerTo(mi.typ).Elem()
+ in := src.asPointerTo(mi.typ).Elem()
+ if emIn, err := extendable(in.Addr().Interface()); err == nil {
+ emOut, _ := extendable(out.Addr().Interface())
+ mIn, muIn := emIn.extensionsRead()
+ if mIn != nil {
+ mOut := emOut.extensionsWrite()
+ muIn.Lock()
+ mergeExtension(mOut, mIn)
+ muIn.Unlock()
+ }
+ }
+
+ if mi.unrecognized.IsValid() {
+ if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 {
+ *dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...)
+ }
+ }
+}
+
+func (mi *mergeInfo) computeMergeInfo() {
+ mi.lock.Lock()
+ defer mi.lock.Unlock()
+ if mi.initialized != 0 {
+ return
+ }
+ t := mi.typ
+ n := t.NumField()
+
+ props := GetProperties(t)
+ for i := 0; i < n; i++ {
+ f := t.Field(i)
+ if strings.HasPrefix(f.Name, "XXX_") {
+ continue
+ }
+
+ mfi := mergeFieldInfo{field: toField(&f)}
+ tf := f.Type
+
+ // As an optimization, we can avoid the merge function call cost
+ // if we know for sure that the source will have no effect
+ // by checking if it is the zero value.
+ if unsafeAllowed {
+ switch tf.Kind() {
+ case reflect.Ptr, reflect.Slice, reflect.String:
+ // As a special case, we assume slices and strings are pointers
+ // since we know that the first field in the SliceSlice or
+ // StringHeader is a data pointer.
+ mfi.isPointer = true
+ case reflect.Bool:
+ mfi.basicWidth = 1
+ case reflect.Int32, reflect.Uint32, reflect.Float32:
+ mfi.basicWidth = 4
+ case reflect.Int64, reflect.Uint64, reflect.Float64:
+ mfi.basicWidth = 8
+ }
+ }
+
+ // Unwrap tf to get at its most basic type.
+ var isPointer, isSlice bool
+ if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
+ isSlice = true
+ tf = tf.Elem()
+ }
+ if tf.Kind() == reflect.Ptr {
+ isPointer = true
+ tf = tf.Elem()
+ }
+ if isPointer && isSlice && tf.Kind() != reflect.Struct {
+ panic("both pointer and slice for basic type in " + tf.Name())
+ }
+
+ switch tf.Kind() {
+ case reflect.Int32:
+ switch {
+ case isSlice: // E.g., []int32
+ mfi.merge = func(dst, src pointer) {
+ // NOTE: toInt32Slice is not defined (see pointer_reflect.go).
+ /*
+ sfsp := src.toInt32Slice()
+ if *sfsp != nil {
+ dfsp := dst.toInt32Slice()
+ *dfsp = append(*dfsp, *sfsp...)
+ if *dfsp == nil {
+ *dfsp = []int64{}
+ }
+ }
+ */
+ sfs := src.getInt32Slice()
+ if sfs != nil {
+ dfs := dst.getInt32Slice()
+ dfs = append(dfs, sfs...)
+ if dfs == nil {
+ dfs = []int32{}
+ }
+ dst.setInt32Slice(dfs)
+ }
+ }
+ case isPointer: // E.g., *int32
+ mfi.merge = func(dst, src pointer) {
+ // NOTE: toInt32Ptr is not defined (see pointer_reflect.go).
+ /*
+ sfpp := src.toInt32Ptr()
+ if *sfpp != nil {
+ dfpp := dst.toInt32Ptr()
+ if *dfpp == nil {
+ *dfpp = Int32(**sfpp)
+ } else {
+ **dfpp = **sfpp
+ }
+ }
+ */
+ sfp := src.getInt32Ptr()
+ if sfp != nil {
+ dfp := dst.getInt32Ptr()
+ if dfp == nil {
+ dst.setInt32Ptr(*sfp)
+ } else {
+ *dfp = *sfp
+ }
+ }
+ }
+ default: // E.g., int32
+ mfi.merge = func(dst, src pointer) {
+ if v := *src.toInt32(); v != 0 {
+ *dst.toInt32() = v
+ }
+ }
+ }
+ case reflect.Int64:
+ switch {
+ case isSlice: // E.g., []int64
+ mfi.merge = func(dst, src pointer) {
+ sfsp := src.toInt64Slice()
+ if *sfsp != nil {
+ dfsp := dst.toInt64Slice()
+ *dfsp = append(*dfsp, *sfsp...)
+ if *dfsp == nil {
+ *dfsp = []int64{}
+ }
+ }
+ }
+ case isPointer: // E.g., *int64
+ mfi.merge = func(dst, src pointer) {
+ sfpp := src.toInt64Ptr()
+ if *sfpp != nil {
+ dfpp := dst.toInt64Ptr()
+ if *dfpp == nil {
+ *dfpp = Int64(**sfpp)
+ } else {
+ **dfpp = **sfpp
+ }
+ }
+ }
+ default: // E.g., int64
+ mfi.merge = func(dst, src pointer) {
+ if v := *src.toInt64(); v != 0 {
+ *dst.toInt64() = v
+ }
+ }
+ }
+ case reflect.Uint32:
+ switch {
+ case isSlice: // E.g., []uint32
+ mfi.merge = func(dst, src pointer) {
+ sfsp := src.toUint32Slice()
+ if *sfsp != nil {
+ dfsp := dst.toUint32Slice()
+ *dfsp = append(*dfsp, *sfsp...)
+ if *dfsp == nil {
+ *dfsp = []uint32{}
+ }
+ }
+ }
+ case isPointer: // E.g., *uint32
+ mfi.merge = func(dst, src pointer) {
+ sfpp := src.toUint32Ptr()
+ if *sfpp != nil {
+ dfpp := dst.toUint32Ptr()
+ if *dfpp == nil {
+ *dfpp = Uint32(**sfpp)
+ } else {
+ **dfpp = **sfpp
+ }
+ }
+ }
+ default: // E.g., uint32
+ mfi.merge = func(dst, src pointer) {
+ if v := *src.toUint32(); v != 0 {
+ *dst.toUint32() = v
+ }
+ }
+ }
+ case reflect.Uint64:
+ switch {
+ case isSlice: // E.g., []uint64
+ mfi.merge = func(dst, src pointer) {
+ sfsp := src.toUint64Slice()
+ if *sfsp != nil {
+ dfsp := dst.toUint64Slice()
+ *dfsp = append(*dfsp, *sfsp...)
+ if *dfsp == nil {
+ *dfsp = []uint64{}
+ }
+ }
+ }
+ case isPointer: // E.g., *uint64
+ mfi.merge = func(dst, src pointer) {
+ sfpp := src.toUint64Ptr()
+ if *sfpp != nil {
+ dfpp := dst.toUint64Ptr()
+ if *dfpp == nil {
+ *dfpp = Uint64(**sfpp)
+ } else {
+ **dfpp = **sfpp
+ }
+ }
+ }
+ default: // E.g., uint64
+ mfi.merge = func(dst, src pointer) {
+ if v := *src.toUint64(); v != 0 {
+ *dst.toUint64() = v
+ }
+ }
+ }
+ case reflect.Float32:
+ switch {
+ case isSlice: // E.g., []float32
+ mfi.merge = func(dst, src pointer) {
+ sfsp := src.toFloat32Slice()
+ if *sfsp != nil {
+ dfsp := dst.toFloat32Slice()
+ *dfsp = append(*dfsp, *sfsp...)
+ if *dfsp == nil {
+ *dfsp = []float32{}
+ }
+ }
+ }
+ case isPointer: // E.g., *float32
+ mfi.merge = func(dst, src pointer) {
+ sfpp := src.toFloat32Ptr()
+ if *sfpp != nil {
+ dfpp := dst.toFloat32Ptr()
+ if *dfpp == nil {
+ *dfpp = Float32(**sfpp)
+ } else {
+ **dfpp = **sfpp
+ }
+ }
+ }
+ default: // E.g., float32
+ mfi.merge = func(dst, src pointer) {
+ if v := *src.toFloat32(); v != 0 {
+ *dst.toFloat32() = v
+ }
+ }
+ }
+ case reflect.Float64:
+ switch {
+ case isSlice: // E.g., []float64
+ mfi.merge = func(dst, src pointer) {
+ sfsp := src.toFloat64Slice()
+ if *sfsp != nil {
+ dfsp := dst.toFloat64Slice()
+ *dfsp = append(*dfsp, *sfsp...)
+ if *dfsp == nil {
+ *dfsp = []float64{}
+ }
+ }
+ }
+ case isPointer: // E.g., *float64
+ mfi.merge = func(dst, src pointer) {
+ sfpp := src.toFloat64Ptr()
+ if *sfpp != nil {
+ dfpp := dst.toFloat64Ptr()
+ if *dfpp == nil {
+ *dfpp = Float64(**sfpp)
+ } else {
+ **dfpp = **sfpp
+ }
+ }
+ }
+ default: // E.g., float64
+ mfi.merge = func(dst, src pointer) {
+ if v := *src.toFloat64(); v != 0 {
+ *dst.toFloat64() = v
+ }
+ }
+ }
+ case reflect.Bool:
+ switch {
+ case isSlice: // E.g., []bool
+ mfi.merge = func(dst, src pointer) {
+ sfsp := src.toBoolSlice()
+ if *sfsp != nil {
+ dfsp := dst.toBoolSlice()
+ *dfsp = append(*dfsp, *sfsp...)
+ if *dfsp == nil {
+ *dfsp = []bool{}
+ }
+ }
+ }
+ case isPointer: // E.g., *bool
+ mfi.merge = func(dst, src pointer) {
+ sfpp := src.toBoolPtr()
+ if *sfpp != nil {
+ dfpp := dst.toBoolPtr()
+ if *dfpp == nil {
+ *dfpp = Bool(**sfpp)
+ } else {
+ **dfpp = **sfpp
+ }
+ }
+ }
+ default: // E.g., bool
+ mfi.merge = func(dst, src pointer) {
+ if v := *src.toBool(); v {
+ *dst.toBool() = v
+ }
+ }
+ }
+ case reflect.String:
+ switch {
+ case isSlice: // E.g., []string
+ mfi.merge = func(dst, src pointer) {
+ sfsp := src.toStringSlice()
+ if *sfsp != nil {
+ dfsp := dst.toStringSlice()
+ *dfsp = append(*dfsp, *sfsp...)
+ if *dfsp == nil {
+ *dfsp = []string{}
+ }
+ }
+ }
+ case isPointer: // E.g., *string
+ mfi.merge = func(dst, src pointer) {
+ sfpp := src.toStringPtr()
+ if *sfpp != nil {
+ dfpp := dst.toStringPtr()
+ if *dfpp == nil {
+ *dfpp = String(**sfpp)
+ } else {
+ **dfpp = **sfpp
+ }
+ }
+ }
+ default: // E.g., string
+ mfi.merge = func(dst, src pointer) {
+ if v := *src.toString(); v != "" {
+ *dst.toString() = v
+ }
+ }
+ }
+ case reflect.Slice:
+ isProto3 := props.Prop[i].proto3
+ switch {
+ case isPointer:
+ panic("bad pointer in byte slice case in " + tf.Name())
+ case tf.Elem().Kind() != reflect.Uint8:
+ panic("bad element kind in byte slice case in " + tf.Name())
+ case isSlice: // E.g., [][]byte
+ mfi.merge = func(dst, src pointer) {
+ sbsp := src.toBytesSlice()
+ if *sbsp != nil {
+ dbsp := dst.toBytesSlice()
+ for _, sb := range *sbsp {
+ if sb == nil {
+ *dbsp = append(*dbsp, nil)
+ } else {
+ *dbsp = append(*dbsp, append([]byte{}, sb...))
+ }
+ }
+ if *dbsp == nil {
+ *dbsp = [][]byte{}
+ }
+ }
+ }
+ default: // E.g., []byte
+ mfi.merge = func(dst, src pointer) {
+ sbp := src.toBytes()
+ if *sbp != nil {
+ dbp := dst.toBytes()
+ if !isProto3 || len(*sbp) > 0 {
+ *dbp = append([]byte{}, *sbp...)
+ }
+ }
+ }
+ }
+ case reflect.Struct:
+ switch {
+ case !isPointer:
+ panic(fmt.Sprintf("message field %s without pointer", tf))
+ case isSlice: // E.g., []*pb.T
+ mi := getMergeInfo(tf)
+ mfi.merge = func(dst, src pointer) {
+ sps := src.getPointerSlice()
+ if sps != nil {
+ dps := dst.getPointerSlice()
+ for _, sp := range sps {
+ var dp pointer
+ if !sp.isNil() {
+ dp = valToPointer(reflect.New(tf))
+ mi.merge(dp, sp)
+ }
+ dps = append(dps, dp)
+ }
+ if dps == nil {
+ dps = []pointer{}
+ }
+ dst.setPointerSlice(dps)
+ }
+ }
+ default: // E.g., *pb.T
+ mi := getMergeInfo(tf)
+ mfi.merge = func(dst, src pointer) {
+ sp := src.getPointer()
+ if !sp.isNil() {
+ dp := dst.getPointer()
+ if dp.isNil() {
+ dp = valToPointer(reflect.New(tf))
+ dst.setPointer(dp)
+ }
+ mi.merge(dp, sp)
+ }
+ }
+ }
+ case reflect.Map:
+ switch {
+ case isPointer || isSlice:
+ panic("bad pointer or slice in map case in " + tf.Name())
+ default: // E.g., map[K]V
+ mfi.merge = func(dst, src pointer) {
+ sm := src.asPointerTo(tf).Elem()
+ if sm.Len() == 0 {
+ return
+ }
+ dm := dst.asPointerTo(tf).Elem()
+ if dm.IsNil() {
+ dm.Set(reflect.MakeMap(tf))
+ }
+
+ switch tf.Elem().Kind() {
+ case reflect.Ptr: // Proto struct (e.g., *T)
+ for _, key := range sm.MapKeys() {
+ val := sm.MapIndex(key)
+ val = reflect.ValueOf(Clone(val.Interface().(Message)))
+ dm.SetMapIndex(key, val)
+ }
+ case reflect.Slice: // E.g. Bytes type (e.g., []byte)
+ for _, key := range sm.MapKeys() {
+ val := sm.MapIndex(key)
+ val = reflect.ValueOf(append([]byte{}, val.Bytes()...))
+ dm.SetMapIndex(key, val)
+ }
+ default: // Basic type (e.g., string)
+ for _, key := range sm.MapKeys() {
+ val := sm.MapIndex(key)
+ dm.SetMapIndex(key, val)
+ }
+ }
+ }
+ }
+ case reflect.Interface:
+ // Must be oneof field.
+ switch {
+ case isPointer || isSlice:
+ panic("bad pointer or slice in interface case in " + tf.Name())
+ default: // E.g., interface{}
+ // TODO: Make this faster?
+ mfi.merge = func(dst, src pointer) {
+ su := src.asPointerTo(tf).Elem()
+ if !su.IsNil() {
+ du := dst.asPointerTo(tf).Elem()
+ typ := su.Elem().Type()
+ if du.IsNil() || du.Elem().Type() != typ {
+ du.Set(reflect.New(typ.Elem())) // Initialize interface if empty
+ }
+ sv := su.Elem().Elem().Field(0)
+ if sv.Kind() == reflect.Ptr && sv.IsNil() {
+ return
+ }
+ dv := du.Elem().Elem().Field(0)
+ if dv.Kind() == reflect.Ptr && dv.IsNil() {
+ dv.Set(reflect.New(sv.Type().Elem())) // Initialize proto message if empty
+ }
+ switch sv.Type().Kind() {
+ case reflect.Ptr: // Proto struct (e.g., *T)
+ Merge(dv.Interface().(Message), sv.Interface().(Message))
+ case reflect.Slice: // E.g. Bytes type (e.g., []byte)
+ dv.Set(reflect.ValueOf(append([]byte{}, sv.Bytes()...)))
+ default: // Basic type (e.g., string)
+ dv.Set(sv)
+ }
+ }
+ }
+ }
+ default:
+ panic(fmt.Sprintf("merger not found for type:%s", tf))
+ }
+ mi.fields = append(mi.fields, mfi)
+ }
+
+ mi.unrecognized = invalidField
+ if f, ok := t.FieldByName("XXX_unrecognized"); ok {
+ if f.Type != reflect.TypeOf([]byte{}) {
+ panic("expected XXX_unrecognized to be of type []byte")
+ }
+ mi.unrecognized = toField(&f)
+ }
+
+ atomic.StoreInt32(&mi.initialized, 1)
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_unmarshal.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_unmarshal.go
new file mode 100644
index 00000000..acee2fc5
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/table_unmarshal.go
@@ -0,0 +1,2053 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2016 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "math"
+ "reflect"
+ "strconv"
+ "strings"
+ "sync"
+ "sync/atomic"
+ "unicode/utf8"
+)
+
+// Unmarshal is the entry point from the generated .pb.go files.
+// This function is not intended to be used by non-generated code.
+// This function is not subject to any compatibility guarantee.
+// msg contains a pointer to a protocol buffer struct.
+// b is the data to be unmarshaled into the protocol buffer.
+// a is a pointer to a place to store cached unmarshal information.
+func (a *InternalMessageInfo) Unmarshal(msg Message, b []byte) error {
+ // Load the unmarshal information for this message type.
+ // The atomic load ensures memory consistency.
+ u := atomicLoadUnmarshalInfo(&a.unmarshal)
+ if u == nil {
+ // Slow path: find unmarshal info for msg, update a with it.
+ u = getUnmarshalInfo(reflect.TypeOf(msg).Elem())
+ atomicStoreUnmarshalInfo(&a.unmarshal, u)
+ }
+ // Then do the unmarshaling.
+ err := u.unmarshal(toPointer(&msg), b)
+ return err
+}
+
+type unmarshalInfo struct {
+ typ reflect.Type // type of the protobuf struct
+
+ // 0 = only typ field is initialized
+ // 1 = completely initialized
+ initialized int32
+ lock sync.Mutex // prevents double initialization
+ dense []unmarshalFieldInfo // fields indexed by tag #
+ sparse map[uint64]unmarshalFieldInfo // fields indexed by tag #
+ reqFields []string // names of required fields
+ reqMask uint64 // 1< 0 {
+ // Read tag and wire type.
+ // Special case 1 and 2 byte varints.
+ var x uint64
+ if b[0] < 128 {
+ x = uint64(b[0])
+ b = b[1:]
+ } else if len(b) >= 2 && b[1] < 128 {
+ x = uint64(b[0]&0x7f) + uint64(b[1])<<7
+ b = b[2:]
+ } else {
+ var n int
+ x, n = decodeVarint(b)
+ if n == 0 {
+ return io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ }
+ tag := x >> 3
+ wire := int(x) & 7
+
+ // Dispatch on the tag to one of the unmarshal* functions below.
+ var f unmarshalFieldInfo
+ if tag < uint64(len(u.dense)) {
+ f = u.dense[tag]
+ } else {
+ f = u.sparse[tag]
+ }
+ if fn := f.unmarshal; fn != nil {
+ var err error
+ b, err = fn(b, m.offset(f.field), wire)
+ if err == nil {
+ reqMask |= f.reqMask
+ continue
+ }
+ if r, ok := err.(*RequiredNotSetError); ok {
+ // Remember this error, but keep parsing. We need to produce
+ // a full parse even if a required field is missing.
+ if errLater == nil {
+ errLater = r
+ }
+ reqMask |= f.reqMask
+ continue
+ }
+ if err != errInternalBadWireType {
+ if err == errInvalidUTF8 {
+ if errLater == nil {
+ fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name
+ errLater = &invalidUTF8Error{fullName}
+ }
+ continue
+ }
+ return err
+ }
+ // Fragments with bad wire type are treated as unknown fields.
+ }
+
+ // Unknown tag.
+ if !u.unrecognized.IsValid() {
+ // Don't keep unrecognized data; just skip it.
+ var err error
+ b, err = skipField(b, wire)
+ if err != nil {
+ return err
+ }
+ continue
+ }
+ // Keep unrecognized data around.
+ // maybe in extensions, maybe in the unrecognized field.
+ z := m.offset(u.unrecognized).toBytes()
+ var emap map[int32]Extension
+ var e Extension
+ for _, r := range u.extensionRanges {
+ if uint64(r.Start) <= tag && tag <= uint64(r.End) {
+ if u.extensions.IsValid() {
+ mp := m.offset(u.extensions).toExtensions()
+ emap = mp.extensionsWrite()
+ e = emap[int32(tag)]
+ z = &e.enc
+ break
+ }
+ if u.oldExtensions.IsValid() {
+ p := m.offset(u.oldExtensions).toOldExtensions()
+ emap = *p
+ if emap == nil {
+ emap = map[int32]Extension{}
+ *p = emap
+ }
+ e = emap[int32(tag)]
+ z = &e.enc
+ break
+ }
+ panic("no extensions field available")
+ }
+ }
+
+ // Use wire type to skip data.
+ var err error
+ b0 := b
+ b, err = skipField(b, wire)
+ if err != nil {
+ return err
+ }
+ *z = encodeVarint(*z, tag<<3|uint64(wire))
+ *z = append(*z, b0[:len(b0)-len(b)]...)
+
+ if emap != nil {
+ emap[int32(tag)] = e
+ }
+ }
+ if reqMask != u.reqMask && errLater == nil {
+ // A required field of this message is missing.
+ for _, n := range u.reqFields {
+ if reqMask&1 == 0 {
+ errLater = &RequiredNotSetError{n}
+ }
+ reqMask >>= 1
+ }
+ }
+ return errLater
+}
+
+// computeUnmarshalInfo fills in u with information for use
+// in unmarshaling protocol buffers of type u.typ.
+func (u *unmarshalInfo) computeUnmarshalInfo() {
+ u.lock.Lock()
+ defer u.lock.Unlock()
+ if u.initialized != 0 {
+ return
+ }
+ t := u.typ
+ n := t.NumField()
+
+ // Set up the "not found" value for the unrecognized byte buffer.
+ // This is the default for proto3.
+ u.unrecognized = invalidField
+ u.extensions = invalidField
+ u.oldExtensions = invalidField
+
+ // List of the generated type and offset for each oneof field.
+ type oneofField struct {
+ ityp reflect.Type // interface type of oneof field
+ field field // offset in containing message
+ }
+ var oneofFields []oneofField
+
+ for i := 0; i < n; i++ {
+ f := t.Field(i)
+ if f.Name == "XXX_unrecognized" {
+ // The byte slice used to hold unrecognized input is special.
+ if f.Type != reflect.TypeOf(([]byte)(nil)) {
+ panic("bad type for XXX_unrecognized field: " + f.Type.Name())
+ }
+ u.unrecognized = toField(&f)
+ continue
+ }
+ if f.Name == "XXX_InternalExtensions" {
+ // Ditto here.
+ if f.Type != reflect.TypeOf(XXX_InternalExtensions{}) {
+ panic("bad type for XXX_InternalExtensions field: " + f.Type.Name())
+ }
+ u.extensions = toField(&f)
+ if f.Tag.Get("protobuf_messageset") == "1" {
+ u.isMessageSet = true
+ }
+ continue
+ }
+ if f.Name == "XXX_extensions" {
+ // An older form of the extensions field.
+ if f.Type != reflect.TypeOf((map[int32]Extension)(nil)) {
+ panic("bad type for XXX_extensions field: " + f.Type.Name())
+ }
+ u.oldExtensions = toField(&f)
+ continue
+ }
+ if f.Name == "XXX_NoUnkeyedLiteral" || f.Name == "XXX_sizecache" {
+ continue
+ }
+
+ oneof := f.Tag.Get("protobuf_oneof")
+ if oneof != "" {
+ oneofFields = append(oneofFields, oneofField{f.Type, toField(&f)})
+ // The rest of oneof processing happens below.
+ continue
+ }
+
+ tags := f.Tag.Get("protobuf")
+ tagArray := strings.Split(tags, ",")
+ if len(tagArray) < 2 {
+ panic("protobuf tag not enough fields in " + t.Name() + "." + f.Name + ": " + tags)
+ }
+ tag, err := strconv.Atoi(tagArray[1])
+ if err != nil {
+ panic("protobuf tag field not an integer: " + tagArray[1])
+ }
+
+ name := ""
+ for _, tag := range tagArray[3:] {
+ if strings.HasPrefix(tag, "name=") {
+ name = tag[5:]
+ }
+ }
+
+ // Extract unmarshaling function from the field (its type and tags).
+ unmarshal := fieldUnmarshaler(&f)
+
+ // Required field?
+ var reqMask uint64
+ if tagArray[2] == "req" {
+ bit := len(u.reqFields)
+ u.reqFields = append(u.reqFields, name)
+ reqMask = uint64(1) << uint(bit)
+ // TODO: if we have more than 64 required fields, we end up
+ // not verifying that all required fields are present.
+ // Fix this, perhaps using a count of required fields?
+ }
+
+ // Store the info in the correct slot in the message.
+ u.setTag(tag, toField(&f), unmarshal, reqMask, name)
+ }
+
+ // Find any types associated with oneof fields.
+ var oneofImplementers []interface{}
+ switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
+ case oneofFuncsIface:
+ _, _, _, oneofImplementers = m.XXX_OneofFuncs()
+ case oneofWrappersIface:
+ oneofImplementers = m.XXX_OneofWrappers()
+ }
+ for _, v := range oneofImplementers {
+ tptr := reflect.TypeOf(v) // *Msg_X
+ typ := tptr.Elem() // Msg_X
+
+ f := typ.Field(0) // oneof implementers have one field
+ baseUnmarshal := fieldUnmarshaler(&f)
+ tags := strings.Split(f.Tag.Get("protobuf"), ",")
+ fieldNum, err := strconv.Atoi(tags[1])
+ if err != nil {
+ panic("protobuf tag field not an integer: " + tags[1])
+ }
+ var name string
+ for _, tag := range tags {
+ if strings.HasPrefix(tag, "name=") {
+ name = strings.TrimPrefix(tag, "name=")
+ break
+ }
+ }
+
+ // Find the oneof field that this struct implements.
+ // Might take O(n^2) to process all of the oneofs, but who cares.
+ for _, of := range oneofFields {
+ if tptr.Implements(of.ityp) {
+ // We have found the corresponding interface for this struct.
+ // That lets us know where this struct should be stored
+ // when we encounter it during unmarshaling.
+ unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal)
+ u.setTag(fieldNum, of.field, unmarshal, 0, name)
+ }
+ }
+
+ }
+
+ // Get extension ranges, if any.
+ fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray")
+ if fn.IsValid() {
+ if !u.extensions.IsValid() && !u.oldExtensions.IsValid() {
+ panic("a message with extensions, but no extensions field in " + t.Name())
+ }
+ u.extensionRanges = fn.Call(nil)[0].Interface().([]ExtensionRange)
+ }
+
+ // Explicitly disallow tag 0. This will ensure we flag an error
+ // when decoding a buffer of all zeros. Without this code, we
+ // would decode and skip an all-zero buffer of even length.
+ // [0 0] is [tag=0/wiretype=varint varint-encoded-0].
+ u.setTag(0, zeroField, func(b []byte, f pointer, w int) ([]byte, error) {
+ return nil, fmt.Errorf("proto: %s: illegal tag 0 (wire type %d)", t, w)
+ }, 0, "")
+
+ // Set mask for required field check.
+ u.reqMask = uint64(1)<= 0 && (tag < 16 || tag < 2*n) { // TODO: what are the right numbers here?
+ for len(u.dense) <= tag {
+ u.dense = append(u.dense, unmarshalFieldInfo{})
+ }
+ u.dense[tag] = i
+ return
+ }
+ if u.sparse == nil {
+ u.sparse = map[uint64]unmarshalFieldInfo{}
+ }
+ u.sparse[uint64(tag)] = i
+}
+
+// fieldUnmarshaler returns an unmarshaler for the given field.
+func fieldUnmarshaler(f *reflect.StructField) unmarshaler {
+ if f.Type.Kind() == reflect.Map {
+ return makeUnmarshalMap(f)
+ }
+ return typeUnmarshaler(f.Type, f.Tag.Get("protobuf"))
+}
+
+// typeUnmarshaler returns an unmarshaler for the given field type / field tag pair.
+func typeUnmarshaler(t reflect.Type, tags string) unmarshaler {
+ tagArray := strings.Split(tags, ",")
+ encoding := tagArray[0]
+ name := "unknown"
+ proto3 := false
+ validateUTF8 := true
+ for _, tag := range tagArray[3:] {
+ if strings.HasPrefix(tag, "name=") {
+ name = tag[5:]
+ }
+ if tag == "proto3" {
+ proto3 = true
+ }
+ }
+ validateUTF8 = validateUTF8 && proto3
+
+ // Figure out packaging (pointer, slice, or both)
+ slice := false
+ pointer := false
+ if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 {
+ slice = true
+ t = t.Elem()
+ }
+ if t.Kind() == reflect.Ptr {
+ pointer = true
+ t = t.Elem()
+ }
+
+ // We'll never have both pointer and slice for basic types.
+ if pointer && slice && t.Kind() != reflect.Struct {
+ panic("both pointer and slice for basic type in " + t.Name())
+ }
+
+ switch t.Kind() {
+ case reflect.Bool:
+ if pointer {
+ return unmarshalBoolPtr
+ }
+ if slice {
+ return unmarshalBoolSlice
+ }
+ return unmarshalBoolValue
+ case reflect.Int32:
+ switch encoding {
+ case "fixed32":
+ if pointer {
+ return unmarshalFixedS32Ptr
+ }
+ if slice {
+ return unmarshalFixedS32Slice
+ }
+ return unmarshalFixedS32Value
+ case "varint":
+ // this could be int32 or enum
+ if pointer {
+ return unmarshalInt32Ptr
+ }
+ if slice {
+ return unmarshalInt32Slice
+ }
+ return unmarshalInt32Value
+ case "zigzag32":
+ if pointer {
+ return unmarshalSint32Ptr
+ }
+ if slice {
+ return unmarshalSint32Slice
+ }
+ return unmarshalSint32Value
+ }
+ case reflect.Int64:
+ switch encoding {
+ case "fixed64":
+ if pointer {
+ return unmarshalFixedS64Ptr
+ }
+ if slice {
+ return unmarshalFixedS64Slice
+ }
+ return unmarshalFixedS64Value
+ case "varint":
+ if pointer {
+ return unmarshalInt64Ptr
+ }
+ if slice {
+ return unmarshalInt64Slice
+ }
+ return unmarshalInt64Value
+ case "zigzag64":
+ if pointer {
+ return unmarshalSint64Ptr
+ }
+ if slice {
+ return unmarshalSint64Slice
+ }
+ return unmarshalSint64Value
+ }
+ case reflect.Uint32:
+ switch encoding {
+ case "fixed32":
+ if pointer {
+ return unmarshalFixed32Ptr
+ }
+ if slice {
+ return unmarshalFixed32Slice
+ }
+ return unmarshalFixed32Value
+ case "varint":
+ if pointer {
+ return unmarshalUint32Ptr
+ }
+ if slice {
+ return unmarshalUint32Slice
+ }
+ return unmarshalUint32Value
+ }
+ case reflect.Uint64:
+ switch encoding {
+ case "fixed64":
+ if pointer {
+ return unmarshalFixed64Ptr
+ }
+ if slice {
+ return unmarshalFixed64Slice
+ }
+ return unmarshalFixed64Value
+ case "varint":
+ if pointer {
+ return unmarshalUint64Ptr
+ }
+ if slice {
+ return unmarshalUint64Slice
+ }
+ return unmarshalUint64Value
+ }
+ case reflect.Float32:
+ if pointer {
+ return unmarshalFloat32Ptr
+ }
+ if slice {
+ return unmarshalFloat32Slice
+ }
+ return unmarshalFloat32Value
+ case reflect.Float64:
+ if pointer {
+ return unmarshalFloat64Ptr
+ }
+ if slice {
+ return unmarshalFloat64Slice
+ }
+ return unmarshalFloat64Value
+ case reflect.Map:
+ panic("map type in typeUnmarshaler in " + t.Name())
+ case reflect.Slice:
+ if pointer {
+ panic("bad pointer in slice case in " + t.Name())
+ }
+ if slice {
+ return unmarshalBytesSlice
+ }
+ return unmarshalBytesValue
+ case reflect.String:
+ if validateUTF8 {
+ if pointer {
+ return unmarshalUTF8StringPtr
+ }
+ if slice {
+ return unmarshalUTF8StringSlice
+ }
+ return unmarshalUTF8StringValue
+ }
+ if pointer {
+ return unmarshalStringPtr
+ }
+ if slice {
+ return unmarshalStringSlice
+ }
+ return unmarshalStringValue
+ case reflect.Struct:
+ // message or group field
+ if !pointer {
+ panic(fmt.Sprintf("message/group field %s:%s without pointer", t, encoding))
+ }
+ switch encoding {
+ case "bytes":
+ if slice {
+ return makeUnmarshalMessageSlicePtr(getUnmarshalInfo(t), name)
+ }
+ return makeUnmarshalMessagePtr(getUnmarshalInfo(t), name)
+ case "group":
+ if slice {
+ return makeUnmarshalGroupSlicePtr(getUnmarshalInfo(t), name)
+ }
+ return makeUnmarshalGroupPtr(getUnmarshalInfo(t), name)
+ }
+ }
+ panic(fmt.Sprintf("unmarshaler not found type:%s encoding:%s", t, encoding))
+}
+
+// Below are all the unmarshalers for individual fields of various types.
+
+func unmarshalInt64Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int64(x)
+ *f.toInt64() = v
+ return b, nil
+}
+
+func unmarshalInt64Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int64(x)
+ *f.toInt64Ptr() = &v
+ return b, nil
+}
+
+func unmarshalInt64Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ x, n = decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int64(x)
+ s := f.toInt64Slice()
+ *s = append(*s, v)
+ }
+ return res, nil
+ }
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int64(x)
+ s := f.toInt64Slice()
+ *s = append(*s, v)
+ return b, nil
+}
+
+func unmarshalSint64Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int64(x>>1) ^ int64(x)<<63>>63
+ *f.toInt64() = v
+ return b, nil
+}
+
+func unmarshalSint64Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int64(x>>1) ^ int64(x)<<63>>63
+ *f.toInt64Ptr() = &v
+ return b, nil
+}
+
+func unmarshalSint64Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ x, n = decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int64(x>>1) ^ int64(x)<<63>>63
+ s := f.toInt64Slice()
+ *s = append(*s, v)
+ }
+ return res, nil
+ }
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int64(x>>1) ^ int64(x)<<63>>63
+ s := f.toInt64Slice()
+ *s = append(*s, v)
+ return b, nil
+}
+
+func unmarshalUint64Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := uint64(x)
+ *f.toUint64() = v
+ return b, nil
+}
+
+func unmarshalUint64Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := uint64(x)
+ *f.toUint64Ptr() = &v
+ return b, nil
+}
+
+func unmarshalUint64Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ x, n = decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := uint64(x)
+ s := f.toUint64Slice()
+ *s = append(*s, v)
+ }
+ return res, nil
+ }
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := uint64(x)
+ s := f.toUint64Slice()
+ *s = append(*s, v)
+ return b, nil
+}
+
+func unmarshalInt32Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int32(x)
+ *f.toInt32() = v
+ return b, nil
+}
+
+func unmarshalInt32Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int32(x)
+ f.setInt32Ptr(v)
+ return b, nil
+}
+
+func unmarshalInt32Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ x, n = decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int32(x)
+ f.appendInt32Slice(v)
+ }
+ return res, nil
+ }
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int32(x)
+ f.appendInt32Slice(v)
+ return b, nil
+}
+
+func unmarshalSint32Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int32(x>>1) ^ int32(x)<<31>>31
+ *f.toInt32() = v
+ return b, nil
+}
+
+func unmarshalSint32Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int32(x>>1) ^ int32(x)<<31>>31
+ f.setInt32Ptr(v)
+ return b, nil
+}
+
+func unmarshalSint32Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ x, n = decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int32(x>>1) ^ int32(x)<<31>>31
+ f.appendInt32Slice(v)
+ }
+ return res, nil
+ }
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := int32(x>>1) ^ int32(x)<<31>>31
+ f.appendInt32Slice(v)
+ return b, nil
+}
+
+func unmarshalUint32Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := uint32(x)
+ *f.toUint32() = v
+ return b, nil
+}
+
+func unmarshalUint32Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := uint32(x)
+ *f.toUint32Ptr() = &v
+ return b, nil
+}
+
+func unmarshalUint32Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ x, n = decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := uint32(x)
+ s := f.toUint32Slice()
+ *s = append(*s, v)
+ }
+ return res, nil
+ }
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ v := uint32(x)
+ s := f.toUint32Slice()
+ *s = append(*s, v)
+ return b, nil
+}
+
+func unmarshalFixed64Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
+ *f.toUint64() = v
+ return b[8:], nil
+}
+
+func unmarshalFixed64Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
+ *f.toUint64Ptr() = &v
+ return b[8:], nil
+}
+
+func unmarshalFixed64Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
+ s := f.toUint64Slice()
+ *s = append(*s, v)
+ b = b[8:]
+ }
+ return res, nil
+ }
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
+ s := f.toUint64Slice()
+ *s = append(*s, v)
+ return b[8:], nil
+}
+
+func unmarshalFixedS64Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56
+ *f.toInt64() = v
+ return b[8:], nil
+}
+
+func unmarshalFixedS64Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56
+ *f.toInt64Ptr() = &v
+ return b[8:], nil
+}
+
+func unmarshalFixedS64Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56
+ s := f.toInt64Slice()
+ *s = append(*s, v)
+ b = b[8:]
+ }
+ return res, nil
+ }
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56
+ s := f.toInt64Slice()
+ *s = append(*s, v)
+ return b[8:], nil
+}
+
+func unmarshalFixed32Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
+ *f.toUint32() = v
+ return b[4:], nil
+}
+
+func unmarshalFixed32Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
+ *f.toUint32Ptr() = &v
+ return b[4:], nil
+}
+
+func unmarshalFixed32Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
+ s := f.toUint32Slice()
+ *s = append(*s, v)
+ b = b[4:]
+ }
+ return res, nil
+ }
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
+ s := f.toUint32Slice()
+ *s = append(*s, v)
+ return b[4:], nil
+}
+
+func unmarshalFixedS32Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24
+ *f.toInt32() = v
+ return b[4:], nil
+}
+
+func unmarshalFixedS32Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24
+ f.setInt32Ptr(v)
+ return b[4:], nil
+}
+
+func unmarshalFixedS32Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24
+ f.appendInt32Slice(v)
+ b = b[4:]
+ }
+ return res, nil
+ }
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24
+ f.appendInt32Slice(v)
+ return b[4:], nil
+}
+
+func unmarshalBoolValue(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ // Note: any length varint is allowed, even though any sane
+ // encoder will use one byte.
+ // See https://github.com/golang/protobuf/issues/76
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ // TODO: check if x>1? Tests seem to indicate no.
+ v := x != 0
+ *f.toBool() = v
+ return b[n:], nil
+}
+
+func unmarshalBoolPtr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := x != 0
+ *f.toBoolPtr() = &v
+ return b[n:], nil
+}
+
+func unmarshalBoolSlice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ x, n = decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := x != 0
+ s := f.toBoolSlice()
+ *s = append(*s, v)
+ b = b[n:]
+ }
+ return res, nil
+ }
+ if w != WireVarint {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := x != 0
+ s := f.toBoolSlice()
+ *s = append(*s, v)
+ return b[n:], nil
+}
+
+func unmarshalFloat64Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56)
+ *f.toFloat64() = v
+ return b[8:], nil
+}
+
+func unmarshalFloat64Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56)
+ *f.toFloat64Ptr() = &v
+ return b[8:], nil
+}
+
+func unmarshalFloat64Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56)
+ s := f.toFloat64Slice()
+ *s = append(*s, v)
+ b = b[8:]
+ }
+ return res, nil
+ }
+ if w != WireFixed64 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 8 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56)
+ s := f.toFloat64Slice()
+ *s = append(*s, v)
+ return b[8:], nil
+}
+
+func unmarshalFloat32Value(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
+ *f.toFloat32() = v
+ return b[4:], nil
+}
+
+func unmarshalFloat32Ptr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
+ *f.toFloat32Ptr() = &v
+ return b[4:], nil
+}
+
+func unmarshalFloat32Slice(b []byte, f pointer, w int) ([]byte, error) {
+ if w == WireBytes { // packed
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ res := b[x:]
+ b = b[:x]
+ for len(b) > 0 {
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
+ s := f.toFloat32Slice()
+ *s = append(*s, v)
+ b = b[4:]
+ }
+ return res, nil
+ }
+ if w != WireFixed32 {
+ return b, errInternalBadWireType
+ }
+ if len(b) < 4 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
+ s := f.toFloat32Slice()
+ *s = append(*s, v)
+ return b[4:], nil
+}
+
+func unmarshalStringValue(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ *f.toString() = v
+ return b[x:], nil
+}
+
+func unmarshalStringPtr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ *f.toStringPtr() = &v
+ return b[x:], nil
+}
+
+func unmarshalStringSlice(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ s := f.toStringSlice()
+ *s = append(*s, v)
+ return b[x:], nil
+}
+
+func unmarshalUTF8StringValue(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ *f.toString() = v
+ if !utf8.ValidString(v) {
+ return b[x:], errInvalidUTF8
+ }
+ return b[x:], nil
+}
+
+func unmarshalUTF8StringPtr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ *f.toStringPtr() = &v
+ if !utf8.ValidString(v) {
+ return b[x:], errInvalidUTF8
+ }
+ return b[x:], nil
+}
+
+func unmarshalUTF8StringSlice(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ s := f.toStringSlice()
+ *s = append(*s, v)
+ if !utf8.ValidString(v) {
+ return b[x:], errInvalidUTF8
+ }
+ return b[x:], nil
+}
+
+var emptyBuf [0]byte
+
+func unmarshalBytesValue(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ // The use of append here is a trick which avoids the zeroing
+ // that would be required if we used a make/copy pair.
+ // We append to emptyBuf instead of nil because we want
+ // a non-nil result even when the length is 0.
+ v := append(emptyBuf[:], b[:x]...)
+ *f.toBytes() = v
+ return b[x:], nil
+}
+
+func unmarshalBytesSlice(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := append(emptyBuf[:], b[:x]...)
+ s := f.toBytesSlice()
+ *s = append(*s, v)
+ return b[x:], nil
+}
+
+func makeUnmarshalMessagePtr(sub *unmarshalInfo, name string) unmarshaler {
+ return func(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ // First read the message field to see if something is there.
+ // The semantics of multiple submessages are weird. Instead of
+ // the last one winning (as it is for all other fields), multiple
+ // submessages are merged.
+ v := f.getPointer()
+ if v.isNil() {
+ v = valToPointer(reflect.New(sub.typ))
+ f.setPointer(v)
+ }
+ err := sub.unmarshal(v, b[:x])
+ if err != nil {
+ if r, ok := err.(*RequiredNotSetError); ok {
+ r.field = name + "." + r.field
+ } else {
+ return nil, err
+ }
+ }
+ return b[x:], err
+ }
+}
+
+func makeUnmarshalMessageSlicePtr(sub *unmarshalInfo, name string) unmarshaler {
+ return func(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := valToPointer(reflect.New(sub.typ))
+ err := sub.unmarshal(v, b[:x])
+ if err != nil {
+ if r, ok := err.(*RequiredNotSetError); ok {
+ r.field = name + "." + r.field
+ } else {
+ return nil, err
+ }
+ }
+ f.appendPointer(v)
+ return b[x:], err
+ }
+}
+
+func makeUnmarshalGroupPtr(sub *unmarshalInfo, name string) unmarshaler {
+ return func(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireStartGroup {
+ return b, errInternalBadWireType
+ }
+ x, y := findEndGroup(b)
+ if x < 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := f.getPointer()
+ if v.isNil() {
+ v = valToPointer(reflect.New(sub.typ))
+ f.setPointer(v)
+ }
+ err := sub.unmarshal(v, b[:x])
+ if err != nil {
+ if r, ok := err.(*RequiredNotSetError); ok {
+ r.field = name + "." + r.field
+ } else {
+ return nil, err
+ }
+ }
+ return b[y:], err
+ }
+}
+
+func makeUnmarshalGroupSlicePtr(sub *unmarshalInfo, name string) unmarshaler {
+ return func(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireStartGroup {
+ return b, errInternalBadWireType
+ }
+ x, y := findEndGroup(b)
+ if x < 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := valToPointer(reflect.New(sub.typ))
+ err := sub.unmarshal(v, b[:x])
+ if err != nil {
+ if r, ok := err.(*RequiredNotSetError); ok {
+ r.field = name + "." + r.field
+ } else {
+ return nil, err
+ }
+ }
+ f.appendPointer(v)
+ return b[y:], err
+ }
+}
+
+func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
+ t := f.Type
+ kt := t.Key()
+ vt := t.Elem()
+ unmarshalKey := typeUnmarshaler(kt, f.Tag.Get("protobuf_key"))
+ unmarshalVal := typeUnmarshaler(vt, f.Tag.Get("protobuf_val"))
+ return func(b []byte, f pointer, w int) ([]byte, error) {
+ // The map entry is a submessage. Figure out how big it is.
+ if w != WireBytes {
+ return nil, fmt.Errorf("proto: bad wiretype for map field: got %d want %d", w, WireBytes)
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ r := b[x:] // unused data to return
+ b = b[:x] // data for map entry
+
+ // Note: we could use #keys * #values ~= 200 functions
+ // to do map decoding without reflection. Probably not worth it.
+ // Maps will be somewhat slow. Oh well.
+
+ // Read key and value from data.
+ var nerr nonFatal
+ k := reflect.New(kt)
+ v := reflect.New(vt)
+ for len(b) > 0 {
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ wire := int(x) & 7
+ b = b[n:]
+
+ var err error
+ switch x >> 3 {
+ case 1:
+ b, err = unmarshalKey(b, valToPointer(k), wire)
+ case 2:
+ b, err = unmarshalVal(b, valToPointer(v), wire)
+ default:
+ err = errInternalBadWireType // skip unknown tag
+ }
+
+ if nerr.Merge(err) {
+ continue
+ }
+ if err != errInternalBadWireType {
+ return nil, err
+ }
+
+ // Skip past unknown fields.
+ b, err = skipField(b, wire)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ // Get map, allocate if needed.
+ m := f.asPointerTo(t).Elem() // an addressable map[K]T
+ if m.IsNil() {
+ m.Set(reflect.MakeMap(t))
+ }
+
+ // Insert into map.
+ m.SetMapIndex(k.Elem(), v.Elem())
+
+ return r, nerr.E
+ }
+}
+
+// makeUnmarshalOneof makes an unmarshaler for oneof fields.
+// for:
+// message Msg {
+// oneof F {
+// int64 X = 1;
+// float64 Y = 2;
+// }
+// }
+// typ is the type of the concrete entry for a oneof case (e.g. Msg_X).
+// ityp is the interface type of the oneof field (e.g. isMsg_F).
+// unmarshal is the unmarshaler for the base type of the oneof case (e.g. int64).
+// Note that this function will be called once for each case in the oneof.
+func makeUnmarshalOneof(typ, ityp reflect.Type, unmarshal unmarshaler) unmarshaler {
+ sf := typ.Field(0)
+ field0 := toField(&sf)
+ return func(b []byte, f pointer, w int) ([]byte, error) {
+ // Allocate holder for value.
+ v := reflect.New(typ)
+
+ // Unmarshal data into holder.
+ // We unmarshal into the first field of the holder object.
+ var err error
+ var nerr nonFatal
+ b, err = unmarshal(b, valToPointer(v).offset(field0), w)
+ if !nerr.Merge(err) {
+ return nil, err
+ }
+
+ // Write pointer to holder into target field.
+ f.asPointerTo(ityp).Elem().Set(v)
+
+ return b, nerr.E
+ }
+}
+
+// Error used by decode internally.
+var errInternalBadWireType = errors.New("proto: internal error: bad wiretype")
+
+// skipField skips past a field of type wire and returns the remaining bytes.
+func skipField(b []byte, wire int) ([]byte, error) {
+ switch wire {
+ case WireVarint:
+ _, k := decodeVarint(b)
+ if k == 0 {
+ return b, io.ErrUnexpectedEOF
+ }
+ b = b[k:]
+ case WireFixed32:
+ if len(b) < 4 {
+ return b, io.ErrUnexpectedEOF
+ }
+ b = b[4:]
+ case WireFixed64:
+ if len(b) < 8 {
+ return b, io.ErrUnexpectedEOF
+ }
+ b = b[8:]
+ case WireBytes:
+ m, k := decodeVarint(b)
+ if k == 0 || uint64(len(b)-k) < m {
+ return b, io.ErrUnexpectedEOF
+ }
+ b = b[uint64(k)+m:]
+ case WireStartGroup:
+ _, i := findEndGroup(b)
+ if i == -1 {
+ return b, io.ErrUnexpectedEOF
+ }
+ b = b[i:]
+ default:
+ return b, fmt.Errorf("proto: can't skip unknown wire type %d", wire)
+ }
+ return b, nil
+}
+
+// findEndGroup finds the index of the next EndGroup tag.
+// Groups may be nested, so the "next" EndGroup tag is the first
+// unpaired EndGroup.
+// findEndGroup returns the indexes of the start and end of the EndGroup tag.
+// Returns (-1,-1) if it can't find one.
+func findEndGroup(b []byte) (int, int) {
+ depth := 1
+ i := 0
+ for {
+ x, n := decodeVarint(b[i:])
+ if n == 0 {
+ return -1, -1
+ }
+ j := i
+ i += n
+ switch x & 7 {
+ case WireVarint:
+ _, k := decodeVarint(b[i:])
+ if k == 0 {
+ return -1, -1
+ }
+ i += k
+ case WireFixed32:
+ if len(b)-4 < i {
+ return -1, -1
+ }
+ i += 4
+ case WireFixed64:
+ if len(b)-8 < i {
+ return -1, -1
+ }
+ i += 8
+ case WireBytes:
+ m, k := decodeVarint(b[i:])
+ if k == 0 {
+ return -1, -1
+ }
+ i += k
+ if uint64(len(b)-i) < m {
+ return -1, -1
+ }
+ i += int(m)
+ case WireStartGroup:
+ depth++
+ case WireEndGroup:
+ depth--
+ if depth == 0 {
+ return j, i
+ }
+ default:
+ return -1, -1
+ }
+ }
+}
+
+// encodeVarint appends a varint-encoded integer to b and returns the result.
+func encodeVarint(b []byte, x uint64) []byte {
+ for x >= 1<<7 {
+ b = append(b, byte(x&0x7f|0x80))
+ x >>= 7
+ }
+ return append(b, byte(x))
+}
+
+// decodeVarint reads a varint-encoded integer from b.
+// Returns the decoded integer and the number of bytes read.
+// If there is an error, it returns 0,0.
+func decodeVarint(b []byte) (uint64, int) {
+ var x, y uint64
+ if len(b) == 0 {
+ goto bad
+ }
+ x = uint64(b[0])
+ if x < 0x80 {
+ return x, 1
+ }
+ x -= 0x80
+
+ if len(b) <= 1 {
+ goto bad
+ }
+ y = uint64(b[1])
+ x += y << 7
+ if y < 0x80 {
+ return x, 2
+ }
+ x -= 0x80 << 7
+
+ if len(b) <= 2 {
+ goto bad
+ }
+ y = uint64(b[2])
+ x += y << 14
+ if y < 0x80 {
+ return x, 3
+ }
+ x -= 0x80 << 14
+
+ if len(b) <= 3 {
+ goto bad
+ }
+ y = uint64(b[3])
+ x += y << 21
+ if y < 0x80 {
+ return x, 4
+ }
+ x -= 0x80 << 21
+
+ if len(b) <= 4 {
+ goto bad
+ }
+ y = uint64(b[4])
+ x += y << 28
+ if y < 0x80 {
+ return x, 5
+ }
+ x -= 0x80 << 28
+
+ if len(b) <= 5 {
+ goto bad
+ }
+ y = uint64(b[5])
+ x += y << 35
+ if y < 0x80 {
+ return x, 6
+ }
+ x -= 0x80 << 35
+
+ if len(b) <= 6 {
+ goto bad
+ }
+ y = uint64(b[6])
+ x += y << 42
+ if y < 0x80 {
+ return x, 7
+ }
+ x -= 0x80 << 42
+
+ if len(b) <= 7 {
+ goto bad
+ }
+ y = uint64(b[7])
+ x += y << 49
+ if y < 0x80 {
+ return x, 8
+ }
+ x -= 0x80 << 49
+
+ if len(b) <= 8 {
+ goto bad
+ }
+ y = uint64(b[8])
+ x += y << 56
+ if y < 0x80 {
+ return x, 9
+ }
+ x -= 0x80 << 56
+
+ if len(b) <= 9 {
+ goto bad
+ }
+ y = uint64(b[9])
+ x += y << 63
+ if y < 2 {
+ return x, 10
+ }
+
+bad:
+ return 0, 0
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/text.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/text.go
new file mode 100644
index 00000000..1aaee725
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/text.go
@@ -0,0 +1,843 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+// Functions for writing the text protocol buffer format.
+
+import (
+ "bufio"
+ "bytes"
+ "encoding"
+ "errors"
+ "fmt"
+ "io"
+ "log"
+ "math"
+ "reflect"
+ "sort"
+ "strings"
+)
+
+var (
+ newline = []byte("\n")
+ spaces = []byte(" ")
+ endBraceNewline = []byte("}\n")
+ backslashN = []byte{'\\', 'n'}
+ backslashR = []byte{'\\', 'r'}
+ backslashT = []byte{'\\', 't'}
+ backslashDQ = []byte{'\\', '"'}
+ backslashBS = []byte{'\\', '\\'}
+ posInf = []byte("inf")
+ negInf = []byte("-inf")
+ nan = []byte("nan")
+)
+
+type writer interface {
+ io.Writer
+ WriteByte(byte) error
+}
+
+// textWriter is an io.Writer that tracks its indentation level.
+type textWriter struct {
+ ind int
+ complete bool // if the current position is a complete line
+ compact bool // whether to write out as a one-liner
+ w writer
+}
+
+func (w *textWriter) WriteString(s string) (n int, err error) {
+ if !strings.Contains(s, "\n") {
+ if !w.compact && w.complete {
+ w.writeIndent()
+ }
+ w.complete = false
+ return io.WriteString(w.w, s)
+ }
+ // WriteString is typically called without newlines, so this
+ // codepath and its copy are rare. We copy to avoid
+ // duplicating all of Write's logic here.
+ return w.Write([]byte(s))
+}
+
+func (w *textWriter) Write(p []byte) (n int, err error) {
+ newlines := bytes.Count(p, newline)
+ if newlines == 0 {
+ if !w.compact && w.complete {
+ w.writeIndent()
+ }
+ n, err = w.w.Write(p)
+ w.complete = false
+ return n, err
+ }
+
+ frags := bytes.SplitN(p, newline, newlines+1)
+ if w.compact {
+ for i, frag := range frags {
+ if i > 0 {
+ if err := w.w.WriteByte(' '); err != nil {
+ return n, err
+ }
+ n++
+ }
+ nn, err := w.w.Write(frag)
+ n += nn
+ if err != nil {
+ return n, err
+ }
+ }
+ return n, nil
+ }
+
+ for i, frag := range frags {
+ if w.complete {
+ w.writeIndent()
+ }
+ nn, err := w.w.Write(frag)
+ n += nn
+ if err != nil {
+ return n, err
+ }
+ if i+1 < len(frags) {
+ if err := w.w.WriteByte('\n'); err != nil {
+ return n, err
+ }
+ n++
+ }
+ }
+ w.complete = len(frags[len(frags)-1]) == 0
+ return n, nil
+}
+
+func (w *textWriter) WriteByte(c byte) error {
+ if w.compact && c == '\n' {
+ c = ' '
+ }
+ if !w.compact && w.complete {
+ w.writeIndent()
+ }
+ err := w.w.WriteByte(c)
+ w.complete = c == '\n'
+ return err
+}
+
+func (w *textWriter) indent() { w.ind++ }
+
+func (w *textWriter) unindent() {
+ if w.ind == 0 {
+ log.Print("proto: textWriter unindented too far")
+ return
+ }
+ w.ind--
+}
+
+func writeName(w *textWriter, props *Properties) error {
+ if _, err := w.WriteString(props.OrigName); err != nil {
+ return err
+ }
+ if props.Wire != "group" {
+ return w.WriteByte(':')
+ }
+ return nil
+}
+
+func requiresQuotes(u string) bool {
+ // When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted.
+ for _, ch := range u {
+ switch {
+ case ch == '.' || ch == '/' || ch == '_':
+ continue
+ case '0' <= ch && ch <= '9':
+ continue
+ case 'A' <= ch && ch <= 'Z':
+ continue
+ case 'a' <= ch && ch <= 'z':
+ continue
+ default:
+ return true
+ }
+ }
+ return false
+}
+
+// isAny reports whether sv is a google.protobuf.Any message
+func isAny(sv reflect.Value) bool {
+ type wkt interface {
+ XXX_WellKnownType() string
+ }
+ t, ok := sv.Addr().Interface().(wkt)
+ return ok && t.XXX_WellKnownType() == "Any"
+}
+
+// writeProto3Any writes an expanded google.protobuf.Any message.
+//
+// It returns (false, nil) if sv value can't be unmarshaled (e.g. because
+// required messages are not linked in).
+//
+// It returns (true, error) when sv was written in expanded format or an error
+// was encountered.
+func (tm *TextMarshaler) writeProto3Any(w *textWriter, sv reflect.Value) (bool, error) {
+ turl := sv.FieldByName("TypeUrl")
+ val := sv.FieldByName("Value")
+ if !turl.IsValid() || !val.IsValid() {
+ return true, errors.New("proto: invalid google.protobuf.Any message")
+ }
+
+ b, ok := val.Interface().([]byte)
+ if !ok {
+ return true, errors.New("proto: invalid google.protobuf.Any message")
+ }
+
+ parts := strings.Split(turl.String(), "/")
+ mt := MessageType(parts[len(parts)-1])
+ if mt == nil {
+ return false, nil
+ }
+ m := reflect.New(mt.Elem())
+ if err := Unmarshal(b, m.Interface().(Message)); err != nil {
+ return false, nil
+ }
+ w.Write([]byte("["))
+ u := turl.String()
+ if requiresQuotes(u) {
+ writeString(w, u)
+ } else {
+ w.Write([]byte(u))
+ }
+ if w.compact {
+ w.Write([]byte("]:<"))
+ } else {
+ w.Write([]byte("]: <\n"))
+ w.ind++
+ }
+ if err := tm.writeStruct(w, m.Elem()); err != nil {
+ return true, err
+ }
+ if w.compact {
+ w.Write([]byte("> "))
+ } else {
+ w.ind--
+ w.Write([]byte(">\n"))
+ }
+ return true, nil
+}
+
+func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
+ if tm.ExpandAny && isAny(sv) {
+ if canExpand, err := tm.writeProto3Any(w, sv); canExpand {
+ return err
+ }
+ }
+ st := sv.Type()
+ sprops := GetProperties(st)
+ for i := 0; i < sv.NumField(); i++ {
+ fv := sv.Field(i)
+ props := sprops.Prop[i]
+ name := st.Field(i).Name
+
+ if name == "XXX_NoUnkeyedLiteral" {
+ continue
+ }
+
+ if strings.HasPrefix(name, "XXX_") {
+ // There are two XXX_ fields:
+ // XXX_unrecognized []byte
+ // XXX_extensions map[int32]proto.Extension
+ // The first is handled here;
+ // the second is handled at the bottom of this function.
+ if name == "XXX_unrecognized" && !fv.IsNil() {
+ if err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil {
+ return err
+ }
+ }
+ continue
+ }
+ if fv.Kind() == reflect.Ptr && fv.IsNil() {
+ // Field not filled in. This could be an optional field or
+ // a required field that wasn't filled in. Either way, there
+ // isn't anything we can show for it.
+ continue
+ }
+ if fv.Kind() == reflect.Slice && fv.IsNil() {
+ // Repeated field that is empty, or a bytes field that is unused.
+ continue
+ }
+
+ if props.Repeated && fv.Kind() == reflect.Slice {
+ // Repeated field.
+ for j := 0; j < fv.Len(); j++ {
+ if err := writeName(w, props); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte(' '); err != nil {
+ return err
+ }
+ }
+ v := fv.Index(j)
+ if v.Kind() == reflect.Ptr && v.IsNil() {
+ // A nil message in a repeated field is not valid,
+ // but we can handle that more gracefully than panicking.
+ if _, err := w.Write([]byte("\n")); err != nil {
+ return err
+ }
+ continue
+ }
+ if err := tm.writeAny(w, v, props); err != nil {
+ return err
+ }
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ }
+ continue
+ }
+ if fv.Kind() == reflect.Map {
+ // Map fields are rendered as a repeated struct with key/value fields.
+ keys := fv.MapKeys()
+ sort.Sort(mapKeys(keys))
+ for _, key := range keys {
+ val := fv.MapIndex(key)
+ if err := writeName(w, props); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte(' '); err != nil {
+ return err
+ }
+ }
+ // open struct
+ if err := w.WriteByte('<'); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ }
+ w.indent()
+ // key
+ if _, err := w.WriteString("key:"); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte(' '); err != nil {
+ return err
+ }
+ }
+ if err := tm.writeAny(w, key, props.MapKeyProp); err != nil {
+ return err
+ }
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ // nil values aren't legal, but we can avoid panicking because of them.
+ if val.Kind() != reflect.Ptr || !val.IsNil() {
+ // value
+ if _, err := w.WriteString("value:"); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte(' '); err != nil {
+ return err
+ }
+ }
+ if err := tm.writeAny(w, val, props.MapValProp); err != nil {
+ return err
+ }
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ }
+ // close struct
+ w.unindent()
+ if err := w.WriteByte('>'); err != nil {
+ return err
+ }
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ }
+ continue
+ }
+ if props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 {
+ // empty bytes field
+ continue
+ }
+ if fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice {
+ // proto3 non-repeated scalar field; skip if zero value
+ if isProto3Zero(fv) {
+ continue
+ }
+ }
+
+ if fv.Kind() == reflect.Interface {
+ // Check if it is a oneof.
+ if st.Field(i).Tag.Get("protobuf_oneof") != "" {
+ // fv is nil, or holds a pointer to generated struct.
+ // That generated struct has exactly one field,
+ // which has a protobuf struct tag.
+ if fv.IsNil() {
+ continue
+ }
+ inner := fv.Elem().Elem() // interface -> *T -> T
+ tag := inner.Type().Field(0).Tag.Get("protobuf")
+ props = new(Properties) // Overwrite the outer props var, but not its pointee.
+ props.Parse(tag)
+ // Write the value in the oneof, not the oneof itself.
+ fv = inner.Field(0)
+
+ // Special case to cope with malformed messages gracefully:
+ // If the value in the oneof is a nil pointer, don't panic
+ // in writeAny.
+ if fv.Kind() == reflect.Ptr && fv.IsNil() {
+ // Use errors.New so writeAny won't render quotes.
+ msg := errors.New("/* nil */")
+ fv = reflect.ValueOf(&msg).Elem()
+ }
+ }
+ }
+
+ if err := writeName(w, props); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte(' '); err != nil {
+ return err
+ }
+ }
+
+ // Enums have a String method, so writeAny will work fine.
+ if err := tm.writeAny(w, fv, props); err != nil {
+ return err
+ }
+
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ }
+
+ // Extensions (the XXX_extensions field).
+ pv := sv.Addr()
+ if _, err := extendable(pv.Interface()); err == nil {
+ if err := tm.writeExtensions(w, pv); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// writeAny writes an arbitrary field.
+func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
+ v = reflect.Indirect(v)
+
+ // Floats have special cases.
+ if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 {
+ x := v.Float()
+ var b []byte
+ switch {
+ case math.IsInf(x, 1):
+ b = posInf
+ case math.IsInf(x, -1):
+ b = negInf
+ case math.IsNaN(x):
+ b = nan
+ }
+ if b != nil {
+ _, err := w.Write(b)
+ return err
+ }
+ // Other values are handled below.
+ }
+
+ // We don't attempt to serialise every possible value type; only those
+ // that can occur in protocol buffers.
+ switch v.Kind() {
+ case reflect.Slice:
+ // Should only be a []byte; repeated fields are handled in writeStruct.
+ if err := writeString(w, string(v.Bytes())); err != nil {
+ return err
+ }
+ case reflect.String:
+ if err := writeString(w, v.String()); err != nil {
+ return err
+ }
+ case reflect.Struct:
+ // Required/optional group/message.
+ var bra, ket byte = '<', '>'
+ if props != nil && props.Wire == "group" {
+ bra, ket = '{', '}'
+ }
+ if err := w.WriteByte(bra); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ }
+ w.indent()
+ if v.CanAddr() {
+ // Calling v.Interface on a struct causes the reflect package to
+ // copy the entire struct. This is racy with the new Marshaler
+ // since we atomically update the XXX_sizecache.
+ //
+ // Thus, we retrieve a pointer to the struct if possible to avoid
+ // a race since v.Interface on the pointer doesn't copy the struct.
+ //
+ // If v is not addressable, then we are not worried about a race
+ // since it implies that the binary Marshaler cannot possibly be
+ // mutating this value.
+ v = v.Addr()
+ }
+ if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
+ text, err := etm.MarshalText()
+ if err != nil {
+ return err
+ }
+ if _, err = w.Write(text); err != nil {
+ return err
+ }
+ } else {
+ if v.Kind() == reflect.Ptr {
+ v = v.Elem()
+ }
+ if err := tm.writeStruct(w, v); err != nil {
+ return err
+ }
+ }
+ w.unindent()
+ if err := w.WriteByte(ket); err != nil {
+ return err
+ }
+ default:
+ _, err := fmt.Fprint(w, v.Interface())
+ return err
+ }
+ return nil
+}
+
+// equivalent to C's isprint.
+func isprint(c byte) bool {
+ return c >= 0x20 && c < 0x7f
+}
+
+// writeString writes a string in the protocol buffer text format.
+// It is similar to strconv.Quote except we don't use Go escape sequences,
+// we treat the string as a byte sequence, and we use octal escapes.
+// These differences are to maintain interoperability with the other
+// languages' implementations of the text format.
+func writeString(w *textWriter, s string) error {
+ // use WriteByte here to get any needed indent
+ if err := w.WriteByte('"'); err != nil {
+ return err
+ }
+ // Loop over the bytes, not the runes.
+ for i := 0; i < len(s); i++ {
+ var err error
+ // Divergence from C++: we don't escape apostrophes.
+ // There's no need to escape them, and the C++ parser
+ // copes with a naked apostrophe.
+ switch c := s[i]; c {
+ case '\n':
+ _, err = w.w.Write(backslashN)
+ case '\r':
+ _, err = w.w.Write(backslashR)
+ case '\t':
+ _, err = w.w.Write(backslashT)
+ case '"':
+ _, err = w.w.Write(backslashDQ)
+ case '\\':
+ _, err = w.w.Write(backslashBS)
+ default:
+ if isprint(c) {
+ err = w.w.WriteByte(c)
+ } else {
+ _, err = fmt.Fprintf(w.w, "\\%03o", c)
+ }
+ }
+ if err != nil {
+ return err
+ }
+ }
+ return w.WriteByte('"')
+}
+
+func writeUnknownStruct(w *textWriter, data []byte) (err error) {
+ if !w.compact {
+ if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil {
+ return err
+ }
+ }
+ b := NewBuffer(data)
+ for b.index < len(b.buf) {
+ x, err := b.DecodeVarint()
+ if err != nil {
+ _, err := fmt.Fprintf(w, "/* %v */\n", err)
+ return err
+ }
+ wire, tag := x&7, x>>3
+ if wire == WireEndGroup {
+ w.unindent()
+ if _, err := w.Write(endBraceNewline); err != nil {
+ return err
+ }
+ continue
+ }
+ if _, err := fmt.Fprint(w, tag); err != nil {
+ return err
+ }
+ if wire != WireStartGroup {
+ if err := w.WriteByte(':'); err != nil {
+ return err
+ }
+ }
+ if !w.compact || wire == WireStartGroup {
+ if err := w.WriteByte(' '); err != nil {
+ return err
+ }
+ }
+ switch wire {
+ case WireBytes:
+ buf, e := b.DecodeRawBytes(false)
+ if e == nil {
+ _, err = fmt.Fprintf(w, "%q", buf)
+ } else {
+ _, err = fmt.Fprintf(w, "/* %v */", e)
+ }
+ case WireFixed32:
+ x, err = b.DecodeFixed32()
+ err = writeUnknownInt(w, x, err)
+ case WireFixed64:
+ x, err = b.DecodeFixed64()
+ err = writeUnknownInt(w, x, err)
+ case WireStartGroup:
+ err = w.WriteByte('{')
+ w.indent()
+ case WireVarint:
+ x, err = b.DecodeVarint()
+ err = writeUnknownInt(w, x, err)
+ default:
+ _, err = fmt.Fprintf(w, "/* unknown wire type %d */", wire)
+ }
+ if err != nil {
+ return err
+ }
+ if err = w.WriteByte('\n'); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func writeUnknownInt(w *textWriter, x uint64, err error) error {
+ if err == nil {
+ _, err = fmt.Fprint(w, x)
+ } else {
+ _, err = fmt.Fprintf(w, "/* %v */", err)
+ }
+ return err
+}
+
+type int32Slice []int32
+
+func (s int32Slice) Len() int { return len(s) }
+func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] }
+func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
+
+// writeExtensions writes all the extensions in pv.
+// pv is assumed to be a pointer to a protocol message struct that is extendable.
+func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error {
+ emap := extensionMaps[pv.Type().Elem()]
+ ep, _ := extendable(pv.Interface())
+
+ // Order the extensions by ID.
+ // This isn't strictly necessary, but it will give us
+ // canonical output, which will also make testing easier.
+ m, mu := ep.extensionsRead()
+ if m == nil {
+ return nil
+ }
+ mu.Lock()
+ ids := make([]int32, 0, len(m))
+ for id := range m {
+ ids = append(ids, id)
+ }
+ sort.Sort(int32Slice(ids))
+ mu.Unlock()
+
+ for _, extNum := range ids {
+ ext := m[extNum]
+ var desc *ExtensionDesc
+ if emap != nil {
+ desc = emap[extNum]
+ }
+ if desc == nil {
+ // Unknown extension.
+ if err := writeUnknownStruct(w, ext.enc); err != nil {
+ return err
+ }
+ continue
+ }
+
+ pb, err := GetExtension(ep, desc)
+ if err != nil {
+ return fmt.Errorf("failed getting extension: %v", err)
+ }
+
+ // Repeated extensions will appear as a slice.
+ if !desc.repeated() {
+ if err := tm.writeExtension(w, desc.Name, pb); err != nil {
+ return err
+ }
+ } else {
+ v := reflect.ValueOf(pb)
+ for i := 0; i < v.Len(); i++ {
+ if err := tm.writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil {
+ return err
+ }
+ }
+ }
+ }
+ return nil
+}
+
+func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error {
+ if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte(' '); err != nil {
+ return err
+ }
+ }
+ if err := tm.writeAny(w, reflect.ValueOf(pb), nil); err != nil {
+ return err
+ }
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (w *textWriter) writeIndent() {
+ if !w.complete {
+ return
+ }
+ remain := w.ind * 2
+ for remain > 0 {
+ n := remain
+ if n > len(spaces) {
+ n = len(spaces)
+ }
+ w.w.Write(spaces[:n])
+ remain -= n
+ }
+ w.complete = false
+}
+
+// TextMarshaler is a configurable text format marshaler.
+type TextMarshaler struct {
+ Compact bool // use compact text format (one line).
+ ExpandAny bool // expand google.protobuf.Any messages of known types
+}
+
+// Marshal writes a given protocol buffer in text format.
+// The only errors returned are from w.
+func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error {
+ val := reflect.ValueOf(pb)
+ if pb == nil || val.IsNil() {
+ w.Write([]byte(""))
+ return nil
+ }
+ var bw *bufio.Writer
+ ww, ok := w.(writer)
+ if !ok {
+ bw = bufio.NewWriter(w)
+ ww = bw
+ }
+ aw := &textWriter{
+ w: ww,
+ complete: true,
+ compact: tm.Compact,
+ }
+
+ if etm, ok := pb.(encoding.TextMarshaler); ok {
+ text, err := etm.MarshalText()
+ if err != nil {
+ return err
+ }
+ if _, err = aw.Write(text); err != nil {
+ return err
+ }
+ if bw != nil {
+ return bw.Flush()
+ }
+ return nil
+ }
+ // Dereference the received pointer so we don't have outer < and >.
+ v := reflect.Indirect(val)
+ if err := tm.writeStruct(aw, v); err != nil {
+ return err
+ }
+ if bw != nil {
+ return bw.Flush()
+ }
+ return nil
+}
+
+// Text is the same as Marshal, but returns the string directly.
+func (tm *TextMarshaler) Text(pb Message) string {
+ var buf bytes.Buffer
+ tm.Marshal(&buf, pb)
+ return buf.String()
+}
+
+var (
+ defaultTextMarshaler = TextMarshaler{}
+ compactTextMarshaler = TextMarshaler{Compact: true}
+)
+
+// TODO: consider removing some of the Marshal functions below.
+
+// MarshalText writes a given protocol buffer in text format.
+// The only errors returned are from w.
+func MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) }
+
+// MarshalTextString is the same as MarshalText, but returns the string directly.
+func MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) }
+
+// CompactText writes a given protocol buffer in compact text format (one line).
+func CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) }
+
+// CompactTextString is the same as CompactText, but returns the string directly.
+func CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) }
diff --git a/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/text_parser.go b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/text_parser.go
new file mode 100644
index 00000000..bb55a3af
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/golang/protobuf/proto/text_parser.go
@@ -0,0 +1,880 @@
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// https://github.com/golang/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+// Functions for parsing the Text protocol buffer format.
+// TODO: message sets.
+
+import (
+ "encoding"
+ "errors"
+ "fmt"
+ "reflect"
+ "strconv"
+ "strings"
+ "unicode/utf8"
+)
+
+// Error string emitted when deserializing Any and fields are already set
+const anyRepeatedlyUnpacked = "Any message unpacked multiple times, or %q already set"
+
+type ParseError struct {
+ Message string
+ Line int // 1-based line number
+ Offset int // 0-based byte offset from start of input
+}
+
+func (p *ParseError) Error() string {
+ if p.Line == 1 {
+ // show offset only for first line
+ return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message)
+ }
+ return fmt.Sprintf("line %d: %v", p.Line, p.Message)
+}
+
+type token struct {
+ value string
+ err *ParseError
+ line int // line number
+ offset int // byte number from start of input, not start of line
+ unquoted string // the unquoted version of value, if it was a quoted string
+}
+
+func (t *token) String() string {
+ if t.err == nil {
+ return fmt.Sprintf("%q (line=%d, offset=%d)", t.value, t.line, t.offset)
+ }
+ return fmt.Sprintf("parse error: %v", t.err)
+}
+
+type textParser struct {
+ s string // remaining input
+ done bool // whether the parsing is finished (success or error)
+ backed bool // whether back() was called
+ offset, line int
+ cur token
+}
+
+func newTextParser(s string) *textParser {
+ p := new(textParser)
+ p.s = s
+ p.line = 1
+ p.cur.line = 1
+ return p
+}
+
+func (p *textParser) errorf(format string, a ...interface{}) *ParseError {
+ pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset}
+ p.cur.err = pe
+ p.done = true
+ return pe
+}
+
+// Numbers and identifiers are matched by [-+._A-Za-z0-9]
+func isIdentOrNumberChar(c byte) bool {
+ switch {
+ case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z':
+ return true
+ case '0' <= c && c <= '9':
+ return true
+ }
+ switch c {
+ case '-', '+', '.', '_':
+ return true
+ }
+ return false
+}
+
+func isWhitespace(c byte) bool {
+ switch c {
+ case ' ', '\t', '\n', '\r':
+ return true
+ }
+ return false
+}
+
+func isQuote(c byte) bool {
+ switch c {
+ case '"', '\'':
+ return true
+ }
+ return false
+}
+
+func (p *textParser) skipWhitespace() {
+ i := 0
+ for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') {
+ if p.s[i] == '#' {
+ // comment; skip to end of line or input
+ for i < len(p.s) && p.s[i] != '\n' {
+ i++
+ }
+ if i == len(p.s) {
+ break
+ }
+ }
+ if p.s[i] == '\n' {
+ p.line++
+ }
+ i++
+ }
+ p.offset += i
+ p.s = p.s[i:len(p.s)]
+ if len(p.s) == 0 {
+ p.done = true
+ }
+}
+
+func (p *textParser) advance() {
+ // Skip whitespace
+ p.skipWhitespace()
+ if p.done {
+ return
+ }
+
+ // Start of non-whitespace
+ p.cur.err = nil
+ p.cur.offset, p.cur.line = p.offset, p.line
+ p.cur.unquoted = ""
+ switch p.s[0] {
+ case '<', '>', '{', '}', ':', '[', ']', ';', ',', '/':
+ // Single symbol
+ p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)]
+ case '"', '\'':
+ // Quoted string
+ i := 1
+ for i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\n' {
+ if p.s[i] == '\\' && i+1 < len(p.s) {
+ // skip escaped char
+ i++
+ }
+ i++
+ }
+ if i >= len(p.s) || p.s[i] != p.s[0] {
+ p.errorf("unmatched quote")
+ return
+ }
+ unq, err := unquoteC(p.s[1:i], rune(p.s[0]))
+ if err != nil {
+ p.errorf("invalid quoted string %s: %v", p.s[0:i+1], err)
+ return
+ }
+ p.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)]
+ p.cur.unquoted = unq
+ default:
+ i := 0
+ for i < len(p.s) && isIdentOrNumberChar(p.s[i]) {
+ i++
+ }
+ if i == 0 {
+ p.errorf("unexpected byte %#x", p.s[0])
+ return
+ }
+ p.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)]
+ }
+ p.offset += len(p.cur.value)
+}
+
+var (
+ errBadUTF8 = errors.New("proto: bad UTF-8")
+)
+
+func unquoteC(s string, quote rune) (string, error) {
+ // This is based on C++'s tokenizer.cc.
+ // Despite its name, this is *not* parsing C syntax.
+ // For instance, "\0" is an invalid quoted string.
+
+ // Avoid allocation in trivial cases.
+ simple := true
+ for _, r := range s {
+ if r == '\\' || r == quote {
+ simple = false
+ break
+ }
+ }
+ if simple {
+ return s, nil
+ }
+
+ buf := make([]byte, 0, 3*len(s)/2)
+ for len(s) > 0 {
+ r, n := utf8.DecodeRuneInString(s)
+ if r == utf8.RuneError && n == 1 {
+ return "", errBadUTF8
+ }
+ s = s[n:]
+ if r != '\\' {
+ if r < utf8.RuneSelf {
+ buf = append(buf, byte(r))
+ } else {
+ buf = append(buf, string(r)...)
+ }
+ continue
+ }
+
+ ch, tail, err := unescape(s)
+ if err != nil {
+ return "", err
+ }
+ buf = append(buf, ch...)
+ s = tail
+ }
+ return string(buf), nil
+}
+
+func unescape(s string) (ch string, tail string, err error) {
+ r, n := utf8.DecodeRuneInString(s)
+ if r == utf8.RuneError && n == 1 {
+ return "", "", errBadUTF8
+ }
+ s = s[n:]
+ switch r {
+ case 'a':
+ return "\a", s, nil
+ case 'b':
+ return "\b", s, nil
+ case 'f':
+ return "\f", s, nil
+ case 'n':
+ return "\n", s, nil
+ case 'r':
+ return "\r", s, nil
+ case 't':
+ return "\t", s, nil
+ case 'v':
+ return "\v", s, nil
+ case '?':
+ return "?", s, nil // trigraph workaround
+ case '\'', '"', '\\':
+ return string(r), s, nil
+ case '0', '1', '2', '3', '4', '5', '6', '7':
+ if len(s) < 2 {
+ return "", "", fmt.Errorf(`\%c requires 2 following digits`, r)
+ }
+ ss := string(r) + s[:2]
+ s = s[2:]
+ i, err := strconv.ParseUint(ss, 8, 8)
+ if err != nil {
+ return "", "", fmt.Errorf(`\%s contains non-octal digits`, ss)
+ }
+ return string([]byte{byte(i)}), s, nil
+ case 'x', 'X', 'u', 'U':
+ var n int
+ switch r {
+ case 'x', 'X':
+ n = 2
+ case 'u':
+ n = 4
+ case 'U':
+ n = 8
+ }
+ if len(s) < n {
+ return "", "", fmt.Errorf(`\%c requires %d following digits`, r, n)
+ }
+ ss := s[:n]
+ s = s[n:]
+ i, err := strconv.ParseUint(ss, 16, 64)
+ if err != nil {
+ return "", "", fmt.Errorf(`\%c%s contains non-hexadecimal digits`, r, ss)
+ }
+ if r == 'x' || r == 'X' {
+ return string([]byte{byte(i)}), s, nil
+ }
+ if i > utf8.MaxRune {
+ return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss)
+ }
+ return string(i), s, nil
+ }
+ return "", "", fmt.Errorf(`unknown escape \%c`, r)
+}
+
+// Back off the parser by one token. Can only be done between calls to next().
+// It makes the next advance() a no-op.
+func (p *textParser) back() { p.backed = true }
+
+// Advances the parser and returns the new current token.
+func (p *textParser) next() *token {
+ if p.backed || p.done {
+ p.backed = false
+ return &p.cur
+ }
+ p.advance()
+ if p.done {
+ p.cur.value = ""
+ } else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) {
+ // Look for multiple quoted strings separated by whitespace,
+ // and concatenate them.
+ cat := p.cur
+ for {
+ p.skipWhitespace()
+ if p.done || !isQuote(p.s[0]) {
+ break
+ }
+ p.advance()
+ if p.cur.err != nil {
+ return &p.cur
+ }
+ cat.value += " " + p.cur.value
+ cat.unquoted += p.cur.unquoted
+ }
+ p.done = false // parser may have seen EOF, but we want to return cat
+ p.cur = cat
+ }
+ return &p.cur
+}
+
+func (p *textParser) consumeToken(s string) error {
+ tok := p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ if tok.value != s {
+ p.back()
+ return p.errorf("expected %q, found %q", s, tok.value)
+ }
+ return nil
+}
+
+// Return a RequiredNotSetError indicating which required field was not set.
+func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError {
+ st := sv.Type()
+ sprops := GetProperties(st)
+ for i := 0; i < st.NumField(); i++ {
+ if !isNil(sv.Field(i)) {
+ continue
+ }
+
+ props := sprops.Prop[i]
+ if props.Required {
+ return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)}
+ }
+ }
+ return &RequiredNotSetError{fmt.Sprintf("%v.", st)} // should not happen
+}
+
+// Returns the index in the struct for the named field, as well as the parsed tag properties.
+func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) {
+ i, ok := sprops.decoderOrigNames[name]
+ if ok {
+ return i, sprops.Prop[i], true
+ }
+ return -1, nil, false
+}
+
+// Consume a ':' from the input stream (if the next token is a colon),
+// returning an error if a colon is needed but not present.
+func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError {
+ tok := p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ if tok.value != ":" {
+ // Colon is optional when the field is a group or message.
+ needColon := true
+ switch props.Wire {
+ case "group":
+ needColon = false
+ case "bytes":
+ // A "bytes" field is either a message, a string, or a repeated field;
+ // those three become *T, *string and []T respectively, so we can check for
+ // this field being a pointer to a non-string.
+ if typ.Kind() == reflect.Ptr {
+ // *T or *string
+ if typ.Elem().Kind() == reflect.String {
+ break
+ }
+ } else if typ.Kind() == reflect.Slice {
+ // []T or []*T
+ if typ.Elem().Kind() != reflect.Ptr {
+ break
+ }
+ } else if typ.Kind() == reflect.String {
+ // The proto3 exception is for a string field,
+ // which requires a colon.
+ break
+ }
+ needColon = false
+ }
+ if needColon {
+ return p.errorf("expected ':', found %q", tok.value)
+ }
+ p.back()
+ }
+ return nil
+}
+
+func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
+ st := sv.Type()
+ sprops := GetProperties(st)
+ reqCount := sprops.reqCount
+ var reqFieldErr error
+ fieldSet := make(map[string]bool)
+ // A struct is a sequence of "name: value", terminated by one of
+ // '>' or '}', or the end of the input. A name may also be
+ // "[extension]" or "[type/url]".
+ //
+ // The whole struct can also be an expanded Any message, like:
+ // [type/url] < ... struct contents ... >
+ for {
+ tok := p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ if tok.value == terminator {
+ break
+ }
+ if tok.value == "[" {
+ // Looks like an extension or an Any.
+ //
+ // TODO: Check whether we need to handle
+ // namespace rooted names (e.g. ".something.Foo").
+ extName, err := p.consumeExtName()
+ if err != nil {
+ return err
+ }
+
+ if s := strings.LastIndex(extName, "/"); s >= 0 {
+ // If it contains a slash, it's an Any type URL.
+ messageName := extName[s+1:]
+ mt := MessageType(messageName)
+ if mt == nil {
+ return p.errorf("unrecognized message %q in google.protobuf.Any", messageName)
+ }
+ tok = p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ // consume an optional colon
+ if tok.value == ":" {
+ tok = p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ }
+ var terminator string
+ switch tok.value {
+ case "<":
+ terminator = ">"
+ case "{":
+ terminator = "}"
+ default:
+ return p.errorf("expected '{' or '<', found %q", tok.value)
+ }
+ v := reflect.New(mt.Elem())
+ if pe := p.readStruct(v.Elem(), terminator); pe != nil {
+ return pe
+ }
+ b, err := Marshal(v.Interface().(Message))
+ if err != nil {
+ return p.errorf("failed to marshal message of type %q: %v", messageName, err)
+ }
+ if fieldSet["type_url"] {
+ return p.errorf(anyRepeatedlyUnpacked, "type_url")
+ }
+ if fieldSet["value"] {
+ return p.errorf(anyRepeatedlyUnpacked, "value")
+ }
+ sv.FieldByName("TypeUrl").SetString(extName)
+ sv.FieldByName("Value").SetBytes(b)
+ fieldSet["type_url"] = true
+ fieldSet["value"] = true
+ continue
+ }
+
+ var desc *ExtensionDesc
+ // This could be faster, but it's functional.
+ // TODO: Do something smarter than a linear scan.
+ for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) {
+ if d.Name == extName {
+ desc = d
+ break
+ }
+ }
+ if desc == nil {
+ return p.errorf("unrecognized extension %q", extName)
+ }
+
+ props := &Properties{}
+ props.Parse(desc.Tag)
+
+ typ := reflect.TypeOf(desc.ExtensionType)
+ if err := p.checkForColon(props, typ); err != nil {
+ return err
+ }
+
+ rep := desc.repeated()
+
+ // Read the extension structure, and set it in
+ // the value we're constructing.
+ var ext reflect.Value
+ if !rep {
+ ext = reflect.New(typ).Elem()
+ } else {
+ ext = reflect.New(typ.Elem()).Elem()
+ }
+ if err := p.readAny(ext, props); err != nil {
+ if _, ok := err.(*RequiredNotSetError); !ok {
+ return err
+ }
+ reqFieldErr = err
+ }
+ ep := sv.Addr().Interface().(Message)
+ if !rep {
+ SetExtension(ep, desc, ext.Interface())
+ } else {
+ old, err := GetExtension(ep, desc)
+ var sl reflect.Value
+ if err == nil {
+ sl = reflect.ValueOf(old) // existing slice
+ } else {
+ sl = reflect.MakeSlice(typ, 0, 1)
+ }
+ sl = reflect.Append(sl, ext)
+ SetExtension(ep, desc, sl.Interface())
+ }
+ if err := p.consumeOptionalSeparator(); err != nil {
+ return err
+ }
+ continue
+ }
+
+ // This is a normal, non-extension field.
+ name := tok.value
+ var dst reflect.Value
+ fi, props, ok := structFieldByName(sprops, name)
+ if ok {
+ dst = sv.Field(fi)
+ } else if oop, ok := sprops.OneofTypes[name]; ok {
+ // It is a oneof.
+ props = oop.Prop
+ nv := reflect.New(oop.Type.Elem())
+ dst = nv.Elem().Field(0)
+ field := sv.Field(oop.Field)
+ if !field.IsNil() {
+ return p.errorf("field '%s' would overwrite already parsed oneof '%s'", name, sv.Type().Field(oop.Field).Name)
+ }
+ field.Set(nv)
+ }
+ if !dst.IsValid() {
+ return p.errorf("unknown field name %q in %v", name, st)
+ }
+
+ if dst.Kind() == reflect.Map {
+ // Consume any colon.
+ if err := p.checkForColon(props, dst.Type()); err != nil {
+ return err
+ }
+
+ // Construct the map if it doesn't already exist.
+ if dst.IsNil() {
+ dst.Set(reflect.MakeMap(dst.Type()))
+ }
+ key := reflect.New(dst.Type().Key()).Elem()
+ val := reflect.New(dst.Type().Elem()).Elem()
+
+ // The map entry should be this sequence of tokens:
+ // < key : KEY value : VALUE >
+ // However, implementations may omit key or value, and technically
+ // we should support them in any order. See b/28924776 for a time
+ // this went wrong.
+
+ tok := p.next()
+ var terminator string
+ switch tok.value {
+ case "<":
+ terminator = ">"
+ case "{":
+ terminator = "}"
+ default:
+ return p.errorf("expected '{' or '<', found %q", tok.value)
+ }
+ for {
+ tok := p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ if tok.value == terminator {
+ break
+ }
+ switch tok.value {
+ case "key":
+ if err := p.consumeToken(":"); err != nil {
+ return err
+ }
+ if err := p.readAny(key, props.MapKeyProp); err != nil {
+ return err
+ }
+ if err := p.consumeOptionalSeparator(); err != nil {
+ return err
+ }
+ case "value":
+ if err := p.checkForColon(props.MapValProp, dst.Type().Elem()); err != nil {
+ return err
+ }
+ if err := p.readAny(val, props.MapValProp); err != nil {
+ return err
+ }
+ if err := p.consumeOptionalSeparator(); err != nil {
+ return err
+ }
+ default:
+ p.back()
+ return p.errorf(`expected "key", "value", or %q, found %q`, terminator, tok.value)
+ }
+ }
+
+ dst.SetMapIndex(key, val)
+ continue
+ }
+
+ // Check that it's not already set if it's not a repeated field.
+ if !props.Repeated && fieldSet[name] {
+ return p.errorf("non-repeated field %q was repeated", name)
+ }
+
+ if err := p.checkForColon(props, dst.Type()); err != nil {
+ return err
+ }
+
+ // Parse into the field.
+ fieldSet[name] = true
+ if err := p.readAny(dst, props); err != nil {
+ if _, ok := err.(*RequiredNotSetError); !ok {
+ return err
+ }
+ reqFieldErr = err
+ }
+ if props.Required {
+ reqCount--
+ }
+
+ if err := p.consumeOptionalSeparator(); err != nil {
+ return err
+ }
+
+ }
+
+ if reqCount > 0 {
+ return p.missingRequiredFieldError(sv)
+ }
+ return reqFieldErr
+}
+
+// consumeExtName consumes extension name or expanded Any type URL and the
+// following ']'. It returns the name or URL consumed.
+func (p *textParser) consumeExtName() (string, error) {
+ tok := p.next()
+ if tok.err != nil {
+ return "", tok.err
+ }
+
+ // If extension name or type url is quoted, it's a single token.
+ if len(tok.value) > 2 && isQuote(tok.value[0]) && tok.value[len(tok.value)-1] == tok.value[0] {
+ name, err := unquoteC(tok.value[1:len(tok.value)-1], rune(tok.value[0]))
+ if err != nil {
+ return "", err
+ }
+ return name, p.consumeToken("]")
+ }
+
+ // Consume everything up to "]"
+ var parts []string
+ for tok.value != "]" {
+ parts = append(parts, tok.value)
+ tok = p.next()
+ if tok.err != nil {
+ return "", p.errorf("unrecognized type_url or extension name: %s", tok.err)
+ }
+ if p.done && tok.value != "]" {
+ return "", p.errorf("unclosed type_url or extension name")
+ }
+ }
+ return strings.Join(parts, ""), nil
+}
+
+// consumeOptionalSeparator consumes an optional semicolon or comma.
+// It is used in readStruct to provide backward compatibility.
+func (p *textParser) consumeOptionalSeparator() error {
+ tok := p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ if tok.value != ";" && tok.value != "," {
+ p.back()
+ }
+ return nil
+}
+
+func (p *textParser) readAny(v reflect.Value, props *Properties) error {
+ tok := p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ if tok.value == "" {
+ return p.errorf("unexpected EOF")
+ }
+
+ switch fv := v; fv.Kind() {
+ case reflect.Slice:
+ at := v.Type()
+ if at.Elem().Kind() == reflect.Uint8 {
+ // Special case for []byte
+ if tok.value[0] != '"' && tok.value[0] != '\'' {
+ // Deliberately written out here, as the error after
+ // this switch statement would write "invalid []byte: ...",
+ // which is not as user-friendly.
+ return p.errorf("invalid string: %v", tok.value)
+ }
+ bytes := []byte(tok.unquoted)
+ fv.Set(reflect.ValueOf(bytes))
+ return nil
+ }
+ // Repeated field.
+ if tok.value == "[" {
+ // Repeated field with list notation, like [1,2,3].
+ for {
+ fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem()))
+ err := p.readAny(fv.Index(fv.Len()-1), props)
+ if err != nil {
+ return err
+ }
+ tok := p.next()
+ if tok.err != nil {
+ return tok.err
+ }
+ if tok.value == "]" {
+ break
+ }
+ if tok.value != "," {
+ return p.errorf("Expected ']' or ',' found %q", tok.value)
+ }
+ }
+ return nil
+ }
+ // One value of the repeated field.
+ p.back()
+ fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem()))
+ return p.readAny(fv.Index(fv.Len()-1), props)
+ case reflect.Bool:
+ // true/1/t/True or false/f/0/False.
+ switch tok.value {
+ case "true", "1", "t", "True":
+ fv.SetBool(true)
+ return nil
+ case "false", "0", "f", "False":
+ fv.SetBool(false)
+ return nil
+ }
+ case reflect.Float32, reflect.Float64:
+ v := tok.value
+ // Ignore 'f' for compatibility with output generated by C++, but don't
+ // remove 'f' when the value is "-inf" or "inf".
+ if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" {
+ v = v[:len(v)-1]
+ }
+ if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil {
+ fv.SetFloat(f)
+ return nil
+ }
+ case reflect.Int32:
+ if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil {
+ fv.SetInt(x)
+ return nil
+ }
+
+ if len(props.Enum) == 0 {
+ break
+ }
+ m, ok := enumValueMaps[props.Enum]
+ if !ok {
+ break
+ }
+ x, ok := m[tok.value]
+ if !ok {
+ break
+ }
+ fv.SetInt(int64(x))
+ return nil
+ case reflect.Int64:
+ if x, err := strconv.ParseInt(tok.value, 0, 64); err == nil {
+ fv.SetInt(x)
+ return nil
+ }
+
+ case reflect.Ptr:
+ // A basic field (indirected through pointer), or a repeated message/group
+ p.back()
+ fv.Set(reflect.New(fv.Type().Elem()))
+ return p.readAny(fv.Elem(), props)
+ case reflect.String:
+ if tok.value[0] == '"' || tok.value[0] == '\'' {
+ fv.SetString(tok.unquoted)
+ return nil
+ }
+ case reflect.Struct:
+ var terminator string
+ switch tok.value {
+ case "{":
+ terminator = "}"
+ case "<":
+ terminator = ">"
+ default:
+ return p.errorf("expected '{' or '<', found %q", tok.value)
+ }
+ // TODO: Handle nested messages which implement encoding.TextUnmarshaler.
+ return p.readStruct(fv, terminator)
+ case reflect.Uint32:
+ if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
+ fv.SetUint(uint64(x))
+ return nil
+ }
+ case reflect.Uint64:
+ if x, err := strconv.ParseUint(tok.value, 0, 64); err == nil {
+ fv.SetUint(x)
+ return nil
+ }
+ }
+ return p.errorf("invalid %v: %v", v.Type(), tok.value)
+}
+
+// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb
+// before starting to unmarshal, so any existing data in pb is always removed.
+// If a required field is not set and no other error occurs,
+// UnmarshalText returns *RequiredNotSetError.
+func UnmarshalText(s string, pb Message) error {
+ if um, ok := pb.(encoding.TextUnmarshaler); ok {
+ return um.UnmarshalText([]byte(s))
+ }
+ pb.Reset()
+ v := reflect.ValueOf(pb)
+ return newTextParser(s).readStruct(v.Elem(), "")
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/.travis.yml b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/.travis.yml
deleted file mode 100644
index 4f2ee4d9..00000000
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/.travis.yml
+++ /dev/null
@@ -1 +0,0 @@
-language: go
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/README.md b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/README.md
index cab0f9fa..b7848de6 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/README.md
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/README.md
@@ -3,13 +3,10 @@
src="logo.png"
width="240" height="78" border="0" alt="GJSON">
-
-
-
get json values quickly
GJSON is a Go package that provides a [fast](#performance) and [simple](#get-a-value) way to get values from a json document.
@@ -126,11 +123,12 @@ nil, for JSON null
To directly access the value:
```go
-result.Type // can be String, Number, True, False, Null, or JSON
-result.Str // holds the string
-result.Num // holds the float64 number
-result.Raw // holds the raw json
-result.Index // index of raw value in original json, zero means index unknown
+result.Type // can be String, Number, True, False, Null, or JSON
+result.Str // holds the string
+result.Num // holds the float64 number
+result.Raw // holds the raw json
+result.Index // index of raw value in original json, zero means index unknown
+result.Indexes // indexes of all the elements that match on a path containing the '#' query character.
```
There are a variety of handy functions that work on a result:
@@ -153,10 +151,6 @@ result.Less(token Result, caseSensitive bool) bool
The `result.Value()` function returns an `interface{}` which requires type assertion and is one of the following Go types:
-The `result.Array()` function returns back an array of values.
-If the result represents a non-existent value, then an empty array will be returned.
-If the result is not a JSON array, the return value will be an array containing one result.
-
```go
boolean >> bool
number >> float64
@@ -166,6 +160,10 @@ array >> []interface{}
object >> map[string]interface{}
```
+The `result.Array()` function returns back an array of values.
+If the result represents a non-existent value, then an empty array will be returned.
+If the result is not a JSON array, the return value will be an array containing one result.
+
### 64-bit integers
The `result.Int()` and `result.Uint()` calls are capable of reading all 64 bits, allowing for large JSON integers.
@@ -193,11 +191,15 @@ we'll get `children` array and reverse the order:
"children|@reverse|0" >> "Jack"
```
-There are currently three built-in modifiers:
+There are currently the following built-in modifiers:
- `@reverse`: Reverse an array or the members of an object.
- `@ugly`: Remove all whitespace from a json document.
- `@pretty`: Make the json document more human readable.
+- `@this`: Returns the current element. It can be used to retrieve the root element.
+- `@valid`: Ensure the json document is valid.
+- `@flatten`: Flattens an array.
+- `@join`: Joins multiple objects into a single object.
### Modifier arguments
@@ -472,7 +474,7 @@ JSON document used:
}
```
-Each operation was rotated though one of the following search paths:
+Each operation was rotated through one of the following search paths:
```
widget.window.name
@@ -480,12 +482,4 @@ widget.image.hOffset
widget.text.onMouseUp
```
-*These benchmarks were run on a MacBook Pro 15" 2.8 GHz Intel Core i7 using Go 1.8 and can be be found [here](https://github.com/tidwall/gjson-benchmarks).*
-
-
-## Contact
-Josh Baker [@tidwall](http://twitter.com/tidwall)
-
-## License
-
-GJSON source code is available under the MIT [License](/LICENSE).
+*These benchmarks were run on a MacBook Pro 15" 2.8 GHz Intel Core i7 using Go 1.8 and can be found [here](https://github.com/tidwall/gjson-benchmarks).*
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/SYNTAX.md b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/SYNTAX.md
index dda33af4..34fdccf4 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/SYNTAX.md
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/SYNTAX.md
@@ -12,6 +12,7 @@ This document is designed to explain the structure of a GJSON Path through examp
- [Queries](#queries)
- [Dot vs Pipe](#dot-vs-pipe)
- [Modifiers](#modifiers)
+- [Multipaths](#multipaths)
The definitive implemenation is [github.com/tidwall/gjson](https://github.com/tidwall/gjson).
Use the [GJSON Playground](https://gjson.dev) to experiment with the syntax online.
@@ -76,6 +77,21 @@ Special purpose characters, such as `.`, `*`, and `?` can be escaped with `\`.
fav\.movie "Deer Hunter"
```
+You'll also need to make sure that the `\` character is correctly escaped when hardcoding a path in you source code.
+
+```go
+// Go
+val := gjson.Get(json, "fav\\.movie") // must escape the slash
+val := gjson.Get(json, `fav\.movie`) // no need to escape the slash
+```
+
+```rust
+// Rust
+let val = gjson::get(json, "fav\\.movie") // must escape the slash
+let val = gjson::get(json, r#"fav\.movie"#) // no need to escape the slash
+```
+
+
### Arrays
The `#` character allows for digging into JSON Arrays.
@@ -119,6 +135,37 @@ changed in v1.3.0 as to avoid confusion with the new [multipath](#multipaths)
syntax. For backwards compatibility, `#[...]` will continue to work until the
next major release.*
+The `~` (tilde) operator will convert a value to a boolean before comparison.
+
+For example, using the following JSON:
+
+```json
+{
+ "vals": [
+ { "a": 1, "b": true },
+ { "a": 2, "b": true },
+ { "a": 3, "b": false },
+ { "a": 4, "b": "0" },
+ { "a": 5, "b": 0 },
+ { "a": 6, "b": "1" },
+ { "a": 7, "b": 1 },
+ { "a": 8, "b": "true" },
+ { "a": 9, "b": false },
+ { "a": 10, "b": null },
+ { "a": 11 }
+ ]
+}
+```
+
+You can now query for all true(ish) or false(ish) values:
+
+```
+vals.#(b==~true)#.a >> [1,2,6,7,8]
+vals.#(b==~false)#.a >> [3,4,5,9,10,11]
+```
+
+The last value which was non-existent is treated as `false`
+
### Dot vs Pipe
The `.` is standard separator, but it's also possible to use a `|`.
@@ -180,11 +227,15 @@ children.@reverse ["Jack","Alex","Sara"]
children.@reverse.0 "Jack"
```
-There are currently three built-in modifiers:
+There are currently the following built-in modifiers:
- `@reverse`: Reverse an array or the members of an object.
- `@ugly`: Remove all whitespace from JSON.
- `@pretty`: Make the JSON more human readable.
+- `@this`: Returns the current element. It can be used to retrieve the root element.
+- `@valid`: Ensure the json document is valid.
+- `@flatten`: Flattens an array.
+- `@join`: Joins multiple objects into a single object.
#### Modifier arguments
@@ -235,11 +286,13 @@ gjson.AddModifier("case", func(json, arg string) string {
"children.@case:lower.@reverse" ["jack","alex","sara"]
```
-#### Multipaths
+*Note: Custom modifiers are not yet available in the Rust version*
+
+### Multipaths
Starting with v1.3.0, GJSON added the ability to join multiple paths together
-to form new documents. Wrapping comma-separated paths between `{...}` or
-`[...]` will result in a new array or object, respectively.
+to form new documents. Wrapping comma-separated paths between `[...]` or
+`{...}` will result in a new array or object, respectively.
For example, using the given multipath
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson.go b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson.go
index 9fe40b58..95d210b2 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson.go
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson.go
@@ -2,17 +2,13 @@
package gjson
import (
- "encoding/base64"
"encoding/json"
- "errors"
- "reflect"
"strconv"
"strings"
- "sync"
- "sync/atomic"
"time"
"unicode/utf16"
"unicode/utf8"
+ "unsafe"
"github.com/tidwall/match"
"github.com/tidwall/pretty"
@@ -68,6 +64,9 @@ type Result struct {
Num float64
// Index of raw value in original json, zero means index unknown
Index int
+ // Indexes of all the elements that match on a path containing the '#'
+ // query character.
+ Indexes []int
}
// String returns a string representation of the value.
@@ -109,7 +108,8 @@ func (t Result) Bool() bool {
case True:
return true
case String:
- return t.Str != "" && t.Str != "0" && t.Str != "false"
+ b, _ := strconv.ParseBool(strings.ToLower(t.Str))
+ return b
case Number:
return t.Num != 0
}
@@ -127,16 +127,17 @@ func (t Result) Int() int64 {
return n
case Number:
// try to directly convert the float64 to int64
- n, ok := floatToInt(t.Num)
- if !ok {
- // now try to parse the raw string
- n, ok = parseInt(t.Raw)
- if !ok {
- // fallback to a standard conversion
- return int64(t.Num)
- }
+ i, ok := safeInt(t.Num)
+ if ok {
+ return i
}
- return n
+ // now try to parse the raw string
+ i, ok = parseInt(t.Raw)
+ if ok {
+ return i
+ }
+ // fallback to a standard conversion
+ return int64(t.Num)
}
}
@@ -152,16 +153,17 @@ func (t Result) Uint() uint64 {
return n
case Number:
// try to directly convert the float64 to uint64
- n, ok := floatToUint(t.Num)
- if !ok {
- // now try to parse the raw string
- n, ok = parseUint(t.Raw)
- if !ok {
- // fallback to a standard conversion
- return uint64(t.Num)
- }
+ i, ok := safeInt(t.Num)
+ if ok && i >= 0 {
+ return uint64(i)
}
- return n
+ // now try to parse the raw string
+ u, ok := parseUint(t.Raw)
+ if ok {
+ return u
+ }
+ // fallback to a standard conversion
+ return uint64(t.Num)
}
}
@@ -282,7 +284,8 @@ func (t Result) ForEach(iterator func(key, value Result) bool) {
}
}
-// Map returns back an map of values. The result should be a JSON array.
+// Map returns back a map of values. The result should be a JSON object.
+// If the result is not a JSON object, the return value will be an empty map.
func (t Result) Map() map[string]Result {
if t.Type != JSON {
return map[string]Result{}
@@ -464,11 +467,13 @@ func ParseBytes(json []byte) Result {
}
func squash(json string) string {
- // expects that the lead character is a '[' or '{'
+ // expects that the lead character is a '[' or '{' or '(' or '"'
// squash the value, ignoring all nested arrays and objects.
- // the first '[' or '{' has already been read
- depth := 1
- for i := 1; i < len(json); i++ {
+ var i, depth int
+ if json[0] != '"' {
+ i, depth = 1, 1
+ }
+ for ; i < len(json); i++ {
if json[i] >= '"' && json[i] <= '}' {
switch json[i] {
case '"':
@@ -495,9 +500,15 @@ func squash(json string) string {
break
}
}
- case '{', '[':
+ if depth == 0 {
+ if i >= len(json) {
+ return json
+ }
+ return json[:i+1]
+ }
+ case '{', '[', '(':
depth++
- case '}', ']':
+ case '}', ']', ')':
depth--
if depth == 0 {
return json[:i+1]
@@ -577,7 +588,7 @@ func tostr(json string) (raw string, str string) {
continue
}
}
- break
+ return json[:i+1], unescape(json[1:i])
}
}
var ret string
@@ -707,10 +718,10 @@ type arrayPathResult struct {
alogkey string
query struct {
on bool
+ all bool
path string
op string
value string
- all bool
}
}
@@ -724,8 +735,13 @@ func parseArrayPath(path string) (r arrayPathResult) {
}
if path[i] == '.' {
r.part = path[:i]
- r.path = path[i+1:]
- r.more = true
+ if !r.arrch && i < len(path)-1 && isDotPiperChar(path[i+1]) {
+ r.pipe = path[i+1:]
+ r.piped = true
+ } else {
+ r.path = path[i+1:]
+ r.more = true
+ }
return
}
if path[i] == '#' {
@@ -738,120 +754,27 @@ func parseArrayPath(path string) (r arrayPathResult) {
} else if path[1] == '[' || path[1] == '(' {
// query
r.query.on = true
- if true {
- qpath, op, value, _, fi, ok := parseQuery(path[i:])
- if !ok {
- // bad query, end now
- break
- }
- r.query.path = qpath
- r.query.op = op
- r.query.value = value
- i = fi - 1
- if i+1 < len(path) && path[i+1] == '#' {
- r.query.all = true
- }
- } else {
- var end byte
- if path[1] == '[' {
- end = ']'
- } else {
- end = ')'
- }
- i += 2
- // whitespace
- for ; i < len(path); i++ {
- if path[i] > ' ' {
- break
- }
- }
- s := i
- for ; i < len(path); i++ {
- if path[i] <= ' ' ||
- path[i] == '!' ||
- path[i] == '=' ||
- path[i] == '<' ||
- path[i] == '>' ||
- path[i] == '%' ||
- path[i] == end {
- break
- }
- }
- r.query.path = path[s:i]
- // whitespace
- for ; i < len(path); i++ {
- if path[i] > ' ' {
- break
- }
- }
- if i < len(path) {
- s = i
- if path[i] == '!' {
- if i < len(path)-1 && (path[i+1] == '=' ||
- path[i+1] == '%') {
- i++
- }
- } else if path[i] == '<' || path[i] == '>' {
- if i < len(path)-1 && path[i+1] == '=' {
- i++
- }
- } else if path[i] == '=' {
- if i < len(path)-1 && path[i+1] == '=' {
- s++
- i++
- }
- }
- i++
- r.query.op = path[s:i]
- // whitespace
- for ; i < len(path); i++ {
- if path[i] > ' ' {
- break
- }
- }
- s = i
- for ; i < len(path); i++ {
- if path[i] == '"' {
- i++
- s2 := i
- for ; i < len(path); i++ {
- if path[i] > '\\' {
- continue
- }
- if path[i] == '"' {
- // look for an escaped slash
- if path[i-1] == '\\' {
- n := 0
- for j := i - 2; j > s2-1; j-- {
- if path[j] != '\\' {
- break
- }
- n++
- }
- if n%2 == 0 {
- continue
- }
- }
- break
- }
- }
- } else if path[i] == end {
- if i+1 < len(path) && path[i+1] == '#' {
- r.query.all = true
- }
- break
- }
- }
- if i > len(path) {
- i = len(path)
- }
- v := path[s:i]
- for len(v) > 0 && v[len(v)-1] <= ' ' {
- v = v[:len(v)-1]
- }
- r.query.value = v
+ qpath, op, value, _, fi, vesc, ok :=
+ parseQuery(path[i:])
+ if !ok {
+ // bad query, end now
+ break
+ }
+ if len(value) > 2 && value[0] == '"' &&
+ value[len(value)-1] == '"' {
+ value = value[1 : len(value)-1]
+ if vesc {
+ value = unescape(value)
}
}
+ r.query.path = qpath
+ r.query.op = op
+ r.query.value = value
+
+ i = fi - 1
+ if i+1 < len(path) && path[i+1] == '#' {
+ r.query.all = true
+ }
}
}
continue
@@ -877,11 +800,11 @@ func parseArrayPath(path string) (r arrayPathResult) {
// # middle
// .cap # right
func parseQuery(query string) (
- path, op, value, remain string, i int, ok bool,
+ path, op, value, remain string, i int, vesc, ok bool,
) {
if len(query) < 2 || query[0] != '#' ||
(query[1] != '(' && query[1] != '[') {
- return "", "", "", "", i, false
+ return "", "", "", "", i, false, false
}
i = 2
j := 0 // start of value part
@@ -909,6 +832,7 @@ func parseQuery(query string) (
i++
for ; i < len(query); i++ {
if query[i] == '\\' {
+ vesc = true
i++
} else if query[i] == '"' {
break
@@ -917,7 +841,7 @@ func parseQuery(query string) (
}
}
if depth > 0 {
- return "", "", "", "", i, false
+ return "", "", "", "", i, false, false
}
if j > 0 {
path = trim(query[2:j])
@@ -954,7 +878,7 @@ func parseQuery(query string) (
path = trim(query[2:i])
remain = query[i+1:]
}
- return path, op, value, remain, i + 1, true
+ return path, op, value, remain, i + 1, vesc, true
}
func trim(s string) string {
@@ -971,6 +895,11 @@ right:
return s
}
+// peek at the next byte and see if it's a '@', '[', or '{'.
+func isDotPiperChar(c byte) bool {
+ return !DisableModifiers && (c == '@' || c == '[' || c == '{')
+}
+
type objectPathResult struct {
part string
path string
@@ -989,12 +918,8 @@ func parseObjectPath(path string) (r objectPathResult) {
return
}
if path[i] == '.' {
- // peek at the next byte and see if it's a '@', '[', or '{'.
r.part = path[:i]
- if !DisableModifiers &&
- i < len(path)-1 &&
- (path[i+1] == '@' ||
- path[i+1] == '[' || path[i+1] == '{') {
+ if i < len(path)-1 && isDotPiperChar(path[i+1]) {
r.pipe = path[i+1:]
r.piped = true
} else {
@@ -1024,14 +949,11 @@ func parseObjectPath(path string) (r objectPathResult) {
continue
} else if path[i] == '.' {
r.part = string(epart)
- // peek at the next byte and see if it's a '@' modifier
- if !DisableModifiers &&
- i < len(path)-1 && path[i+1] == '@' {
+ if i < len(path)-1 && isDotPiperChar(path[i+1]) {
r.pipe = path[i+1:]
r.piped = true
} else {
r.path = path[i+1:]
- r.more = true
}
r.more = true
return
@@ -1056,9 +978,9 @@ func parseObjectPath(path string) (r objectPathResult) {
}
func parseSquash(json string, i int) (int, string) {
- // expects that the lead character is a '[' or '{'
+ // expects that the lead character is a '[' or '{' or '('
// squash the value, ignoring all nested arrays and objects.
- // the first '[' or '{' has already been read
+ // the first '[' or '{' or '(' has already been read
s := i
i++
depth := 1
@@ -1089,9 +1011,9 @@ func parseSquash(json string, i int) (int, string) {
break
}
}
- case '{', '[':
+ case '{', '[', '(':
depth++
- case '}', ']':
+ case '}', ']', ')':
depth--
if depth == 0 {
i++
@@ -1167,9 +1089,9 @@ func parseObject(c *parseContext, i int, path string) (int, bool) {
}
if rp.wild {
if kesc {
- pmatch = match.Match(unescape(key), rp.part)
+ pmatch = matchLimit(unescape(key), rp.part)
} else {
- pmatch = match.Match(key, rp.part)
+ pmatch = matchLimit(key, rp.part)
}
} else {
if kesc {
@@ -1254,10 +1176,25 @@ func parseObject(c *parseContext, i int, path string) (int, bool) {
}
return i, false
}
+
+// matchLimit will limit the complexity of the match operation to avoid ReDos
+// attacks from arbritary inputs.
+// See the github.com/tidwall/match.MatchLimit function for more information.
+func matchLimit(str, pattern string) bool {
+ matched, _ := match.MatchLimit(str, pattern, 10000)
+ return matched
+}
+
func queryMatches(rp *arrayPathResult, value Result) bool {
rpv := rp.query.value
- if len(rpv) > 2 && rpv[0] == '"' && rpv[len(rpv)-1] == '"' {
- rpv = rpv[1 : len(rpv)-1]
+ if len(rpv) > 0 && rpv[0] == '~' {
+ // convert to bool
+ rpv = rpv[1:]
+ if value.Bool() {
+ value = Result{Type: True}
+ } else {
+ value = Result{Type: False}
+ }
}
if !value.Exists() {
return false
@@ -1285,9 +1222,9 @@ func queryMatches(rp *arrayPathResult, value Result) bool {
case ">=":
return value.Str >= rpv
case "%":
- return match.Match(value.Str, rpv)
+ return matchLimit(value.Str, rpv)
case "!%":
- return !match.Match(value.Str, rpv)
+ return !matchLimit(value.Str, rpv)
}
case Number:
rpvn, _ := strconv.ParseFloat(rpv, 64)
@@ -1337,6 +1274,7 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
var alog []int
var partidx int
var multires []byte
+ var queryIndexes []int
rp := parseArrayPath(path)
if !rp.arrch {
n, ok := parseUint(rp.part)
@@ -1357,6 +1295,10 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
multires = append(multires, '[')
}
}
+ var tmp parseContext
+ tmp.value = qval
+ fillIndex(c.json, &tmp)
+ parentIndex := tmp.value.Index
var res Result
if qval.Type == JSON {
res = qval.Get(rp.query.path)
@@ -1388,6 +1330,7 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
multires = append(multires, ',')
}
multires = append(multires, raw...)
+ queryIndexes = append(queryIndexes, res.Index+parentIndex)
}
} else {
c.value = res
@@ -1396,7 +1339,6 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
}
return false
}
-
for i < len(c.json)+1 {
if !rp.arrch {
pmatch = partidx == h
@@ -1553,28 +1495,44 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
c.pipe = right
c.piped = true
}
+ var indexes = make([]int, 0, 64)
var jsons = make([]byte, 0, 64)
jsons = append(jsons, '[')
for j, k := 0, 0; j < len(alog); j++ {
- _, res, ok := parseAny(c.json, alog[j], true)
- if ok {
- res := res.Get(rp.alogkey)
- if res.Exists() {
- if k > 0 {
- jsons = append(jsons, ',')
- }
- raw := res.Raw
- if len(raw) == 0 {
- raw = res.String()
+ idx := alog[j]
+ for idx < len(c.json) {
+ switch c.json[idx] {
+ case ' ', '\t', '\r', '\n':
+ idx++
+ continue
+ }
+ break
+ }
+ if idx < len(c.json) && c.json[idx] != ']' {
+ _, res, ok := parseAny(c.json, idx, true)
+ parentIndex := res.Index
+ if ok {
+ res := res.Get(rp.alogkey)
+ if res.Exists() {
+ if k > 0 {
+ jsons = append(jsons, ',')
+ }
+ raw := res.Raw
+ if len(raw) == 0 {
+ raw = res.String()
+ }
+ jsons = append(jsons, []byte(raw)...)
+ indexes = append(indexes,
+ res.Index+parentIndex)
+ k++
}
- jsons = append(jsons, []byte(raw)...)
- k++
}
}
}
jsons = append(jsons, ']')
c.value.Type = JSON
c.value.Raw = string(jsons)
+ c.value.Indexes = indexes
return i + 1, true
}
if rp.alogok {
@@ -1587,10 +1545,18 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
c.calcd = true
return i + 1, true
}
- if len(multires) > 0 && !c.value.Exists() {
- c.value = Result{
- Raw: string(append(multires, ']')),
- Type: JSON,
+ if !c.value.Exists() {
+ if len(multires) > 0 {
+ c.value = Result{
+ Raw: string(append(multires, ']')),
+ Type: JSON,
+ Indexes: queryIndexes,
+ }
+ } else if rp.query.all {
+ c.value = Result{
+ Raw: "[]",
+ Type: JSON,
+ }
}
}
return i + 1, false
@@ -1615,10 +1581,21 @@ func splitPossiblePipe(path string) (left, right string, ok bool) {
return
}
+ if len(path) > 0 && path[0] == '{' {
+ squashed := squash(path[1:])
+ if len(squashed) < len(path)-1 {
+ squashed = path[:len(squashed)+1]
+ remain := path[len(squashed):]
+ if remain[0] == '|' {
+ return squashed, remain[1:], true
+ }
+ }
+ return
+ }
+
// split the left and right side of the path with the pipe character as
// the delimiter. This is a little tricky because we'll need to basically
// parse the entire path.
-
for i := 0; i < len(path); i++ {
if path[i] == '\\' {
i++
@@ -1699,6 +1676,7 @@ type subSelector struct {
// first character in path is either '[' or '{', and has already been checked
// prior to calling this function.
func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
+ modifer := 0
depth := 1
colon := 0
start := 1
@@ -1719,8 +1697,12 @@ func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
switch path[i] {
case '\\':
i++
+ case '@':
+ if modifer == 0 && i > 0 && (path[i-1] == '.' || path[i-1] == '|') {
+ modifer = i
+ }
case ':':
- if depth == 1 {
+ if modifer == 0 && colon == 0 && depth == 1 {
colon = i
}
case ',':
@@ -1806,7 +1788,7 @@ type parseContext struct {
// A path is in dot syntax, such as "name.last" or "age".
// When the value is found it's returned immediately.
//
-// A path is a series of keys searated by a dot.
+// A path is a series of keys separated by a dot.
// A key may contain special wildcard characters '*' and '?'.
// To access an array value use the index as the key.
// To get the number of elements in an array or to access a child path, use
@@ -1849,6 +1831,7 @@ func Get(json, path string) Result {
if len(path) > 0 && (path[0] == '|' || path[0] == '.') {
res := Get(rjson, path[1:])
res.Index = 0
+ res.Indexes = nil
return res
}
return Parse(rjson)
@@ -1915,7 +1898,6 @@ func Get(json, path string) Result {
}
}
}
-
var i int
var c = &parseContext{json: json}
if len(path) >= 2 && path[0] == '.' && path[1] == '.' {
@@ -1957,7 +1939,7 @@ func runeit(json string) rune {
}
// unescape unescapes a string
-func unescape(json string) string { //, error) {
+func unescape(json string) string {
var str = make([]byte, 0, len(json))
for i := 0; i < len(json); i++ {
switch {
@@ -2090,7 +2072,10 @@ func parseAny(json string, i int, hit bool) (int, Result, bool) {
res.Raw = val
res.Type = JSON
}
- return i, res, true
+ var tmp parseContext
+ tmp.value = res
+ fillIndex(json, &tmp)
+ return i, tmp.value, true
}
if json[i] <= ' ' {
continue
@@ -2140,11 +2125,6 @@ func parseAny(json string, i int, hit bool) (int, Result, bool) {
return i, res, false
}
-var ( // used for testing
- testWatchForFallback bool
- testLastWasFallback bool
-)
-
// GetMany searches json for the multiple paths.
// The return value is a Result array where the number of items
// will be equal to the number of input paths.
@@ -2167,145 +2147,6 @@ func GetManyBytes(json []byte, path ...string) []Result {
return res
}
-var fieldsmu sync.RWMutex
-var fields = make(map[string]map[string]int)
-
-func assign(jsval Result, goval reflect.Value) {
- if jsval.Type == Null {
- return
- }
- switch goval.Kind() {
- default:
- case reflect.Ptr:
- if !goval.IsNil() {
- newval := reflect.New(goval.Elem().Type())
- assign(jsval, newval.Elem())
- goval.Elem().Set(newval.Elem())
- } else {
- newval := reflect.New(goval.Type().Elem())
- assign(jsval, newval.Elem())
- goval.Set(newval)
- }
- case reflect.Struct:
- fieldsmu.RLock()
- sf := fields[goval.Type().String()]
- fieldsmu.RUnlock()
- if sf == nil {
- fieldsmu.Lock()
- sf = make(map[string]int)
- for i := 0; i < goval.Type().NumField(); i++ {
- f := goval.Type().Field(i)
- tag := strings.Split(f.Tag.Get("json"), ",")[0]
- if tag != "-" {
- if tag != "" {
- sf[tag] = i
- sf[f.Name] = i
- } else {
- sf[f.Name] = i
- }
- }
- }
- fields[goval.Type().String()] = sf
- fieldsmu.Unlock()
- }
- jsval.ForEach(func(key, value Result) bool {
- if idx, ok := sf[key.Str]; ok {
- f := goval.Field(idx)
- if f.CanSet() {
- assign(value, f)
- }
- }
- return true
- })
- case reflect.Slice:
- if goval.Type().Elem().Kind() == reflect.Uint8 &&
- jsval.Type == String {
- data, _ := base64.StdEncoding.DecodeString(jsval.String())
- goval.Set(reflect.ValueOf(data))
- } else {
- jsvals := jsval.Array()
- slice := reflect.MakeSlice(goval.Type(), len(jsvals), len(jsvals))
- for i := 0; i < len(jsvals); i++ {
- assign(jsvals[i], slice.Index(i))
- }
- goval.Set(slice)
- }
- case reflect.Array:
- i, n := 0, goval.Len()
- jsval.ForEach(func(_, value Result) bool {
- if i == n {
- return false
- }
- assign(value, goval.Index(i))
- i++
- return true
- })
- case reflect.Map:
- if goval.Type().Key().Kind() == reflect.String &&
- goval.Type().Elem().Kind() == reflect.Interface {
- goval.Set(reflect.ValueOf(jsval.Value()))
- }
- case reflect.Interface:
- goval.Set(reflect.ValueOf(jsval.Value()))
- case reflect.Bool:
- goval.SetBool(jsval.Bool())
- case reflect.Float32, reflect.Float64:
- goval.SetFloat(jsval.Float())
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32,
- reflect.Int64:
- goval.SetInt(jsval.Int())
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32,
- reflect.Uint64:
- goval.SetUint(jsval.Uint())
- case reflect.String:
- goval.SetString(jsval.String())
- }
- if len(goval.Type().PkgPath()) > 0 {
- v := goval.Addr()
- if v.Type().NumMethod() > 0 {
- if u, ok := v.Interface().(json.Unmarshaler); ok {
- u.UnmarshalJSON([]byte(jsval.Raw))
- }
- }
- }
-}
-
-var validate uintptr = 1
-
-// UnmarshalValidationEnabled provides the option to disable JSON validation
-// during the Unmarshal routine. Validation is enabled by default.
-//
-// Deprecated: Use encoder/json.Unmarshal instead
-func UnmarshalValidationEnabled(enabled bool) {
- if enabled {
- atomic.StoreUintptr(&validate, 1)
- } else {
- atomic.StoreUintptr(&validate, 0)
- }
-}
-
-// Unmarshal loads the JSON data into the value pointed to by v.
-//
-// This function works almost identically to json.Unmarshal except that
-// gjson.Unmarshal will automatically attempt to convert JSON values to any Go
-// type. For example, the JSON string "100" or the JSON number 100 can be
-// equally assigned to Go string, int, byte, uint64, etc. This rule applies to
-// all types.
-//
-// Deprecated: Use encoder/json.Unmarshal instead
-func Unmarshal(data []byte, v interface{}) error {
- if atomic.LoadUintptr(&validate) == 1 {
- _, ok := validpayload(data, 0)
- if !ok {
- return errors.New("invalid json")
- }
- }
- if v := reflect.ValueOf(v); v.Kind() == reflect.Ptr {
- assign(ParseBytes(data), v)
- }
- return nil
-}
-
func validpayload(data []byte, i int) (outi int, ok bool) {
for ; i < len(data); i++ {
switch data[i] {
@@ -2484,6 +2325,12 @@ func validnumber(data []byte, i int) (outi int, ok bool) {
// sign
if data[i] == '-' {
i++
+ if i == len(data) {
+ return i, false
+ }
+ if data[i] < '0' || data[i] > '9' {
+ return i, false
+ }
}
// int
if i == len(data) {
@@ -2634,25 +2481,15 @@ func parseInt(s string) (n int64, ok bool) {
return n, true
}
-const minUint53 = 0
-const maxUint53 = 4503599627370495
-const minInt53 = -2251799813685248
-const maxInt53 = 2251799813685247
-
-func floatToUint(f float64) (n uint64, ok bool) {
- n = uint64(f)
- if float64(n) == f && n >= minUint53 && n <= maxUint53 {
- return n, true
- }
- return 0, false
-}
-
-func floatToInt(f float64) (n int64, ok bool) {
- n = int64(f)
- if float64(n) == f && n >= minInt53 && n <= maxInt53 {
- return n, true
+// safeInt validates a given JSON number
+// ensures it lies within the minimum and maximum representable JSON numbers
+func safeInt(f float64) (n int64, ok bool) {
+ // https://tc39.es/ecma262/#sec-number.min_safe_integer
+ // https://tc39.es/ecma262/#sec-number.max_safe_integer
+ if f < -9007199254740991 || f > 9007199254740991 {
+ return 0, false
}
- return 0, false
+ return int64(f), true
}
// execModifier parses the path to find a matching modifier function.
@@ -2686,7 +2523,7 @@ func execModifier(json, path string) (pathOut, res string, ok bool) {
case '{', '[', '"':
res := Parse(pathOut)
if res.Exists() {
- _, args = parseSquash(pathOut, 0)
+ args = squash(pathOut)
pathOut = pathOut[len(args):]
parsedArgs = true
}
@@ -2707,6 +2544,15 @@ func execModifier(json, path string) (pathOut, res string, ok bool) {
return pathOut, res, false
}
+// unwrap removes the '[]' or '{}' characters around json
+func unwrap(json string) string {
+ json = trim(json)
+ if len(json) >= 2 && (json[0] == '[' || json[0] == '{') {
+ json = json[1 : len(json)-1]
+ }
+ return json
+}
+
// DisableModifiers will disable the modifier syntax
var DisableModifiers = false
@@ -2714,6 +2560,10 @@ var modifiers = map[string]func(json, arg string) string{
"pretty": modPretty,
"ugly": modUgly,
"reverse": modReverse,
+ "this": modThis,
+ "flatten": modFlatten,
+ "join": modJoin,
+ "valid": modValid,
}
// AddModifier binds a custom modifier command to the GJSON syntax.
@@ -2729,6 +2579,26 @@ func ModifierExists(name string, fn func(json, arg string) string) bool {
return ok
}
+// cleanWS remove any non-whitespace from string
+func cleanWS(s string) string {
+ for i := 0; i < len(s); i++ {
+ switch s[i] {
+ case ' ', '\t', '\n', '\r':
+ continue
+ default:
+ var s2 []byte
+ for i := 0; i < len(s); i++ {
+ switch s[i] {
+ case ' ', '\t', '\n', '\r':
+ s2 = append(s2, s[i])
+ }
+ }
+ return string(s2)
+ }
+ }
+ return s
+}
+
// @pretty modifier makes the json look nice.
func modPretty(json, arg string) string {
if len(arg) > 0 {
@@ -2738,9 +2608,9 @@ func modPretty(json, arg string) string {
case "sortKeys":
opts.SortKeys = value.Bool()
case "indent":
- opts.Indent = value.String()
+ opts.Indent = cleanWS(value.String())
case "prefix":
- opts.Prefix = value.String()
+ opts.Prefix = cleanWS(value.String())
case "width":
opts.Width = int(value.Int())
}
@@ -2751,6 +2621,11 @@ func modPretty(json, arg string) string {
return bytesString(pretty.Pretty(stringBytes(json)))
}
+// @this returns the current element. Can be used to retrieve the root element.
+func modThis(json, arg string) string {
+ return json
+}
+
// @ugly modifier removes all whitespace.
func modUgly(json, arg string) string {
return bytesString(pretty.Ugly(stringBytes(json)))
@@ -2797,3 +2672,213 @@ func modReverse(json, arg string) string {
}
return json
}
+
+// @flatten an array with child arrays.
+// [1,[2],[3,4],[5,[6,7]]] -> [1,2,3,4,5,[6,7]]
+// The {"deep":true} arg can be provide for deep flattening.
+// [1,[2],[3,4],[5,[6,7]]] -> [1,2,3,4,5,6,7]
+// The original json is returned when the json is not an array.
+func modFlatten(json, arg string) string {
+ res := Parse(json)
+ if !res.IsArray() {
+ return json
+ }
+ var deep bool
+ if arg != "" {
+ Parse(arg).ForEach(func(key, value Result) bool {
+ if key.String() == "deep" {
+ deep = value.Bool()
+ }
+ return true
+ })
+ }
+ var out []byte
+ out = append(out, '[')
+ var idx int
+ res.ForEach(func(_, value Result) bool {
+ var raw string
+ if value.IsArray() {
+ if deep {
+ raw = unwrap(modFlatten(value.Raw, arg))
+ } else {
+ raw = unwrap(value.Raw)
+ }
+ } else {
+ raw = value.Raw
+ }
+ raw = strings.TrimSpace(raw)
+ if len(raw) > 0 {
+ if idx > 0 {
+ out = append(out, ',')
+ }
+ out = append(out, raw...)
+ idx++
+ }
+ return true
+ })
+ out = append(out, ']')
+ return bytesString(out)
+}
+
+// @join multiple objects into a single object.
+// [{"first":"Tom"},{"last":"Smith"}] -> {"first","Tom","last":"Smith"}
+// The arg can be "true" to specify that duplicate keys should be preserved.
+// [{"first":"Tom","age":37},{"age":41}] -> {"first","Tom","age":37,"age":41}
+// Without preserved keys:
+// [{"first":"Tom","age":37},{"age":41}] -> {"first","Tom","age":41}
+// The original json is returned when the json is not an object.
+func modJoin(json, arg string) string {
+ res := Parse(json)
+ if !res.IsArray() {
+ return json
+ }
+ var preserve bool
+ if arg != "" {
+ Parse(arg).ForEach(func(key, value Result) bool {
+ if key.String() == "preserve" {
+ preserve = value.Bool()
+ }
+ return true
+ })
+ }
+ var out []byte
+ out = append(out, '{')
+ if preserve {
+ // Preserve duplicate keys.
+ var idx int
+ res.ForEach(func(_, value Result) bool {
+ if !value.IsObject() {
+ return true
+ }
+ if idx > 0 {
+ out = append(out, ',')
+ }
+ out = append(out, unwrap(value.Raw)...)
+ idx++
+ return true
+ })
+ } else {
+ // Deduplicate keys and generate an object with stable ordering.
+ var keys []Result
+ kvals := make(map[string]Result)
+ res.ForEach(func(_, value Result) bool {
+ if !value.IsObject() {
+ return true
+ }
+ value.ForEach(func(key, value Result) bool {
+ k := key.String()
+ if _, ok := kvals[k]; !ok {
+ keys = append(keys, key)
+ }
+ kvals[k] = value
+ return true
+ })
+ return true
+ })
+ for i := 0; i < len(keys); i++ {
+ if i > 0 {
+ out = append(out, ',')
+ }
+ out = append(out, keys[i].Raw...)
+ out = append(out, ':')
+ out = append(out, kvals[keys[i].String()].Raw...)
+ }
+ }
+ out = append(out, '}')
+ return bytesString(out)
+}
+
+// @valid ensures that the json is valid before moving on. An empty string is
+// returned when the json is not valid, otherwise it returns the original json.
+func modValid(json, arg string) string {
+ if !Valid(json) {
+ return ""
+ }
+ return json
+}
+
+// stringHeader instead of reflect.StringHeader
+type stringHeader struct {
+ data unsafe.Pointer
+ len int
+}
+
+// sliceHeader instead of reflect.SliceHeader
+type sliceHeader struct {
+ data unsafe.Pointer
+ len int
+ cap int
+}
+
+// getBytes casts the input json bytes to a string and safely returns the
+// results as uniquely allocated data. This operation is intended to minimize
+// copies and allocations for the large json string->[]byte.
+func getBytes(json []byte, path string) Result {
+ var result Result
+ if json != nil {
+ // unsafe cast to string
+ result = Get(*(*string)(unsafe.Pointer(&json)), path)
+ // safely get the string headers
+ rawhi := *(*stringHeader)(unsafe.Pointer(&result.Raw))
+ strhi := *(*stringHeader)(unsafe.Pointer(&result.Str))
+ // create byte slice headers
+ rawh := sliceHeader{data: rawhi.data, len: rawhi.len, cap: rawhi.len}
+ strh := sliceHeader{data: strhi.data, len: strhi.len, cap: rawhi.len}
+ if strh.data == nil {
+ // str is nil
+ if rawh.data == nil {
+ // raw is nil
+ result.Raw = ""
+ } else {
+ // raw has data, safely copy the slice header to a string
+ result.Raw = string(*(*[]byte)(unsafe.Pointer(&rawh)))
+ }
+ result.Str = ""
+ } else if rawh.data == nil {
+ // raw is nil
+ result.Raw = ""
+ // str has data, safely copy the slice header to a string
+ result.Str = string(*(*[]byte)(unsafe.Pointer(&strh)))
+ } else if uintptr(strh.data) >= uintptr(rawh.data) &&
+ uintptr(strh.data)+uintptr(strh.len) <=
+ uintptr(rawh.data)+uintptr(rawh.len) {
+ // Str is a substring of Raw.
+ start := uintptr(strh.data) - uintptr(rawh.data)
+ // safely copy the raw slice header
+ result.Raw = string(*(*[]byte)(unsafe.Pointer(&rawh)))
+ // substring the raw
+ result.Str = result.Raw[start : start+uintptr(strh.len)]
+ } else {
+ // safely copy both the raw and str slice headers to strings
+ result.Raw = string(*(*[]byte)(unsafe.Pointer(&rawh)))
+ result.Str = string(*(*[]byte)(unsafe.Pointer(&strh)))
+ }
+ }
+ return result
+}
+
+// fillIndex finds the position of Raw data and assigns it to the Index field
+// of the resulting value. If the position cannot be found then Index zero is
+// used instead.
+func fillIndex(json string, c *parseContext) {
+ if len(c.value.Raw) > 0 && !c.calcd {
+ jhdr := *(*stringHeader)(unsafe.Pointer(&json))
+ rhdr := *(*stringHeader)(unsafe.Pointer(&(c.value.Raw)))
+ c.value.Index = int(uintptr(rhdr.data) - uintptr(jhdr.data))
+ if c.value.Index < 0 || c.value.Index >= len(json) {
+ c.value.Index = 0
+ }
+ }
+}
+
+func stringBytes(s string) []byte {
+ return *(*[]byte)(unsafe.Pointer(&sliceHeader{
+ data: (*stringHeader)(unsafe.Pointer(&s)).data,
+ len: len(s),
+ cap: len(s),
+ }))
+}
+
+func bytesString(b []byte) string {
+ return *(*string)(unsafe.Pointer(&b))
+}
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson_gae.go b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson_gae.go
deleted file mode 100644
index 95869039..00000000
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson_gae.go
+++ /dev/null
@@ -1,18 +0,0 @@
-//+build appengine js
-
-package gjson
-
-func getBytes(json []byte, path string) Result {
- return Get(string(json), path)
-}
-func fillIndex(json string, c *parseContext) {
- // noop. Use zero for the Index value.
-}
-
-func stringBytes(s string) []byte {
- return []byte(s)
-}
-
-func bytesString(b []byte) string {
- return string(b)
-}
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson_ngae.go b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson_ngae.go
deleted file mode 100644
index bc608b53..00000000
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/gjson_ngae.go
+++ /dev/null
@@ -1,81 +0,0 @@
-//+build !appengine
-//+build !js
-
-package gjson
-
-import (
- "reflect"
- "unsafe"
-)
-
-// getBytes casts the input json bytes to a string and safely returns the
-// results as uniquely allocated data. This operation is intended to minimize
-// copies and allocations for the large json string->[]byte.
-func getBytes(json []byte, path string) Result {
- var result Result
- if json != nil {
- // unsafe cast to string
- result = Get(*(*string)(unsafe.Pointer(&json)), path)
- // safely get the string headers
- rawhi := *(*reflect.StringHeader)(unsafe.Pointer(&result.Raw))
- strhi := *(*reflect.StringHeader)(unsafe.Pointer(&result.Str))
- // create byte slice headers
- rawh := reflect.SliceHeader{Data: rawhi.Data, Len: rawhi.Len}
- strh := reflect.SliceHeader{Data: strhi.Data, Len: strhi.Len}
- if strh.Data == 0 {
- // str is nil
- if rawh.Data == 0 {
- // raw is nil
- result.Raw = ""
- } else {
- // raw has data, safely copy the slice header to a string
- result.Raw = string(*(*[]byte)(unsafe.Pointer(&rawh)))
- }
- result.Str = ""
- } else if rawh.Data == 0 {
- // raw is nil
- result.Raw = ""
- // str has data, safely copy the slice header to a string
- result.Str = string(*(*[]byte)(unsafe.Pointer(&strh)))
- } else if strh.Data >= rawh.Data &&
- int(strh.Data)+strh.Len <= int(rawh.Data)+rawh.Len {
- // Str is a substring of Raw.
- start := int(strh.Data - rawh.Data)
- // safely copy the raw slice header
- result.Raw = string(*(*[]byte)(unsafe.Pointer(&rawh)))
- // substring the raw
- result.Str = result.Raw[start : start+strh.Len]
- } else {
- // safely copy both the raw and str slice headers to strings
- result.Raw = string(*(*[]byte)(unsafe.Pointer(&rawh)))
- result.Str = string(*(*[]byte)(unsafe.Pointer(&strh)))
- }
- }
- return result
-}
-
-// fillIndex finds the position of Raw data and assigns it to the Index field
-// of the resulting value. If the position cannot be found then Index zero is
-// used instead.
-func fillIndex(json string, c *parseContext) {
- if len(c.value.Raw) > 0 && !c.calcd {
- jhdr := *(*reflect.StringHeader)(unsafe.Pointer(&json))
- rhdr := *(*reflect.StringHeader)(unsafe.Pointer(&(c.value.Raw)))
- c.value.Index = int(rhdr.Data - jhdr.Data)
- if c.value.Index < 0 || c.value.Index >= len(json) {
- c.value.Index = 0
- }
- }
-}
-
-func stringBytes(s string) []byte {
- return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
- Data: (*reflect.StringHeader)(unsafe.Pointer(&s)).Data,
- Len: len(s),
- Cap: len(s),
- }))
-}
-
-func bytesString(b []byte) string {
- return *(*string)(unsafe.Pointer(&b))
-}
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/go.mod b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/go.mod
index d851688c..6f640836 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/go.mod
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/go.mod
@@ -3,6 +3,6 @@ module github.com/tidwall/gjson
go 1.12
require (
- github.com/tidwall/match v1.0.1
- github.com/tidwall/pretty v1.0.0
+ github.com/tidwall/match v1.1.1
+ github.com/tidwall/pretty v1.2.0
)
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/go.sum b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/go.sum
index a4a2d872..be39c8c1 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/go.sum
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/gjson/go.sum
@@ -1,4 +1,4 @@
-github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
-github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
-github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
-github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
+github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
+github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
+github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
+github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/match/.travis.yml b/tools/bbbsupervisor/vendor/github.com/tidwall/match/.travis.yml
deleted file mode 100644
index 4f2ee4d9..00000000
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/match/.travis.yml
+++ /dev/null
@@ -1 +0,0 @@
-language: go
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/match/README.md b/tools/bbbsupervisor/vendor/github.com/tidwall/match/README.md
index 2aa5bc38..5fdd4cf6 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/match/README.md
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/match/README.md
@@ -1,20 +1,17 @@
-Match
-=====
-
-
+# Match
+
+[](https://godoc.org/github.com/tidwall/match)
Match is a very simple pattern matcher where '*' matches on any
number characters and '?' matches on any one character.
-Installing
-----------
+## Installing
```
go get -u github.com/tidwall/match
```
-Example
--------
+## Example
```go
match.Match("hello", "*llo")
@@ -23,10 +20,10 @@ match.Match("hello", "h*o")
```
-Contact
--------
+## Contact
+
Josh Baker [@tidwall](http://twitter.com/tidwall)
-License
--------
+## License
+
Redcon source code is available under the MIT [License](/LICENSE).
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/match/go.mod b/tools/bbbsupervisor/vendor/github.com/tidwall/match/go.mod
new file mode 100644
index 00000000..df19b5f7
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/match/go.mod
@@ -0,0 +1,3 @@
+module github.com/tidwall/match
+
+go 1.15
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/match/match.go b/tools/bbbsupervisor/vendor/github.com/tidwall/match/match.go
index fcfe998b..11da28f1 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/match/match.go
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/match/match.go
@@ -1,12 +1,14 @@
-// Match provides a simple pattern matcher with unicode support.
+// Package match provides a simple pattern matcher with unicode support.
package match
-import "unicode/utf8"
+import (
+ "unicode/utf8"
+)
// Match returns true if str matches pattern. This is a very
// simple wildcard match where '*' matches on any number characters
// and '?' matches on any one character.
-
+//
// pattern:
// { term }
// term:
@@ -19,113 +21,167 @@ func Match(str, pattern string) bool {
if pattern == "*" {
return true
}
- return deepMatch(str, pattern)
+ return match(str, pattern, 0, nil, -1) == rMatch
}
-func deepMatch(str, pattern string) bool {
- for len(pattern) > 0 {
- if pattern[0] > 0x7f {
- return deepMatchRune(str, pattern)
- }
- switch pattern[0] {
- default:
- if len(str) == 0 {
- return false
- }
- if str[0] > 0x7f {
- return deepMatchRune(str, pattern)
- }
- if str[0] != pattern[0] {
- return false
- }
- case '?':
- if len(str) == 0 {
- return false
- }
- case '*':
- return deepMatch(str, pattern[1:]) ||
- (len(str) > 0 && deepMatch(str[1:], pattern))
- }
- str = str[1:]
- pattern = pattern[1:]
+
+// MatchLimit is the same as Match but will limit the complexity of the match
+// operation. This is to avoid long running matches, specifically to avoid ReDos
+// attacks from arbritary inputs.
+//
+// How it works:
+// The underlying match routine is recursive and may call itself when it
+// encounters a sandwiched wildcard pattern, such as: `user:*:name`.
+// Everytime it calls itself a counter is incremented.
+// The operation is stopped when counter > maxcomp*len(str).
+func MatchLimit(str, pattern string, maxcomp int) (matched, stopped bool) {
+ if pattern == "*" {
+ return true, false
+ }
+ counter := 0
+ r := match(str, pattern, len(str), &counter, maxcomp)
+ if r == rStop {
+ return false, true
}
- return len(str) == 0 && len(pattern) == 0
+ return r == rMatch, false
}
-func deepMatchRune(str, pattern string) bool {
- var sr, pr rune
- var srsz, prsz int
+type result int
- // read the first rune ahead of time
- if len(str) > 0 {
- if str[0] > 0x7f {
- sr, srsz = utf8.DecodeRuneInString(str)
- } else {
- sr, srsz = rune(str[0]), 1
+const (
+ rNoMatch result = iota
+ rMatch
+ rStop
+)
+
+func match(str, pat string, slen int, counter *int, maxcomp int) result {
+ // check complexity limit
+ if maxcomp > -1 {
+ if *counter > slen*maxcomp {
+ return rStop
}
- } else {
- sr, srsz = utf8.RuneError, 0
+ *counter++
}
- if len(pattern) > 0 {
- if pattern[0] > 0x7f {
- pr, prsz = utf8.DecodeRuneInString(pattern)
- } else {
- pr, prsz = rune(pattern[0]), 1
+
+ for len(pat) > 0 {
+ var wild bool
+ pc, ps := rune(pat[0]), 1
+ if pc > 0x7f {
+ pc, ps = utf8.DecodeRuneInString(pat)
}
- } else {
- pr, prsz = utf8.RuneError, 0
- }
- // done reading
- for pr != utf8.RuneError {
- switch pr {
- default:
- if srsz == utf8.RuneError {
- return false
- }
- if sr != pr {
- return false
+ var sc rune
+ var ss int
+ if len(str) > 0 {
+ sc, ss = rune(str[0]), 1
+ if sc > 0x7f {
+ sc, ss = utf8.DecodeRuneInString(str)
}
+ }
+ switch pc {
case '?':
- if srsz == utf8.RuneError {
- return false
+ if ss == 0 {
+ return rNoMatch
}
case '*':
- return deepMatchRune(str, pattern[prsz:]) ||
- (srsz > 0 && deepMatchRune(str[srsz:], pattern))
- }
- str = str[srsz:]
- pattern = pattern[prsz:]
- // read the next runes
- if len(str) > 0 {
- if str[0] > 0x7f {
- sr, srsz = utf8.DecodeRuneInString(str)
- } else {
- sr, srsz = rune(str[0]), 1
+ // Ignore repeating stars.
+ for len(pat) > 1 && pat[1] == '*' {
+ pat = pat[1:]
}
- } else {
- sr, srsz = utf8.RuneError, 0
- }
- if len(pattern) > 0 {
- if pattern[0] > 0x7f {
- pr, prsz = utf8.DecodeRuneInString(pattern)
- } else {
- pr, prsz = rune(pattern[0]), 1
+
+ // If this star is the last character then it must be a match.
+ if len(pat) == 1 {
+ return rMatch
}
- } else {
- pr, prsz = utf8.RuneError, 0
+
+ // Match and trim any non-wildcard suffix characters.
+ var ok bool
+ str, pat, ok = matchTrimSuffix(str, pat)
+ if !ok {
+ return rNoMatch
+ }
+
+ // Check for single star again.
+ if len(pat) == 1 {
+ return rMatch
+ }
+
+ // Perform recursive wildcard search.
+ r := match(str, pat[1:], slen, counter, maxcomp)
+ if r != rNoMatch {
+ return r
+ }
+ if len(str) == 0 {
+ return rNoMatch
+ }
+ wild = true
+ default:
+ if ss == 0 {
+ return rNoMatch
+ }
+ if pc == '\\' {
+ pat = pat[ps:]
+ pc, ps = utf8.DecodeRuneInString(pat)
+ if ps == 0 {
+ return rNoMatch
+ }
+ }
+ if sc != pc {
+ return rNoMatch
+ }
+ }
+ str = str[ss:]
+ if !wild {
+ pat = pat[ps:]
}
- // done reading
}
-
- return srsz == 0 && prsz == 0
+ if len(str) == 0 {
+ return rMatch
+ }
+ return rNoMatch
}
-var maxRuneBytes = func() []byte {
- b := make([]byte, 4)
- if utf8.EncodeRune(b, '\U0010FFFF') != 4 {
- panic("invalid rune encoding")
+// matchTrimSuffix matches and trims any non-wildcard suffix characters.
+// Returns the trimed string and pattern.
+//
+// This is called because the pattern contains extra data after the wildcard
+// star. Here we compare any suffix characters in the pattern to the suffix of
+// the target string. Basically a reverse match that stops when a wildcard
+// character is reached. This is a little trickier than a forward match because
+// we need to evaluate an escaped character in reverse.
+//
+// Any matched characters will be trimmed from both the target
+// string and the pattern.
+func matchTrimSuffix(str, pat string) (string, string, bool) {
+ // It's expected that the pattern has at least two bytes and the first byte
+ // is a wildcard star '*'
+ match := true
+ for len(str) > 0 && len(pat) > 1 {
+ pc, ps := utf8.DecodeLastRuneInString(pat)
+ var esc bool
+ for i := 0; ; i++ {
+ if pat[len(pat)-ps-i-1] != '\\' {
+ if i&1 == 1 {
+ esc = true
+ ps++
+ }
+ break
+ }
+ }
+ if pc == '*' && !esc {
+ match = true
+ break
+ }
+ sc, ss := utf8.DecodeLastRuneInString(str)
+ if !((pc == '?' && !esc) || pc == sc) {
+ match = false
+ break
+ }
+ str = str[:len(str)-ss]
+ pat = pat[:len(pat)-ps]
}
- return b
-}()
+ return str, pat, match
+}
+
+var maxRuneBytes = [...]byte{244, 143, 191, 191}
// Allowable parses the pattern and determines the minimum and maximum allowable
// values that the pattern can represent.
@@ -146,7 +202,7 @@ func Allowable(pattern string) (min, max string) {
}
if pattern[i] == '?' {
minb = append(minb, 0)
- maxb = append(maxb, maxRuneBytes...)
+ maxb = append(maxb, maxRuneBytes[:]...)
} else {
minb = append(minb, pattern[i])
maxb = append(maxb, pattern[i])
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/.travis.yml b/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/.travis.yml
deleted file mode 100644
index 4f2ee4d9..00000000
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/.travis.yml
+++ /dev/null
@@ -1 +0,0 @@
-language: go
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/README.md b/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/README.md
index d2b8864d..d3be5e54 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/README.md
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/README.md
@@ -1,8 +1,6 @@
# Pretty
-[](https://travis-ci.org/tidwall/prettty)
-[](http://gocover.io/github.com/tidwall/pretty)
-[](https://godoc.org/github.com/tidwall/pretty)
+[](https://pkg.go.dev/github.com/tidwall/pretty)
Pretty is a Go package that provides [fast](#performance) methods for formatting JSON for human readability, or to compact JSON for smaller payloads.
@@ -81,7 +79,6 @@ Will format the json to:
{"name":{"first":"Tom","last":"Anderson"},"age":37,"children":["Sara","Alex","Jack"],"fav.movie":"Deer Hunter","friends":[{"first":"Janet","last":"Murphy","age":44}]}```
```
-
## Customized output
There's a `PrettyOptions(json, opts)` function which allows for customizing the output with the following options:
@@ -106,14 +103,15 @@ type Options struct {
Benchmarks of Pretty alongside the builtin `encoding/json` Indent/Compact methods.
```
-BenchmarkPretty-8 1000000 1283 ns/op 720 B/op 2 allocs/op
-BenchmarkUgly-8 3000000 426 ns/op 240 B/op 1 allocs/op
-BenchmarkUglyInPlace-8 5000000 340 ns/op 0 B/op 0 allocs/op
-BenchmarkJSONIndent-8 300000 4628 ns/op 1069 B/op 4 allocs/op
-BenchmarkJSONCompact-8 1000000 2469 ns/op 758 B/op 4 allocs/op
+BenchmarkPretty-16 1000000 1034 ns/op 720 B/op 2 allocs/op
+BenchmarkPrettySortKeys-16 586797 1983 ns/op 2848 B/op 14 allocs/op
+BenchmarkUgly-16 4652365 254 ns/op 240 B/op 1 allocs/op
+BenchmarkUglyInPlace-16 6481233 183 ns/op 0 B/op 0 allocs/op
+BenchmarkJSONIndent-16 450654 2687 ns/op 1221 B/op 0 allocs/op
+BenchmarkJSONCompact-16 685111 1699 ns/op 442 B/op 0 allocs/op
```
-*These benchmarks were run on a MacBook Pro 15" 2.8 GHz Intel Core i7 using Go 1.7.*
+*These benchmarks were run on a MacBook Pro 2.4 GHz 8-Core Intel Core i9.*
## Contact
Josh Baker [@tidwall](http://twitter.com/tidwall)
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/go.mod b/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/go.mod
new file mode 100644
index 00000000..6106735a
--- /dev/null
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/go.mod
@@ -0,0 +1,3 @@
+module github.com/tidwall/pretty
+
+go 1.16
diff --git a/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/pretty.go b/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/pretty.go
index 0a922d03..f3f756aa 100644
--- a/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/pretty.go
+++ b/tools/bbbsupervisor/vendor/github.com/tidwall/pretty/pretty.go
@@ -1,7 +1,10 @@
package pretty
import (
+ "bytes"
+ "encoding/json"
"sort"
+ "strconv"
)
// Options is Pretty options
@@ -84,6 +87,14 @@ func ugly(dst, src []byte) []byte {
return dst
}
+func isNaNOrInf(src []byte) bool {
+ return src[0] == 'i' || //Inf
+ src[0] == 'I' || // inf
+ src[0] == '+' || // +Inf
+ src[0] == 'N' || // Nan
+ (src[0] == 'n' && len(src) > 1 && src[1] != 'u') // nan
+}
+
func appendPrettyAny(buf, json []byte, i int, pretty bool, width int, prefix, indent string, sortkeys bool, tabs, nl, max int) ([]byte, int, int, bool) {
for ; i < len(json); i++ {
if json[i] <= ' ' {
@@ -92,7 +103,8 @@ func appendPrettyAny(buf, json []byte, i int, pretty bool, width int, prefix, in
if json[i] == '"' {
return appendPrettyString(buf, json, i, nl)
}
- if (json[i] >= '0' && json[i] <= '9') || json[i] == '-' {
+
+ if (json[i] >= '0' && json[i] <= '9') || json[i] == '-' || isNaNOrInf(json[i:]) {
return appendPrettyNumber(buf, json, i, nl)
}
if json[i] == '{' {
@@ -118,25 +130,121 @@ type pair struct {
vstart, vend int
}
-type byKey struct {
+type byKeyVal struct {
sorted bool
json []byte
+ buf []byte
pairs []pair
}
-func (arr *byKey) Len() int {
+func (arr *byKeyVal) Len() int {
return len(arr.pairs)
}
-func (arr *byKey) Less(i, j int) bool {
- key1 := arr.json[arr.pairs[i].kstart+1 : arr.pairs[i].kend-1]
- key2 := arr.json[arr.pairs[j].kstart+1 : arr.pairs[j].kend-1]
- return string(key1) < string(key2)
+func (arr *byKeyVal) Less(i, j int) bool {
+ if arr.isLess(i, j, byKey) {
+ return true
+ }
+ if arr.isLess(j, i, byKey) {
+ return false
+ }
+ return arr.isLess(i, j, byVal)
}
-func (arr *byKey) Swap(i, j int) {
+func (arr *byKeyVal) Swap(i, j int) {
arr.pairs[i], arr.pairs[j] = arr.pairs[j], arr.pairs[i]
arr.sorted = true
}
+type byKind int
+
+const (
+ byKey byKind = 0
+ byVal byKind = 1
+)
+
+type jtype int
+
+const (
+ jnull jtype = iota
+ jfalse
+ jnumber
+ jstring
+ jtrue
+ jjson
+)
+
+func getjtype(v []byte) jtype {
+ if len(v) == 0 {
+ return jnull
+ }
+ switch v[0] {
+ case '"':
+ return jstring
+ case 'f':
+ return jfalse
+ case 't':
+ return jtrue
+ case 'n':
+ return jnull
+ case '[', '{':
+ return jjson
+ default:
+ return jnumber
+ }
+}
+
+func (arr *byKeyVal) isLess(i, j int, kind byKind) bool {
+ k1 := arr.json[arr.pairs[i].kstart:arr.pairs[i].kend]
+ k2 := arr.json[arr.pairs[j].kstart:arr.pairs[j].kend]
+ var v1, v2 []byte
+ if kind == byKey {
+ v1 = k1
+ v2 = k2
+ } else {
+ v1 = bytes.TrimSpace(arr.buf[arr.pairs[i].vstart:arr.pairs[i].vend])
+ v2 = bytes.TrimSpace(arr.buf[arr.pairs[j].vstart:arr.pairs[j].vend])
+ if len(v1) >= len(k1)+1 {
+ v1 = bytes.TrimSpace(v1[len(k1)+1:])
+ }
+ if len(v2) >= len(k2)+1 {
+ v2 = bytes.TrimSpace(v2[len(k2)+1:])
+ }
+ }
+ t1 := getjtype(v1)
+ t2 := getjtype(v2)
+ if t1 < t2 {
+ return true
+ }
+ if t1 > t2 {
+ return false
+ }
+ if t1 == jstring {
+ s1 := parsestr(v1)
+ s2 := parsestr(v2)
+ return string(s1) < string(s2)
+ }
+ if t1 == jnumber {
+ n1, _ := strconv.ParseFloat(string(v1), 64)
+ n2, _ := strconv.ParseFloat(string(v2), 64)
+ return n1 < n2
+ }
+ return string(v1) < string(v2)
+
+}
+
+func parsestr(s []byte) []byte {
+ for i := 1; i < len(s); i++ {
+ if s[i] == '\\' {
+ var str string
+ json.Unmarshal(s, &str)
+ return []byte(str)
+ }
+ if s[i] == '"' {
+ return s[1:i]
+ }
+ }
+ return nil
+}
+
func appendPrettyObject(buf, json []byte, i int, open, close byte, pretty bool, width int, prefix, indent string, sortkeys bool, tabs, nl, max int) ([]byte, int, int, bool) {
var ok bool
if width > 0 {
@@ -174,7 +282,11 @@ func appendPrettyObject(buf, json []byte, i int, open, close byte, pretty bool,
}
if n > 0 {
nl = len(buf)
- buf = append(buf, '\n')
+ if buf[nl-1] == ' ' {
+ buf[nl-1] = '\n'
+ } else {
+ buf = append(buf, '\n')
+ }
}
if buf[len(buf)-1] != open {
buf = appendTabs(buf, prefix, indent, tabs)
@@ -193,7 +305,11 @@ func appendPrettyObject(buf, json []byte, i int, open, close byte, pretty bool,
var p pair
if pretty {
nl = len(buf)
- buf = append(buf, '\n')
+ if buf[nl-1] == ' ' {
+ buf[nl-1] = '\n'
+ } else {
+ buf = append(buf, '\n')
+ }
if open == '{' && sortkeys {
p.kstart = i
p.vstart = len(buf)
@@ -235,8 +351,8 @@ func sortPairs(json, buf []byte, pairs []pair) []byte {
}
vstart := pairs[0].vstart
vend := pairs[len(pairs)-1].vend
- arr := byKey{false, json, pairs}
- sort.Sort(&arr)
+ arr := byKeyVal{false, json, buf, pairs}
+ sort.Stable(&arr)
if !arr.sorted {
return buf
}
@@ -305,6 +421,7 @@ func appendTabs(buf []byte, prefix, indent string, tabs int) []byte {
type Style struct {
Key, String, Number [2]string
True, False, Null [2]string
+ Escape [2]string
Append func(dst []byte, c byte) []byte
}
@@ -318,21 +435,26 @@ func hexp(p byte) byte {
}
// TerminalStyle is for terminals
-var TerminalStyle = &Style{
- Key: [2]string{"\x1B[94m", "\x1B[0m"},
- String: [2]string{"\x1B[92m", "\x1B[0m"},
- Number: [2]string{"\x1B[93m", "\x1B[0m"},
- True: [2]string{"\x1B[96m", "\x1B[0m"},
- False: [2]string{"\x1B[96m", "\x1B[0m"},
- Null: [2]string{"\x1B[91m", "\x1B[0m"},
- Append: func(dst []byte, c byte) []byte {
- if c < ' ' && (c != '\r' && c != '\n' && c != '\t' && c != '\v') {
- dst = append(dst, "\\u00"...)
- dst = append(dst, hexp((c>>4)&0xF))
- return append(dst, hexp((c)&0xF))
- }
- return append(dst, c)
- },
+var TerminalStyle *Style
+
+func init() {
+ TerminalStyle = &Style{
+ Key: [2]string{"\x1B[94m", "\x1B[0m"},
+ String: [2]string{"\x1B[92m", "\x1B[0m"},
+ Number: [2]string{"\x1B[93m", "\x1B[0m"},
+ True: [2]string{"\x1B[96m", "\x1B[0m"},
+ False: [2]string{"\x1B[96m", "\x1B[0m"},
+ Null: [2]string{"\x1B[91m", "\x1B[0m"},
+ Escape: [2]string{"\x1B[35m", "\x1B[0m"},
+ Append: func(dst []byte, c byte) []byte {
+ if c < ' ' && (c != '\r' && c != '\n' && c != '\t' && c != '\v') {
+ dst = append(dst, "\\u00"...)
+ dst = append(dst, hexp((c>>4)&0xF))
+ return append(dst, hexp((c)&0xF))
+ }
+ return append(dst, c)
+ },
+ }
}
// Color will colorize the json. The style parma is used for customizing
@@ -363,8 +485,39 @@ func Color(src []byte, style *Style) []byte {
dst = append(dst, style.String[0]...)
}
dst = apnd(dst, '"')
+ esc := false
+ uesc := 0
for i = i + 1; i < len(src); i++ {
- dst = apnd(dst, src[i])
+ if src[i] == '\\' {
+ if key {
+ dst = append(dst, style.Key[1]...)
+ } else {
+ dst = append(dst, style.String[1]...)
+ }
+ dst = append(dst, style.Escape[0]...)
+ dst = apnd(dst, src[i])
+ esc = true
+ if i+1 < len(src) && src[i+1] == 'u' {
+ uesc = 5
+ } else {
+ uesc = 1
+ }
+ } else if esc {
+ dst = apnd(dst, src[i])
+ if uesc == 1 {
+ esc = false
+ dst = append(dst, style.Escape[1]...)
+ if key {
+ dst = append(dst, style.Key[0]...)
+ } else {
+ dst = append(dst, style.String[0]...)
+ }
+ } else {
+ uesc--
+ }
+ } else {
+ dst = apnd(dst, src[i])
+ }
if src[i] == '"' {
j := i - 1
for ; ; j-- {
@@ -377,7 +530,9 @@ func Color(src []byte, style *Style) []byte {
}
}
}
- if key {
+ if esc {
+ dst = append(dst, style.Escape[1]...)
+ } else if key {
dst = append(dst, style.Key[1]...)
} else {
dst = append(dst, style.String[1]...)
@@ -393,7 +548,7 @@ func Color(src []byte, style *Style) []byte {
dst = apnd(dst, src[i])
} else {
var kind byte
- if (src[i] >= '0' && src[i] <= '9') || src[i] == '-' {
+ if (src[i] >= '0' && src[i] <= '9') || src[i] == '-' || isNaNOrInf(src[i:]) {
kind = '0'
dst = append(dst, style.Number[0]...)
} else if src[i] == 't' {
@@ -430,3 +585,90 @@ func Color(src []byte, style *Style) []byte {
}
return dst
}
+
+// Spec strips out comments and trailing commas and convert the input to a
+// valid JSON per the official spec: https://tools.ietf.org/html/rfc8259
+//
+// The resulting JSON will always be the same length as the input and it will
+// include all of the same line breaks at matching offsets. This is to ensure
+// the result can be later processed by a external parser and that that
+// parser will report messages or errors with the correct offsets.
+func Spec(src []byte) []byte {
+ return spec(src, nil)
+}
+
+// SpecInPlace is the same as Spec, but this method reuses the input json
+// buffer to avoid allocations. Do not use the original bytes slice upon return.
+func SpecInPlace(src []byte) []byte {
+ return spec(src, src)
+}
+
+func spec(src, dst []byte) []byte {
+ dst = dst[:0]
+ for i := 0; i < len(src); i++ {
+ if src[i] == '/' {
+ if i < len(src)-1 {
+ if src[i+1] == '/' {
+ dst = append(dst, ' ', ' ')
+ i += 2
+ for ; i < len(src); i++ {
+ if src[i] == '\n' {
+ dst = append(dst, '\n')
+ break
+ } else if src[i] == '\t' || src[i] == '\r' {
+ dst = append(dst, src[i])
+ } else {
+ dst = append(dst, ' ')
+ }
+ }
+ continue
+ }
+ if src[i+1] == '*' {
+ dst = append(dst, ' ', ' ')
+ i += 2
+ for ; i < len(src)-1; i++ {
+ if src[i] == '*' && src[i+1] == '/' {
+ dst = append(dst, ' ', ' ')
+ i++
+ break
+ } else if src[i] == '\n' || src[i] == '\t' ||
+ src[i] == '\r' {
+ dst = append(dst, src[i])
+ } else {
+ dst = append(dst, ' ')
+ }
+ }
+ continue
+ }
+ }
+ }
+ dst = append(dst, src[i])
+ if src[i] == '"' {
+ for i = i + 1; i < len(src); i++ {
+ dst = append(dst, src[i])
+ if src[i] == '"' {
+ j := i - 1
+ for ; ; j-- {
+ if src[j] != '\\' {
+ break
+ }
+ }
+ if (j-i)%2 != 0 {
+ break
+ }
+ }
+ }
+ } else if src[i] == '}' || src[i] == ']' {
+ for j := len(dst) - 2; j >= 0; j-- {
+ if dst[j] <= ' ' {
+ continue
+ }
+ if dst[j] == ',' {
+ dst[j] = ' '
+ }
+ break
+ }
+ }
+ }
+ return dst
+}
diff --git a/tools/bbbsupervisor/vendor/modules.txt b/tools/bbbsupervisor/vendor/modules.txt
index 40cd9302..70a45167 100644
--- a/tools/bbbsupervisor/vendor/modules.txt
+++ b/tools/bbbsupervisor/vendor/modules.txt
@@ -1,9 +1,16 @@
+# github.com/digitalbitbox/bitbox-base/middleware v0.0.0-20191204153728-1128dd782517
+github.com/digitalbitbox/bitbox-base/middleware/src/redis
+github.com/digitalbitbox/bitbox-base/middleware/src/rpcmessages
+# github.com/digitalbitbox/bitbox02-api-go v0.0.0-20191204135529-eb28ed7e9cbd
+github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages
+# github.com/golang/protobuf v1.3.2
+github.com/golang/protobuf/proto
# github.com/gomodule/redigo v2.0.0+incompatible
github.com/gomodule/redigo/internal
github.com/gomodule/redigo/redis
-# github.com/tidwall/gjson v1.3.2
+# github.com/tidwall/gjson v1.9.3
github.com/tidwall/gjson
-# github.com/tidwall/match v1.0.1
+# github.com/tidwall/match v1.1.1
github.com/tidwall/match
-# github.com/tidwall/pretty v1.0.0
+# github.com/tidwall/pretty v1.2.0
github.com/tidwall/pretty