From 43446bc692344df4bd2ae8a0004feb819bbeaae8 Mon Sep 17 00:00:00 2001 From: Devin Carr Date: Mon, 20 May 2024 16:09:25 -0700 Subject: [PATCH] TUN-8423: Deprecate older legacy tunnel capnp interfaces Since legacy tunnels have been removed for a while now, we can remove many of the capnp rpc interfaces that are no longer leveraged by the legacy tunnel registration and authentication mechanisms. --- cmd/cloudflared/tunnel/cmd.go | 4 +- cmd/cloudflared/tunnel/configuration.go | 6 +- cmd/cloudflared/tunnel/tag.go | 12 +- cmd/cloudflared/tunnel/tag_test.go | 10 +- connection/rpc.go | 35 - orchestration/orchestrator.go | 16 +- orchestration/orchestrator_test.go | 4 +- proxy/proxy.go | 6 +- proxy/proxy_test.go | 4 +- supervisor/tunnel.go | 36 +- tunnelrpc/pogs/auth_outcome.go | 131 - tunnelrpc/pogs/auth_serialize.go | 78 - tunnelrpc/pogs/auth_test.go | 136 - ...loudflaredrpc.go => cloudflared_server.go} | 0 ...urationrpc.go => configuration_manager.go} | 0 tunnelrpc/pogs/reconnect_tunnel.go | 93 - ...onnectionrpc.go => registration_server.go} | 0 ...pc_test.go => registration_server_test.go} | 14 +- .../{sessionrpc.go => session_manager.go} | 0 tunnelrpc/pogs/support_test.go | 40 - tunnelrpc/pogs/tag.go | 8 + tunnelrpc/pogs/tunnelrpc.go | 334 -- tunnelrpc/pogs/tunnelrpc_test.go | 57 - tunnelrpc/proto/tunnelrpc.capnp | 52 +- tunnelrpc/proto/tunnelrpc.capnp.go | 2760 ++++++++--------- 25 files changed, 1468 insertions(+), 2368 deletions(-) delete mode 100644 tunnelrpc/pogs/auth_outcome.go delete mode 100644 tunnelrpc/pogs/auth_serialize.go delete mode 100644 tunnelrpc/pogs/auth_test.go rename tunnelrpc/pogs/{cloudflaredrpc.go => cloudflared_server.go} (100%) rename tunnelrpc/pogs/{configurationrpc.go => configuration_manager.go} (100%) delete mode 100644 tunnelrpc/pogs/reconnect_tunnel.go rename tunnelrpc/pogs/{connectionrpc.go => registration_server.go} (100%) rename tunnelrpc/pogs/{connectionrpc_test.go => registration_server_test.go} (93%) rename tunnelrpc/pogs/{sessionrpc.go => session_manager.go} (100%) delete mode 100644 tunnelrpc/pogs/support_test.go create mode 100644 tunnelrpc/pogs/tag.go delete mode 100644 tunnelrpc/pogs/tunnelrpc.go delete mode 100644 tunnelrpc/pogs/tunnelrpc_test.go diff --git a/cmd/cloudflared/tunnel/cmd.go b/cmd/cloudflared/tunnel/cmd.go index 5196d08a..9b2cd834 100644 --- a/cmd/cloudflared/tunnel/cmd.go +++ b/cmd/cloudflared/tunnel/cmd.go @@ -663,9 +663,9 @@ func tunnelFlags(shouldHide bool) []cli.Flag { }), altsrc.NewStringSliceFlag(&cli.StringSliceFlag{ Name: "tag", - Usage: "Custom tags used to identify this tunnel, in format `KEY=VALUE`. Multiple tags may be specified", + Usage: "Custom tags used to identify this tunnel via added HTTP request headers to the origin, in format `KEY=VALUE`. Multiple tags may be specified.", EnvVars: []string{"TUNNEL_TAG"}, - Hidden: shouldHide, + Hidden: true, }), altsrc.NewDurationFlag(&cli.DurationFlag{ Name: "heartbeat-interval", diff --git a/cmd/cloudflared/tunnel/configuration.go b/cmd/cloudflared/tunnel/configuration.go index 6f8f6b92..db9558e3 100644 --- a/cmd/cloudflared/tunnel/configuration.go +++ b/cmd/cloudflared/tunnel/configuration.go @@ -27,7 +27,7 @@ import ( "github.com/cloudflare/cloudflared/orchestration" "github.com/cloudflare/cloudflared/supervisor" "github.com/cloudflare/cloudflared/tlsconfig" - tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" + "github.com/cloudflare/cloudflared/tunnelrpc/pogs" ) const ( @@ -133,7 +133,7 @@ func prepareTunnelConfig( log.Err(err).Msg("Tag parse failure") return nil, nil, errors.Wrap(err, "Tag parse failure") } - tags = append(tags, tunnelpogs.Tag{Name: "ID", Value: clientID.String()}) + tags = append(tags, pogs.Tag{Name: "ID", Value: clientID.String()}) transportProtocol := c.String("protocol") @@ -166,7 +166,7 @@ func prepareTunnelConfig( ) } - namedTunnel.Client = tunnelpogs.ClientInfo{ + namedTunnel.Client = pogs.ClientInfo{ ClientID: clientID[:], Features: clientFeatures, Version: info.Version(), diff --git a/cmd/cloudflared/tunnel/tag.go b/cmd/cloudflared/tunnel/tag.go index 3ba2a05e..badca9d7 100644 --- a/cmd/cloudflared/tunnel/tag.go +++ b/cmd/cloudflared/tunnel/tag.go @@ -4,23 +4,23 @@ import ( "fmt" "regexp" - tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" + "github.com/cloudflare/cloudflared/tunnelrpc/pogs" ) // Restrict key names to characters allowed in an HTTP header name. // Restrict key values to printable characters (what is recognised as data in an HTTP header value). var tagRegexp = regexp.MustCompile("^([a-zA-Z0-9!#$%&'*+\\-.^_`|~]+)=([[:print:]]+)$") -func NewTagFromCLI(compoundTag string) (tunnelpogs.Tag, bool) { +func NewTagFromCLI(compoundTag string) (pogs.Tag, bool) { matches := tagRegexp.FindStringSubmatch(compoundTag) if len(matches) == 0 { - return tunnelpogs.Tag{}, false + return pogs.Tag{}, false } - return tunnelpogs.Tag{Name: matches[1], Value: matches[2]}, true + return pogs.Tag{Name: matches[1], Value: matches[2]}, true } -func NewTagSliceFromCLI(tags []string) ([]tunnelpogs.Tag, error) { - var tagSlice []tunnelpogs.Tag +func NewTagSliceFromCLI(tags []string) ([]pogs.Tag, error) { + var tagSlice []pogs.Tag for _, compoundTag := range tags { if tag, ok := NewTagFromCLI(compoundTag); ok { tagSlice = append(tagSlice, tag) diff --git a/cmd/cloudflared/tunnel/tag_test.go b/cmd/cloudflared/tunnel/tag_test.go index 36b7ba6f..0419d4df 100644 --- a/cmd/cloudflared/tunnel/tag_test.go +++ b/cmd/cloudflared/tunnel/tag_test.go @@ -3,7 +3,7 @@ package tunnel import ( "testing" - tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" + "github.com/cloudflare/cloudflared/tunnelrpc/pogs" "github.com/stretchr/testify/assert" ) @@ -11,12 +11,12 @@ import ( func TestSingleTag(t *testing.T) { testCases := []struct { Input string - Output tunnelpogs.Tag + Output pogs.Tag Fail bool }{ - {Input: "x=y", Output: tunnelpogs.Tag{Name: "x", Value: "y"}}, - {Input: "More-Complex=Tag Values", Output: tunnelpogs.Tag{Name: "More-Complex", Value: "Tag Values"}}, - {Input: "First=Equals=Wins", Output: tunnelpogs.Tag{Name: "First", Value: "Equals=Wins"}}, + {Input: "x=y", Output: pogs.Tag{Name: "x", Value: "y"}}, + {Input: "More-Complex=Tag Values", Output: pogs.Tag{Name: "More-Complex", Value: "Tag Values"}}, + {Input: "First=Equals=Wins", Output: pogs.Tag{Name: "First", Value: "Equals=Wins"}}, {Input: "x=", Fail: true}, {Input: "=y", Fail: true}, {Input: "=", Fail: true}, diff --git a/connection/rpc.go b/connection/rpc.go index d72c28f3..f30b7b93 100644 --- a/connection/rpc.go +++ b/connection/rpc.go @@ -12,41 +12,6 @@ import ( tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" ) -type tunnelServerClient struct { - client tunnelpogs.TunnelServer_PogsClient - transport rpc.Transport -} - -// NewTunnelRPCClient creates and returns a new RPC client, which will communicate using a stream on the given muxer. -// This method is exported for supervisor to call Authenticate RPC -func NewTunnelServerClient( - ctx context.Context, - stream io.ReadWriteCloser, - log *zerolog.Logger, -) *tunnelServerClient { - transport := rpc.StreamTransport(stream) - conn := rpc.NewConn(transport) - registrationClient := tunnelpogs.RegistrationServer_PogsClient{Client: conn.Bootstrap(ctx), Conn: conn} - return &tunnelServerClient{ - client: tunnelpogs.TunnelServer_PogsClient{RegistrationServer_PogsClient: registrationClient, Client: conn.Bootstrap(ctx), Conn: conn}, - transport: transport, - } -} - -func (tsc *tunnelServerClient) Authenticate(ctx context.Context, classicTunnel *ClassicTunnelProperties, registrationOptions *tunnelpogs.RegistrationOptions) (tunnelpogs.AuthOutcome, error) { - authResp, err := tsc.client.Authenticate(ctx, classicTunnel.OriginCert, classicTunnel.Hostname, registrationOptions) - if err != nil { - return nil, err - } - return authResp.Outcome(), nil -} - -func (tsc *tunnelServerClient) Close() { - // Closing the client will also close the connection - _ = tsc.client.Close() - _ = tsc.transport.Close() -} - type NamedTunnelRPCClient interface { RegisterConnection( c context.Context, diff --git a/orchestration/orchestrator.go b/orchestration/orchestrator.go index 93afef31..9af18865 100644 --- a/orchestration/orchestrator.go +++ b/orchestration/orchestrator.go @@ -14,7 +14,7 @@ import ( "github.com/cloudflare/cloudflared/connection" "github.com/cloudflare/cloudflared/ingress" "github.com/cloudflare/cloudflared/proxy" - tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" + "github.com/cloudflare/cloudflared/tunnelrpc/pogs" ) // Orchestrator manages configurations, so they can be updatable during runtime @@ -32,7 +32,7 @@ type Orchestrator struct { internalRules []ingress.Rule // cloudflared Configuration config *Config - tags []tunnelpogs.Tag + tags []pogs.Tag log *zerolog.Logger // orchestrator must not handle any more updates after shutdownC is closed @@ -43,7 +43,7 @@ type Orchestrator struct { func NewOrchestrator(ctx context.Context, config *Config, - tags []tunnelpogs.Tag, + tags []pogs.Tag, internalRules []ingress.Rule, log *zerolog.Logger) (*Orchestrator, error) { o := &Orchestrator{ @@ -65,7 +65,7 @@ func NewOrchestrator(ctx context.Context, } // UpdateConfig creates a new proxy with the new ingress rules -func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.UpdateConfigurationResponse { +func (o *Orchestrator) UpdateConfig(version int32, config []byte) *pogs.UpdateConfigurationResponse { o.lock.Lock() defer o.lock.Unlock() @@ -74,7 +74,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up Int32("current_version", o.currentVersion). Int32("received_version", version). Msg("Current version is equal or newer than received version") - return &tunnelpogs.UpdateConfigurationResponse{ + return &pogs.UpdateConfigurationResponse{ LastAppliedVersion: o.currentVersion, } } @@ -84,7 +84,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up Int32("version", version). Str("config", string(config)). Msgf("Failed to deserialize new configuration") - return &tunnelpogs.UpdateConfigurationResponse{ + return &pogs.UpdateConfigurationResponse{ LastAppliedVersion: o.currentVersion, Err: err, } @@ -95,7 +95,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up Int32("version", version). Str("config", string(config)). Msgf("Failed to update ingress") - return &tunnelpogs.UpdateConfigurationResponse{ + return &pogs.UpdateConfigurationResponse{ LastAppliedVersion: o.currentVersion, Err: err, } @@ -107,7 +107,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up Str("config", string(config)). Msg("Updated to new configuration") configVersion.Set(float64(version)) - return &tunnelpogs.UpdateConfigurationResponse{ + return &pogs.UpdateConfigurationResponse{ LastAppliedVersion: o.currentVersion, } } diff --git a/orchestration/orchestrator_test.go b/orchestration/orchestrator_test.go index 233367c9..eb2c6f72 100644 --- a/orchestration/orchestrator_test.go +++ b/orchestration/orchestrator_test.go @@ -23,12 +23,12 @@ import ( "github.com/cloudflare/cloudflared/ingress" "github.com/cloudflare/cloudflared/management" "github.com/cloudflare/cloudflared/tracing" - tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" + "github.com/cloudflare/cloudflared/tunnelrpc/pogs" ) var ( testLogger = zerolog.Nop() - testTags = []tunnelpogs.Tag{ + testTags = []pogs.Tag{ { Name: "package", Value: "orchestration", diff --git a/proxy/proxy.go b/proxy/proxy.go index dc02eeac..dd999f87 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -19,7 +19,7 @@ import ( "github.com/cloudflare/cloudflared/ingress" "github.com/cloudflare/cloudflared/stream" "github.com/cloudflare/cloudflared/tracing" - tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" + "github.com/cloudflare/cloudflared/tunnelrpc/pogs" ) const ( @@ -33,7 +33,7 @@ type Proxy struct { ingressRules ingress.Ingress warpRouting *ingress.WarpRoutingService management *ingress.ManagementService - tags []tunnelpogs.Tag + tags []pogs.Tag log *zerolog.Logger } @@ -41,7 +41,7 @@ type Proxy struct { func NewOriginProxy( ingressRules ingress.Ingress, warpRouting ingress.WarpRoutingConfig, - tags []tunnelpogs.Tag, + tags []pogs.Tag, writeTimeout time.Duration, log *zerolog.Logger, ) *Proxy { diff --git a/proxy/proxy_test.go b/proxy/proxy_test.go index ed7a1439..c1c60fc4 100644 --- a/proxy/proxy_test.go +++ b/proxy/proxy_test.go @@ -30,11 +30,11 @@ import ( "github.com/cloudflare/cloudflared/ingress" "github.com/cloudflare/cloudflared/logger" "github.com/cloudflare/cloudflared/tracing" - tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" + "github.com/cloudflare/cloudflared/tunnelrpc/pogs" ) var ( - testTags = []tunnelpogs.Tag{{Name: "Name", Value: "value"}} + testTags = []pogs.Tag{{Name: "Name", Value: "value"}} noWarpRouting = ingress.WarpRoutingConfig{} testWarpRouting = ingress.WarpRoutingConfig{ ConnectTimeout: config.CustomDuration{Duration: time.Second}, diff --git a/supervisor/tunnel.go b/supervisor/tunnel.go index ba52d0df..e7c25baf 100644 --- a/supervisor/tunnel.go +++ b/supervisor/tunnel.go @@ -10,7 +10,6 @@ import ( "sync" "time" - "github.com/google/uuid" "github.com/pkg/errors" "github.com/quic-go/quic-go" "github.com/rs/zerolog" @@ -27,8 +26,7 @@ import ( quicpogs "github.com/cloudflare/cloudflared/quic" "github.com/cloudflare/cloudflared/retry" "github.com/cloudflare/cloudflared/signal" - tunnelpogs "github.com/cloudflare/cloudflared/tunnelrpc/pogs" - "github.com/cloudflare/cloudflared/tunnelrpc/proto" + "github.com/cloudflare/cloudflared/tunnelrpc/pogs" "github.com/cloudflare/cloudflared/tunnelstate" ) @@ -49,7 +47,7 @@ type TunnelConfig struct { HAConnections int IsAutoupdated bool LBPool string - Tags []tunnelpogs.Tag + Tags []pogs.Tag Log *zerolog.Logger LogTransport *zerolog.Logger Observer *connection.Observer @@ -73,34 +71,12 @@ type TunnelConfig struct { FeatureSelector *features.FeatureSelector } -func (c *TunnelConfig) registrationOptions(connectionID uint8, OriginLocalIP string, uuid uuid.UUID) *tunnelpogs.RegistrationOptions { - policy := proto.ExistingTunnelPolicy_balance - if c.HAConnections <= 1 && c.LBPool == "" { - policy = proto.ExistingTunnelPolicy_disconnect - } - return &tunnelpogs.RegistrationOptions{ - ClientID: c.ClientID, - Version: c.ReportedVersion, - OS: c.OSArch, - ExistingTunnelPolicy: policy, - PoolName: c.LBPool, - Tags: c.Tags, - ConnectionID: connectionID, - OriginLocalIP: OriginLocalIP, - IsAutoupdated: c.IsAutoupdated, - RunFromTerminal: c.RunFromTerminal, - CompressionQuality: 0, - UUID: uuid.String(), - Features: c.SupportedFeatures(), - } -} - -func (c *TunnelConfig) connectionOptions(originLocalAddr string, numPreviousAttempts uint8) *tunnelpogs.ConnectionOptions { +func (c *TunnelConfig) connectionOptions(originLocalAddr string, numPreviousAttempts uint8) *pogs.ConnectionOptions { // attempt to parse out origin IP, but don't fail since it's informational field host, _, _ := net.SplitHostPort(originLocalAddr) originIP := net.ParseIP(host) - return &tunnelpogs.ConnectionOptions{ + return &pogs.ConnectionOptions{ Client: c.NamedTunnel.Client, OriginLocalIP: originIP, ReplaceExisting: c.ReplaceExisting, @@ -530,7 +506,7 @@ func (e *EdgeTunnelServer) serveHTTP2( ctx context.Context, connLog *ConnAwareLogger, tlsServerConn net.Conn, - connOptions *tunnelpogs.ConnectionOptions, + connOptions *pogs.ConnectionOptions, controlStreamHandler connection.ControlStreamHandler, connIndex uint8, ) error { @@ -572,7 +548,7 @@ func (e *EdgeTunnelServer) serveQUIC( ctx context.Context, edgeAddr *net.UDPAddr, connLogger *ConnAwareLogger, - connOptions *tunnelpogs.ConnectionOptions, + connOptions *pogs.ConnectionOptions, controlStreamHandler connection.ControlStreamHandler, connIndex uint8, ) (err error, recoverable bool) { diff --git a/tunnelrpc/pogs/auth_outcome.go b/tunnelrpc/pogs/auth_outcome.go deleted file mode 100644 index fcbb7186..00000000 --- a/tunnelrpc/pogs/auth_outcome.go +++ /dev/null @@ -1,131 +0,0 @@ -package pogs - -import ( - "errors" - "time" -) - -// AuthenticateResponse is the serialized response from the Authenticate RPC. -// It's a 1:1 representation of the capnp message, so it's not very useful for programmers. -// Instead, you should call the `Outcome()` method to get a programmer-friendly sum type, with one -// case for each possible outcome. -type AuthenticateResponse struct { - PermanentErr string - RetryableErr string - Jwt []byte - HoursUntilRefresh uint8 -} - -// Outcome turns the deserialized response of Authenticate into a programmer-friendly sum type. -func (ar AuthenticateResponse) Outcome() AuthOutcome { - // If the user's authentication was unsuccessful, the server will return an error explaining why. - // cloudflared should fatal with this error. - if ar.PermanentErr != "" { - return NewAuthFail(errors.New(ar.PermanentErr)) - } - - // If there was a network error, then cloudflared should retry later, - // because origintunneld couldn't prove whether auth was correct or not. - if ar.RetryableErr != "" { - return NewAuthUnknown(errors.New(ar.RetryableErr), ar.HoursUntilRefresh) - } - - // If auth succeeded, return the token and refresh it when instructed. - if len(ar.Jwt) > 0 { - return NewAuthSuccess(ar.Jwt, ar.HoursUntilRefresh) - } - - // Otherwise the state got messed up. - return nil -} - -// AuthOutcome is a programmer-friendly sum type denoting the possible outcomes of Authenticate. -type AuthOutcome interface { - isAuthOutcome() - // Serialize into an AuthenticateResponse which can be sent via Capnp - Serialize() AuthenticateResponse -} - -// AuthSuccess means the backend successfully authenticated this cloudflared. -type AuthSuccess struct { - jwt []byte - hoursUntilRefresh uint8 -} - -func NewAuthSuccess(jwt []byte, hoursUntilRefresh uint8) AuthSuccess { - return AuthSuccess{jwt: jwt, hoursUntilRefresh: hoursUntilRefresh} -} - -func (ao AuthSuccess) JWT() []byte { - return ao.jwt -} - -// RefreshAfter is how long cloudflared should wait before rerunning Authenticate. -func (ao AuthSuccess) RefreshAfter() time.Duration { - return hoursToTime(ao.hoursUntilRefresh) -} - -// Serialize into an AuthenticateResponse which can be sent via Capnp -func (ao AuthSuccess) Serialize() AuthenticateResponse { - return AuthenticateResponse{ - Jwt: ao.jwt, - HoursUntilRefresh: ao.hoursUntilRefresh, - } -} - -func (ao AuthSuccess) isAuthOutcome() {} - -// AuthFail means this cloudflared has the wrong auth and should exit. -type AuthFail struct { - err error -} - -func NewAuthFail(err error) AuthFail { - return AuthFail{err: err} -} - -func (ao AuthFail) Error() string { - return ao.err.Error() -} - -// Serialize into an AuthenticateResponse which can be sent via Capnp -func (ao AuthFail) Serialize() AuthenticateResponse { - return AuthenticateResponse{ - PermanentErr: ao.err.Error(), - } -} - -func (ao AuthFail) isAuthOutcome() {} - -// AuthUnknown means the backend couldn't finish checking authentication. Try again later. -type AuthUnknown struct { - err error - hoursUntilRefresh uint8 -} - -func NewAuthUnknown(err error, hoursUntilRefresh uint8) AuthUnknown { - return AuthUnknown{err: err, hoursUntilRefresh: hoursUntilRefresh} -} - -func (ao AuthUnknown) Error() string { - return ao.err.Error() -} - -// RefreshAfter is how long cloudflared should wait before rerunning Authenticate. -func (ao AuthUnknown) RefreshAfter() time.Duration { - return hoursToTime(ao.hoursUntilRefresh) -} - -// Serialize into an AuthenticateResponse which can be sent via Capnp -func (ao AuthUnknown) Serialize() AuthenticateResponse { - return AuthenticateResponse{ - RetryableErr: ao.err.Error(), - HoursUntilRefresh: ao.hoursUntilRefresh, - } -} - -func (ao AuthUnknown) isAuthOutcome() {} - -func hoursToTime(hours uint8) time.Duration { - return time.Duration(hours) * time.Hour -} diff --git a/tunnelrpc/pogs/auth_serialize.go b/tunnelrpc/pogs/auth_serialize.go deleted file mode 100644 index 68072199..00000000 --- a/tunnelrpc/pogs/auth_serialize.go +++ /dev/null @@ -1,78 +0,0 @@ -package pogs - -import ( - "context" - - "zombiezen.com/go/capnproto2/pogs" - "zombiezen.com/go/capnproto2/server" - - "github.com/cloudflare/cloudflared/tunnelrpc/proto" -) - -func (i TunnelServer_PogsImpl) Authenticate(p proto.TunnelServer_authenticate) error { - originCert, err := p.Params.OriginCert() - if err != nil { - return err - } - hostname, err := p.Params.Hostname() - if err != nil { - return err - } - options, err := p.Params.Options() - if err != nil { - return err - } - pogsOptions, err := UnmarshalRegistrationOptions(options) - if err != nil { - return err - } - - server.Ack(p.Options) - resp, err := i.impl.Authenticate(p.Ctx, originCert, hostname, pogsOptions) - if err != nil { - return err - } - result, err := p.Results.NewResult() - if err != nil { - return err - } - return MarshalAuthenticateResponse(result, resp) -} - -func MarshalAuthenticateResponse(s proto.AuthenticateResponse, p *AuthenticateResponse) error { - return pogs.Insert(proto.AuthenticateResponse_TypeID, s.Struct, p) -} - -func (c TunnelServer_PogsClient) Authenticate(ctx context.Context, originCert []byte, hostname string, options *RegistrationOptions) (*AuthenticateResponse, error) { - client := proto.TunnelServer{Client: c.Client} - promise := client.Authenticate(ctx, func(p proto.TunnelServer_authenticate_Params) error { - err := p.SetOriginCert(originCert) - if err != nil { - return err - } - err = p.SetHostname(hostname) - if err != nil { - return err - } - registrationOptions, err := p.NewOptions() - if err != nil { - return err - } - err = MarshalRegistrationOptions(registrationOptions, options) - if err != nil { - return err - } - return nil - }) - retval, err := promise.Result().Struct() - if err != nil { - return nil, err - } - return UnmarshalAuthenticateResponse(retval) -} - -func UnmarshalAuthenticateResponse(s proto.AuthenticateResponse) (*AuthenticateResponse, error) { - p := new(AuthenticateResponse) - err := pogs.Extract(p, proto.AuthenticateResponse_TypeID, s.Struct) - return p, err -} diff --git a/tunnelrpc/pogs/auth_test.go b/tunnelrpc/pogs/auth_test.go deleted file mode 100644 index f76f6f65..00000000 --- a/tunnelrpc/pogs/auth_test.go +++ /dev/null @@ -1,136 +0,0 @@ -package pogs - -import ( - "fmt" - "reflect" - "testing" - "time" - - "github.com/stretchr/testify/assert" - capnp "zombiezen.com/go/capnproto2" - - "github.com/cloudflare/cloudflared/tunnelrpc/proto" -) - -// Ensure the AuthOutcome sum is correct -var _ AuthOutcome = &AuthSuccess{} -var _ AuthOutcome = &AuthFail{} -var _ AuthOutcome = &AuthUnknown{} - -// Unit tests for AuthenticateResponse.Outcome() -func TestAuthenticateResponseOutcome(t *testing.T) { - type fields struct { - PermanentErr string - RetryableErr string - Jwt []byte - HoursUntilRefresh uint8 - } - tests := []struct { - name string - fields fields - want AuthOutcome - }{ - {"success", - fields{Jwt: []byte("asdf"), HoursUntilRefresh: 6}, - AuthSuccess{jwt: []byte("asdf"), hoursUntilRefresh: 6}, - }, - {"fail", - fields{PermanentErr: "bad creds"}, - AuthFail{err: fmt.Errorf("bad creds")}, - }, - {"error", - fields{RetryableErr: "bad conn", HoursUntilRefresh: 6}, - AuthUnknown{err: fmt.Errorf("bad conn"), hoursUntilRefresh: 6}, - }, - {"nil (no fields are set)", - fields{}, - nil, - }, - {"nil (too few fields are set)", - fields{HoursUntilRefresh: 6}, - nil, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ar := AuthenticateResponse{ - PermanentErr: tt.fields.PermanentErr, - RetryableErr: tt.fields.RetryableErr, - Jwt: tt.fields.Jwt, - HoursUntilRefresh: tt.fields.HoursUntilRefresh, - } - got := ar.Outcome() - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("AuthenticateResponse.Outcome() = %T, want %v", got, tt.want) - } - if got != nil && !reflect.DeepEqual(got.Serialize(), ar) { - t.Errorf(".Outcome() and .Serialize() should be inverses but weren't. Expected %v, got %v", ar, got.Serialize()) - } - }) - } -} - -func TestAuthSuccess(t *testing.T) { - input := NewAuthSuccess([]byte("asdf"), 6) - output, ok := input.Serialize().Outcome().(AuthSuccess) - assert.True(t, ok) - assert.Equal(t, input, output) -} - -func TestAuthUnknown(t *testing.T) { - input := NewAuthUnknown(fmt.Errorf("pdx unreachable"), 6) - output, ok := input.Serialize().Outcome().(AuthUnknown) - assert.True(t, ok) - assert.Equal(t, input, output) -} - -func TestAuthFail(t *testing.T) { - input := NewAuthFail(fmt.Errorf("wrong creds")) - output, ok := input.Serialize().Outcome().(AuthFail) - assert.True(t, ok) - assert.Equal(t, input, output) -} - -func TestWhenToRefresh(t *testing.T) { - expected := 4 * time.Hour - actual := hoursToTime(4) - if expected != actual { - t.Fatalf("expected %v hours, got %v", expected, actual) - } -} - -// Test that serializing and deserializing AuthenticationResponse undo each other. -func TestSerializeAuthenticationResponse(t *testing.T) { - - tests := []*AuthenticateResponse{ - { - Jwt: []byte("\xbd\xb2\x3d\xbc\x20\xe2\x8c\x98"), - HoursUntilRefresh: 24, - }, - { - PermanentErr: "bad auth", - }, - { - RetryableErr: "bad connection", - HoursUntilRefresh: 24, - }, - } - - for i, testCase := range tests { - _, seg, err := capnp.NewMessage(capnp.SingleSegment(nil)) - assert.NoError(t, err) - capnpEntity, err := proto.NewAuthenticateResponse(seg) - if !assert.NoError(t, err) { - t.Fatal("Couldn't initialize a new message") - } - err = MarshalAuthenticateResponse(capnpEntity, testCase) - if !assert.NoError(t, err, "testCase index %v failed to marshal", i) { - continue - } - result, err := UnmarshalAuthenticateResponse(capnpEntity) - if !assert.NoError(t, err, "testCase index %v failed to unmarshal", i) { - continue - } - assert.Equal(t, testCase, result, "testCase index %v didn't preserve struct through marshalling and unmarshalling", i) - } -} diff --git a/tunnelrpc/pogs/cloudflaredrpc.go b/tunnelrpc/pogs/cloudflared_server.go similarity index 100% rename from tunnelrpc/pogs/cloudflaredrpc.go rename to tunnelrpc/pogs/cloudflared_server.go diff --git a/tunnelrpc/pogs/configurationrpc.go b/tunnelrpc/pogs/configuration_manager.go similarity index 100% rename from tunnelrpc/pogs/configurationrpc.go rename to tunnelrpc/pogs/configuration_manager.go diff --git a/tunnelrpc/pogs/reconnect_tunnel.go b/tunnelrpc/pogs/reconnect_tunnel.go deleted file mode 100644 index 081f8628..00000000 --- a/tunnelrpc/pogs/reconnect_tunnel.go +++ /dev/null @@ -1,93 +0,0 @@ -package pogs - -import ( - "context" - - "zombiezen.com/go/capnproto2/server" - - "github.com/cloudflare/cloudflared/tunnelrpc/proto" -) - -func (i TunnelServer_PogsImpl) ReconnectTunnel(p proto.TunnelServer_reconnectTunnel) error { - jwt, err := p.Params.Jwt() - if err != nil { - return err - } - eventDigest, err := p.Params.EventDigest() - if err != nil { - return err - } - connDigest, err := p.Params.ConnDigest() - if err != nil { - return err - } - hostname, err := p.Params.Hostname() - if err != nil { - return err - } - options, err := p.Params.Options() - if err != nil { - return err - } - pogsOptions, err := UnmarshalRegistrationOptions(options) - if err != nil { - return err - } - server.Ack(p.Options) - registration, err := i.impl.ReconnectTunnel(p.Ctx, jwt, eventDigest, connDigest, hostname, pogsOptions) - if err != nil { - return err - } - result, err := p.Results.NewResult() - if err != nil { - return err - } - return MarshalTunnelRegistration(result, registration) -} - -func (c TunnelServer_PogsClient) ReconnectTunnel( - ctx context.Context, - jwt, - eventDigest []byte, - connDigest []byte, - hostname string, - options *RegistrationOptions, -) *TunnelRegistration { - client := proto.TunnelServer{Client: c.Client} - promise := client.ReconnectTunnel(ctx, func(p proto.TunnelServer_reconnectTunnel_Params) error { - err := p.SetJwt(jwt) - if err != nil { - return err - } - err = p.SetEventDigest(eventDigest) - if err != nil { - return err - } - err = p.SetConnDigest(connDigest) - if err != nil { - return err - } - err = p.SetHostname(hostname) - if err != nil { - return err - } - registrationOptions, err := p.NewOptions() - if err != nil { - return err - } - err = MarshalRegistrationOptions(registrationOptions, options) - if err != nil { - return err - } - return nil - }) - retval, err := promise.Result().Struct() - if err != nil { - return NewRetryableRegistrationError(err, defaultRetryAfterSeconds).Serialize() - } - registration, err := UnmarshalTunnelRegistration(retval) - if err != nil { - return NewRetryableRegistrationError(err, defaultRetryAfterSeconds).Serialize() - } - return registration -} diff --git a/tunnelrpc/pogs/connectionrpc.go b/tunnelrpc/pogs/registration_server.go similarity index 100% rename from tunnelrpc/pogs/connectionrpc.go rename to tunnelrpc/pogs/registration_server.go diff --git a/tunnelrpc/pogs/connectionrpc_test.go b/tunnelrpc/pogs/registration_server_test.go similarity index 93% rename from tunnelrpc/pogs/connectionrpc_test.go rename to tunnelrpc/pogs/registration_server_test.go index 114b09ae..70dfba48 100644 --- a/tunnelrpc/pogs/connectionrpc_test.go +++ b/tunnelrpc/pogs/registration_server_test.go @@ -54,18 +54,14 @@ func TestConnectionRegistrationRPC(t *testing.T) { // Server-side testImpl := testConnectionRegistrationServer{} - srv := TunnelServer_ServerToClient(&testImpl) + srv := RegistrationServer_ServerToClient(&testImpl) serverConn := rpc.NewConn(t1, rpc.MainInterface(srv.Client)) defer serverConn.Wait() ctx := context.Background() clientConn := rpc.NewConn(t2) defer clientConn.Close() - client := TunnelServer_PogsClient{ - RegistrationServer_PogsClient: RegistrationServer_PogsClient{ - Client: clientConn.Bootstrap(ctx), - Conn: clientConn, - }, + client := RegistrationServer_PogsClient{ Client: clientConn.Bootstrap(ctx), Conn: clientConn, } @@ -123,8 +119,6 @@ func TestConnectionRegistrationRPC(t *testing.T) { } type testConnectionRegistrationServer struct { - mockTunnelServerBase - details *ConnectionDetails err error } @@ -147,3 +141,7 @@ func (t *testConnectionRegistrationServer) RegisterConnection(ctx context.Contex panic("either details or err mush be set") } + +func (t *testConnectionRegistrationServer) UnregisterConnection(ctx context.Context) { + panic("unimplemented: UnregisterConnection") +} diff --git a/tunnelrpc/pogs/sessionrpc.go b/tunnelrpc/pogs/session_manager.go similarity index 100% rename from tunnelrpc/pogs/sessionrpc.go rename to tunnelrpc/pogs/session_manager.go diff --git a/tunnelrpc/pogs/support_test.go b/tunnelrpc/pogs/support_test.go deleted file mode 100644 index dc98ed39..00000000 --- a/tunnelrpc/pogs/support_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package pogs - -import ( - "context" - - "github.com/google/uuid" -) - -// mockTunnelServerBase provides a placeholder implementation -// for TunnelServer interface that can be used to build -// mocks for specific unit tests without having to implement every method -type mockTunnelServerBase struct{} - -func (mockTunnelServerBase) RegisterConnection(ctx context.Context, auth TunnelAuth, tunnelID uuid.UUID, connIndex byte, options *ConnectionOptions) (*ConnectionDetails, error) { - panic("unexpected call to RegisterConnection") -} - -func (mockTunnelServerBase) UnregisterConnection(ctx context.Context) { - panic("unexpected call to UnregisterConnection") -} - -func (mockTunnelServerBase) RegisterTunnel(ctx context.Context, originCert []byte, hostname string, options *RegistrationOptions) *TunnelRegistration { - panic("unexpected call to RegisterTunnel") -} - -func (mockTunnelServerBase) GetServerInfo(ctx context.Context) (*ServerInfo, error) { - panic("unexpected call to GetServerInfo") -} - -func (mockTunnelServerBase) UnregisterTunnel(ctx context.Context, gracePeriodNanoSec int64) error { - panic("unexpected call to UnregisterTunnel") -} - -func (mockTunnelServerBase) Authenticate(ctx context.Context, originCert []byte, hostname string, options *RegistrationOptions) (*AuthenticateResponse, error) { - panic("unexpected call to Authenticate") -} - -func (mockTunnelServerBase) ReconnectTunnel(ctx context.Context, jwt, eventDigest, connDigest []byte, hostname string, options *RegistrationOptions) (*TunnelRegistration, error) { - panic("unexpected call to ReconnectTunnel") -} diff --git a/tunnelrpc/pogs/tag.go b/tunnelrpc/pogs/tag.go new file mode 100644 index 00000000..51919582 --- /dev/null +++ b/tunnelrpc/pogs/tag.go @@ -0,0 +1,8 @@ +package pogs + +// Tag previously was a legacy tunnel capnp struct but was deprecated. To help reduce the amount of changes imposed +// by removing this simple struct, it was copied out of the capnp and provided here instead. +type Tag struct { + Name string + Value string +} diff --git a/tunnelrpc/pogs/tunnelrpc.go b/tunnelrpc/pogs/tunnelrpc.go deleted file mode 100644 index d7af7b20..00000000 --- a/tunnelrpc/pogs/tunnelrpc.go +++ /dev/null @@ -1,334 +0,0 @@ -package pogs - -import ( - "context" - "fmt" - - capnp "zombiezen.com/go/capnproto2" - "zombiezen.com/go/capnproto2/pogs" - "zombiezen.com/go/capnproto2/rpc" - "zombiezen.com/go/capnproto2/server" - - "github.com/cloudflare/cloudflared/tunnelrpc/proto" -) - -const ( - defaultRetryAfterSeconds = 15 -) - -type Authentication struct { - Key string - Email string - OriginCAKey string -} - -func MarshalAuthentication(s proto.Authentication, p *Authentication) error { - return pogs.Insert(proto.Authentication_TypeID, s.Struct, p) -} - -func UnmarshalAuthentication(s proto.Authentication) (*Authentication, error) { - p := new(Authentication) - err := pogs.Extract(p, proto.Authentication_TypeID, s.Struct) - return p, err -} - -type TunnelRegistration struct { - SuccessfulTunnelRegistration - Err string - PermanentFailure bool - RetryAfterSeconds uint16 -} - -type SuccessfulTunnelRegistration struct { - Url string - LogLines []string - TunnelID string `capnp:"tunnelID"` - EventDigest []byte - ConnDigest []byte -} - -func NewSuccessfulTunnelRegistration( - url string, - logLines []string, - tunnelID string, - eventDigest []byte, - connDigest []byte, -) *TunnelRegistration { - // Marshal nil will result in an error - if logLines == nil { - logLines = []string{} - } - return &TunnelRegistration{ - SuccessfulTunnelRegistration: SuccessfulTunnelRegistration{ - Url: url, - LogLines: logLines, - TunnelID: tunnelID, - EventDigest: eventDigest, - ConnDigest: connDigest, - }, - } -} - -// Not calling this function Error() to avoid confusion with implementing error interface -func (tr TunnelRegistration) DeserializeError() TunnelRegistrationError { - if tr.Err != "" { - err := fmt.Errorf(tr.Err) - if tr.PermanentFailure { - return NewPermanentRegistrationError(err) - } - retryAfterSeconds := tr.RetryAfterSeconds - if retryAfterSeconds < defaultRetryAfterSeconds { - retryAfterSeconds = defaultRetryAfterSeconds - } - return NewRetryableRegistrationError(err, retryAfterSeconds) - } - return nil -} - -type TunnelRegistrationError interface { - error - Serialize() *TunnelRegistration - IsPermanent() bool -} - -type PermanentRegistrationError struct { - err string -} - -func NewPermanentRegistrationError(err error) TunnelRegistrationError { - return &PermanentRegistrationError{ - err: err.Error(), - } -} - -func (pre *PermanentRegistrationError) Error() string { - return pre.err -} - -func (pre *PermanentRegistrationError) Serialize() *TunnelRegistration { - return &TunnelRegistration{ - Err: pre.err, - PermanentFailure: true, - } -} - -func (*PermanentRegistrationError) IsPermanent() bool { - return true -} - -type RetryableRegistrationError struct { - err string - retryAfterSeconds uint16 -} - -func NewRetryableRegistrationError(err error, retryAfterSeconds uint16) TunnelRegistrationError { - return &RetryableRegistrationError{ - err: err.Error(), - retryAfterSeconds: retryAfterSeconds, - } -} - -func (rre *RetryableRegistrationError) Error() string { - return rre.err -} - -func (rre *RetryableRegistrationError) Serialize() *TunnelRegistration { - return &TunnelRegistration{ - Err: rre.err, - PermanentFailure: false, - RetryAfterSeconds: rre.retryAfterSeconds, - } -} - -func (*RetryableRegistrationError) IsPermanent() bool { - return false -} - -func MarshalTunnelRegistration(s proto.TunnelRegistration, p *TunnelRegistration) error { - return pogs.Insert(proto.TunnelRegistration_TypeID, s.Struct, p) -} - -func UnmarshalTunnelRegistration(s proto.TunnelRegistration) (*TunnelRegistration, error) { - p := new(TunnelRegistration) - err := pogs.Extract(p, proto.TunnelRegistration_TypeID, s.Struct) - return p, err -} - -type RegistrationOptions struct { - ClientID string `capnp:"clientId"` - Version string - OS string `capnp:"os"` - ExistingTunnelPolicy proto.ExistingTunnelPolicy - PoolName string `capnp:"poolName"` - Tags []Tag - ConnectionID uint8 `capnp:"connectionId"` - OriginLocalIP string `capnp:"originLocalIp"` - IsAutoupdated bool `capnp:"isAutoupdated"` - RunFromTerminal bool `capnp:"runFromTerminal"` - CompressionQuality uint64 `capnp:"compressionQuality"` - UUID string `capnp:"uuid"` - NumPreviousAttempts uint8 - Features []string -} - -func MarshalRegistrationOptions(s proto.RegistrationOptions, p *RegistrationOptions) error { - return pogs.Insert(proto.RegistrationOptions_TypeID, s.Struct, p) -} - -func UnmarshalRegistrationOptions(s proto.RegistrationOptions) (*RegistrationOptions, error) { - p := new(RegistrationOptions) - err := pogs.Extract(p, proto.RegistrationOptions_TypeID, s.Struct) - return p, err -} - -type Tag struct { - Name string `json:"name"` - Value string `json:"value"` -} - -type ServerInfo struct { - LocationName string -} - -func MarshalServerInfo(s proto.ServerInfo, p *ServerInfo) error { - return pogs.Insert(proto.ServerInfo_TypeID, s.Struct, p) -} - -func UnmarshalServerInfo(s proto.ServerInfo) (*ServerInfo, error) { - p := new(ServerInfo) - err := pogs.Extract(p, proto.ServerInfo_TypeID, s.Struct) - return p, err -} - -type TunnelServer interface { - RegistrationServer - RegisterTunnel(ctx context.Context, originCert []byte, hostname string, options *RegistrationOptions) *TunnelRegistration - GetServerInfo(ctx context.Context) (*ServerInfo, error) - UnregisterTunnel(ctx context.Context, gracePeriodNanoSec int64) error - Authenticate(ctx context.Context, originCert []byte, hostname string, options *RegistrationOptions) (*AuthenticateResponse, error) - ReconnectTunnel(ctx context.Context, jwt, eventDigest, connDigest []byte, hostname string, options *RegistrationOptions) (*TunnelRegistration, error) -} - -func TunnelServer_ServerToClient(s TunnelServer) proto.TunnelServer { - return proto.TunnelServer_ServerToClient(TunnelServer_PogsImpl{RegistrationServer_PogsImpl{s}, s}) -} - -type TunnelServer_PogsImpl struct { - RegistrationServer_PogsImpl - impl TunnelServer -} - -func (i TunnelServer_PogsImpl) RegisterTunnel(p proto.TunnelServer_registerTunnel) error { - originCert, err := p.Params.OriginCert() - if err != nil { - return err - } - hostname, err := p.Params.Hostname() - if err != nil { - return err - } - options, err := p.Params.Options() - if err != nil { - return err - } - pogsOptions, err := UnmarshalRegistrationOptions(options) - if err != nil { - return err - } - server.Ack(p.Options) - registration := i.impl.RegisterTunnel(p.Ctx, originCert, hostname, pogsOptions) - - result, err := p.Results.NewResult() - if err != nil { - return err - } - return MarshalTunnelRegistration(result, registration) -} - -func (i TunnelServer_PogsImpl) GetServerInfo(p proto.TunnelServer_getServerInfo) error { - server.Ack(p.Options) - serverInfo, err := i.impl.GetServerInfo(p.Ctx) - if err != nil { - return err - } - result, err := p.Results.NewResult() - if err != nil { - return err - } - return MarshalServerInfo(result, serverInfo) -} - -func (i TunnelServer_PogsImpl) UnregisterTunnel(p proto.TunnelServer_unregisterTunnel) error { - gracePeriodNanoSec := p.Params.GracePeriodNanoSec() - server.Ack(p.Options) - return i.impl.UnregisterTunnel(p.Ctx, gracePeriodNanoSec) -} - -func (i TunnelServer_PogsImpl) ObsoleteDeclarativeTunnelConnect(p proto.TunnelServer_obsoleteDeclarativeTunnelConnect) error { - return fmt.Errorf("RPC to create declarative tunnel connection has been deprecated") -} - -type TunnelServer_PogsClient struct { - RegistrationServer_PogsClient - Client capnp.Client - Conn *rpc.Conn -} - -func (c TunnelServer_PogsClient) Close() error { - c.Client.Close() - return c.Conn.Close() -} - -func (c TunnelServer_PogsClient) RegisterTunnel(ctx context.Context, originCert []byte, hostname string, options *RegistrationOptions) *TunnelRegistration { - client := proto.TunnelServer{Client: c.Client} - promise := client.RegisterTunnel(ctx, func(p proto.TunnelServer_registerTunnel_Params) error { - err := p.SetOriginCert(originCert) - if err != nil { - return err - } - err = p.SetHostname(hostname) - if err != nil { - return err - } - registrationOptions, err := p.NewOptions() - if err != nil { - return err - } - err = MarshalRegistrationOptions(registrationOptions, options) - if err != nil { - return err - } - return nil - }) - retval, err := promise.Result().Struct() - if err != nil { - return NewRetryableRegistrationError(err, defaultRetryAfterSeconds).Serialize() - } - registration, err := UnmarshalTunnelRegistration(retval) - if err != nil { - return NewRetryableRegistrationError(err, defaultRetryAfterSeconds).Serialize() - } - return registration -} - -func (c TunnelServer_PogsClient) GetServerInfo(ctx context.Context) (*ServerInfo, error) { - client := proto.TunnelServer{Client: c.Client} - promise := client.GetServerInfo(ctx, func(p proto.TunnelServer_getServerInfo_Params) error { - return nil - }) - retval, err := promise.Result().Struct() - if err != nil { - return nil, err - } - return UnmarshalServerInfo(retval) -} - -func (c TunnelServer_PogsClient) UnregisterTunnel(ctx context.Context, gracePeriodNanoSec int64) error { - client := proto.TunnelServer{Client: c.Client} - promise := client.UnregisterTunnel(ctx, func(p proto.TunnelServer_unregisterTunnel_Params) error { - p.SetGracePeriodNanoSec(gracePeriodNanoSec) - return nil - }) - _, err := promise.Struct() - return err -} diff --git a/tunnelrpc/pogs/tunnelrpc_test.go b/tunnelrpc/pogs/tunnelrpc_test.go deleted file mode 100644 index 2a80cc56..00000000 --- a/tunnelrpc/pogs/tunnelrpc_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package pogs - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" - capnp "zombiezen.com/go/capnproto2" - - "github.com/cloudflare/cloudflared/tunnelrpc/proto" -) - -const ( - testURL = "tunnel.example.com" - testTunnelID = "asdfghjkl;" - testRetryAfterSeconds = 19 -) - -var ( - testErr = fmt.Errorf("Invalid credential") - testLogLines = []string{"all", "working"} - testEventDigest = []byte("asdf") - testConnDigest = []byte("lkjh") -) - -// *PermanentRegistrationError implements TunnelRegistrationError -var _ TunnelRegistrationError = (*PermanentRegistrationError)(nil) - -// *RetryableRegistrationError implements TunnelRegistrationError -var _ TunnelRegistrationError = (*RetryableRegistrationError)(nil) - -func TestTunnelRegistration(t *testing.T) { - testCases := []*TunnelRegistration{ - NewSuccessfulTunnelRegistration(testURL, testLogLines, testTunnelID, testEventDigest, testConnDigest), - NewSuccessfulTunnelRegistration(testURL, nil, testTunnelID, testEventDigest, testConnDigest), - NewPermanentRegistrationError(testErr).Serialize(), - NewRetryableRegistrationError(testErr, testRetryAfterSeconds).Serialize(), - } - for i, testCase := range testCases { - _, seg, err := capnp.NewMessage(capnp.SingleSegment(nil)) - assert.NoError(t, err) - capnpEntity, err := proto.NewTunnelRegistration(seg) - if !assert.NoError(t, err) { - t.Fatal("Couldn't initialize a new message") - } - err = MarshalTunnelRegistration(capnpEntity, testCase) - if !assert.NoError(t, err, "testCase #%v failed to marshal", i) { - continue - } - result, err := UnmarshalTunnelRegistration(capnpEntity) - if !assert.NoError(t, err, "testCase #%v failed to unmarshal", i) { - continue - } - assert.Equal(t, testCase, result, "testCase index %v didn't preserve struct through marshalling and unmarshalling", i) - } - -} diff --git a/tunnelrpc/proto/tunnelrpc.capnp b/tunnelrpc/proto/tunnelrpc.capnp index 206060a1..08c3b9e0 100644 --- a/tunnelrpc/proto/tunnelrpc.capnp +++ b/tunnelrpc/proto/tunnelrpc.capnp @@ -3,13 +3,21 @@ using Go = import "go.capnp"; $Go.package("proto"); $Go.import("github.com/cloudflare/cloudflared/tunnelrpc"); +# === DEPRECATED Legacy Tunnel Authentication and Registration methods/servers === +# +# These structs and interfaces are no longer used but it is important to keep +# them around to make sure backwards compatibility within the rpc protocol is +# maintained. + struct Authentication @0xc082ef6e0d42ed1d { + # DEPRECATED: Legacy tunnel authentication mechanism key @0 :Text; email @1 :Text; originCAKey @2 :Text; } struct TunnelRegistration @0xf41a0f001ad49e46 { + # DEPRECATED: Legacy tunnel authentication mechanism err @0 :Text; # the url to access the tunnel url @1 :Text; @@ -28,6 +36,8 @@ struct TunnelRegistration @0xf41a0f001ad49e46 { } struct RegistrationOptions @0xc793e50592935b4a { + # DEPRECATED: Legacy tunnel authentication mechanism + # The tunnel client's unique identifier, used to verify a reconnection. clientId @0 :Text; # Information about the running binary. @@ -56,28 +66,50 @@ struct RegistrationOptions @0xc793e50592935b4a { features @13 :List(Text); } -struct Tag @0xcbd96442ae3bb01a { - name @0 :Text; - value @1 :Text; -} - enum ExistingTunnelPolicy @0x84cb9536a2cf6d3c { + # DEPRECATED: Legacy tunnel registration mechanism + ignore @0; disconnect @1; balance @2; } struct ServerInfo @0xf2c68e2547ec3866 { + # DEPRECATED: Legacy tunnel registration mechanism + locationName @0 :Text; } struct AuthenticateResponse @0x82c325a07ad22a65 { + # DEPRECATED: Legacy tunnel registration mechanism + permanentErr @0 :Text; retryableErr @1 :Text; jwt @2 :Data; hoursUntilRefresh @3 :UInt8; } +interface TunnelServer @0xea58385c65416035 extends (RegistrationServer) { + # DEPRECATED: Legacy tunnel authentication server + + registerTunnel @0 (originCert :Data, hostname :Text, options :RegistrationOptions) -> (result :TunnelRegistration); + getServerInfo @1 () -> (result :ServerInfo); + unregisterTunnel @2 (gracePeriodNanoSec :Int64) -> (); + # obsoleteDeclarativeTunnelConnect RPC deprecated in TUN-3019 + obsoleteDeclarativeTunnelConnect @3 () -> (); + authenticate @4 (originCert :Data, hostname :Text, options :RegistrationOptions) -> (result :AuthenticateResponse); + reconnectTunnel @5 (jwt :Data, eventDigest :Data, connDigest :Data, hostname :Text, options :RegistrationOptions) -> (result :TunnelRegistration); +} + +struct Tag @0xcbd96442ae3bb01a { + # DEPRECATED: Legacy tunnel additional HTTP header mechanism + + name @0 :Text; + value @1 :Text; +} + +# === End DEPRECATED Objects === + struct ClientInfo @0x83ced0145b2f114b { # The tunnel client's unique identifier, used to verify a reconnection. clientId @0 :Data; @@ -136,16 +168,6 @@ interface RegistrationServer @0xf71695ec7fe85497 { updateLocalConfiguration @2 (config :Data) -> (); } -interface TunnelServer @0xea58385c65416035 extends (RegistrationServer) { - registerTunnel @0 (originCert :Data, hostname :Text, options :RegistrationOptions) -> (result :TunnelRegistration); - getServerInfo @1 () -> (result :ServerInfo); - unregisterTunnel @2 (gracePeriodNanoSec :Int64) -> (); - # obsoleteDeclarativeTunnelConnect RPC deprecated in TUN-3019 - obsoleteDeclarativeTunnelConnect @3 () -> (); - authenticate @4 (originCert :Data, hostname :Text, options :RegistrationOptions) -> (result :AuthenticateResponse); - reconnectTunnel @5 (jwt :Data, eventDigest :Data, connDigest :Data, hostname :Text, options :RegistrationOptions) -> (result :TunnelRegistration); -} - struct RegisterUdpSessionResponse @0xab6d5210c1f26687 { err @0 :Text; spans @1 :Data; diff --git a/tunnelrpc/proto/tunnelrpc.capnp.go b/tunnelrpc/proto/tunnelrpc.capnp.go index e6ab3ec9..e1fe98ad 100644 --- a/tunnelrpc/proto/tunnelrpc.capnp.go +++ b/tunnelrpc/proto/tunnelrpc.capnp.go @@ -568,95 +568,6 @@ func (p RegistrationOptions_Promise) Struct() (RegistrationOptions, error) { return RegistrationOptions{s}, err } -type Tag struct{ capnp.Struct } - -// Tag_TypeID is the unique identifier for the type Tag. -const Tag_TypeID = 0xcbd96442ae3bb01a - -func NewTag(s *capnp.Segment) (Tag, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) - return Tag{st}, err -} - -func NewRootTag(s *capnp.Segment) (Tag, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) - return Tag{st}, err -} - -func ReadRootTag(msg *capnp.Message) (Tag, error) { - root, err := msg.RootPtr() - return Tag{root.Struct()}, err -} - -func (s Tag) String() string { - str, _ := text.Marshal(0xcbd96442ae3bb01a, s.Struct) - return str -} - -func (s Tag) Name() (string, error) { - p, err := s.Struct.Ptr(0) - return p.Text(), err -} - -func (s Tag) HasName() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s Tag) NameBytes() ([]byte, error) { - p, err := s.Struct.Ptr(0) - return p.TextBytes(), err -} - -func (s Tag) SetName(v string) error { - return s.Struct.SetText(0, v) -} - -func (s Tag) Value() (string, error) { - p, err := s.Struct.Ptr(1) - return p.Text(), err -} - -func (s Tag) HasValue() bool { - p, err := s.Struct.Ptr(1) - return p.IsValid() || err != nil -} - -func (s Tag) ValueBytes() ([]byte, error) { - p, err := s.Struct.Ptr(1) - return p.TextBytes(), err -} - -func (s Tag) SetValue(v string) error { - return s.Struct.SetText(1, v) -} - -// Tag_List is a list of Tag. -type Tag_List struct{ capnp.List } - -// NewTag creates a new list of Tag. -func NewTag_List(s *capnp.Segment, sz int32) (Tag_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz) - return Tag_List{l}, err -} - -func (s Tag_List) At(i int) Tag { return Tag{s.List.Struct(i)} } - -func (s Tag_List) Set(i int, v Tag) error { return s.List.SetStruct(i, v.Struct) } - -func (s Tag_List) String() string { - str, _ := text.MarshalList(0xcbd96442ae3bb01a, s.List) - return str -} - -// Tag_Promise is a wrapper for a Tag promised by a client call. -type Tag_Promise struct{ *capnp.Pipeline } - -func (p Tag_Promise) Struct() (Tag, error) { - s, err := p.Pipeline.Struct() - return Tag{s}, err -} - type ExistingTunnelPolicy uint16 // ExistingTunnelPolicy_TypeID is the unique identifier for the type ExistingTunnelPolicy. @@ -902,1297 +813,6 @@ func (p AuthenticateResponse_Promise) Struct() (AuthenticateResponse, error) { return AuthenticateResponse{s}, err } -type ClientInfo struct{ capnp.Struct } - -// ClientInfo_TypeID is the unique identifier for the type ClientInfo. -const ClientInfo_TypeID = 0x83ced0145b2f114b - -func NewClientInfo(s *capnp.Segment) (ClientInfo, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 4}) - return ClientInfo{st}, err -} - -func NewRootClientInfo(s *capnp.Segment) (ClientInfo, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 4}) - return ClientInfo{st}, err -} - -func ReadRootClientInfo(msg *capnp.Message) (ClientInfo, error) { - root, err := msg.RootPtr() - return ClientInfo{root.Struct()}, err -} - -func (s ClientInfo) String() string { - str, _ := text.Marshal(0x83ced0145b2f114b, s.Struct) - return str -} - -func (s ClientInfo) ClientId() ([]byte, error) { - p, err := s.Struct.Ptr(0) - return []byte(p.Data()), err -} - -func (s ClientInfo) HasClientId() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s ClientInfo) SetClientId(v []byte) error { - return s.Struct.SetData(0, v) -} - -func (s ClientInfo) Features() (capnp.TextList, error) { - p, err := s.Struct.Ptr(1) - return capnp.TextList{List: p.List()}, err -} - -func (s ClientInfo) HasFeatures() bool { - p, err := s.Struct.Ptr(1) - return p.IsValid() || err != nil -} - -func (s ClientInfo) SetFeatures(v capnp.TextList) error { - return s.Struct.SetPtr(1, v.List.ToPtr()) -} - -// NewFeatures sets the features field to a newly -// allocated capnp.TextList, preferring placement in s's segment. -func (s ClientInfo) NewFeatures(n int32) (capnp.TextList, error) { - l, err := capnp.NewTextList(s.Struct.Segment(), n) - if err != nil { - return capnp.TextList{}, err - } - err = s.Struct.SetPtr(1, l.List.ToPtr()) - return l, err -} - -func (s ClientInfo) Version() (string, error) { - p, err := s.Struct.Ptr(2) - return p.Text(), err -} - -func (s ClientInfo) HasVersion() bool { - p, err := s.Struct.Ptr(2) - return p.IsValid() || err != nil -} - -func (s ClientInfo) VersionBytes() ([]byte, error) { - p, err := s.Struct.Ptr(2) - return p.TextBytes(), err -} - -func (s ClientInfo) SetVersion(v string) error { - return s.Struct.SetText(2, v) -} - -func (s ClientInfo) Arch() (string, error) { - p, err := s.Struct.Ptr(3) - return p.Text(), err -} - -func (s ClientInfo) HasArch() bool { - p, err := s.Struct.Ptr(3) - return p.IsValid() || err != nil -} - -func (s ClientInfo) ArchBytes() ([]byte, error) { - p, err := s.Struct.Ptr(3) - return p.TextBytes(), err -} - -func (s ClientInfo) SetArch(v string) error { - return s.Struct.SetText(3, v) -} - -// ClientInfo_List is a list of ClientInfo. -type ClientInfo_List struct{ capnp.List } - -// NewClientInfo creates a new list of ClientInfo. -func NewClientInfo_List(s *capnp.Segment, sz int32) (ClientInfo_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 4}, sz) - return ClientInfo_List{l}, err -} - -func (s ClientInfo_List) At(i int) ClientInfo { return ClientInfo{s.List.Struct(i)} } - -func (s ClientInfo_List) Set(i int, v ClientInfo) error { return s.List.SetStruct(i, v.Struct) } - -func (s ClientInfo_List) String() string { - str, _ := text.MarshalList(0x83ced0145b2f114b, s.List) - return str -} - -// ClientInfo_Promise is a wrapper for a ClientInfo promised by a client call. -type ClientInfo_Promise struct{ *capnp.Pipeline } - -func (p ClientInfo_Promise) Struct() (ClientInfo, error) { - s, err := p.Pipeline.Struct() - return ClientInfo{s}, err -} - -type ConnectionOptions struct{ capnp.Struct } - -// ConnectionOptions_TypeID is the unique identifier for the type ConnectionOptions. -const ConnectionOptions_TypeID = 0xb4bf9861fe035d04 - -func NewConnectionOptions(s *capnp.Segment) (ConnectionOptions, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}) - return ConnectionOptions{st}, err -} - -func NewRootConnectionOptions(s *capnp.Segment) (ConnectionOptions, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}) - return ConnectionOptions{st}, err -} - -func ReadRootConnectionOptions(msg *capnp.Message) (ConnectionOptions, error) { - root, err := msg.RootPtr() - return ConnectionOptions{root.Struct()}, err -} - -func (s ConnectionOptions) String() string { - str, _ := text.Marshal(0xb4bf9861fe035d04, s.Struct) - return str -} - -func (s ConnectionOptions) Client() (ClientInfo, error) { - p, err := s.Struct.Ptr(0) - return ClientInfo{Struct: p.Struct()}, err -} - -func (s ConnectionOptions) HasClient() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s ConnectionOptions) SetClient(v ClientInfo) error { - return s.Struct.SetPtr(0, v.Struct.ToPtr()) -} - -// NewClient sets the client field to a newly -// allocated ClientInfo struct, preferring placement in s's segment. -func (s ConnectionOptions) NewClient() (ClientInfo, error) { - ss, err := NewClientInfo(s.Struct.Segment()) - if err != nil { - return ClientInfo{}, err - } - err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) - return ss, err -} - -func (s ConnectionOptions) OriginLocalIp() ([]byte, error) { - p, err := s.Struct.Ptr(1) - return []byte(p.Data()), err -} - -func (s ConnectionOptions) HasOriginLocalIp() bool { - p, err := s.Struct.Ptr(1) - return p.IsValid() || err != nil -} - -func (s ConnectionOptions) SetOriginLocalIp(v []byte) error { - return s.Struct.SetData(1, v) -} - -func (s ConnectionOptions) ReplaceExisting() bool { - return s.Struct.Bit(0) -} - -func (s ConnectionOptions) SetReplaceExisting(v bool) { - s.Struct.SetBit(0, v) -} - -func (s ConnectionOptions) CompressionQuality() uint8 { - return s.Struct.Uint8(1) -} - -func (s ConnectionOptions) SetCompressionQuality(v uint8) { - s.Struct.SetUint8(1, v) -} - -func (s ConnectionOptions) NumPreviousAttempts() uint8 { - return s.Struct.Uint8(2) -} - -func (s ConnectionOptions) SetNumPreviousAttempts(v uint8) { - s.Struct.SetUint8(2, v) -} - -// ConnectionOptions_List is a list of ConnectionOptions. -type ConnectionOptions_List struct{ capnp.List } - -// NewConnectionOptions creates a new list of ConnectionOptions. -func NewConnectionOptions_List(s *capnp.Segment, sz int32) (ConnectionOptions_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}, sz) - return ConnectionOptions_List{l}, err -} - -func (s ConnectionOptions_List) At(i int) ConnectionOptions { - return ConnectionOptions{s.List.Struct(i)} -} - -func (s ConnectionOptions_List) Set(i int, v ConnectionOptions) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s ConnectionOptions_List) String() string { - str, _ := text.MarshalList(0xb4bf9861fe035d04, s.List) - return str -} - -// ConnectionOptions_Promise is a wrapper for a ConnectionOptions promised by a client call. -type ConnectionOptions_Promise struct{ *capnp.Pipeline } - -func (p ConnectionOptions_Promise) Struct() (ConnectionOptions, error) { - s, err := p.Pipeline.Struct() - return ConnectionOptions{s}, err -} - -func (p ConnectionOptions_Promise) Client() ClientInfo_Promise { - return ClientInfo_Promise{Pipeline: p.Pipeline.GetPipeline(0)} -} - -type ConnectionResponse struct{ capnp.Struct } -type ConnectionResponse_result ConnectionResponse -type ConnectionResponse_result_Which uint16 - -const ( - ConnectionResponse_result_Which_error ConnectionResponse_result_Which = 0 - ConnectionResponse_result_Which_connectionDetails ConnectionResponse_result_Which = 1 -) - -func (w ConnectionResponse_result_Which) String() string { - const s = "errorconnectionDetails" - switch w { - case ConnectionResponse_result_Which_error: - return s[0:5] - case ConnectionResponse_result_Which_connectionDetails: - return s[5:22] - - } - return "ConnectionResponse_result_Which(" + strconv.FormatUint(uint64(w), 10) + ")" -} - -// ConnectionResponse_TypeID is the unique identifier for the type ConnectionResponse. -const ConnectionResponse_TypeID = 0xdbaa9d03d52b62dc - -func NewConnectionResponse(s *capnp.Segment) (ConnectionResponse, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1}) - return ConnectionResponse{st}, err -} - -func NewRootConnectionResponse(s *capnp.Segment) (ConnectionResponse, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1}) - return ConnectionResponse{st}, err -} - -func ReadRootConnectionResponse(msg *capnp.Message) (ConnectionResponse, error) { - root, err := msg.RootPtr() - return ConnectionResponse{root.Struct()}, err -} - -func (s ConnectionResponse) String() string { - str, _ := text.Marshal(0xdbaa9d03d52b62dc, s.Struct) - return str -} - -func (s ConnectionResponse) Result() ConnectionResponse_result { return ConnectionResponse_result(s) } - -func (s ConnectionResponse_result) Which() ConnectionResponse_result_Which { - return ConnectionResponse_result_Which(s.Struct.Uint16(0)) -} -func (s ConnectionResponse_result) Error() (ConnectionError, error) { - if s.Struct.Uint16(0) != 0 { - panic("Which() != error") - } - p, err := s.Struct.Ptr(0) - return ConnectionError{Struct: p.Struct()}, err -} - -func (s ConnectionResponse_result) HasError() bool { - if s.Struct.Uint16(0) != 0 { - return false - } - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s ConnectionResponse_result) SetError(v ConnectionError) error { - s.Struct.SetUint16(0, 0) - return s.Struct.SetPtr(0, v.Struct.ToPtr()) -} - -// NewError sets the error field to a newly -// allocated ConnectionError struct, preferring placement in s's segment. -func (s ConnectionResponse_result) NewError() (ConnectionError, error) { - s.Struct.SetUint16(0, 0) - ss, err := NewConnectionError(s.Struct.Segment()) - if err != nil { - return ConnectionError{}, err - } - err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) - return ss, err -} - -func (s ConnectionResponse_result) ConnectionDetails() (ConnectionDetails, error) { - if s.Struct.Uint16(0) != 1 { - panic("Which() != connectionDetails") - } - p, err := s.Struct.Ptr(0) - return ConnectionDetails{Struct: p.Struct()}, err -} - -func (s ConnectionResponse_result) HasConnectionDetails() bool { - if s.Struct.Uint16(0) != 1 { - return false - } - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s ConnectionResponse_result) SetConnectionDetails(v ConnectionDetails) error { - s.Struct.SetUint16(0, 1) - return s.Struct.SetPtr(0, v.Struct.ToPtr()) -} - -// NewConnectionDetails sets the connectionDetails field to a newly -// allocated ConnectionDetails struct, preferring placement in s's segment. -func (s ConnectionResponse_result) NewConnectionDetails() (ConnectionDetails, error) { - s.Struct.SetUint16(0, 1) - ss, err := NewConnectionDetails(s.Struct.Segment()) - if err != nil { - return ConnectionDetails{}, err - } - err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) - return ss, err -} - -// ConnectionResponse_List is a list of ConnectionResponse. -type ConnectionResponse_List struct{ capnp.List } - -// NewConnectionResponse creates a new list of ConnectionResponse. -func NewConnectionResponse_List(s *capnp.Segment, sz int32) (ConnectionResponse_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1}, sz) - return ConnectionResponse_List{l}, err -} - -func (s ConnectionResponse_List) At(i int) ConnectionResponse { - return ConnectionResponse{s.List.Struct(i)} -} - -func (s ConnectionResponse_List) Set(i int, v ConnectionResponse) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s ConnectionResponse_List) String() string { - str, _ := text.MarshalList(0xdbaa9d03d52b62dc, s.List) - return str -} - -// ConnectionResponse_Promise is a wrapper for a ConnectionResponse promised by a client call. -type ConnectionResponse_Promise struct{ *capnp.Pipeline } - -func (p ConnectionResponse_Promise) Struct() (ConnectionResponse, error) { - s, err := p.Pipeline.Struct() - return ConnectionResponse{s}, err -} - -func (p ConnectionResponse_Promise) Result() ConnectionResponse_result_Promise { - return ConnectionResponse_result_Promise{p.Pipeline} -} - -// ConnectionResponse_result_Promise is a wrapper for a ConnectionResponse_result promised by a client call. -type ConnectionResponse_result_Promise struct{ *capnp.Pipeline } - -func (p ConnectionResponse_result_Promise) Struct() (ConnectionResponse_result, error) { - s, err := p.Pipeline.Struct() - return ConnectionResponse_result{s}, err -} - -func (p ConnectionResponse_result_Promise) Error() ConnectionError_Promise { - return ConnectionError_Promise{Pipeline: p.Pipeline.GetPipeline(0)} -} - -func (p ConnectionResponse_result_Promise) ConnectionDetails() ConnectionDetails_Promise { - return ConnectionDetails_Promise{Pipeline: p.Pipeline.GetPipeline(0)} -} - -type ConnectionError struct{ capnp.Struct } - -// ConnectionError_TypeID is the unique identifier for the type ConnectionError. -const ConnectionError_TypeID = 0xf5f383d2785edb86 - -func NewConnectionError(s *capnp.Segment) (ConnectionError, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1}) - return ConnectionError{st}, err -} - -func NewRootConnectionError(s *capnp.Segment) (ConnectionError, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1}) - return ConnectionError{st}, err -} - -func ReadRootConnectionError(msg *capnp.Message) (ConnectionError, error) { - root, err := msg.RootPtr() - return ConnectionError{root.Struct()}, err -} - -func (s ConnectionError) String() string { - str, _ := text.Marshal(0xf5f383d2785edb86, s.Struct) - return str -} - -func (s ConnectionError) Cause() (string, error) { - p, err := s.Struct.Ptr(0) - return p.Text(), err -} - -func (s ConnectionError) HasCause() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s ConnectionError) CauseBytes() ([]byte, error) { - p, err := s.Struct.Ptr(0) - return p.TextBytes(), err -} - -func (s ConnectionError) SetCause(v string) error { - return s.Struct.SetText(0, v) -} - -func (s ConnectionError) RetryAfter() int64 { - return int64(s.Struct.Uint64(0)) -} - -func (s ConnectionError) SetRetryAfter(v int64) { - s.Struct.SetUint64(0, uint64(v)) -} - -func (s ConnectionError) ShouldRetry() bool { - return s.Struct.Bit(64) -} - -func (s ConnectionError) SetShouldRetry(v bool) { - s.Struct.SetBit(64, v) -} - -// ConnectionError_List is a list of ConnectionError. -type ConnectionError_List struct{ capnp.List } - -// NewConnectionError creates a new list of ConnectionError. -func NewConnectionError_List(s *capnp.Segment, sz int32) (ConnectionError_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1}, sz) - return ConnectionError_List{l}, err -} - -func (s ConnectionError_List) At(i int) ConnectionError { return ConnectionError{s.List.Struct(i)} } - -func (s ConnectionError_List) Set(i int, v ConnectionError) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s ConnectionError_List) String() string { - str, _ := text.MarshalList(0xf5f383d2785edb86, s.List) - return str -} - -// ConnectionError_Promise is a wrapper for a ConnectionError promised by a client call. -type ConnectionError_Promise struct{ *capnp.Pipeline } - -func (p ConnectionError_Promise) Struct() (ConnectionError, error) { - s, err := p.Pipeline.Struct() - return ConnectionError{s}, err -} - -type ConnectionDetails struct{ capnp.Struct } - -// ConnectionDetails_TypeID is the unique identifier for the type ConnectionDetails. -const ConnectionDetails_TypeID = 0xb5f39f082b9ac18a - -func NewConnectionDetails(s *capnp.Segment) (ConnectionDetails, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}) - return ConnectionDetails{st}, err -} - -func NewRootConnectionDetails(s *capnp.Segment) (ConnectionDetails, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}) - return ConnectionDetails{st}, err -} - -func ReadRootConnectionDetails(msg *capnp.Message) (ConnectionDetails, error) { - root, err := msg.RootPtr() - return ConnectionDetails{root.Struct()}, err -} - -func (s ConnectionDetails) String() string { - str, _ := text.Marshal(0xb5f39f082b9ac18a, s.Struct) - return str -} - -func (s ConnectionDetails) Uuid() ([]byte, error) { - p, err := s.Struct.Ptr(0) - return []byte(p.Data()), err -} - -func (s ConnectionDetails) HasUuid() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s ConnectionDetails) SetUuid(v []byte) error { - return s.Struct.SetData(0, v) -} - -func (s ConnectionDetails) LocationName() (string, error) { - p, err := s.Struct.Ptr(1) - return p.Text(), err -} - -func (s ConnectionDetails) HasLocationName() bool { - p, err := s.Struct.Ptr(1) - return p.IsValid() || err != nil -} - -func (s ConnectionDetails) LocationNameBytes() ([]byte, error) { - p, err := s.Struct.Ptr(1) - return p.TextBytes(), err -} - -func (s ConnectionDetails) SetLocationName(v string) error { - return s.Struct.SetText(1, v) -} - -func (s ConnectionDetails) TunnelIsRemotelyManaged() bool { - return s.Struct.Bit(0) -} - -func (s ConnectionDetails) SetTunnelIsRemotelyManaged(v bool) { - s.Struct.SetBit(0, v) -} - -// ConnectionDetails_List is a list of ConnectionDetails. -type ConnectionDetails_List struct{ capnp.List } - -// NewConnectionDetails creates a new list of ConnectionDetails. -func NewConnectionDetails_List(s *capnp.Segment, sz int32) (ConnectionDetails_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}, sz) - return ConnectionDetails_List{l}, err -} - -func (s ConnectionDetails_List) At(i int) ConnectionDetails { - return ConnectionDetails{s.List.Struct(i)} -} - -func (s ConnectionDetails_List) Set(i int, v ConnectionDetails) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s ConnectionDetails_List) String() string { - str, _ := text.MarshalList(0xb5f39f082b9ac18a, s.List) - return str -} - -// ConnectionDetails_Promise is a wrapper for a ConnectionDetails promised by a client call. -type ConnectionDetails_Promise struct{ *capnp.Pipeline } - -func (p ConnectionDetails_Promise) Struct() (ConnectionDetails, error) { - s, err := p.Pipeline.Struct() - return ConnectionDetails{s}, err -} - -type TunnelAuth struct{ capnp.Struct } - -// TunnelAuth_TypeID is the unique identifier for the type TunnelAuth. -const TunnelAuth_TypeID = 0x9496331ab9cd463f - -func NewTunnelAuth(s *capnp.Segment) (TunnelAuth, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) - return TunnelAuth{st}, err -} - -func NewRootTunnelAuth(s *capnp.Segment) (TunnelAuth, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) - return TunnelAuth{st}, err -} - -func ReadRootTunnelAuth(msg *capnp.Message) (TunnelAuth, error) { - root, err := msg.RootPtr() - return TunnelAuth{root.Struct()}, err -} - -func (s TunnelAuth) String() string { - str, _ := text.Marshal(0x9496331ab9cd463f, s.Struct) - return str -} - -func (s TunnelAuth) AccountTag() (string, error) { - p, err := s.Struct.Ptr(0) - return p.Text(), err -} - -func (s TunnelAuth) HasAccountTag() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s TunnelAuth) AccountTagBytes() ([]byte, error) { - p, err := s.Struct.Ptr(0) - return p.TextBytes(), err -} - -func (s TunnelAuth) SetAccountTag(v string) error { - return s.Struct.SetText(0, v) -} - -func (s TunnelAuth) TunnelSecret() ([]byte, error) { - p, err := s.Struct.Ptr(1) - return []byte(p.Data()), err -} - -func (s TunnelAuth) HasTunnelSecret() bool { - p, err := s.Struct.Ptr(1) - return p.IsValid() || err != nil -} - -func (s TunnelAuth) SetTunnelSecret(v []byte) error { - return s.Struct.SetData(1, v) -} - -// TunnelAuth_List is a list of TunnelAuth. -type TunnelAuth_List struct{ capnp.List } - -// NewTunnelAuth creates a new list of TunnelAuth. -func NewTunnelAuth_List(s *capnp.Segment, sz int32) (TunnelAuth_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz) - return TunnelAuth_List{l}, err -} - -func (s TunnelAuth_List) At(i int) TunnelAuth { return TunnelAuth{s.List.Struct(i)} } - -func (s TunnelAuth_List) Set(i int, v TunnelAuth) error { return s.List.SetStruct(i, v.Struct) } - -func (s TunnelAuth_List) String() string { - str, _ := text.MarshalList(0x9496331ab9cd463f, s.List) - return str -} - -// TunnelAuth_Promise is a wrapper for a TunnelAuth promised by a client call. -type TunnelAuth_Promise struct{ *capnp.Pipeline } - -func (p TunnelAuth_Promise) Struct() (TunnelAuth, error) { - s, err := p.Pipeline.Struct() - return TunnelAuth{s}, err -} - -type RegistrationServer struct{ Client capnp.Client } - -// RegistrationServer_TypeID is the unique identifier for the type RegistrationServer. -const RegistrationServer_TypeID = 0xf71695ec7fe85497 - -func (c RegistrationServer) RegisterConnection(ctx context.Context, params func(RegistrationServer_registerConnection_Params) error, opts ...capnp.CallOption) RegistrationServer_registerConnection_Results_Promise { - if c.Client == nil { - return RegistrationServer_registerConnection_Results_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))} - } - call := &capnp.Call{ - Ctx: ctx, - Method: capnp.Method{ - InterfaceID: 0xf71695ec7fe85497, - MethodID: 0, - InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", - MethodName: "registerConnection", - }, - Options: capnp.NewCallOptions(opts), - } - if params != nil { - call.ParamsSize = capnp.ObjectSize{DataSize: 8, PointerCount: 3} - call.ParamsFunc = func(s capnp.Struct) error { return params(RegistrationServer_registerConnection_Params{Struct: s}) } - } - return RegistrationServer_registerConnection_Results_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))} -} -func (c RegistrationServer) UnregisterConnection(ctx context.Context, params func(RegistrationServer_unregisterConnection_Params) error, opts ...capnp.CallOption) RegistrationServer_unregisterConnection_Results_Promise { - if c.Client == nil { - return RegistrationServer_unregisterConnection_Results_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))} - } - call := &capnp.Call{ - Ctx: ctx, - Method: capnp.Method{ - InterfaceID: 0xf71695ec7fe85497, - MethodID: 1, - InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", - MethodName: "unregisterConnection", - }, - Options: capnp.NewCallOptions(opts), - } - if params != nil { - call.ParamsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 0} - call.ParamsFunc = func(s capnp.Struct) error { return params(RegistrationServer_unregisterConnection_Params{Struct: s}) } - } - return RegistrationServer_unregisterConnection_Results_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))} -} -func (c RegistrationServer) UpdateLocalConfiguration(ctx context.Context, params func(RegistrationServer_updateLocalConfiguration_Params) error, opts ...capnp.CallOption) RegistrationServer_updateLocalConfiguration_Results_Promise { - if c.Client == nil { - return RegistrationServer_updateLocalConfiguration_Results_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))} - } - call := &capnp.Call{ - Ctx: ctx, - Method: capnp.Method{ - InterfaceID: 0xf71695ec7fe85497, - MethodID: 2, - InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", - MethodName: "updateLocalConfiguration", - }, - Options: capnp.NewCallOptions(opts), - } - if params != nil { - call.ParamsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 1} - call.ParamsFunc = func(s capnp.Struct) error { - return params(RegistrationServer_updateLocalConfiguration_Params{Struct: s}) - } - } - return RegistrationServer_updateLocalConfiguration_Results_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))} -} - -type RegistrationServer_Server interface { - RegisterConnection(RegistrationServer_registerConnection) error - - UnregisterConnection(RegistrationServer_unregisterConnection) error - - UpdateLocalConfiguration(RegistrationServer_updateLocalConfiguration) error -} - -func RegistrationServer_ServerToClient(s RegistrationServer_Server) RegistrationServer { - c, _ := s.(server.Closer) - return RegistrationServer{Client: server.New(RegistrationServer_Methods(nil, s), c)} -} - -func RegistrationServer_Methods(methods []server.Method, s RegistrationServer_Server) []server.Method { - if cap(methods) == 0 { - methods = make([]server.Method, 0, 3) - } - - methods = append(methods, server.Method{ - Method: capnp.Method{ - InterfaceID: 0xf71695ec7fe85497, - MethodID: 0, - InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", - MethodName: "registerConnection", - }, - Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error { - call := RegistrationServer_registerConnection{c, opts, RegistrationServer_registerConnection_Params{Struct: p}, RegistrationServer_registerConnection_Results{Struct: r}} - return s.RegisterConnection(call) - }, - ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 1}, - }) - - methods = append(methods, server.Method{ - Method: capnp.Method{ - InterfaceID: 0xf71695ec7fe85497, - MethodID: 1, - InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", - MethodName: "unregisterConnection", - }, - Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error { - call := RegistrationServer_unregisterConnection{c, opts, RegistrationServer_unregisterConnection_Params{Struct: p}, RegistrationServer_unregisterConnection_Results{Struct: r}} - return s.UnregisterConnection(call) - }, - ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 0}, - }) - - methods = append(methods, server.Method{ - Method: capnp.Method{ - InterfaceID: 0xf71695ec7fe85497, - MethodID: 2, - InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", - MethodName: "updateLocalConfiguration", - }, - Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error { - call := RegistrationServer_updateLocalConfiguration{c, opts, RegistrationServer_updateLocalConfiguration_Params{Struct: p}, RegistrationServer_updateLocalConfiguration_Results{Struct: r}} - return s.UpdateLocalConfiguration(call) - }, - ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 0}, - }) - - return methods -} - -// RegistrationServer_registerConnection holds the arguments for a server call to RegistrationServer.registerConnection. -type RegistrationServer_registerConnection struct { - Ctx context.Context - Options capnp.CallOptions - Params RegistrationServer_registerConnection_Params - Results RegistrationServer_registerConnection_Results -} - -// RegistrationServer_unregisterConnection holds the arguments for a server call to RegistrationServer.unregisterConnection. -type RegistrationServer_unregisterConnection struct { - Ctx context.Context - Options capnp.CallOptions - Params RegistrationServer_unregisterConnection_Params - Results RegistrationServer_unregisterConnection_Results -} - -// RegistrationServer_updateLocalConfiguration holds the arguments for a server call to RegistrationServer.updateLocalConfiguration. -type RegistrationServer_updateLocalConfiguration struct { - Ctx context.Context - Options capnp.CallOptions - Params RegistrationServer_updateLocalConfiguration_Params - Results RegistrationServer_updateLocalConfiguration_Results -} - -type RegistrationServer_registerConnection_Params struct{ capnp.Struct } - -// RegistrationServer_registerConnection_Params_TypeID is the unique identifier for the type RegistrationServer_registerConnection_Params. -const RegistrationServer_registerConnection_Params_TypeID = 0xe6646dec8feaa6ee - -func NewRegistrationServer_registerConnection_Params(s *capnp.Segment) (RegistrationServer_registerConnection_Params, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 3}) - return RegistrationServer_registerConnection_Params{st}, err -} - -func NewRootRegistrationServer_registerConnection_Params(s *capnp.Segment) (RegistrationServer_registerConnection_Params, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 3}) - return RegistrationServer_registerConnection_Params{st}, err -} - -func ReadRootRegistrationServer_registerConnection_Params(msg *capnp.Message) (RegistrationServer_registerConnection_Params, error) { - root, err := msg.RootPtr() - return RegistrationServer_registerConnection_Params{root.Struct()}, err -} - -func (s RegistrationServer_registerConnection_Params) String() string { - str, _ := text.Marshal(0xe6646dec8feaa6ee, s.Struct) - return str -} - -func (s RegistrationServer_registerConnection_Params) Auth() (TunnelAuth, error) { - p, err := s.Struct.Ptr(0) - return TunnelAuth{Struct: p.Struct()}, err -} - -func (s RegistrationServer_registerConnection_Params) HasAuth() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s RegistrationServer_registerConnection_Params) SetAuth(v TunnelAuth) error { - return s.Struct.SetPtr(0, v.Struct.ToPtr()) -} - -// NewAuth sets the auth field to a newly -// allocated TunnelAuth struct, preferring placement in s's segment. -func (s RegistrationServer_registerConnection_Params) NewAuth() (TunnelAuth, error) { - ss, err := NewTunnelAuth(s.Struct.Segment()) - if err != nil { - return TunnelAuth{}, err - } - err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) - return ss, err -} - -func (s RegistrationServer_registerConnection_Params) TunnelId() ([]byte, error) { - p, err := s.Struct.Ptr(1) - return []byte(p.Data()), err -} - -func (s RegistrationServer_registerConnection_Params) HasTunnelId() bool { - p, err := s.Struct.Ptr(1) - return p.IsValid() || err != nil -} - -func (s RegistrationServer_registerConnection_Params) SetTunnelId(v []byte) error { - return s.Struct.SetData(1, v) -} - -func (s RegistrationServer_registerConnection_Params) ConnIndex() uint8 { - return s.Struct.Uint8(0) -} - -func (s RegistrationServer_registerConnection_Params) SetConnIndex(v uint8) { - s.Struct.SetUint8(0, v) -} - -func (s RegistrationServer_registerConnection_Params) Options() (ConnectionOptions, error) { - p, err := s.Struct.Ptr(2) - return ConnectionOptions{Struct: p.Struct()}, err -} - -func (s RegistrationServer_registerConnection_Params) HasOptions() bool { - p, err := s.Struct.Ptr(2) - return p.IsValid() || err != nil -} - -func (s RegistrationServer_registerConnection_Params) SetOptions(v ConnectionOptions) error { - return s.Struct.SetPtr(2, v.Struct.ToPtr()) -} - -// NewOptions sets the options field to a newly -// allocated ConnectionOptions struct, preferring placement in s's segment. -func (s RegistrationServer_registerConnection_Params) NewOptions() (ConnectionOptions, error) { - ss, err := NewConnectionOptions(s.Struct.Segment()) - if err != nil { - return ConnectionOptions{}, err - } - err = s.Struct.SetPtr(2, ss.Struct.ToPtr()) - return ss, err -} - -// RegistrationServer_registerConnection_Params_List is a list of RegistrationServer_registerConnection_Params. -type RegistrationServer_registerConnection_Params_List struct{ capnp.List } - -// NewRegistrationServer_registerConnection_Params creates a new list of RegistrationServer_registerConnection_Params. -func NewRegistrationServer_registerConnection_Params_List(s *capnp.Segment, sz int32) (RegistrationServer_registerConnection_Params_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 3}, sz) - return RegistrationServer_registerConnection_Params_List{l}, err -} - -func (s RegistrationServer_registerConnection_Params_List) At(i int) RegistrationServer_registerConnection_Params { - return RegistrationServer_registerConnection_Params{s.List.Struct(i)} -} - -func (s RegistrationServer_registerConnection_Params_List) Set(i int, v RegistrationServer_registerConnection_Params) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s RegistrationServer_registerConnection_Params_List) String() string { - str, _ := text.MarshalList(0xe6646dec8feaa6ee, s.List) - return str -} - -// RegistrationServer_registerConnection_Params_Promise is a wrapper for a RegistrationServer_registerConnection_Params promised by a client call. -type RegistrationServer_registerConnection_Params_Promise struct{ *capnp.Pipeline } - -func (p RegistrationServer_registerConnection_Params_Promise) Struct() (RegistrationServer_registerConnection_Params, error) { - s, err := p.Pipeline.Struct() - return RegistrationServer_registerConnection_Params{s}, err -} - -func (p RegistrationServer_registerConnection_Params_Promise) Auth() TunnelAuth_Promise { - return TunnelAuth_Promise{Pipeline: p.Pipeline.GetPipeline(0)} -} - -func (p RegistrationServer_registerConnection_Params_Promise) Options() ConnectionOptions_Promise { - return ConnectionOptions_Promise{Pipeline: p.Pipeline.GetPipeline(2)} -} - -type RegistrationServer_registerConnection_Results struct{ capnp.Struct } - -// RegistrationServer_registerConnection_Results_TypeID is the unique identifier for the type RegistrationServer_registerConnection_Results. -const RegistrationServer_registerConnection_Results_TypeID = 0xea50d822450d1f17 - -func NewRegistrationServer_registerConnection_Results(s *capnp.Segment) (RegistrationServer_registerConnection_Results, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return RegistrationServer_registerConnection_Results{st}, err -} - -func NewRootRegistrationServer_registerConnection_Results(s *capnp.Segment) (RegistrationServer_registerConnection_Results, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return RegistrationServer_registerConnection_Results{st}, err -} - -func ReadRootRegistrationServer_registerConnection_Results(msg *capnp.Message) (RegistrationServer_registerConnection_Results, error) { - root, err := msg.RootPtr() - return RegistrationServer_registerConnection_Results{root.Struct()}, err -} - -func (s RegistrationServer_registerConnection_Results) String() string { - str, _ := text.Marshal(0xea50d822450d1f17, s.Struct) - return str -} - -func (s RegistrationServer_registerConnection_Results) Result() (ConnectionResponse, error) { - p, err := s.Struct.Ptr(0) - return ConnectionResponse{Struct: p.Struct()}, err -} - -func (s RegistrationServer_registerConnection_Results) HasResult() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s RegistrationServer_registerConnection_Results) SetResult(v ConnectionResponse) error { - return s.Struct.SetPtr(0, v.Struct.ToPtr()) -} - -// NewResult sets the result field to a newly -// allocated ConnectionResponse struct, preferring placement in s's segment. -func (s RegistrationServer_registerConnection_Results) NewResult() (ConnectionResponse, error) { - ss, err := NewConnectionResponse(s.Struct.Segment()) - if err != nil { - return ConnectionResponse{}, err - } - err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) - return ss, err -} - -// RegistrationServer_registerConnection_Results_List is a list of RegistrationServer_registerConnection_Results. -type RegistrationServer_registerConnection_Results_List struct{ capnp.List } - -// NewRegistrationServer_registerConnection_Results creates a new list of RegistrationServer_registerConnection_Results. -func NewRegistrationServer_registerConnection_Results_List(s *capnp.Segment, sz int32) (RegistrationServer_registerConnection_Results_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz) - return RegistrationServer_registerConnection_Results_List{l}, err -} - -func (s RegistrationServer_registerConnection_Results_List) At(i int) RegistrationServer_registerConnection_Results { - return RegistrationServer_registerConnection_Results{s.List.Struct(i)} -} - -func (s RegistrationServer_registerConnection_Results_List) Set(i int, v RegistrationServer_registerConnection_Results) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s RegistrationServer_registerConnection_Results_List) String() string { - str, _ := text.MarshalList(0xea50d822450d1f17, s.List) - return str -} - -// RegistrationServer_registerConnection_Results_Promise is a wrapper for a RegistrationServer_registerConnection_Results promised by a client call. -type RegistrationServer_registerConnection_Results_Promise struct{ *capnp.Pipeline } - -func (p RegistrationServer_registerConnection_Results_Promise) Struct() (RegistrationServer_registerConnection_Results, error) { - s, err := p.Pipeline.Struct() - return RegistrationServer_registerConnection_Results{s}, err -} - -func (p RegistrationServer_registerConnection_Results_Promise) Result() ConnectionResponse_Promise { - return ConnectionResponse_Promise{Pipeline: p.Pipeline.GetPipeline(0)} -} - -type RegistrationServer_unregisterConnection_Params struct{ capnp.Struct } - -// RegistrationServer_unregisterConnection_Params_TypeID is the unique identifier for the type RegistrationServer_unregisterConnection_Params. -const RegistrationServer_unregisterConnection_Params_TypeID = 0xf9cb7f4431a307d0 - -func NewRegistrationServer_unregisterConnection_Params(s *capnp.Segment) (RegistrationServer_unregisterConnection_Params, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return RegistrationServer_unregisterConnection_Params{st}, err -} - -func NewRootRegistrationServer_unregisterConnection_Params(s *capnp.Segment) (RegistrationServer_unregisterConnection_Params, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return RegistrationServer_unregisterConnection_Params{st}, err -} - -func ReadRootRegistrationServer_unregisterConnection_Params(msg *capnp.Message) (RegistrationServer_unregisterConnection_Params, error) { - root, err := msg.RootPtr() - return RegistrationServer_unregisterConnection_Params{root.Struct()}, err -} - -func (s RegistrationServer_unregisterConnection_Params) String() string { - str, _ := text.Marshal(0xf9cb7f4431a307d0, s.Struct) - return str -} - -// RegistrationServer_unregisterConnection_Params_List is a list of RegistrationServer_unregisterConnection_Params. -type RegistrationServer_unregisterConnection_Params_List struct{ capnp.List } - -// NewRegistrationServer_unregisterConnection_Params creates a new list of RegistrationServer_unregisterConnection_Params. -func NewRegistrationServer_unregisterConnection_Params_List(s *capnp.Segment, sz int32) (RegistrationServer_unregisterConnection_Params_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return RegistrationServer_unregisterConnection_Params_List{l}, err -} - -func (s RegistrationServer_unregisterConnection_Params_List) At(i int) RegistrationServer_unregisterConnection_Params { - return RegistrationServer_unregisterConnection_Params{s.List.Struct(i)} -} - -func (s RegistrationServer_unregisterConnection_Params_List) Set(i int, v RegistrationServer_unregisterConnection_Params) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s RegistrationServer_unregisterConnection_Params_List) String() string { - str, _ := text.MarshalList(0xf9cb7f4431a307d0, s.List) - return str -} - -// RegistrationServer_unregisterConnection_Params_Promise is a wrapper for a RegistrationServer_unregisterConnection_Params promised by a client call. -type RegistrationServer_unregisterConnection_Params_Promise struct{ *capnp.Pipeline } - -func (p RegistrationServer_unregisterConnection_Params_Promise) Struct() (RegistrationServer_unregisterConnection_Params, error) { - s, err := p.Pipeline.Struct() - return RegistrationServer_unregisterConnection_Params{s}, err -} - -type RegistrationServer_unregisterConnection_Results struct{ capnp.Struct } - -// RegistrationServer_unregisterConnection_Results_TypeID is the unique identifier for the type RegistrationServer_unregisterConnection_Results. -const RegistrationServer_unregisterConnection_Results_TypeID = 0xb046e578094b1ead - -func NewRegistrationServer_unregisterConnection_Results(s *capnp.Segment) (RegistrationServer_unregisterConnection_Results, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return RegistrationServer_unregisterConnection_Results{st}, err -} - -func NewRootRegistrationServer_unregisterConnection_Results(s *capnp.Segment) (RegistrationServer_unregisterConnection_Results, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return RegistrationServer_unregisterConnection_Results{st}, err -} - -func ReadRootRegistrationServer_unregisterConnection_Results(msg *capnp.Message) (RegistrationServer_unregisterConnection_Results, error) { - root, err := msg.RootPtr() - return RegistrationServer_unregisterConnection_Results{root.Struct()}, err -} - -func (s RegistrationServer_unregisterConnection_Results) String() string { - str, _ := text.Marshal(0xb046e578094b1ead, s.Struct) - return str -} - -// RegistrationServer_unregisterConnection_Results_List is a list of RegistrationServer_unregisterConnection_Results. -type RegistrationServer_unregisterConnection_Results_List struct{ capnp.List } - -// NewRegistrationServer_unregisterConnection_Results creates a new list of RegistrationServer_unregisterConnection_Results. -func NewRegistrationServer_unregisterConnection_Results_List(s *capnp.Segment, sz int32) (RegistrationServer_unregisterConnection_Results_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return RegistrationServer_unregisterConnection_Results_List{l}, err -} - -func (s RegistrationServer_unregisterConnection_Results_List) At(i int) RegistrationServer_unregisterConnection_Results { - return RegistrationServer_unregisterConnection_Results{s.List.Struct(i)} -} - -func (s RegistrationServer_unregisterConnection_Results_List) Set(i int, v RegistrationServer_unregisterConnection_Results) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s RegistrationServer_unregisterConnection_Results_List) String() string { - str, _ := text.MarshalList(0xb046e578094b1ead, s.List) - return str -} - -// RegistrationServer_unregisterConnection_Results_Promise is a wrapper for a RegistrationServer_unregisterConnection_Results promised by a client call. -type RegistrationServer_unregisterConnection_Results_Promise struct{ *capnp.Pipeline } - -func (p RegistrationServer_unregisterConnection_Results_Promise) Struct() (RegistrationServer_unregisterConnection_Results, error) { - s, err := p.Pipeline.Struct() - return RegistrationServer_unregisterConnection_Results{s}, err -} - -type RegistrationServer_updateLocalConfiguration_Params struct{ capnp.Struct } - -// RegistrationServer_updateLocalConfiguration_Params_TypeID is the unique identifier for the type RegistrationServer_updateLocalConfiguration_Params. -const RegistrationServer_updateLocalConfiguration_Params_TypeID = 0xc5d6e311876a3604 - -func NewRegistrationServer_updateLocalConfiguration_Params(s *capnp.Segment) (RegistrationServer_updateLocalConfiguration_Params, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return RegistrationServer_updateLocalConfiguration_Params{st}, err -} - -func NewRootRegistrationServer_updateLocalConfiguration_Params(s *capnp.Segment) (RegistrationServer_updateLocalConfiguration_Params, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return RegistrationServer_updateLocalConfiguration_Params{st}, err -} - -func ReadRootRegistrationServer_updateLocalConfiguration_Params(msg *capnp.Message) (RegistrationServer_updateLocalConfiguration_Params, error) { - root, err := msg.RootPtr() - return RegistrationServer_updateLocalConfiguration_Params{root.Struct()}, err -} - -func (s RegistrationServer_updateLocalConfiguration_Params) String() string { - str, _ := text.Marshal(0xc5d6e311876a3604, s.Struct) - return str -} - -func (s RegistrationServer_updateLocalConfiguration_Params) Config() ([]byte, error) { - p, err := s.Struct.Ptr(0) - return []byte(p.Data()), err -} - -func (s RegistrationServer_updateLocalConfiguration_Params) HasConfig() bool { - p, err := s.Struct.Ptr(0) - return p.IsValid() || err != nil -} - -func (s RegistrationServer_updateLocalConfiguration_Params) SetConfig(v []byte) error { - return s.Struct.SetData(0, v) -} - -// RegistrationServer_updateLocalConfiguration_Params_List is a list of RegistrationServer_updateLocalConfiguration_Params. -type RegistrationServer_updateLocalConfiguration_Params_List struct{ capnp.List } - -// NewRegistrationServer_updateLocalConfiguration_Params creates a new list of RegistrationServer_updateLocalConfiguration_Params. -func NewRegistrationServer_updateLocalConfiguration_Params_List(s *capnp.Segment, sz int32) (RegistrationServer_updateLocalConfiguration_Params_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz) - return RegistrationServer_updateLocalConfiguration_Params_List{l}, err -} - -func (s RegistrationServer_updateLocalConfiguration_Params_List) At(i int) RegistrationServer_updateLocalConfiguration_Params { - return RegistrationServer_updateLocalConfiguration_Params{s.List.Struct(i)} -} - -func (s RegistrationServer_updateLocalConfiguration_Params_List) Set(i int, v RegistrationServer_updateLocalConfiguration_Params) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s RegistrationServer_updateLocalConfiguration_Params_List) String() string { - str, _ := text.MarshalList(0xc5d6e311876a3604, s.List) - return str -} - -// RegistrationServer_updateLocalConfiguration_Params_Promise is a wrapper for a RegistrationServer_updateLocalConfiguration_Params promised by a client call. -type RegistrationServer_updateLocalConfiguration_Params_Promise struct{ *capnp.Pipeline } - -func (p RegistrationServer_updateLocalConfiguration_Params_Promise) Struct() (RegistrationServer_updateLocalConfiguration_Params, error) { - s, err := p.Pipeline.Struct() - return RegistrationServer_updateLocalConfiguration_Params{s}, err -} - -type RegistrationServer_updateLocalConfiguration_Results struct{ capnp.Struct } - -// RegistrationServer_updateLocalConfiguration_Results_TypeID is the unique identifier for the type RegistrationServer_updateLocalConfiguration_Results. -const RegistrationServer_updateLocalConfiguration_Results_TypeID = 0xe5ceae5d6897d7be - -func NewRegistrationServer_updateLocalConfiguration_Results(s *capnp.Segment) (RegistrationServer_updateLocalConfiguration_Results, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return RegistrationServer_updateLocalConfiguration_Results{st}, err -} - -func NewRootRegistrationServer_updateLocalConfiguration_Results(s *capnp.Segment) (RegistrationServer_updateLocalConfiguration_Results, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return RegistrationServer_updateLocalConfiguration_Results{st}, err -} - -func ReadRootRegistrationServer_updateLocalConfiguration_Results(msg *capnp.Message) (RegistrationServer_updateLocalConfiguration_Results, error) { - root, err := msg.RootPtr() - return RegistrationServer_updateLocalConfiguration_Results{root.Struct()}, err -} - -func (s RegistrationServer_updateLocalConfiguration_Results) String() string { - str, _ := text.Marshal(0xe5ceae5d6897d7be, s.Struct) - return str -} - -// RegistrationServer_updateLocalConfiguration_Results_List is a list of RegistrationServer_updateLocalConfiguration_Results. -type RegistrationServer_updateLocalConfiguration_Results_List struct{ capnp.List } - -// NewRegistrationServer_updateLocalConfiguration_Results creates a new list of RegistrationServer_updateLocalConfiguration_Results. -func NewRegistrationServer_updateLocalConfiguration_Results_List(s *capnp.Segment, sz int32) (RegistrationServer_updateLocalConfiguration_Results_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return RegistrationServer_updateLocalConfiguration_Results_List{l}, err -} - -func (s RegistrationServer_updateLocalConfiguration_Results_List) At(i int) RegistrationServer_updateLocalConfiguration_Results { - return RegistrationServer_updateLocalConfiguration_Results{s.List.Struct(i)} -} - -func (s RegistrationServer_updateLocalConfiguration_Results_List) Set(i int, v RegistrationServer_updateLocalConfiguration_Results) error { - return s.List.SetStruct(i, v.Struct) -} - -func (s RegistrationServer_updateLocalConfiguration_Results_List) String() string { - str, _ := text.MarshalList(0xe5ceae5d6897d7be, s.List) - return str -} - -// RegistrationServer_updateLocalConfiguration_Results_Promise is a wrapper for a RegistrationServer_updateLocalConfiguration_Results promised by a client call. -type RegistrationServer_updateLocalConfiguration_Results_Promise struct{ *capnp.Pipeline } - -func (p RegistrationServer_updateLocalConfiguration_Results_Promise) Struct() (RegistrationServer_updateLocalConfiguration_Results, error) { - s, err := p.Pipeline.Struct() - return RegistrationServer_updateLocalConfiguration_Results{s}, err -} - type TunnelServer struct{ Client capnp.Client } // TunnelServer_TypeID is the unique identifier for the type TunnelServer. @@ -3588,6 +2208,1386 @@ func (p TunnelServer_reconnectTunnel_Results_Promise) Result() TunnelRegistratio return TunnelRegistration_Promise{Pipeline: p.Pipeline.GetPipeline(0)} } +type Tag struct{ capnp.Struct } + +// Tag_TypeID is the unique identifier for the type Tag. +const Tag_TypeID = 0xcbd96442ae3bb01a + +func NewTag(s *capnp.Segment) (Tag, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) + return Tag{st}, err +} + +func NewRootTag(s *capnp.Segment) (Tag, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) + return Tag{st}, err +} + +func ReadRootTag(msg *capnp.Message) (Tag, error) { + root, err := msg.RootPtr() + return Tag{root.Struct()}, err +} + +func (s Tag) String() string { + str, _ := text.Marshal(0xcbd96442ae3bb01a, s.Struct) + return str +} + +func (s Tag) Name() (string, error) { + p, err := s.Struct.Ptr(0) + return p.Text(), err +} + +func (s Tag) HasName() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s Tag) NameBytes() ([]byte, error) { + p, err := s.Struct.Ptr(0) + return p.TextBytes(), err +} + +func (s Tag) SetName(v string) error { + return s.Struct.SetText(0, v) +} + +func (s Tag) Value() (string, error) { + p, err := s.Struct.Ptr(1) + return p.Text(), err +} + +func (s Tag) HasValue() bool { + p, err := s.Struct.Ptr(1) + return p.IsValid() || err != nil +} + +func (s Tag) ValueBytes() ([]byte, error) { + p, err := s.Struct.Ptr(1) + return p.TextBytes(), err +} + +func (s Tag) SetValue(v string) error { + return s.Struct.SetText(1, v) +} + +// Tag_List is a list of Tag. +type Tag_List struct{ capnp.List } + +// NewTag creates a new list of Tag. +func NewTag_List(s *capnp.Segment, sz int32) (Tag_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz) + return Tag_List{l}, err +} + +func (s Tag_List) At(i int) Tag { return Tag{s.List.Struct(i)} } + +func (s Tag_List) Set(i int, v Tag) error { return s.List.SetStruct(i, v.Struct) } + +func (s Tag_List) String() string { + str, _ := text.MarshalList(0xcbd96442ae3bb01a, s.List) + return str +} + +// Tag_Promise is a wrapper for a Tag promised by a client call. +type Tag_Promise struct{ *capnp.Pipeline } + +func (p Tag_Promise) Struct() (Tag, error) { + s, err := p.Pipeline.Struct() + return Tag{s}, err +} + +type ClientInfo struct{ capnp.Struct } + +// ClientInfo_TypeID is the unique identifier for the type ClientInfo. +const ClientInfo_TypeID = 0x83ced0145b2f114b + +func NewClientInfo(s *capnp.Segment) (ClientInfo, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 4}) + return ClientInfo{st}, err +} + +func NewRootClientInfo(s *capnp.Segment) (ClientInfo, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 4}) + return ClientInfo{st}, err +} + +func ReadRootClientInfo(msg *capnp.Message) (ClientInfo, error) { + root, err := msg.RootPtr() + return ClientInfo{root.Struct()}, err +} + +func (s ClientInfo) String() string { + str, _ := text.Marshal(0x83ced0145b2f114b, s.Struct) + return str +} + +func (s ClientInfo) ClientId() ([]byte, error) { + p, err := s.Struct.Ptr(0) + return []byte(p.Data()), err +} + +func (s ClientInfo) HasClientId() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s ClientInfo) SetClientId(v []byte) error { + return s.Struct.SetData(0, v) +} + +func (s ClientInfo) Features() (capnp.TextList, error) { + p, err := s.Struct.Ptr(1) + return capnp.TextList{List: p.List()}, err +} + +func (s ClientInfo) HasFeatures() bool { + p, err := s.Struct.Ptr(1) + return p.IsValid() || err != nil +} + +func (s ClientInfo) SetFeatures(v capnp.TextList) error { + return s.Struct.SetPtr(1, v.List.ToPtr()) +} + +// NewFeatures sets the features field to a newly +// allocated capnp.TextList, preferring placement in s's segment. +func (s ClientInfo) NewFeatures(n int32) (capnp.TextList, error) { + l, err := capnp.NewTextList(s.Struct.Segment(), n) + if err != nil { + return capnp.TextList{}, err + } + err = s.Struct.SetPtr(1, l.List.ToPtr()) + return l, err +} + +func (s ClientInfo) Version() (string, error) { + p, err := s.Struct.Ptr(2) + return p.Text(), err +} + +func (s ClientInfo) HasVersion() bool { + p, err := s.Struct.Ptr(2) + return p.IsValid() || err != nil +} + +func (s ClientInfo) VersionBytes() ([]byte, error) { + p, err := s.Struct.Ptr(2) + return p.TextBytes(), err +} + +func (s ClientInfo) SetVersion(v string) error { + return s.Struct.SetText(2, v) +} + +func (s ClientInfo) Arch() (string, error) { + p, err := s.Struct.Ptr(3) + return p.Text(), err +} + +func (s ClientInfo) HasArch() bool { + p, err := s.Struct.Ptr(3) + return p.IsValid() || err != nil +} + +func (s ClientInfo) ArchBytes() ([]byte, error) { + p, err := s.Struct.Ptr(3) + return p.TextBytes(), err +} + +func (s ClientInfo) SetArch(v string) error { + return s.Struct.SetText(3, v) +} + +// ClientInfo_List is a list of ClientInfo. +type ClientInfo_List struct{ capnp.List } + +// NewClientInfo creates a new list of ClientInfo. +func NewClientInfo_List(s *capnp.Segment, sz int32) (ClientInfo_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 4}, sz) + return ClientInfo_List{l}, err +} + +func (s ClientInfo_List) At(i int) ClientInfo { return ClientInfo{s.List.Struct(i)} } + +func (s ClientInfo_List) Set(i int, v ClientInfo) error { return s.List.SetStruct(i, v.Struct) } + +func (s ClientInfo_List) String() string { + str, _ := text.MarshalList(0x83ced0145b2f114b, s.List) + return str +} + +// ClientInfo_Promise is a wrapper for a ClientInfo promised by a client call. +type ClientInfo_Promise struct{ *capnp.Pipeline } + +func (p ClientInfo_Promise) Struct() (ClientInfo, error) { + s, err := p.Pipeline.Struct() + return ClientInfo{s}, err +} + +type ConnectionOptions struct{ capnp.Struct } + +// ConnectionOptions_TypeID is the unique identifier for the type ConnectionOptions. +const ConnectionOptions_TypeID = 0xb4bf9861fe035d04 + +func NewConnectionOptions(s *capnp.Segment) (ConnectionOptions, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}) + return ConnectionOptions{st}, err +} + +func NewRootConnectionOptions(s *capnp.Segment) (ConnectionOptions, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}) + return ConnectionOptions{st}, err +} + +func ReadRootConnectionOptions(msg *capnp.Message) (ConnectionOptions, error) { + root, err := msg.RootPtr() + return ConnectionOptions{root.Struct()}, err +} + +func (s ConnectionOptions) String() string { + str, _ := text.Marshal(0xb4bf9861fe035d04, s.Struct) + return str +} + +func (s ConnectionOptions) Client() (ClientInfo, error) { + p, err := s.Struct.Ptr(0) + return ClientInfo{Struct: p.Struct()}, err +} + +func (s ConnectionOptions) HasClient() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s ConnectionOptions) SetClient(v ClientInfo) error { + return s.Struct.SetPtr(0, v.Struct.ToPtr()) +} + +// NewClient sets the client field to a newly +// allocated ClientInfo struct, preferring placement in s's segment. +func (s ConnectionOptions) NewClient() (ClientInfo, error) { + ss, err := NewClientInfo(s.Struct.Segment()) + if err != nil { + return ClientInfo{}, err + } + err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) + return ss, err +} + +func (s ConnectionOptions) OriginLocalIp() ([]byte, error) { + p, err := s.Struct.Ptr(1) + return []byte(p.Data()), err +} + +func (s ConnectionOptions) HasOriginLocalIp() bool { + p, err := s.Struct.Ptr(1) + return p.IsValid() || err != nil +} + +func (s ConnectionOptions) SetOriginLocalIp(v []byte) error { + return s.Struct.SetData(1, v) +} + +func (s ConnectionOptions) ReplaceExisting() bool { + return s.Struct.Bit(0) +} + +func (s ConnectionOptions) SetReplaceExisting(v bool) { + s.Struct.SetBit(0, v) +} + +func (s ConnectionOptions) CompressionQuality() uint8 { + return s.Struct.Uint8(1) +} + +func (s ConnectionOptions) SetCompressionQuality(v uint8) { + s.Struct.SetUint8(1, v) +} + +func (s ConnectionOptions) NumPreviousAttempts() uint8 { + return s.Struct.Uint8(2) +} + +func (s ConnectionOptions) SetNumPreviousAttempts(v uint8) { + s.Struct.SetUint8(2, v) +} + +// ConnectionOptions_List is a list of ConnectionOptions. +type ConnectionOptions_List struct{ capnp.List } + +// NewConnectionOptions creates a new list of ConnectionOptions. +func NewConnectionOptions_List(s *capnp.Segment, sz int32) (ConnectionOptions_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}, sz) + return ConnectionOptions_List{l}, err +} + +func (s ConnectionOptions_List) At(i int) ConnectionOptions { + return ConnectionOptions{s.List.Struct(i)} +} + +func (s ConnectionOptions_List) Set(i int, v ConnectionOptions) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s ConnectionOptions_List) String() string { + str, _ := text.MarshalList(0xb4bf9861fe035d04, s.List) + return str +} + +// ConnectionOptions_Promise is a wrapper for a ConnectionOptions promised by a client call. +type ConnectionOptions_Promise struct{ *capnp.Pipeline } + +func (p ConnectionOptions_Promise) Struct() (ConnectionOptions, error) { + s, err := p.Pipeline.Struct() + return ConnectionOptions{s}, err +} + +func (p ConnectionOptions_Promise) Client() ClientInfo_Promise { + return ClientInfo_Promise{Pipeline: p.Pipeline.GetPipeline(0)} +} + +type ConnectionResponse struct{ capnp.Struct } +type ConnectionResponse_result ConnectionResponse +type ConnectionResponse_result_Which uint16 + +const ( + ConnectionResponse_result_Which_error ConnectionResponse_result_Which = 0 + ConnectionResponse_result_Which_connectionDetails ConnectionResponse_result_Which = 1 +) + +func (w ConnectionResponse_result_Which) String() string { + const s = "errorconnectionDetails" + switch w { + case ConnectionResponse_result_Which_error: + return s[0:5] + case ConnectionResponse_result_Which_connectionDetails: + return s[5:22] + + } + return "ConnectionResponse_result_Which(" + strconv.FormatUint(uint64(w), 10) + ")" +} + +// ConnectionResponse_TypeID is the unique identifier for the type ConnectionResponse. +const ConnectionResponse_TypeID = 0xdbaa9d03d52b62dc + +func NewConnectionResponse(s *capnp.Segment) (ConnectionResponse, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1}) + return ConnectionResponse{st}, err +} + +func NewRootConnectionResponse(s *capnp.Segment) (ConnectionResponse, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1}) + return ConnectionResponse{st}, err +} + +func ReadRootConnectionResponse(msg *capnp.Message) (ConnectionResponse, error) { + root, err := msg.RootPtr() + return ConnectionResponse{root.Struct()}, err +} + +func (s ConnectionResponse) String() string { + str, _ := text.Marshal(0xdbaa9d03d52b62dc, s.Struct) + return str +} + +func (s ConnectionResponse) Result() ConnectionResponse_result { return ConnectionResponse_result(s) } + +func (s ConnectionResponse_result) Which() ConnectionResponse_result_Which { + return ConnectionResponse_result_Which(s.Struct.Uint16(0)) +} +func (s ConnectionResponse_result) Error() (ConnectionError, error) { + if s.Struct.Uint16(0) != 0 { + panic("Which() != error") + } + p, err := s.Struct.Ptr(0) + return ConnectionError{Struct: p.Struct()}, err +} + +func (s ConnectionResponse_result) HasError() bool { + if s.Struct.Uint16(0) != 0 { + return false + } + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s ConnectionResponse_result) SetError(v ConnectionError) error { + s.Struct.SetUint16(0, 0) + return s.Struct.SetPtr(0, v.Struct.ToPtr()) +} + +// NewError sets the error field to a newly +// allocated ConnectionError struct, preferring placement in s's segment. +func (s ConnectionResponse_result) NewError() (ConnectionError, error) { + s.Struct.SetUint16(0, 0) + ss, err := NewConnectionError(s.Struct.Segment()) + if err != nil { + return ConnectionError{}, err + } + err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) + return ss, err +} + +func (s ConnectionResponse_result) ConnectionDetails() (ConnectionDetails, error) { + if s.Struct.Uint16(0) != 1 { + panic("Which() != connectionDetails") + } + p, err := s.Struct.Ptr(0) + return ConnectionDetails{Struct: p.Struct()}, err +} + +func (s ConnectionResponse_result) HasConnectionDetails() bool { + if s.Struct.Uint16(0) != 1 { + return false + } + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s ConnectionResponse_result) SetConnectionDetails(v ConnectionDetails) error { + s.Struct.SetUint16(0, 1) + return s.Struct.SetPtr(0, v.Struct.ToPtr()) +} + +// NewConnectionDetails sets the connectionDetails field to a newly +// allocated ConnectionDetails struct, preferring placement in s's segment. +func (s ConnectionResponse_result) NewConnectionDetails() (ConnectionDetails, error) { + s.Struct.SetUint16(0, 1) + ss, err := NewConnectionDetails(s.Struct.Segment()) + if err != nil { + return ConnectionDetails{}, err + } + err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) + return ss, err +} + +// ConnectionResponse_List is a list of ConnectionResponse. +type ConnectionResponse_List struct{ capnp.List } + +// NewConnectionResponse creates a new list of ConnectionResponse. +func NewConnectionResponse_List(s *capnp.Segment, sz int32) (ConnectionResponse_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 1}, sz) + return ConnectionResponse_List{l}, err +} + +func (s ConnectionResponse_List) At(i int) ConnectionResponse { + return ConnectionResponse{s.List.Struct(i)} +} + +func (s ConnectionResponse_List) Set(i int, v ConnectionResponse) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s ConnectionResponse_List) String() string { + str, _ := text.MarshalList(0xdbaa9d03d52b62dc, s.List) + return str +} + +// ConnectionResponse_Promise is a wrapper for a ConnectionResponse promised by a client call. +type ConnectionResponse_Promise struct{ *capnp.Pipeline } + +func (p ConnectionResponse_Promise) Struct() (ConnectionResponse, error) { + s, err := p.Pipeline.Struct() + return ConnectionResponse{s}, err +} + +func (p ConnectionResponse_Promise) Result() ConnectionResponse_result_Promise { + return ConnectionResponse_result_Promise{p.Pipeline} +} + +// ConnectionResponse_result_Promise is a wrapper for a ConnectionResponse_result promised by a client call. +type ConnectionResponse_result_Promise struct{ *capnp.Pipeline } + +func (p ConnectionResponse_result_Promise) Struct() (ConnectionResponse_result, error) { + s, err := p.Pipeline.Struct() + return ConnectionResponse_result{s}, err +} + +func (p ConnectionResponse_result_Promise) Error() ConnectionError_Promise { + return ConnectionError_Promise{Pipeline: p.Pipeline.GetPipeline(0)} +} + +func (p ConnectionResponse_result_Promise) ConnectionDetails() ConnectionDetails_Promise { + return ConnectionDetails_Promise{Pipeline: p.Pipeline.GetPipeline(0)} +} + +type ConnectionError struct{ capnp.Struct } + +// ConnectionError_TypeID is the unique identifier for the type ConnectionError. +const ConnectionError_TypeID = 0xf5f383d2785edb86 + +func NewConnectionError(s *capnp.Segment) (ConnectionError, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1}) + return ConnectionError{st}, err +} + +func NewRootConnectionError(s *capnp.Segment) (ConnectionError, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1}) + return ConnectionError{st}, err +} + +func ReadRootConnectionError(msg *capnp.Message) (ConnectionError, error) { + root, err := msg.RootPtr() + return ConnectionError{root.Struct()}, err +} + +func (s ConnectionError) String() string { + str, _ := text.Marshal(0xf5f383d2785edb86, s.Struct) + return str +} + +func (s ConnectionError) Cause() (string, error) { + p, err := s.Struct.Ptr(0) + return p.Text(), err +} + +func (s ConnectionError) HasCause() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s ConnectionError) CauseBytes() ([]byte, error) { + p, err := s.Struct.Ptr(0) + return p.TextBytes(), err +} + +func (s ConnectionError) SetCause(v string) error { + return s.Struct.SetText(0, v) +} + +func (s ConnectionError) RetryAfter() int64 { + return int64(s.Struct.Uint64(0)) +} + +func (s ConnectionError) SetRetryAfter(v int64) { + s.Struct.SetUint64(0, uint64(v)) +} + +func (s ConnectionError) ShouldRetry() bool { + return s.Struct.Bit(64) +} + +func (s ConnectionError) SetShouldRetry(v bool) { + s.Struct.SetBit(64, v) +} + +// ConnectionError_List is a list of ConnectionError. +type ConnectionError_List struct{ capnp.List } + +// NewConnectionError creates a new list of ConnectionError. +func NewConnectionError_List(s *capnp.Segment, sz int32) (ConnectionError_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 16, PointerCount: 1}, sz) + return ConnectionError_List{l}, err +} + +func (s ConnectionError_List) At(i int) ConnectionError { return ConnectionError{s.List.Struct(i)} } + +func (s ConnectionError_List) Set(i int, v ConnectionError) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s ConnectionError_List) String() string { + str, _ := text.MarshalList(0xf5f383d2785edb86, s.List) + return str +} + +// ConnectionError_Promise is a wrapper for a ConnectionError promised by a client call. +type ConnectionError_Promise struct{ *capnp.Pipeline } + +func (p ConnectionError_Promise) Struct() (ConnectionError, error) { + s, err := p.Pipeline.Struct() + return ConnectionError{s}, err +} + +type ConnectionDetails struct{ capnp.Struct } + +// ConnectionDetails_TypeID is the unique identifier for the type ConnectionDetails. +const ConnectionDetails_TypeID = 0xb5f39f082b9ac18a + +func NewConnectionDetails(s *capnp.Segment) (ConnectionDetails, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}) + return ConnectionDetails{st}, err +} + +func NewRootConnectionDetails(s *capnp.Segment) (ConnectionDetails, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}) + return ConnectionDetails{st}, err +} + +func ReadRootConnectionDetails(msg *capnp.Message) (ConnectionDetails, error) { + root, err := msg.RootPtr() + return ConnectionDetails{root.Struct()}, err +} + +func (s ConnectionDetails) String() string { + str, _ := text.Marshal(0xb5f39f082b9ac18a, s.Struct) + return str +} + +func (s ConnectionDetails) Uuid() ([]byte, error) { + p, err := s.Struct.Ptr(0) + return []byte(p.Data()), err +} + +func (s ConnectionDetails) HasUuid() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s ConnectionDetails) SetUuid(v []byte) error { + return s.Struct.SetData(0, v) +} + +func (s ConnectionDetails) LocationName() (string, error) { + p, err := s.Struct.Ptr(1) + return p.Text(), err +} + +func (s ConnectionDetails) HasLocationName() bool { + p, err := s.Struct.Ptr(1) + return p.IsValid() || err != nil +} + +func (s ConnectionDetails) LocationNameBytes() ([]byte, error) { + p, err := s.Struct.Ptr(1) + return p.TextBytes(), err +} + +func (s ConnectionDetails) SetLocationName(v string) error { + return s.Struct.SetText(1, v) +} + +func (s ConnectionDetails) TunnelIsRemotelyManaged() bool { + return s.Struct.Bit(0) +} + +func (s ConnectionDetails) SetTunnelIsRemotelyManaged(v bool) { + s.Struct.SetBit(0, v) +} + +// ConnectionDetails_List is a list of ConnectionDetails. +type ConnectionDetails_List struct{ capnp.List } + +// NewConnectionDetails creates a new list of ConnectionDetails. +func NewConnectionDetails_List(s *capnp.Segment, sz int32) (ConnectionDetails_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}, sz) + return ConnectionDetails_List{l}, err +} + +func (s ConnectionDetails_List) At(i int) ConnectionDetails { + return ConnectionDetails{s.List.Struct(i)} +} + +func (s ConnectionDetails_List) Set(i int, v ConnectionDetails) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s ConnectionDetails_List) String() string { + str, _ := text.MarshalList(0xb5f39f082b9ac18a, s.List) + return str +} + +// ConnectionDetails_Promise is a wrapper for a ConnectionDetails promised by a client call. +type ConnectionDetails_Promise struct{ *capnp.Pipeline } + +func (p ConnectionDetails_Promise) Struct() (ConnectionDetails, error) { + s, err := p.Pipeline.Struct() + return ConnectionDetails{s}, err +} + +type TunnelAuth struct{ capnp.Struct } + +// TunnelAuth_TypeID is the unique identifier for the type TunnelAuth. +const TunnelAuth_TypeID = 0x9496331ab9cd463f + +func NewTunnelAuth(s *capnp.Segment) (TunnelAuth, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) + return TunnelAuth{st}, err +} + +func NewRootTunnelAuth(s *capnp.Segment) (TunnelAuth, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) + return TunnelAuth{st}, err +} + +func ReadRootTunnelAuth(msg *capnp.Message) (TunnelAuth, error) { + root, err := msg.RootPtr() + return TunnelAuth{root.Struct()}, err +} + +func (s TunnelAuth) String() string { + str, _ := text.Marshal(0x9496331ab9cd463f, s.Struct) + return str +} + +func (s TunnelAuth) AccountTag() (string, error) { + p, err := s.Struct.Ptr(0) + return p.Text(), err +} + +func (s TunnelAuth) HasAccountTag() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s TunnelAuth) AccountTagBytes() ([]byte, error) { + p, err := s.Struct.Ptr(0) + return p.TextBytes(), err +} + +func (s TunnelAuth) SetAccountTag(v string) error { + return s.Struct.SetText(0, v) +} + +func (s TunnelAuth) TunnelSecret() ([]byte, error) { + p, err := s.Struct.Ptr(1) + return []byte(p.Data()), err +} + +func (s TunnelAuth) HasTunnelSecret() bool { + p, err := s.Struct.Ptr(1) + return p.IsValid() || err != nil +} + +func (s TunnelAuth) SetTunnelSecret(v []byte) error { + return s.Struct.SetData(1, v) +} + +// TunnelAuth_List is a list of TunnelAuth. +type TunnelAuth_List struct{ capnp.List } + +// NewTunnelAuth creates a new list of TunnelAuth. +func NewTunnelAuth_List(s *capnp.Segment, sz int32) (TunnelAuth_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz) + return TunnelAuth_List{l}, err +} + +func (s TunnelAuth_List) At(i int) TunnelAuth { return TunnelAuth{s.List.Struct(i)} } + +func (s TunnelAuth_List) Set(i int, v TunnelAuth) error { return s.List.SetStruct(i, v.Struct) } + +func (s TunnelAuth_List) String() string { + str, _ := text.MarshalList(0x9496331ab9cd463f, s.List) + return str +} + +// TunnelAuth_Promise is a wrapper for a TunnelAuth promised by a client call. +type TunnelAuth_Promise struct{ *capnp.Pipeline } + +func (p TunnelAuth_Promise) Struct() (TunnelAuth, error) { + s, err := p.Pipeline.Struct() + return TunnelAuth{s}, err +} + +type RegistrationServer struct{ Client capnp.Client } + +// RegistrationServer_TypeID is the unique identifier for the type RegistrationServer. +const RegistrationServer_TypeID = 0xf71695ec7fe85497 + +func (c RegistrationServer) RegisterConnection(ctx context.Context, params func(RegistrationServer_registerConnection_Params) error, opts ...capnp.CallOption) RegistrationServer_registerConnection_Results_Promise { + if c.Client == nil { + return RegistrationServer_registerConnection_Results_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))} + } + call := &capnp.Call{ + Ctx: ctx, + Method: capnp.Method{ + InterfaceID: 0xf71695ec7fe85497, + MethodID: 0, + InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", + MethodName: "registerConnection", + }, + Options: capnp.NewCallOptions(opts), + } + if params != nil { + call.ParamsSize = capnp.ObjectSize{DataSize: 8, PointerCount: 3} + call.ParamsFunc = func(s capnp.Struct) error { return params(RegistrationServer_registerConnection_Params{Struct: s}) } + } + return RegistrationServer_registerConnection_Results_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))} +} +func (c RegistrationServer) UnregisterConnection(ctx context.Context, params func(RegistrationServer_unregisterConnection_Params) error, opts ...capnp.CallOption) RegistrationServer_unregisterConnection_Results_Promise { + if c.Client == nil { + return RegistrationServer_unregisterConnection_Results_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))} + } + call := &capnp.Call{ + Ctx: ctx, + Method: capnp.Method{ + InterfaceID: 0xf71695ec7fe85497, + MethodID: 1, + InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", + MethodName: "unregisterConnection", + }, + Options: capnp.NewCallOptions(opts), + } + if params != nil { + call.ParamsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 0} + call.ParamsFunc = func(s capnp.Struct) error { return params(RegistrationServer_unregisterConnection_Params{Struct: s}) } + } + return RegistrationServer_unregisterConnection_Results_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))} +} +func (c RegistrationServer) UpdateLocalConfiguration(ctx context.Context, params func(RegistrationServer_updateLocalConfiguration_Params) error, opts ...capnp.CallOption) RegistrationServer_updateLocalConfiguration_Results_Promise { + if c.Client == nil { + return RegistrationServer_updateLocalConfiguration_Results_Promise{Pipeline: capnp.NewPipeline(capnp.ErrorAnswer(capnp.ErrNullClient))} + } + call := &capnp.Call{ + Ctx: ctx, + Method: capnp.Method{ + InterfaceID: 0xf71695ec7fe85497, + MethodID: 2, + InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", + MethodName: "updateLocalConfiguration", + }, + Options: capnp.NewCallOptions(opts), + } + if params != nil { + call.ParamsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 1} + call.ParamsFunc = func(s capnp.Struct) error { + return params(RegistrationServer_updateLocalConfiguration_Params{Struct: s}) + } + } + return RegistrationServer_updateLocalConfiguration_Results_Promise{Pipeline: capnp.NewPipeline(c.Client.Call(call))} +} + +type RegistrationServer_Server interface { + RegisterConnection(RegistrationServer_registerConnection) error + + UnregisterConnection(RegistrationServer_unregisterConnection) error + + UpdateLocalConfiguration(RegistrationServer_updateLocalConfiguration) error +} + +func RegistrationServer_ServerToClient(s RegistrationServer_Server) RegistrationServer { + c, _ := s.(server.Closer) + return RegistrationServer{Client: server.New(RegistrationServer_Methods(nil, s), c)} +} + +func RegistrationServer_Methods(methods []server.Method, s RegistrationServer_Server) []server.Method { + if cap(methods) == 0 { + methods = make([]server.Method, 0, 3) + } + + methods = append(methods, server.Method{ + Method: capnp.Method{ + InterfaceID: 0xf71695ec7fe85497, + MethodID: 0, + InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", + MethodName: "registerConnection", + }, + Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error { + call := RegistrationServer_registerConnection{c, opts, RegistrationServer_registerConnection_Params{Struct: p}, RegistrationServer_registerConnection_Results{Struct: r}} + return s.RegisterConnection(call) + }, + ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 1}, + }) + + methods = append(methods, server.Method{ + Method: capnp.Method{ + InterfaceID: 0xf71695ec7fe85497, + MethodID: 1, + InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", + MethodName: "unregisterConnection", + }, + Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error { + call := RegistrationServer_unregisterConnection{c, opts, RegistrationServer_unregisterConnection_Params{Struct: p}, RegistrationServer_unregisterConnection_Results{Struct: r}} + return s.UnregisterConnection(call) + }, + ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 0}, + }) + + methods = append(methods, server.Method{ + Method: capnp.Method{ + InterfaceID: 0xf71695ec7fe85497, + MethodID: 2, + InterfaceName: "tunnelrpc/proto/tunnelrpc.capnp:RegistrationServer", + MethodName: "updateLocalConfiguration", + }, + Impl: func(c context.Context, opts capnp.CallOptions, p, r capnp.Struct) error { + call := RegistrationServer_updateLocalConfiguration{c, opts, RegistrationServer_updateLocalConfiguration_Params{Struct: p}, RegistrationServer_updateLocalConfiguration_Results{Struct: r}} + return s.UpdateLocalConfiguration(call) + }, + ResultsSize: capnp.ObjectSize{DataSize: 0, PointerCount: 0}, + }) + + return methods +} + +// RegistrationServer_registerConnection holds the arguments for a server call to RegistrationServer.registerConnection. +type RegistrationServer_registerConnection struct { + Ctx context.Context + Options capnp.CallOptions + Params RegistrationServer_registerConnection_Params + Results RegistrationServer_registerConnection_Results +} + +// RegistrationServer_unregisterConnection holds the arguments for a server call to RegistrationServer.unregisterConnection. +type RegistrationServer_unregisterConnection struct { + Ctx context.Context + Options capnp.CallOptions + Params RegistrationServer_unregisterConnection_Params + Results RegistrationServer_unregisterConnection_Results +} + +// RegistrationServer_updateLocalConfiguration holds the arguments for a server call to RegistrationServer.updateLocalConfiguration. +type RegistrationServer_updateLocalConfiguration struct { + Ctx context.Context + Options capnp.CallOptions + Params RegistrationServer_updateLocalConfiguration_Params + Results RegistrationServer_updateLocalConfiguration_Results +} + +type RegistrationServer_registerConnection_Params struct{ capnp.Struct } + +// RegistrationServer_registerConnection_Params_TypeID is the unique identifier for the type RegistrationServer_registerConnection_Params. +const RegistrationServer_registerConnection_Params_TypeID = 0xe6646dec8feaa6ee + +func NewRegistrationServer_registerConnection_Params(s *capnp.Segment) (RegistrationServer_registerConnection_Params, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 3}) + return RegistrationServer_registerConnection_Params{st}, err +} + +func NewRootRegistrationServer_registerConnection_Params(s *capnp.Segment) (RegistrationServer_registerConnection_Params, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 3}) + return RegistrationServer_registerConnection_Params{st}, err +} + +func ReadRootRegistrationServer_registerConnection_Params(msg *capnp.Message) (RegistrationServer_registerConnection_Params, error) { + root, err := msg.RootPtr() + return RegistrationServer_registerConnection_Params{root.Struct()}, err +} + +func (s RegistrationServer_registerConnection_Params) String() string { + str, _ := text.Marshal(0xe6646dec8feaa6ee, s.Struct) + return str +} + +func (s RegistrationServer_registerConnection_Params) Auth() (TunnelAuth, error) { + p, err := s.Struct.Ptr(0) + return TunnelAuth{Struct: p.Struct()}, err +} + +func (s RegistrationServer_registerConnection_Params) HasAuth() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s RegistrationServer_registerConnection_Params) SetAuth(v TunnelAuth) error { + return s.Struct.SetPtr(0, v.Struct.ToPtr()) +} + +// NewAuth sets the auth field to a newly +// allocated TunnelAuth struct, preferring placement in s's segment. +func (s RegistrationServer_registerConnection_Params) NewAuth() (TunnelAuth, error) { + ss, err := NewTunnelAuth(s.Struct.Segment()) + if err != nil { + return TunnelAuth{}, err + } + err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) + return ss, err +} + +func (s RegistrationServer_registerConnection_Params) TunnelId() ([]byte, error) { + p, err := s.Struct.Ptr(1) + return []byte(p.Data()), err +} + +func (s RegistrationServer_registerConnection_Params) HasTunnelId() bool { + p, err := s.Struct.Ptr(1) + return p.IsValid() || err != nil +} + +func (s RegistrationServer_registerConnection_Params) SetTunnelId(v []byte) error { + return s.Struct.SetData(1, v) +} + +func (s RegistrationServer_registerConnection_Params) ConnIndex() uint8 { + return s.Struct.Uint8(0) +} + +func (s RegistrationServer_registerConnection_Params) SetConnIndex(v uint8) { + s.Struct.SetUint8(0, v) +} + +func (s RegistrationServer_registerConnection_Params) Options() (ConnectionOptions, error) { + p, err := s.Struct.Ptr(2) + return ConnectionOptions{Struct: p.Struct()}, err +} + +func (s RegistrationServer_registerConnection_Params) HasOptions() bool { + p, err := s.Struct.Ptr(2) + return p.IsValid() || err != nil +} + +func (s RegistrationServer_registerConnection_Params) SetOptions(v ConnectionOptions) error { + return s.Struct.SetPtr(2, v.Struct.ToPtr()) +} + +// NewOptions sets the options field to a newly +// allocated ConnectionOptions struct, preferring placement in s's segment. +func (s RegistrationServer_registerConnection_Params) NewOptions() (ConnectionOptions, error) { + ss, err := NewConnectionOptions(s.Struct.Segment()) + if err != nil { + return ConnectionOptions{}, err + } + err = s.Struct.SetPtr(2, ss.Struct.ToPtr()) + return ss, err +} + +// RegistrationServer_registerConnection_Params_List is a list of RegistrationServer_registerConnection_Params. +type RegistrationServer_registerConnection_Params_List struct{ capnp.List } + +// NewRegistrationServer_registerConnection_Params creates a new list of RegistrationServer_registerConnection_Params. +func NewRegistrationServer_registerConnection_Params_List(s *capnp.Segment, sz int32) (RegistrationServer_registerConnection_Params_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 3}, sz) + return RegistrationServer_registerConnection_Params_List{l}, err +} + +func (s RegistrationServer_registerConnection_Params_List) At(i int) RegistrationServer_registerConnection_Params { + return RegistrationServer_registerConnection_Params{s.List.Struct(i)} +} + +func (s RegistrationServer_registerConnection_Params_List) Set(i int, v RegistrationServer_registerConnection_Params) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s RegistrationServer_registerConnection_Params_List) String() string { + str, _ := text.MarshalList(0xe6646dec8feaa6ee, s.List) + return str +} + +// RegistrationServer_registerConnection_Params_Promise is a wrapper for a RegistrationServer_registerConnection_Params promised by a client call. +type RegistrationServer_registerConnection_Params_Promise struct{ *capnp.Pipeline } + +func (p RegistrationServer_registerConnection_Params_Promise) Struct() (RegistrationServer_registerConnection_Params, error) { + s, err := p.Pipeline.Struct() + return RegistrationServer_registerConnection_Params{s}, err +} + +func (p RegistrationServer_registerConnection_Params_Promise) Auth() TunnelAuth_Promise { + return TunnelAuth_Promise{Pipeline: p.Pipeline.GetPipeline(0)} +} + +func (p RegistrationServer_registerConnection_Params_Promise) Options() ConnectionOptions_Promise { + return ConnectionOptions_Promise{Pipeline: p.Pipeline.GetPipeline(2)} +} + +type RegistrationServer_registerConnection_Results struct{ capnp.Struct } + +// RegistrationServer_registerConnection_Results_TypeID is the unique identifier for the type RegistrationServer_registerConnection_Results. +const RegistrationServer_registerConnection_Results_TypeID = 0xea50d822450d1f17 + +func NewRegistrationServer_registerConnection_Results(s *capnp.Segment) (RegistrationServer_registerConnection_Results, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) + return RegistrationServer_registerConnection_Results{st}, err +} + +func NewRootRegistrationServer_registerConnection_Results(s *capnp.Segment) (RegistrationServer_registerConnection_Results, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) + return RegistrationServer_registerConnection_Results{st}, err +} + +func ReadRootRegistrationServer_registerConnection_Results(msg *capnp.Message) (RegistrationServer_registerConnection_Results, error) { + root, err := msg.RootPtr() + return RegistrationServer_registerConnection_Results{root.Struct()}, err +} + +func (s RegistrationServer_registerConnection_Results) String() string { + str, _ := text.Marshal(0xea50d822450d1f17, s.Struct) + return str +} + +func (s RegistrationServer_registerConnection_Results) Result() (ConnectionResponse, error) { + p, err := s.Struct.Ptr(0) + return ConnectionResponse{Struct: p.Struct()}, err +} + +func (s RegistrationServer_registerConnection_Results) HasResult() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s RegistrationServer_registerConnection_Results) SetResult(v ConnectionResponse) error { + return s.Struct.SetPtr(0, v.Struct.ToPtr()) +} + +// NewResult sets the result field to a newly +// allocated ConnectionResponse struct, preferring placement in s's segment. +func (s RegistrationServer_registerConnection_Results) NewResult() (ConnectionResponse, error) { + ss, err := NewConnectionResponse(s.Struct.Segment()) + if err != nil { + return ConnectionResponse{}, err + } + err = s.Struct.SetPtr(0, ss.Struct.ToPtr()) + return ss, err +} + +// RegistrationServer_registerConnection_Results_List is a list of RegistrationServer_registerConnection_Results. +type RegistrationServer_registerConnection_Results_List struct{ capnp.List } + +// NewRegistrationServer_registerConnection_Results creates a new list of RegistrationServer_registerConnection_Results. +func NewRegistrationServer_registerConnection_Results_List(s *capnp.Segment, sz int32) (RegistrationServer_registerConnection_Results_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz) + return RegistrationServer_registerConnection_Results_List{l}, err +} + +func (s RegistrationServer_registerConnection_Results_List) At(i int) RegistrationServer_registerConnection_Results { + return RegistrationServer_registerConnection_Results{s.List.Struct(i)} +} + +func (s RegistrationServer_registerConnection_Results_List) Set(i int, v RegistrationServer_registerConnection_Results) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s RegistrationServer_registerConnection_Results_List) String() string { + str, _ := text.MarshalList(0xea50d822450d1f17, s.List) + return str +} + +// RegistrationServer_registerConnection_Results_Promise is a wrapper for a RegistrationServer_registerConnection_Results promised by a client call. +type RegistrationServer_registerConnection_Results_Promise struct{ *capnp.Pipeline } + +func (p RegistrationServer_registerConnection_Results_Promise) Struct() (RegistrationServer_registerConnection_Results, error) { + s, err := p.Pipeline.Struct() + return RegistrationServer_registerConnection_Results{s}, err +} + +func (p RegistrationServer_registerConnection_Results_Promise) Result() ConnectionResponse_Promise { + return ConnectionResponse_Promise{Pipeline: p.Pipeline.GetPipeline(0)} +} + +type RegistrationServer_unregisterConnection_Params struct{ capnp.Struct } + +// RegistrationServer_unregisterConnection_Params_TypeID is the unique identifier for the type RegistrationServer_unregisterConnection_Params. +const RegistrationServer_unregisterConnection_Params_TypeID = 0xf9cb7f4431a307d0 + +func NewRegistrationServer_unregisterConnection_Params(s *capnp.Segment) (RegistrationServer_unregisterConnection_Params, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) + return RegistrationServer_unregisterConnection_Params{st}, err +} + +func NewRootRegistrationServer_unregisterConnection_Params(s *capnp.Segment) (RegistrationServer_unregisterConnection_Params, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) + return RegistrationServer_unregisterConnection_Params{st}, err +} + +func ReadRootRegistrationServer_unregisterConnection_Params(msg *capnp.Message) (RegistrationServer_unregisterConnection_Params, error) { + root, err := msg.RootPtr() + return RegistrationServer_unregisterConnection_Params{root.Struct()}, err +} + +func (s RegistrationServer_unregisterConnection_Params) String() string { + str, _ := text.Marshal(0xf9cb7f4431a307d0, s.Struct) + return str +} + +// RegistrationServer_unregisterConnection_Params_List is a list of RegistrationServer_unregisterConnection_Params. +type RegistrationServer_unregisterConnection_Params_List struct{ capnp.List } + +// NewRegistrationServer_unregisterConnection_Params creates a new list of RegistrationServer_unregisterConnection_Params. +func NewRegistrationServer_unregisterConnection_Params_List(s *capnp.Segment, sz int32) (RegistrationServer_unregisterConnection_Params_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) + return RegistrationServer_unregisterConnection_Params_List{l}, err +} + +func (s RegistrationServer_unregisterConnection_Params_List) At(i int) RegistrationServer_unregisterConnection_Params { + return RegistrationServer_unregisterConnection_Params{s.List.Struct(i)} +} + +func (s RegistrationServer_unregisterConnection_Params_List) Set(i int, v RegistrationServer_unregisterConnection_Params) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s RegistrationServer_unregisterConnection_Params_List) String() string { + str, _ := text.MarshalList(0xf9cb7f4431a307d0, s.List) + return str +} + +// RegistrationServer_unregisterConnection_Params_Promise is a wrapper for a RegistrationServer_unregisterConnection_Params promised by a client call. +type RegistrationServer_unregisterConnection_Params_Promise struct{ *capnp.Pipeline } + +func (p RegistrationServer_unregisterConnection_Params_Promise) Struct() (RegistrationServer_unregisterConnection_Params, error) { + s, err := p.Pipeline.Struct() + return RegistrationServer_unregisterConnection_Params{s}, err +} + +type RegistrationServer_unregisterConnection_Results struct{ capnp.Struct } + +// RegistrationServer_unregisterConnection_Results_TypeID is the unique identifier for the type RegistrationServer_unregisterConnection_Results. +const RegistrationServer_unregisterConnection_Results_TypeID = 0xb046e578094b1ead + +func NewRegistrationServer_unregisterConnection_Results(s *capnp.Segment) (RegistrationServer_unregisterConnection_Results, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) + return RegistrationServer_unregisterConnection_Results{st}, err +} + +func NewRootRegistrationServer_unregisterConnection_Results(s *capnp.Segment) (RegistrationServer_unregisterConnection_Results, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) + return RegistrationServer_unregisterConnection_Results{st}, err +} + +func ReadRootRegistrationServer_unregisterConnection_Results(msg *capnp.Message) (RegistrationServer_unregisterConnection_Results, error) { + root, err := msg.RootPtr() + return RegistrationServer_unregisterConnection_Results{root.Struct()}, err +} + +func (s RegistrationServer_unregisterConnection_Results) String() string { + str, _ := text.Marshal(0xb046e578094b1ead, s.Struct) + return str +} + +// RegistrationServer_unregisterConnection_Results_List is a list of RegistrationServer_unregisterConnection_Results. +type RegistrationServer_unregisterConnection_Results_List struct{ capnp.List } + +// NewRegistrationServer_unregisterConnection_Results creates a new list of RegistrationServer_unregisterConnection_Results. +func NewRegistrationServer_unregisterConnection_Results_List(s *capnp.Segment, sz int32) (RegistrationServer_unregisterConnection_Results_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) + return RegistrationServer_unregisterConnection_Results_List{l}, err +} + +func (s RegistrationServer_unregisterConnection_Results_List) At(i int) RegistrationServer_unregisterConnection_Results { + return RegistrationServer_unregisterConnection_Results{s.List.Struct(i)} +} + +func (s RegistrationServer_unregisterConnection_Results_List) Set(i int, v RegistrationServer_unregisterConnection_Results) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s RegistrationServer_unregisterConnection_Results_List) String() string { + str, _ := text.MarshalList(0xb046e578094b1ead, s.List) + return str +} + +// RegistrationServer_unregisterConnection_Results_Promise is a wrapper for a RegistrationServer_unregisterConnection_Results promised by a client call. +type RegistrationServer_unregisterConnection_Results_Promise struct{ *capnp.Pipeline } + +func (p RegistrationServer_unregisterConnection_Results_Promise) Struct() (RegistrationServer_unregisterConnection_Results, error) { + s, err := p.Pipeline.Struct() + return RegistrationServer_unregisterConnection_Results{s}, err +} + +type RegistrationServer_updateLocalConfiguration_Params struct{ capnp.Struct } + +// RegistrationServer_updateLocalConfiguration_Params_TypeID is the unique identifier for the type RegistrationServer_updateLocalConfiguration_Params. +const RegistrationServer_updateLocalConfiguration_Params_TypeID = 0xc5d6e311876a3604 + +func NewRegistrationServer_updateLocalConfiguration_Params(s *capnp.Segment) (RegistrationServer_updateLocalConfiguration_Params, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) + return RegistrationServer_updateLocalConfiguration_Params{st}, err +} + +func NewRootRegistrationServer_updateLocalConfiguration_Params(s *capnp.Segment) (RegistrationServer_updateLocalConfiguration_Params, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) + return RegistrationServer_updateLocalConfiguration_Params{st}, err +} + +func ReadRootRegistrationServer_updateLocalConfiguration_Params(msg *capnp.Message) (RegistrationServer_updateLocalConfiguration_Params, error) { + root, err := msg.RootPtr() + return RegistrationServer_updateLocalConfiguration_Params{root.Struct()}, err +} + +func (s RegistrationServer_updateLocalConfiguration_Params) String() string { + str, _ := text.Marshal(0xc5d6e311876a3604, s.Struct) + return str +} + +func (s RegistrationServer_updateLocalConfiguration_Params) Config() ([]byte, error) { + p, err := s.Struct.Ptr(0) + return []byte(p.Data()), err +} + +func (s RegistrationServer_updateLocalConfiguration_Params) HasConfig() bool { + p, err := s.Struct.Ptr(0) + return p.IsValid() || err != nil +} + +func (s RegistrationServer_updateLocalConfiguration_Params) SetConfig(v []byte) error { + return s.Struct.SetData(0, v) +} + +// RegistrationServer_updateLocalConfiguration_Params_List is a list of RegistrationServer_updateLocalConfiguration_Params. +type RegistrationServer_updateLocalConfiguration_Params_List struct{ capnp.List } + +// NewRegistrationServer_updateLocalConfiguration_Params creates a new list of RegistrationServer_updateLocalConfiguration_Params. +func NewRegistrationServer_updateLocalConfiguration_Params_List(s *capnp.Segment, sz int32) (RegistrationServer_updateLocalConfiguration_Params_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz) + return RegistrationServer_updateLocalConfiguration_Params_List{l}, err +} + +func (s RegistrationServer_updateLocalConfiguration_Params_List) At(i int) RegistrationServer_updateLocalConfiguration_Params { + return RegistrationServer_updateLocalConfiguration_Params{s.List.Struct(i)} +} + +func (s RegistrationServer_updateLocalConfiguration_Params_List) Set(i int, v RegistrationServer_updateLocalConfiguration_Params) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s RegistrationServer_updateLocalConfiguration_Params_List) String() string { + str, _ := text.MarshalList(0xc5d6e311876a3604, s.List) + return str +} + +// RegistrationServer_updateLocalConfiguration_Params_Promise is a wrapper for a RegistrationServer_updateLocalConfiguration_Params promised by a client call. +type RegistrationServer_updateLocalConfiguration_Params_Promise struct{ *capnp.Pipeline } + +func (p RegistrationServer_updateLocalConfiguration_Params_Promise) Struct() (RegistrationServer_updateLocalConfiguration_Params, error) { + s, err := p.Pipeline.Struct() + return RegistrationServer_updateLocalConfiguration_Params{s}, err +} + +type RegistrationServer_updateLocalConfiguration_Results struct{ capnp.Struct } + +// RegistrationServer_updateLocalConfiguration_Results_TypeID is the unique identifier for the type RegistrationServer_updateLocalConfiguration_Results. +const RegistrationServer_updateLocalConfiguration_Results_TypeID = 0xe5ceae5d6897d7be + +func NewRegistrationServer_updateLocalConfiguration_Results(s *capnp.Segment) (RegistrationServer_updateLocalConfiguration_Results, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) + return RegistrationServer_updateLocalConfiguration_Results{st}, err +} + +func NewRootRegistrationServer_updateLocalConfiguration_Results(s *capnp.Segment) (RegistrationServer_updateLocalConfiguration_Results, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) + return RegistrationServer_updateLocalConfiguration_Results{st}, err +} + +func ReadRootRegistrationServer_updateLocalConfiguration_Results(msg *capnp.Message) (RegistrationServer_updateLocalConfiguration_Results, error) { + root, err := msg.RootPtr() + return RegistrationServer_updateLocalConfiguration_Results{root.Struct()}, err +} + +func (s RegistrationServer_updateLocalConfiguration_Results) String() string { + str, _ := text.Marshal(0xe5ceae5d6897d7be, s.Struct) + return str +} + +// RegistrationServer_updateLocalConfiguration_Results_List is a list of RegistrationServer_updateLocalConfiguration_Results. +type RegistrationServer_updateLocalConfiguration_Results_List struct{ capnp.List } + +// NewRegistrationServer_updateLocalConfiguration_Results creates a new list of RegistrationServer_updateLocalConfiguration_Results. +func NewRegistrationServer_updateLocalConfiguration_Results_List(s *capnp.Segment, sz int32) (RegistrationServer_updateLocalConfiguration_Results_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) + return RegistrationServer_updateLocalConfiguration_Results_List{l}, err +} + +func (s RegistrationServer_updateLocalConfiguration_Results_List) At(i int) RegistrationServer_updateLocalConfiguration_Results { + return RegistrationServer_updateLocalConfiguration_Results{s.List.Struct(i)} +} + +func (s RegistrationServer_updateLocalConfiguration_Results_List) Set(i int, v RegistrationServer_updateLocalConfiguration_Results) error { + return s.List.SetStruct(i, v.Struct) +} + +func (s RegistrationServer_updateLocalConfiguration_Results_List) String() string { + str, _ := text.MarshalList(0xe5ceae5d6897d7be, s.List) + return str +} + +// RegistrationServer_updateLocalConfiguration_Results_Promise is a wrapper for a RegistrationServer_updateLocalConfiguration_Results promised by a client call. +type RegistrationServer_updateLocalConfiguration_Results_Promise struct{ *capnp.Pipeline } + +func (p RegistrationServer_updateLocalConfiguration_Results_Promise) Struct() (RegistrationServer_updateLocalConfiguration_Results, error) { + s, err := p.Pipeline.Struct() + return RegistrationServer_updateLocalConfiguration_Results{s}, err +} + type RegisterUdpSessionResponse struct{ capnp.Struct } // RegisterUdpSessionResponse_TypeID is the unique identifier for the type RegisterUdpSessionResponse.