diff --git a/controller/apierror/api.go b/controller/apierror/api.go index 8bff7c3f9..1da43a3b2 100644 --- a/controller/apierror/api.go +++ b/controller/apierror/api.go @@ -1,50 +1,50 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package apierror - -import "encoding/json" - -type ApiError struct { - Code string `json:"code"` - Message string `json:"message"` - Status int `json:"-"` - Cause error `json:"cause"` - AppendCause bool `json:"-"` -} - -func (e ApiError) Error() string { - s := e.Code + ": " + e.Message - - if e.Cause != nil && e.AppendCause { - s = s + ": " + e.Cause.Error() - } - - return s -} - -type GenericCauseError struct { - Message string - DataMap map[string]interface{} -} - -func (e GenericCauseError) Error() string { - return e.Message -} - -func (e *GenericCauseError) MarshalJSON() ([]byte, error) { - return json.Marshal(e.DataMap) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package apierror + +import "encoding/json" + +type ApiError struct { + Code string `json:"code"` + Message string `json:"message"` + Status int `json:"-"` + Cause error `json:"cause"` + AppendCause bool `json:"-"` +} + +func (e ApiError) Error() string { + s := e.Code + ": " + e.Message + + if e.Cause != nil && e.AppendCause { + s = s + ": " + e.Cause.Error() + } + + return s +} + +type GenericCauseError struct { + Message string + DataMap map[string]interface{} +} + +func (e GenericCauseError) Error() string { + return e.Message +} + +func (e *GenericCauseError) MarshalJSON() ([]byte, error) { + return json.Marshal(e.DataMap) +} diff --git a/controller/apierror/bodyparser.go b/controller/apierror/bodyparser.go index b10905398..89aba5a4c 100644 --- a/controller/apierror/bodyparser.go +++ b/controller/apierror/bodyparser.go @@ -1,98 +1,99 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package apierror - -import ( - "encoding/json" - "fmt" - "strings" -) - -const ( - maxFieldErrorValueLength = 64 -) - -type BodyParseTypeError struct { - Near string `json:"near"` - ExpectedType string `json:"expectedType"` - EncounteredType string `json:"encounteredType"` - Offset int64 `json:"totalOffset"` - Line int64 `json:"line"` -} - -func (e BodyParseTypeError) Error() string { - return fmt.Sprintf("Expected type %s, but encountered %s near %s", e.ExpectedType, e.ExpectedType, e.Near) -} - -func NewBodyParseTypeError(e *json.UnmarshalTypeError, body string) *BodyParseTypeError { - nearStart := e.Offset - 10 - nearEnd := e.Offset - - if nearStart < 0 { - nearEnd = 5 - } - - near := body[nearStart:nearEnd] - - bodyToError := body[:e.Offset] - - line := strings.Count(bodyToError, "\n") + 1 - - return &BodyParseTypeError{ - ExpectedType: e.Type.String(), - EncounteredType: e.Value, - Near: near, - Offset: e.Offset, - Line: int64(line), - } -} - -type BodyParseSyntaxError struct { - Near string `json:"near"` - Offset int64 `json:"totalOffset"` - Line int64 `json:"line"` -} - -func (e BodyParseSyntaxError) Error() string { - return fmt.Sprintf("Invalid syntax on line %d", e.Line) -} - -func NewBodyParseSyntaxError(e *json.SyntaxError, body string) *BodyParseSyntaxError { - nearStart := e.Offset - 10 - nearEnd := e.Offset - - if nearStart < 0 { - nearStart = 0 - nearEnd = 5 - } - - if nearEnd > int64(len(body)) { - nearEnd = int64(len(body)) - } - - near := body[nearStart:nearEnd] - - bodyToError := body[:e.Offset] - - line := strings.Count(bodyToError, "\n") + 1 - - return &BodyParseSyntaxError{ - Near: near, - Offset: e.Offset, - Line: int64(line), - } -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package apierror + +import ( + "encoding/json" + "fmt" + "strings" +) + +const ( + maxFieldErrorValueLength = 64 +) + + +type BodyParseTypeError struct { + Near string `json:"near"` + ExpectedType string `json:"expectedType"` + EncounteredType string `json:"encounteredType"` + Offset int64 `json:"totalOffset"` + Line int64 `json:"line"` +} + +func (e BodyParseTypeError) Error() string { + return fmt.Sprintf("Expected type %s, but encountered %s near %s", e.ExpectedType, e.ExpectedType, e.Near) +} + +func NewBodyParseTypeError(e *json.UnmarshalTypeError, body string) *BodyParseTypeError { + nearStart := e.Offset - 10 + nearEnd := e.Offset + + if nearStart < 0 { + nearEnd = 5 + } + + near := body[nearStart:nearEnd] + + bodyToError := body[:e.Offset] + + line := strings.Count(bodyToError, "\n") + 1 + + return &BodyParseTypeError{ + ExpectedType: e.Type.String(), + EncounteredType: e.Value, + Near: near, + Offset: e.Offset, + Line: int64(line), + } +} + +type BodyParseSyntaxError struct { + Near string `json:"near"` + Offset int64 `json:"totalOffset"` + Line int64 `json:"line"` +} + +func (e BodyParseSyntaxError) Error() string { + return fmt.Sprintf("Invalid syntax on line %d", e.Line) +} + +func NewBodyParseSyntaxError(e *json.SyntaxError, body string) *BodyParseSyntaxError { + nearStart := e.Offset - 10 + nearEnd := e.Offset + + if nearStart < 0 { + nearStart = 0 + nearEnd = 5 + } + + if nearEnd > int64(len(body)) { + nearEnd = int64(len(body)) + } + + near := body[nearStart:nearEnd] + + bodyToError := body[:e.Offset] + + line := strings.Count(bodyToError, "\n") + 1 + + return &BodyParseSyntaxError{ + Near: near, + Offset: e.Offset, + Line: int64(line), + } +} \ No newline at end of file diff --git a/controller/apierror/field.go b/controller/apierror/field.go index b002f9bb7..be1c369c9 100644 --- a/controller/apierror/field.go +++ b/controller/apierror/field.go @@ -1,43 +1,43 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package apierror - -import "fmt" - -type FieldError struct { - Reason string `json:"message"` - FieldName string `json:"field"` - FieldValue interface{} `json:"value"` -} - -func (fe FieldError) Error() string { - v := fe.FieldValue - if s, ok := fe.FieldValue.(string); ok { - if len(s) > maxFieldErrorValueLength { - v = s[0:maxFieldErrorValueLength] + "..." - } - } - return fmt.Sprintf("the value '%v' for '%s' is invalid: %s", v, fe.FieldName, fe.Reason) -} - -func NewFieldError(reason, name string, value interface{}) *FieldError { - return &FieldError{ - Reason: reason, - FieldName: name, - FieldValue: value, - } -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package apierror + +import "fmt" + +type FieldError struct { + Reason string `json:"message"` + FieldName string `json:"field"` + FieldValue interface{} `json:"value"` +} + +func (fe FieldError) Error() string { + v := fe.FieldValue + if s, ok := fe.FieldValue.(string); ok { + if len(s) > maxFieldErrorValueLength { + v = s[0:maxFieldErrorValueLength] + "..." + } + } + return fmt.Sprintf("the value '%v' for '%s' is invalid: %s", v, fe.FieldName, fe.Reason) +} + +func NewFieldError(reason, name string, value interface{}) *FieldError { + return &FieldError{ + Reason: reason, + FieldName: name, + FieldValue: value, + } +} \ No newline at end of file diff --git a/controller/apierror/helpers.go b/controller/apierror/helpers.go index f8b8566e5..cededf041 100644 --- a/controller/apierror/helpers.go +++ b/controller/apierror/helpers.go @@ -1,284 +1,284 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package apierror - -import ( - "github.com/xeipuuv/gojsonschema" - "net/http" -) - -func NewNotFound() *ApiError { - return &ApiError{ - Code: NotFoundCode, - Message: NotFoundMessage, - Status: NotFoundStatus, - } -} -func NewForbidden() *ApiError { - return &ApiError{ - Code: ForbiddenCode, - Message: ForbiddenMessage, - Status: ForbiddenStatus, - } -} -func NewUnhandled() *ApiError { - return &ApiError{ - Code: UnhandledCode, - Message: UnhandledMessage, - Status: UnhandledStatus, - } -} -func NewCouldNotParseBody() *ApiError { - return &ApiError{ - Code: CouldNotParseBodyCode, - Message: CouldNotParseBodyMessage, - Status: CouldNotParseBodyStatus, - } -} - -func NewInvalidContentType(contentType string) *ApiError { - return &ApiError{ - Code: InvalidContentTypeCode, - Message: InvalidContentTypeMessage + ": " + contentType, - Status: InvalidContentTypeStatus, - } -} - -func NewCouldNotReadBody() *ApiError { - return &ApiError{ - Code: CouldNotReadBodyCode, - Message: CouldNotReadBodyMessage, - Status: CouldNotReadBodyStatus, - } -} -func NewInvalidField() *ApiError { - return &ApiError{ - Code: InvalidFieldCode, - Message: InvalidFieldMessage, - Status: InvalidFieldStatus, - } -} - -func NewEntityCanNotBeDeleted() *ApiError { - return &ApiError{ - Code: EntityCanNotBeDeletedCode, - Message: EntityCanNotBeDeletedMessage, - Status: EntityCanNotBeDeletedStatus, - } -} -func NewInvalidAuth() *ApiError { - return &ApiError{ - Code: InvalidAuthCode, - Message: InvalidAuthMessage, - Status: InvalidAuthStatus, - } -} -func NewInvalidAuthMethod() *ApiError { - return &ApiError{ - Code: InvalidAuthMethodCode, - Message: InvalidAuthMethodMessage, - Status: InvalidAuthMethodStatus, - } -} -func NewEnrollmentExpired() *ApiError { - return &ApiError{ - Code: EnrollmentExpiredCode, - Message: EnrollmentExpiredMessage, - Status: EnrollmentExpiredStatus, - } -} -func NewCouldNotProcessCsr() *ApiError { - return &ApiError{ - Code: CouldNotProcessCsrCode, - Message: CouldNotProcessCsrMessage, - Status: CouldNotProcessCsrStatus, - } -} -func NewEnrollmentCaNoLongValid() *ApiError { - return &ApiError{ - Code: EnrollmentCaNoLongValidCode, - Message: EnrollmentCaNoLongValidMessage, - Status: EnrollmentCaNoLongValidStatus, - } -} -func NewEnrollmentNoValidCas() *ApiError { - return &ApiError{ - Code: EnrollmentNoValidCasCode, - Message: EnrollmentNoValidCasMessage, - Status: EnrollmentNoValidCasStatus, - } -} -func NewInvalidEnrollmentToken() *ApiError { - return &ApiError{ - Code: InvalidEnrollmentTokenCode, - Message: InvalidEnrollmentTokenMessage, - Status: InvalidEnrollmentTokenStatus, - } -} -func NewInvalidEnrollMethod() *ApiError { - return &ApiError{ - Code: InvalidEnrollMethodCode, - Message: InvalidEnrollMethodMessage, - Status: InvalidEnrollMethodStatus, - } -} -func NewInvalidFilter() *ApiError { - return &ApiError{ - Code: InvalidFilterCode, - Message: InvalidFilterMessage, - Status: InvalidFilterStatus, - } -} -func NewInvalidPagination() *ApiError { - return &ApiError{ - Code: InvalidPaginationCode, - Message: InvalidPaginationMessage, - Status: InvalidPaginationStatus, - } -} -func NewNoEdgeRoutersAvailable() *ApiError { - return &ApiError{ - Code: NoEdgeRoutersAvailableCode, - Message: NoEdgeRoutersAvailableMessage, - Status: NoEdgeRoutersAvailableStatus, - } -} -func NewInvalidSort() *ApiError { - return &ApiError{ - Code: InvalidSortCode, - Message: InvalidSortMessage, - Status: InvalidSortStatus, - } -} -func NewCouldNotValidate() *ApiError { - return &ApiError{ - Code: CouldNotValidateCode, - Message: CouldNotValidateMessage, - Status: CouldNotValidateStatus, - } -} -func NewUnauthorized() *ApiError { - return &ApiError{ - Code: UnauthorizedCode, - Message: UnauthorizedMessage, - Status: UnauthorizedStatus, - } -} -func NewCouldNotParseX509FromDer() *ApiError { - return &ApiError{ - Code: CouldNotParseX509FromDerCode, - Message: CouldNotParseX509FromDerMessage, - Status: CouldNotParseX509FromDerStatus, - } -} -func NewCertFailedValidation() *ApiError { - return &ApiError{ - Code: CertFailedValidationCode, - Message: CertFailedValidationMessage, - Status: CertFailedValidationStatus, - } -} -func NewCertInUse() *ApiError { - return &ApiError{ - Code: CertInUseCode, - Message: CertInUseMessage, - Status: CertInUseStatus, - } -} -func NewCaAlreadyVerified() *ApiError { - return &ApiError{ - Code: CaAlreadyVerifiedCode, - Message: CaAlreadyVerifiedMessage, - Status: CaAlreadyVerifiedStatus, - } -} -func NewExpectedPemBlockCertificate() *ApiError { - return &ApiError{ - Code: ExpectedPemBlockCertificateCode, - Message: ExpectedPemBlockCertificateMessage, - Status: ExpectedPemBlockCertificateStatus, - } -} -func NewCouldNotParseDerBlock() *ApiError { - return &ApiError{ - Code: CouldNotParseDerBlockCode, - Message: CouldNotParseDerBlockMessage, - Status: CouldNotParseDerBlockStatus, - } -} -func NewCouldNotParsePem() *ApiError { - return &ApiError{ - Code: CouldNotParsePemCode, - Message: CouldNotParsePemMessage, - Status: CouldNotParsePemStatus, - } -} -func NewInvalidCommonName() *ApiError { - return &ApiError{ - Code: InvalidCommonNameCode, - Message: InvalidCommonNameMessage, - Status: InvalidCommonNameStatus, - } -} -func NewFailedCertificateValidation() *ApiError { - return &ApiError{ - Code: FailedCertificateValidationCode, - Message: FailedCertificateValidationMessage, - Status: FailedCertificateValidationStatus, - } -} -func NewCertificateIsNotCa() *ApiError { - return &ApiError{ - Code: CertificateIsNotCaCode, - Message: CertificateIsNotCaMessage, - Status: CertificateIsNotCaStatus, - } -} - -func NewValidationError(err gojsonschema.ResultError) *ValidationError { - return &ValidationError{ - Field: err.Field(), - Type: err.Type(), - Value: err.Value(), - Message: err.String(), - Details: err.Details(), - } -} - -func NewField(fieldError *FieldError) *ApiError { - return &ApiError{ - Code: InvalidFieldCode, - Message: InvalidFieldMessage, - Status: http.StatusBadRequest, - Cause: fieldError, - AppendCause: true, - } -} - -func NewInvalidUuid(val string) *ApiError { - return &ApiError{ - Code: InvalidUuidCode, - Message: InvalidUuidMessage, - Status: InvalidUuidStatus, - Cause: &GenericCauseError{ - Message: "invalid uuid", - DataMap: map[string]interface{}{ - "uuid": val, - }, - }, - } -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package apierror + +import ( + "github.com/xeipuuv/gojsonschema" + "net/http" +) + +func NewNotFound() *ApiError { + return &ApiError{ + Code: NotFoundCode, + Message: NotFoundMessage, + Status: NotFoundStatus, + } +} +func NewForbidden() *ApiError { + return &ApiError{ + Code: ForbiddenCode, + Message: ForbiddenMessage, + Status: ForbiddenStatus, + } +} +func NewUnhandled() *ApiError { + return &ApiError{ + Code: UnhandledCode, + Message: UnhandledMessage, + Status: UnhandledStatus, + } +} +func NewCouldNotParseBody() *ApiError { + return &ApiError{ + Code: CouldNotParseBodyCode, + Message: CouldNotParseBodyMessage, + Status: CouldNotParseBodyStatus, + } +} + +func NewInvalidContentType(contentType string) *ApiError { + return &ApiError{ + Code: InvalidContentTypeCode, + Message: InvalidContentTypeMessage + ": " + contentType, + Status: InvalidContentTypeStatus, + } +} + +func NewCouldNotReadBody() *ApiError { + return &ApiError{ + Code: CouldNotReadBodyCode, + Message: CouldNotReadBodyMessage, + Status: CouldNotReadBodyStatus, + } +} +func NewInvalidField() *ApiError { + return &ApiError{ + Code: InvalidFieldCode, + Message: InvalidFieldMessage, + Status: InvalidFieldStatus, + } +} + +func NewEntityCanNotBeDeleted() *ApiError { + return &ApiError{ + Code: EntityCanNotBeDeletedCode, + Message: EntityCanNotBeDeletedMessage, + Status: EntityCanNotBeDeletedStatus, + } +} +func NewInvalidAuth() *ApiError { + return &ApiError{ + Code: InvalidAuthCode, + Message: InvalidAuthMessage, + Status: InvalidAuthStatus, + } +} +func NewInvalidAuthMethod() *ApiError { + return &ApiError{ + Code: InvalidAuthMethodCode, + Message: InvalidAuthMethodMessage, + Status: InvalidAuthMethodStatus, + } +} +func NewEnrollmentExpired() *ApiError { + return &ApiError{ + Code: EnrollmentExpiredCode, + Message: EnrollmentExpiredMessage, + Status: EnrollmentExpiredStatus, + } +} +func NewCouldNotProcessCsr() *ApiError { + return &ApiError{ + Code: CouldNotProcessCsrCode, + Message: CouldNotProcessCsrMessage, + Status: CouldNotProcessCsrStatus, + } +} +func NewEnrollmentCaNoLongValid() *ApiError { + return &ApiError{ + Code: EnrollmentCaNoLongValidCode, + Message: EnrollmentCaNoLongValidMessage, + Status: EnrollmentCaNoLongValidStatus, + } +} +func NewEnrollmentNoValidCas() *ApiError { + return &ApiError{ + Code: EnrollmentNoValidCasCode, + Message: EnrollmentNoValidCasMessage, + Status: EnrollmentNoValidCasStatus, + } +} +func NewInvalidEnrollmentToken() *ApiError { + return &ApiError{ + Code: InvalidEnrollmentTokenCode, + Message: InvalidEnrollmentTokenMessage, + Status: InvalidEnrollmentTokenStatus, + } +} +func NewInvalidEnrollMethod() *ApiError { + return &ApiError{ + Code: InvalidEnrollMethodCode, + Message: InvalidEnrollMethodMessage, + Status: InvalidEnrollMethodStatus, + } +} +func NewInvalidFilter() *ApiError { + return &ApiError{ + Code: InvalidFilterCode, + Message: InvalidFilterMessage, + Status: InvalidFilterStatus, + } +} +func NewInvalidPagination() *ApiError { + return &ApiError{ + Code: InvalidPaginationCode, + Message: InvalidPaginationMessage, + Status: InvalidPaginationStatus, + } +} +func NewNoEdgeRoutersAvailable() *ApiError { + return &ApiError{ + Code: NoEdgeRoutersAvailableCode, + Message: NoEdgeRoutersAvailableMessage, + Status: NoEdgeRoutersAvailableStatus, + } +} +func NewInvalidSort() *ApiError { + return &ApiError{ + Code: InvalidSortCode, + Message: InvalidSortMessage, + Status: InvalidSortStatus, + } +} +func NewCouldNotValidate() *ApiError { + return &ApiError{ + Code: CouldNotValidateCode, + Message: CouldNotValidateMessage, + Status: CouldNotValidateStatus, + } +} +func NewUnauthorized() *ApiError { + return &ApiError{ + Code: UnauthorizedCode, + Message: UnauthorizedMessage, + Status: UnauthorizedStatus, + } +} +func NewCouldNotParseX509FromDer() *ApiError { + return &ApiError{ + Code: CouldNotParseX509FromDerCode, + Message: CouldNotParseX509FromDerMessage, + Status: CouldNotParseX509FromDerStatus, + } +} +func NewCertFailedValidation() *ApiError { + return &ApiError{ + Code: CertFailedValidationCode, + Message: CertFailedValidationMessage, + Status: CertFailedValidationStatus, + } +} +func NewCertInUse() *ApiError { + return &ApiError{ + Code: CertInUseCode, + Message: CertInUseMessage, + Status: CertInUseStatus, + } +} +func NewCaAlreadyVerified() *ApiError { + return &ApiError{ + Code: CaAlreadyVerifiedCode, + Message: CaAlreadyVerifiedMessage, + Status: CaAlreadyVerifiedStatus, + } +} +func NewExpectedPemBlockCertificate() *ApiError { + return &ApiError{ + Code: ExpectedPemBlockCertificateCode, + Message: ExpectedPemBlockCertificateMessage, + Status: ExpectedPemBlockCertificateStatus, + } +} +func NewCouldNotParseDerBlock() *ApiError { + return &ApiError{ + Code: CouldNotParseDerBlockCode, + Message: CouldNotParseDerBlockMessage, + Status: CouldNotParseDerBlockStatus, + } +} +func NewCouldNotParsePem() *ApiError { + return &ApiError{ + Code: CouldNotParsePemCode, + Message: CouldNotParsePemMessage, + Status: CouldNotParsePemStatus, + } +} +func NewInvalidCommonName() *ApiError { + return &ApiError{ + Code: InvalidCommonNameCode, + Message: InvalidCommonNameMessage, + Status: InvalidCommonNameStatus, + } +} +func NewFailedCertificateValidation() *ApiError { + return &ApiError{ + Code: FailedCertificateValidationCode, + Message: FailedCertificateValidationMessage, + Status: FailedCertificateValidationStatus, + } +} +func NewCertificateIsNotCa() *ApiError { + return &ApiError{ + Code: CertificateIsNotCaCode, + Message: CertificateIsNotCaMessage, + Status: CertificateIsNotCaStatus, + } +} + +func NewValidationError(err gojsonschema.ResultError) *ValidationError { + return &ValidationError{ + Field: err.Field(), + Type: err.Type(), + Value: err.Value(), + Message: err.String(), + Details: err.Details(), + } +} + +func NewField(fieldError *FieldError) *ApiError { + return &ApiError{ + Code: InvalidFieldCode, + Message: InvalidFieldMessage, + Status: http.StatusBadRequest, + Cause: fieldError, + AppendCause: true, + } +} + +func NewInvalidUuid(val string) *ApiError { + return &ApiError{ + Code: InvalidUuidCode, + Message: InvalidUuidMessage, + Status: InvalidUuidStatus, + Cause: &GenericCauseError{ + Message: "invalid uuid", + DataMap: map[string]interface{}{ + "uuid": val, + }, + }, + } +} diff --git a/controller/apierror/json.go b/controller/apierror/json.go index a749110c5..98a54b5da 100644 --- a/controller/apierror/json.go +++ b/controller/apierror/json.go @@ -1,30 +1,30 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package apierror - -import ( - "encoding/json" -) - -func GetJsonParseError(e error, body []byte) error { - if ute, ok := e.(*json.UnmarshalTypeError); ok { - e = NewBodyParseTypeError(ute, string(body)) - } else if se, ok := e.(*json.SyntaxError); ok { - e = NewBodyParseSyntaxError(se, string(body)) - } - return e -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package apierror + +import ( + "encoding/json" +) + +func GetJsonParseError(e error, body []byte) error { + if ute, ok := e.(*json.UnmarshalTypeError); ok { + e = NewBodyParseTypeError(ute, string(body)) + } else if se, ok := e.(*json.SyntaxError); ok { + e = NewBodyParseSyntaxError(se, string(body)) + } + return e +} diff --git a/controller/apierror/messages.go b/controller/apierror/messages.go index 7d6cfebf2..2a854c426 100644 --- a/controller/apierror/messages.go +++ b/controller/apierror/messages.go @@ -1,160 +1,160 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package apierror - -import "net/http" - -const ( - NotFoundCode string = "NOT_FOUND" - NotFoundMessage string = "The resource requested was not found or is no longer available" - NotFoundStatus int = http.StatusNotFound - - ForbiddenCode string = "FORBIDDEN" - ForbiddenMessage string = "The resource requested" - ForbiddenStatus int = http.StatusForbidden - - UnhandledCode string = "UNHANDLED" - UnhandledMessage string = "An unhandled error occurred" - UnhandledStatus int = http.StatusInternalServerError - - CouldNotParseBodyCode string = "COULD_NOT_PARSE_BODY" - CouldNotParseBodyMessage string = "The body of the request could not be parsed" - CouldNotParseBodyStatus int = http.StatusInternalServerError - - CouldNotReadBodyCode string = "COULD_NOT_READ_BODY" - CouldNotReadBodyMessage string = "The body of the request could not be read" - CouldNotReadBodyStatus int = http.StatusInternalServerError - - InvalidFieldCode string = "INVALID_FIELD" - InvalidFieldMessage string = "The field contains an invalid value" - InvalidFieldStatus int = http.StatusBadRequest - - EntityCanNotBeDeletedCode string = "ENTITY_CAN_NOT_BE_DELETED" - EntityCanNotBeDeletedMessage string = "The entity requested for delete can not be deleted" - EntityCanNotBeDeletedStatus = http.StatusBadRequest - - InvalidUuidCode string = "INVALID_UUID" - InvalidUuidMessage string = "The supplied UUID is invalid" - InvalidUuidStatus int = http.StatusBadRequest - - InvalidContentTypeCode string = "INVALID_CONTENT_TYPE" - InvalidContentTypeMessage string = "The content type supplied is not acceptable" - InvalidContentTypeStatus int = http.StatusBadRequest -) - -// specific -const ( - InvalidAuthCode string = "INVALID_AUTH" - InvalidAuthMessage string = "The authentication request failed" - InvalidAuthStatus int = http.StatusUnauthorized - - InvalidAuthMethodCode string = "INVALID_AUTH_METHOD" - InvalidAuthMethodMessage string = "The supplied authentication method is not valid" - InvalidAuthMethodStatus int = http.StatusBadRequest - - EnrollmentExpiredCode string = "ENROLLMENT_EXPIRED" - EnrollmentExpiredMessage string = "The window for this enrollment has expired" - EnrollmentExpiredStatus int = http.StatusBadRequest - - CouldNotProcessCsrCode string = "COULD_NOT_PROCESS_CSR" - CouldNotProcessCsrMessage string = "The supplied csr could not be processed" - CouldNotProcessCsrStatus int = http.StatusBadRequest - - EnrollmentCaNoLongValidCode string = "ENROLLMENT_CA_NOT_VALID" - EnrollmentCaNoLongValidMessage string = "The CA tied to the supplied token is no longer valid" - EnrollmentCaNoLongValidStatus int = http.StatusBadRequest - - EnrollmentNoValidCasCode string = "ENROLLMENT_NO_VALID_CAS" - EnrollmentNoValidCasMessage string = "No CAs are valid for this request" - EnrollmentNoValidCasStatus int = http.StatusBadRequest - - InvalidEnrollmentTokenCode string = "INVALID_ENROLLMENT_TOKEN" - InvalidEnrollmentTokenMessage string = "The supplied token is not valid" - InvalidEnrollmentTokenStatus int = http.StatusBadRequest - - InvalidEnrollMethodCode string = "INVALID_ENROLL_METHOD" - InvalidEnrollMethodMessage string = "The supplied enrollment method is not valid" - InvalidEnrollMethodStatus int = http.StatusBadRequest - - InvalidFilterCode string = "INVALID_FILTER" - InvalidFilterMessage string = "The filter query supplied is invalid" - InvalidFilterStatus int = http.StatusBadRequest - - InvalidPaginationCode string = "INVALID_PAGINATION" - InvalidPaginationMessage string = "The pagination properties provided are invalid" - InvalidPaginationStatus int = http.StatusBadRequest - - NoEdgeRoutersAvailableCode string = "NO_EDGE_ROUTERS_AVAILABLE" - NoEdgeRoutersAvailableMessage string = "No edge routers are assigned and online to handle the requested connection" - NoEdgeRoutersAvailableStatus int = http.StatusBadRequest - - InvalidSortCode string = "INVALID_SORT_IDENTIFIER" - InvalidSortMessage string = "The sort order supplied is invalid" - InvalidSortStatus int = http.StatusBadRequest - - CouldNotValidateCode string = "COULD_NOT_VALIDATE" - CouldNotValidateMessage string = "The supplied request contains an invalid document" - CouldNotValidateStatus int = http.StatusBadRequest - - UnauthorizedCode string = "UNAUTHORIZED" - UnauthorizedMessage string = "The request could not be completed. The session is not authorized or the credentials are invalid" - UnauthorizedStatus int = http.StatusUnauthorized - - CouldNotDecodeProxiedCertCode string = "COULD_NOT_PARSE_PROXY_CERT" - CouldNotDecodeProxiedCertMessage string = "could not decode proxy client cert" - CouldNotDecodeProxiedCertStatus int = http.StatusInternalServerError - - CouldNotParseX509FromDerCode string = "COULD_NOT_PARSE_x509_FROM_DER" - CouldNotParseX509FromDerMessage string = "could not parse x509 from DER" - CouldNotParseX509FromDerStatus int = http.StatusBadRequest - - CertFailedValidationCode string = "CERT_FAILED_VALIDATION" - CertFailedValidationMessage string = "certificate failed to validate against CA" - CertFailedValidationStatus int = http.StatusBadRequest - - CertInUseCode string = "CERT_IN_USE" - CertInUseMessage string = "The certificate supplied is already associated with another identity" - CertInUseStatus int = http.StatusConflict - - CaAlreadyVerifiedCode string = "CA_ALREADY_VERIFIED" - CaAlreadyVerifiedMessage string = "CA has already been verified" - CaAlreadyVerifiedStatus int = http.StatusConflict - - ExpectedPemBlockCertificateCode = "EXPECTED_PEM_CERTIFICATE" - ExpectedPemBlockCertificateMessage string = "expected PEM block type 'CERTIFICATE'" - ExpectedPemBlockCertificateStatus int = http.StatusBadRequest - - CouldNotParseDerBlockCode string = "COULD_NOT_PARSE_DER_BLOCK" - CouldNotParseDerBlockMessage string = "The certificate's DER block could not be parsed" - CouldNotParseDerBlockStatus int = http.StatusBadRequest - - CouldNotParsePemCode string = "COULD_NOT_PARSE_PEM_BLOCK" - CouldNotParsePemMessage string = "The certificate's PEM block could not be parsed" - CouldNotParsePemStatus int = http.StatusBadRequest - - InvalidCommonNameCode string = "INVALID_COMMON_NAME" - InvalidCommonNameMessage string = "The common name of the supplied certificate is invalid" - InvalidCommonNameStatus int = http.StatusBadRequest - - FailedCertificateValidationCode string = "CERTIFICATE_FAILED_VALIDATION" - FailedCertificateValidationMessage string = "The supplied certificate failed to validate against the CA's certificate chain" - FailedCertificateValidationStatus int = http.StatusBadRequest - - CertificateIsNotCaCode string = "CERTIFICATE_IS_NOT_CA" - CertificateIsNotCaMessage string = "Leading certificate is not a CA" - CertificateIsNotCaStatus int = http.StatusBadRequest -) +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package apierror + +import "net/http" + +const ( + NotFoundCode string = "NOT_FOUND" + NotFoundMessage string = "The resource requested was not found or is no longer available" + NotFoundStatus int = http.StatusNotFound + + ForbiddenCode string = "FORBIDDEN" + ForbiddenMessage string = "The resource requested" + ForbiddenStatus int = http.StatusForbidden + + UnhandledCode string = "UNHANDLED" + UnhandledMessage string = "An unhandled error occurred" + UnhandledStatus int = http.StatusInternalServerError + + CouldNotParseBodyCode string = "COULD_NOT_PARSE_BODY" + CouldNotParseBodyMessage string = "The body of the request could not be parsed" + CouldNotParseBodyStatus int = http.StatusInternalServerError + + CouldNotReadBodyCode string = "COULD_NOT_READ_BODY" + CouldNotReadBodyMessage string = "The body of the request could not be read" + CouldNotReadBodyStatus int = http.StatusInternalServerError + + InvalidFieldCode string = "INVALID_FIELD" + InvalidFieldMessage string = "The field contains an invalid value" + InvalidFieldStatus int = http.StatusBadRequest + + EntityCanNotBeDeletedCode string = "ENTITY_CAN_NOT_BE_DELETED" + EntityCanNotBeDeletedMessage string = "The entity requested for delete can not be deleted" + EntityCanNotBeDeletedStatus = http.StatusBadRequest + + InvalidUuidCode string = "INVALID_UUID" + InvalidUuidMessage string = "The supplied UUID is invalid" + InvalidUuidStatus int = http.StatusBadRequest + + InvalidContentTypeCode string = "INVALID_CONTENT_TYPE" + InvalidContentTypeMessage string = "The content type supplied is not acceptable" + InvalidContentTypeStatus int = http.StatusBadRequest +) + +// specific +const ( + InvalidAuthCode string = "INVALID_AUTH" + InvalidAuthMessage string = "The authentication request failed" + InvalidAuthStatus int = http.StatusUnauthorized + + InvalidAuthMethodCode string = "INVALID_AUTH_METHOD" + InvalidAuthMethodMessage string = "The supplied authentication method is not valid" + InvalidAuthMethodStatus int = http.StatusBadRequest + + EnrollmentExpiredCode string = "ENROLLMENT_EXPIRED" + EnrollmentExpiredMessage string = "The window for this enrollment has expired" + EnrollmentExpiredStatus int = http.StatusBadRequest + + CouldNotProcessCsrCode string = "COULD_NOT_PROCESS_CSR" + CouldNotProcessCsrMessage string = "The supplied csr could not be processed" + CouldNotProcessCsrStatus int = http.StatusBadRequest + + EnrollmentCaNoLongValidCode string = "ENROLLMENT_CA_NOT_VALID" + EnrollmentCaNoLongValidMessage string = "The CA tied to the supplied token is no longer valid" + EnrollmentCaNoLongValidStatus int = http.StatusBadRequest + + EnrollmentNoValidCasCode string = "ENROLLMENT_NO_VALID_CAS" + EnrollmentNoValidCasMessage string = "No CAs are valid for this request" + EnrollmentNoValidCasStatus int = http.StatusBadRequest + + InvalidEnrollmentTokenCode string = "INVALID_ENROLLMENT_TOKEN" + InvalidEnrollmentTokenMessage string = "The supplied token is not valid" + InvalidEnrollmentTokenStatus int = http.StatusBadRequest + + InvalidEnrollMethodCode string = "INVALID_ENROLL_METHOD" + InvalidEnrollMethodMessage string = "The supplied enrollment method is not valid" + InvalidEnrollMethodStatus int = http.StatusBadRequest + + InvalidFilterCode string = "INVALID_FILTER" + InvalidFilterMessage string = "The filter query supplied is invalid" + InvalidFilterStatus int = http.StatusBadRequest + + InvalidPaginationCode string = "INVALID_PAGINATION" + InvalidPaginationMessage string = "The pagination properties provided are invalid" + InvalidPaginationStatus int = http.StatusBadRequest + + NoEdgeRoutersAvailableCode string = "NO_EDGE_ROUTERS_AVAILABLE" + NoEdgeRoutersAvailableMessage string = "No edge routers are assigned and online to handle the requested connection" + NoEdgeRoutersAvailableStatus int = http.StatusBadRequest + + InvalidSortCode string = "INVALID_SORT_IDENTIFIER" + InvalidSortMessage string = "The sort order supplied is invalid" + InvalidSortStatus int = http.StatusBadRequest + + CouldNotValidateCode string = "COULD_NOT_VALIDATE" + CouldNotValidateMessage string = "The supplied request contains an invalid document" + CouldNotValidateStatus int = http.StatusBadRequest + + UnauthorizedCode string = "UNAUTHORIZED" + UnauthorizedMessage string = "The request could not be completed. The session is not authorized or the credentials are invalid" + UnauthorizedStatus int = http.StatusUnauthorized + + CouldNotDecodeProxiedCertCode string = "COULD_NOT_PARSE_PROXY_CERT" + CouldNotDecodeProxiedCertMessage string = "could not decode proxy client cert" + CouldNotDecodeProxiedCertStatus int = http.StatusInternalServerError + + CouldNotParseX509FromDerCode string = "COULD_NOT_PARSE_x509_FROM_DER" + CouldNotParseX509FromDerMessage string = "could not parse x509 from DER" + CouldNotParseX509FromDerStatus int = http.StatusBadRequest + + CertFailedValidationCode string = "CERT_FAILED_VALIDATION" + CertFailedValidationMessage string = "certificate failed to validate against CA" + CertFailedValidationStatus int = http.StatusBadRequest + + CertInUseCode string = "CERT_IN_USE" + CertInUseMessage string = "The certificate supplied is already associated with another identity" + CertInUseStatus int = http.StatusConflict + + CaAlreadyVerifiedCode string = "CA_ALREADY_VERIFIED" + CaAlreadyVerifiedMessage string = "CA has already been verified" + CaAlreadyVerifiedStatus int = http.StatusConflict + + ExpectedPemBlockCertificateCode = "EXPECTED_PEM_CERTIFICATE" + ExpectedPemBlockCertificateMessage string = "expected PEM block type 'CERTIFICATE'" + ExpectedPemBlockCertificateStatus int = http.StatusBadRequest + + CouldNotParseDerBlockCode string = "COULD_NOT_PARSE_DER_BLOCK" + CouldNotParseDerBlockMessage string = "The certificate's DER block could not be parsed" + CouldNotParseDerBlockStatus int = http.StatusBadRequest + + CouldNotParsePemCode string = "COULD_NOT_PARSE_PEM_BLOCK" + CouldNotParsePemMessage string = "The certificate's PEM block could not be parsed" + CouldNotParsePemStatus int = http.StatusBadRequest + + InvalidCommonNameCode string = "INVALID_COMMON_NAME" + InvalidCommonNameMessage string = "The common name of the supplied certificate is invalid" + InvalidCommonNameStatus int = http.StatusBadRequest + + FailedCertificateValidationCode string = "CERTIFICATE_FAILED_VALIDATION" + FailedCertificateValidationMessage string = "The supplied certificate failed to validate against the CA's certificate chain" + FailedCertificateValidationStatus int = http.StatusBadRequest + + CertificateIsNotCaCode string = "CERTIFICATE_IS_NOT_CA" + CertificateIsNotCaMessage string = "Leading certificate is not a CA" + CertificateIsNotCaStatus int = http.StatusBadRequest +) diff --git a/controller/apierror/validation.go b/controller/apierror/validation.go index 5cd9a22da..8a136cadf 100644 --- a/controller/apierror/validation.go +++ b/controller/apierror/validation.go @@ -1,31 +1,31 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package apierror - -import "fmt" - -type ValidationError struct { - Field string `json:"field"` - Type string `json:"type"` - Value interface{} `json:"value"` - Message string `json:"message"` - Details map[string]interface{} `json:"details"` -} - -func (e ValidationError) Error() string { - return fmt.Sprintf("%s is invalid: %s", e.Field, e.Message) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package apierror + +import "fmt" + +type ValidationError struct { + Field string `json:"field"` + Type string `json:"type"` + Value interface{} `json:"value"` + Message string `json:"message"` + Details map[string]interface{} `json:"details"` +} + +func (e ValidationError) Error() string { + return fmt.Sprintf("%s is invalid: %s", e.Field, e.Message) +} diff --git a/controller/config/config.go b/controller/config/config.go index d1ac78219..8ca3cacc2 100644 --- a/controller/config/config.go +++ b/controller/config/config.go @@ -1,452 +1,452 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package config - -import ( - "bytes" - "crypto/sha1" - "encoding/pem" - "errors" - "fmt" - "github.com/gobuffalo/packr" - "github.com/michaelquigley/pfxlog" - "github.com/netfoundry/ziti-foundation/identity/identity" - "gopkg.in/yaml.v2" - "io/ioutil" - "os" - "strconv" - "strings" - "sync" - "time" -) - -const ( - sessionTimeoutDefault = 10 - sessionTimeoutMin = 1 - - enrollmentDurationMin = 5 - enrollmentDurationDefault = 1440 -) - -type Db struct { - ConnectionUrl string `yaml:"connectionUrl"` - DbName string `yaml:"dbName"` -} - -type Persistence struct { - boxes []*packr.Box - Postgres *Db `yaml:"postgres"` -} - -func (p *Persistence) AddMigrationBox(b *packr.Box) { - p.boxes = append(p.boxes, b) -} - -func (p *Persistence) GetBoxes() []*packr.Box { - return p.boxes -} - -type Enrollment struct { - SigningCert identity.Identity - SigningCertConfig identity.IdentityConfig - SigningCertCaPem []byte - EdgeIdentity EnrollmentOption - EdgeRouter EnrollmentOption -} - -type EnrollmentOption struct { - DurationMinutes time.Duration -} - -type Api struct { - SessionTimeoutSeconds time.Duration - Listener string - Advertise string - Identity identity.Identity - IdentityConfig identity.IdentityConfig - IdentityCaPem []byte -} - -type Config struct { - RootIdentityConfig identity.IdentityConfig - RootIdentity identity.Identity - RootIdentityCaPem []byte - Enabled bool - Api Api - Enrollment Enrollment - Persistence Persistence - caPems [][]byte - caPemsBuf []byte - caPemsOnce sync.Once -} - -func (c *Config) SessionTimeoutDuration() time.Duration { - return c.Api.SessionTimeoutSeconds -} - -func toHex(data []byte) string { - var buf bytes.Buffer - for i, b := range data { - if i > 0 { - _, _ = fmt.Fprintf(&buf, ":") - } - _, _ = fmt.Fprintf(&buf, "%02x", b) - } - return strings.ToUpper(buf.String()) -} - -func (c *Config) CaPems() []byte { - c.caPemsOnce.Do(func() { - buf := bytes.Buffer{} - //dedupe chains - pemMap := map[string][]byte{} - for _, caChain := range c.caPems { - rest := caChain - for len(rest) != 0 { - var block *pem.Block - block, rest = pem.Decode(rest) - - if block != nil { - hash := sha1.Sum(block.Bytes) - fingerprint := toHex(hash[:]) - pemMap[fingerprint] = pem.EncodeToMemory(block) - } - } - } - - i := 0 - for _, pemBytes := range pemMap { - if i != 0 { - buf.Write([]byte("\n")) - } - buf.Write(pemBytes) - i++ - } - c.caPemsBuf = buf.Bytes() - }) - - return c.caPemsBuf -} - -func (c *Config) loadRootIdentity(fabricConfigMap map[interface{}]interface{}) error { - var fabricIdentitySubMap map[interface{}]interface{} - if value, found := fabricConfigMap["identity"]; found { - fabricIdentitySubMap = value.(map[interface{}]interface{}) - } else { - return errors.New("required configuration value [identity] missing") - } - - if value, found := fabricIdentitySubMap["cert"]; found { - c.RootIdentityConfig.Cert = value.(string) - } else { - return fmt.Errorf("required configuration value [identity.cert] is missing") - } - - if value, found := fabricIdentitySubMap["server_cert"]; found { - c.RootIdentityConfig.ServerCert = value.(string) - } else { - return fmt.Errorf("required configuration value [identity.server_cert] is missing") - } - - if value, found := fabricIdentitySubMap["key"]; found { - c.RootIdentityConfig.Key = value.(string) - } else { - return fmt.Errorf("required configuration value [identity.key] is missing") - } - - if value, found := fabricIdentitySubMap["server_key"]; found { - c.RootIdentityConfig.ServerKey = value.(string) - } //allow "key" to be the default, this isn't an error - - if value, found := fabricIdentitySubMap["ca"]; found { - c.RootIdentityConfig.CA = value.(string) - } - - var err error - if c.RootIdentityCaPem, err = ioutil.ReadFile(c.RootIdentityConfig.CA); err != nil { - return fmt.Errorf("could not read file CA file from [identity.ca]") - } - - c.caPems = append(c.caPems, c.RootIdentityCaPem) - - c.RootIdentity, err = identity.LoadIdentity(c.RootIdentityConfig) - - return err -} - -func (c *Config) loadApiSection(edgeConfigMap map[interface{}]interface{}) error { - c.Api = Api{} - var err error - - if value, found := edgeConfigMap["api"]; found { - submap := value.(map[interface{}]interface{}) - - if value, found := submap["listener"]; found { - c.Api.Listener = value.(string) - } else { - return errors.New("required configuration value [edge.api.listener] missing") - } - - if value, found := submap["advertise"]; found { - c.Api.Advertise = value.(string) - } else { - return errors.New("required configuration value [edge.api.advertise] missing") - } - - var intValue = 0 - if value, found := submap["sessionTimeoutMinutes"]; found { - intValue = value.(int) - } - - if intValue < sessionTimeoutMin { - intValue = sessionTimeoutDefault - pfxlog.Logger().Warn("[edge.api.sessionTimeout] defaulted to " + strconv.Itoa(intValue)) - } - - c.Api.SessionTimeoutSeconds = time.Duration(intValue) * time.Minute - - var apiIdentitySubMap map[interface{}]interface{} - if value, found = submap["identity"]; found { - apiIdentitySubMap = value.(map[interface{}]interface{}) - } - - if err = c.loadIApiIdentity(apiIdentitySubMap); err != nil { - return fmt.Errorf("error loading Edge API Identity: %s", err) - } - - } else { - return errors.New("required configuration section [edge.api] missing") - } - - return nil -} - -func (c *Config) loadIApiIdentity(apiIdentitySubMap map[interface{}]interface{}) error { - //default to root identity value - c.Api.IdentityConfig = identity.IdentityConfig{ - Key: c.RootIdentityConfig.Key, - Cert: c.RootIdentityConfig.Cert, - ServerCert: c.RootIdentityConfig.ServerCert, - ServerKey: c.RootIdentityConfig.ServerKey, - CA: c.RootIdentityConfig.CA, - } - - if apiIdentitySubMap != nil { - if value, found := apiIdentitySubMap["server_cert"]; found { - c.Api.IdentityConfig.ServerCert = value.(string) - } else { - return fmt.Errorf("configuration value [edge.api.identity.server_cert] is required if [edge.api.identity] is specified") - } - - if value, found := apiIdentitySubMap["server_key"]; found { - c.Api.IdentityConfig.ServerKey = value.(string) - } else { - return fmt.Errorf("configuration value [edge.api.identity.server_key] is required if [edge.api.identity] is specified") - } - - if value, found := apiIdentitySubMap["ca"]; found { - c.Api.IdentityConfig.CA = value.(string) - var err error - if c.Api.IdentityCaPem, err = ioutil.ReadFile(c.Api.IdentityConfig.CA); err != nil { - return fmt.Errorf("could not read file CA file from [edge.api.identity.ca]") - } - c.caPems = append(c.caPems, c.Api.IdentityCaPem) - } - } - - var err error - c.Api.Identity, err = identity.LoadIdentity(c.Api.IdentityConfig) - - return err -} - -func (c *Config) loadEnrollmentSection(edgeConfigMap map[interface{}]interface{}) error { - c.Enrollment = Enrollment{} - var err error - - if value, found := edgeConfigMap["enrollment"]; found { - submap := value.(map[interface{}]interface{}) - - if value, found := submap["signingCert"]; found { - submap := value.(map[interface{}]interface{}) - c.Enrollment.SigningCertConfig = identity.IdentityConfig{} - - if value, found := submap["cert"]; found { - c.Enrollment.SigningCertConfig.Cert = value.(string) - certPem, err := ioutil.ReadFile(c.Enrollment.SigningCertConfig.Cert) - if err != nil { - pfxlog.Logger().WithError(err).Panic("unable to read [edge.enrollment.cert]") - } - //The signer is a valid trust anchor - c.caPems = append(c.caPems, certPem) - - } else { - return fmt.Errorf("required configuration value [edge.enrollment.cert] is missing") - } - - if value, found := submap["key"]; found { - c.Enrollment.SigningCertConfig.Key = value.(string) - } else { - return fmt.Errorf("required configuration value [edge.enrollment.key] is missing") - } - - if value, found := submap["ca"]; found { - c.Enrollment.SigningCertConfig.CA = value.(string) - - if c.Enrollment.SigningCertCaPem, err = ioutil.ReadFile(c.Enrollment.SigningCertConfig.CA); err != nil { - return fmt.Errorf("could not read file CA file from [edge.enrollment.signingCert.ca]") - } - - c.caPems = append(c.caPems, c.Enrollment.SigningCertCaPem) - } //not an error if the signing cert's CA is already represented in the root [identity.ca] - - if c.Enrollment.SigningCert, err = identity.LoadIdentity(c.Enrollment.SigningCertConfig); err != nil { - return fmt.Errorf("error loading [edge.enrollment.signingCert]: %s", err) - } - - } else { - return errors.New("required configuration section [edge.enrollment.signingCert] missing") - } - - if value, found := submap["edgeIdentity"]; found { - submap := value.(map[interface{}]interface{}) - - var edgeIdentityDurationInt = 0 - if value, found := submap["durationMinutes"]; found { - edgeIdentityDurationInt = value.(int) - } - - if edgeIdentityDurationInt < enrollmentDurationMin { - edgeIdentityDurationInt = enrollmentDurationDefault - } - - c.Enrollment.EdgeIdentity = EnrollmentOption{DurationMinutes: time.Duration(edgeIdentityDurationInt) * time.Minute} - - } else { - return errors.New("required configuration section [edge.enrollment.edgeIdentity] missing") - } - - if value, found := submap["edgeRouter"]; found { - submap := value.(map[interface{}]interface{}) - - var edgeRouterDurationInt = 0 - if value, found := submap["durationMinutes"]; found { - edgeRouterDurationInt = value.(int) - } - - if edgeRouterDurationInt < enrollmentDurationMin { - edgeRouterDurationInt = enrollmentDurationDefault - } - - c.Enrollment.EdgeRouter = EnrollmentOption{DurationMinutes: time.Duration(edgeRouterDurationInt) * time.Minute} - - } else { - return errors.New("required configuration section [edge.enrollment.edgeRouter] missing") - } - - } else { - return errors.New("required configuration section [edge.enrollment] missing") - } - - return nil -} - -func (c *Config) loadPersistenceSection(edgeConfigMap map[interface{}]interface{}) error { - c.Persistence = Persistence{Postgres: &Db{}} - - if value, found := edgeConfigMap["persistence"]; found { - submap := value.(map[interface{}]interface{}) - - if value, found := submap["connectionUrl"]; found { - c.Persistence.Postgres.ConnectionUrl = value.(string) - } else { - return errors.New("required configuration value [edge.persistence.connectionUrl] missing") - } - - if value, found := submap["dbName"]; found { - c.Persistence.Postgres.DbName = value.(string) - } else { - return errors.New("required configuration value [edge.persistence.dbName] missing") - } - - } //no longer required - - return nil -} - -func LoadFromMap(cfgmap map[interface{}]interface{}) (*Config, error) { - edgeConfig := &Config{ - Enabled: false, - } - - var edgeConfigMap map[interface{}]interface{} = nil - - if val, ok := cfgmap["edge"]; ok && val != nil { - if edgeConfigMap, ok = val.(map[interface{}]interface{}); !ok { - return nil, fmt.Errorf("expected map as edge configuration") - } - } else { - return edgeConfig, nil - } - - edgeConfig.Enabled = cfgmap != nil - - if !edgeConfig.Enabled { - return edgeConfig, nil - } - - var err error - - if err = edgeConfig.loadRootIdentity(cfgmap); err != nil { - return nil, err - } - - if err = edgeConfig.loadApiSection(edgeConfigMap); err != nil { - return nil, err - } - - if err = edgeConfig.loadEnrollmentSection(edgeConfigMap); err != nil { - return nil, err - } - - if err = edgeConfig.loadPersistenceSection(edgeConfigMap); err != nil { - return nil, err - } - - return edgeConfig, nil -} - -func LoadFromFile(path string) (*Config, error) { - c := map[interface{}]interface{}{} - - f, err := os.Open(path) - - if err != nil { - return nil, err - } - - defer f.Close() - - d := yaml.NewDecoder(f) - err = d.Decode(c) - - if err != nil { - return nil, err - } - - return LoadFromMap(c) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package config + +import ( + "github.com/netfoundry/ziti-foundation/identity/identity" + "bytes" + "crypto/sha1" + "encoding/pem" + "errors" + "fmt" + "github.com/gobuffalo/packr" + "github.com/michaelquigley/pfxlog" + "gopkg.in/yaml.v2" + "io/ioutil" + "os" + "strconv" + "strings" + "sync" + "time" +) + +const ( + sessionTimeoutDefault = 10 + sessionTimeoutMin = 1 + + enrollmentDurationMin = 5 + enrollmentDurationDefault = 1440 +) + +type Db struct { + ConnectionUrl string `yaml:"connectionUrl"` + DbName string `yaml:"dbName"` +} + +type Persistence struct { + boxes []*packr.Box + Postgres *Db `yaml:"postgres"` +} + +func (p *Persistence) AddMigrationBox(b *packr.Box) { + p.boxes = append(p.boxes, b) +} + +func (p *Persistence) GetBoxes() []*packr.Box { + return p.boxes +} + +type Enrollment struct { + SigningCert identity.Identity + SigningCertConfig identity.IdentityConfig + SigningCertCaPem []byte + EdgeIdentity EnrollmentOption + EdgeRouter EnrollmentOption +} + +type EnrollmentOption struct { + DurationMinutes time.Duration +} + +type Api struct { + SessionTimeoutSeconds time.Duration + Listener string + Advertise string + Identity identity.Identity + IdentityConfig identity.IdentityConfig + IdentityCaPem []byte +} + +type Config struct { + RootIdentityConfig identity.IdentityConfig + RootIdentity identity.Identity + RootIdentityCaPem []byte + Enabled bool + Api Api + Enrollment Enrollment + Persistence Persistence + caPems [][]byte + caPemsBuf []byte + caPemsOnce sync.Once +} + +func (c *Config) SessionTimeoutDuration() time.Duration { + return c.Api.SessionTimeoutSeconds +} + +func toHex(data []byte) string { + var buf bytes.Buffer + for i, b := range data { + if i > 0 { + _, _ = fmt.Fprintf(&buf, ":") + } + _, _ = fmt.Fprintf(&buf, "%02x", b) + } + return strings.ToUpper(buf.String()) +} + +func (c *Config) CaPems() []byte { + c.caPemsOnce.Do(func() { + buf := bytes.Buffer{} + //dedupe chains + pemMap := map[string][]byte{} + for _, caChain := range c.caPems { + rest := caChain + for len(rest) != 0 { + var block *pem.Block + block, rest = pem.Decode(rest) + + if block != nil { + hash := sha1.Sum(block.Bytes) + fingerprint := toHex(hash[:]) + pemMap[fingerprint] = pem.EncodeToMemory(block) + } + } + } + + i := 0 + for _, pemBytes := range pemMap { + if i != 0 { + buf.Write([]byte("\n")) + } + buf.Write(pemBytes) + i++ + } + c.caPemsBuf = buf.Bytes() + }) + + return c.caPemsBuf +} + +func (c *Config) loadRootIdentity(fabricConfigMap map[interface{}]interface{}) error { + var fabricIdentitySubMap map[interface{}]interface{} + if value, found := fabricConfigMap["identity"]; found { + fabricIdentitySubMap = value.(map[interface{}]interface{}) + } else { + return errors.New("required configuration value [identity] missing") + } + + if value, found := fabricIdentitySubMap["cert"]; found { + c.RootIdentityConfig.Cert = value.(string) + } else { + return fmt.Errorf("required configuration value [identity.cert] is missing") + } + + if value, found := fabricIdentitySubMap["server_cert"]; found { + c.RootIdentityConfig.ServerCert = value.(string) + } else { + return fmt.Errorf("required configuration value [identity.server_cert] is missing") + } + + if value, found := fabricIdentitySubMap["key"]; found { + c.RootIdentityConfig.Key = value.(string) + } else { + return fmt.Errorf("required configuration value [identity.key] is missing") + } + + if value, found := fabricIdentitySubMap["server_key"]; found { + c.RootIdentityConfig.ServerKey = value.(string) + } //allow "key" to be the default, this isn't an error + + if value, found := fabricIdentitySubMap["ca"]; found { + c.RootIdentityConfig.CA = value.(string) + } + + var err error + if c.RootIdentityCaPem, err = ioutil.ReadFile(c.RootIdentityConfig.CA); err != nil { + return fmt.Errorf("could not read file CA file from [identity.ca]") + } + + c.caPems = append(c.caPems, c.RootIdentityCaPem) + + c.RootIdentity, err = identity.LoadIdentity(c.RootIdentityConfig) + + return err +} + +func (c *Config) loadApiSection(edgeConfigMap map[interface{}]interface{}) error { + c.Api = Api{} + var err error + + if value, found := edgeConfigMap["api"]; found { + submap := value.(map[interface{}]interface{}) + + if value, found := submap["listener"]; found { + c.Api.Listener = value.(string) + } else { + return errors.New("required configuration value [edge.api.listener] missing") + } + + if value, found := submap["advertise"]; found { + c.Api.Advertise = value.(string) + } else { + return errors.New("required configuration value [edge.api.advertise] missing") + } + + var intValue = 0 + if value, found := submap["sessionTimeoutMinutes"]; found { + intValue = value.(int) + } + + if intValue < sessionTimeoutMin { + intValue = sessionTimeoutDefault + pfxlog.Logger().Warn("[edge.api.sessionTimeout] defaulted to " + strconv.Itoa(intValue)) + } + + c.Api.SessionTimeoutSeconds = time.Duration(intValue) * time.Minute + + var apiIdentitySubMap map[interface{}]interface{} + if value, found = submap["identity"]; found { + apiIdentitySubMap = value.(map[interface{}]interface{}) + } + + if err = c.loadIApiIdentity(apiIdentitySubMap); err != nil { + return fmt.Errorf("error loading Edge API Identity: %s", err) + } + + } else { + return errors.New("required configuration section [edge.api] missing") + } + + return nil +} + +func (c *Config) loadIApiIdentity(apiIdentitySubMap map[interface{}]interface{}) error { + //default to root identity value + c.Api.IdentityConfig = identity.IdentityConfig{ + Key: c.RootIdentityConfig.Key, + Cert: c.RootIdentityConfig.Cert, + ServerCert: c.RootIdentityConfig.ServerCert, + ServerKey: c.RootIdentityConfig.ServerKey, + CA: c.RootIdentityConfig.CA, + } + + if apiIdentitySubMap != nil { + if value, found := apiIdentitySubMap["server_cert"]; found { + c.Api.IdentityConfig.ServerCert = value.(string) + } else { + return fmt.Errorf("configuration value [edge.api.identity.server_cert] is required if [edge.api.identity] is specified") + } + + if value, found := apiIdentitySubMap["server_key"]; found { + c.Api.IdentityConfig.ServerKey = value.(string) + } else { + return fmt.Errorf("configuration value [edge.api.identity.server_key] is required if [edge.api.identity] is specified") + } + + if value, found := apiIdentitySubMap["ca"]; found { + c.Api.IdentityConfig.CA = value.(string) + var err error + if c.Api.IdentityCaPem, err = ioutil.ReadFile(c.Api.IdentityConfig.CA); err != nil { + return fmt.Errorf("could not read file CA file from [edge.api.identity.ca]") + } + c.caPems = append(c.caPems, c.Api.IdentityCaPem) + } + } + + var err error + c.Api.Identity, err = identity.LoadIdentity(c.Api.IdentityConfig) + + return err +} + +func (c *Config) loadEnrollmentSection(edgeConfigMap map[interface{}]interface{}) error { + c.Enrollment = Enrollment{} + var err error + + if value, found := edgeConfigMap["enrollment"]; found { + submap := value.(map[interface{}]interface{}) + + if value, found := submap["signingCert"]; found { + submap := value.(map[interface{}]interface{}) + c.Enrollment.SigningCertConfig = identity.IdentityConfig{} + + if value, found := submap["cert"]; found { + c.Enrollment.SigningCertConfig.Cert = value.(string) + certPem, err := ioutil.ReadFile(c.Enrollment.SigningCertConfig.Cert) + if err != nil { + pfxlog.Logger().WithError(err).Panic("unable to read [edge.enrollment.cert]") + } + //The signer is a valid trust anchor + c.caPems = append(c.caPems, certPem) + + } else { + return fmt.Errorf("required configuration value [edge.enrollment.cert] is missing") + } + + if value, found := submap["key"]; found { + c.Enrollment.SigningCertConfig.Key = value.(string) + } else { + return fmt.Errorf("required configuration value [edge.enrollment.key] is missing") + } + + if value, found := submap["ca"]; found { + c.Enrollment.SigningCertConfig.CA = value.(string) + + if c.Enrollment.SigningCertCaPem, err = ioutil.ReadFile(c.Enrollment.SigningCertConfig.CA); err != nil { + return fmt.Errorf("could not read file CA file from [edge.enrollment.signingCert.ca]") + } + + c.caPems = append(c.caPems, c.Enrollment.SigningCertCaPem) + } //not an error if the signing cert's CA is already represented in the root [identity.ca] + + if c.Enrollment.SigningCert, err = identity.LoadIdentity(c.Enrollment.SigningCertConfig); err != nil { + return fmt.Errorf("error loading [edge.enrollment.signingCert]: %s", err) + } + + } else { + return errors.New("required configuration section [edge.enrollment.signingCert] missing") + } + + if value, found := submap["edgeIdentity"]; found { + submap := value.(map[interface{}]interface{}) + + var edgeIdentityDurationInt = 0 + if value, found := submap["durationMinutes"]; found { + edgeIdentityDurationInt = value.(int) + } + + if edgeIdentityDurationInt < enrollmentDurationMin { + edgeIdentityDurationInt = enrollmentDurationDefault + } + + c.Enrollment.EdgeIdentity = EnrollmentOption{DurationMinutes: time.Duration(edgeIdentityDurationInt) * time.Minute} + + } else { + return errors.New("required configuration section [edge.enrollment.edgeIdentity] missing") + } + + if value, found := submap["edgeRouter"]; found { + submap := value.(map[interface{}]interface{}) + + var edgeRouterDurationInt = 0 + if value, found := submap["durationMinutes"]; found { + edgeRouterDurationInt = value.(int) + } + + if edgeRouterDurationInt < enrollmentDurationMin { + edgeRouterDurationInt = enrollmentDurationDefault + } + + c.Enrollment.EdgeRouter = EnrollmentOption{DurationMinutes: time.Duration(edgeRouterDurationInt) * time.Minute} + + } else { + return errors.New("required configuration section [edge.enrollment.edgeRouter] missing") + } + + } else { + return errors.New("required configuration section [edge.enrollment] missing") + } + + return nil +} + +func (c *Config) loadPersistenceSection(edgeConfigMap map[interface{}]interface{}) error { + c.Persistence = Persistence{Postgres: &Db{}} + + if value, found := edgeConfigMap["persistence"]; found { + submap := value.(map[interface{}]interface{}) + + if value, found := submap["connectionUrl"]; found { + c.Persistence.Postgres.ConnectionUrl = value.(string) + } else { + return errors.New("required configuration value [edge.persistence.connectionUrl] missing") + } + + if value, found := submap["dbName"]; found { + c.Persistence.Postgres.DbName = value.(string) + } else { + return errors.New("required configuration value [edge.persistence.dbName] missing") + } + + } //no longer required + + return nil +} + +func LoadFromMap(cfgmap map[interface{}]interface{}) (*Config, error) { + edgeConfig := &Config{ + Enabled: false, + } + + var edgeConfigMap map[interface{}]interface{} = nil + + if val, ok := cfgmap["edge"]; ok && val != nil { + if edgeConfigMap, ok = val.(map[interface{}]interface{}); !ok { + return nil, fmt.Errorf("expected map as edge configuration") + } + } else { + return edgeConfig, nil + } + + edgeConfig.Enabled = cfgmap != nil + + if !edgeConfig.Enabled { + return edgeConfig, nil + } + + var err error + + if err = edgeConfig.loadRootIdentity(cfgmap); err != nil { + return nil, err + } + + if err = edgeConfig.loadApiSection(edgeConfigMap); err != nil { + return nil, err + } + + if err = edgeConfig.loadEnrollmentSection(edgeConfigMap); err != nil { + return nil, err + } + + if err = edgeConfig.loadPersistenceSection(edgeConfigMap); err != nil { + return nil, err + } + + return edgeConfig, nil +} + +func LoadFromFile(path string) (*Config, error) { + c := map[interface{}]interface{}{} + + f, err := os.Open(path) + + if err != nil { + return nil, err + } + + defer f.Close() + + d := yaml.NewDecoder(f) + err = d.Decode(c) + + if err != nil { + return nil, err + } + + return LoadFromMap(c) +} diff --git a/controller/entities/entities.go b/controller/entities/entities.go index 187ddb457..18a1294ee 100644 --- a/controller/entities/entities.go +++ b/controller/entities/entities.go @@ -1,33 +1,33 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package entities - -import "time" - -type EntityStandardFields struct { - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - Tags map[string]interface{} `json:"tags"` -} - -type SessionEntity struct { - Token string `json:"token"` - EntityStandardFields -} - -type Empty struct { -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package entities + +import "time" + +type EntityStandardFields struct { + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + Tags map[string]interface{} `json:"tags"` +} + +type SessionEntity struct { + Token string `json:"token"` + EntityStandardFields +} + +type Empty struct { +} diff --git a/controller/env/authinfo.go b/controller/env/authinfo.go index 3c0aebdd0..2de2862b1 100644 --- a/controller/env/authinfo.go +++ b/controller/env/authinfo.go @@ -1,60 +1,60 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package env - -import ( - "github.com/Jeffail/gabs" -) - -type EnvInfo struct { - Arch string `json:"arch"` - Os string `json:"os"` - OsRelease string `json:"osRelease"` - OsVersion string `json:"osVersion"` -} - -type SdkInfo struct { - Branch string `json:"branch"` - Revision string `json:"revision"` - Type string `json:"type"` - Version string `json:"version"` -} - -type Info struct { - EnvInfo *EnvInfo `json:"envInfo"` - SdkInfo *SdkInfo `json:"sdkInfo"` -} - -func ParseInfoFromBody(body []byte) (map[interface{}]interface{}, error) { - container, err := gabs.ParseJSON(body) - if err != nil { - return nil, err - } - return ParseInfoFromContainer(container) -} - -func ParseInfoFromContainer(container *gabs.Container) (map[interface{}]interface{}, error) { - info := map[interface{}]interface{}{} - - envInfo := container.Search("envInfo") - sdkInfo := container.Search("sdkInfo") - - info["envInfo"] = envInfo.Data() - info["sdkInfo"] = sdkInfo.Data() - - return info, nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package env + +import ( + "github.com/Jeffail/gabs" +) + +type EnvInfo struct { + Arch string `json:"arch"` + Os string `json:"os"` + OsRelease string `json:"osRelease"` + OsVersion string `json:"osVersion"` +} + +type SdkInfo struct { + Branch string `json:"branch"` + Revision string `json:"revision"` + Type string `json:"type"` + Version string `json:"version"` +} + +type Info struct { + EnvInfo *EnvInfo `json:"envInfo"` + SdkInfo *SdkInfo `json:"sdkInfo"` +} + +func ParseInfoFromBody(body []byte) (map[interface{}]interface{}, error) { + container, err := gabs.ParseJSON(body) + if err != nil { + return nil, err + } + return ParseInfoFromContainer(container) +} + +func ParseInfoFromContainer(container *gabs.Container) (map[interface{}]interface{}, error) { + info := map[interface{}]interface{}{} + + envInfo := container.Search("envInfo") + sdkInfo := container.Search("sdkInfo") + + info["envInfo"] = envInfo.Data() + info["sdkInfo"] = sdkInfo.Data() + + return info, nil +} diff --git a/controller/env/routers.go b/controller/env/routers.go index c3877ab81..9a0ba61d4 100644 --- a/controller/env/routers.go +++ b/controller/env/routers.go @@ -1,33 +1,33 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package env - -var routerFuncs []AddRouterFunc - -type AddRouterFunc func(ae *AppEnv) - -type ApiRouter interface { - Register(ae *AppEnv) -} - -func AddRouter(rf ApiRouter) { - routerFuncs = append(routerFuncs, rf.Register) -} - -func GetRouters() []AddRouterFunc { - return routerFuncs -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package env + +var routerFuncs []AddRouterFunc + +type AddRouterFunc func(ae *AppEnv) + +type ApiRouter interface { + Register(ae *AppEnv) +} + +func AddRouter(rf ApiRouter) { + routerFuncs = append(routerFuncs, rf.Register) +} + +func GetRouters() []AddRouterFunc { + return routerFuncs +} diff --git a/controller/internal/permissions/always.go b/controller/internal/permissions/always.go index 539faadd8..f866feba9 100644 --- a/controller/internal/permissions/always.go +++ b/controller/internal/permissions/always.go @@ -1,29 +1,29 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package permissions - -type AlwaysAllow struct{} - -var always = &AlwaysAllow{} - -func (a *AlwaysAllow) IsAllowed(_ ...string) bool { - return true -} - -func Always() *AlwaysAllow { - return always -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package permissions + +type AlwaysAllow struct{} + +var always = &AlwaysAllow{} + +func (a *AlwaysAllow) IsAllowed(_ ...string) bool { + return true +} + +func Always() *AlwaysAllow { + return always +} diff --git a/controller/internal/permissions/is_admin.go b/controller/internal/permissions/is_admin.go index 1427a38a1..08589b201 100644 --- a/controller/internal/permissions/is_admin.go +++ b/controller/internal/permissions/is_admin.go @@ -1,35 +1,35 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package permissions - -type RequireAdmin struct{} - -var requireAdmin = &RequireAdmin{} - -func IsAdmin() *RequireAdmin { - return requireAdmin -} - -func (ia *RequireAdmin) IsAllowed(identityPerms ...string) bool { - for _, p := range identityPerms { - if p == AdminPermission { - return true - } - } - - return false -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package permissions + +type RequireAdmin struct{} + +var requireAdmin = &RequireAdmin{} + +func IsAdmin() *RequireAdmin { + return requireAdmin +} + +func (ia *RequireAdmin) IsAllowed(identityPerms ...string) bool { + for _, p := range identityPerms { + if p == AdminPermission { + return true + } + } + + return false +} diff --git a/controller/internal/permissions/is_authed.go b/controller/internal/permissions/is_authed.go index 1e423b0ec..8ceae8955 100644 --- a/controller/internal/permissions/is_authed.go +++ b/controller/internal/permissions/is_authed.go @@ -1,35 +1,35 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package permissions - -type RequireAuthenticated struct{} - -var isAuthenticated = &RequireAuthenticated{} - -func IsAuthenticated() *RequireAuthenticated { - return isAuthenticated -} - -func (ir *RequireAuthenticated) IsAllowed(identityPerms ...string) bool { - for _, p := range identityPerms { - if p == AuthenticatedPermission { - return true - } - } - - return false -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package permissions + +type RequireAuthenticated struct{} + +var isAuthenticated = &RequireAuthenticated{} + +func IsAuthenticated() *RequireAuthenticated { + return isAuthenticated +} + +func (ir *RequireAuthenticated) IsAllowed(identityPerms ...string) bool { + for _, p := range identityPerms { + if p == AuthenticatedPermission { + return true + } + } + + return false +} diff --git a/controller/internal/permissions/permissions.go b/controller/internal/permissions/permissions.go index 04b0fd727..9b107e3a3 100644 --- a/controller/internal/permissions/permissions.go +++ b/controller/internal/permissions/permissions.go @@ -1,26 +1,26 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package permissions - -const ( - AdminPermission = "ADMIN" - AuthenticatedPermission = "AUTHENTICATED" -) - -type Resolver interface { - IsAllowed(...string) bool -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package permissions + +const ( + AdminPermission = "ADMIN" + AuthenticatedPermission = "AUTHENTICATED" +) + +type Resolver interface { + IsAllowed(...string) bool +} diff --git a/controller/internal/permissions/require_all.go b/controller/internal/permissions/require_all.go index fe0d5ab73..d12da7bd3 100644 --- a/controller/internal/permissions/require_all.go +++ b/controller/internal/permissions/require_all.go @@ -1,52 +1,52 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package permissions - -type RequireAll struct { - required []string -} - -func NewRequireAll(perms ...string) *RequireAll { - ra := &RequireAll{ - required: perms, - } - return ra -} - -func (ra *RequireAll) IsAllowed(identityPerms ...string) bool { - ps := map[string]bool{} - - if len(identityPerms) < len(ra.required) { - return false - } - - for _, p := range identityPerms { - ps[p] = true - - //short cut admins - if p == AdminPermission { - return true - } - } - - for _, r := range ra.required { - if _, ok := ps[r]; !ok { - return false - } - } - return true -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package permissions + +type RequireAll struct { + required []string +} + +func NewRequireAll(perms ...string) *RequireAll { + ra := &RequireAll{ + required: perms, + } + return ra +} + +func (ra *RequireAll) IsAllowed(identityPerms ...string) bool { + ps := map[string]bool{} + + if len(identityPerms) < len(ra.required) { + return false + } + + for _, p := range identityPerms { + ps[p] = true + + //short cut admins + if p == AdminPermission { + return true + } + } + + for _, r := range ra.required { + if _, ok := ps[r]; !ok { + return false + } + } + return true +} diff --git a/controller/internal/permissions/require_one.go b/controller/internal/permissions/require_one.go index 64c32fe10..cb20c02e7 100644 --- a/controller/internal/permissions/require_one.go +++ b/controller/internal/permissions/require_one.go @@ -1,47 +1,47 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package permissions - -type RequireOne struct { - required map[string]bool -} - -func NewRequireOne(perms ...string) *RequireOne { - ro := &RequireOne{} - ro.required = map[string]bool{} - - for _, p := range perms { - ro.required[p] = true - } - - return ro -} - -func (ro *RequireOne) IsAllowed(identityPerms ...string) bool { - for _, p := range identityPerms { - - //short cut admins - if p == AdminPermission { - return true - } - - if _, ok := ro.required[p]; ok { - return true - } - } - return false -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package permissions + +type RequireOne struct { + required map[string]bool +} + +func NewRequireOne(perms ...string) *RequireOne { + ro := &RequireOne{} + ro.required = map[string]bool{} + + for _, p := range perms { + ro.required[p] = true + } + + return ro +} + +func (ro *RequireOne) IsAllowed(identityPerms ...string) bool { + for _, p := range identityPerms { + + //short cut admins + if p == AdminPermission { + return true + } + + if _, ok := ro.required[p]; ok { + return true + } + } + return false +} diff --git a/controller/internal/routes/root_router.go b/controller/internal/routes/root_router.go index 20d2bfcd7..15d0efe21 100644 --- a/controller/internal/routes/root_router.go +++ b/controller/internal/routes/root_router.go @@ -71,7 +71,7 @@ func (ir *RootRouter) List(ae *env.AppEnv, rc *response.RequestContext) { "fabrics": newCrudLinks("./fabrics", ""), "fabric-types": newReadOnlyLinks("./fabric-types", ""), "event-logs": newReadOnlyLinks("./event-logs", ""), - "edge-routers": newCrudLinks("./edge-routers", ""), + "edge-routers": newCrudLinks("./edge-routers", ""), "geo-regions": newReadOnlyLinks("./geo-regions", ""), "identities": newCrudLinks("./identities", ""), "identity-types": newReadOnlyLinks("./identity-types", ""), diff --git a/controller/internal/routes/version_router.go b/controller/internal/routes/version_router.go index 879f9372c..e2ceef7a2 100644 --- a/controller/internal/routes/version_router.go +++ b/controller/internal/routes/version_router.go @@ -64,7 +64,7 @@ func (ir *VersionRouter) List(ae *env.AppEnv, rc *response.RequestContext) { pfxlog.Logger().WithField("cause", err).Panic("could not set value by path") } - if _, err := data.SetP(runtime.Version(), "runtimeVersion"); err != nil { + if _, err := data.SetP(runtime.Version(),"runtimeVersion"); err != nil { pfxlog.Logger().WithField("cause", err).Panic("could not set value by path") } diff --git a/controller/middleware/debug_logging.go b/controller/middleware/debug_logging.go index c547afab5..e278542ef 100644 --- a/controller/middleware/debug_logging.go +++ b/controller/middleware/debug_logging.go @@ -1,30 +1,30 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package middleware - -import ( - "github.com/michaelquigley/pfxlog" - "net/http" -) - -func RequestDebugLogger(next http.Handler) http.Handler { - log := pfxlog.Logger() - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - log.Debug(r.RequestURI) - next.ServeHTTP(w, r) - }) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package middleware + +import ( + "github.com/michaelquigley/pfxlog" + "net/http" +) + +func RequestDebugLogger(next http.Handler) http.Handler { + log := pfxlog.Logger() + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + log.Debug(r.RequestURI) + next.ServeHTTP(w, r) + }) +} diff --git a/controller/middleware/json.go b/controller/middleware/json.go index c86efe2ae..30d026913 100644 --- a/controller/middleware/json.go +++ b/controller/middleware/json.go @@ -1,28 +1,28 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package middleware - -import ( - "net/http" -) - -func SetResponseTypeToJson(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - next.ServeHTTP(w, r) - }) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package middleware + +import ( + "net/http" +) + +func SetResponseTypeToJson(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + next.ServeHTTP(w, r) + }) +} diff --git a/controller/middleware/response_logging.go b/controller/middleware/response_logging.go index 31c3737f1..a78c09f5e 100644 --- a/controller/middleware/response_logging.go +++ b/controller/middleware/response_logging.go @@ -1,67 +1,67 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package middleware - -import ( - "github.com/google/uuid" - "github.com/michaelquigley/pfxlog" - "net/http" -) - -type StatusWriter struct { - http.ResponseWriter - status int - length int - RequestId uuid.UUID -} - -func (w *StatusWriter) WriteHeader(status int) { - w.status = status - w.ResponseWriter.WriteHeader(status) -} - -func (w *StatusWriter) Write(b []byte) (int, error) { - if w.status == 0 { - w.status = 500 - } - n, err := w.ResponseWriter.Write(b) - w.length += n - return n, err -} - -func UseStatusWriter(next http.Handler) http.Handler { - log := pfxlog.Logger() - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - rid := uuid.New() - log.WithField("id", rid.String()). - WithField("method", r.Method). - WithField("url", r.URL.String()). - Debugf("handling request[%s]: method [%s] URL [%s]", rid.String(), r.Method, r.URL.String()) - - sw := &StatusWriter{ - ResponseWriter: w, - RequestId: rid, - } - next.ServeHTTP(sw, r) - - log.WithField("id", rid.String()). - WithField("method", r.Method). - WithField("url", r.URL.String()). - WithField("status", sw.status). - Debugf("responding for request [%s] with status [%d]: method [%s] URL [%s]", sw.RequestId.String(), sw.status, r.Method, r.URL.String()) - }) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package middleware + +import ( + "github.com/google/uuid" + "github.com/michaelquigley/pfxlog" + "net/http" +) + +type StatusWriter struct { + http.ResponseWriter + status int + length int + RequestId uuid.UUID +} + +func (w *StatusWriter) WriteHeader(status int) { + w.status = status + w.ResponseWriter.WriteHeader(status) +} + +func (w *StatusWriter) Write(b []byte) (int, error) { + if w.status == 0 { + w.status = 500 + } + n, err := w.ResponseWriter.Write(b) + w.length += n + return n, err +} + +func UseStatusWriter(next http.Handler) http.Handler { + log := pfxlog.Logger() + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + rid := uuid.New() + log.WithField("id", rid.String()). + WithField("method", r.Method). + WithField("url", r.URL.String()). + Debugf("handling request[%s]: method [%s] URL [%s]", rid.String(), r.Method, r.URL.String()) + + sw := &StatusWriter{ + ResponseWriter: w, + RequestId: rid, + } + next.ServeHTTP(sw, r) + + log.WithField("id", rid.String()). + WithField("method", r.Method). + WithField("url", r.URL.String()). + WithField("status", sw.status). + Debugf("responding for request [%s] with status [%d]: method [%s] URL [%s]", sw.RequestId.String(), sw.status, r.Method, r.URL.String()) + }) +} diff --git a/controller/model/appwan_model.go b/controller/model/appwan_model.go index 33f6849e7..239161db1 100644 --- a/controller/model/appwan_model.go +++ b/controller/model/appwan_model.go @@ -71,4 +71,4 @@ func (entity *Appwan) FillFrom(handler Handler, tx *bbolt.Tx, boltEntity boltz.B entity.Identities = boltAppwan.Identities entity.Services = boltAppwan.Services return nil -} +} \ No newline at end of file diff --git a/controller/model/base_model.go b/controller/model/base_model.go index c704f321c..d6387c72f 100644 --- a/controller/model/base_model.go +++ b/controller/model/base_model.go @@ -100,4 +100,4 @@ func ValidateEntityList(tx *bbolt.Tx, store boltz.ListStore, field string, ids [ return NewFieldError(fmt.Sprintf("%v(s) not found", store.GetEntityType()), field, invalidIds) } return nil -} +} \ No newline at end of file diff --git a/controller/model/errors.go b/controller/model/errors.go index 1272433a4..e33072144 100644 --- a/controller/model/errors.go +++ b/controller/model/errors.go @@ -1,47 +1,48 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package model - -import "fmt" - -const ( - maxFieldErrorValueLength = 20 -) - -type FieldError struct { - Reason string - FieldName string - FieldValue interface{} -} - -func (fe FieldError) Error() string { - v := fe.FieldValue - if s, ok := fe.FieldValue.(string); ok { - if len(s) > maxFieldErrorValueLength { - v = s[0:maxFieldErrorValueLength] + "..." - } - } - return fmt.Sprintf("the value '%v' for '%s' is invalid: %s", v, fe.FieldName, fe.Reason) -} - -func NewFieldError(reason, name string, value interface{}) *FieldError { - return &FieldError{ - Reason: reason, - FieldName: name, - FieldValue: value, - } -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package model + +import "fmt" + +const ( + maxFieldErrorValueLength = 20 +) + +type FieldError struct { + Reason string + FieldName string + FieldValue interface{} +} + +func (fe FieldError) Error() string { + v := fe.FieldValue + if s, ok := fe.FieldValue.(string); ok { + if len(s) > maxFieldErrorValueLength { + v = s[0:maxFieldErrorValueLength] + "..." + } + } + return fmt.Sprintf("the value '%v' for '%s' is invalid: %s", v, fe.FieldName, fe.Reason) +} + +func NewFieldError(reason, name string, value interface{}) *FieldError { + return &FieldError{ + Reason: reason, + FieldName: name, + FieldValue: value, + } +} + diff --git a/controller/model/query_options.go b/controller/model/query_options.go index 00f021e23..02cacbc67 100644 --- a/controller/model/query_options.go +++ b/controller/model/query_options.go @@ -116,4 +116,4 @@ func (qo *QueryOptions) getFullQuery(predicate string) string { } } return queryBuilder.String() -} +} \ No newline at end of file diff --git a/controller/packrsource/source.go b/controller/packrsource/source.go index f9cf7d2e5..41a508c6e 100644 --- a/controller/packrsource/source.go +++ b/controller/packrsource/source.go @@ -1,187 +1,187 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package packrsource - -import ( - "bytes" - "fmt" - "github.com/gobuffalo/packr" - "github.com/golang-migrate/migrate/source" - "io" - "io/ioutil" - "net/http" - nurl "net/url" - "os" - "path" - "path/filepath" -) - -type Packr struct { - url string - path string - migrations *source.Migrations - boxes []*packr.Box - boxMap map[string]*packr.Box -} - -func NewPakrSource(bs ...*packr.Box) *Packr { - return &Packr{ - boxes: bs, - } -} - -func (f *Packr) Open(url string) (source.Driver, error) { - u, err := nurl.Parse(url) - if err != nil { - return nil, err - } - - // concat host and path to restore full path - // host might be `.` - p := u.Host + u.Path - - if len(p) == 0 { - // default to current directory if no path - wd, err := os.Getwd() - if err != nil { - return nil, err - } - p = wd - - } - - nf := &Packr{ - url: url, - path: p, - migrations: source.NewMigrations(), - boxes: f.boxes, - boxMap: map[string]*packr.Box{}, - } - for _, box := range f.boxes { - curBox := box - err = curBox.WalkPrefix(p, func(s string, f packr.File) error { - fi, _ := f.FileInfo() - if !fi.IsDir() { - fn := filepath.Base(fi.Name()) - nf.boxMap[fn] = curBox - m, err := source.DefaultParse(fn) - - if err != nil { - // ignore files that we can't parse - return nil - } - if !nf.migrations.Append(m) { - return fmt.Errorf("unable to add file, null or possible duplicate: %v", fi.Name()) - } - } - return nil - }) - - if err != nil { - return nil, err - } - } - - return nf, nil -} - -func (f *Packr) Close() error { - // nothing do to here - return nil -} - -func (f *Packr) First() (version uint, err error) { - if v, ok := f.migrations.First(); !ok { - return 0, &os.PathError{Op: "first", Path: f.path, Err: os.ErrNotExist} - } else { - return v, nil - } -} - -func (f *Packr) Prev(version uint) (prevVersion uint, err error) { - if v, ok := f.migrations.Prev(version); !ok { - return 0, &os.PathError{Op: fmt.Sprintf("prev for version %v", version), Path: f.path, Err: os.ErrNotExist} - } else { - return v, nil - } -} - -func (f *Packr) Next(version uint) (nextVersion uint, err error) { - if v, ok := f.migrations.Next(version); !ok { - return 0, &os.PathError{Op: fmt.Sprintf("next for version %v", version), Path: f.path, Err: os.ErrNotExist} - } else { - return v, nil - } -} - -func (f *Packr) ReadUp(version uint) (r io.ReadCloser, identifier string, err error) { - if m, ok := f.migrations.Up(version); ok { - box := f.boxMap[m.Raw] - r, err := box.Open(path.Join(f.path, m.Raw)) - - if err != nil { - return nil, "", err - } - - fb, err := toMemeoryBuff(r) - - if err != nil { - return nil, "", err - } - return fb, m.Identifier, nil - } - return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: f.path, Err: os.ErrNotExist} -} - -func (f *Packr) ReadDown(version uint) (r io.ReadCloser, identifier string, err error) { - if m, ok := f.migrations.Down(version); ok { - box := f.boxMap[m.Raw] - r, err := box.Open(path.Join(f.path, m.Raw)) - - if err != nil { - return nil, "", err - } - - fb, err := toMemeoryBuff(r) - - if err != nil { - return nil, "", err - } - return fb, m.Identifier, nil - } - return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: f.path, Err: os.ErrNotExist} -} - -type nopCloser struct { - io.Reader -} - -func (nopCloser) Close() error { return nil } - -//Patch the io.ReadCloser from packr as the migration engine depends -//on a full implementation -func toMemeoryBuff(r http.File) (io.ReadCloser, error) { - b, err := ioutil.ReadAll(r) - - if err != nil { - return nil, err - } - - fb := bytes.NewBuffer(b) - - return nopCloser{fb}, nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package packrsource + +import ( + "bytes" + "fmt" + "github.com/gobuffalo/packr" + "github.com/golang-migrate/migrate/source" + "io" + "io/ioutil" + "net/http" + nurl "net/url" + "os" + "path" + "path/filepath" +) + +type Packr struct { + url string + path string + migrations *source.Migrations + boxes []*packr.Box + boxMap map[string]*packr.Box +} + +func NewPakrSource(bs ...*packr.Box) *Packr { + return &Packr{ + boxes: bs, + } +} + +func (f *Packr) Open(url string) (source.Driver, error) { + u, err := nurl.Parse(url) + if err != nil { + return nil, err + } + + // concat host and path to restore full path + // host might be `.` + p := u.Host + u.Path + + if len(p) == 0 { + // default to current directory if no path + wd, err := os.Getwd() + if err != nil { + return nil, err + } + p = wd + + } + + nf := &Packr{ + url: url, + path: p, + migrations: source.NewMigrations(), + boxes: f.boxes, + boxMap: map[string]*packr.Box{}, + } + for _, box := range f.boxes { + curBox := box + err = curBox.WalkPrefix(p, func(s string, f packr.File) error { + fi, _ := f.FileInfo() + if !fi.IsDir() { + fn := filepath.Base(fi.Name()) + nf.boxMap[fn] = curBox + m, err := source.DefaultParse(fn) + + if err != nil { + // ignore files that we can't parse + return nil + } + if !nf.migrations.Append(m) { + return fmt.Errorf("unable to add file, null or possible duplicate: %v", fi.Name()) + } + } + return nil + }) + + if err != nil { + return nil, err + } + } + + return nf, nil +} + +func (f *Packr) Close() error { + // nothing do to here + return nil +} + +func (f *Packr) First() (version uint, err error) { + if v, ok := f.migrations.First(); !ok { + return 0, &os.PathError{Op: "first", Path: f.path, Err: os.ErrNotExist} + } else { + return v, nil + } +} + +func (f *Packr) Prev(version uint) (prevVersion uint, err error) { + if v, ok := f.migrations.Prev(version); !ok { + return 0, &os.PathError{Op: fmt.Sprintf("prev for version %v", version), Path: f.path, Err: os.ErrNotExist} + } else { + return v, nil + } +} + +func (f *Packr) Next(version uint) (nextVersion uint, err error) { + if v, ok := f.migrations.Next(version); !ok { + return 0, &os.PathError{Op: fmt.Sprintf("next for version %v", version), Path: f.path, Err: os.ErrNotExist} + } else { + return v, nil + } +} + +func (f *Packr) ReadUp(version uint) (r io.ReadCloser, identifier string, err error) { + if m, ok := f.migrations.Up(version); ok { + box := f.boxMap[m.Raw] + r, err := box.Open(path.Join(f.path, m.Raw)) + + if err != nil { + return nil, "", err + } + + fb, err := toMemeoryBuff(r) + + if err != nil { + return nil, "", err + } + return fb, m.Identifier, nil + } + return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: f.path, Err: os.ErrNotExist} +} + +func (f *Packr) ReadDown(version uint) (r io.ReadCloser, identifier string, err error) { + if m, ok := f.migrations.Down(version); ok { + box := f.boxMap[m.Raw] + r, err := box.Open(path.Join(f.path, m.Raw)) + + if err != nil { + return nil, "", err + } + + fb, err := toMemeoryBuff(r) + + if err != nil { + return nil, "", err + } + return fb, m.Identifier, nil + } + return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: f.path, Err: os.ErrNotExist} +} + +type nopCloser struct { + io.Reader +} + +func (nopCloser) Close() error { return nil } + +//Patch the io.ReadCloser from packr as the migration engine depends +//on a full implementation +func toMemeoryBuff(r http.File) (io.ReadCloser, error) { + b, err := ioutil.ReadAll(r) + + if err != nil { + return nil, err + } + + fb := bytes.NewBuffer(b) + + return nopCloser{fb}, nil +} diff --git a/controller/persistence/migration_v1.go b/controller/persistence/migration_v1.go index b464760e4..eb2c36719 100644 --- a/controller/persistence/migration_v1.go +++ b/controller/persistence/migration_v1.go @@ -1,77 +1,77 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package persistence - -var geoRegionsV1 = map[string]string{ - "a0e2c29f-9922-4435-a8a7-5dbf7bd92377": "Canada Central", - "ac469973-105c-4de1-9f31-fffc077487fb": "US West", - "2360479d-cc08-4224-bd56-43baa672af30": "Japan", - "edd0680f-3ab4-49e6-9db5-c68258ba480d": "Australia", - "521a3db9-8140-4854-a782-61cb5d3fe043": "South America", - "8342acad-4e49-4098-84de-829feb55d350": "Korea", - "b5562b15-ffeb-4910-bf14-a03067f9ca2e": "US Midwest", - "6efe28a5-744e-464d-b147-4072efb769f0": "Canada West", - "10c6f648-92b7-49e2-be96-f62357ea572f": "Europe West", - "72946251-1fc7-4b3b-8568-c59d4723e704": "Africa", - "70438d63-97b3-48b2-aeb5-b066a9526456": "Europe East", - "e339d699-7f51-4e9c-a2ca-81720e07f196": "US South", - "00586703-6748-4c78-890d-efa216f21ef3": "Canada East", - "63f7200b-7794-4a68-92aa-a36ed338ecba": "Asia", - "f91ecca3-6f82-4c7b-8191-ea0036ce7b5a": "US East", - "41929e78-6674-4708-89d2-9b934ea96822": "Middle East", - "5d0042bb-6fd5-4959-90a7-6bca70e23f76": "US Central", -} - -func createGeoRegionsV1(mtx *MigrationContext) error { - for id, name := range geoRegionsV1 { - geoRegion := &GeoRegion{ - BaseEdgeEntityImpl: *NewBaseEdgeEntity(id, nil), - Name: name, - } - - err := mtx.Stores.GeoRegion.Create(mtx.Ctx, geoRegion) - - if err != nil { - return err - } - } - - return nil -} - -var IdentityTypesV1 = map[string]string{ - "577104f2-1e3a-4947-a927-7383baefbc9a": "User", - "5b53fb49-51b1-4a87-a4e4-edda9716a970": "Device", - "c4d66f9d-fe18-4143-85d3-74329c54282b": "Service", -} - -func createIdentityTypesV1(mtx *MigrationContext) error { - for id, name := range IdentityTypesV1 { - identityType := &IdentityType{ - BaseEdgeEntityImpl: *NewBaseEdgeEntity(id, nil), - Name: name, - } - - err := mtx.Stores.IdentityType.Create(mtx.Ctx, identityType) - - if err != nil { - return err - } - } - - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package persistence + +var geoRegionsV1 = map[string]string{ + "a0e2c29f-9922-4435-a8a7-5dbf7bd92377": "Canada Central", + "ac469973-105c-4de1-9f31-fffc077487fb": "US West", + "2360479d-cc08-4224-bd56-43baa672af30": "Japan", + "edd0680f-3ab4-49e6-9db5-c68258ba480d": "Australia", + "521a3db9-8140-4854-a782-61cb5d3fe043": "South America", + "8342acad-4e49-4098-84de-829feb55d350": "Korea", + "b5562b15-ffeb-4910-bf14-a03067f9ca2e": "US Midwest", + "6efe28a5-744e-464d-b147-4072efb769f0": "Canada West", + "10c6f648-92b7-49e2-be96-f62357ea572f": "Europe West", + "72946251-1fc7-4b3b-8568-c59d4723e704": "Africa", + "70438d63-97b3-48b2-aeb5-b066a9526456": "Europe East", + "e339d699-7f51-4e9c-a2ca-81720e07f196": "US South", + "00586703-6748-4c78-890d-efa216f21ef3": "Canada East", + "63f7200b-7794-4a68-92aa-a36ed338ecba": "Asia", + "f91ecca3-6f82-4c7b-8191-ea0036ce7b5a": "US East", + "41929e78-6674-4708-89d2-9b934ea96822": "Middle East", + "5d0042bb-6fd5-4959-90a7-6bca70e23f76": "US Central", +} + +func createGeoRegionsV1(mtx *MigrationContext) error { + for id, name := range geoRegionsV1 { + geoRegion := &GeoRegion{ + BaseEdgeEntityImpl: *NewBaseEdgeEntity(id, nil), + Name: name, + } + + err := mtx.Stores.GeoRegion.Create(mtx.Ctx, geoRegion) + + if err != nil { + return err + } + } + + return nil +} + +var IdentityTypesV1 = map[string]string{ + "577104f2-1e3a-4947-a927-7383baefbc9a": "User", + "5b53fb49-51b1-4a87-a4e4-edda9716a970": "Device", + "c4d66f9d-fe18-4143-85d3-74329c54282b": "Service", +} + +func createIdentityTypesV1(mtx *MigrationContext) error { + for id, name := range IdentityTypesV1 { + identityType := &IdentityType{ + BaseEdgeEntityImpl: *NewBaseEdgeEntity(id, nil), + Name: name, + } + + err := mtx.Stores.IdentityType.Create(mtx.Ctx, identityType) + + if err != nil { + return err + } + } + + return nil +} diff --git a/controller/predicate/model.go b/controller/predicate/model.go index 5f03fef9b..3219bfe7b 100644 --- a/controller/predicate/model.go +++ b/controller/predicate/model.go @@ -1,340 +1,340 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package predicate - -import ( - "github.com/michaelquigley/pfxlog" - "gopkg.in/Masterminds/squirrel.v1" -) - -type ConjType string - -const ( - AndConj ConjType = "AND" - OrConj ConjType = "OR" -) - -type ResolverType string - -const ( - ConjResolver ResolverType = "CONJ" - GroupResolver ResolverType = "GROUP" - OpResolver ResolverType = "OP" -) - -type OpType string - -const ( - EqOp OpType = "=" - NeqOp OpType = "!=" - BetweenOp OpType = "BETWEEN" - NotBetweenOp OpType = "NOT BETWEEN" - InOp OpType = "IN" - NotInOp OpType = "NOT IN" - ContainsOp OpType = "CONTAINS" - NotContainsOp OpType = "NOT CONTAINS" - LtOp OpType = "<" - LtEOp OpType = "<=" - GtOp OpType = ">" - GtEOp OpType = ">=" -) - -type ValueType string - -const ( - StringType ValueType = "STRING" - NumberType ValueType = "NUMBER" - DatetimeType ValueType = "DATETIME" - BoolType ValueType = "BOOL" - NullType ValueType = "NULL" - StringArrayType ValueType = "STRING_ARRAY" - NumberArrayType ValueType = "NUMBER_ARRAY" - DatetimeArrayType ValueType = "DATETIME_ARRAY" -) - -type OpSet map[OpType]bool - -func (os *OpSet) Merge(os2 *OpSet) { - for k, v := range *os2 { - (*os)[k] = v - } -} - -type IdentifierOps map[string]OpSet - -func (io *IdentifierOps) Merge(io2 *IdentifierOps) { - for k, v := range *io2 { - if g, found := (*io)[k]; found { - g.Merge(&v) - } else { - (*io)[k] = v - } - } -} - -type IdentifierTranslations map[string]string - -type resolver interface { - Resolve() (squirrel.Sqlizer, IdentifierOps) - ResolverType() ResolverType -} - -type conj interface { - Resolve() (squirrel.Sqlizer, IdentifierOps) - ResolverType() ResolverType - ConjType() ConjType - Append(r resolver) -} - -type group struct { - Parent *group - conjugations []conj - operations []resolver - resolverType ResolverType -} - -func newGroup(parent *group) *group { - return &group{ - Parent: parent, - conjugations: []conj{}, - operations: []resolver{}, - resolverType: GroupResolver, - } -} - -func (g *group) Resolve() (squirrel.Sqlizer, IdentifierOps) { - if len(g.conjugations) == 0 { - - if len(g.operations) == 0 { - return nil, nil - } - - switch len(g.operations) { - case 1: - return g.operations[0].Resolve() - default: - pfxlog.Logger().Panic("Invalid number of operations") - } - } - - var root conj - - ops := g.operations - - for i, curConj := range g.conjugations { - if i == 0 { - root = curConj - } - - // One or in a group causes the entire root clause to swap to an OR - if root.ConjType() != OrConj && curConj.ConjType() == OrConj { - curConj.Append(root) - root = curConj - } - - var prevConj conj - - if i > 0 { - prevConj = g.conjugations[i-1] - } - - if len(ops) == 0 { - break - } - - var r resolver - switch { - case prevConj == nil && curConj.ConjType() == AndConj: - //First ANDs consume 2 ops - r, ops = ops[0], ops[1:] - curConj.Append(r) - - if len(ops) == 0 { - break - } - - r, ops = ops[0], ops[1:] - curConj.Append(r) - - case prevConj == nil && curConj.ConjType() == OrConj: - //First ORs consume 1 op - r, ops = ops[0], ops[1:] - curConj.Append(r) - - //..unless there are no other conjs e.g. (a=1 or b=2) - onLastConj := i >= len(g.conjugations)-1 - if onLastConj || g.conjugations[i+1].ConjType() == OrConj { - r, ops = ops[0], ops[1:] - root.Append(r) - } - - case prevConj.ConjType() == AndConj && curConj.ConjType() == AndConj: - // serial ANDs after the first consume 1 op (e.g a=1 AND b=3 AND c=3) - r, ops = ops[0], ops[1:] - prevConj.Append(r) - - case prevConj.ConjType() == OrConj && curConj.ConjType() == AndConj: - // swapping from OR to AND means this is the new first AND of potentially serial ANDs, consume 2 ops - r, ops = ops[0], ops[1:] - curConj.Append(r) - - if len(ops) == 0 { - break - } - - r, ops = ops[0], ops[1:] - curConj.Append(r) - - root.Append(curConj) - - case curConj.ConjType() == OrConj: - // ors only consume tokens if they are the last conj, always append ors to root OR (1 or makes root an OR) - onLastConj := i >= len(g.conjugations)-1 - if len(ops) > 0 && (onLastConj || g.conjugations[i+1].ConjType() == OrConj) { - r, ops = ops[0], ops[1:] - root.Append(r) - } - - //only append if we are also not root - if root != curConj { - root.Append(curConj) - } - default: - - panic("unhandled case") - } - - } - - if len(ops) != 0 { - panic("ops left behind") - } - - return root.Resolve() -} - -func (g *group) ResolverType() ResolverType { - return g.resolverType -} - -type op struct { - op squirrel.Sqlizer - resolverType ResolverType - identifier string - value interface{} - opType OpType - valueType ValueType -} - -func newOp(o squirrel.Sqlizer, identifier string, opType OpType, value interface{}, valueType ValueType) resolver { - return &op{ - op: o, - resolverType: OpResolver, - identifier: identifier, - opType: opType, - value: value, - valueType: valueType, - } -} - -func (o *op) Resolve() (squirrel.Sqlizer, IdentifierOps) { - i := IdentifierOps{ - o.identifier: OpSet{ - o.opType: true, - }, - } - - return o.op, i -} - -func (o *op) ResolverType() ResolverType { - return o.resolverType -} - -type and struct { - resolverType ResolverType - conjType ConjType - resolvers []resolver -} - -func newAnd() *and { - return &and{ - resolverType: ConjResolver, - conjType: AndConj, - resolvers: []resolver{}, - } -} - -func (a *and) Resolve() (squirrel.Sqlizer, IdentifierOps) { - sos := []squirrel.Sqlizer{} - io := IdentifierOps{} - for _, r := range a.resolvers { - so, io2 := r.Resolve() - sos = append(sos, so) - io.Merge(&io2) - } - return squirrel.And(sos), io -} - -func (a *and) ResolverType() ResolverType { - return a.resolverType -} - -func (a *and) ConjType() ConjType { - return a.conjType -} - -func (a *and) Append(op resolver) { - a.resolvers = append(a.resolvers, op) -} - -type or struct { - resolverType ResolverType - conjType ConjType - resolvers []resolver -} - -func newOr() *or { - return &or{ - resolverType: ConjResolver, - conjType: OrConj, - resolvers: []resolver{}, - } -} - -func (o *or) Resolve() (squirrel.Sqlizer, IdentifierOps) { - sos := []squirrel.Sqlizer{} - io := IdentifierOps{} - for _, r := range o.resolvers { - so, io2 := r.Resolve() - sos = append(sos, so) - io.Merge(&io2) - } - return squirrel.Or(sos), io -} - -func (o *or) ResolverType() ResolverType { - return ConjResolver -} - -func (o *or) ConjType() ConjType { - return o.conjType -} - -func (o *or) Append(op resolver) { - o.resolvers = append(o.resolvers, op) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package predicate + +import ( + "github.com/michaelquigley/pfxlog" + "gopkg.in/Masterminds/squirrel.v1" +) + +type ConjType string + +const ( + AndConj ConjType = "AND" + OrConj ConjType = "OR" +) + +type ResolverType string + +const ( + ConjResolver ResolverType = "CONJ" + GroupResolver ResolverType = "GROUP" + OpResolver ResolverType = "OP" +) + +type OpType string + +const ( + EqOp OpType = "=" + NeqOp OpType = "!=" + BetweenOp OpType = "BETWEEN" + NotBetweenOp OpType = "NOT BETWEEN" + InOp OpType = "IN" + NotInOp OpType = "NOT IN" + ContainsOp OpType = "CONTAINS" + NotContainsOp OpType = "NOT CONTAINS" + LtOp OpType = "<" + LtEOp OpType = "<=" + GtOp OpType = ">" + GtEOp OpType = ">=" +) + +type ValueType string + +const ( + StringType ValueType = "STRING" + NumberType ValueType = "NUMBER" + DatetimeType ValueType = "DATETIME" + BoolType ValueType = "BOOL" + NullType ValueType = "NULL" + StringArrayType ValueType = "STRING_ARRAY" + NumberArrayType ValueType = "NUMBER_ARRAY" + DatetimeArrayType ValueType = "DATETIME_ARRAY" +) + +type OpSet map[OpType]bool + +func (os *OpSet) Merge(os2 *OpSet) { + for k, v := range *os2 { + (*os)[k] = v + } +} + +type IdentifierOps map[string]OpSet + +func (io *IdentifierOps) Merge(io2 *IdentifierOps) { + for k, v := range *io2 { + if g, found := (*io)[k]; found { + g.Merge(&v) + } else { + (*io)[k] = v + } + } +} + +type IdentifierTranslations map[string]string + +type resolver interface { + Resolve() (squirrel.Sqlizer, IdentifierOps) + ResolverType() ResolverType +} + +type conj interface { + Resolve() (squirrel.Sqlizer, IdentifierOps) + ResolverType() ResolverType + ConjType() ConjType + Append(r resolver) +} + +type group struct { + Parent *group + conjugations []conj + operations []resolver + resolverType ResolverType +} + +func newGroup(parent *group) *group { + return &group{ + Parent: parent, + conjugations: []conj{}, + operations: []resolver{}, + resolverType: GroupResolver, + } +} + +func (g *group) Resolve() (squirrel.Sqlizer, IdentifierOps) { + if len(g.conjugations) == 0 { + + if len(g.operations) == 0 { + return nil, nil + } + + switch len(g.operations) { + case 1: + return g.operations[0].Resolve() + default: + pfxlog.Logger().Panic("Invalid number of operations") + } + } + + var root conj + + ops := g.operations + + for i, curConj := range g.conjugations { + if i == 0 { + root = curConj + } + + // One or in a group causes the entire root clause to swap to an OR + if root.ConjType() != OrConj && curConj.ConjType() == OrConj { + curConj.Append(root) + root = curConj + } + + var prevConj conj + + if i > 0 { + prevConj = g.conjugations[i-1] + } + + if len(ops) == 0 { + break + } + + var r resolver + switch { + case prevConj == nil && curConj.ConjType() == AndConj: + //First ANDs consume 2 ops + r, ops = ops[0], ops[1:] + curConj.Append(r) + + if len(ops) == 0 { + break + } + + r, ops = ops[0], ops[1:] + curConj.Append(r) + + case prevConj == nil && curConj.ConjType() == OrConj: + //First ORs consume 1 op + r, ops = ops[0], ops[1:] + curConj.Append(r) + + //..unless there are no other conjs e.g. (a=1 or b=2) + onLastConj := i >= len(g.conjugations)-1 + if onLastConj || g.conjugations[i+1].ConjType() == OrConj { + r, ops = ops[0], ops[1:] + root.Append(r) + } + + case prevConj.ConjType() == AndConj && curConj.ConjType() == AndConj: + // serial ANDs after the first consume 1 op (e.g a=1 AND b=3 AND c=3) + r, ops = ops[0], ops[1:] + prevConj.Append(r) + + case prevConj.ConjType() == OrConj && curConj.ConjType() == AndConj: + // swapping from OR to AND means this is the new first AND of potentially serial ANDs, consume 2 ops + r, ops = ops[0], ops[1:] + curConj.Append(r) + + if len(ops) == 0 { + break + } + + r, ops = ops[0], ops[1:] + curConj.Append(r) + + root.Append(curConj) + + case curConj.ConjType() == OrConj: + // ors only consume tokens if they are the last conj, always append ors to root OR (1 or makes root an OR) + onLastConj := i >= len(g.conjugations)-1 + if len(ops) > 0 && (onLastConj || g.conjugations[i+1].ConjType() == OrConj) { + r, ops = ops[0], ops[1:] + root.Append(r) + } + + //only append if we are also not root + if root != curConj { + root.Append(curConj) + } + default: + + panic("unhandled case") + } + + } + + if len(ops) != 0 { + panic("ops left behind") + } + + return root.Resolve() +} + +func (g *group) ResolverType() ResolverType { + return g.resolverType +} + +type op struct { + op squirrel.Sqlizer + resolverType ResolverType + identifier string + value interface{} + opType OpType + valueType ValueType +} + +func newOp(o squirrel.Sqlizer, identifier string, opType OpType, value interface{}, valueType ValueType) resolver { + return &op{ + op: o, + resolverType: OpResolver, + identifier: identifier, + opType: opType, + value: value, + valueType: valueType, + } +} + +func (o *op) Resolve() (squirrel.Sqlizer, IdentifierOps) { + i := IdentifierOps{ + o.identifier: OpSet{ + o.opType: true, + }, + } + + return o.op, i +} + +func (o *op) ResolverType() ResolverType { + return o.resolverType +} + +type and struct { + resolverType ResolverType + conjType ConjType + resolvers []resolver +} + +func newAnd() *and { + return &and{ + resolverType: ConjResolver, + conjType: AndConj, + resolvers: []resolver{}, + } +} + +func (a *and) Resolve() (squirrel.Sqlizer, IdentifierOps) { + sos := []squirrel.Sqlizer{} + io := IdentifierOps{} + for _, r := range a.resolvers { + so, io2 := r.Resolve() + sos = append(sos, so) + io.Merge(&io2) + } + return squirrel.And(sos), io +} + +func (a *and) ResolverType() ResolverType { + return a.resolverType +} + +func (a *and) ConjType() ConjType { + return a.conjType +} + +func (a *and) Append(op resolver) { + a.resolvers = append(a.resolvers, op) +} + +type or struct { + resolverType ResolverType + conjType ConjType + resolvers []resolver +} + +func newOr() *or { + return &or{ + resolverType: ConjResolver, + conjType: OrConj, + resolvers: []resolver{}, + } +} + +func (o *or) Resolve() (squirrel.Sqlizer, IdentifierOps) { + sos := []squirrel.Sqlizer{} + io := IdentifierOps{} + for _, r := range o.resolvers { + so, io2 := r.Resolve() + sos = append(sos, so) + io.Merge(&io2) + } + return squirrel.Or(sos), io +} + +func (o *or) ResolverType() ResolverType { + return ConjResolver +} + +func (o *or) ConjType() ConjType { + return o.conjType +} + +func (o *or) Append(op resolver) { + o.resolvers = append(o.resolvers, op) +} diff --git a/controller/predicate/ops.go b/controller/predicate/ops.go index 706cbe5e5..e526b90c3 100644 --- a/controller/predicate/ops.go +++ b/controller/predicate/ops.go @@ -1,117 +1,117 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package predicate - -import ( - "fmt" - "gopkg.in/Masterminds/squirrel.v1" -) - -//type Sqlizer interface { -// Parts() (string, []interface{}, error) -//} - -type binaryOp struct { - Identifier string - LeftValue interface{} - RightValue interface{} -} - -type unaryOp struct { - Identifier string - value interface{} -} - -type Between binaryOp - -func newBetween(identifier string, leftValue, rightValue interface{}) Between { - return Between{ - Identifier: identifier, - LeftValue: leftValue, - RightValue: rightValue, - } -} - -func (b Between) ToSql() (string, []interface{}, error) { - args := []interface{}{b.LeftValue, b.RightValue} - sql := fmt.Sprintf("%s BETWEEN %s AND %s", b.Identifier, "?", "?") - return sql, args, nil -} - -type NotBetween binaryOp - -func newNotBetween(identifier string, leftValue, rightValue interface{}) NotBetween { - return NotBetween{ - Identifier: identifier, - LeftValue: leftValue, - RightValue: rightValue, - } -} - -func (b NotBetween) ToSql() (string, []interface{}, error) { - args := []interface{}{b.LeftValue, b.RightValue} - sql := fmt.Sprintf("%s NOT BETWEEN %s AND %s", b.Identifier, "?", "?") - return sql, args, nil -} - -type Contains unaryOp - -func newContains(identifier, value string) Contains { - return Contains{ - Identifier: identifier, - value: value, - } -} - -func (c Contains) ToSql() (string, []interface{}, error) { - v := fmt.Sprintf("%%%s%%", c.value) - - args := []interface{}{v} - - sql := fmt.Sprintf("%s LIKE %s", c.Identifier, "?") - - return sql, args, nil -} - -type NotContains unaryOp - -func newNotContains(identifier, value string) NotContains { - return NotContains{ - Identifier: identifier, - value: value, - } -} - -func (c NotContains) ToSql() (string, []interface{}, error) { - v := fmt.Sprintf("%%%s%%", c.value) - - args := []interface{}{v} - - sql := fmt.Sprintf("%s NOT LIKE %s", c.Identifier, "?") - - return sql, args, nil -} - -type InSubSelect struct { - Column string - Select squirrel.SelectBuilder -} - -func (ss InSubSelect) ToSql() (string, []interface{}, error) { - s, b, err := ss.Select.ToSql() - return fmt.Sprintf("%s IN (%s)", ss.Column, s), b, err -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package predicate + +import ( + "fmt" + "gopkg.in/Masterminds/squirrel.v1" +) + +//type Sqlizer interface { +// Parts() (string, []interface{}, error) +//} + +type binaryOp struct { + Identifier string + LeftValue interface{} + RightValue interface{} +} + +type unaryOp struct { + Identifier string + value interface{} +} + +type Between binaryOp + +func newBetween(identifier string, leftValue, rightValue interface{}) Between { + return Between{ + Identifier: identifier, + LeftValue: leftValue, + RightValue: rightValue, + } +} + +func (b Between) ToSql() (string, []interface{}, error) { + args := []interface{}{b.LeftValue, b.RightValue} + sql := fmt.Sprintf("%s BETWEEN %s AND %s", b.Identifier, "?", "?") + return sql, args, nil +} + +type NotBetween binaryOp + +func newNotBetween(identifier string, leftValue, rightValue interface{}) NotBetween { + return NotBetween{ + Identifier: identifier, + LeftValue: leftValue, + RightValue: rightValue, + } +} + +func (b NotBetween) ToSql() (string, []interface{}, error) { + args := []interface{}{b.LeftValue, b.RightValue} + sql := fmt.Sprintf("%s NOT BETWEEN %s AND %s", b.Identifier, "?", "?") + return sql, args, nil +} + +type Contains unaryOp + +func newContains(identifier, value string) Contains { + return Contains{ + Identifier: identifier, + value: value, + } +} + +func (c Contains) ToSql() (string, []interface{}, error) { + v := fmt.Sprintf("%%%s%%", c.value) + + args := []interface{}{v} + + sql := fmt.Sprintf("%s LIKE %s", c.Identifier, "?") + + return sql, args, nil +} + +type NotContains unaryOp + +func newNotContains(identifier, value string) NotContains { + return NotContains{ + Identifier: identifier, + value: value, + } +} + +func (c NotContains) ToSql() (string, []interface{}, error) { + v := fmt.Sprintf("%%%s%%", c.value) + + args := []interface{}{v} + + sql := fmt.Sprintf("%s NOT LIKE %s", c.Identifier, "?") + + return sql, args, nil +} + +type InSubSelect struct { + Column string + Select squirrel.SelectBuilder +} + +func (ss InSubSelect) ToSql() (string, []interface{}, error) { + s, b, err := ss.Select.ToSql() + return fmt.Sprintf("%s IN (%s)", ss.Column, s), b, err +} diff --git a/controller/predicate/state.go b/controller/predicate/state.go index 979ff459f..d5c9f1d5f 100644 --- a/controller/predicate/state.go +++ b/controller/predicate/state.go @@ -1,60 +1,60 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package predicate - -import ( - "gopkg.in/Masterminds/squirrel.v1" -) - -type parseState struct { - root *group - currentGroup *group -} - -func newParseState() *parseState { - r := newGroup(nil) - return &parseState{ - root: r, - currentGroup: r, - } -} - -func (ps *parseState) AddOp(o resolver) { - ps.currentGroup.operations = append(ps.currentGroup.operations, o) -} - -func (ps *parseState) AddOr() { - ps.currentGroup.conjugations = append(ps.currentGroup.conjugations, newOr()) -} - -func (ps *parseState) AddAnd() { - ps.currentGroup.conjugations = append(ps.currentGroup.conjugations, newAnd()) -} - -func (ps *parseState) EnterGroup() { - ng := newGroup(ps.currentGroup) - ps.currentGroup.operations = append(ps.currentGroup.operations, ng) - ps.currentGroup = ng -} - -func (ps *parseState) ExitGroup() { - ps.currentGroup = ps.currentGroup.Parent -} - -func (ps *parseState) End() (squirrel.Sqlizer, IdentifierOps) { - return ps.root.Resolve() -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package predicate + +import ( + "gopkg.in/Masterminds/squirrel.v1" +) + +type parseState struct { + root *group + currentGroup *group +} + +func newParseState() *parseState { + r := newGroup(nil) + return &parseState{ + root: r, + currentGroup: r, + } +} + +func (ps *parseState) AddOp(o resolver) { + ps.currentGroup.operations = append(ps.currentGroup.operations, o) +} + +func (ps *parseState) AddOr() { + ps.currentGroup.conjugations = append(ps.currentGroup.conjugations, newOr()) +} + +func (ps *parseState) AddAnd() { + ps.currentGroup.conjugations = append(ps.currentGroup.conjugations, newAnd()) +} + +func (ps *parseState) EnterGroup() { + ng := newGroup(ps.currentGroup) + ps.currentGroup.operations = append(ps.currentGroup.operations, ng) + ps.currentGroup = ng +} + +func (ps *parseState) ExitGroup() { + ps.currentGroup = ps.currentGroup.Parent +} + +func (ps *parseState) End() (squirrel.Sqlizer, IdentifierOps) { + return ps.root.Resolve() +} diff --git a/controller/response/entity.go b/controller/response/entity.go index 6234d5596..13dc9d334 100644 --- a/controller/response/entity.go +++ b/controller/response/entity.go @@ -1,65 +1,65 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package response - -import ( - "fmt" - "github.com/Jeffail/gabs" - "github.com/michaelquigley/pfxlog" - "net/http" - "net/url" -) - -const ZitiControllerVersionHeader = "ziti-version" - -type Identifier interface { - GetId() string - GetSelfUrl() url.URL -} - -type Response struct { - Contents interface{} - HttpStatusCode int -} - -func NewEntityResponse(contents interface{}, httpStatusCode int) (*Response, error) { - r := &Response{ - Contents: contents, - HttpStatusCode: httpStatusCode, - } - return r, nil -} - -func (r *Response) Respond(w http.ResponseWriter) error { - jsonObj := gabs.New() - - _, err := jsonObj.Set(r.Contents) - - if err != nil { - pfxlog.Logger().WithField("cause", err).Error("could not set contents of response") - } - AddVersionHeader(w) - - w.WriteHeader(r.HttpStatusCode) - _, err = w.Write(jsonObj.Bytes()) - - if err != nil { - return fmt.Errorf("could not write to body: %v", err) - } - - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package response + +import ( + "fmt" + "github.com/Jeffail/gabs" + "github.com/michaelquigley/pfxlog" + "net/http" + "net/url" +) + +const ZitiControllerVersionHeader = "ziti-version" + +type Identifier interface { + GetId() string + GetSelfUrl() url.URL +} + +type Response struct { + Contents interface{} + HttpStatusCode int +} + +func NewEntityResponse(contents interface{}, httpStatusCode int) (*Response, error) { + r := &Response{ + Contents: contents, + HttpStatusCode: httpStatusCode, + } + return r, nil +} + +func (r *Response) Respond(w http.ResponseWriter) error { + jsonObj := gabs.New() + + _, err := jsonObj.Set(r.Contents) + + if err != nil { + pfxlog.Logger().WithField("cause", err).Error("could not set contents of response") + } + AddVersionHeader(w) + + w.WriteHeader(r.HttpStatusCode) + _, err = w.Write(jsonObj.Bytes()) + + if err != nil { + return fmt.Errorf("could not write to body: %v", err) + } + + return nil +} diff --git a/controller/zitiql/util.go b/controller/zitiql/util.go index f34816835..1ad295201 100644 --- a/controller/zitiql/util.go +++ b/controller/zitiql/util.go @@ -1,102 +1,102 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package zitiql - -import ( - "fmt" - "github.com/antlr/antlr4/runtime/Go/antlr" -) - -func parse(str string, l ZitiQlListener, el antlr.ErrorListener, debug bool) { - input := antlr.NewInputStream(str) - lexer := NewZitiQlLexer(input) - - stream := antlr.NewCommonTokenStream(lexer, 0) - - p := NewZitiQlParser(stream) - - if debug { - p.AddErrorListener(antlr.NewDiagnosticErrorListener(true)) - } else { - p.RemoveErrorListeners() - } - - p.AddErrorListener(el) - - p.BuildParseTrees = true - tree := p.Start() - - antlr.ParseTreeWalkerDefault.Walk(l, tree) -} - -func Parse(str string, l ZitiQlListener) []ParseError { - el := newErrorListener() - parse(str, l, el, false) - - return el.Errors -} - -func ParseWithDebug(str string, l ZitiQlListener) []ParseError { - el := newErrorListener() - parse(str, l, el, true) - - return el.Errors -} - -type ParseError struct { - Line int - Column int - Symbol string - Message string -} - -func newErrorListener() *ErrorListener { - return &ErrorListener{ - Errors: []ParseError{}, - } -} - -type ErrorListener struct { - Errors []ParseError -} - -func (el *ErrorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException) { - s, ok := offendingSymbol.(*antlr.CommonToken) - symbol := "" - if ok { - symbol = s.GetText() - } - - el.Errors = append(el.Errors, ParseError{ - Line: line, - Column: column, - Symbol: symbol, - Message: fmt.Sprintf(`Unexpected symbol: "%s" at line: %d column: %d`, s.GetText(), line, column), - }) -} - -func (el *ErrorListener) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs antlr.ATNConfigSet) { - // ignored -} - -func (el *ErrorListener) ReportAttemptingFullContext(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, conflictingAlts *antlr.BitSet, configs antlr.ATNConfigSet) { - // ignored -} - -func (el *ErrorListener) ReportContextSensitivity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex, prediction int, configs antlr.ATNConfigSet) { - // ignored -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package zitiql + +import ( + "fmt" + "github.com/antlr/antlr4/runtime/Go/antlr" +) + +func parse(str string, l ZitiQlListener, el antlr.ErrorListener, debug bool) { + input := antlr.NewInputStream(str) + lexer := NewZitiQlLexer(input) + + stream := antlr.NewCommonTokenStream(lexer, 0) + + p := NewZitiQlParser(stream) + + if debug { + p.AddErrorListener(antlr.NewDiagnosticErrorListener(true)) + } else { + p.RemoveErrorListeners() + } + + p.AddErrorListener(el) + + p.BuildParseTrees = true + tree := p.Start() + + antlr.ParseTreeWalkerDefault.Walk(l, tree) +} + +func Parse(str string, l ZitiQlListener) []ParseError { + el := newErrorListener() + parse(str, l, el, false) + + return el.Errors +} + +func ParseWithDebug(str string, l ZitiQlListener) []ParseError { + el := newErrorListener() + parse(str, l, el, true) + + return el.Errors +} + +type ParseError struct { + Line int + Column int + Symbol string + Message string +} + +func newErrorListener() *ErrorListener { + return &ErrorListener{ + Errors: []ParseError{}, + } +} + +type ErrorListener struct { + Errors []ParseError +} + +func (el *ErrorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol interface{}, line, column int, msg string, e antlr.RecognitionException) { + s, ok := offendingSymbol.(*antlr.CommonToken) + symbol := "" + if ok { + symbol = s.GetText() + } + + el.Errors = append(el.Errors, ParseError{ + Line: line, + Column: column, + Symbol: symbol, + Message: fmt.Sprintf(`Unexpected symbol: "%s" at line: %d column: %d`, s.GetText(), line, column), + }) +} + +func (el *ErrorListener) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs antlr.ATNConfigSet) { + // ignored +} + +func (el *ErrorListener) ReportAttemptingFullContext(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, conflictingAlts *antlr.BitSet, configs antlr.ATNConfigSet) { + // ignored +} + +func (el *ErrorListener) ReportContextSensitivity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex, prediction int, configs antlr.ATNConfigSet) { + // ignored +} diff --git a/controller/zitiql/zitiql_base_listener.go b/controller/zitiql/zitiql_base_listener.go index 2d150faba..02764f209 100644 --- a/controller/zitiql/zitiql_base_listener.go +++ b/controller/zitiql/zitiql_base_listener.go @@ -1,177 +1,177 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// Code generated from ZitiQl.g4 by ANTLR 4.7.1. DO NOT EDIT. - -package zitiql // ZitiQl -import "github.com/antlr/antlr4/runtime/Go/antlr" - -// BaseZitiQlListener is a complete listener for a parse tree produced by ZitiQlParser. -type BaseZitiQlListener struct{} - -var _ ZitiQlListener = &BaseZitiQlListener{} - -// VisitTerminal is called when a terminal node is visited. -func (s *BaseZitiQlListener) VisitTerminal(node antlr.TerminalNode) {} - -// VisitErrorNode is called when an error node is visited. -func (s *BaseZitiQlListener) VisitErrorNode(node antlr.ErrorNode) {} - -// EnterEveryRule is called when any rule is entered. -func (s *BaseZitiQlListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} - -// ExitEveryRule is called when any rule is exited. -func (s *BaseZitiQlListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} - -// EnterString_array is called when production string_array is entered. -func (s *BaseZitiQlListener) EnterString_array(ctx *String_arrayContext) {} - -// ExitString_array is called when production string_array is exited. -func (s *BaseZitiQlListener) ExitString_array(ctx *String_arrayContext) {} - -// EnterNumber_array is called when production number_array is entered. -func (s *BaseZitiQlListener) EnterNumber_array(ctx *Number_arrayContext) {} - -// ExitNumber_array is called when production number_array is exited. -func (s *BaseZitiQlListener) ExitNumber_array(ctx *Number_arrayContext) {} - -// EnterDatetime_array is called when production datetime_array is entered. -func (s *BaseZitiQlListener) EnterDatetime_array(ctx *Datetime_arrayContext) {} - -// ExitDatetime_array is called when production datetime_array is exited. -func (s *BaseZitiQlListener) ExitDatetime_array(ctx *Datetime_arrayContext) {} - -// EnterEnd is called when production End is entered. -func (s *BaseZitiQlListener) EnterEnd(ctx *EndContext) {} - -// ExitEnd is called when production End is exited. -func (s *BaseZitiQlListener) ExitEnd(ctx *EndContext) {} - -// EnterGroup is called when production Group is entered. -func (s *BaseZitiQlListener) EnterGroup(ctx *GroupContext) {} - -// ExitGroup is called when production Group is exited. -func (s *BaseZitiQlListener) ExitGroup(ctx *GroupContext) {} - -// EnterOrConjunction is called when production OrConjunction is entered. -func (s *BaseZitiQlListener) EnterOrConjunction(ctx *OrConjunctionContext) {} - -// ExitOrConjunction is called when production OrConjunction is exited. -func (s *BaseZitiQlListener) ExitOrConjunction(ctx *OrConjunctionContext) {} - -// EnterOperationOp is called when production OperationOp is entered. -func (s *BaseZitiQlListener) EnterOperationOp(ctx *OperationOpContext) {} - -// ExitOperationOp is called when production OperationOp is exited. -func (s *BaseZitiQlListener) ExitOperationOp(ctx *OperationOpContext) {} - -// EnterAndConjunction is called when production AndConjunction is entered. -func (s *BaseZitiQlListener) EnterAndConjunction(ctx *AndConjunctionContext) {} - -// ExitAndConjunction is called when production AndConjunction is exited. -func (s *BaseZitiQlListener) ExitAndConjunction(ctx *AndConjunctionContext) {} - -// EnterInStringArrayOp is called when production InStringArrayOp is entered. -func (s *BaseZitiQlListener) EnterInStringArrayOp(ctx *InStringArrayOpContext) {} - -// ExitInStringArrayOp is called when production InStringArrayOp is exited. -func (s *BaseZitiQlListener) ExitInStringArrayOp(ctx *InStringArrayOpContext) {} - -// EnterInNumberArrayOp is called when production InNumberArrayOp is entered. -func (s *BaseZitiQlListener) EnterInNumberArrayOp(ctx *InNumberArrayOpContext) {} - -// ExitInNumberArrayOp is called when production InNumberArrayOp is exited. -func (s *BaseZitiQlListener) ExitInNumberArrayOp(ctx *InNumberArrayOpContext) {} - -// EnterInDatetimeArrayOp is called when production InDatetimeArrayOp is entered. -func (s *BaseZitiQlListener) EnterInDatetimeArrayOp(ctx *InDatetimeArrayOpContext) {} - -// ExitInDatetimeArrayOp is called when production InDatetimeArrayOp is exited. -func (s *BaseZitiQlListener) ExitInDatetimeArrayOp(ctx *InDatetimeArrayOpContext) {} - -// EnterBetweenNumberOp is called when production BetweenNumberOp is entered. -func (s *BaseZitiQlListener) EnterBetweenNumberOp(ctx *BetweenNumberOpContext) {} - -// ExitBetweenNumberOp is called when production BetweenNumberOp is exited. -func (s *BaseZitiQlListener) ExitBetweenNumberOp(ctx *BetweenNumberOpContext) {} - -// EnterBetweenDateOp is called when production BetweenDateOp is entered. -func (s *BaseZitiQlListener) EnterBetweenDateOp(ctx *BetweenDateOpContext) {} - -// ExitBetweenDateOp is called when production BetweenDateOp is exited. -func (s *BaseZitiQlListener) ExitBetweenDateOp(ctx *BetweenDateOpContext) {} - -// EnterBinaryLessThanNumberOp is called when production BinaryLessThanNumberOp is entered. -func (s *BaseZitiQlListener) EnterBinaryLessThanNumberOp(ctx *BinaryLessThanNumberOpContext) {} - -// ExitBinaryLessThanNumberOp is called when production BinaryLessThanNumberOp is exited. -func (s *BaseZitiQlListener) ExitBinaryLessThanNumberOp(ctx *BinaryLessThanNumberOpContext) {} - -// EnterBinaryLessThanDatetimeOp is called when production BinaryLessThanDatetimeOp is entered. -func (s *BaseZitiQlListener) EnterBinaryLessThanDatetimeOp(ctx *BinaryLessThanDatetimeOpContext) {} - -// ExitBinaryLessThanDatetimeOp is called when production BinaryLessThanDatetimeOp is exited. -func (s *BaseZitiQlListener) ExitBinaryLessThanDatetimeOp(ctx *BinaryLessThanDatetimeOpContext) {} - -// EnterBinaryGreaterThanNumberOp is called when production BinaryGreaterThanNumberOp is entered. -func (s *BaseZitiQlListener) EnterBinaryGreaterThanNumberOp(ctx *BinaryGreaterThanNumberOpContext) {} - -// ExitBinaryGreaterThanNumberOp is called when production BinaryGreaterThanNumberOp is exited. -func (s *BaseZitiQlListener) ExitBinaryGreaterThanNumberOp(ctx *BinaryGreaterThanNumberOpContext) {} - -// EnterBinaryGreaterThanDatetimeOp is called when production BinaryGreaterThanDatetimeOp is entered. -func (s *BaseZitiQlListener) EnterBinaryGreaterThanDatetimeOp(ctx *BinaryGreaterThanDatetimeOpContext) { -} - -// ExitBinaryGreaterThanDatetimeOp is called when production BinaryGreaterThanDatetimeOp is exited. -func (s *BaseZitiQlListener) ExitBinaryGreaterThanDatetimeOp(ctx *BinaryGreaterThanDatetimeOpContext) { -} - -// EnterBinaryEqualToStringOp is called when production BinaryEqualToStringOp is entered. -func (s *BaseZitiQlListener) EnterBinaryEqualToStringOp(ctx *BinaryEqualToStringOpContext) {} - -// ExitBinaryEqualToStringOp is called when production BinaryEqualToStringOp is exited. -func (s *BaseZitiQlListener) ExitBinaryEqualToStringOp(ctx *BinaryEqualToStringOpContext) {} - -// EnterBinaryEqualToNumberOp is called when production BinaryEqualToNumberOp is entered. -func (s *BaseZitiQlListener) EnterBinaryEqualToNumberOp(ctx *BinaryEqualToNumberOpContext) {} - -// ExitBinaryEqualToNumberOp is called when production BinaryEqualToNumberOp is exited. -func (s *BaseZitiQlListener) ExitBinaryEqualToNumberOp(ctx *BinaryEqualToNumberOpContext) {} - -// EnterBinaryEqualToDatetimeOp is called when production BinaryEqualToDatetimeOp is entered. -func (s *BaseZitiQlListener) EnterBinaryEqualToDatetimeOp(ctx *BinaryEqualToDatetimeOpContext) {} - -// ExitBinaryEqualToDatetimeOp is called when production BinaryEqualToDatetimeOp is exited. -func (s *BaseZitiQlListener) ExitBinaryEqualToDatetimeOp(ctx *BinaryEqualToDatetimeOpContext) {} - -// EnterBinaryEqualToBoolOp is called when production BinaryEqualToBoolOp is entered. -func (s *BaseZitiQlListener) EnterBinaryEqualToBoolOp(ctx *BinaryEqualToBoolOpContext) {} - -// ExitBinaryEqualToBoolOp is called when production BinaryEqualToBoolOp is exited. -func (s *BaseZitiQlListener) ExitBinaryEqualToBoolOp(ctx *BinaryEqualToBoolOpContext) {} - -// EnterBinaryEqualToNullOp is called when production BinaryEqualToNullOp is entered. -func (s *BaseZitiQlListener) EnterBinaryEqualToNullOp(ctx *BinaryEqualToNullOpContext) {} - -// ExitBinaryEqualToNullOp is called when production BinaryEqualToNullOp is exited. -func (s *BaseZitiQlListener) ExitBinaryEqualToNullOp(ctx *BinaryEqualToNullOpContext) {} - -// EnterBinaryContainsOp is called when production BinaryContainsOp is entered. -func (s *BaseZitiQlListener) EnterBinaryContainsOp(ctx *BinaryContainsOpContext) {} - -// ExitBinaryContainsOp is called when production BinaryContainsOp is exited. -func (s *BaseZitiQlListener) ExitBinaryContainsOp(ctx *BinaryContainsOpContext) {} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Code generated from ZitiQl.g4 by ANTLR 4.7.1. DO NOT EDIT. + +package zitiql // ZitiQl +import "github.com/antlr/antlr4/runtime/Go/antlr" + +// BaseZitiQlListener is a complete listener for a parse tree produced by ZitiQlParser. +type BaseZitiQlListener struct{} + +var _ ZitiQlListener = &BaseZitiQlListener{} + +// VisitTerminal is called when a terminal node is visited. +func (s *BaseZitiQlListener) VisitTerminal(node antlr.TerminalNode) {} + +// VisitErrorNode is called when an error node is visited. +func (s *BaseZitiQlListener) VisitErrorNode(node antlr.ErrorNode) {} + +// EnterEveryRule is called when any rule is entered. +func (s *BaseZitiQlListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} + +// ExitEveryRule is called when any rule is exited. +func (s *BaseZitiQlListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} + +// EnterString_array is called when production string_array is entered. +func (s *BaseZitiQlListener) EnterString_array(ctx *String_arrayContext) {} + +// ExitString_array is called when production string_array is exited. +func (s *BaseZitiQlListener) ExitString_array(ctx *String_arrayContext) {} + +// EnterNumber_array is called when production number_array is entered. +func (s *BaseZitiQlListener) EnterNumber_array(ctx *Number_arrayContext) {} + +// ExitNumber_array is called when production number_array is exited. +func (s *BaseZitiQlListener) ExitNumber_array(ctx *Number_arrayContext) {} + +// EnterDatetime_array is called when production datetime_array is entered. +func (s *BaseZitiQlListener) EnterDatetime_array(ctx *Datetime_arrayContext) {} + +// ExitDatetime_array is called when production datetime_array is exited. +func (s *BaseZitiQlListener) ExitDatetime_array(ctx *Datetime_arrayContext) {} + +// EnterEnd is called when production End is entered. +func (s *BaseZitiQlListener) EnterEnd(ctx *EndContext) {} + +// ExitEnd is called when production End is exited. +func (s *BaseZitiQlListener) ExitEnd(ctx *EndContext) {} + +// EnterGroup is called when production Group is entered. +func (s *BaseZitiQlListener) EnterGroup(ctx *GroupContext) {} + +// ExitGroup is called when production Group is exited. +func (s *BaseZitiQlListener) ExitGroup(ctx *GroupContext) {} + +// EnterOrConjunction is called when production OrConjunction is entered. +func (s *BaseZitiQlListener) EnterOrConjunction(ctx *OrConjunctionContext) {} + +// ExitOrConjunction is called when production OrConjunction is exited. +func (s *BaseZitiQlListener) ExitOrConjunction(ctx *OrConjunctionContext) {} + +// EnterOperationOp is called when production OperationOp is entered. +func (s *BaseZitiQlListener) EnterOperationOp(ctx *OperationOpContext) {} + +// ExitOperationOp is called when production OperationOp is exited. +func (s *BaseZitiQlListener) ExitOperationOp(ctx *OperationOpContext) {} + +// EnterAndConjunction is called when production AndConjunction is entered. +func (s *BaseZitiQlListener) EnterAndConjunction(ctx *AndConjunctionContext) {} + +// ExitAndConjunction is called when production AndConjunction is exited. +func (s *BaseZitiQlListener) ExitAndConjunction(ctx *AndConjunctionContext) {} + +// EnterInStringArrayOp is called when production InStringArrayOp is entered. +func (s *BaseZitiQlListener) EnterInStringArrayOp(ctx *InStringArrayOpContext) {} + +// ExitInStringArrayOp is called when production InStringArrayOp is exited. +func (s *BaseZitiQlListener) ExitInStringArrayOp(ctx *InStringArrayOpContext) {} + +// EnterInNumberArrayOp is called when production InNumberArrayOp is entered. +func (s *BaseZitiQlListener) EnterInNumberArrayOp(ctx *InNumberArrayOpContext) {} + +// ExitInNumberArrayOp is called when production InNumberArrayOp is exited. +func (s *BaseZitiQlListener) ExitInNumberArrayOp(ctx *InNumberArrayOpContext) {} + +// EnterInDatetimeArrayOp is called when production InDatetimeArrayOp is entered. +func (s *BaseZitiQlListener) EnterInDatetimeArrayOp(ctx *InDatetimeArrayOpContext) {} + +// ExitInDatetimeArrayOp is called when production InDatetimeArrayOp is exited. +func (s *BaseZitiQlListener) ExitInDatetimeArrayOp(ctx *InDatetimeArrayOpContext) {} + +// EnterBetweenNumberOp is called when production BetweenNumberOp is entered. +func (s *BaseZitiQlListener) EnterBetweenNumberOp(ctx *BetweenNumberOpContext) {} + +// ExitBetweenNumberOp is called when production BetweenNumberOp is exited. +func (s *BaseZitiQlListener) ExitBetweenNumberOp(ctx *BetweenNumberOpContext) {} + +// EnterBetweenDateOp is called when production BetweenDateOp is entered. +func (s *BaseZitiQlListener) EnterBetweenDateOp(ctx *BetweenDateOpContext) {} + +// ExitBetweenDateOp is called when production BetweenDateOp is exited. +func (s *BaseZitiQlListener) ExitBetweenDateOp(ctx *BetweenDateOpContext) {} + +// EnterBinaryLessThanNumberOp is called when production BinaryLessThanNumberOp is entered. +func (s *BaseZitiQlListener) EnterBinaryLessThanNumberOp(ctx *BinaryLessThanNumberOpContext) {} + +// ExitBinaryLessThanNumberOp is called when production BinaryLessThanNumberOp is exited. +func (s *BaseZitiQlListener) ExitBinaryLessThanNumberOp(ctx *BinaryLessThanNumberOpContext) {} + +// EnterBinaryLessThanDatetimeOp is called when production BinaryLessThanDatetimeOp is entered. +func (s *BaseZitiQlListener) EnterBinaryLessThanDatetimeOp(ctx *BinaryLessThanDatetimeOpContext) {} + +// ExitBinaryLessThanDatetimeOp is called when production BinaryLessThanDatetimeOp is exited. +func (s *BaseZitiQlListener) ExitBinaryLessThanDatetimeOp(ctx *BinaryLessThanDatetimeOpContext) {} + +// EnterBinaryGreaterThanNumberOp is called when production BinaryGreaterThanNumberOp is entered. +func (s *BaseZitiQlListener) EnterBinaryGreaterThanNumberOp(ctx *BinaryGreaterThanNumberOpContext) {} + +// ExitBinaryGreaterThanNumberOp is called when production BinaryGreaterThanNumberOp is exited. +func (s *BaseZitiQlListener) ExitBinaryGreaterThanNumberOp(ctx *BinaryGreaterThanNumberOpContext) {} + +// EnterBinaryGreaterThanDatetimeOp is called when production BinaryGreaterThanDatetimeOp is entered. +func (s *BaseZitiQlListener) EnterBinaryGreaterThanDatetimeOp(ctx *BinaryGreaterThanDatetimeOpContext) { +} + +// ExitBinaryGreaterThanDatetimeOp is called when production BinaryGreaterThanDatetimeOp is exited. +func (s *BaseZitiQlListener) ExitBinaryGreaterThanDatetimeOp(ctx *BinaryGreaterThanDatetimeOpContext) { +} + +// EnterBinaryEqualToStringOp is called when production BinaryEqualToStringOp is entered. +func (s *BaseZitiQlListener) EnterBinaryEqualToStringOp(ctx *BinaryEqualToStringOpContext) {} + +// ExitBinaryEqualToStringOp is called when production BinaryEqualToStringOp is exited. +func (s *BaseZitiQlListener) ExitBinaryEqualToStringOp(ctx *BinaryEqualToStringOpContext) {} + +// EnterBinaryEqualToNumberOp is called when production BinaryEqualToNumberOp is entered. +func (s *BaseZitiQlListener) EnterBinaryEqualToNumberOp(ctx *BinaryEqualToNumberOpContext) {} + +// ExitBinaryEqualToNumberOp is called when production BinaryEqualToNumberOp is exited. +func (s *BaseZitiQlListener) ExitBinaryEqualToNumberOp(ctx *BinaryEqualToNumberOpContext) {} + +// EnterBinaryEqualToDatetimeOp is called when production BinaryEqualToDatetimeOp is entered. +func (s *BaseZitiQlListener) EnterBinaryEqualToDatetimeOp(ctx *BinaryEqualToDatetimeOpContext) {} + +// ExitBinaryEqualToDatetimeOp is called when production BinaryEqualToDatetimeOp is exited. +func (s *BaseZitiQlListener) ExitBinaryEqualToDatetimeOp(ctx *BinaryEqualToDatetimeOpContext) {} + +// EnterBinaryEqualToBoolOp is called when production BinaryEqualToBoolOp is entered. +func (s *BaseZitiQlListener) EnterBinaryEqualToBoolOp(ctx *BinaryEqualToBoolOpContext) {} + +// ExitBinaryEqualToBoolOp is called when production BinaryEqualToBoolOp is exited. +func (s *BaseZitiQlListener) ExitBinaryEqualToBoolOp(ctx *BinaryEqualToBoolOpContext) {} + +// EnterBinaryEqualToNullOp is called when production BinaryEqualToNullOp is entered. +func (s *BaseZitiQlListener) EnterBinaryEqualToNullOp(ctx *BinaryEqualToNullOpContext) {} + +// ExitBinaryEqualToNullOp is called when production BinaryEqualToNullOp is exited. +func (s *BaseZitiQlListener) ExitBinaryEqualToNullOp(ctx *BinaryEqualToNullOpContext) {} + +// EnterBinaryContainsOp is called when production BinaryContainsOp is entered. +func (s *BaseZitiQlListener) EnterBinaryContainsOp(ctx *BinaryContainsOpContext) {} + +// ExitBinaryContainsOp is called when production BinaryContainsOp is exited. +func (s *BaseZitiQlListener) ExitBinaryContainsOp(ctx *BinaryContainsOpContext) {} diff --git a/controller/zitiql/zitiql_lexer.go b/controller/zitiql/zitiql_lexer.go index 43fa47df7..d827f6d99 100644 --- a/controller/zitiql/zitiql_lexer.go +++ b/controller/zitiql/zitiql_lexer.go @@ -1,341 +1,341 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// Code generated from ZitiQl.g4 by ANTLR 4.7.1. DO NOT EDIT. - -package zitiql - -import ( - "fmt" - "unicode" - - "github.com/antlr/antlr4/runtime/Go/antlr" -) - -// Suppress unused import error -var _ = fmt.Printf -var _ = unicode.IsLetter - -var serializedLexerAtn = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 23, 482, - 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, - 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, - 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, - 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, - 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, - 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, - 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, - 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, - 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, - 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, - 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, - 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, - 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, - 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, - 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, - 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, - 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, - 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 31, 3, 31, - 3, 32, 3, 32, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, - 35, 3, 36, 3, 36, 5, 36, 209, 10, 36, 3, 37, 3, 37, 5, 37, 213, 10, 37, - 3, 38, 5, 38, 216, 10, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 39, 6, - 39, 224, 10, 39, 13, 39, 14, 39, 225, 5, 39, 228, 10, 39, 3, 39, 3, 39, - 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, - 40, 3, 40, 5, 40, 244, 10, 40, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, - 3, 41, 6, 41, 253, 10, 41, 13, 41, 14, 41, 254, 5, 41, 257, 10, 41, 3, - 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 5, 42, - 269, 10, 42, 3, 43, 3, 43, 3, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, - 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, - 3, 45, 3, 45, 3, 45, 7, 45, 293, 10, 45, 12, 45, 14, 45, 296, 11, 45, 3, - 45, 3, 45, 7, 45, 300, 10, 45, 12, 45, 14, 45, 303, 11, 45, 3, 45, 3, 45, - 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 47, 3, 47, 3, - 47, 3, 47, 3, 47, 5, 47, 320, 10, 47, 3, 47, 3, 47, 3, 48, 6, 48, 325, - 10, 48, 13, 48, 14, 48, 326, 3, 49, 3, 49, 3, 49, 3, 49, 5, 49, 333, 10, - 49, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 5, 50, 341, 10, 50, 3, 51, - 3, 51, 3, 51, 3, 51, 5, 51, 347, 10, 51, 3, 52, 3, 52, 3, 52, 3, 53, 3, - 53, 3, 53, 3, 53, 5, 53, 356, 10, 53, 3, 54, 6, 54, 359, 10, 54, 13, 54, - 14, 54, 360, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 5, 55, 369, 10, - 55, 3, 56, 3, 56, 3, 56, 3, 56, 5, 56, 375, 10, 56, 3, 57, 3, 57, 3, 57, - 3, 58, 3, 58, 3, 58, 7, 58, 383, 10, 58, 12, 58, 14, 58, 386, 11, 58, 3, - 58, 3, 58, 3, 59, 5, 59, 391, 10, 59, 3, 59, 3, 59, 3, 59, 6, 59, 396, - 10, 59, 13, 59, 14, 59, 397, 5, 59, 400, 10, 59, 3, 59, 5, 59, 403, 10, - 59, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 3, 61, 3, 61, 3, 61, 7, 61, 413, - 10, 61, 12, 61, 14, 61, 416, 11, 61, 5, 61, 418, 10, 61, 3, 62, 3, 62, - 5, 62, 422, 10, 62, 3, 62, 3, 62, 3, 63, 3, 63, 3, 63, 3, 64, 3, 64, 3, - 65, 3, 65, 7, 65, 433, 10, 65, 12, 65, 14, 65, 436, 11, 65, 3, 65, 3, 65, - 3, 65, 7, 65, 441, 10, 65, 12, 65, 14, 65, 444, 11, 65, 7, 65, 446, 10, - 65, 12, 65, 14, 65, 449, 11, 65, 3, 65, 5, 65, 452, 10, 65, 3, 65, 3, 65, - 7, 65, 456, 10, 65, 12, 65, 14, 65, 459, 11, 65, 3, 65, 3, 65, 3, 65, 7, - 65, 464, 10, 65, 12, 65, 14, 65, 467, 11, 65, 7, 65, 469, 10, 65, 12, 65, - 14, 65, 472, 11, 65, 3, 65, 5, 65, 475, 10, 65, 3, 66, 3, 66, 3, 66, 3, - 66, 3, 67, 3, 67, 2, 2, 68, 3, 3, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2, - 17, 2, 19, 2, 21, 2, 23, 2, 25, 2, 27, 2, 29, 2, 31, 2, 33, 2, 35, 2, 37, - 2, 39, 2, 41, 2, 43, 2, 45, 2, 47, 2, 49, 2, 51, 2, 53, 2, 55, 2, 57, 4, - 59, 5, 61, 6, 63, 7, 65, 8, 67, 9, 69, 10, 71, 11, 73, 12, 75, 13, 77, - 14, 79, 15, 81, 16, 83, 17, 85, 2, 87, 2, 89, 18, 91, 2, 93, 2, 95, 2, - 97, 2, 99, 2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2, 113, 2, 115, - 19, 117, 20, 119, 21, 121, 2, 123, 2, 125, 2, 127, 2, 129, 22, 131, 23, - 133, 2, 3, 2, 41, 4, 2, 67, 67, 99, 99, 4, 2, 68, 68, 100, 100, 4, 2, 69, - 69, 101, 101, 4, 2, 70, 70, 102, 102, 4, 2, 71, 71, 103, 103, 4, 2, 72, - 72, 104, 104, 4, 2, 73, 73, 105, 105, 4, 2, 74, 74, 106, 106, 4, 2, 75, - 75, 107, 107, 4, 2, 76, 76, 108, 108, 4, 2, 77, 77, 109, 109, 4, 2, 78, - 78, 110, 110, 4, 2, 79, 79, 111, 111, 4, 2, 80, 80, 112, 112, 4, 2, 81, - 81, 113, 113, 4, 2, 82, 82, 114, 114, 4, 2, 83, 83, 115, 115, 4, 2, 84, - 84, 116, 116, 4, 2, 85, 85, 117, 117, 4, 2, 86, 86, 118, 118, 4, 2, 87, - 87, 119, 119, 4, 2, 88, 88, 120, 120, 4, 2, 89, 89, 121, 121, 4, 2, 90, - 90, 122, 122, 4, 2, 91, 91, 123, 123, 4, 2, 92, 92, 124, 124, 5, 2, 11, - 12, 15, 15, 34, 34, 3, 2, 51, 59, 3, 2, 50, 52, 3, 2, 51, 52, 3, 2, 50, - 59, 3, 2, 50, 51, 3, 2, 50, 53, 3, 2, 50, 55, 4, 2, 45, 45, 47, 47, 8, - 2, 36, 36, 94, 94, 104, 104, 112, 112, 116, 116, 118, 118, 4, 2, 67, 92, - 99, 124, 5, 2, 67, 92, 97, 97, 99, 124, 5, 2, 2, 33, 36, 36, 94, 94, 2, - 474, 2, 3, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, - 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, - 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, - 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, - 2, 89, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 117, 3, 2, 2, 2, 2, 119, 3, 2, - 2, 2, 2, 129, 3, 2, 2, 2, 2, 131, 3, 2, 2, 2, 3, 135, 3, 2, 2, 2, 5, 137, - 3, 2, 2, 2, 7, 139, 3, 2, 2, 2, 9, 141, 3, 2, 2, 2, 11, 143, 3, 2, 2, 2, - 13, 145, 3, 2, 2, 2, 15, 147, 3, 2, 2, 2, 17, 149, 3, 2, 2, 2, 19, 151, - 3, 2, 2, 2, 21, 153, 3, 2, 2, 2, 23, 155, 3, 2, 2, 2, 25, 157, 3, 2, 2, - 2, 27, 159, 3, 2, 2, 2, 29, 161, 3, 2, 2, 2, 31, 163, 3, 2, 2, 2, 33, 165, - 3, 2, 2, 2, 35, 167, 3, 2, 2, 2, 37, 169, 3, 2, 2, 2, 39, 171, 3, 2, 2, - 2, 41, 173, 3, 2, 2, 2, 43, 175, 3, 2, 2, 2, 45, 177, 3, 2, 2, 2, 47, 179, - 3, 2, 2, 2, 49, 181, 3, 2, 2, 2, 51, 183, 3, 2, 2, 2, 53, 185, 3, 2, 2, - 2, 55, 187, 3, 2, 2, 2, 57, 189, 3, 2, 2, 2, 59, 191, 3, 2, 2, 2, 61, 193, - 3, 2, 2, 2, 63, 195, 3, 2, 2, 2, 65, 197, 3, 2, 2, 2, 67, 199, 3, 2, 2, - 2, 69, 203, 3, 2, 2, 2, 71, 206, 3, 2, 2, 2, 73, 210, 3, 2, 2, 2, 75, 215, - 3, 2, 2, 2, 77, 227, 3, 2, 2, 2, 79, 243, 3, 2, 2, 2, 81, 256, 3, 2, 2, - 2, 83, 268, 3, 2, 2, 2, 85, 270, 3, 2, 2, 2, 87, 275, 3, 2, 2, 2, 89, 281, - 3, 2, 2, 2, 91, 306, 3, 2, 2, 2, 93, 312, 3, 2, 2, 2, 95, 324, 3, 2, 2, - 2, 97, 332, 3, 2, 2, 2, 99, 340, 3, 2, 2, 2, 101, 346, 3, 2, 2, 2, 103, - 348, 3, 2, 2, 2, 105, 355, 3, 2, 2, 2, 107, 358, 3, 2, 2, 2, 109, 368, - 3, 2, 2, 2, 111, 374, 3, 2, 2, 2, 113, 376, 3, 2, 2, 2, 115, 379, 3, 2, - 2, 2, 117, 390, 3, 2, 2, 2, 119, 404, 3, 2, 2, 2, 121, 417, 3, 2, 2, 2, - 123, 419, 3, 2, 2, 2, 125, 425, 3, 2, 2, 2, 127, 428, 3, 2, 2, 2, 129, - 474, 3, 2, 2, 2, 131, 476, 3, 2, 2, 2, 133, 480, 3, 2, 2, 2, 135, 136, - 7, 46, 2, 2, 136, 4, 3, 2, 2, 2, 137, 138, 9, 2, 2, 2, 138, 6, 3, 2, 2, - 2, 139, 140, 9, 3, 2, 2, 140, 8, 3, 2, 2, 2, 141, 142, 9, 4, 2, 2, 142, - 10, 3, 2, 2, 2, 143, 144, 9, 5, 2, 2, 144, 12, 3, 2, 2, 2, 145, 146, 9, - 6, 2, 2, 146, 14, 3, 2, 2, 2, 147, 148, 9, 7, 2, 2, 148, 16, 3, 2, 2, 2, - 149, 150, 9, 8, 2, 2, 150, 18, 3, 2, 2, 2, 151, 152, 9, 9, 2, 2, 152, 20, - 3, 2, 2, 2, 153, 154, 9, 10, 2, 2, 154, 22, 3, 2, 2, 2, 155, 156, 9, 11, - 2, 2, 156, 24, 3, 2, 2, 2, 157, 158, 9, 12, 2, 2, 158, 26, 3, 2, 2, 2, - 159, 160, 9, 13, 2, 2, 160, 28, 3, 2, 2, 2, 161, 162, 9, 14, 2, 2, 162, - 30, 3, 2, 2, 2, 163, 164, 9, 15, 2, 2, 164, 32, 3, 2, 2, 2, 165, 166, 9, - 16, 2, 2, 166, 34, 3, 2, 2, 2, 167, 168, 9, 17, 2, 2, 168, 36, 3, 2, 2, - 2, 169, 170, 9, 18, 2, 2, 170, 38, 3, 2, 2, 2, 171, 172, 9, 19, 2, 2, 172, - 40, 3, 2, 2, 2, 173, 174, 9, 20, 2, 2, 174, 42, 3, 2, 2, 2, 175, 176, 9, - 21, 2, 2, 176, 44, 3, 2, 2, 2, 177, 178, 9, 22, 2, 2, 178, 46, 3, 2, 2, - 2, 179, 180, 9, 23, 2, 2, 180, 48, 3, 2, 2, 2, 181, 182, 9, 24, 2, 2, 182, - 50, 3, 2, 2, 2, 183, 184, 9, 25, 2, 2, 184, 52, 3, 2, 2, 2, 185, 186, 9, - 26, 2, 2, 186, 54, 3, 2, 2, 2, 187, 188, 9, 27, 2, 2, 188, 56, 3, 2, 2, - 2, 189, 190, 9, 28, 2, 2, 190, 58, 3, 2, 2, 2, 191, 192, 7, 42, 2, 2, 192, - 60, 3, 2, 2, 2, 193, 194, 7, 43, 2, 2, 194, 62, 3, 2, 2, 2, 195, 196, 7, - 93, 2, 2, 196, 64, 3, 2, 2, 2, 197, 198, 7, 95, 2, 2, 198, 66, 3, 2, 2, - 2, 199, 200, 5, 5, 3, 2, 200, 201, 5, 31, 16, 2, 201, 202, 5, 11, 6, 2, - 202, 68, 3, 2, 2, 2, 203, 204, 5, 33, 17, 2, 204, 205, 5, 39, 20, 2, 205, - 70, 3, 2, 2, 2, 206, 208, 7, 62, 2, 2, 207, 209, 7, 63, 2, 2, 208, 207, - 3, 2, 2, 2, 208, 209, 3, 2, 2, 2, 209, 72, 3, 2, 2, 2, 210, 212, 7, 64, - 2, 2, 211, 213, 7, 63, 2, 2, 212, 211, 3, 2, 2, 2, 212, 213, 3, 2, 2, 2, - 213, 74, 3, 2, 2, 2, 214, 216, 7, 35, 2, 2, 215, 214, 3, 2, 2, 2, 215, - 216, 3, 2, 2, 2, 216, 217, 3, 2, 2, 2, 217, 218, 7, 63, 2, 2, 218, 76, - 3, 2, 2, 2, 219, 220, 5, 31, 16, 2, 220, 221, 5, 33, 17, 2, 221, 223, 5, - 43, 22, 2, 222, 224, 5, 57, 29, 2, 223, 222, 3, 2, 2, 2, 224, 225, 3, 2, - 2, 2, 225, 223, 3, 2, 2, 2, 225, 226, 3, 2, 2, 2, 226, 228, 3, 2, 2, 2, - 227, 219, 3, 2, 2, 2, 227, 228, 3, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229, - 230, 5, 9, 5, 2, 230, 231, 5, 33, 17, 2, 231, 232, 5, 31, 16, 2, 232, 233, - 5, 43, 22, 2, 233, 234, 5, 5, 3, 2, 234, 235, 5, 21, 11, 2, 235, 236, 5, - 31, 16, 2, 236, 237, 5, 41, 21, 2, 237, 78, 3, 2, 2, 2, 238, 239, 5, 31, - 16, 2, 239, 240, 5, 33, 17, 2, 240, 241, 5, 43, 22, 2, 241, 242, 5, 57, - 29, 2, 242, 244, 3, 2, 2, 2, 243, 238, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, - 244, 245, 3, 2, 2, 2, 245, 246, 5, 21, 11, 2, 246, 247, 5, 31, 16, 2, 247, - 80, 3, 2, 2, 2, 248, 249, 5, 31, 16, 2, 249, 250, 5, 33, 17, 2, 250, 252, - 5, 43, 22, 2, 251, 253, 5, 57, 29, 2, 252, 251, 3, 2, 2, 2, 253, 254, 3, - 2, 2, 2, 254, 252, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 257, 3, 2, 2, - 2, 256, 248, 3, 2, 2, 2, 256, 257, 3, 2, 2, 2, 257, 258, 3, 2, 2, 2, 258, - 259, 5, 7, 4, 2, 259, 260, 5, 13, 7, 2, 260, 261, 5, 43, 22, 2, 261, 262, - 5, 49, 25, 2, 262, 263, 5, 13, 7, 2, 263, 264, 5, 13, 7, 2, 264, 265, 5, - 31, 16, 2, 265, 82, 3, 2, 2, 2, 266, 269, 5, 85, 43, 2, 267, 269, 5, 87, - 44, 2, 268, 266, 3, 2, 2, 2, 268, 267, 3, 2, 2, 2, 269, 84, 3, 2, 2, 2, - 270, 271, 5, 43, 22, 2, 271, 272, 5, 39, 20, 2, 272, 273, 5, 45, 23, 2, - 273, 274, 5, 13, 7, 2, 274, 86, 3, 2, 2, 2, 275, 276, 5, 15, 8, 2, 276, - 277, 5, 5, 3, 2, 277, 278, 5, 27, 14, 2, 278, 279, 5, 41, 21, 2, 279, 280, - 5, 13, 7, 2, 280, 88, 3, 2, 2, 2, 281, 282, 7, 102, 2, 2, 282, 283, 7, - 99, 2, 2, 283, 284, 7, 118, 2, 2, 284, 285, 7, 103, 2, 2, 285, 286, 7, - 118, 2, 2, 286, 287, 7, 107, 2, 2, 287, 288, 7, 111, 2, 2, 288, 289, 7, - 103, 2, 2, 289, 290, 7, 42, 2, 2, 290, 294, 3, 2, 2, 2, 291, 293, 5, 57, - 29, 2, 292, 291, 3, 2, 2, 2, 293, 296, 3, 2, 2, 2, 294, 292, 3, 2, 2, 2, - 294, 295, 3, 2, 2, 2, 295, 297, 3, 2, 2, 2, 296, 294, 3, 2, 2, 2, 297, - 301, 5, 131, 66, 2, 298, 300, 5, 57, 29, 2, 299, 298, 3, 2, 2, 2, 300, - 303, 3, 2, 2, 2, 301, 299, 3, 2, 2, 2, 301, 302, 3, 2, 2, 2, 302, 304, - 3, 2, 2, 2, 303, 301, 3, 2, 2, 2, 304, 305, 7, 43, 2, 2, 305, 90, 3, 2, - 2, 2, 306, 307, 5, 95, 48, 2, 307, 308, 7, 47, 2, 2, 308, 309, 5, 97, 49, - 2, 309, 310, 7, 47, 2, 2, 310, 311, 5, 99, 50, 2, 311, 92, 3, 2, 2, 2, - 312, 313, 5, 101, 51, 2, 313, 314, 7, 60, 2, 2, 314, 315, 5, 103, 52, 2, - 315, 316, 7, 60, 2, 2, 316, 319, 5, 105, 53, 2, 317, 318, 7, 48, 2, 2, - 318, 320, 5, 107, 54, 2, 319, 317, 3, 2, 2, 2, 319, 320, 3, 2, 2, 2, 320, - 321, 3, 2, 2, 2, 321, 322, 5, 109, 55, 2, 322, 94, 3, 2, 2, 2, 323, 325, - 5, 121, 61, 2, 324, 323, 3, 2, 2, 2, 325, 326, 3, 2, 2, 2, 326, 324, 3, - 2, 2, 2, 326, 327, 3, 2, 2, 2, 327, 96, 3, 2, 2, 2, 328, 329, 7, 50, 2, - 2, 329, 333, 9, 29, 2, 2, 330, 331, 7, 51, 2, 2, 331, 333, 9, 30, 2, 2, - 332, 328, 3, 2, 2, 2, 332, 330, 3, 2, 2, 2, 333, 98, 3, 2, 2, 2, 334, 335, - 7, 50, 2, 2, 335, 341, 9, 29, 2, 2, 336, 337, 9, 31, 2, 2, 337, 341, 9, - 32, 2, 2, 338, 339, 7, 53, 2, 2, 339, 341, 9, 33, 2, 2, 340, 334, 3, 2, - 2, 2, 340, 336, 3, 2, 2, 2, 340, 338, 3, 2, 2, 2, 341, 100, 3, 2, 2, 2, - 342, 343, 9, 33, 2, 2, 343, 347, 9, 32, 2, 2, 344, 345, 7, 52, 2, 2, 345, - 347, 9, 34, 2, 2, 346, 342, 3, 2, 2, 2, 346, 344, 3, 2, 2, 2, 347, 102, - 3, 2, 2, 2, 348, 349, 9, 35, 2, 2, 349, 350, 9, 32, 2, 2, 350, 104, 3, - 2, 2, 2, 351, 352, 9, 35, 2, 2, 352, 356, 9, 32, 2, 2, 353, 354, 7, 56, - 2, 2, 354, 356, 7, 50, 2, 2, 355, 351, 3, 2, 2, 2, 355, 353, 3, 2, 2, 2, - 356, 106, 3, 2, 2, 2, 357, 359, 9, 32, 2, 2, 358, 357, 3, 2, 2, 2, 359, - 360, 3, 2, 2, 2, 360, 358, 3, 2, 2, 2, 360, 361, 3, 2, 2, 2, 361, 108, - 3, 2, 2, 2, 362, 369, 5, 55, 28, 2, 363, 364, 9, 36, 2, 2, 364, 365, 5, - 111, 56, 2, 365, 366, 7, 60, 2, 2, 366, 367, 5, 113, 57, 2, 367, 369, 3, - 2, 2, 2, 368, 362, 3, 2, 2, 2, 368, 363, 3, 2, 2, 2, 369, 110, 3, 2, 2, - 2, 370, 371, 9, 33, 2, 2, 371, 375, 9, 32, 2, 2, 372, 373, 7, 52, 2, 2, - 373, 375, 9, 34, 2, 2, 374, 370, 3, 2, 2, 2, 374, 372, 3, 2, 2, 2, 375, - 112, 3, 2, 2, 2, 376, 377, 9, 35, 2, 2, 377, 378, 9, 32, 2, 2, 378, 114, - 3, 2, 2, 2, 379, 384, 7, 36, 2, 2, 380, 383, 5, 125, 63, 2, 381, 383, 5, - 133, 67, 2, 382, 380, 3, 2, 2, 2, 382, 381, 3, 2, 2, 2, 383, 386, 3, 2, - 2, 2, 384, 382, 3, 2, 2, 2, 384, 385, 3, 2, 2, 2, 385, 387, 3, 2, 2, 2, - 386, 384, 3, 2, 2, 2, 387, 388, 7, 36, 2, 2, 388, 116, 3, 2, 2, 2, 389, - 391, 7, 47, 2, 2, 390, 389, 3, 2, 2, 2, 390, 391, 3, 2, 2, 2, 391, 392, - 3, 2, 2, 2, 392, 399, 5, 121, 61, 2, 393, 395, 7, 48, 2, 2, 394, 396, 9, - 32, 2, 2, 395, 394, 3, 2, 2, 2, 396, 397, 3, 2, 2, 2, 397, 395, 3, 2, 2, - 2, 397, 398, 3, 2, 2, 2, 398, 400, 3, 2, 2, 2, 399, 393, 3, 2, 2, 2, 399, - 400, 3, 2, 2, 2, 400, 402, 3, 2, 2, 2, 401, 403, 5, 123, 62, 2, 402, 401, - 3, 2, 2, 2, 402, 403, 3, 2, 2, 2, 403, 118, 3, 2, 2, 2, 404, 405, 5, 31, - 16, 2, 405, 406, 5, 45, 23, 2, 406, 407, 5, 27, 14, 2, 407, 408, 5, 27, - 14, 2, 408, 120, 3, 2, 2, 2, 409, 418, 7, 50, 2, 2, 410, 414, 9, 29, 2, - 2, 411, 413, 9, 32, 2, 2, 412, 411, 3, 2, 2, 2, 413, 416, 3, 2, 2, 2, 414, - 412, 3, 2, 2, 2, 414, 415, 3, 2, 2, 2, 415, 418, 3, 2, 2, 2, 416, 414, - 3, 2, 2, 2, 417, 409, 3, 2, 2, 2, 417, 410, 3, 2, 2, 2, 418, 122, 3, 2, - 2, 2, 419, 421, 9, 6, 2, 2, 420, 422, 9, 36, 2, 2, 421, 420, 3, 2, 2, 2, - 421, 422, 3, 2, 2, 2, 422, 423, 3, 2, 2, 2, 423, 424, 5, 121, 61, 2, 424, - 124, 3, 2, 2, 2, 425, 426, 7, 94, 2, 2, 426, 427, 9, 37, 2, 2, 427, 126, - 3, 2, 2, 2, 428, 429, 7, 48, 2, 2, 429, 128, 3, 2, 2, 2, 430, 434, 9, 38, - 2, 2, 431, 433, 9, 39, 2, 2, 432, 431, 3, 2, 2, 2, 433, 436, 3, 2, 2, 2, - 434, 432, 3, 2, 2, 2, 434, 435, 3, 2, 2, 2, 435, 447, 3, 2, 2, 2, 436, - 434, 3, 2, 2, 2, 437, 438, 5, 127, 64, 2, 438, 442, 9, 38, 2, 2, 439, 441, - 9, 39, 2, 2, 440, 439, 3, 2, 2, 2, 441, 444, 3, 2, 2, 2, 442, 440, 3, 2, - 2, 2, 442, 443, 3, 2, 2, 2, 443, 446, 3, 2, 2, 2, 444, 442, 3, 2, 2, 2, - 445, 437, 3, 2, 2, 2, 446, 449, 3, 2, 2, 2, 447, 445, 3, 2, 2, 2, 447, - 448, 3, 2, 2, 2, 448, 475, 3, 2, 2, 2, 449, 447, 3, 2, 2, 2, 450, 452, - 7, 41, 2, 2, 451, 450, 3, 2, 2, 2, 451, 452, 3, 2, 2, 2, 452, 453, 3, 2, - 2, 2, 453, 457, 9, 38, 2, 2, 454, 456, 9, 39, 2, 2, 455, 454, 3, 2, 2, - 2, 456, 459, 3, 2, 2, 2, 457, 455, 3, 2, 2, 2, 457, 458, 3, 2, 2, 2, 458, - 470, 3, 2, 2, 2, 459, 457, 3, 2, 2, 2, 460, 461, 5, 127, 64, 2, 461, 465, - 9, 38, 2, 2, 462, 464, 9, 39, 2, 2, 463, 462, 3, 2, 2, 2, 464, 467, 3, - 2, 2, 2, 465, 463, 3, 2, 2, 2, 465, 466, 3, 2, 2, 2, 466, 469, 3, 2, 2, - 2, 467, 465, 3, 2, 2, 2, 468, 460, 3, 2, 2, 2, 469, 472, 3, 2, 2, 2, 470, - 468, 3, 2, 2, 2, 470, 471, 3, 2, 2, 2, 471, 473, 3, 2, 2, 2, 472, 470, - 3, 2, 2, 2, 473, 475, 7, 41, 2, 2, 474, 430, 3, 2, 2, 2, 474, 451, 3, 2, - 2, 2, 475, 130, 3, 2, 2, 2, 476, 477, 5, 91, 46, 2, 477, 478, 5, 43, 22, - 2, 478, 479, 5, 93, 47, 2, 479, 132, 3, 2, 2, 2, 480, 481, 10, 40, 2, 2, - 481, 134, 3, 2, 2, 2, 40, 2, 208, 212, 215, 225, 227, 243, 254, 256, 268, - 294, 301, 319, 326, 332, 340, 346, 355, 360, 368, 374, 382, 384, 390, 397, - 399, 402, 414, 417, 421, 434, 442, 447, 451, 457, 465, 470, 474, 2, -} - -var lexerDeserializer = antlr.NewATNDeserializer(nil) -var lexerAtn = lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn) - -var lexerChannelNames = []string{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", -} - -var lexerModeNames = []string{ - "DEFAULT_MODE", -} - -var lexerLiteralNames = []string{ - "", "','", "", "'('", "')'", "'['", "']'", -} - -var lexerSymbolicNames = []string{ - "", "", "WS", "LPAREN", "RPAREN", "LBRACKET", "RBRACKET", "AND", "OR", - "LT", "GT", "EQ", "CONTAINS", "IN", "BETWEEN", "BOOL", "DATETIME", "STRING", - "NUMBER", "NULL", "IDENTIFIER", "RFC3339_DATE_TIME", -} - -var lexerRuleNames = []string{ - "T__0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", - "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "WS", - "LPAREN", "RPAREN", "LBRACKET", "RBRACKET", "AND", "OR", "LT", "GT", "EQ", - "CONTAINS", "IN", "BETWEEN", "BOOL", "TRUE", "FALSE", "DATETIME", "FULL_DATE", - "FULL_TIME", "YEAR", "MONTH", "DAY", "HOUR", "MINUTE", "SECOND", "SECOND_FRACTION", - "TIME_NUM_OFFSET", "TIME_NUM_OFFSET_HOUR", "TIME_NUM_OFFSET_MINUTE", "STRING", - "NUMBER", "NULL", "INT", "EXP", "ESC", "IDENTSEP", "IDENTIFIER", "RFC3339_DATE_TIME", - "SAFECODEPOINT", -} - -type ZitiQlLexer struct { - *antlr.BaseLexer - channelNames []string - modeNames []string - // TODO: EOF string -} - -var lexerDecisionToDFA = make([]*antlr.DFA, len(lexerAtn.DecisionToState)) - -func init() { - for index, ds := range lexerAtn.DecisionToState { - lexerDecisionToDFA[index] = antlr.NewDFA(ds, index) - } -} - -func NewZitiQlLexer(input antlr.CharStream) *ZitiQlLexer { - - l := new(ZitiQlLexer) - - l.BaseLexer = antlr.NewBaseLexer(input) - l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache()) - - l.channelNames = lexerChannelNames - l.modeNames = lexerModeNames - l.RuleNames = lexerRuleNames - l.LiteralNames = lexerLiteralNames - l.SymbolicNames = lexerSymbolicNames - l.GrammarFileName = "ZitiQl.g4" - // TODO: l.EOF = antlr.TokenEOF - - return l -} - -// ZitiQlLexer tokens. -const ( - ZitiQlLexerT__0 = 1 - ZitiQlLexerWS = 2 - ZitiQlLexerLPAREN = 3 - ZitiQlLexerRPAREN = 4 - ZitiQlLexerLBRACKET = 5 - ZitiQlLexerRBRACKET = 6 - ZitiQlLexerAND = 7 - ZitiQlLexerOR = 8 - ZitiQlLexerLT = 9 - ZitiQlLexerGT = 10 - ZitiQlLexerEQ = 11 - ZitiQlLexerCONTAINS = 12 - ZitiQlLexerIN = 13 - ZitiQlLexerBETWEEN = 14 - ZitiQlLexerBOOL = 15 - ZitiQlLexerDATETIME = 16 - ZitiQlLexerSTRING = 17 - ZitiQlLexerNUMBER = 18 - ZitiQlLexerNULL = 19 - ZitiQlLexerIDENTIFIER = 20 - ZitiQlLexerRFC3339_DATE_TIME = 21 -) +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Code generated from ZitiQl.g4 by ANTLR 4.7.1. DO NOT EDIT. + +package zitiql + +import ( + "fmt" + "unicode" + + "github.com/antlr/antlr4/runtime/Go/antlr" +) + +// Suppress unused import error +var _ = fmt.Printf +var _ = unicode.IsLetter + +var serializedLexerAtn = []uint16{ + 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 23, 482, + 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, + 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, + 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, + 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, + 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, + 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, + 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, + 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, + 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, + 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, + 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, + 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, + 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, + 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, + 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, + 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, + 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, + 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 31, 3, 31, + 3, 32, 3, 32, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, + 35, 3, 36, 3, 36, 5, 36, 209, 10, 36, 3, 37, 3, 37, 5, 37, 213, 10, 37, + 3, 38, 5, 38, 216, 10, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 39, 6, + 39, 224, 10, 39, 13, 39, 14, 39, 225, 5, 39, 228, 10, 39, 3, 39, 3, 39, + 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, + 40, 3, 40, 5, 40, 244, 10, 40, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, + 3, 41, 6, 41, 253, 10, 41, 13, 41, 14, 41, 254, 5, 41, 257, 10, 41, 3, + 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 5, 42, + 269, 10, 42, 3, 43, 3, 43, 3, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, + 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, + 3, 45, 3, 45, 3, 45, 7, 45, 293, 10, 45, 12, 45, 14, 45, 296, 11, 45, 3, + 45, 3, 45, 7, 45, 300, 10, 45, 12, 45, 14, 45, 303, 11, 45, 3, 45, 3, 45, + 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 47, 3, 47, 3, + 47, 3, 47, 3, 47, 5, 47, 320, 10, 47, 3, 47, 3, 47, 3, 48, 6, 48, 325, + 10, 48, 13, 48, 14, 48, 326, 3, 49, 3, 49, 3, 49, 3, 49, 5, 49, 333, 10, + 49, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 5, 50, 341, 10, 50, 3, 51, + 3, 51, 3, 51, 3, 51, 5, 51, 347, 10, 51, 3, 52, 3, 52, 3, 52, 3, 53, 3, + 53, 3, 53, 3, 53, 5, 53, 356, 10, 53, 3, 54, 6, 54, 359, 10, 54, 13, 54, + 14, 54, 360, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 5, 55, 369, 10, + 55, 3, 56, 3, 56, 3, 56, 3, 56, 5, 56, 375, 10, 56, 3, 57, 3, 57, 3, 57, + 3, 58, 3, 58, 3, 58, 7, 58, 383, 10, 58, 12, 58, 14, 58, 386, 11, 58, 3, + 58, 3, 58, 3, 59, 5, 59, 391, 10, 59, 3, 59, 3, 59, 3, 59, 6, 59, 396, + 10, 59, 13, 59, 14, 59, 397, 5, 59, 400, 10, 59, 3, 59, 5, 59, 403, 10, + 59, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 3, 61, 3, 61, 3, 61, 7, 61, 413, + 10, 61, 12, 61, 14, 61, 416, 11, 61, 5, 61, 418, 10, 61, 3, 62, 3, 62, + 5, 62, 422, 10, 62, 3, 62, 3, 62, 3, 63, 3, 63, 3, 63, 3, 64, 3, 64, 3, + 65, 3, 65, 7, 65, 433, 10, 65, 12, 65, 14, 65, 436, 11, 65, 3, 65, 3, 65, + 3, 65, 7, 65, 441, 10, 65, 12, 65, 14, 65, 444, 11, 65, 7, 65, 446, 10, + 65, 12, 65, 14, 65, 449, 11, 65, 3, 65, 5, 65, 452, 10, 65, 3, 65, 3, 65, + 7, 65, 456, 10, 65, 12, 65, 14, 65, 459, 11, 65, 3, 65, 3, 65, 3, 65, 7, + 65, 464, 10, 65, 12, 65, 14, 65, 467, 11, 65, 7, 65, 469, 10, 65, 12, 65, + 14, 65, 472, 11, 65, 3, 65, 5, 65, 475, 10, 65, 3, 66, 3, 66, 3, 66, 3, + 66, 3, 67, 3, 67, 2, 2, 68, 3, 3, 5, 2, 7, 2, 9, 2, 11, 2, 13, 2, 15, 2, + 17, 2, 19, 2, 21, 2, 23, 2, 25, 2, 27, 2, 29, 2, 31, 2, 33, 2, 35, 2, 37, + 2, 39, 2, 41, 2, 43, 2, 45, 2, 47, 2, 49, 2, 51, 2, 53, 2, 55, 2, 57, 4, + 59, 5, 61, 6, 63, 7, 65, 8, 67, 9, 69, 10, 71, 11, 73, 12, 75, 13, 77, + 14, 79, 15, 81, 16, 83, 17, 85, 2, 87, 2, 89, 18, 91, 2, 93, 2, 95, 2, + 97, 2, 99, 2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2, 113, 2, 115, + 19, 117, 20, 119, 21, 121, 2, 123, 2, 125, 2, 127, 2, 129, 22, 131, 23, + 133, 2, 3, 2, 41, 4, 2, 67, 67, 99, 99, 4, 2, 68, 68, 100, 100, 4, 2, 69, + 69, 101, 101, 4, 2, 70, 70, 102, 102, 4, 2, 71, 71, 103, 103, 4, 2, 72, + 72, 104, 104, 4, 2, 73, 73, 105, 105, 4, 2, 74, 74, 106, 106, 4, 2, 75, + 75, 107, 107, 4, 2, 76, 76, 108, 108, 4, 2, 77, 77, 109, 109, 4, 2, 78, + 78, 110, 110, 4, 2, 79, 79, 111, 111, 4, 2, 80, 80, 112, 112, 4, 2, 81, + 81, 113, 113, 4, 2, 82, 82, 114, 114, 4, 2, 83, 83, 115, 115, 4, 2, 84, + 84, 116, 116, 4, 2, 85, 85, 117, 117, 4, 2, 86, 86, 118, 118, 4, 2, 87, + 87, 119, 119, 4, 2, 88, 88, 120, 120, 4, 2, 89, 89, 121, 121, 4, 2, 90, + 90, 122, 122, 4, 2, 91, 91, 123, 123, 4, 2, 92, 92, 124, 124, 5, 2, 11, + 12, 15, 15, 34, 34, 3, 2, 51, 59, 3, 2, 50, 52, 3, 2, 51, 52, 3, 2, 50, + 59, 3, 2, 50, 51, 3, 2, 50, 53, 3, 2, 50, 55, 4, 2, 45, 45, 47, 47, 8, + 2, 36, 36, 94, 94, 104, 104, 112, 112, 116, 116, 118, 118, 4, 2, 67, 92, + 99, 124, 5, 2, 67, 92, 97, 97, 99, 124, 5, 2, 2, 33, 36, 36, 94, 94, 2, + 474, 2, 3, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, + 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, + 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, + 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, + 2, 89, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 117, 3, 2, 2, 2, 2, 119, 3, 2, + 2, 2, 2, 129, 3, 2, 2, 2, 2, 131, 3, 2, 2, 2, 3, 135, 3, 2, 2, 2, 5, 137, + 3, 2, 2, 2, 7, 139, 3, 2, 2, 2, 9, 141, 3, 2, 2, 2, 11, 143, 3, 2, 2, 2, + 13, 145, 3, 2, 2, 2, 15, 147, 3, 2, 2, 2, 17, 149, 3, 2, 2, 2, 19, 151, + 3, 2, 2, 2, 21, 153, 3, 2, 2, 2, 23, 155, 3, 2, 2, 2, 25, 157, 3, 2, 2, + 2, 27, 159, 3, 2, 2, 2, 29, 161, 3, 2, 2, 2, 31, 163, 3, 2, 2, 2, 33, 165, + 3, 2, 2, 2, 35, 167, 3, 2, 2, 2, 37, 169, 3, 2, 2, 2, 39, 171, 3, 2, 2, + 2, 41, 173, 3, 2, 2, 2, 43, 175, 3, 2, 2, 2, 45, 177, 3, 2, 2, 2, 47, 179, + 3, 2, 2, 2, 49, 181, 3, 2, 2, 2, 51, 183, 3, 2, 2, 2, 53, 185, 3, 2, 2, + 2, 55, 187, 3, 2, 2, 2, 57, 189, 3, 2, 2, 2, 59, 191, 3, 2, 2, 2, 61, 193, + 3, 2, 2, 2, 63, 195, 3, 2, 2, 2, 65, 197, 3, 2, 2, 2, 67, 199, 3, 2, 2, + 2, 69, 203, 3, 2, 2, 2, 71, 206, 3, 2, 2, 2, 73, 210, 3, 2, 2, 2, 75, 215, + 3, 2, 2, 2, 77, 227, 3, 2, 2, 2, 79, 243, 3, 2, 2, 2, 81, 256, 3, 2, 2, + 2, 83, 268, 3, 2, 2, 2, 85, 270, 3, 2, 2, 2, 87, 275, 3, 2, 2, 2, 89, 281, + 3, 2, 2, 2, 91, 306, 3, 2, 2, 2, 93, 312, 3, 2, 2, 2, 95, 324, 3, 2, 2, + 2, 97, 332, 3, 2, 2, 2, 99, 340, 3, 2, 2, 2, 101, 346, 3, 2, 2, 2, 103, + 348, 3, 2, 2, 2, 105, 355, 3, 2, 2, 2, 107, 358, 3, 2, 2, 2, 109, 368, + 3, 2, 2, 2, 111, 374, 3, 2, 2, 2, 113, 376, 3, 2, 2, 2, 115, 379, 3, 2, + 2, 2, 117, 390, 3, 2, 2, 2, 119, 404, 3, 2, 2, 2, 121, 417, 3, 2, 2, 2, + 123, 419, 3, 2, 2, 2, 125, 425, 3, 2, 2, 2, 127, 428, 3, 2, 2, 2, 129, + 474, 3, 2, 2, 2, 131, 476, 3, 2, 2, 2, 133, 480, 3, 2, 2, 2, 135, 136, + 7, 46, 2, 2, 136, 4, 3, 2, 2, 2, 137, 138, 9, 2, 2, 2, 138, 6, 3, 2, 2, + 2, 139, 140, 9, 3, 2, 2, 140, 8, 3, 2, 2, 2, 141, 142, 9, 4, 2, 2, 142, + 10, 3, 2, 2, 2, 143, 144, 9, 5, 2, 2, 144, 12, 3, 2, 2, 2, 145, 146, 9, + 6, 2, 2, 146, 14, 3, 2, 2, 2, 147, 148, 9, 7, 2, 2, 148, 16, 3, 2, 2, 2, + 149, 150, 9, 8, 2, 2, 150, 18, 3, 2, 2, 2, 151, 152, 9, 9, 2, 2, 152, 20, + 3, 2, 2, 2, 153, 154, 9, 10, 2, 2, 154, 22, 3, 2, 2, 2, 155, 156, 9, 11, + 2, 2, 156, 24, 3, 2, 2, 2, 157, 158, 9, 12, 2, 2, 158, 26, 3, 2, 2, 2, + 159, 160, 9, 13, 2, 2, 160, 28, 3, 2, 2, 2, 161, 162, 9, 14, 2, 2, 162, + 30, 3, 2, 2, 2, 163, 164, 9, 15, 2, 2, 164, 32, 3, 2, 2, 2, 165, 166, 9, + 16, 2, 2, 166, 34, 3, 2, 2, 2, 167, 168, 9, 17, 2, 2, 168, 36, 3, 2, 2, + 2, 169, 170, 9, 18, 2, 2, 170, 38, 3, 2, 2, 2, 171, 172, 9, 19, 2, 2, 172, + 40, 3, 2, 2, 2, 173, 174, 9, 20, 2, 2, 174, 42, 3, 2, 2, 2, 175, 176, 9, + 21, 2, 2, 176, 44, 3, 2, 2, 2, 177, 178, 9, 22, 2, 2, 178, 46, 3, 2, 2, + 2, 179, 180, 9, 23, 2, 2, 180, 48, 3, 2, 2, 2, 181, 182, 9, 24, 2, 2, 182, + 50, 3, 2, 2, 2, 183, 184, 9, 25, 2, 2, 184, 52, 3, 2, 2, 2, 185, 186, 9, + 26, 2, 2, 186, 54, 3, 2, 2, 2, 187, 188, 9, 27, 2, 2, 188, 56, 3, 2, 2, + 2, 189, 190, 9, 28, 2, 2, 190, 58, 3, 2, 2, 2, 191, 192, 7, 42, 2, 2, 192, + 60, 3, 2, 2, 2, 193, 194, 7, 43, 2, 2, 194, 62, 3, 2, 2, 2, 195, 196, 7, + 93, 2, 2, 196, 64, 3, 2, 2, 2, 197, 198, 7, 95, 2, 2, 198, 66, 3, 2, 2, + 2, 199, 200, 5, 5, 3, 2, 200, 201, 5, 31, 16, 2, 201, 202, 5, 11, 6, 2, + 202, 68, 3, 2, 2, 2, 203, 204, 5, 33, 17, 2, 204, 205, 5, 39, 20, 2, 205, + 70, 3, 2, 2, 2, 206, 208, 7, 62, 2, 2, 207, 209, 7, 63, 2, 2, 208, 207, + 3, 2, 2, 2, 208, 209, 3, 2, 2, 2, 209, 72, 3, 2, 2, 2, 210, 212, 7, 64, + 2, 2, 211, 213, 7, 63, 2, 2, 212, 211, 3, 2, 2, 2, 212, 213, 3, 2, 2, 2, + 213, 74, 3, 2, 2, 2, 214, 216, 7, 35, 2, 2, 215, 214, 3, 2, 2, 2, 215, + 216, 3, 2, 2, 2, 216, 217, 3, 2, 2, 2, 217, 218, 7, 63, 2, 2, 218, 76, + 3, 2, 2, 2, 219, 220, 5, 31, 16, 2, 220, 221, 5, 33, 17, 2, 221, 223, 5, + 43, 22, 2, 222, 224, 5, 57, 29, 2, 223, 222, 3, 2, 2, 2, 224, 225, 3, 2, + 2, 2, 225, 223, 3, 2, 2, 2, 225, 226, 3, 2, 2, 2, 226, 228, 3, 2, 2, 2, + 227, 219, 3, 2, 2, 2, 227, 228, 3, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229, + 230, 5, 9, 5, 2, 230, 231, 5, 33, 17, 2, 231, 232, 5, 31, 16, 2, 232, 233, + 5, 43, 22, 2, 233, 234, 5, 5, 3, 2, 234, 235, 5, 21, 11, 2, 235, 236, 5, + 31, 16, 2, 236, 237, 5, 41, 21, 2, 237, 78, 3, 2, 2, 2, 238, 239, 5, 31, + 16, 2, 239, 240, 5, 33, 17, 2, 240, 241, 5, 43, 22, 2, 241, 242, 5, 57, + 29, 2, 242, 244, 3, 2, 2, 2, 243, 238, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, + 244, 245, 3, 2, 2, 2, 245, 246, 5, 21, 11, 2, 246, 247, 5, 31, 16, 2, 247, + 80, 3, 2, 2, 2, 248, 249, 5, 31, 16, 2, 249, 250, 5, 33, 17, 2, 250, 252, + 5, 43, 22, 2, 251, 253, 5, 57, 29, 2, 252, 251, 3, 2, 2, 2, 253, 254, 3, + 2, 2, 2, 254, 252, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 257, 3, 2, 2, + 2, 256, 248, 3, 2, 2, 2, 256, 257, 3, 2, 2, 2, 257, 258, 3, 2, 2, 2, 258, + 259, 5, 7, 4, 2, 259, 260, 5, 13, 7, 2, 260, 261, 5, 43, 22, 2, 261, 262, + 5, 49, 25, 2, 262, 263, 5, 13, 7, 2, 263, 264, 5, 13, 7, 2, 264, 265, 5, + 31, 16, 2, 265, 82, 3, 2, 2, 2, 266, 269, 5, 85, 43, 2, 267, 269, 5, 87, + 44, 2, 268, 266, 3, 2, 2, 2, 268, 267, 3, 2, 2, 2, 269, 84, 3, 2, 2, 2, + 270, 271, 5, 43, 22, 2, 271, 272, 5, 39, 20, 2, 272, 273, 5, 45, 23, 2, + 273, 274, 5, 13, 7, 2, 274, 86, 3, 2, 2, 2, 275, 276, 5, 15, 8, 2, 276, + 277, 5, 5, 3, 2, 277, 278, 5, 27, 14, 2, 278, 279, 5, 41, 21, 2, 279, 280, + 5, 13, 7, 2, 280, 88, 3, 2, 2, 2, 281, 282, 7, 102, 2, 2, 282, 283, 7, + 99, 2, 2, 283, 284, 7, 118, 2, 2, 284, 285, 7, 103, 2, 2, 285, 286, 7, + 118, 2, 2, 286, 287, 7, 107, 2, 2, 287, 288, 7, 111, 2, 2, 288, 289, 7, + 103, 2, 2, 289, 290, 7, 42, 2, 2, 290, 294, 3, 2, 2, 2, 291, 293, 5, 57, + 29, 2, 292, 291, 3, 2, 2, 2, 293, 296, 3, 2, 2, 2, 294, 292, 3, 2, 2, 2, + 294, 295, 3, 2, 2, 2, 295, 297, 3, 2, 2, 2, 296, 294, 3, 2, 2, 2, 297, + 301, 5, 131, 66, 2, 298, 300, 5, 57, 29, 2, 299, 298, 3, 2, 2, 2, 300, + 303, 3, 2, 2, 2, 301, 299, 3, 2, 2, 2, 301, 302, 3, 2, 2, 2, 302, 304, + 3, 2, 2, 2, 303, 301, 3, 2, 2, 2, 304, 305, 7, 43, 2, 2, 305, 90, 3, 2, + 2, 2, 306, 307, 5, 95, 48, 2, 307, 308, 7, 47, 2, 2, 308, 309, 5, 97, 49, + 2, 309, 310, 7, 47, 2, 2, 310, 311, 5, 99, 50, 2, 311, 92, 3, 2, 2, 2, + 312, 313, 5, 101, 51, 2, 313, 314, 7, 60, 2, 2, 314, 315, 5, 103, 52, 2, + 315, 316, 7, 60, 2, 2, 316, 319, 5, 105, 53, 2, 317, 318, 7, 48, 2, 2, + 318, 320, 5, 107, 54, 2, 319, 317, 3, 2, 2, 2, 319, 320, 3, 2, 2, 2, 320, + 321, 3, 2, 2, 2, 321, 322, 5, 109, 55, 2, 322, 94, 3, 2, 2, 2, 323, 325, + 5, 121, 61, 2, 324, 323, 3, 2, 2, 2, 325, 326, 3, 2, 2, 2, 326, 324, 3, + 2, 2, 2, 326, 327, 3, 2, 2, 2, 327, 96, 3, 2, 2, 2, 328, 329, 7, 50, 2, + 2, 329, 333, 9, 29, 2, 2, 330, 331, 7, 51, 2, 2, 331, 333, 9, 30, 2, 2, + 332, 328, 3, 2, 2, 2, 332, 330, 3, 2, 2, 2, 333, 98, 3, 2, 2, 2, 334, 335, + 7, 50, 2, 2, 335, 341, 9, 29, 2, 2, 336, 337, 9, 31, 2, 2, 337, 341, 9, + 32, 2, 2, 338, 339, 7, 53, 2, 2, 339, 341, 9, 33, 2, 2, 340, 334, 3, 2, + 2, 2, 340, 336, 3, 2, 2, 2, 340, 338, 3, 2, 2, 2, 341, 100, 3, 2, 2, 2, + 342, 343, 9, 33, 2, 2, 343, 347, 9, 32, 2, 2, 344, 345, 7, 52, 2, 2, 345, + 347, 9, 34, 2, 2, 346, 342, 3, 2, 2, 2, 346, 344, 3, 2, 2, 2, 347, 102, + 3, 2, 2, 2, 348, 349, 9, 35, 2, 2, 349, 350, 9, 32, 2, 2, 350, 104, 3, + 2, 2, 2, 351, 352, 9, 35, 2, 2, 352, 356, 9, 32, 2, 2, 353, 354, 7, 56, + 2, 2, 354, 356, 7, 50, 2, 2, 355, 351, 3, 2, 2, 2, 355, 353, 3, 2, 2, 2, + 356, 106, 3, 2, 2, 2, 357, 359, 9, 32, 2, 2, 358, 357, 3, 2, 2, 2, 359, + 360, 3, 2, 2, 2, 360, 358, 3, 2, 2, 2, 360, 361, 3, 2, 2, 2, 361, 108, + 3, 2, 2, 2, 362, 369, 5, 55, 28, 2, 363, 364, 9, 36, 2, 2, 364, 365, 5, + 111, 56, 2, 365, 366, 7, 60, 2, 2, 366, 367, 5, 113, 57, 2, 367, 369, 3, + 2, 2, 2, 368, 362, 3, 2, 2, 2, 368, 363, 3, 2, 2, 2, 369, 110, 3, 2, 2, + 2, 370, 371, 9, 33, 2, 2, 371, 375, 9, 32, 2, 2, 372, 373, 7, 52, 2, 2, + 373, 375, 9, 34, 2, 2, 374, 370, 3, 2, 2, 2, 374, 372, 3, 2, 2, 2, 375, + 112, 3, 2, 2, 2, 376, 377, 9, 35, 2, 2, 377, 378, 9, 32, 2, 2, 378, 114, + 3, 2, 2, 2, 379, 384, 7, 36, 2, 2, 380, 383, 5, 125, 63, 2, 381, 383, 5, + 133, 67, 2, 382, 380, 3, 2, 2, 2, 382, 381, 3, 2, 2, 2, 383, 386, 3, 2, + 2, 2, 384, 382, 3, 2, 2, 2, 384, 385, 3, 2, 2, 2, 385, 387, 3, 2, 2, 2, + 386, 384, 3, 2, 2, 2, 387, 388, 7, 36, 2, 2, 388, 116, 3, 2, 2, 2, 389, + 391, 7, 47, 2, 2, 390, 389, 3, 2, 2, 2, 390, 391, 3, 2, 2, 2, 391, 392, + 3, 2, 2, 2, 392, 399, 5, 121, 61, 2, 393, 395, 7, 48, 2, 2, 394, 396, 9, + 32, 2, 2, 395, 394, 3, 2, 2, 2, 396, 397, 3, 2, 2, 2, 397, 395, 3, 2, 2, + 2, 397, 398, 3, 2, 2, 2, 398, 400, 3, 2, 2, 2, 399, 393, 3, 2, 2, 2, 399, + 400, 3, 2, 2, 2, 400, 402, 3, 2, 2, 2, 401, 403, 5, 123, 62, 2, 402, 401, + 3, 2, 2, 2, 402, 403, 3, 2, 2, 2, 403, 118, 3, 2, 2, 2, 404, 405, 5, 31, + 16, 2, 405, 406, 5, 45, 23, 2, 406, 407, 5, 27, 14, 2, 407, 408, 5, 27, + 14, 2, 408, 120, 3, 2, 2, 2, 409, 418, 7, 50, 2, 2, 410, 414, 9, 29, 2, + 2, 411, 413, 9, 32, 2, 2, 412, 411, 3, 2, 2, 2, 413, 416, 3, 2, 2, 2, 414, + 412, 3, 2, 2, 2, 414, 415, 3, 2, 2, 2, 415, 418, 3, 2, 2, 2, 416, 414, + 3, 2, 2, 2, 417, 409, 3, 2, 2, 2, 417, 410, 3, 2, 2, 2, 418, 122, 3, 2, + 2, 2, 419, 421, 9, 6, 2, 2, 420, 422, 9, 36, 2, 2, 421, 420, 3, 2, 2, 2, + 421, 422, 3, 2, 2, 2, 422, 423, 3, 2, 2, 2, 423, 424, 5, 121, 61, 2, 424, + 124, 3, 2, 2, 2, 425, 426, 7, 94, 2, 2, 426, 427, 9, 37, 2, 2, 427, 126, + 3, 2, 2, 2, 428, 429, 7, 48, 2, 2, 429, 128, 3, 2, 2, 2, 430, 434, 9, 38, + 2, 2, 431, 433, 9, 39, 2, 2, 432, 431, 3, 2, 2, 2, 433, 436, 3, 2, 2, 2, + 434, 432, 3, 2, 2, 2, 434, 435, 3, 2, 2, 2, 435, 447, 3, 2, 2, 2, 436, + 434, 3, 2, 2, 2, 437, 438, 5, 127, 64, 2, 438, 442, 9, 38, 2, 2, 439, 441, + 9, 39, 2, 2, 440, 439, 3, 2, 2, 2, 441, 444, 3, 2, 2, 2, 442, 440, 3, 2, + 2, 2, 442, 443, 3, 2, 2, 2, 443, 446, 3, 2, 2, 2, 444, 442, 3, 2, 2, 2, + 445, 437, 3, 2, 2, 2, 446, 449, 3, 2, 2, 2, 447, 445, 3, 2, 2, 2, 447, + 448, 3, 2, 2, 2, 448, 475, 3, 2, 2, 2, 449, 447, 3, 2, 2, 2, 450, 452, + 7, 41, 2, 2, 451, 450, 3, 2, 2, 2, 451, 452, 3, 2, 2, 2, 452, 453, 3, 2, + 2, 2, 453, 457, 9, 38, 2, 2, 454, 456, 9, 39, 2, 2, 455, 454, 3, 2, 2, + 2, 456, 459, 3, 2, 2, 2, 457, 455, 3, 2, 2, 2, 457, 458, 3, 2, 2, 2, 458, + 470, 3, 2, 2, 2, 459, 457, 3, 2, 2, 2, 460, 461, 5, 127, 64, 2, 461, 465, + 9, 38, 2, 2, 462, 464, 9, 39, 2, 2, 463, 462, 3, 2, 2, 2, 464, 467, 3, + 2, 2, 2, 465, 463, 3, 2, 2, 2, 465, 466, 3, 2, 2, 2, 466, 469, 3, 2, 2, + 2, 467, 465, 3, 2, 2, 2, 468, 460, 3, 2, 2, 2, 469, 472, 3, 2, 2, 2, 470, + 468, 3, 2, 2, 2, 470, 471, 3, 2, 2, 2, 471, 473, 3, 2, 2, 2, 472, 470, + 3, 2, 2, 2, 473, 475, 7, 41, 2, 2, 474, 430, 3, 2, 2, 2, 474, 451, 3, 2, + 2, 2, 475, 130, 3, 2, 2, 2, 476, 477, 5, 91, 46, 2, 477, 478, 5, 43, 22, + 2, 478, 479, 5, 93, 47, 2, 479, 132, 3, 2, 2, 2, 480, 481, 10, 40, 2, 2, + 481, 134, 3, 2, 2, 2, 40, 2, 208, 212, 215, 225, 227, 243, 254, 256, 268, + 294, 301, 319, 326, 332, 340, 346, 355, 360, 368, 374, 382, 384, 390, 397, + 399, 402, 414, 417, 421, 434, 442, 447, 451, 457, 465, 470, 474, 2, +} + +var lexerDeserializer = antlr.NewATNDeserializer(nil) +var lexerAtn = lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn) + +var lexerChannelNames = []string{ + "DEFAULT_TOKEN_CHANNEL", "HIDDEN", +} + +var lexerModeNames = []string{ + "DEFAULT_MODE", +} + +var lexerLiteralNames = []string{ + "", "','", "", "'('", "')'", "'['", "']'", +} + +var lexerSymbolicNames = []string{ + "", "", "WS", "LPAREN", "RPAREN", "LBRACKET", "RBRACKET", "AND", "OR", + "LT", "GT", "EQ", "CONTAINS", "IN", "BETWEEN", "BOOL", "DATETIME", "STRING", + "NUMBER", "NULL", "IDENTIFIER", "RFC3339_DATE_TIME", +} + +var lexerRuleNames = []string{ + "T__0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", + "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "WS", + "LPAREN", "RPAREN", "LBRACKET", "RBRACKET", "AND", "OR", "LT", "GT", "EQ", + "CONTAINS", "IN", "BETWEEN", "BOOL", "TRUE", "FALSE", "DATETIME", "FULL_DATE", + "FULL_TIME", "YEAR", "MONTH", "DAY", "HOUR", "MINUTE", "SECOND", "SECOND_FRACTION", + "TIME_NUM_OFFSET", "TIME_NUM_OFFSET_HOUR", "TIME_NUM_OFFSET_MINUTE", "STRING", + "NUMBER", "NULL", "INT", "EXP", "ESC", "IDENTSEP", "IDENTIFIER", "RFC3339_DATE_TIME", + "SAFECODEPOINT", +} + +type ZitiQlLexer struct { + *antlr.BaseLexer + channelNames []string + modeNames []string + // TODO: EOF string +} + +var lexerDecisionToDFA = make([]*antlr.DFA, len(lexerAtn.DecisionToState)) + +func init() { + for index, ds := range lexerAtn.DecisionToState { + lexerDecisionToDFA[index] = antlr.NewDFA(ds, index) + } +} + +func NewZitiQlLexer(input antlr.CharStream) *ZitiQlLexer { + + l := new(ZitiQlLexer) + + l.BaseLexer = antlr.NewBaseLexer(input) + l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache()) + + l.channelNames = lexerChannelNames + l.modeNames = lexerModeNames + l.RuleNames = lexerRuleNames + l.LiteralNames = lexerLiteralNames + l.SymbolicNames = lexerSymbolicNames + l.GrammarFileName = "ZitiQl.g4" + // TODO: l.EOF = antlr.TokenEOF + + return l +} + +// ZitiQlLexer tokens. +const ( + ZitiQlLexerT__0 = 1 + ZitiQlLexerWS = 2 + ZitiQlLexerLPAREN = 3 + ZitiQlLexerRPAREN = 4 + ZitiQlLexerLBRACKET = 5 + ZitiQlLexerRBRACKET = 6 + ZitiQlLexerAND = 7 + ZitiQlLexerOR = 8 + ZitiQlLexerLT = 9 + ZitiQlLexerGT = 10 + ZitiQlLexerEQ = 11 + ZitiQlLexerCONTAINS = 12 + ZitiQlLexerIN = 13 + ZitiQlLexerBETWEEN = 14 + ZitiQlLexerBOOL = 15 + ZitiQlLexerDATETIME = 16 + ZitiQlLexerSTRING = 17 + ZitiQlLexerNUMBER = 18 + ZitiQlLexerNULL = 19 + ZitiQlLexerIDENTIFIER = 20 + ZitiQlLexerRFC3339_DATE_TIME = 21 +) diff --git a/controller/zitiql/zitiql_listener.go b/controller/zitiql/zitiql_listener.go index c5807f497..970e6c91c 100644 --- a/controller/zitiql/zitiql_listener.go +++ b/controller/zitiql/zitiql_listener.go @@ -1,163 +1,163 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// Code generated from ZitiQl.g4 by ANTLR 4.7.1. DO NOT EDIT. - -package zitiql // ZitiQl -import "github.com/antlr/antlr4/runtime/Go/antlr" - -// ZitiQlListener is a complete listener for a parse tree produced by ZitiQlParser. -type ZitiQlListener interface { - antlr.ParseTreeListener - - // EnterString_array is called when entering the string_array production. - EnterString_array(c *String_arrayContext) - - // EnterNumber_array is called when entering the number_array production. - EnterNumber_array(c *Number_arrayContext) - - // EnterDatetime_array is called when entering the datetime_array production. - EnterDatetime_array(c *Datetime_arrayContext) - - // EnterEnd is called when entering the End production. - EnterEnd(c *EndContext) - - // EnterGroup is called when entering the Group production. - EnterGroup(c *GroupContext) - - // EnterOrConjunction is called when entering the OrConjunction production. - EnterOrConjunction(c *OrConjunctionContext) - - // EnterOperationOp is called when entering the OperationOp production. - EnterOperationOp(c *OperationOpContext) - - // EnterAndConjunction is called when entering the AndConjunction production. - EnterAndConjunction(c *AndConjunctionContext) - - // EnterInStringArrayOp is called when entering the InStringArrayOp production. - EnterInStringArrayOp(c *InStringArrayOpContext) - - // EnterInNumberArrayOp is called when entering the InNumberArrayOp production. - EnterInNumberArrayOp(c *InNumberArrayOpContext) - - // EnterInDatetimeArrayOp is called when entering the InDatetimeArrayOp production. - EnterInDatetimeArrayOp(c *InDatetimeArrayOpContext) - - // EnterBetweenNumberOp is called when entering the BetweenNumberOp production. - EnterBetweenNumberOp(c *BetweenNumberOpContext) - - // EnterBetweenDateOp is called when entering the BetweenDateOp production. - EnterBetweenDateOp(c *BetweenDateOpContext) - - // EnterBinaryLessThanNumberOp is called when entering the BinaryLessThanNumberOp production. - EnterBinaryLessThanNumberOp(c *BinaryLessThanNumberOpContext) - - // EnterBinaryLessThanDatetimeOp is called when entering the BinaryLessThanDatetimeOp production. - EnterBinaryLessThanDatetimeOp(c *BinaryLessThanDatetimeOpContext) - - // EnterBinaryGreaterThanNumberOp is called when entering the BinaryGreaterThanNumberOp production. - EnterBinaryGreaterThanNumberOp(c *BinaryGreaterThanNumberOpContext) - - // EnterBinaryGreaterThanDatetimeOp is called when entering the BinaryGreaterThanDatetimeOp production. - EnterBinaryGreaterThanDatetimeOp(c *BinaryGreaterThanDatetimeOpContext) - - // EnterBinaryEqualToStringOp is called when entering the BinaryEqualToStringOp production. - EnterBinaryEqualToStringOp(c *BinaryEqualToStringOpContext) - - // EnterBinaryEqualToNumberOp is called when entering the BinaryEqualToNumberOp production. - EnterBinaryEqualToNumberOp(c *BinaryEqualToNumberOpContext) - - // EnterBinaryEqualToDatetimeOp is called when entering the BinaryEqualToDatetimeOp production. - EnterBinaryEqualToDatetimeOp(c *BinaryEqualToDatetimeOpContext) - - // EnterBinaryEqualToBoolOp is called when entering the BinaryEqualToBoolOp production. - EnterBinaryEqualToBoolOp(c *BinaryEqualToBoolOpContext) - - // EnterBinaryEqualToNullOp is called when entering the BinaryEqualToNullOp production. - EnterBinaryEqualToNullOp(c *BinaryEqualToNullOpContext) - - // EnterBinaryContainsOp is called when entering the BinaryContainsOp production. - EnterBinaryContainsOp(c *BinaryContainsOpContext) - - // ExitString_array is called when exiting the string_array production. - ExitString_array(c *String_arrayContext) - - // ExitNumber_array is called when exiting the number_array production. - ExitNumber_array(c *Number_arrayContext) - - // ExitDatetime_array is called when exiting the datetime_array production. - ExitDatetime_array(c *Datetime_arrayContext) - - // ExitEnd is called when exiting the End production. - ExitEnd(c *EndContext) - - // ExitGroup is called when exiting the Group production. - ExitGroup(c *GroupContext) - - // ExitOrConjunction is called when exiting the OrConjunction production. - ExitOrConjunction(c *OrConjunctionContext) - - // ExitOperationOp is called when exiting the OperationOp production. - ExitOperationOp(c *OperationOpContext) - - // ExitAndConjunction is called when exiting the AndConjunction production. - ExitAndConjunction(c *AndConjunctionContext) - - // ExitInStringArrayOp is called when exiting the InStringArrayOp production. - ExitInStringArrayOp(c *InStringArrayOpContext) - - // ExitInNumberArrayOp is called when exiting the InNumberArrayOp production. - ExitInNumberArrayOp(c *InNumberArrayOpContext) - - // ExitInDatetimeArrayOp is called when exiting the InDatetimeArrayOp production. - ExitInDatetimeArrayOp(c *InDatetimeArrayOpContext) - - // ExitBetweenNumberOp is called when exiting the BetweenNumberOp production. - ExitBetweenNumberOp(c *BetweenNumberOpContext) - - // ExitBetweenDateOp is called when exiting the BetweenDateOp production. - ExitBetweenDateOp(c *BetweenDateOpContext) - - // ExitBinaryLessThanNumberOp is called when exiting the BinaryLessThanNumberOp production. - ExitBinaryLessThanNumberOp(c *BinaryLessThanNumberOpContext) - - // ExitBinaryLessThanDatetimeOp is called when exiting the BinaryLessThanDatetimeOp production. - ExitBinaryLessThanDatetimeOp(c *BinaryLessThanDatetimeOpContext) - - // ExitBinaryGreaterThanNumberOp is called when exiting the BinaryGreaterThanNumberOp production. - ExitBinaryGreaterThanNumberOp(c *BinaryGreaterThanNumberOpContext) - - // ExitBinaryGreaterThanDatetimeOp is called when exiting the BinaryGreaterThanDatetimeOp production. - ExitBinaryGreaterThanDatetimeOp(c *BinaryGreaterThanDatetimeOpContext) - - // ExitBinaryEqualToStringOp is called when exiting the BinaryEqualToStringOp production. - ExitBinaryEqualToStringOp(c *BinaryEqualToStringOpContext) - - // ExitBinaryEqualToNumberOp is called when exiting the BinaryEqualToNumberOp production. - ExitBinaryEqualToNumberOp(c *BinaryEqualToNumberOpContext) - - // ExitBinaryEqualToDatetimeOp is called when exiting the BinaryEqualToDatetimeOp production. - ExitBinaryEqualToDatetimeOp(c *BinaryEqualToDatetimeOpContext) - - // ExitBinaryEqualToBoolOp is called when exiting the BinaryEqualToBoolOp production. - ExitBinaryEqualToBoolOp(c *BinaryEqualToBoolOpContext) - - // ExitBinaryEqualToNullOp is called when exiting the BinaryEqualToNullOp production. - ExitBinaryEqualToNullOp(c *BinaryEqualToNullOpContext) - - // ExitBinaryContainsOp is called when exiting the BinaryContainsOp production. - ExitBinaryContainsOp(c *BinaryContainsOpContext) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Code generated from ZitiQl.g4 by ANTLR 4.7.1. DO NOT EDIT. + +package zitiql // ZitiQl +import "github.com/antlr/antlr4/runtime/Go/antlr" + +// ZitiQlListener is a complete listener for a parse tree produced by ZitiQlParser. +type ZitiQlListener interface { + antlr.ParseTreeListener + + // EnterString_array is called when entering the string_array production. + EnterString_array(c *String_arrayContext) + + // EnterNumber_array is called when entering the number_array production. + EnterNumber_array(c *Number_arrayContext) + + // EnterDatetime_array is called when entering the datetime_array production. + EnterDatetime_array(c *Datetime_arrayContext) + + // EnterEnd is called when entering the End production. + EnterEnd(c *EndContext) + + // EnterGroup is called when entering the Group production. + EnterGroup(c *GroupContext) + + // EnterOrConjunction is called when entering the OrConjunction production. + EnterOrConjunction(c *OrConjunctionContext) + + // EnterOperationOp is called when entering the OperationOp production. + EnterOperationOp(c *OperationOpContext) + + // EnterAndConjunction is called when entering the AndConjunction production. + EnterAndConjunction(c *AndConjunctionContext) + + // EnterInStringArrayOp is called when entering the InStringArrayOp production. + EnterInStringArrayOp(c *InStringArrayOpContext) + + // EnterInNumberArrayOp is called when entering the InNumberArrayOp production. + EnterInNumberArrayOp(c *InNumberArrayOpContext) + + // EnterInDatetimeArrayOp is called when entering the InDatetimeArrayOp production. + EnterInDatetimeArrayOp(c *InDatetimeArrayOpContext) + + // EnterBetweenNumberOp is called when entering the BetweenNumberOp production. + EnterBetweenNumberOp(c *BetweenNumberOpContext) + + // EnterBetweenDateOp is called when entering the BetweenDateOp production. + EnterBetweenDateOp(c *BetweenDateOpContext) + + // EnterBinaryLessThanNumberOp is called when entering the BinaryLessThanNumberOp production. + EnterBinaryLessThanNumberOp(c *BinaryLessThanNumberOpContext) + + // EnterBinaryLessThanDatetimeOp is called when entering the BinaryLessThanDatetimeOp production. + EnterBinaryLessThanDatetimeOp(c *BinaryLessThanDatetimeOpContext) + + // EnterBinaryGreaterThanNumberOp is called when entering the BinaryGreaterThanNumberOp production. + EnterBinaryGreaterThanNumberOp(c *BinaryGreaterThanNumberOpContext) + + // EnterBinaryGreaterThanDatetimeOp is called when entering the BinaryGreaterThanDatetimeOp production. + EnterBinaryGreaterThanDatetimeOp(c *BinaryGreaterThanDatetimeOpContext) + + // EnterBinaryEqualToStringOp is called when entering the BinaryEqualToStringOp production. + EnterBinaryEqualToStringOp(c *BinaryEqualToStringOpContext) + + // EnterBinaryEqualToNumberOp is called when entering the BinaryEqualToNumberOp production. + EnterBinaryEqualToNumberOp(c *BinaryEqualToNumberOpContext) + + // EnterBinaryEqualToDatetimeOp is called when entering the BinaryEqualToDatetimeOp production. + EnterBinaryEqualToDatetimeOp(c *BinaryEqualToDatetimeOpContext) + + // EnterBinaryEqualToBoolOp is called when entering the BinaryEqualToBoolOp production. + EnterBinaryEqualToBoolOp(c *BinaryEqualToBoolOpContext) + + // EnterBinaryEqualToNullOp is called when entering the BinaryEqualToNullOp production. + EnterBinaryEqualToNullOp(c *BinaryEqualToNullOpContext) + + // EnterBinaryContainsOp is called when entering the BinaryContainsOp production. + EnterBinaryContainsOp(c *BinaryContainsOpContext) + + // ExitString_array is called when exiting the string_array production. + ExitString_array(c *String_arrayContext) + + // ExitNumber_array is called when exiting the number_array production. + ExitNumber_array(c *Number_arrayContext) + + // ExitDatetime_array is called when exiting the datetime_array production. + ExitDatetime_array(c *Datetime_arrayContext) + + // ExitEnd is called when exiting the End production. + ExitEnd(c *EndContext) + + // ExitGroup is called when exiting the Group production. + ExitGroup(c *GroupContext) + + // ExitOrConjunction is called when exiting the OrConjunction production. + ExitOrConjunction(c *OrConjunctionContext) + + // ExitOperationOp is called when exiting the OperationOp production. + ExitOperationOp(c *OperationOpContext) + + // ExitAndConjunction is called when exiting the AndConjunction production. + ExitAndConjunction(c *AndConjunctionContext) + + // ExitInStringArrayOp is called when exiting the InStringArrayOp production. + ExitInStringArrayOp(c *InStringArrayOpContext) + + // ExitInNumberArrayOp is called when exiting the InNumberArrayOp production. + ExitInNumberArrayOp(c *InNumberArrayOpContext) + + // ExitInDatetimeArrayOp is called when exiting the InDatetimeArrayOp production. + ExitInDatetimeArrayOp(c *InDatetimeArrayOpContext) + + // ExitBetweenNumberOp is called when exiting the BetweenNumberOp production. + ExitBetweenNumberOp(c *BetweenNumberOpContext) + + // ExitBetweenDateOp is called when exiting the BetweenDateOp production. + ExitBetweenDateOp(c *BetweenDateOpContext) + + // ExitBinaryLessThanNumberOp is called when exiting the BinaryLessThanNumberOp production. + ExitBinaryLessThanNumberOp(c *BinaryLessThanNumberOpContext) + + // ExitBinaryLessThanDatetimeOp is called when exiting the BinaryLessThanDatetimeOp production. + ExitBinaryLessThanDatetimeOp(c *BinaryLessThanDatetimeOpContext) + + // ExitBinaryGreaterThanNumberOp is called when exiting the BinaryGreaterThanNumberOp production. + ExitBinaryGreaterThanNumberOp(c *BinaryGreaterThanNumberOpContext) + + // ExitBinaryGreaterThanDatetimeOp is called when exiting the BinaryGreaterThanDatetimeOp production. + ExitBinaryGreaterThanDatetimeOp(c *BinaryGreaterThanDatetimeOpContext) + + // ExitBinaryEqualToStringOp is called when exiting the BinaryEqualToStringOp production. + ExitBinaryEqualToStringOp(c *BinaryEqualToStringOpContext) + + // ExitBinaryEqualToNumberOp is called when exiting the BinaryEqualToNumberOp production. + ExitBinaryEqualToNumberOp(c *BinaryEqualToNumberOpContext) + + // ExitBinaryEqualToDatetimeOp is called when exiting the BinaryEqualToDatetimeOp production. + ExitBinaryEqualToDatetimeOp(c *BinaryEqualToDatetimeOpContext) + + // ExitBinaryEqualToBoolOp is called when exiting the BinaryEqualToBoolOp production. + ExitBinaryEqualToBoolOp(c *BinaryEqualToBoolOpContext) + + // ExitBinaryEqualToNullOp is called when exiting the BinaryEqualToNullOp production. + ExitBinaryEqualToNullOp(c *BinaryEqualToNullOpContext) + + // ExitBinaryContainsOp is called when exiting the BinaryContainsOp production. + ExitBinaryContainsOp(c *BinaryContainsOpContext) +} diff --git a/controller/zitiql/zitiql_parser.go b/controller/zitiql/zitiql_parser.go index dd1220822..425313dcd 100644 --- a/controller/zitiql/zitiql_parser.go +++ b/controller/zitiql/zitiql_parser.go @@ -1,3261 +1,3261 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// Code generated from ZitiQl.g4 by ANTLR 4.7.1. DO NOT EDIT. - -package zitiql // ZitiQl -import ( - "fmt" - "reflect" - "strconv" - - "github.com/antlr/antlr4/runtime/Go/antlr" -) - -// Suppress unused import errors -var _ = fmt.Printf -var _ = reflect.Copy -var _ = strconv.Itoa - -var parserATN = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 23, 439, - 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, - 3, 2, 3, 2, 7, 2, 17, 10, 2, 12, 2, 14, 2, 20, 11, 2, 3, 2, 3, 2, 7, 2, - 24, 10, 2, 12, 2, 14, 2, 27, 11, 2, 3, 2, 3, 2, 7, 2, 31, 10, 2, 12, 2, - 14, 2, 34, 11, 2, 3, 2, 7, 2, 37, 10, 2, 12, 2, 14, 2, 40, 11, 2, 3, 2, - 7, 2, 43, 10, 2, 12, 2, 14, 2, 46, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 7, 3, - 52, 10, 3, 12, 3, 14, 3, 55, 11, 3, 3, 3, 3, 3, 7, 3, 59, 10, 3, 12, 3, - 14, 3, 62, 11, 3, 3, 3, 3, 3, 7, 3, 66, 10, 3, 12, 3, 14, 3, 69, 11, 3, - 3, 3, 7, 3, 72, 10, 3, 12, 3, 14, 3, 75, 11, 3, 3, 3, 7, 3, 78, 10, 3, - 12, 3, 14, 3, 81, 11, 3, 3, 3, 3, 3, 3, 4, 3, 4, 7, 4, 87, 10, 4, 12, 4, - 14, 4, 90, 11, 4, 3, 4, 3, 4, 7, 4, 94, 10, 4, 12, 4, 14, 4, 97, 11, 4, - 3, 4, 3, 4, 7, 4, 101, 10, 4, 12, 4, 14, 4, 104, 11, 4, 3, 4, 7, 4, 107, - 10, 4, 12, 4, 14, 4, 110, 11, 4, 3, 4, 7, 4, 113, 10, 4, 12, 4, 14, 4, - 116, 11, 4, 3, 4, 3, 4, 3, 5, 7, 5, 121, 10, 5, 12, 5, 14, 5, 124, 11, - 5, 3, 5, 7, 5, 127, 10, 5, 12, 5, 14, 5, 130, 11, 5, 3, 5, 7, 5, 133, 10, - 5, 12, 5, 14, 5, 136, 11, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 7, 6, - 144, 10, 6, 12, 6, 14, 6, 147, 11, 6, 3, 6, 3, 6, 7, 6, 151, 10, 6, 12, - 6, 14, 6, 154, 11, 6, 3, 6, 3, 6, 5, 6, 158, 10, 6, 3, 6, 3, 6, 6, 6, 162, - 10, 6, 13, 6, 14, 6, 163, 3, 6, 3, 6, 6, 6, 168, 10, 6, 13, 6, 14, 6, 169, - 3, 6, 6, 6, 173, 10, 6, 13, 6, 14, 6, 174, 3, 6, 3, 6, 6, 6, 179, 10, 6, - 13, 6, 14, 6, 180, 3, 6, 3, 6, 6, 6, 185, 10, 6, 13, 6, 14, 6, 186, 3, - 6, 6, 6, 190, 10, 6, 13, 6, 14, 6, 191, 7, 6, 194, 10, 6, 12, 6, 14, 6, - 197, 11, 6, 3, 7, 3, 7, 6, 7, 201, 10, 7, 13, 7, 14, 7, 202, 3, 7, 3, 7, - 6, 7, 207, 10, 7, 13, 7, 14, 7, 208, 3, 7, 3, 7, 3, 7, 6, 7, 214, 10, 7, - 13, 7, 14, 7, 215, 3, 7, 3, 7, 6, 7, 220, 10, 7, 13, 7, 14, 7, 221, 3, - 7, 3, 7, 3, 7, 6, 7, 227, 10, 7, 13, 7, 14, 7, 228, 3, 7, 3, 7, 6, 7, 233, - 10, 7, 13, 7, 14, 7, 234, 3, 7, 3, 7, 3, 7, 6, 7, 240, 10, 7, 13, 7, 14, - 7, 241, 3, 7, 3, 7, 6, 7, 246, 10, 7, 13, 7, 14, 7, 247, 3, 7, 3, 7, 6, - 7, 252, 10, 7, 13, 7, 14, 7, 253, 3, 7, 3, 7, 6, 7, 258, 10, 7, 13, 7, - 14, 7, 259, 3, 7, 3, 7, 3, 7, 6, 7, 265, 10, 7, 13, 7, 14, 7, 266, 3, 7, - 3, 7, 6, 7, 271, 10, 7, 13, 7, 14, 7, 272, 3, 7, 3, 7, 6, 7, 277, 10, 7, - 13, 7, 14, 7, 278, 3, 7, 3, 7, 6, 7, 283, 10, 7, 13, 7, 14, 7, 284, 3, - 7, 3, 7, 3, 7, 7, 7, 290, 10, 7, 12, 7, 14, 7, 293, 11, 7, 3, 7, 3, 7, - 7, 7, 297, 10, 7, 12, 7, 14, 7, 300, 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 305, - 10, 7, 12, 7, 14, 7, 308, 11, 7, 3, 7, 3, 7, 7, 7, 312, 10, 7, 12, 7, 14, - 7, 315, 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 320, 10, 7, 12, 7, 14, 7, 323, 11, - 7, 3, 7, 3, 7, 7, 7, 327, 10, 7, 12, 7, 14, 7, 330, 11, 7, 3, 7, 3, 7, - 3, 7, 7, 7, 335, 10, 7, 12, 7, 14, 7, 338, 11, 7, 3, 7, 3, 7, 7, 7, 342, - 10, 7, 12, 7, 14, 7, 345, 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 350, 10, 7, 12, - 7, 14, 7, 353, 11, 7, 3, 7, 3, 7, 7, 7, 357, 10, 7, 12, 7, 14, 7, 360, - 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 365, 10, 7, 12, 7, 14, 7, 368, 11, 7, 3, - 7, 3, 7, 7, 7, 372, 10, 7, 12, 7, 14, 7, 375, 11, 7, 3, 7, 3, 7, 3, 7, - 7, 7, 380, 10, 7, 12, 7, 14, 7, 383, 11, 7, 3, 7, 3, 7, 7, 7, 387, 10, - 7, 12, 7, 14, 7, 390, 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 395, 10, 7, 12, 7, - 14, 7, 398, 11, 7, 3, 7, 3, 7, 7, 7, 402, 10, 7, 12, 7, 14, 7, 405, 11, - 7, 3, 7, 3, 7, 3, 7, 7, 7, 410, 10, 7, 12, 7, 14, 7, 413, 11, 7, 3, 7, - 3, 7, 7, 7, 417, 10, 7, 12, 7, 14, 7, 420, 11, 7, 3, 7, 3, 7, 3, 7, 7, - 7, 425, 10, 7, 12, 7, 14, 7, 428, 11, 7, 3, 7, 3, 7, 6, 7, 432, 10, 7, - 13, 7, 14, 7, 433, 3, 7, 5, 7, 437, 10, 7, 3, 7, 2, 3, 10, 8, 2, 4, 6, - 8, 10, 12, 2, 3, 3, 2, 19, 20, 2, 509, 2, 14, 3, 2, 2, 2, 4, 49, 3, 2, - 2, 2, 6, 84, 3, 2, 2, 2, 8, 122, 3, 2, 2, 2, 10, 157, 3, 2, 2, 2, 12, 436, - 3, 2, 2, 2, 14, 18, 7, 7, 2, 2, 15, 17, 7, 4, 2, 2, 16, 15, 3, 2, 2, 2, - 17, 20, 3, 2, 2, 2, 18, 16, 3, 2, 2, 2, 18, 19, 3, 2, 2, 2, 19, 21, 3, - 2, 2, 2, 20, 18, 3, 2, 2, 2, 21, 38, 7, 19, 2, 2, 22, 24, 7, 4, 2, 2, 23, - 22, 3, 2, 2, 2, 24, 27, 3, 2, 2, 2, 25, 23, 3, 2, 2, 2, 25, 26, 3, 2, 2, - 2, 26, 28, 3, 2, 2, 2, 27, 25, 3, 2, 2, 2, 28, 32, 7, 3, 2, 2, 29, 31, - 7, 4, 2, 2, 30, 29, 3, 2, 2, 2, 31, 34, 3, 2, 2, 2, 32, 30, 3, 2, 2, 2, - 32, 33, 3, 2, 2, 2, 33, 35, 3, 2, 2, 2, 34, 32, 3, 2, 2, 2, 35, 37, 7, - 19, 2, 2, 36, 25, 3, 2, 2, 2, 37, 40, 3, 2, 2, 2, 38, 36, 3, 2, 2, 2, 38, - 39, 3, 2, 2, 2, 39, 44, 3, 2, 2, 2, 40, 38, 3, 2, 2, 2, 41, 43, 7, 4, 2, - 2, 42, 41, 3, 2, 2, 2, 43, 46, 3, 2, 2, 2, 44, 42, 3, 2, 2, 2, 44, 45, - 3, 2, 2, 2, 45, 47, 3, 2, 2, 2, 46, 44, 3, 2, 2, 2, 47, 48, 7, 8, 2, 2, - 48, 3, 3, 2, 2, 2, 49, 53, 7, 7, 2, 2, 50, 52, 7, 4, 2, 2, 51, 50, 3, 2, - 2, 2, 52, 55, 3, 2, 2, 2, 53, 51, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 56, - 3, 2, 2, 2, 55, 53, 3, 2, 2, 2, 56, 73, 7, 20, 2, 2, 57, 59, 7, 4, 2, 2, - 58, 57, 3, 2, 2, 2, 59, 62, 3, 2, 2, 2, 60, 58, 3, 2, 2, 2, 60, 61, 3, - 2, 2, 2, 61, 63, 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 63, 67, 7, 3, 2, 2, 64, - 66, 7, 4, 2, 2, 65, 64, 3, 2, 2, 2, 66, 69, 3, 2, 2, 2, 67, 65, 3, 2, 2, - 2, 67, 68, 3, 2, 2, 2, 68, 70, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 70, 72, - 7, 20, 2, 2, 71, 60, 3, 2, 2, 2, 72, 75, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, - 73, 74, 3, 2, 2, 2, 74, 79, 3, 2, 2, 2, 75, 73, 3, 2, 2, 2, 76, 78, 7, - 4, 2, 2, 77, 76, 3, 2, 2, 2, 78, 81, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 79, - 80, 3, 2, 2, 2, 80, 82, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 82, 83, 7, 8, 2, - 2, 83, 5, 3, 2, 2, 2, 84, 88, 7, 7, 2, 2, 85, 87, 7, 4, 2, 2, 86, 85, 3, - 2, 2, 2, 87, 90, 3, 2, 2, 2, 88, 86, 3, 2, 2, 2, 88, 89, 3, 2, 2, 2, 89, - 91, 3, 2, 2, 2, 90, 88, 3, 2, 2, 2, 91, 108, 7, 18, 2, 2, 92, 94, 7, 4, - 2, 2, 93, 92, 3, 2, 2, 2, 94, 97, 3, 2, 2, 2, 95, 93, 3, 2, 2, 2, 95, 96, - 3, 2, 2, 2, 96, 98, 3, 2, 2, 2, 97, 95, 3, 2, 2, 2, 98, 102, 7, 3, 2, 2, - 99, 101, 7, 4, 2, 2, 100, 99, 3, 2, 2, 2, 101, 104, 3, 2, 2, 2, 102, 100, - 3, 2, 2, 2, 102, 103, 3, 2, 2, 2, 103, 105, 3, 2, 2, 2, 104, 102, 3, 2, - 2, 2, 105, 107, 7, 18, 2, 2, 106, 95, 3, 2, 2, 2, 107, 110, 3, 2, 2, 2, - 108, 106, 3, 2, 2, 2, 108, 109, 3, 2, 2, 2, 109, 114, 3, 2, 2, 2, 110, - 108, 3, 2, 2, 2, 111, 113, 7, 4, 2, 2, 112, 111, 3, 2, 2, 2, 113, 116, - 3, 2, 2, 2, 114, 112, 3, 2, 2, 2, 114, 115, 3, 2, 2, 2, 115, 117, 3, 2, - 2, 2, 116, 114, 3, 2, 2, 2, 117, 118, 7, 8, 2, 2, 118, 7, 3, 2, 2, 2, 119, - 121, 7, 4, 2, 2, 120, 119, 3, 2, 2, 2, 121, 124, 3, 2, 2, 2, 122, 120, - 3, 2, 2, 2, 122, 123, 3, 2, 2, 2, 123, 128, 3, 2, 2, 2, 124, 122, 3, 2, - 2, 2, 125, 127, 5, 10, 6, 2, 126, 125, 3, 2, 2, 2, 127, 130, 3, 2, 2, 2, - 128, 126, 3, 2, 2, 2, 128, 129, 3, 2, 2, 2, 129, 134, 3, 2, 2, 2, 130, - 128, 3, 2, 2, 2, 131, 133, 7, 4, 2, 2, 132, 131, 3, 2, 2, 2, 133, 136, - 3, 2, 2, 2, 134, 132, 3, 2, 2, 2, 134, 135, 3, 2, 2, 2, 135, 137, 3, 2, - 2, 2, 136, 134, 3, 2, 2, 2, 137, 138, 7, 2, 2, 3, 138, 9, 3, 2, 2, 2, 139, - 140, 8, 6, 1, 2, 140, 158, 5, 12, 7, 2, 141, 145, 7, 5, 2, 2, 142, 144, - 7, 4, 2, 2, 143, 142, 3, 2, 2, 2, 144, 147, 3, 2, 2, 2, 145, 143, 3, 2, - 2, 2, 145, 146, 3, 2, 2, 2, 146, 148, 3, 2, 2, 2, 147, 145, 3, 2, 2, 2, - 148, 152, 5, 10, 6, 2, 149, 151, 7, 4, 2, 2, 150, 149, 3, 2, 2, 2, 151, - 154, 3, 2, 2, 2, 152, 150, 3, 2, 2, 2, 152, 153, 3, 2, 2, 2, 153, 155, - 3, 2, 2, 2, 154, 152, 3, 2, 2, 2, 155, 156, 7, 6, 2, 2, 156, 158, 3, 2, - 2, 2, 157, 139, 3, 2, 2, 2, 157, 141, 3, 2, 2, 2, 158, 195, 3, 2, 2, 2, - 159, 172, 12, 4, 2, 2, 160, 162, 7, 4, 2, 2, 161, 160, 3, 2, 2, 2, 162, - 163, 3, 2, 2, 2, 163, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 165, - 3, 2, 2, 2, 165, 167, 7, 9, 2, 2, 166, 168, 7, 4, 2, 2, 167, 166, 3, 2, - 2, 2, 168, 169, 3, 2, 2, 2, 169, 167, 3, 2, 2, 2, 169, 170, 3, 2, 2, 2, - 170, 171, 3, 2, 2, 2, 171, 173, 5, 10, 6, 2, 172, 161, 3, 2, 2, 2, 173, - 174, 3, 2, 2, 2, 174, 172, 3, 2, 2, 2, 174, 175, 3, 2, 2, 2, 175, 194, - 3, 2, 2, 2, 176, 189, 12, 3, 2, 2, 177, 179, 7, 4, 2, 2, 178, 177, 3, 2, - 2, 2, 179, 180, 3, 2, 2, 2, 180, 178, 3, 2, 2, 2, 180, 181, 3, 2, 2, 2, - 181, 182, 3, 2, 2, 2, 182, 184, 7, 10, 2, 2, 183, 185, 7, 4, 2, 2, 184, - 183, 3, 2, 2, 2, 185, 186, 3, 2, 2, 2, 186, 184, 3, 2, 2, 2, 186, 187, - 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 190, 5, 10, 6, 2, 189, 178, 3, 2, - 2, 2, 190, 191, 3, 2, 2, 2, 191, 189, 3, 2, 2, 2, 191, 192, 3, 2, 2, 2, - 192, 194, 3, 2, 2, 2, 193, 159, 3, 2, 2, 2, 193, 176, 3, 2, 2, 2, 194, - 197, 3, 2, 2, 2, 195, 193, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 11, 3, - 2, 2, 2, 197, 195, 3, 2, 2, 2, 198, 200, 7, 22, 2, 2, 199, 201, 7, 4, 2, - 2, 200, 199, 3, 2, 2, 2, 201, 202, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 202, - 203, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 206, 7, 15, 2, 2, 205, 207, - 7, 4, 2, 2, 206, 205, 3, 2, 2, 2, 207, 208, 3, 2, 2, 2, 208, 206, 3, 2, - 2, 2, 208, 209, 3, 2, 2, 2, 209, 210, 3, 2, 2, 2, 210, 437, 5, 2, 2, 2, - 211, 213, 7, 22, 2, 2, 212, 214, 7, 4, 2, 2, 213, 212, 3, 2, 2, 2, 214, - 215, 3, 2, 2, 2, 215, 213, 3, 2, 2, 2, 215, 216, 3, 2, 2, 2, 216, 217, - 3, 2, 2, 2, 217, 219, 7, 15, 2, 2, 218, 220, 7, 4, 2, 2, 219, 218, 3, 2, - 2, 2, 220, 221, 3, 2, 2, 2, 221, 219, 3, 2, 2, 2, 221, 222, 3, 2, 2, 2, - 222, 223, 3, 2, 2, 2, 223, 437, 5, 4, 3, 2, 224, 226, 7, 22, 2, 2, 225, - 227, 7, 4, 2, 2, 226, 225, 3, 2, 2, 2, 227, 228, 3, 2, 2, 2, 228, 226, - 3, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229, 230, 3, 2, 2, 2, 230, 232, 7, 15, - 2, 2, 231, 233, 7, 4, 2, 2, 232, 231, 3, 2, 2, 2, 233, 234, 3, 2, 2, 2, - 234, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 2, 235, 236, 3, 2, 2, 2, 236, - 437, 5, 6, 4, 2, 237, 239, 7, 22, 2, 2, 238, 240, 7, 4, 2, 2, 239, 238, - 3, 2, 2, 2, 240, 241, 3, 2, 2, 2, 241, 239, 3, 2, 2, 2, 241, 242, 3, 2, - 2, 2, 242, 243, 3, 2, 2, 2, 243, 245, 7, 16, 2, 2, 244, 246, 7, 4, 2, 2, - 245, 244, 3, 2, 2, 2, 246, 247, 3, 2, 2, 2, 247, 245, 3, 2, 2, 2, 247, - 248, 3, 2, 2, 2, 248, 249, 3, 2, 2, 2, 249, 251, 7, 20, 2, 2, 250, 252, - 7, 4, 2, 2, 251, 250, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 251, 3, 2, - 2, 2, 253, 254, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 257, 7, 9, 2, 2, - 256, 258, 7, 4, 2, 2, 257, 256, 3, 2, 2, 2, 258, 259, 3, 2, 2, 2, 259, - 257, 3, 2, 2, 2, 259, 260, 3, 2, 2, 2, 260, 261, 3, 2, 2, 2, 261, 437, - 7, 20, 2, 2, 262, 264, 7, 22, 2, 2, 263, 265, 7, 4, 2, 2, 264, 263, 3, - 2, 2, 2, 265, 266, 3, 2, 2, 2, 266, 264, 3, 2, 2, 2, 266, 267, 3, 2, 2, - 2, 267, 268, 3, 2, 2, 2, 268, 270, 7, 16, 2, 2, 269, 271, 7, 4, 2, 2, 270, - 269, 3, 2, 2, 2, 271, 272, 3, 2, 2, 2, 272, 270, 3, 2, 2, 2, 272, 273, - 3, 2, 2, 2, 273, 274, 3, 2, 2, 2, 274, 276, 7, 18, 2, 2, 275, 277, 7, 4, - 2, 2, 276, 275, 3, 2, 2, 2, 277, 278, 3, 2, 2, 2, 278, 276, 3, 2, 2, 2, - 278, 279, 3, 2, 2, 2, 279, 280, 3, 2, 2, 2, 280, 282, 7, 9, 2, 2, 281, - 283, 7, 4, 2, 2, 282, 281, 3, 2, 2, 2, 283, 284, 3, 2, 2, 2, 284, 282, - 3, 2, 2, 2, 284, 285, 3, 2, 2, 2, 285, 286, 3, 2, 2, 2, 286, 437, 7, 18, - 2, 2, 287, 291, 7, 22, 2, 2, 288, 290, 7, 4, 2, 2, 289, 288, 3, 2, 2, 2, - 290, 293, 3, 2, 2, 2, 291, 289, 3, 2, 2, 2, 291, 292, 3, 2, 2, 2, 292, - 294, 3, 2, 2, 2, 293, 291, 3, 2, 2, 2, 294, 298, 7, 11, 2, 2, 295, 297, - 7, 4, 2, 2, 296, 295, 3, 2, 2, 2, 297, 300, 3, 2, 2, 2, 298, 296, 3, 2, - 2, 2, 298, 299, 3, 2, 2, 2, 299, 301, 3, 2, 2, 2, 300, 298, 3, 2, 2, 2, - 301, 437, 7, 20, 2, 2, 302, 306, 7, 22, 2, 2, 303, 305, 7, 4, 2, 2, 304, - 303, 3, 2, 2, 2, 305, 308, 3, 2, 2, 2, 306, 304, 3, 2, 2, 2, 306, 307, - 3, 2, 2, 2, 307, 309, 3, 2, 2, 2, 308, 306, 3, 2, 2, 2, 309, 313, 7, 11, - 2, 2, 310, 312, 7, 4, 2, 2, 311, 310, 3, 2, 2, 2, 312, 315, 3, 2, 2, 2, - 313, 311, 3, 2, 2, 2, 313, 314, 3, 2, 2, 2, 314, 316, 3, 2, 2, 2, 315, - 313, 3, 2, 2, 2, 316, 437, 7, 18, 2, 2, 317, 321, 7, 22, 2, 2, 318, 320, - 7, 4, 2, 2, 319, 318, 3, 2, 2, 2, 320, 323, 3, 2, 2, 2, 321, 319, 3, 2, - 2, 2, 321, 322, 3, 2, 2, 2, 322, 324, 3, 2, 2, 2, 323, 321, 3, 2, 2, 2, - 324, 328, 7, 12, 2, 2, 325, 327, 7, 4, 2, 2, 326, 325, 3, 2, 2, 2, 327, - 330, 3, 2, 2, 2, 328, 326, 3, 2, 2, 2, 328, 329, 3, 2, 2, 2, 329, 331, - 3, 2, 2, 2, 330, 328, 3, 2, 2, 2, 331, 437, 7, 20, 2, 2, 332, 336, 7, 22, - 2, 2, 333, 335, 7, 4, 2, 2, 334, 333, 3, 2, 2, 2, 335, 338, 3, 2, 2, 2, - 336, 334, 3, 2, 2, 2, 336, 337, 3, 2, 2, 2, 337, 339, 3, 2, 2, 2, 338, - 336, 3, 2, 2, 2, 339, 343, 7, 12, 2, 2, 340, 342, 7, 4, 2, 2, 341, 340, - 3, 2, 2, 2, 342, 345, 3, 2, 2, 2, 343, 341, 3, 2, 2, 2, 343, 344, 3, 2, - 2, 2, 344, 346, 3, 2, 2, 2, 345, 343, 3, 2, 2, 2, 346, 437, 7, 18, 2, 2, - 347, 351, 7, 22, 2, 2, 348, 350, 7, 4, 2, 2, 349, 348, 3, 2, 2, 2, 350, - 353, 3, 2, 2, 2, 351, 349, 3, 2, 2, 2, 351, 352, 3, 2, 2, 2, 352, 354, - 3, 2, 2, 2, 353, 351, 3, 2, 2, 2, 354, 358, 7, 13, 2, 2, 355, 357, 7, 4, - 2, 2, 356, 355, 3, 2, 2, 2, 357, 360, 3, 2, 2, 2, 358, 356, 3, 2, 2, 2, - 358, 359, 3, 2, 2, 2, 359, 361, 3, 2, 2, 2, 360, 358, 3, 2, 2, 2, 361, - 437, 7, 19, 2, 2, 362, 366, 7, 22, 2, 2, 363, 365, 7, 4, 2, 2, 364, 363, - 3, 2, 2, 2, 365, 368, 3, 2, 2, 2, 366, 364, 3, 2, 2, 2, 366, 367, 3, 2, - 2, 2, 367, 369, 3, 2, 2, 2, 368, 366, 3, 2, 2, 2, 369, 373, 7, 13, 2, 2, - 370, 372, 7, 4, 2, 2, 371, 370, 3, 2, 2, 2, 372, 375, 3, 2, 2, 2, 373, - 371, 3, 2, 2, 2, 373, 374, 3, 2, 2, 2, 374, 376, 3, 2, 2, 2, 375, 373, - 3, 2, 2, 2, 376, 437, 7, 20, 2, 2, 377, 381, 7, 22, 2, 2, 378, 380, 7, - 4, 2, 2, 379, 378, 3, 2, 2, 2, 380, 383, 3, 2, 2, 2, 381, 379, 3, 2, 2, - 2, 381, 382, 3, 2, 2, 2, 382, 384, 3, 2, 2, 2, 383, 381, 3, 2, 2, 2, 384, - 388, 7, 13, 2, 2, 385, 387, 7, 4, 2, 2, 386, 385, 3, 2, 2, 2, 387, 390, - 3, 2, 2, 2, 388, 386, 3, 2, 2, 2, 388, 389, 3, 2, 2, 2, 389, 391, 3, 2, - 2, 2, 390, 388, 3, 2, 2, 2, 391, 437, 7, 18, 2, 2, 392, 396, 7, 22, 2, - 2, 393, 395, 7, 4, 2, 2, 394, 393, 3, 2, 2, 2, 395, 398, 3, 2, 2, 2, 396, - 394, 3, 2, 2, 2, 396, 397, 3, 2, 2, 2, 397, 399, 3, 2, 2, 2, 398, 396, - 3, 2, 2, 2, 399, 403, 7, 13, 2, 2, 400, 402, 7, 4, 2, 2, 401, 400, 3, 2, - 2, 2, 402, 405, 3, 2, 2, 2, 403, 401, 3, 2, 2, 2, 403, 404, 3, 2, 2, 2, - 404, 406, 3, 2, 2, 2, 405, 403, 3, 2, 2, 2, 406, 437, 7, 17, 2, 2, 407, - 411, 7, 22, 2, 2, 408, 410, 7, 4, 2, 2, 409, 408, 3, 2, 2, 2, 410, 413, - 3, 2, 2, 2, 411, 409, 3, 2, 2, 2, 411, 412, 3, 2, 2, 2, 412, 414, 3, 2, - 2, 2, 413, 411, 3, 2, 2, 2, 414, 418, 7, 13, 2, 2, 415, 417, 7, 4, 2, 2, - 416, 415, 3, 2, 2, 2, 417, 420, 3, 2, 2, 2, 418, 416, 3, 2, 2, 2, 418, - 419, 3, 2, 2, 2, 419, 421, 3, 2, 2, 2, 420, 418, 3, 2, 2, 2, 421, 437, - 7, 21, 2, 2, 422, 426, 7, 22, 2, 2, 423, 425, 7, 4, 2, 2, 424, 423, 3, - 2, 2, 2, 425, 428, 3, 2, 2, 2, 426, 424, 3, 2, 2, 2, 426, 427, 3, 2, 2, - 2, 427, 429, 3, 2, 2, 2, 428, 426, 3, 2, 2, 2, 429, 431, 7, 14, 2, 2, 430, - 432, 7, 4, 2, 2, 431, 430, 3, 2, 2, 2, 432, 433, 3, 2, 2, 2, 433, 431, - 3, 2, 2, 2, 433, 434, 3, 2, 2, 2, 434, 435, 3, 2, 2, 2, 435, 437, 9, 2, - 2, 2, 436, 198, 3, 2, 2, 2, 436, 211, 3, 2, 2, 2, 436, 224, 3, 2, 2, 2, - 436, 237, 3, 2, 2, 2, 436, 262, 3, 2, 2, 2, 436, 287, 3, 2, 2, 2, 436, - 302, 3, 2, 2, 2, 436, 317, 3, 2, 2, 2, 436, 332, 3, 2, 2, 2, 436, 347, - 3, 2, 2, 2, 436, 362, 3, 2, 2, 2, 436, 377, 3, 2, 2, 2, 436, 392, 3, 2, - 2, 2, 436, 407, 3, 2, 2, 2, 436, 422, 3, 2, 2, 2, 437, 13, 3, 2, 2, 2, - 66, 18, 25, 32, 38, 44, 53, 60, 67, 73, 79, 88, 95, 102, 108, 114, 122, - 128, 134, 145, 152, 157, 163, 169, 174, 180, 186, 191, 193, 195, 202, 208, - 215, 221, 228, 234, 241, 247, 253, 259, 266, 272, 278, 284, 291, 298, 306, - 313, 321, 328, 336, 343, 351, 358, 366, 373, 381, 388, 396, 403, 411, 418, - 426, 433, 436, -} -var deserializer = antlr.NewATNDeserializer(nil) -var deserializedATN = deserializer.DeserializeFromUInt16(parserATN) - -var literalNames = []string{ - "", "','", "", "'('", "')'", "'['", "']'", -} -var symbolicNames = []string{ - "", "", "WS", "LPAREN", "RPAREN", "LBRACKET", "RBRACKET", "AND", "OR", - "LT", "GT", "EQ", "CONTAINS", "IN", "BETWEEN", "BOOL", "DATETIME", "STRING", - "NUMBER", "NULL", "IDENTIFIER", "RFC3339_DATE_TIME", -} - -var ruleNames = []string{ - "string_array", "number_array", "datetime_array", "start", "expression", - "operation", -} -var decisionToDFA = make([]*antlr.DFA, len(deserializedATN.DecisionToState)) - -func init() { - for index, ds := range deserializedATN.DecisionToState { - decisionToDFA[index] = antlr.NewDFA(ds, index) - } -} - -type ZitiQlParser struct { - *antlr.BaseParser -} - -func NewZitiQlParser(input antlr.TokenStream) *ZitiQlParser { - this := new(ZitiQlParser) - - this.BaseParser = antlr.NewBaseParser(input) - - this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, antlr.NewPredictionContextCache()) - this.RuleNames = ruleNames - this.LiteralNames = literalNames - this.SymbolicNames = symbolicNames - this.GrammarFileName = "ZitiQl.g4" - - return this -} - -// ZitiQlParser tokens. -const ( - ZitiQlParserEOF = antlr.TokenEOF - ZitiQlParserT__0 = 1 - ZitiQlParserWS = 2 - ZitiQlParserLPAREN = 3 - ZitiQlParserRPAREN = 4 - ZitiQlParserLBRACKET = 5 - ZitiQlParserRBRACKET = 6 - ZitiQlParserAND = 7 - ZitiQlParserOR = 8 - ZitiQlParserLT = 9 - ZitiQlParserGT = 10 - ZitiQlParserEQ = 11 - ZitiQlParserCONTAINS = 12 - ZitiQlParserIN = 13 - ZitiQlParserBETWEEN = 14 - ZitiQlParserBOOL = 15 - ZitiQlParserDATETIME = 16 - ZitiQlParserSTRING = 17 - ZitiQlParserNUMBER = 18 - ZitiQlParserNULL = 19 - ZitiQlParserIDENTIFIER = 20 - ZitiQlParserRFC3339_DATE_TIME = 21 -) - -// ZitiQlParser rules. -const ( - ZitiQlParserRULE_string_array = 0 - ZitiQlParserRULE_number_array = 1 - ZitiQlParserRULE_datetime_array = 2 - ZitiQlParserRULE_start = 3 - ZitiQlParserRULE_expression = 4 - ZitiQlParserRULE_operation = 5 -) - -// IString_arrayContext is an interface to support dynamic dispatch. -type IString_arrayContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // IsString_arrayContext differentiates from other interfaces. - IsString_arrayContext() -} - -type String_arrayContext struct { - *antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyString_arrayContext() *String_arrayContext { - var p = new(String_arrayContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) - p.RuleIndex = ZitiQlParserRULE_string_array - return p -} - -func (*String_arrayContext) IsString_arrayContext() {} - -func NewString_arrayContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *String_arrayContext { - var p = new(String_arrayContext) - - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) - - p.parser = parser - p.RuleIndex = ZitiQlParserRULE_string_array - - return p -} - -func (s *String_arrayContext) GetParser() antlr.Parser { return s.parser } - -func (s *String_arrayContext) LBRACKET() antlr.TerminalNode { - return s.GetToken(ZitiQlParserLBRACKET, 0) -} - -func (s *String_arrayContext) AllSTRING() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserSTRING) -} - -func (s *String_arrayContext) STRING(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserSTRING, i) -} - -func (s *String_arrayContext) RBRACKET() antlr.TerminalNode { - return s.GetToken(ZitiQlParserRBRACKET, 0) -} - -func (s *String_arrayContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *String_arrayContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *String_arrayContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *String_arrayContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *String_arrayContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterString_array(s) - } -} - -func (s *String_arrayContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitString_array(s) - } -} - -func (p *ZitiQlParser) String_array() (localctx IString_arrayContext) { - localctx = NewString_arrayContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 0, ZitiQlParserRULE_string_array) - var _la int - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - - var _alt int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(12) - p.Match(ZitiQlParserLBRACKET) - } - p.SetState(16) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(13) - p.Match(ZitiQlParserWS) - } - - p.SetState(18) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(19) - p.Match(ZitiQlParserSTRING) - } - p.SetState(36) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 3, p.GetParserRuleContext()) - - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - p.SetState(23) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(20) - p.Match(ZitiQlParserWS) - } - - p.SetState(25) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(26) - p.Match(ZitiQlParserT__0) - } - p.SetState(30) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(27) - p.Match(ZitiQlParserWS) - } - - p.SetState(32) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(33) - p.Match(ZitiQlParserSTRING) - } - - } - p.SetState(38) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 3, p.GetParserRuleContext()) - } - p.SetState(42) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(39) - p.Match(ZitiQlParserWS) - } - - p.SetState(44) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(45) - p.Match(ZitiQlParserRBRACKET) - } - - return localctx -} - -// INumber_arrayContext is an interface to support dynamic dispatch. -type INumber_arrayContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // IsNumber_arrayContext differentiates from other interfaces. - IsNumber_arrayContext() -} - -type Number_arrayContext struct { - *antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyNumber_arrayContext() *Number_arrayContext { - var p = new(Number_arrayContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) - p.RuleIndex = ZitiQlParserRULE_number_array - return p -} - -func (*Number_arrayContext) IsNumber_arrayContext() {} - -func NewNumber_arrayContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Number_arrayContext { - var p = new(Number_arrayContext) - - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) - - p.parser = parser - p.RuleIndex = ZitiQlParserRULE_number_array - - return p -} - -func (s *Number_arrayContext) GetParser() antlr.Parser { return s.parser } - -func (s *Number_arrayContext) LBRACKET() antlr.TerminalNode { - return s.GetToken(ZitiQlParserLBRACKET, 0) -} - -func (s *Number_arrayContext) AllNUMBER() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserNUMBER) -} - -func (s *Number_arrayContext) NUMBER(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserNUMBER, i) -} - -func (s *Number_arrayContext) RBRACKET() antlr.TerminalNode { - return s.GetToken(ZitiQlParserRBRACKET, 0) -} - -func (s *Number_arrayContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *Number_arrayContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *Number_arrayContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *Number_arrayContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *Number_arrayContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterNumber_array(s) - } -} - -func (s *Number_arrayContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitNumber_array(s) - } -} - -func (p *ZitiQlParser) Number_array() (localctx INumber_arrayContext) { - localctx = NewNumber_arrayContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 2, ZitiQlParserRULE_number_array) - var _la int - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - - var _alt int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(47) - p.Match(ZitiQlParserLBRACKET) - } - p.SetState(51) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(48) - p.Match(ZitiQlParserWS) - } - - p.SetState(53) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(54) - p.Match(ZitiQlParserNUMBER) - } - p.SetState(71) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) - - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - p.SetState(58) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(55) - p.Match(ZitiQlParserWS) - } - - p.SetState(60) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(61) - p.Match(ZitiQlParserT__0) - } - p.SetState(65) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(62) - p.Match(ZitiQlParserWS) - } - - p.SetState(67) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(68) - p.Match(ZitiQlParserNUMBER) - } - - } - p.SetState(73) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) - } - p.SetState(77) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(74) - p.Match(ZitiQlParserWS) - } - - p.SetState(79) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(80) - p.Match(ZitiQlParserRBRACKET) - } - - return localctx -} - -// IDatetime_arrayContext is an interface to support dynamic dispatch. -type IDatetime_arrayContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // IsDatetime_arrayContext differentiates from other interfaces. - IsDatetime_arrayContext() -} - -type Datetime_arrayContext struct { - *antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyDatetime_arrayContext() *Datetime_arrayContext { - var p = new(Datetime_arrayContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) - p.RuleIndex = ZitiQlParserRULE_datetime_array - return p -} - -func (*Datetime_arrayContext) IsDatetime_arrayContext() {} - -func NewDatetime_arrayContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Datetime_arrayContext { - var p = new(Datetime_arrayContext) - - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) - - p.parser = parser - p.RuleIndex = ZitiQlParserRULE_datetime_array - - return p -} - -func (s *Datetime_arrayContext) GetParser() antlr.Parser { return s.parser } - -func (s *Datetime_arrayContext) LBRACKET() antlr.TerminalNode { - return s.GetToken(ZitiQlParserLBRACKET, 0) -} - -func (s *Datetime_arrayContext) AllDATETIME() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserDATETIME) -} - -func (s *Datetime_arrayContext) DATETIME(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserDATETIME, i) -} - -func (s *Datetime_arrayContext) RBRACKET() antlr.TerminalNode { - return s.GetToken(ZitiQlParserRBRACKET, 0) -} - -func (s *Datetime_arrayContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *Datetime_arrayContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *Datetime_arrayContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *Datetime_arrayContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *Datetime_arrayContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterDatetime_array(s) - } -} - -func (s *Datetime_arrayContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitDatetime_array(s) - } -} - -func (p *ZitiQlParser) Datetime_array() (localctx IDatetime_arrayContext) { - localctx = NewDatetime_arrayContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 4, ZitiQlParserRULE_datetime_array) - var _la int - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - - var _alt int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(82) - p.Match(ZitiQlParserLBRACKET) - } - p.SetState(86) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(83) - p.Match(ZitiQlParserWS) - } - - p.SetState(88) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(89) - p.Match(ZitiQlParserDATETIME) - } - p.SetState(106) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext()) - - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - p.SetState(93) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(90) - p.Match(ZitiQlParserWS) - } - - p.SetState(95) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(96) - p.Match(ZitiQlParserT__0) - } - p.SetState(100) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(97) - p.Match(ZitiQlParserWS) - } - - p.SetState(102) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(103) - p.Match(ZitiQlParserDATETIME) - } - - } - p.SetState(108) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext()) - } - p.SetState(112) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(109) - p.Match(ZitiQlParserWS) - } - - p.SetState(114) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(115) - p.Match(ZitiQlParserRBRACKET) - } - - return localctx -} - -// IStartContext is an interface to support dynamic dispatch. -type IStartContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // IsStartContext differentiates from other interfaces. - IsStartContext() -} - -type StartContext struct { - *antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyStartContext() *StartContext { - var p = new(StartContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) - p.RuleIndex = ZitiQlParserRULE_start - return p -} - -func (*StartContext) IsStartContext() {} - -func NewStartContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *StartContext { - var p = new(StartContext) - - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) - - p.parser = parser - p.RuleIndex = ZitiQlParserRULE_start - - return p -} - -func (s *StartContext) GetParser() antlr.Parser { return s.parser } - -func (s *StartContext) CopyFrom(ctx *StartContext) { - s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) -} - -func (s *StartContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *StartContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -type EndContext struct { - *StartContext -} - -func NewEndContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *EndContext { - var p = new(EndContext) - - p.StartContext = NewEmptyStartContext() - p.parser = parser - p.CopyFrom(ctx.(*StartContext)) - - return p -} - -func (s *EndContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *EndContext) EOF() antlr.TerminalNode { - return s.GetToken(ZitiQlParserEOF, 0) -} - -func (s *EndContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *EndContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *EndContext) AllExpression() []IExpressionContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExpressionContext)(nil)).Elem()) - var tst = make([]IExpressionContext, len(ts)) - - for i, t := range ts { - if t != nil { - tst[i] = t.(IExpressionContext) - } - } - - return tst -} - -func (s *EndContext) Expression(i int) IExpressionContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IExpressionContext)(nil)).Elem(), i) - - if t == nil { - return nil - } - - return t.(IExpressionContext) -} - -func (s *EndContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterEnd(s) - } -} - -func (s *EndContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitEnd(s) - } -} - -func (p *ZitiQlParser) Start() (localctx IStartContext) { - localctx = NewStartContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 6, ZitiQlParserRULE_start) - var _la int - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - - var _alt int - - localctx = NewEndContext(p, localctx) - p.EnterOuterAlt(localctx, 1) - p.SetState(120) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 15, p.GetParserRuleContext()) - - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - { - p.SetState(117) - p.Match(ZitiQlParserWS) - } - - } - p.SetState(122) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 15, p.GetParserRuleContext()) - } - p.SetState(126) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserLPAREN || _la == ZitiQlParserIDENTIFIER { - { - p.SetState(123) - p.expression(0) - } - - p.SetState(128) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - p.SetState(132) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(129) - p.Match(ZitiQlParserWS) - } - - p.SetState(134) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(135) - p.Match(ZitiQlParserEOF) - } - - return localctx -} - -// IExpressionContext is an interface to support dynamic dispatch. -type IExpressionContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // IsExpressionContext differentiates from other interfaces. - IsExpressionContext() -} - -type ExpressionContext struct { - *antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyExpressionContext() *ExpressionContext { - var p = new(ExpressionContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) - p.RuleIndex = ZitiQlParserRULE_expression - return p -} - -func (*ExpressionContext) IsExpressionContext() {} - -func NewExpressionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExpressionContext { - var p = new(ExpressionContext) - - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) - - p.parser = parser - p.RuleIndex = ZitiQlParserRULE_expression - - return p -} - -func (s *ExpressionContext) GetParser() antlr.Parser { return s.parser } - -func (s *ExpressionContext) CopyFrom(ctx *ExpressionContext) { - s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) -} - -func (s *ExpressionContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ExpressionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -type GroupContext struct { - *ExpressionContext -} - -func NewGroupContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *GroupContext { - var p = new(GroupContext) - - p.ExpressionContext = NewEmptyExpressionContext() - p.parser = parser - p.CopyFrom(ctx.(*ExpressionContext)) - - return p -} - -func (s *GroupContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *GroupContext) LPAREN() antlr.TerminalNode { - return s.GetToken(ZitiQlParserLPAREN, 0) -} - -func (s *GroupContext) Expression() IExpressionContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IExpressionContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(IExpressionContext) -} - -func (s *GroupContext) RPAREN() antlr.TerminalNode { - return s.GetToken(ZitiQlParserRPAREN, 0) -} - -func (s *GroupContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *GroupContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *GroupContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterGroup(s) - } -} - -func (s *GroupContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitGroup(s) - } -} - -type OrConjunctionContext struct { - *ExpressionContext -} - -func NewOrConjunctionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *OrConjunctionContext { - var p = new(OrConjunctionContext) - - p.ExpressionContext = NewEmptyExpressionContext() - p.parser = parser - p.CopyFrom(ctx.(*ExpressionContext)) - - return p -} - -func (s *OrConjunctionContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *OrConjunctionContext) AllExpression() []IExpressionContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExpressionContext)(nil)).Elem()) - var tst = make([]IExpressionContext, len(ts)) - - for i, t := range ts { - if t != nil { - tst[i] = t.(IExpressionContext) - } - } - - return tst -} - -func (s *OrConjunctionContext) Expression(i int) IExpressionContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IExpressionContext)(nil)).Elem(), i) - - if t == nil { - return nil - } - - return t.(IExpressionContext) -} - -func (s *OrConjunctionContext) AllOR() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserOR) -} - -func (s *OrConjunctionContext) OR(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserOR, i) -} - -func (s *OrConjunctionContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *OrConjunctionContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *OrConjunctionContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterOrConjunction(s) - } -} - -func (s *OrConjunctionContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitOrConjunction(s) - } -} - -type OperationOpContext struct { - *ExpressionContext -} - -func NewOperationOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *OperationOpContext { - var p = new(OperationOpContext) - - p.ExpressionContext = NewEmptyExpressionContext() - p.parser = parser - p.CopyFrom(ctx.(*ExpressionContext)) - - return p -} - -func (s *OperationOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *OperationOpContext) Operation() IOperationContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IOperationContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(IOperationContext) -} - -func (s *OperationOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterOperationOp(s) - } -} - -func (s *OperationOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitOperationOp(s) - } -} - -type AndConjunctionContext struct { - *ExpressionContext -} - -func NewAndConjunctionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *AndConjunctionContext { - var p = new(AndConjunctionContext) - - p.ExpressionContext = NewEmptyExpressionContext() - p.parser = parser - p.CopyFrom(ctx.(*ExpressionContext)) - - return p -} - -func (s *AndConjunctionContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *AndConjunctionContext) AllExpression() []IExpressionContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExpressionContext)(nil)).Elem()) - var tst = make([]IExpressionContext, len(ts)) - - for i, t := range ts { - if t != nil { - tst[i] = t.(IExpressionContext) - } - } - - return tst -} - -func (s *AndConjunctionContext) Expression(i int) IExpressionContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IExpressionContext)(nil)).Elem(), i) - - if t == nil { - return nil - } - - return t.(IExpressionContext) -} - -func (s *AndConjunctionContext) AllAND() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserAND) -} - -func (s *AndConjunctionContext) AND(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserAND, i) -} - -func (s *AndConjunctionContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *AndConjunctionContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *AndConjunctionContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterAndConjunction(s) - } -} - -func (s *AndConjunctionContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitAndConjunction(s) - } -} - -func (p *ZitiQlParser) Expression() (localctx IExpressionContext) { - return p.expression(0) -} - -func (p *ZitiQlParser) expression(_p int) (localctx IExpressionContext) { - var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext() - _parentState := p.GetState() - localctx = NewExpressionContext(p, p.GetParserRuleContext(), _parentState) - var _prevctx IExpressionContext = localctx - var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. - _startState := 8 - p.EnterRecursionRule(localctx, 8, ZitiQlParserRULE_expression, _p) - var _la int - - defer func() { - p.UnrollRecursionContexts(_parentctx) - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - - var _alt int - - p.EnterOuterAlt(localctx, 1) - p.SetState(155) - p.GetErrorHandler().Sync(p) - - switch p.GetTokenStream().LA(1) { - case ZitiQlParserIDENTIFIER: - localctx = NewOperationOpContext(p, localctx) - p.SetParserRuleContext(localctx) - _prevctx = localctx - - { - p.SetState(138) - p.Operation() - } - - case ZitiQlParserLPAREN: - localctx = NewGroupContext(p, localctx) - p.SetParserRuleContext(localctx) - _prevctx = localctx - { - p.SetState(139) - p.Match(ZitiQlParserLPAREN) - } - p.SetState(143) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(140) - p.Match(ZitiQlParserWS) - } - - p.SetState(145) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(146) - p.expression(0) - } - p.SetState(150) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(147) - p.Match(ZitiQlParserWS) - } - - p.SetState(152) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(153) - p.Match(ZitiQlParserRPAREN) - } - - default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) - } - p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) - p.SetState(193) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 28, p.GetParserRuleContext()) - - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - if p.GetParseListeners() != nil { - p.TriggerExitRuleEvent() - } - _prevctx = localctx - p.SetState(191) - p.GetErrorHandler().Sync(p) - switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 27, p.GetParserRuleContext()) { - case 1: - localctx = NewAndConjunctionContext(p, NewExpressionContext(p, _parentctx, _parentState)) - p.PushNewRecursionContext(localctx, _startState, ZitiQlParserRULE_expression) - p.SetState(157) - - if !(p.Precpred(p.GetParserRuleContext(), 2)) { - panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 2)", "")) - } - p.SetState(170) - p.GetErrorHandler().Sync(p) - _alt = 1 - for ok := true; ok; ok = _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - switch _alt { - case 1: - p.SetState(159) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(158) - p.Match(ZitiQlParserWS) - } - - p.SetState(161) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(163) - p.Match(ZitiQlParserAND) - } - p.SetState(165) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(164) - p.Match(ZitiQlParserWS) - } - - p.SetState(167) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(169) - p.expression(0) - } - - default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) - } - - p.SetState(172) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 23, p.GetParserRuleContext()) - } - - case 2: - localctx = NewOrConjunctionContext(p, NewExpressionContext(p, _parentctx, _parentState)) - p.PushNewRecursionContext(localctx, _startState, ZitiQlParserRULE_expression) - p.SetState(174) - - if !(p.Precpred(p.GetParserRuleContext(), 1)) { - panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 1)", "")) - } - p.SetState(187) - p.GetErrorHandler().Sync(p) - _alt = 1 - for ok := true; ok; ok = _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - switch _alt { - case 1: - p.SetState(176) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(175) - p.Match(ZitiQlParserWS) - } - - p.SetState(178) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(180) - p.Match(ZitiQlParserOR) - } - p.SetState(182) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(181) - p.Match(ZitiQlParserWS) - } - - p.SetState(184) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(186) - p.expression(0) - } - - default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) - } - - p.SetState(189) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 26, p.GetParserRuleContext()) - } - - } - - } - p.SetState(195) - p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 28, p.GetParserRuleContext()) - } - - return localctx -} - -// IOperationContext is an interface to support dynamic dispatch. -type IOperationContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // IsOperationContext differentiates from other interfaces. - IsOperationContext() -} - -type OperationContext struct { - *antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyOperationContext() *OperationContext { - var p = new(OperationContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) - p.RuleIndex = ZitiQlParserRULE_operation - return p -} - -func (*OperationContext) IsOperationContext() {} - -func NewOperationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *OperationContext { - var p = new(OperationContext) - - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) - - p.parser = parser - p.RuleIndex = ZitiQlParserRULE_operation - - return p -} - -func (s *OperationContext) GetParser() antlr.Parser { return s.parser } - -func (s *OperationContext) CopyFrom(ctx *OperationContext) { - s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) -} - -func (s *OperationContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *OperationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -type BinaryEqualToNullOpContext struct { - *OperationContext -} - -func NewBinaryEqualToNullOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToNullOpContext { - var p = new(BinaryEqualToNullOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryEqualToNullOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryEqualToNullOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryEqualToNullOpContext) EQ() antlr.TerminalNode { - return s.GetToken(ZitiQlParserEQ, 0) -} - -func (s *BinaryEqualToNullOpContext) NULL() antlr.TerminalNode { - return s.GetToken(ZitiQlParserNULL, 0) -} - -func (s *BinaryEqualToNullOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryEqualToNullOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryEqualToNullOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryEqualToNullOp(s) - } -} - -func (s *BinaryEqualToNullOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryEqualToNullOp(s) - } -} - -type BinaryLessThanNumberOpContext struct { - *OperationContext -} - -func NewBinaryLessThanNumberOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryLessThanNumberOpContext { - var p = new(BinaryLessThanNumberOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryLessThanNumberOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryLessThanNumberOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryLessThanNumberOpContext) LT() antlr.TerminalNode { - return s.GetToken(ZitiQlParserLT, 0) -} - -func (s *BinaryLessThanNumberOpContext) NUMBER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserNUMBER, 0) -} - -func (s *BinaryLessThanNumberOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryLessThanNumberOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryLessThanNumberOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryLessThanNumberOp(s) - } -} - -func (s *BinaryLessThanNumberOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryLessThanNumberOp(s) - } -} - -type BinaryGreaterThanDatetimeOpContext struct { - *OperationContext -} - -func NewBinaryGreaterThanDatetimeOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryGreaterThanDatetimeOpContext { - var p = new(BinaryGreaterThanDatetimeOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryGreaterThanDatetimeOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryGreaterThanDatetimeOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryGreaterThanDatetimeOpContext) GT() antlr.TerminalNode { - return s.GetToken(ZitiQlParserGT, 0) -} - -func (s *BinaryGreaterThanDatetimeOpContext) DATETIME() antlr.TerminalNode { - return s.GetToken(ZitiQlParserDATETIME, 0) -} - -func (s *BinaryGreaterThanDatetimeOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryGreaterThanDatetimeOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryGreaterThanDatetimeOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryGreaterThanDatetimeOp(s) - } -} - -func (s *BinaryGreaterThanDatetimeOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryGreaterThanDatetimeOp(s) - } -} - -type InNumberArrayOpContext struct { - *OperationContext -} - -func NewInNumberArrayOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InNumberArrayOpContext { - var p = new(InNumberArrayOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *InNumberArrayOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *InNumberArrayOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *InNumberArrayOpContext) IN() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIN, 0) -} - -func (s *InNumberArrayOpContext) Number_array() INumber_arrayContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*INumber_arrayContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(INumber_arrayContext) -} - -func (s *InNumberArrayOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *InNumberArrayOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *InNumberArrayOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterInNumberArrayOp(s) - } -} - -func (s *InNumberArrayOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitInNumberArrayOp(s) - } -} - -type InStringArrayOpContext struct { - *OperationContext -} - -func NewInStringArrayOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InStringArrayOpContext { - var p = new(InStringArrayOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *InStringArrayOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *InStringArrayOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *InStringArrayOpContext) IN() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIN, 0) -} - -func (s *InStringArrayOpContext) String_array() IString_arrayContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IString_arrayContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(IString_arrayContext) -} - -func (s *InStringArrayOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *InStringArrayOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *InStringArrayOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterInStringArrayOp(s) - } -} - -func (s *InStringArrayOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitInStringArrayOp(s) - } -} - -type BinaryLessThanDatetimeOpContext struct { - *OperationContext -} - -func NewBinaryLessThanDatetimeOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryLessThanDatetimeOpContext { - var p = new(BinaryLessThanDatetimeOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryLessThanDatetimeOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryLessThanDatetimeOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryLessThanDatetimeOpContext) LT() antlr.TerminalNode { - return s.GetToken(ZitiQlParserLT, 0) -} - -func (s *BinaryLessThanDatetimeOpContext) DATETIME() antlr.TerminalNode { - return s.GetToken(ZitiQlParserDATETIME, 0) -} - -func (s *BinaryLessThanDatetimeOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryLessThanDatetimeOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryLessThanDatetimeOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryLessThanDatetimeOp(s) - } -} - -func (s *BinaryLessThanDatetimeOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryLessThanDatetimeOp(s) - } -} - -type BinaryGreaterThanNumberOpContext struct { - *OperationContext -} - -func NewBinaryGreaterThanNumberOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryGreaterThanNumberOpContext { - var p = new(BinaryGreaterThanNumberOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryGreaterThanNumberOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryGreaterThanNumberOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryGreaterThanNumberOpContext) GT() antlr.TerminalNode { - return s.GetToken(ZitiQlParserGT, 0) -} - -func (s *BinaryGreaterThanNumberOpContext) NUMBER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserNUMBER, 0) -} - -func (s *BinaryGreaterThanNumberOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryGreaterThanNumberOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryGreaterThanNumberOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryGreaterThanNumberOp(s) - } -} - -func (s *BinaryGreaterThanNumberOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryGreaterThanNumberOp(s) - } -} - -type InDatetimeArrayOpContext struct { - *OperationContext -} - -func NewInDatetimeArrayOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InDatetimeArrayOpContext { - var p = new(InDatetimeArrayOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *InDatetimeArrayOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *InDatetimeArrayOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *InDatetimeArrayOpContext) IN() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIN, 0) -} - -func (s *InDatetimeArrayOpContext) Datetime_array() IDatetime_arrayContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IDatetime_arrayContext)(nil)).Elem(), 0) - - if t == nil { - return nil - } - - return t.(IDatetime_arrayContext) -} - -func (s *InDatetimeArrayOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *InDatetimeArrayOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *InDatetimeArrayOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterInDatetimeArrayOp(s) - } -} - -func (s *InDatetimeArrayOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitInDatetimeArrayOp(s) - } -} - -type BetweenDateOpContext struct { - *OperationContext -} - -func NewBetweenDateOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BetweenDateOpContext { - var p = new(BetweenDateOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BetweenDateOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BetweenDateOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BetweenDateOpContext) BETWEEN() antlr.TerminalNode { - return s.GetToken(ZitiQlParserBETWEEN, 0) -} - -func (s *BetweenDateOpContext) AllDATETIME() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserDATETIME) -} - -func (s *BetweenDateOpContext) DATETIME(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserDATETIME, i) -} - -func (s *BetweenDateOpContext) AND() antlr.TerminalNode { - return s.GetToken(ZitiQlParserAND, 0) -} - -func (s *BetweenDateOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BetweenDateOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BetweenDateOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBetweenDateOp(s) - } -} - -func (s *BetweenDateOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBetweenDateOp(s) - } -} - -type BinaryEqualToNumberOpContext struct { - *OperationContext -} - -func NewBinaryEqualToNumberOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToNumberOpContext { - var p = new(BinaryEqualToNumberOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryEqualToNumberOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryEqualToNumberOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryEqualToNumberOpContext) EQ() antlr.TerminalNode { - return s.GetToken(ZitiQlParserEQ, 0) -} - -func (s *BinaryEqualToNumberOpContext) NUMBER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserNUMBER, 0) -} - -func (s *BinaryEqualToNumberOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryEqualToNumberOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryEqualToNumberOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryEqualToNumberOp(s) - } -} - -func (s *BinaryEqualToNumberOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryEqualToNumberOp(s) - } -} - -type BinaryEqualToBoolOpContext struct { - *OperationContext -} - -func NewBinaryEqualToBoolOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToBoolOpContext { - var p = new(BinaryEqualToBoolOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryEqualToBoolOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryEqualToBoolOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryEqualToBoolOpContext) EQ() antlr.TerminalNode { - return s.GetToken(ZitiQlParserEQ, 0) -} - -func (s *BinaryEqualToBoolOpContext) BOOL() antlr.TerminalNode { - return s.GetToken(ZitiQlParserBOOL, 0) -} - -func (s *BinaryEqualToBoolOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryEqualToBoolOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryEqualToBoolOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryEqualToBoolOp(s) - } -} - -func (s *BinaryEqualToBoolOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryEqualToBoolOp(s) - } -} - -type BinaryEqualToStringOpContext struct { - *OperationContext -} - -func NewBinaryEqualToStringOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToStringOpContext { - var p = new(BinaryEqualToStringOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryEqualToStringOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryEqualToStringOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryEqualToStringOpContext) EQ() antlr.TerminalNode { - return s.GetToken(ZitiQlParserEQ, 0) -} - -func (s *BinaryEqualToStringOpContext) STRING() antlr.TerminalNode { - return s.GetToken(ZitiQlParserSTRING, 0) -} - -func (s *BinaryEqualToStringOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryEqualToStringOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryEqualToStringOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryEqualToStringOp(s) - } -} - -func (s *BinaryEqualToStringOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryEqualToStringOp(s) - } -} - -type BetweenNumberOpContext struct { - *OperationContext -} - -func NewBetweenNumberOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BetweenNumberOpContext { - var p = new(BetweenNumberOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BetweenNumberOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BetweenNumberOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BetweenNumberOpContext) BETWEEN() antlr.TerminalNode { - return s.GetToken(ZitiQlParserBETWEEN, 0) -} - -func (s *BetweenNumberOpContext) AllNUMBER() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserNUMBER) -} - -func (s *BetweenNumberOpContext) NUMBER(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserNUMBER, i) -} - -func (s *BetweenNumberOpContext) AND() antlr.TerminalNode { - return s.GetToken(ZitiQlParserAND, 0) -} - -func (s *BetweenNumberOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BetweenNumberOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BetweenNumberOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBetweenNumberOp(s) - } -} - -func (s *BetweenNumberOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBetweenNumberOp(s) - } -} - -type BinaryContainsOpContext struct { - *OperationContext -} - -func NewBinaryContainsOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryContainsOpContext { - var p = new(BinaryContainsOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryContainsOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryContainsOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryContainsOpContext) CONTAINS() antlr.TerminalNode { - return s.GetToken(ZitiQlParserCONTAINS, 0) -} - -func (s *BinaryContainsOpContext) STRING() antlr.TerminalNode { - return s.GetToken(ZitiQlParserSTRING, 0) -} - -func (s *BinaryContainsOpContext) NUMBER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserNUMBER, 0) -} - -func (s *BinaryContainsOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryContainsOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryContainsOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryContainsOp(s) - } -} - -func (s *BinaryContainsOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryContainsOp(s) - } -} - -type BinaryEqualToDatetimeOpContext struct { - *OperationContext -} - -func NewBinaryEqualToDatetimeOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToDatetimeOpContext { - var p = new(BinaryEqualToDatetimeOpContext) - - p.OperationContext = NewEmptyOperationContext() - p.parser = parser - p.CopyFrom(ctx.(*OperationContext)) - - return p -} - -func (s *BinaryEqualToDatetimeOpContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *BinaryEqualToDatetimeOpContext) IDENTIFIER() antlr.TerminalNode { - return s.GetToken(ZitiQlParserIDENTIFIER, 0) -} - -func (s *BinaryEqualToDatetimeOpContext) EQ() antlr.TerminalNode { - return s.GetToken(ZitiQlParserEQ, 0) -} - -func (s *BinaryEqualToDatetimeOpContext) DATETIME() antlr.TerminalNode { - return s.GetToken(ZitiQlParserDATETIME, 0) -} - -func (s *BinaryEqualToDatetimeOpContext) AllWS() []antlr.TerminalNode { - return s.GetTokens(ZitiQlParserWS) -} - -func (s *BinaryEqualToDatetimeOpContext) WS(i int) antlr.TerminalNode { - return s.GetToken(ZitiQlParserWS, i) -} - -func (s *BinaryEqualToDatetimeOpContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.EnterBinaryEqualToDatetimeOp(s) - } -} - -func (s *BinaryEqualToDatetimeOpContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ZitiQlListener); ok { - listenerT.ExitBinaryEqualToDatetimeOp(s) - } -} - -func (p *ZitiQlParser) Operation() (localctx IOperationContext) { - localctx = NewOperationContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 10, ZitiQlParserRULE_operation) - var _la int - - defer func() { - p.ExitRule() - }() - - defer func() { - if err := recover(); err != nil { - if v, ok := err.(antlr.RecognitionException); ok { - localctx.SetException(v) - p.GetErrorHandler().ReportError(p, v) - p.GetErrorHandler().Recover(p, v) - } else { - panic(err) - } - } - }() - - p.SetState(434) - p.GetErrorHandler().Sync(p) - switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 63, p.GetParserRuleContext()) { - case 1: - localctx = NewInStringArrayOpContext(p, localctx) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(196) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(198) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(197) - p.Match(ZitiQlParserWS) - } - - p.SetState(200) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(202) - p.Match(ZitiQlParserIN) - } - p.SetState(204) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(203) - p.Match(ZitiQlParserWS) - } - - p.SetState(206) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(208) - p.String_array() - } - - case 2: - localctx = NewInNumberArrayOpContext(p, localctx) - p.EnterOuterAlt(localctx, 2) - { - p.SetState(209) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(211) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(210) - p.Match(ZitiQlParserWS) - } - - p.SetState(213) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(215) - p.Match(ZitiQlParserIN) - } - p.SetState(217) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(216) - p.Match(ZitiQlParserWS) - } - - p.SetState(219) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(221) - p.Number_array() - } - - case 3: - localctx = NewInDatetimeArrayOpContext(p, localctx) - p.EnterOuterAlt(localctx, 3) - { - p.SetState(222) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(224) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(223) - p.Match(ZitiQlParserWS) - } - - p.SetState(226) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(228) - p.Match(ZitiQlParserIN) - } - p.SetState(230) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(229) - p.Match(ZitiQlParserWS) - } - - p.SetState(232) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(234) - p.Datetime_array() - } - - case 4: - localctx = NewBetweenNumberOpContext(p, localctx) - p.EnterOuterAlt(localctx, 4) - { - p.SetState(235) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(237) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(236) - p.Match(ZitiQlParserWS) - } - - p.SetState(239) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(241) - p.Match(ZitiQlParserBETWEEN) - } - p.SetState(243) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(242) - p.Match(ZitiQlParserWS) - } - - p.SetState(245) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(247) - p.Match(ZitiQlParserNUMBER) - } - p.SetState(249) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(248) - p.Match(ZitiQlParserWS) - } - - p.SetState(251) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(253) - p.Match(ZitiQlParserAND) - } - p.SetState(255) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(254) - p.Match(ZitiQlParserWS) - } - - p.SetState(257) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(259) - p.Match(ZitiQlParserNUMBER) - } - - case 5: - localctx = NewBetweenDateOpContext(p, localctx) - p.EnterOuterAlt(localctx, 5) - { - p.SetState(260) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(262) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(261) - p.Match(ZitiQlParserWS) - } - - p.SetState(264) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(266) - p.Match(ZitiQlParserBETWEEN) - } - p.SetState(268) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(267) - p.Match(ZitiQlParserWS) - } - - p.SetState(270) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(272) - p.Match(ZitiQlParserDATETIME) - } - p.SetState(274) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(273) - p.Match(ZitiQlParserWS) - } - - p.SetState(276) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(278) - p.Match(ZitiQlParserAND) - } - p.SetState(280) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(279) - p.Match(ZitiQlParserWS) - } - - p.SetState(282) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(284) - p.Match(ZitiQlParserDATETIME) - } - - case 6: - localctx = NewBinaryLessThanNumberOpContext(p, localctx) - p.EnterOuterAlt(localctx, 6) - { - p.SetState(285) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(289) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(286) - p.Match(ZitiQlParserWS) - } - - p.SetState(291) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(292) - p.Match(ZitiQlParserLT) - } - p.SetState(296) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(293) - p.Match(ZitiQlParserWS) - } - - p.SetState(298) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(299) - p.Match(ZitiQlParserNUMBER) - } - - case 7: - localctx = NewBinaryLessThanDatetimeOpContext(p, localctx) - p.EnterOuterAlt(localctx, 7) - { - p.SetState(300) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(304) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(301) - p.Match(ZitiQlParserWS) - } - - p.SetState(306) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(307) - p.Match(ZitiQlParserLT) - } - p.SetState(311) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(308) - p.Match(ZitiQlParserWS) - } - - p.SetState(313) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(314) - p.Match(ZitiQlParserDATETIME) - } - - case 8: - localctx = NewBinaryGreaterThanNumberOpContext(p, localctx) - p.EnterOuterAlt(localctx, 8) - { - p.SetState(315) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(319) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(316) - p.Match(ZitiQlParserWS) - } - - p.SetState(321) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(322) - p.Match(ZitiQlParserGT) - } - p.SetState(326) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(323) - p.Match(ZitiQlParserWS) - } - - p.SetState(328) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(329) - p.Match(ZitiQlParserNUMBER) - } - - case 9: - localctx = NewBinaryGreaterThanDatetimeOpContext(p, localctx) - p.EnterOuterAlt(localctx, 9) - { - p.SetState(330) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(334) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(331) - p.Match(ZitiQlParserWS) - } - - p.SetState(336) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(337) - p.Match(ZitiQlParserGT) - } - p.SetState(341) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(338) - p.Match(ZitiQlParserWS) - } - - p.SetState(343) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(344) - p.Match(ZitiQlParserDATETIME) - } - - case 10: - localctx = NewBinaryEqualToStringOpContext(p, localctx) - p.EnterOuterAlt(localctx, 10) - { - p.SetState(345) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(349) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(346) - p.Match(ZitiQlParserWS) - } - - p.SetState(351) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(352) - p.Match(ZitiQlParserEQ) - } - p.SetState(356) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(353) - p.Match(ZitiQlParserWS) - } - - p.SetState(358) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(359) - p.Match(ZitiQlParserSTRING) - } - - case 11: - localctx = NewBinaryEqualToNumberOpContext(p, localctx) - p.EnterOuterAlt(localctx, 11) - { - p.SetState(360) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(364) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(361) - p.Match(ZitiQlParserWS) - } - - p.SetState(366) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(367) - p.Match(ZitiQlParserEQ) - } - p.SetState(371) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(368) - p.Match(ZitiQlParserWS) - } - - p.SetState(373) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(374) - p.Match(ZitiQlParserNUMBER) - } - - case 12: - localctx = NewBinaryEqualToDatetimeOpContext(p, localctx) - p.EnterOuterAlt(localctx, 12) - { - p.SetState(375) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(379) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(376) - p.Match(ZitiQlParserWS) - } - - p.SetState(381) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(382) - p.Match(ZitiQlParserEQ) - } - p.SetState(386) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(383) - p.Match(ZitiQlParserWS) - } - - p.SetState(388) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(389) - p.Match(ZitiQlParserDATETIME) - } - - case 13: - localctx = NewBinaryEqualToBoolOpContext(p, localctx) - p.EnterOuterAlt(localctx, 13) - { - p.SetState(390) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(394) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(391) - p.Match(ZitiQlParserWS) - } - - p.SetState(396) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(397) - p.Match(ZitiQlParserEQ) - } - p.SetState(401) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(398) - p.Match(ZitiQlParserWS) - } - - p.SetState(403) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(404) - p.Match(ZitiQlParserBOOL) - } - - case 14: - localctx = NewBinaryEqualToNullOpContext(p, localctx) - p.EnterOuterAlt(localctx, 14) - { - p.SetState(405) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(409) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(406) - p.Match(ZitiQlParserWS) - } - - p.SetState(411) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(412) - p.Match(ZitiQlParserEQ) - } - p.SetState(416) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(413) - p.Match(ZitiQlParserWS) - } - - p.SetState(418) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(419) - p.Match(ZitiQlParserNULL) - } - - case 15: - localctx = NewBinaryContainsOpContext(p, localctx) - p.EnterOuterAlt(localctx, 15) - { - p.SetState(420) - p.Match(ZitiQlParserIDENTIFIER) - } - p.SetState(424) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for _la == ZitiQlParserWS { - { - p.SetState(421) - p.Match(ZitiQlParserWS) - } - - p.SetState(426) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(427) - p.Match(ZitiQlParserCONTAINS) - } - p.SetState(429) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ZitiQlParserWS { - { - p.SetState(428) - p.Match(ZitiQlParserWS) - } - - p.SetState(431) - p.GetErrorHandler().Sync(p) - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(433) - _la = p.GetTokenStream().LA(1) - - if !(_la == ZitiQlParserSTRING || _la == ZitiQlParserNUMBER) { - p.GetErrorHandler().RecoverInline(p) - } else { - p.GetErrorHandler().ReportMatch(p) - p.Consume() - } - } - - } - - return localctx -} - -func (p *ZitiQlParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool { - switch ruleIndex { - case 4: - var t *ExpressionContext = nil - if localctx != nil { - t = localctx.(*ExpressionContext) - } - return p.Expression_Sempred(t, predIndex) - - default: - panic("No predicate with index: " + fmt.Sprint(ruleIndex)) - } -} - -func (p *ZitiQlParser) Expression_Sempred(localctx antlr.RuleContext, predIndex int) bool { - switch predIndex { - case 0: - return p.Precpred(p.GetParserRuleContext(), 2) - - case 1: - return p.Precpred(p.GetParserRuleContext(), 1) - - default: - panic("No predicate with index: " + fmt.Sprint(predIndex)) - } -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Code generated from ZitiQl.g4 by ANTLR 4.7.1. DO NOT EDIT. + +package zitiql // ZitiQl +import ( + "fmt" + "reflect" + "strconv" + + "github.com/antlr/antlr4/runtime/Go/antlr" +) + +// Suppress unused import errors +var _ = fmt.Printf +var _ = reflect.Copy +var _ = strconv.Itoa + +var parserATN = []uint16{ + 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 23, 439, + 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, + 3, 2, 3, 2, 7, 2, 17, 10, 2, 12, 2, 14, 2, 20, 11, 2, 3, 2, 3, 2, 7, 2, + 24, 10, 2, 12, 2, 14, 2, 27, 11, 2, 3, 2, 3, 2, 7, 2, 31, 10, 2, 12, 2, + 14, 2, 34, 11, 2, 3, 2, 7, 2, 37, 10, 2, 12, 2, 14, 2, 40, 11, 2, 3, 2, + 7, 2, 43, 10, 2, 12, 2, 14, 2, 46, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 7, 3, + 52, 10, 3, 12, 3, 14, 3, 55, 11, 3, 3, 3, 3, 3, 7, 3, 59, 10, 3, 12, 3, + 14, 3, 62, 11, 3, 3, 3, 3, 3, 7, 3, 66, 10, 3, 12, 3, 14, 3, 69, 11, 3, + 3, 3, 7, 3, 72, 10, 3, 12, 3, 14, 3, 75, 11, 3, 3, 3, 7, 3, 78, 10, 3, + 12, 3, 14, 3, 81, 11, 3, 3, 3, 3, 3, 3, 4, 3, 4, 7, 4, 87, 10, 4, 12, 4, + 14, 4, 90, 11, 4, 3, 4, 3, 4, 7, 4, 94, 10, 4, 12, 4, 14, 4, 97, 11, 4, + 3, 4, 3, 4, 7, 4, 101, 10, 4, 12, 4, 14, 4, 104, 11, 4, 3, 4, 7, 4, 107, + 10, 4, 12, 4, 14, 4, 110, 11, 4, 3, 4, 7, 4, 113, 10, 4, 12, 4, 14, 4, + 116, 11, 4, 3, 4, 3, 4, 3, 5, 7, 5, 121, 10, 5, 12, 5, 14, 5, 124, 11, + 5, 3, 5, 7, 5, 127, 10, 5, 12, 5, 14, 5, 130, 11, 5, 3, 5, 7, 5, 133, 10, + 5, 12, 5, 14, 5, 136, 11, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 7, 6, + 144, 10, 6, 12, 6, 14, 6, 147, 11, 6, 3, 6, 3, 6, 7, 6, 151, 10, 6, 12, + 6, 14, 6, 154, 11, 6, 3, 6, 3, 6, 5, 6, 158, 10, 6, 3, 6, 3, 6, 6, 6, 162, + 10, 6, 13, 6, 14, 6, 163, 3, 6, 3, 6, 6, 6, 168, 10, 6, 13, 6, 14, 6, 169, + 3, 6, 6, 6, 173, 10, 6, 13, 6, 14, 6, 174, 3, 6, 3, 6, 6, 6, 179, 10, 6, + 13, 6, 14, 6, 180, 3, 6, 3, 6, 6, 6, 185, 10, 6, 13, 6, 14, 6, 186, 3, + 6, 6, 6, 190, 10, 6, 13, 6, 14, 6, 191, 7, 6, 194, 10, 6, 12, 6, 14, 6, + 197, 11, 6, 3, 7, 3, 7, 6, 7, 201, 10, 7, 13, 7, 14, 7, 202, 3, 7, 3, 7, + 6, 7, 207, 10, 7, 13, 7, 14, 7, 208, 3, 7, 3, 7, 3, 7, 6, 7, 214, 10, 7, + 13, 7, 14, 7, 215, 3, 7, 3, 7, 6, 7, 220, 10, 7, 13, 7, 14, 7, 221, 3, + 7, 3, 7, 3, 7, 6, 7, 227, 10, 7, 13, 7, 14, 7, 228, 3, 7, 3, 7, 6, 7, 233, + 10, 7, 13, 7, 14, 7, 234, 3, 7, 3, 7, 3, 7, 6, 7, 240, 10, 7, 13, 7, 14, + 7, 241, 3, 7, 3, 7, 6, 7, 246, 10, 7, 13, 7, 14, 7, 247, 3, 7, 3, 7, 6, + 7, 252, 10, 7, 13, 7, 14, 7, 253, 3, 7, 3, 7, 6, 7, 258, 10, 7, 13, 7, + 14, 7, 259, 3, 7, 3, 7, 3, 7, 6, 7, 265, 10, 7, 13, 7, 14, 7, 266, 3, 7, + 3, 7, 6, 7, 271, 10, 7, 13, 7, 14, 7, 272, 3, 7, 3, 7, 6, 7, 277, 10, 7, + 13, 7, 14, 7, 278, 3, 7, 3, 7, 6, 7, 283, 10, 7, 13, 7, 14, 7, 284, 3, + 7, 3, 7, 3, 7, 7, 7, 290, 10, 7, 12, 7, 14, 7, 293, 11, 7, 3, 7, 3, 7, + 7, 7, 297, 10, 7, 12, 7, 14, 7, 300, 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 305, + 10, 7, 12, 7, 14, 7, 308, 11, 7, 3, 7, 3, 7, 7, 7, 312, 10, 7, 12, 7, 14, + 7, 315, 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 320, 10, 7, 12, 7, 14, 7, 323, 11, + 7, 3, 7, 3, 7, 7, 7, 327, 10, 7, 12, 7, 14, 7, 330, 11, 7, 3, 7, 3, 7, + 3, 7, 7, 7, 335, 10, 7, 12, 7, 14, 7, 338, 11, 7, 3, 7, 3, 7, 7, 7, 342, + 10, 7, 12, 7, 14, 7, 345, 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 350, 10, 7, 12, + 7, 14, 7, 353, 11, 7, 3, 7, 3, 7, 7, 7, 357, 10, 7, 12, 7, 14, 7, 360, + 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 365, 10, 7, 12, 7, 14, 7, 368, 11, 7, 3, + 7, 3, 7, 7, 7, 372, 10, 7, 12, 7, 14, 7, 375, 11, 7, 3, 7, 3, 7, 3, 7, + 7, 7, 380, 10, 7, 12, 7, 14, 7, 383, 11, 7, 3, 7, 3, 7, 7, 7, 387, 10, + 7, 12, 7, 14, 7, 390, 11, 7, 3, 7, 3, 7, 3, 7, 7, 7, 395, 10, 7, 12, 7, + 14, 7, 398, 11, 7, 3, 7, 3, 7, 7, 7, 402, 10, 7, 12, 7, 14, 7, 405, 11, + 7, 3, 7, 3, 7, 3, 7, 7, 7, 410, 10, 7, 12, 7, 14, 7, 413, 11, 7, 3, 7, + 3, 7, 7, 7, 417, 10, 7, 12, 7, 14, 7, 420, 11, 7, 3, 7, 3, 7, 3, 7, 7, + 7, 425, 10, 7, 12, 7, 14, 7, 428, 11, 7, 3, 7, 3, 7, 6, 7, 432, 10, 7, + 13, 7, 14, 7, 433, 3, 7, 5, 7, 437, 10, 7, 3, 7, 2, 3, 10, 8, 2, 4, 6, + 8, 10, 12, 2, 3, 3, 2, 19, 20, 2, 509, 2, 14, 3, 2, 2, 2, 4, 49, 3, 2, + 2, 2, 6, 84, 3, 2, 2, 2, 8, 122, 3, 2, 2, 2, 10, 157, 3, 2, 2, 2, 12, 436, + 3, 2, 2, 2, 14, 18, 7, 7, 2, 2, 15, 17, 7, 4, 2, 2, 16, 15, 3, 2, 2, 2, + 17, 20, 3, 2, 2, 2, 18, 16, 3, 2, 2, 2, 18, 19, 3, 2, 2, 2, 19, 21, 3, + 2, 2, 2, 20, 18, 3, 2, 2, 2, 21, 38, 7, 19, 2, 2, 22, 24, 7, 4, 2, 2, 23, + 22, 3, 2, 2, 2, 24, 27, 3, 2, 2, 2, 25, 23, 3, 2, 2, 2, 25, 26, 3, 2, 2, + 2, 26, 28, 3, 2, 2, 2, 27, 25, 3, 2, 2, 2, 28, 32, 7, 3, 2, 2, 29, 31, + 7, 4, 2, 2, 30, 29, 3, 2, 2, 2, 31, 34, 3, 2, 2, 2, 32, 30, 3, 2, 2, 2, + 32, 33, 3, 2, 2, 2, 33, 35, 3, 2, 2, 2, 34, 32, 3, 2, 2, 2, 35, 37, 7, + 19, 2, 2, 36, 25, 3, 2, 2, 2, 37, 40, 3, 2, 2, 2, 38, 36, 3, 2, 2, 2, 38, + 39, 3, 2, 2, 2, 39, 44, 3, 2, 2, 2, 40, 38, 3, 2, 2, 2, 41, 43, 7, 4, 2, + 2, 42, 41, 3, 2, 2, 2, 43, 46, 3, 2, 2, 2, 44, 42, 3, 2, 2, 2, 44, 45, + 3, 2, 2, 2, 45, 47, 3, 2, 2, 2, 46, 44, 3, 2, 2, 2, 47, 48, 7, 8, 2, 2, + 48, 3, 3, 2, 2, 2, 49, 53, 7, 7, 2, 2, 50, 52, 7, 4, 2, 2, 51, 50, 3, 2, + 2, 2, 52, 55, 3, 2, 2, 2, 53, 51, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 56, + 3, 2, 2, 2, 55, 53, 3, 2, 2, 2, 56, 73, 7, 20, 2, 2, 57, 59, 7, 4, 2, 2, + 58, 57, 3, 2, 2, 2, 59, 62, 3, 2, 2, 2, 60, 58, 3, 2, 2, 2, 60, 61, 3, + 2, 2, 2, 61, 63, 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 63, 67, 7, 3, 2, 2, 64, + 66, 7, 4, 2, 2, 65, 64, 3, 2, 2, 2, 66, 69, 3, 2, 2, 2, 67, 65, 3, 2, 2, + 2, 67, 68, 3, 2, 2, 2, 68, 70, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 70, 72, + 7, 20, 2, 2, 71, 60, 3, 2, 2, 2, 72, 75, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, + 73, 74, 3, 2, 2, 2, 74, 79, 3, 2, 2, 2, 75, 73, 3, 2, 2, 2, 76, 78, 7, + 4, 2, 2, 77, 76, 3, 2, 2, 2, 78, 81, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 79, + 80, 3, 2, 2, 2, 80, 82, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 82, 83, 7, 8, 2, + 2, 83, 5, 3, 2, 2, 2, 84, 88, 7, 7, 2, 2, 85, 87, 7, 4, 2, 2, 86, 85, 3, + 2, 2, 2, 87, 90, 3, 2, 2, 2, 88, 86, 3, 2, 2, 2, 88, 89, 3, 2, 2, 2, 89, + 91, 3, 2, 2, 2, 90, 88, 3, 2, 2, 2, 91, 108, 7, 18, 2, 2, 92, 94, 7, 4, + 2, 2, 93, 92, 3, 2, 2, 2, 94, 97, 3, 2, 2, 2, 95, 93, 3, 2, 2, 2, 95, 96, + 3, 2, 2, 2, 96, 98, 3, 2, 2, 2, 97, 95, 3, 2, 2, 2, 98, 102, 7, 3, 2, 2, + 99, 101, 7, 4, 2, 2, 100, 99, 3, 2, 2, 2, 101, 104, 3, 2, 2, 2, 102, 100, + 3, 2, 2, 2, 102, 103, 3, 2, 2, 2, 103, 105, 3, 2, 2, 2, 104, 102, 3, 2, + 2, 2, 105, 107, 7, 18, 2, 2, 106, 95, 3, 2, 2, 2, 107, 110, 3, 2, 2, 2, + 108, 106, 3, 2, 2, 2, 108, 109, 3, 2, 2, 2, 109, 114, 3, 2, 2, 2, 110, + 108, 3, 2, 2, 2, 111, 113, 7, 4, 2, 2, 112, 111, 3, 2, 2, 2, 113, 116, + 3, 2, 2, 2, 114, 112, 3, 2, 2, 2, 114, 115, 3, 2, 2, 2, 115, 117, 3, 2, + 2, 2, 116, 114, 3, 2, 2, 2, 117, 118, 7, 8, 2, 2, 118, 7, 3, 2, 2, 2, 119, + 121, 7, 4, 2, 2, 120, 119, 3, 2, 2, 2, 121, 124, 3, 2, 2, 2, 122, 120, + 3, 2, 2, 2, 122, 123, 3, 2, 2, 2, 123, 128, 3, 2, 2, 2, 124, 122, 3, 2, + 2, 2, 125, 127, 5, 10, 6, 2, 126, 125, 3, 2, 2, 2, 127, 130, 3, 2, 2, 2, + 128, 126, 3, 2, 2, 2, 128, 129, 3, 2, 2, 2, 129, 134, 3, 2, 2, 2, 130, + 128, 3, 2, 2, 2, 131, 133, 7, 4, 2, 2, 132, 131, 3, 2, 2, 2, 133, 136, + 3, 2, 2, 2, 134, 132, 3, 2, 2, 2, 134, 135, 3, 2, 2, 2, 135, 137, 3, 2, + 2, 2, 136, 134, 3, 2, 2, 2, 137, 138, 7, 2, 2, 3, 138, 9, 3, 2, 2, 2, 139, + 140, 8, 6, 1, 2, 140, 158, 5, 12, 7, 2, 141, 145, 7, 5, 2, 2, 142, 144, + 7, 4, 2, 2, 143, 142, 3, 2, 2, 2, 144, 147, 3, 2, 2, 2, 145, 143, 3, 2, + 2, 2, 145, 146, 3, 2, 2, 2, 146, 148, 3, 2, 2, 2, 147, 145, 3, 2, 2, 2, + 148, 152, 5, 10, 6, 2, 149, 151, 7, 4, 2, 2, 150, 149, 3, 2, 2, 2, 151, + 154, 3, 2, 2, 2, 152, 150, 3, 2, 2, 2, 152, 153, 3, 2, 2, 2, 153, 155, + 3, 2, 2, 2, 154, 152, 3, 2, 2, 2, 155, 156, 7, 6, 2, 2, 156, 158, 3, 2, + 2, 2, 157, 139, 3, 2, 2, 2, 157, 141, 3, 2, 2, 2, 158, 195, 3, 2, 2, 2, + 159, 172, 12, 4, 2, 2, 160, 162, 7, 4, 2, 2, 161, 160, 3, 2, 2, 2, 162, + 163, 3, 2, 2, 2, 163, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 165, + 3, 2, 2, 2, 165, 167, 7, 9, 2, 2, 166, 168, 7, 4, 2, 2, 167, 166, 3, 2, + 2, 2, 168, 169, 3, 2, 2, 2, 169, 167, 3, 2, 2, 2, 169, 170, 3, 2, 2, 2, + 170, 171, 3, 2, 2, 2, 171, 173, 5, 10, 6, 2, 172, 161, 3, 2, 2, 2, 173, + 174, 3, 2, 2, 2, 174, 172, 3, 2, 2, 2, 174, 175, 3, 2, 2, 2, 175, 194, + 3, 2, 2, 2, 176, 189, 12, 3, 2, 2, 177, 179, 7, 4, 2, 2, 178, 177, 3, 2, + 2, 2, 179, 180, 3, 2, 2, 2, 180, 178, 3, 2, 2, 2, 180, 181, 3, 2, 2, 2, + 181, 182, 3, 2, 2, 2, 182, 184, 7, 10, 2, 2, 183, 185, 7, 4, 2, 2, 184, + 183, 3, 2, 2, 2, 185, 186, 3, 2, 2, 2, 186, 184, 3, 2, 2, 2, 186, 187, + 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 190, 5, 10, 6, 2, 189, 178, 3, 2, + 2, 2, 190, 191, 3, 2, 2, 2, 191, 189, 3, 2, 2, 2, 191, 192, 3, 2, 2, 2, + 192, 194, 3, 2, 2, 2, 193, 159, 3, 2, 2, 2, 193, 176, 3, 2, 2, 2, 194, + 197, 3, 2, 2, 2, 195, 193, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 11, 3, + 2, 2, 2, 197, 195, 3, 2, 2, 2, 198, 200, 7, 22, 2, 2, 199, 201, 7, 4, 2, + 2, 200, 199, 3, 2, 2, 2, 201, 202, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 202, + 203, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 206, 7, 15, 2, 2, 205, 207, + 7, 4, 2, 2, 206, 205, 3, 2, 2, 2, 207, 208, 3, 2, 2, 2, 208, 206, 3, 2, + 2, 2, 208, 209, 3, 2, 2, 2, 209, 210, 3, 2, 2, 2, 210, 437, 5, 2, 2, 2, + 211, 213, 7, 22, 2, 2, 212, 214, 7, 4, 2, 2, 213, 212, 3, 2, 2, 2, 214, + 215, 3, 2, 2, 2, 215, 213, 3, 2, 2, 2, 215, 216, 3, 2, 2, 2, 216, 217, + 3, 2, 2, 2, 217, 219, 7, 15, 2, 2, 218, 220, 7, 4, 2, 2, 219, 218, 3, 2, + 2, 2, 220, 221, 3, 2, 2, 2, 221, 219, 3, 2, 2, 2, 221, 222, 3, 2, 2, 2, + 222, 223, 3, 2, 2, 2, 223, 437, 5, 4, 3, 2, 224, 226, 7, 22, 2, 2, 225, + 227, 7, 4, 2, 2, 226, 225, 3, 2, 2, 2, 227, 228, 3, 2, 2, 2, 228, 226, + 3, 2, 2, 2, 228, 229, 3, 2, 2, 2, 229, 230, 3, 2, 2, 2, 230, 232, 7, 15, + 2, 2, 231, 233, 7, 4, 2, 2, 232, 231, 3, 2, 2, 2, 233, 234, 3, 2, 2, 2, + 234, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 2, 235, 236, 3, 2, 2, 2, 236, + 437, 5, 6, 4, 2, 237, 239, 7, 22, 2, 2, 238, 240, 7, 4, 2, 2, 239, 238, + 3, 2, 2, 2, 240, 241, 3, 2, 2, 2, 241, 239, 3, 2, 2, 2, 241, 242, 3, 2, + 2, 2, 242, 243, 3, 2, 2, 2, 243, 245, 7, 16, 2, 2, 244, 246, 7, 4, 2, 2, + 245, 244, 3, 2, 2, 2, 246, 247, 3, 2, 2, 2, 247, 245, 3, 2, 2, 2, 247, + 248, 3, 2, 2, 2, 248, 249, 3, 2, 2, 2, 249, 251, 7, 20, 2, 2, 250, 252, + 7, 4, 2, 2, 251, 250, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 251, 3, 2, + 2, 2, 253, 254, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 257, 7, 9, 2, 2, + 256, 258, 7, 4, 2, 2, 257, 256, 3, 2, 2, 2, 258, 259, 3, 2, 2, 2, 259, + 257, 3, 2, 2, 2, 259, 260, 3, 2, 2, 2, 260, 261, 3, 2, 2, 2, 261, 437, + 7, 20, 2, 2, 262, 264, 7, 22, 2, 2, 263, 265, 7, 4, 2, 2, 264, 263, 3, + 2, 2, 2, 265, 266, 3, 2, 2, 2, 266, 264, 3, 2, 2, 2, 266, 267, 3, 2, 2, + 2, 267, 268, 3, 2, 2, 2, 268, 270, 7, 16, 2, 2, 269, 271, 7, 4, 2, 2, 270, + 269, 3, 2, 2, 2, 271, 272, 3, 2, 2, 2, 272, 270, 3, 2, 2, 2, 272, 273, + 3, 2, 2, 2, 273, 274, 3, 2, 2, 2, 274, 276, 7, 18, 2, 2, 275, 277, 7, 4, + 2, 2, 276, 275, 3, 2, 2, 2, 277, 278, 3, 2, 2, 2, 278, 276, 3, 2, 2, 2, + 278, 279, 3, 2, 2, 2, 279, 280, 3, 2, 2, 2, 280, 282, 7, 9, 2, 2, 281, + 283, 7, 4, 2, 2, 282, 281, 3, 2, 2, 2, 283, 284, 3, 2, 2, 2, 284, 282, + 3, 2, 2, 2, 284, 285, 3, 2, 2, 2, 285, 286, 3, 2, 2, 2, 286, 437, 7, 18, + 2, 2, 287, 291, 7, 22, 2, 2, 288, 290, 7, 4, 2, 2, 289, 288, 3, 2, 2, 2, + 290, 293, 3, 2, 2, 2, 291, 289, 3, 2, 2, 2, 291, 292, 3, 2, 2, 2, 292, + 294, 3, 2, 2, 2, 293, 291, 3, 2, 2, 2, 294, 298, 7, 11, 2, 2, 295, 297, + 7, 4, 2, 2, 296, 295, 3, 2, 2, 2, 297, 300, 3, 2, 2, 2, 298, 296, 3, 2, + 2, 2, 298, 299, 3, 2, 2, 2, 299, 301, 3, 2, 2, 2, 300, 298, 3, 2, 2, 2, + 301, 437, 7, 20, 2, 2, 302, 306, 7, 22, 2, 2, 303, 305, 7, 4, 2, 2, 304, + 303, 3, 2, 2, 2, 305, 308, 3, 2, 2, 2, 306, 304, 3, 2, 2, 2, 306, 307, + 3, 2, 2, 2, 307, 309, 3, 2, 2, 2, 308, 306, 3, 2, 2, 2, 309, 313, 7, 11, + 2, 2, 310, 312, 7, 4, 2, 2, 311, 310, 3, 2, 2, 2, 312, 315, 3, 2, 2, 2, + 313, 311, 3, 2, 2, 2, 313, 314, 3, 2, 2, 2, 314, 316, 3, 2, 2, 2, 315, + 313, 3, 2, 2, 2, 316, 437, 7, 18, 2, 2, 317, 321, 7, 22, 2, 2, 318, 320, + 7, 4, 2, 2, 319, 318, 3, 2, 2, 2, 320, 323, 3, 2, 2, 2, 321, 319, 3, 2, + 2, 2, 321, 322, 3, 2, 2, 2, 322, 324, 3, 2, 2, 2, 323, 321, 3, 2, 2, 2, + 324, 328, 7, 12, 2, 2, 325, 327, 7, 4, 2, 2, 326, 325, 3, 2, 2, 2, 327, + 330, 3, 2, 2, 2, 328, 326, 3, 2, 2, 2, 328, 329, 3, 2, 2, 2, 329, 331, + 3, 2, 2, 2, 330, 328, 3, 2, 2, 2, 331, 437, 7, 20, 2, 2, 332, 336, 7, 22, + 2, 2, 333, 335, 7, 4, 2, 2, 334, 333, 3, 2, 2, 2, 335, 338, 3, 2, 2, 2, + 336, 334, 3, 2, 2, 2, 336, 337, 3, 2, 2, 2, 337, 339, 3, 2, 2, 2, 338, + 336, 3, 2, 2, 2, 339, 343, 7, 12, 2, 2, 340, 342, 7, 4, 2, 2, 341, 340, + 3, 2, 2, 2, 342, 345, 3, 2, 2, 2, 343, 341, 3, 2, 2, 2, 343, 344, 3, 2, + 2, 2, 344, 346, 3, 2, 2, 2, 345, 343, 3, 2, 2, 2, 346, 437, 7, 18, 2, 2, + 347, 351, 7, 22, 2, 2, 348, 350, 7, 4, 2, 2, 349, 348, 3, 2, 2, 2, 350, + 353, 3, 2, 2, 2, 351, 349, 3, 2, 2, 2, 351, 352, 3, 2, 2, 2, 352, 354, + 3, 2, 2, 2, 353, 351, 3, 2, 2, 2, 354, 358, 7, 13, 2, 2, 355, 357, 7, 4, + 2, 2, 356, 355, 3, 2, 2, 2, 357, 360, 3, 2, 2, 2, 358, 356, 3, 2, 2, 2, + 358, 359, 3, 2, 2, 2, 359, 361, 3, 2, 2, 2, 360, 358, 3, 2, 2, 2, 361, + 437, 7, 19, 2, 2, 362, 366, 7, 22, 2, 2, 363, 365, 7, 4, 2, 2, 364, 363, + 3, 2, 2, 2, 365, 368, 3, 2, 2, 2, 366, 364, 3, 2, 2, 2, 366, 367, 3, 2, + 2, 2, 367, 369, 3, 2, 2, 2, 368, 366, 3, 2, 2, 2, 369, 373, 7, 13, 2, 2, + 370, 372, 7, 4, 2, 2, 371, 370, 3, 2, 2, 2, 372, 375, 3, 2, 2, 2, 373, + 371, 3, 2, 2, 2, 373, 374, 3, 2, 2, 2, 374, 376, 3, 2, 2, 2, 375, 373, + 3, 2, 2, 2, 376, 437, 7, 20, 2, 2, 377, 381, 7, 22, 2, 2, 378, 380, 7, + 4, 2, 2, 379, 378, 3, 2, 2, 2, 380, 383, 3, 2, 2, 2, 381, 379, 3, 2, 2, + 2, 381, 382, 3, 2, 2, 2, 382, 384, 3, 2, 2, 2, 383, 381, 3, 2, 2, 2, 384, + 388, 7, 13, 2, 2, 385, 387, 7, 4, 2, 2, 386, 385, 3, 2, 2, 2, 387, 390, + 3, 2, 2, 2, 388, 386, 3, 2, 2, 2, 388, 389, 3, 2, 2, 2, 389, 391, 3, 2, + 2, 2, 390, 388, 3, 2, 2, 2, 391, 437, 7, 18, 2, 2, 392, 396, 7, 22, 2, + 2, 393, 395, 7, 4, 2, 2, 394, 393, 3, 2, 2, 2, 395, 398, 3, 2, 2, 2, 396, + 394, 3, 2, 2, 2, 396, 397, 3, 2, 2, 2, 397, 399, 3, 2, 2, 2, 398, 396, + 3, 2, 2, 2, 399, 403, 7, 13, 2, 2, 400, 402, 7, 4, 2, 2, 401, 400, 3, 2, + 2, 2, 402, 405, 3, 2, 2, 2, 403, 401, 3, 2, 2, 2, 403, 404, 3, 2, 2, 2, + 404, 406, 3, 2, 2, 2, 405, 403, 3, 2, 2, 2, 406, 437, 7, 17, 2, 2, 407, + 411, 7, 22, 2, 2, 408, 410, 7, 4, 2, 2, 409, 408, 3, 2, 2, 2, 410, 413, + 3, 2, 2, 2, 411, 409, 3, 2, 2, 2, 411, 412, 3, 2, 2, 2, 412, 414, 3, 2, + 2, 2, 413, 411, 3, 2, 2, 2, 414, 418, 7, 13, 2, 2, 415, 417, 7, 4, 2, 2, + 416, 415, 3, 2, 2, 2, 417, 420, 3, 2, 2, 2, 418, 416, 3, 2, 2, 2, 418, + 419, 3, 2, 2, 2, 419, 421, 3, 2, 2, 2, 420, 418, 3, 2, 2, 2, 421, 437, + 7, 21, 2, 2, 422, 426, 7, 22, 2, 2, 423, 425, 7, 4, 2, 2, 424, 423, 3, + 2, 2, 2, 425, 428, 3, 2, 2, 2, 426, 424, 3, 2, 2, 2, 426, 427, 3, 2, 2, + 2, 427, 429, 3, 2, 2, 2, 428, 426, 3, 2, 2, 2, 429, 431, 7, 14, 2, 2, 430, + 432, 7, 4, 2, 2, 431, 430, 3, 2, 2, 2, 432, 433, 3, 2, 2, 2, 433, 431, + 3, 2, 2, 2, 433, 434, 3, 2, 2, 2, 434, 435, 3, 2, 2, 2, 435, 437, 9, 2, + 2, 2, 436, 198, 3, 2, 2, 2, 436, 211, 3, 2, 2, 2, 436, 224, 3, 2, 2, 2, + 436, 237, 3, 2, 2, 2, 436, 262, 3, 2, 2, 2, 436, 287, 3, 2, 2, 2, 436, + 302, 3, 2, 2, 2, 436, 317, 3, 2, 2, 2, 436, 332, 3, 2, 2, 2, 436, 347, + 3, 2, 2, 2, 436, 362, 3, 2, 2, 2, 436, 377, 3, 2, 2, 2, 436, 392, 3, 2, + 2, 2, 436, 407, 3, 2, 2, 2, 436, 422, 3, 2, 2, 2, 437, 13, 3, 2, 2, 2, + 66, 18, 25, 32, 38, 44, 53, 60, 67, 73, 79, 88, 95, 102, 108, 114, 122, + 128, 134, 145, 152, 157, 163, 169, 174, 180, 186, 191, 193, 195, 202, 208, + 215, 221, 228, 234, 241, 247, 253, 259, 266, 272, 278, 284, 291, 298, 306, + 313, 321, 328, 336, 343, 351, 358, 366, 373, 381, 388, 396, 403, 411, 418, + 426, 433, 436, +} +var deserializer = antlr.NewATNDeserializer(nil) +var deserializedATN = deserializer.DeserializeFromUInt16(parserATN) + +var literalNames = []string{ + "", "','", "", "'('", "')'", "'['", "']'", +} +var symbolicNames = []string{ + "", "", "WS", "LPAREN", "RPAREN", "LBRACKET", "RBRACKET", "AND", "OR", + "LT", "GT", "EQ", "CONTAINS", "IN", "BETWEEN", "BOOL", "DATETIME", "STRING", + "NUMBER", "NULL", "IDENTIFIER", "RFC3339_DATE_TIME", +} + +var ruleNames = []string{ + "string_array", "number_array", "datetime_array", "start", "expression", + "operation", +} +var decisionToDFA = make([]*antlr.DFA, len(deserializedATN.DecisionToState)) + +func init() { + for index, ds := range deserializedATN.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(ds, index) + } +} + +type ZitiQlParser struct { + *antlr.BaseParser +} + +func NewZitiQlParser(input antlr.TokenStream) *ZitiQlParser { + this := new(ZitiQlParser) + + this.BaseParser = antlr.NewBaseParser(input) + + this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, antlr.NewPredictionContextCache()) + this.RuleNames = ruleNames + this.LiteralNames = literalNames + this.SymbolicNames = symbolicNames + this.GrammarFileName = "ZitiQl.g4" + + return this +} + +// ZitiQlParser tokens. +const ( + ZitiQlParserEOF = antlr.TokenEOF + ZitiQlParserT__0 = 1 + ZitiQlParserWS = 2 + ZitiQlParserLPAREN = 3 + ZitiQlParserRPAREN = 4 + ZitiQlParserLBRACKET = 5 + ZitiQlParserRBRACKET = 6 + ZitiQlParserAND = 7 + ZitiQlParserOR = 8 + ZitiQlParserLT = 9 + ZitiQlParserGT = 10 + ZitiQlParserEQ = 11 + ZitiQlParserCONTAINS = 12 + ZitiQlParserIN = 13 + ZitiQlParserBETWEEN = 14 + ZitiQlParserBOOL = 15 + ZitiQlParserDATETIME = 16 + ZitiQlParserSTRING = 17 + ZitiQlParserNUMBER = 18 + ZitiQlParserNULL = 19 + ZitiQlParserIDENTIFIER = 20 + ZitiQlParserRFC3339_DATE_TIME = 21 +) + +// ZitiQlParser rules. +const ( + ZitiQlParserRULE_string_array = 0 + ZitiQlParserRULE_number_array = 1 + ZitiQlParserRULE_datetime_array = 2 + ZitiQlParserRULE_start = 3 + ZitiQlParserRULE_expression = 4 + ZitiQlParserRULE_operation = 5 +) + +// IString_arrayContext is an interface to support dynamic dispatch. +type IString_arrayContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsString_arrayContext differentiates from other interfaces. + IsString_arrayContext() +} + +type String_arrayContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyString_arrayContext() *String_arrayContext { + var p = new(String_arrayContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ZitiQlParserRULE_string_array + return p +} + +func (*String_arrayContext) IsString_arrayContext() {} + +func NewString_arrayContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *String_arrayContext { + var p = new(String_arrayContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ZitiQlParserRULE_string_array + + return p +} + +func (s *String_arrayContext) GetParser() antlr.Parser { return s.parser } + +func (s *String_arrayContext) LBRACKET() antlr.TerminalNode { + return s.GetToken(ZitiQlParserLBRACKET, 0) +} + +func (s *String_arrayContext) AllSTRING() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserSTRING) +} + +func (s *String_arrayContext) STRING(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserSTRING, i) +} + +func (s *String_arrayContext) RBRACKET() antlr.TerminalNode { + return s.GetToken(ZitiQlParserRBRACKET, 0) +} + +func (s *String_arrayContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *String_arrayContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *String_arrayContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *String_arrayContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *String_arrayContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterString_array(s) + } +} + +func (s *String_arrayContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitString_array(s) + } +} + +func (p *ZitiQlParser) String_array() (localctx IString_arrayContext) { + localctx = NewString_arrayContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 0, ZitiQlParserRULE_string_array) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + var _alt int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(12) + p.Match(ZitiQlParserLBRACKET) + } + p.SetState(16) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(13) + p.Match(ZitiQlParserWS) + } + + p.SetState(18) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(19) + p.Match(ZitiQlParserSTRING) + } + p.SetState(36) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 3, p.GetParserRuleContext()) + + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + p.SetState(23) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(20) + p.Match(ZitiQlParserWS) + } + + p.SetState(25) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(26) + p.Match(ZitiQlParserT__0) + } + p.SetState(30) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(27) + p.Match(ZitiQlParserWS) + } + + p.SetState(32) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(33) + p.Match(ZitiQlParserSTRING) + } + + } + p.SetState(38) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 3, p.GetParserRuleContext()) + } + p.SetState(42) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(39) + p.Match(ZitiQlParserWS) + } + + p.SetState(44) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(45) + p.Match(ZitiQlParserRBRACKET) + } + + return localctx +} + +// INumber_arrayContext is an interface to support dynamic dispatch. +type INumber_arrayContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsNumber_arrayContext differentiates from other interfaces. + IsNumber_arrayContext() +} + +type Number_arrayContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyNumber_arrayContext() *Number_arrayContext { + var p = new(Number_arrayContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ZitiQlParserRULE_number_array + return p +} + +func (*Number_arrayContext) IsNumber_arrayContext() {} + +func NewNumber_arrayContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Number_arrayContext { + var p = new(Number_arrayContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ZitiQlParserRULE_number_array + + return p +} + +func (s *Number_arrayContext) GetParser() antlr.Parser { return s.parser } + +func (s *Number_arrayContext) LBRACKET() antlr.TerminalNode { + return s.GetToken(ZitiQlParserLBRACKET, 0) +} + +func (s *Number_arrayContext) AllNUMBER() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserNUMBER) +} + +func (s *Number_arrayContext) NUMBER(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserNUMBER, i) +} + +func (s *Number_arrayContext) RBRACKET() antlr.TerminalNode { + return s.GetToken(ZitiQlParserRBRACKET, 0) +} + +func (s *Number_arrayContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *Number_arrayContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *Number_arrayContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Number_arrayContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Number_arrayContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterNumber_array(s) + } +} + +func (s *Number_arrayContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitNumber_array(s) + } +} + +func (p *ZitiQlParser) Number_array() (localctx INumber_arrayContext) { + localctx = NewNumber_arrayContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 2, ZitiQlParserRULE_number_array) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + var _alt int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(47) + p.Match(ZitiQlParserLBRACKET) + } + p.SetState(51) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(48) + p.Match(ZitiQlParserWS) + } + + p.SetState(53) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(54) + p.Match(ZitiQlParserNUMBER) + } + p.SetState(71) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) + + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + p.SetState(58) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(55) + p.Match(ZitiQlParserWS) + } + + p.SetState(60) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(61) + p.Match(ZitiQlParserT__0) + } + p.SetState(65) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(62) + p.Match(ZitiQlParserWS) + } + + p.SetState(67) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(68) + p.Match(ZitiQlParserNUMBER) + } + + } + p.SetState(73) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) + } + p.SetState(77) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(74) + p.Match(ZitiQlParserWS) + } + + p.SetState(79) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(80) + p.Match(ZitiQlParserRBRACKET) + } + + return localctx +} + +// IDatetime_arrayContext is an interface to support dynamic dispatch. +type IDatetime_arrayContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsDatetime_arrayContext differentiates from other interfaces. + IsDatetime_arrayContext() +} + +type Datetime_arrayContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyDatetime_arrayContext() *Datetime_arrayContext { + var p = new(Datetime_arrayContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ZitiQlParserRULE_datetime_array + return p +} + +func (*Datetime_arrayContext) IsDatetime_arrayContext() {} + +func NewDatetime_arrayContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Datetime_arrayContext { + var p = new(Datetime_arrayContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ZitiQlParserRULE_datetime_array + + return p +} + +func (s *Datetime_arrayContext) GetParser() antlr.Parser { return s.parser } + +func (s *Datetime_arrayContext) LBRACKET() antlr.TerminalNode { + return s.GetToken(ZitiQlParserLBRACKET, 0) +} + +func (s *Datetime_arrayContext) AllDATETIME() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserDATETIME) +} + +func (s *Datetime_arrayContext) DATETIME(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserDATETIME, i) +} + +func (s *Datetime_arrayContext) RBRACKET() antlr.TerminalNode { + return s.GetToken(ZitiQlParserRBRACKET, 0) +} + +func (s *Datetime_arrayContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *Datetime_arrayContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *Datetime_arrayContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *Datetime_arrayContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *Datetime_arrayContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterDatetime_array(s) + } +} + +func (s *Datetime_arrayContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitDatetime_array(s) + } +} + +func (p *ZitiQlParser) Datetime_array() (localctx IDatetime_arrayContext) { + localctx = NewDatetime_arrayContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 4, ZitiQlParserRULE_datetime_array) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + var _alt int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(82) + p.Match(ZitiQlParserLBRACKET) + } + p.SetState(86) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(83) + p.Match(ZitiQlParserWS) + } + + p.SetState(88) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(89) + p.Match(ZitiQlParserDATETIME) + } + p.SetState(106) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext()) + + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + p.SetState(93) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(90) + p.Match(ZitiQlParserWS) + } + + p.SetState(95) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(96) + p.Match(ZitiQlParserT__0) + } + p.SetState(100) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(97) + p.Match(ZitiQlParserWS) + } + + p.SetState(102) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(103) + p.Match(ZitiQlParserDATETIME) + } + + } + p.SetState(108) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext()) + } + p.SetState(112) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(109) + p.Match(ZitiQlParserWS) + } + + p.SetState(114) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(115) + p.Match(ZitiQlParserRBRACKET) + } + + return localctx +} + +// IStartContext is an interface to support dynamic dispatch. +type IStartContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsStartContext differentiates from other interfaces. + IsStartContext() +} + +type StartContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyStartContext() *StartContext { + var p = new(StartContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ZitiQlParserRULE_start + return p +} + +func (*StartContext) IsStartContext() {} + +func NewStartContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *StartContext { + var p = new(StartContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ZitiQlParserRULE_start + + return p +} + +func (s *StartContext) GetParser() antlr.Parser { return s.parser } + +func (s *StartContext) CopyFrom(ctx *StartContext) { + s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) +} + +func (s *StartContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *StartContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +type EndContext struct { + *StartContext +} + +func NewEndContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *EndContext { + var p = new(EndContext) + + p.StartContext = NewEmptyStartContext() + p.parser = parser + p.CopyFrom(ctx.(*StartContext)) + + return p +} + +func (s *EndContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *EndContext) EOF() antlr.TerminalNode { + return s.GetToken(ZitiQlParserEOF, 0) +} + +func (s *EndContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *EndContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *EndContext) AllExpression() []IExpressionContext { + var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExpressionContext)(nil)).Elem()) + var tst = make([]IExpressionContext, len(ts)) + + for i, t := range ts { + if t != nil { + tst[i] = t.(IExpressionContext) + } + } + + return tst +} + +func (s *EndContext) Expression(i int) IExpressionContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IExpressionContext)(nil)).Elem(), i) + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *EndContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterEnd(s) + } +} + +func (s *EndContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitEnd(s) + } +} + +func (p *ZitiQlParser) Start() (localctx IStartContext) { + localctx = NewStartContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 6, ZitiQlParserRULE_start) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + var _alt int + + localctx = NewEndContext(p, localctx) + p.EnterOuterAlt(localctx, 1) + p.SetState(120) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 15, p.GetParserRuleContext()) + + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + { + p.SetState(117) + p.Match(ZitiQlParserWS) + } + + } + p.SetState(122) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 15, p.GetParserRuleContext()) + } + p.SetState(126) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserLPAREN || _la == ZitiQlParserIDENTIFIER { + { + p.SetState(123) + p.expression(0) + } + + p.SetState(128) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + p.SetState(132) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(129) + p.Match(ZitiQlParserWS) + } + + p.SetState(134) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(135) + p.Match(ZitiQlParserEOF) + } + + return localctx +} + +// IExpressionContext is an interface to support dynamic dispatch. +type IExpressionContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsExpressionContext differentiates from other interfaces. + IsExpressionContext() +} + +type ExpressionContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyExpressionContext() *ExpressionContext { + var p = new(ExpressionContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ZitiQlParserRULE_expression + return p +} + +func (*ExpressionContext) IsExpressionContext() {} + +func NewExpressionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExpressionContext { + var p = new(ExpressionContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ZitiQlParserRULE_expression + + return p +} + +func (s *ExpressionContext) GetParser() antlr.Parser { return s.parser } + +func (s *ExpressionContext) CopyFrom(ctx *ExpressionContext) { + s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) +} + +func (s *ExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ExpressionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +type GroupContext struct { + *ExpressionContext +} + +func NewGroupContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *GroupContext { + var p = new(GroupContext) + + p.ExpressionContext = NewEmptyExpressionContext() + p.parser = parser + p.CopyFrom(ctx.(*ExpressionContext)) + + return p +} + +func (s *GroupContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *GroupContext) LPAREN() antlr.TerminalNode { + return s.GetToken(ZitiQlParserLPAREN, 0) +} + +func (s *GroupContext) Expression() IExpressionContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IExpressionContext)(nil)).Elem(), 0) + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *GroupContext) RPAREN() antlr.TerminalNode { + return s.GetToken(ZitiQlParserRPAREN, 0) +} + +func (s *GroupContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *GroupContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *GroupContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterGroup(s) + } +} + +func (s *GroupContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitGroup(s) + } +} + +type OrConjunctionContext struct { + *ExpressionContext +} + +func NewOrConjunctionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *OrConjunctionContext { + var p = new(OrConjunctionContext) + + p.ExpressionContext = NewEmptyExpressionContext() + p.parser = parser + p.CopyFrom(ctx.(*ExpressionContext)) + + return p +} + +func (s *OrConjunctionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *OrConjunctionContext) AllExpression() []IExpressionContext { + var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExpressionContext)(nil)).Elem()) + var tst = make([]IExpressionContext, len(ts)) + + for i, t := range ts { + if t != nil { + tst[i] = t.(IExpressionContext) + } + } + + return tst +} + +func (s *OrConjunctionContext) Expression(i int) IExpressionContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IExpressionContext)(nil)).Elem(), i) + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *OrConjunctionContext) AllOR() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserOR) +} + +func (s *OrConjunctionContext) OR(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserOR, i) +} + +func (s *OrConjunctionContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *OrConjunctionContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *OrConjunctionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterOrConjunction(s) + } +} + +func (s *OrConjunctionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitOrConjunction(s) + } +} + +type OperationOpContext struct { + *ExpressionContext +} + +func NewOperationOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *OperationOpContext { + var p = new(OperationOpContext) + + p.ExpressionContext = NewEmptyExpressionContext() + p.parser = parser + p.CopyFrom(ctx.(*ExpressionContext)) + + return p +} + +func (s *OperationOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *OperationOpContext) Operation() IOperationContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IOperationContext)(nil)).Elem(), 0) + + if t == nil { + return nil + } + + return t.(IOperationContext) +} + +func (s *OperationOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterOperationOp(s) + } +} + +func (s *OperationOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitOperationOp(s) + } +} + +type AndConjunctionContext struct { + *ExpressionContext +} + +func NewAndConjunctionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *AndConjunctionContext { + var p = new(AndConjunctionContext) + + p.ExpressionContext = NewEmptyExpressionContext() + p.parser = parser + p.CopyFrom(ctx.(*ExpressionContext)) + + return p +} + +func (s *AndConjunctionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *AndConjunctionContext) AllExpression() []IExpressionContext { + var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IExpressionContext)(nil)).Elem()) + var tst = make([]IExpressionContext, len(ts)) + + for i, t := range ts { + if t != nil { + tst[i] = t.(IExpressionContext) + } + } + + return tst +} + +func (s *AndConjunctionContext) Expression(i int) IExpressionContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IExpressionContext)(nil)).Elem(), i) + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *AndConjunctionContext) AllAND() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserAND) +} + +func (s *AndConjunctionContext) AND(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserAND, i) +} + +func (s *AndConjunctionContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *AndConjunctionContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *AndConjunctionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterAndConjunction(s) + } +} + +func (s *AndConjunctionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitAndConjunction(s) + } +} + +func (p *ZitiQlParser) Expression() (localctx IExpressionContext) { + return p.expression(0) +} + +func (p *ZitiQlParser) expression(_p int) (localctx IExpressionContext) { + var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext() + _parentState := p.GetState() + localctx = NewExpressionContext(p, p.GetParserRuleContext(), _parentState) + var _prevctx IExpressionContext = localctx + var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. + _startState := 8 + p.EnterRecursionRule(localctx, 8, ZitiQlParserRULE_expression, _p) + var _la int + + defer func() { + p.UnrollRecursionContexts(_parentctx) + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + var _alt int + + p.EnterOuterAlt(localctx, 1) + p.SetState(155) + p.GetErrorHandler().Sync(p) + + switch p.GetTokenStream().LA(1) { + case ZitiQlParserIDENTIFIER: + localctx = NewOperationOpContext(p, localctx) + p.SetParserRuleContext(localctx) + _prevctx = localctx + + { + p.SetState(138) + p.Operation() + } + + case ZitiQlParserLPAREN: + localctx = NewGroupContext(p, localctx) + p.SetParserRuleContext(localctx) + _prevctx = localctx + { + p.SetState(139) + p.Match(ZitiQlParserLPAREN) + } + p.SetState(143) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(140) + p.Match(ZitiQlParserWS) + } + + p.SetState(145) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(146) + p.expression(0) + } + p.SetState(150) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(147) + p.Match(ZitiQlParserWS) + } + + p.SetState(152) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(153) + p.Match(ZitiQlParserRPAREN) + } + + default: + panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + } + p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) + p.SetState(193) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 28, p.GetParserRuleContext()) + + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + if p.GetParseListeners() != nil { + p.TriggerExitRuleEvent() + } + _prevctx = localctx + p.SetState(191) + p.GetErrorHandler().Sync(p) + switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 27, p.GetParserRuleContext()) { + case 1: + localctx = NewAndConjunctionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, ZitiQlParserRULE_expression) + p.SetState(157) + + if !(p.Precpred(p.GetParserRuleContext(), 2)) { + panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 2)", "")) + } + p.SetState(170) + p.GetErrorHandler().Sync(p) + _alt = 1 + for ok := true; ok; ok = _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + switch _alt { + case 1: + p.SetState(159) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(158) + p.Match(ZitiQlParserWS) + } + + p.SetState(161) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(163) + p.Match(ZitiQlParserAND) + } + p.SetState(165) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(164) + p.Match(ZitiQlParserWS) + } + + p.SetState(167) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(169) + p.expression(0) + } + + default: + panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + } + + p.SetState(172) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 23, p.GetParserRuleContext()) + } + + case 2: + localctx = NewOrConjunctionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, ZitiQlParserRULE_expression) + p.SetState(174) + + if !(p.Precpred(p.GetParserRuleContext(), 1)) { + panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 1)", "")) + } + p.SetState(187) + p.GetErrorHandler().Sync(p) + _alt = 1 + for ok := true; ok; ok = _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + switch _alt { + case 1: + p.SetState(176) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(175) + p.Match(ZitiQlParserWS) + } + + p.SetState(178) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(180) + p.Match(ZitiQlParserOR) + } + p.SetState(182) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(181) + p.Match(ZitiQlParserWS) + } + + p.SetState(184) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(186) + p.expression(0) + } + + default: + panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + } + + p.SetState(189) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 26, p.GetParserRuleContext()) + } + + } + + } + p.SetState(195) + p.GetErrorHandler().Sync(p) + _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 28, p.GetParserRuleContext()) + } + + return localctx +} + +// IOperationContext is an interface to support dynamic dispatch. +type IOperationContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // IsOperationContext differentiates from other interfaces. + IsOperationContext() +} + +type OperationContext struct { + *antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyOperationContext() *OperationContext { + var p = new(OperationContext) + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + p.RuleIndex = ZitiQlParserRULE_operation + return p +} + +func (*OperationContext) IsOperationContext() {} + +func NewOperationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *OperationContext { + var p = new(OperationContext) + + p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + + p.parser = parser + p.RuleIndex = ZitiQlParserRULE_operation + + return p +} + +func (s *OperationContext) GetParser() antlr.Parser { return s.parser } + +func (s *OperationContext) CopyFrom(ctx *OperationContext) { + s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) +} + +func (s *OperationContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *OperationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +type BinaryEqualToNullOpContext struct { + *OperationContext +} + +func NewBinaryEqualToNullOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToNullOpContext { + var p = new(BinaryEqualToNullOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryEqualToNullOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryEqualToNullOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryEqualToNullOpContext) EQ() antlr.TerminalNode { + return s.GetToken(ZitiQlParserEQ, 0) +} + +func (s *BinaryEqualToNullOpContext) NULL() antlr.TerminalNode { + return s.GetToken(ZitiQlParserNULL, 0) +} + +func (s *BinaryEqualToNullOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryEqualToNullOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryEqualToNullOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryEqualToNullOp(s) + } +} + +func (s *BinaryEqualToNullOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryEqualToNullOp(s) + } +} + +type BinaryLessThanNumberOpContext struct { + *OperationContext +} + +func NewBinaryLessThanNumberOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryLessThanNumberOpContext { + var p = new(BinaryLessThanNumberOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryLessThanNumberOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryLessThanNumberOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryLessThanNumberOpContext) LT() antlr.TerminalNode { + return s.GetToken(ZitiQlParserLT, 0) +} + +func (s *BinaryLessThanNumberOpContext) NUMBER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserNUMBER, 0) +} + +func (s *BinaryLessThanNumberOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryLessThanNumberOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryLessThanNumberOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryLessThanNumberOp(s) + } +} + +func (s *BinaryLessThanNumberOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryLessThanNumberOp(s) + } +} + +type BinaryGreaterThanDatetimeOpContext struct { + *OperationContext +} + +func NewBinaryGreaterThanDatetimeOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryGreaterThanDatetimeOpContext { + var p = new(BinaryGreaterThanDatetimeOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryGreaterThanDatetimeOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryGreaterThanDatetimeOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryGreaterThanDatetimeOpContext) GT() antlr.TerminalNode { + return s.GetToken(ZitiQlParserGT, 0) +} + +func (s *BinaryGreaterThanDatetimeOpContext) DATETIME() antlr.TerminalNode { + return s.GetToken(ZitiQlParserDATETIME, 0) +} + +func (s *BinaryGreaterThanDatetimeOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryGreaterThanDatetimeOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryGreaterThanDatetimeOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryGreaterThanDatetimeOp(s) + } +} + +func (s *BinaryGreaterThanDatetimeOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryGreaterThanDatetimeOp(s) + } +} + +type InNumberArrayOpContext struct { + *OperationContext +} + +func NewInNumberArrayOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InNumberArrayOpContext { + var p = new(InNumberArrayOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *InNumberArrayOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *InNumberArrayOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *InNumberArrayOpContext) IN() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIN, 0) +} + +func (s *InNumberArrayOpContext) Number_array() INumber_arrayContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*INumber_arrayContext)(nil)).Elem(), 0) + + if t == nil { + return nil + } + + return t.(INumber_arrayContext) +} + +func (s *InNumberArrayOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *InNumberArrayOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *InNumberArrayOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterInNumberArrayOp(s) + } +} + +func (s *InNumberArrayOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitInNumberArrayOp(s) + } +} + +type InStringArrayOpContext struct { + *OperationContext +} + +func NewInStringArrayOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InStringArrayOpContext { + var p = new(InStringArrayOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *InStringArrayOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *InStringArrayOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *InStringArrayOpContext) IN() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIN, 0) +} + +func (s *InStringArrayOpContext) String_array() IString_arrayContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IString_arrayContext)(nil)).Elem(), 0) + + if t == nil { + return nil + } + + return t.(IString_arrayContext) +} + +func (s *InStringArrayOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *InStringArrayOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *InStringArrayOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterInStringArrayOp(s) + } +} + +func (s *InStringArrayOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitInStringArrayOp(s) + } +} + +type BinaryLessThanDatetimeOpContext struct { + *OperationContext +} + +func NewBinaryLessThanDatetimeOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryLessThanDatetimeOpContext { + var p = new(BinaryLessThanDatetimeOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryLessThanDatetimeOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryLessThanDatetimeOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryLessThanDatetimeOpContext) LT() antlr.TerminalNode { + return s.GetToken(ZitiQlParserLT, 0) +} + +func (s *BinaryLessThanDatetimeOpContext) DATETIME() antlr.TerminalNode { + return s.GetToken(ZitiQlParserDATETIME, 0) +} + +func (s *BinaryLessThanDatetimeOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryLessThanDatetimeOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryLessThanDatetimeOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryLessThanDatetimeOp(s) + } +} + +func (s *BinaryLessThanDatetimeOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryLessThanDatetimeOp(s) + } +} + +type BinaryGreaterThanNumberOpContext struct { + *OperationContext +} + +func NewBinaryGreaterThanNumberOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryGreaterThanNumberOpContext { + var p = new(BinaryGreaterThanNumberOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryGreaterThanNumberOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryGreaterThanNumberOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryGreaterThanNumberOpContext) GT() antlr.TerminalNode { + return s.GetToken(ZitiQlParserGT, 0) +} + +func (s *BinaryGreaterThanNumberOpContext) NUMBER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserNUMBER, 0) +} + +func (s *BinaryGreaterThanNumberOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryGreaterThanNumberOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryGreaterThanNumberOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryGreaterThanNumberOp(s) + } +} + +func (s *BinaryGreaterThanNumberOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryGreaterThanNumberOp(s) + } +} + +type InDatetimeArrayOpContext struct { + *OperationContext +} + +func NewInDatetimeArrayOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InDatetimeArrayOpContext { + var p = new(InDatetimeArrayOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *InDatetimeArrayOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *InDatetimeArrayOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *InDatetimeArrayOpContext) IN() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIN, 0) +} + +func (s *InDatetimeArrayOpContext) Datetime_array() IDatetime_arrayContext { + var t = s.GetTypedRuleContext(reflect.TypeOf((*IDatetime_arrayContext)(nil)).Elem(), 0) + + if t == nil { + return nil + } + + return t.(IDatetime_arrayContext) +} + +func (s *InDatetimeArrayOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *InDatetimeArrayOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *InDatetimeArrayOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterInDatetimeArrayOp(s) + } +} + +func (s *InDatetimeArrayOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitInDatetimeArrayOp(s) + } +} + +type BetweenDateOpContext struct { + *OperationContext +} + +func NewBetweenDateOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BetweenDateOpContext { + var p = new(BetweenDateOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BetweenDateOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BetweenDateOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BetweenDateOpContext) BETWEEN() antlr.TerminalNode { + return s.GetToken(ZitiQlParserBETWEEN, 0) +} + +func (s *BetweenDateOpContext) AllDATETIME() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserDATETIME) +} + +func (s *BetweenDateOpContext) DATETIME(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserDATETIME, i) +} + +func (s *BetweenDateOpContext) AND() antlr.TerminalNode { + return s.GetToken(ZitiQlParserAND, 0) +} + +func (s *BetweenDateOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BetweenDateOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BetweenDateOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBetweenDateOp(s) + } +} + +func (s *BetweenDateOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBetweenDateOp(s) + } +} + +type BinaryEqualToNumberOpContext struct { + *OperationContext +} + +func NewBinaryEqualToNumberOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToNumberOpContext { + var p = new(BinaryEqualToNumberOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryEqualToNumberOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryEqualToNumberOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryEqualToNumberOpContext) EQ() antlr.TerminalNode { + return s.GetToken(ZitiQlParserEQ, 0) +} + +func (s *BinaryEqualToNumberOpContext) NUMBER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserNUMBER, 0) +} + +func (s *BinaryEqualToNumberOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryEqualToNumberOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryEqualToNumberOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryEqualToNumberOp(s) + } +} + +func (s *BinaryEqualToNumberOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryEqualToNumberOp(s) + } +} + +type BinaryEqualToBoolOpContext struct { + *OperationContext +} + +func NewBinaryEqualToBoolOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToBoolOpContext { + var p = new(BinaryEqualToBoolOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryEqualToBoolOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryEqualToBoolOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryEqualToBoolOpContext) EQ() antlr.TerminalNode { + return s.GetToken(ZitiQlParserEQ, 0) +} + +func (s *BinaryEqualToBoolOpContext) BOOL() antlr.TerminalNode { + return s.GetToken(ZitiQlParserBOOL, 0) +} + +func (s *BinaryEqualToBoolOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryEqualToBoolOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryEqualToBoolOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryEqualToBoolOp(s) + } +} + +func (s *BinaryEqualToBoolOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryEqualToBoolOp(s) + } +} + +type BinaryEqualToStringOpContext struct { + *OperationContext +} + +func NewBinaryEqualToStringOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToStringOpContext { + var p = new(BinaryEqualToStringOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryEqualToStringOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryEqualToStringOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryEqualToStringOpContext) EQ() antlr.TerminalNode { + return s.GetToken(ZitiQlParserEQ, 0) +} + +func (s *BinaryEqualToStringOpContext) STRING() antlr.TerminalNode { + return s.GetToken(ZitiQlParserSTRING, 0) +} + +func (s *BinaryEqualToStringOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryEqualToStringOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryEqualToStringOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryEqualToStringOp(s) + } +} + +func (s *BinaryEqualToStringOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryEqualToStringOp(s) + } +} + +type BetweenNumberOpContext struct { + *OperationContext +} + +func NewBetweenNumberOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BetweenNumberOpContext { + var p = new(BetweenNumberOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BetweenNumberOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BetweenNumberOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BetweenNumberOpContext) BETWEEN() antlr.TerminalNode { + return s.GetToken(ZitiQlParserBETWEEN, 0) +} + +func (s *BetweenNumberOpContext) AllNUMBER() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserNUMBER) +} + +func (s *BetweenNumberOpContext) NUMBER(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserNUMBER, i) +} + +func (s *BetweenNumberOpContext) AND() antlr.TerminalNode { + return s.GetToken(ZitiQlParserAND, 0) +} + +func (s *BetweenNumberOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BetweenNumberOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BetweenNumberOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBetweenNumberOp(s) + } +} + +func (s *BetweenNumberOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBetweenNumberOp(s) + } +} + +type BinaryContainsOpContext struct { + *OperationContext +} + +func NewBinaryContainsOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryContainsOpContext { + var p = new(BinaryContainsOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryContainsOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryContainsOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryContainsOpContext) CONTAINS() antlr.TerminalNode { + return s.GetToken(ZitiQlParserCONTAINS, 0) +} + +func (s *BinaryContainsOpContext) STRING() antlr.TerminalNode { + return s.GetToken(ZitiQlParserSTRING, 0) +} + +func (s *BinaryContainsOpContext) NUMBER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserNUMBER, 0) +} + +func (s *BinaryContainsOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryContainsOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryContainsOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryContainsOp(s) + } +} + +func (s *BinaryContainsOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryContainsOp(s) + } +} + +type BinaryEqualToDatetimeOpContext struct { + *OperationContext +} + +func NewBinaryEqualToDatetimeOpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BinaryEqualToDatetimeOpContext { + var p = new(BinaryEqualToDatetimeOpContext) + + p.OperationContext = NewEmptyOperationContext() + p.parser = parser + p.CopyFrom(ctx.(*OperationContext)) + + return p +} + +func (s *BinaryEqualToDatetimeOpContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BinaryEqualToDatetimeOpContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(ZitiQlParserIDENTIFIER, 0) +} + +func (s *BinaryEqualToDatetimeOpContext) EQ() antlr.TerminalNode { + return s.GetToken(ZitiQlParserEQ, 0) +} + +func (s *BinaryEqualToDatetimeOpContext) DATETIME() antlr.TerminalNode { + return s.GetToken(ZitiQlParserDATETIME, 0) +} + +func (s *BinaryEqualToDatetimeOpContext) AllWS() []antlr.TerminalNode { + return s.GetTokens(ZitiQlParserWS) +} + +func (s *BinaryEqualToDatetimeOpContext) WS(i int) antlr.TerminalNode { + return s.GetToken(ZitiQlParserWS, i) +} + +func (s *BinaryEqualToDatetimeOpContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.EnterBinaryEqualToDatetimeOp(s) + } +} + +func (s *BinaryEqualToDatetimeOpContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(ZitiQlListener); ok { + listenerT.ExitBinaryEqualToDatetimeOp(s) + } +} + +func (p *ZitiQlParser) Operation() (localctx IOperationContext) { + localctx = NewOperationContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 10, ZitiQlParserRULE_operation) + var _la int + + defer func() { + p.ExitRule() + }() + + defer func() { + if err := recover(); err != nil { + if v, ok := err.(antlr.RecognitionException); ok { + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + } else { + panic(err) + } + } + }() + + p.SetState(434) + p.GetErrorHandler().Sync(p) + switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 63, p.GetParserRuleContext()) { + case 1: + localctx = NewInStringArrayOpContext(p, localctx) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(196) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(198) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(197) + p.Match(ZitiQlParserWS) + } + + p.SetState(200) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(202) + p.Match(ZitiQlParserIN) + } + p.SetState(204) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(203) + p.Match(ZitiQlParserWS) + } + + p.SetState(206) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(208) + p.String_array() + } + + case 2: + localctx = NewInNumberArrayOpContext(p, localctx) + p.EnterOuterAlt(localctx, 2) + { + p.SetState(209) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(211) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(210) + p.Match(ZitiQlParserWS) + } + + p.SetState(213) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(215) + p.Match(ZitiQlParserIN) + } + p.SetState(217) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(216) + p.Match(ZitiQlParserWS) + } + + p.SetState(219) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(221) + p.Number_array() + } + + case 3: + localctx = NewInDatetimeArrayOpContext(p, localctx) + p.EnterOuterAlt(localctx, 3) + { + p.SetState(222) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(224) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(223) + p.Match(ZitiQlParserWS) + } + + p.SetState(226) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(228) + p.Match(ZitiQlParserIN) + } + p.SetState(230) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(229) + p.Match(ZitiQlParserWS) + } + + p.SetState(232) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(234) + p.Datetime_array() + } + + case 4: + localctx = NewBetweenNumberOpContext(p, localctx) + p.EnterOuterAlt(localctx, 4) + { + p.SetState(235) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(237) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(236) + p.Match(ZitiQlParserWS) + } + + p.SetState(239) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(241) + p.Match(ZitiQlParserBETWEEN) + } + p.SetState(243) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(242) + p.Match(ZitiQlParserWS) + } + + p.SetState(245) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(247) + p.Match(ZitiQlParserNUMBER) + } + p.SetState(249) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(248) + p.Match(ZitiQlParserWS) + } + + p.SetState(251) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(253) + p.Match(ZitiQlParserAND) + } + p.SetState(255) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(254) + p.Match(ZitiQlParserWS) + } + + p.SetState(257) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(259) + p.Match(ZitiQlParserNUMBER) + } + + case 5: + localctx = NewBetweenDateOpContext(p, localctx) + p.EnterOuterAlt(localctx, 5) + { + p.SetState(260) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(262) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(261) + p.Match(ZitiQlParserWS) + } + + p.SetState(264) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(266) + p.Match(ZitiQlParserBETWEEN) + } + p.SetState(268) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(267) + p.Match(ZitiQlParserWS) + } + + p.SetState(270) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(272) + p.Match(ZitiQlParserDATETIME) + } + p.SetState(274) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(273) + p.Match(ZitiQlParserWS) + } + + p.SetState(276) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(278) + p.Match(ZitiQlParserAND) + } + p.SetState(280) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(279) + p.Match(ZitiQlParserWS) + } + + p.SetState(282) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(284) + p.Match(ZitiQlParserDATETIME) + } + + case 6: + localctx = NewBinaryLessThanNumberOpContext(p, localctx) + p.EnterOuterAlt(localctx, 6) + { + p.SetState(285) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(289) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(286) + p.Match(ZitiQlParserWS) + } + + p.SetState(291) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(292) + p.Match(ZitiQlParserLT) + } + p.SetState(296) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(293) + p.Match(ZitiQlParserWS) + } + + p.SetState(298) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(299) + p.Match(ZitiQlParserNUMBER) + } + + case 7: + localctx = NewBinaryLessThanDatetimeOpContext(p, localctx) + p.EnterOuterAlt(localctx, 7) + { + p.SetState(300) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(304) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(301) + p.Match(ZitiQlParserWS) + } + + p.SetState(306) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(307) + p.Match(ZitiQlParserLT) + } + p.SetState(311) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(308) + p.Match(ZitiQlParserWS) + } + + p.SetState(313) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(314) + p.Match(ZitiQlParserDATETIME) + } + + case 8: + localctx = NewBinaryGreaterThanNumberOpContext(p, localctx) + p.EnterOuterAlt(localctx, 8) + { + p.SetState(315) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(319) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(316) + p.Match(ZitiQlParserWS) + } + + p.SetState(321) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(322) + p.Match(ZitiQlParserGT) + } + p.SetState(326) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(323) + p.Match(ZitiQlParserWS) + } + + p.SetState(328) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(329) + p.Match(ZitiQlParserNUMBER) + } + + case 9: + localctx = NewBinaryGreaterThanDatetimeOpContext(p, localctx) + p.EnterOuterAlt(localctx, 9) + { + p.SetState(330) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(334) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(331) + p.Match(ZitiQlParserWS) + } + + p.SetState(336) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(337) + p.Match(ZitiQlParserGT) + } + p.SetState(341) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(338) + p.Match(ZitiQlParserWS) + } + + p.SetState(343) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(344) + p.Match(ZitiQlParserDATETIME) + } + + case 10: + localctx = NewBinaryEqualToStringOpContext(p, localctx) + p.EnterOuterAlt(localctx, 10) + { + p.SetState(345) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(349) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(346) + p.Match(ZitiQlParserWS) + } + + p.SetState(351) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(352) + p.Match(ZitiQlParserEQ) + } + p.SetState(356) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(353) + p.Match(ZitiQlParserWS) + } + + p.SetState(358) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(359) + p.Match(ZitiQlParserSTRING) + } + + case 11: + localctx = NewBinaryEqualToNumberOpContext(p, localctx) + p.EnterOuterAlt(localctx, 11) + { + p.SetState(360) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(364) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(361) + p.Match(ZitiQlParserWS) + } + + p.SetState(366) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(367) + p.Match(ZitiQlParserEQ) + } + p.SetState(371) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(368) + p.Match(ZitiQlParserWS) + } + + p.SetState(373) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(374) + p.Match(ZitiQlParserNUMBER) + } + + case 12: + localctx = NewBinaryEqualToDatetimeOpContext(p, localctx) + p.EnterOuterAlt(localctx, 12) + { + p.SetState(375) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(379) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(376) + p.Match(ZitiQlParserWS) + } + + p.SetState(381) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(382) + p.Match(ZitiQlParserEQ) + } + p.SetState(386) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(383) + p.Match(ZitiQlParserWS) + } + + p.SetState(388) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(389) + p.Match(ZitiQlParserDATETIME) + } + + case 13: + localctx = NewBinaryEqualToBoolOpContext(p, localctx) + p.EnterOuterAlt(localctx, 13) + { + p.SetState(390) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(394) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(391) + p.Match(ZitiQlParserWS) + } + + p.SetState(396) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(397) + p.Match(ZitiQlParserEQ) + } + p.SetState(401) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(398) + p.Match(ZitiQlParserWS) + } + + p.SetState(403) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(404) + p.Match(ZitiQlParserBOOL) + } + + case 14: + localctx = NewBinaryEqualToNullOpContext(p, localctx) + p.EnterOuterAlt(localctx, 14) + { + p.SetState(405) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(409) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(406) + p.Match(ZitiQlParserWS) + } + + p.SetState(411) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(412) + p.Match(ZitiQlParserEQ) + } + p.SetState(416) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(413) + p.Match(ZitiQlParserWS) + } + + p.SetState(418) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(419) + p.Match(ZitiQlParserNULL) + } + + case 15: + localctx = NewBinaryContainsOpContext(p, localctx) + p.EnterOuterAlt(localctx, 15) + { + p.SetState(420) + p.Match(ZitiQlParserIDENTIFIER) + } + p.SetState(424) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for _la == ZitiQlParserWS { + { + p.SetState(421) + p.Match(ZitiQlParserWS) + } + + p.SetState(426) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(427) + p.Match(ZitiQlParserCONTAINS) + } + p.SetState(429) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + + for ok := true; ok; ok = _la == ZitiQlParserWS { + { + p.SetState(428) + p.Match(ZitiQlParserWS) + } + + p.SetState(431) + p.GetErrorHandler().Sync(p) + _la = p.GetTokenStream().LA(1) + } + { + p.SetState(433) + _la = p.GetTokenStream().LA(1) + + if !(_la == ZitiQlParserSTRING || _la == ZitiQlParserNUMBER) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + + } + + return localctx +} + +func (p *ZitiQlParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool { + switch ruleIndex { + case 4: + var t *ExpressionContext = nil + if localctx != nil { + t = localctx.(*ExpressionContext) + } + return p.Expression_Sempred(t, predIndex) + + default: + panic("No predicate with index: " + fmt.Sprint(ruleIndex)) + } +} + +func (p *ZitiQlParser) Expression_Sempred(localctx antlr.RuleContext, predIndex int) bool { + switch predIndex { + case 0: + return p.Precpred(p.GetParserRuleContext(), 2) + + case 1: + return p.Precpred(p.GetParserRuleContext(), 1) + + default: + panic("No predicate with index: " + fmt.Sprint(predIndex)) + } +} diff --git a/crypto/hash.go b/crypto/hash.go index 128985751..41119b8fe 100644 --- a/crypto/hash.go +++ b/crypto/hash.go @@ -1,52 +1,52 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package crypto - -import ( - "encoding/binary" - "golang.org/x/crypto/argon2" - "math/rand" - "time" -) - -type HashResult struct { - Hash []byte - Salt []byte -} - -func salt() []byte { - buf := make([]byte, binary.MaxVarintLen64) - src := rand.NewSource(time.Now().UnixNano()) - rnd := rand.New(src) - n := binary.PutVarint(buf, rnd.Int63()) - b := buf[:n] - return b -} - -func Hash(password string) *HashResult { - s := salt() - return ReHash(password, s) -} - -func ReHash(password string, s []byte) *HashResult { - h := argon2.IDKey([]byte(password), s, 1, 3*1024, 4, 32) - - return &HashResult{ - Hash: h, - Salt: s, - } -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package crypto + +import ( + "encoding/binary" + "golang.org/x/crypto/argon2" + "math/rand" + "time" +) + +type HashResult struct { + Hash []byte + Salt []byte +} + +func salt() []byte { + buf := make([]byte, binary.MaxVarintLen64) + src := rand.NewSource(time.Now().UnixNano()) + rnd := rand.New(src) + n := binary.PutVarint(buf, rnd.Int63()) + b := buf[:n] + return b +} + +func Hash(password string) *HashResult { + s := salt() + return ReHash(password, s) +} + +func ReHash(password string, s []byte) *HashResult { + h := argon2.IDKey([]byte(password), s, 1, 3*1024, 4, 32) + + return &HashResult{ + Hash: h, + Salt: s, + } +} diff --git a/gateway/internal/gateway/types.go b/gateway/internal/gateway/types.go index 1b5a9636f..f128832fe 100644 --- a/gateway/internal/gateway/types.go +++ b/gateway/internal/gateway/types.go @@ -1,37 +1,39 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package gateway - -import ( - "net" - "net/url" - "time" -) - -type Memory struct { - Path string `yaml:"path"` - Interval time.Duration `yaml:"intervalMs"` -} - -type Sans struct { - DnsAddresses []string `yaml:"dns" mapstructure:"dns"` - IpAddresses []string `yaml:"ip" mapstructure:"ip"` - IpAddressesParsed []net.IP - EmailAddresses []string `yaml:"email" mapstructure:"email"` - UriAddresses []string `yaml:"uri" mapstructure:"uri"` - UriAddressesParsed []*url.URL -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package gateway + +import ( + "net" + "net/url" + "time" +) + +type Memory struct { + Path string `yaml:"path"` + Interval time.Duration `yaml:"intervalMs"` +} + +type Sans struct { + DnsAddresses []string `yaml:"dns" mapstructure:"dns"` + IpAddresses []string `yaml:"ip" mapstructure:"ip"` + IpAddressesParsed []net.IP + EmailAddresses []string `yaml:"email" mapstructure:"email"` + UriAddresses []string `yaml:"uri" mapstructure:"uri"` + UriAddressesParsed []*url.URL +} + + diff --git a/gateway/xgress_edge/dialer.go b/gateway/xgress_edge/dialer.go index f8ba6bd68..6319dcb3a 100644 --- a/gateway/xgress_edge/dialer.go +++ b/gateway/xgress_edge/dialer.go @@ -1,85 +1,85 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package xgress_edge - -import ( - "fmt" - "github.com/michaelquigley/pfxlog" - "github.com/netfoundry/ziti-fabric/xgress" - "github.com/netfoundry/ziti-foundation/identity/identity" - "github.com/netfoundry/ziti-sdk-golang/ziti/edge" - "strings" - "time" -) - -type dialer struct { - factory *Factory - options *Options -} - -func newDialer(factory *Factory, options *Options) xgress.XgressDialer { - txd := &dialer{ - factory: factory, - options: options, - } - return txd -} - -func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler) error { - log := pfxlog.Logger().WithField("sessionId", sessionId.Token) - destParts := strings.Split(destination, ":") - if len(destParts) != 2 { - return fmt.Errorf("destination '%v' format is incorrect", destination) - } - - if destParts[0] != "hosted" { - return fmt.Errorf("unsupported destination type: '%v'", destParts[0]) - } - - token := destParts[1] - - log.Debug("looking up hosted service conn") - listenConn, found := dialer.factory.hostedServices.Get(token) - if !found { - return fmt.Errorf("host for token '%v' not found", token) - } - - log.Debug("dialing sdk client hosting service") - dialRequest := edge.NewDialMsg(listenConn.Id(), token) - reply, err := listenConn.SendAndWaitWithTimeout(dialRequest, 5*time.Second) - if err != nil { - return err - } - result, err := edge.UnmarshalDialResult(reply) - - if err != nil { - return err - } - - if !result.Success { - return fmt.Errorf("failed to establish connection with token %v. error: (%v)", token, result.Message) - } - - conn := listenConn.newSink(result.NewConnId, dialer.options) - - x := xgress.NewXgress(sessionId, address, conn, xgress.Terminator, &dialer.options.Options) - bindHandler.HandleXgressBind(sessionId, address, xgress.Terminator, x) - - start := edge.NewStateConnectedMsg(result.ConnId) - start.ReplyTo(reply) - return listenConn.SendState(start) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package xgress_edge + +import ( + "fmt" + "github.com/michaelquigley/pfxlog" + "github.com/netfoundry/ziti-fabric/xgress" + "github.com/netfoundry/ziti-foundation/identity/identity" + "github.com/netfoundry/ziti-sdk-golang/ziti/edge" + "strings" + "time" +) + +type dialer struct { + factory *Factory + options *Options +} + +func newDialer(factory *Factory, options *Options) xgress.XgressDialer { + txd := &dialer{ + factory: factory, + options: options, + } + return txd +} + +func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, address xgress.Address, bindHandler xgress.BindHandler) error { + log := pfxlog.Logger().WithField("sessionId", sessionId.Token) + destParts := strings.Split(destination, ":") + if len(destParts) != 2 { + return fmt.Errorf("destination '%v' format is incorrect", destination) + } + + if destParts[0] != "hosted" { + return fmt.Errorf("unsupported destination type: '%v'", destParts[0]) + } + + token := destParts[1] + + log.Debug("looking up hosted service conn") + listenConn, found := dialer.factory.hostedServices.Get(token) + if !found { + return fmt.Errorf("host for token '%v' not found", token) + } + + log.Debug("dialing sdk client hosting service") + dialRequest := edge.NewDialMsg(listenConn.Id(), token) + reply, err := listenConn.SendAndWaitWithTimeout(dialRequest, 5*time.Second) + if err != nil { + return err + } + result, err := edge.UnmarshalDialResult(reply) + + if err != nil { + return err + } + + if !result.Success { + return fmt.Errorf("failed to establish connection with token %v. error: (%v)", token, result.Message) + } + + conn := listenConn.newSink(result.NewConnId, dialer.options) + + x := xgress.NewXgress(sessionId, address, conn, xgress.Terminator, &dialer.options.Options) + bindHandler.HandleXgressBind(sessionId, address, xgress.Terminator, x) + + start := edge.NewStateConnectedMsg(result.ConnId) + start.ReplyTo(reply) + return listenConn.SendState(start) +} diff --git a/gateway/xgress_edge/fabric.go b/gateway/xgress_edge/fabric.go index c55ef27a2..8776f2a7c 100644 --- a/gateway/xgress_edge/fabric.go +++ b/gateway/xgress_edge/fabric.go @@ -1,143 +1,143 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package xgress_edge - -import ( - "github.com/michaelquigley/pfxlog" - "github.com/netfoundry/ziti-fabric/xgress" - "github.com/netfoundry/ziti-foundation/channel2" - "github.com/netfoundry/ziti-foundation/util/concurrenz" - "github.com/netfoundry/ziti-foundation/util/sequencer" - "github.com/netfoundry/ziti-sdk-golang/ziti/edge" - "io" -) - -type localMessageSink struct { - edge.MsgChannel - seq sequencer.Sequencer - closeCB func(connId uint32) - newSinkCB func(sink *localMessageSink) - closed concurrenz.AtomicBoolean -} - -type localListener struct { - localMessageSink - token string - service string - parent *ingressProxy -} - -func (conn *localMessageSink) newSink(connId uint32, options *Options) *localMessageSink { - result := &localMessageSink{ - MsgChannel: *edge.NewEdgeMsgChannel(conn.Channel, connId), - seq: sequencer.NewSingleWriterSeq(options.MaxOutOfOrderMsgs), - closeCB: conn.closeCB, - newSinkCB: conn.newSinkCB, - } - - // TODO: Evaluate best way to get new conn in map. Split dial? Any way to use regular map? - if conn.newSinkCB != nil { - conn.newSinkCB(result) - } - return result -} - -func (conn *localMessageSink) LogContext() string { - return conn.Channel.Label() -} - -func (conn *localMessageSink) ReadPayload() ([]byte, map[uint8][]byte, error) { - log := pfxlog.ContextLogger(conn.Channel.Label()).WithField("connId", conn.Id()) - - for { - next := conn.seq.GetNext() - if next == nil { - log.Debug("sequencer closed, return EOF") - conn.closeCB(conn.Id()) - return nil, nil, io.EOF // io.EOF signals xgress to shutdown - } - - em := next.(*edge.MsgEvent) - log = log.WithFields(em.GetLoggerFields()) - log.Debug("processing") - - switch em.Msg.ContentType { - case edge.ContentTypeData: - log.Debugf("received data message with payload size %v", len(em.Msg.Body)) - return em.Msg.Body, conn.getHeaderMap(em.Msg), nil - - case edge.ContentTypeStateClosed: - log.Debug("received close message, closing connection and returning EOF") - conn.close(false, "close message received") - conn.closeCB(conn.Id()) - return nil, nil, io.EOF // io.EOF signals xgress to shutdown - - default: - log.Error("unexpected message type") - } - } -} - -func (conn *localMessageSink) WritePayload(p []byte, headers map[uint8][]byte) (n int, err error) { - msgUUID := headers[xgress.HeaderKeyUUID] - return conn.WriteTraced(p, msgUUID) -} - -func (conn *localMessageSink) Close() error { - conn.close(true, "close called") - - return nil -} - -func (conn *localMessageSink) close(notify bool, reason string) { - if !conn.closed.CompareAndSwap(false, true) { - // already closed - return - } - - log := pfxlog.ContextLogger(conn.Channel.Label()).WithField("connId", conn.Id()) - log.Infof("closing message sink, reason: %v", reason) - if notify { - // Notify edge client of close - closeMsg := edge.NewStateClosedMsg(conn.Id(), "") - if err := conn.SendState(closeMsg); err != nil { - log.WithError(err).Warn("unable to send close msg to edge client") - } - } - - // remove ourselves from mux, etc - conn.closeCB(conn.Id()) - - // When nextSeq is closed, GetNext in Read() will return a nil. - // This will cause an io.EOF to be returned to the xgress read loop, which will cause that - // to terminate - conn.seq.Close() -} - -func (conn *localMessageSink) Accept(event *edge.MsgEvent) { - if err := conn.seq.PutSequenced(event.Seq, event); err != nil { - pfxlog.Logger().WithFields(event.GetLoggerFields()).Errorf("failed to dispatch to fabric: (%v)", err) - } -} - -func (conn *localMessageSink) getHeaderMap(message *channel2.Message) map[uint8][]byte { - msgUUID, found := message.Headers[edge.UUIDHeader] - if found { - return map[uint8][]byte{xgress.HeaderKeyUUID: msgUUID} - } - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package xgress_edge + +import ( + "github.com/michaelquigley/pfxlog" + "github.com/netfoundry/ziti-fabric/xgress" + "github.com/netfoundry/ziti-foundation/channel2" + "github.com/netfoundry/ziti-foundation/util/concurrenz" + "github.com/netfoundry/ziti-foundation/util/sequencer" + "github.com/netfoundry/ziti-sdk-golang/ziti/edge" + "io" +) + +type localMessageSink struct { + edge.MsgChannel + seq sequencer.Sequencer + closeCB func(connId uint32) + newSinkCB func(sink *localMessageSink) + closed concurrenz.AtomicBoolean +} + +type localListener struct { + localMessageSink + token string + service string + parent *ingressProxy +} + +func (conn *localMessageSink) newSink(connId uint32, options *Options) *localMessageSink { + result := &localMessageSink{ + MsgChannel: *edge.NewEdgeMsgChannel(conn.Channel, connId), + seq: sequencer.NewSingleWriterSeq(options.MaxOutOfOrderMsgs), + closeCB: conn.closeCB, + newSinkCB: conn.newSinkCB, + } + + // TODO: Evaluate best way to get new conn in map. Split dial? Any way to use regular map? + if conn.newSinkCB != nil { + conn.newSinkCB(result) + } + return result +} + +func (conn *localMessageSink) LogContext() string { + return conn.Channel.Label() +} + +func (conn *localMessageSink) ReadPayload() ([]byte, map[uint8][]byte, error) { + log := pfxlog.ContextLogger(conn.Channel.Label()).WithField("connId", conn.Id()) + + for { + next := conn.seq.GetNext() + if next == nil { + log.Debug("sequencer closed, return EOF") + conn.closeCB(conn.Id()) + return nil, nil, io.EOF // io.EOF signals xgress to shutdown + } + + em := next.(*edge.MsgEvent) + log = log.WithFields(em.GetLoggerFields()) + log.Debug("processing") + + switch em.Msg.ContentType { + case edge.ContentTypeData: + log.Debugf("received data message with payload size %v", len(em.Msg.Body)) + return em.Msg.Body, conn.getHeaderMap(em.Msg), nil + + case edge.ContentTypeStateClosed: + log.Debug("received close message, closing connection and returning EOF") + conn.close(false, "close message received") + conn.closeCB(conn.Id()) + return nil, nil, io.EOF // io.EOF signals xgress to shutdown + + default: + log.Error("unexpected message type") + } + } +} + +func (conn *localMessageSink) WritePayload(p []byte, headers map[uint8][]byte) (n int, err error) { + msgUUID := headers[xgress.HeaderKeyUUID] + return conn.WriteTraced(p, msgUUID) +} + +func (conn *localMessageSink) Close() error { + conn.close(true, "close called") + + return nil +} + +func (conn *localMessageSink) close(notify bool, reason string) { + if !conn.closed.CompareAndSwap(false, true) { + // already closed + return + } + + log := pfxlog.ContextLogger(conn.Channel.Label()).WithField("connId", conn.Id()) + log.Infof("closing message sink, reason: %v", reason) + if notify { + // Notify edge client of close + closeMsg := edge.NewStateClosedMsg(conn.Id(), "") + if err := conn.SendState(closeMsg); err != nil { + log.WithError(err).Warn("unable to send close msg to edge client") + } + } + + // remove ourselves from mux, etc + conn.closeCB(conn.Id()) + + // When nextSeq is closed, GetNext in Read() will return a nil. + // This will cause an io.EOF to be returned to the xgress read loop, which will cause that + // to terminate + conn.seq.Close() +} + +func (conn *localMessageSink) Accept(event *edge.MsgEvent) { + if err := conn.seq.PutSequenced(event.Seq, event); err != nil { + pfxlog.Logger().WithFields(event.GetLoggerFields()).Errorf("failed to dispatch to fabric: (%v)", err) + } +} + +func (conn *localMessageSink) getHeaderMap(message *channel2.Message) map[uint8][]byte { + msgUUID, found := message.Headers[edge.UUIDHeader] + if found { + return map[uint8][]byte{xgress.HeaderKeyUUID: msgUUID} + } + return nil +} diff --git a/gateway/xgress_edge/hosted.go b/gateway/xgress_edge/hosted.go index d0561a7d6..301f6947a 100644 --- a/gateway/xgress_edge/hosted.go +++ b/gateway/xgress_edge/hosted.go @@ -1,55 +1,55 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package xgress_edge - -import ( - "sync" -) - -type hostedServiceRegistry struct { - services sync.Map -} - -func (registry *hostedServiceRegistry) Put(hostId string, conn *localListener) { - registry.services.Store(hostId, conn) -} - -func (registry *hostedServiceRegistry) Get(hostId string) (*localListener, bool) { - val, ok := registry.services.Load(hostId) - if !ok { - return nil, false - } - ch, ok := val.(*localListener) - return ch, ok -} - -func (registry *hostedServiceRegistry) Delete(hostId string) { - registry.services.Delete(hostId) -} - -func (registry *hostedServiceRegistry) cleanupServices(proxy *ingressProxy) (listeners []*localListener) { - registry.services.Range(func(key, value interface{}) bool { - listener := value.(*localListener) - if listener.parent == proxy { - listener.close(true, "underlying channel closing") - registry.services.Delete(key) - listeners = append(listeners, listener) - } - return true - }) - return -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package xgress_edge + +import ( + "sync" +) + +type hostedServiceRegistry struct { + services sync.Map +} + +func (registry *hostedServiceRegistry) Put(hostId string, conn *localListener) { + registry.services.Store(hostId, conn) +} + +func (registry *hostedServiceRegistry) Get(hostId string) (*localListener, bool) { + val, ok := registry.services.Load(hostId) + if !ok { + return nil, false + } + ch, ok := val.(*localListener) + return ch, ok +} + +func (registry *hostedServiceRegistry) Delete(hostId string) { + registry.services.Delete(hostId) +} + +func (registry *hostedServiceRegistry) cleanupServices(proxy *ingressProxy) (listeners []*localListener) { + registry.services.Range(func(key, value interface{}) bool { + listener := value.(*localListener) + if listener.parent == proxy { + listener.close(true, "underlying channel closing") + registry.services.Delete(key) + listeners = append(listeners, listener) + } + return true + }) + return +} diff --git a/internal/cert/cert.go b/internal/cert/cert.go index 1733290af..930ac3ad7 100644 --- a/internal/cert/cert.go +++ b/internal/cert/cert.go @@ -1,276 +1,276 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package cert - -import ( - "bytes" - "crypto/rand" - "crypto/x509" - "encoding/pem" - "errors" - "fmt" - "github.com/michaelquigley/pfxlog" - "math/big" - "net" - "net/url" - "strings" - "time" -) - -type SignFunc func([]byte, *SigningOpts) ([]byte, error) - -type CertPem struct { - Cert *x509.Certificate - Pem []byte -} - -type Signer interface { - Sign([]byte, *SigningOpts) ([]byte, error) - ToPem([]byte) ([]byte, error) - SigningCertPEM() string -} - -type SigningOpts struct { - // Subject Alternate Name values. - DNSNames []string - EmailAddresses []string - IPAddresses []net.IP - URIs []*url.URL -} - -func (so *SigningOpts) Apply(c *x509.Certificate) { - c.DNSNames = so.DNSNames - c.EmailAddresses = so.EmailAddresses - c.IPAddresses = so.IPAddresses - c.URIs = so.URIs -} - -type SerialGenerator interface { - Generate() *big.Int -} - -type DefaultSerialGenerator struct{} - -func (DefaultSerialGenerator) Generate() *big.Int { - //@todo this need to be better, this does not include negative numbers for 20bit values, nor is this managed - r, _ := rand.Int(rand.Reader, big.NewInt(524287)) - - return r -} - -type ServerSigner struct { - caCert *x509.Certificate - caKey interface{} - SerialGenerator SerialGenerator -} - -func NewServerSigner(caCert *x509.Certificate, caKey interface{}) *ServerSigner { - return &ServerSigner{ - caCert: caCert, - caKey: caKey, - SerialGenerator: &DefaultSerialGenerator{}, - } -} - -func (s *ServerSigner) SigningCertPEM() string { - b, err := s.ToPem(s.caCert.Raw) - if err != nil { - pfxlog.Logger().WithError(err).Error("failed to convert signing cert into PEM") - return "" - } - - return string(b) -} - -func (s *ServerSigner) ToPem(raw []byte) ([]byte, error) { - return cert2pem(raw) -} - -func (s *ServerSigner) Sign(csrPem []byte, opts *SigningOpts) ([]byte, error) { - csr, err := ParseCsr(csrPem) - - if err != nil { - return nil, fmt.Errorf("unable to parse PEM bytes as CSR: %s", err) - } - - if err = csr.CheckSignature(); err != nil { - return nil, fmt.Errorf("CSR signature validation failed: %s", err) - } - - // create client certificate template - certTemplate := x509.Certificate{ - Signature: csr.Signature, - PublicKeyAlgorithm: csr.PublicKeyAlgorithm, - PublicKey: csr.PublicKey, - - SerialNumber: s.SerialGenerator.Generate(), - Issuer: s.caCert.Subject, - Subject: csr.Subject, - NotBefore: time.Now().Add(-time.Minute), - NotAfter: time.Now().AddDate(1, 0, 0), //@todo make this an option? - KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageDataEncipherment, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, - IsCA: false, - } - - if opts != nil { - opts.Apply(&certTemplate) - } - - cert, err := x509.CreateCertificate(rand.Reader, &certTemplate, s.caCert, csr.PublicKey, s.caKey) - - if err != nil { - return nil, fmt.Errorf("could not sign cert: %s", err) - } - - return cert, nil -} - -type ClientSigner struct { - caCert *x509.Certificate - caKey interface{} - SerialGenerator SerialGenerator -} - -func (s *ClientSigner) SigningCertPEM() string { - return "" -} - -func NewClientSigner(caCert *x509.Certificate, caKey interface{}) *ClientSigner { - return &ClientSigner{ - caCert: caCert, - caKey: caKey, - SerialGenerator: &DefaultSerialGenerator{}, - } -} - -func (s *ClientSigner) ToPem(raw []byte) ([]byte, error) { - return cert2pem(raw) -} - -func (s *ClientSigner) Sign(csrPem []byte, opts *SigningOpts) ([]byte, error) { - csr, err := ParseCsr(csrPem) - - if err != nil { - return nil, fmt.Errorf("unable to parse PEM bytes as CSR: %s", err) - } - - if err = csr.CheckSignature(); err != nil { - return nil, fmt.Errorf("CSR signature validation failed: %s", err) - } - - // create client certificate template - certTemplate := x509.Certificate{ - Signature: csr.Signature, - - PublicKeyAlgorithm: csr.PublicKeyAlgorithm, - PublicKey: csr.PublicKey, - - SerialNumber: s.SerialGenerator.Generate(), - Issuer: s.caCert.Subject, - Subject: csr.Subject, - NotBefore: time.Now().Add(-time.Minute), - NotAfter: time.Now().AddDate(1, 0, 0), - KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageDataEncipherment, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, - IsCA: false, - } - - if opts != nil { - opts.Apply(&certTemplate) - } - - cert, err := x509.CreateCertificate(rand.Reader, &certTemplate, s.caCert, csr.PublicKey, s.caKey) - - if err != nil { - return nil, fmt.Errorf("could not sign cert: %s", err) - } - - return cert, nil -} - -func cert2pem(raw []byte) ([]byte, error) { - cert := bytes.NewBuffer(make([]byte, 0)) - - err := pem.Encode(cert, &pem.Block{Type: "CERTIFICATE", Bytes: raw}) - - if err != nil { - return nil, fmt.Errorf("could not create pem encoding: %s", err) - } - - return cert.Bytes(), nil -} - -func ParseCsr(csrPem []byte) (*x509.CertificateRequest, error) { - if len(csrPem) == 0 { - return nil, errors.New("csrPem must not be null or empty") - } - - pemBlock, remainder := pem.Decode(csrPem) - if pemBlock == nil { - return nil, fmt.Errorf("could not decode csrPem as PEM") - } - - if remainder == nil || len(remainder) != 0 { - return nil, fmt.Errorf("unexpected PEM blocks at end of CSR") - } - - return x509.ParseCertificateRequest(pemBlock.Bytes) -} - -func PemChain2Blocks(pemBuff string) ([]*pem.Block, error) { - remainder := []byte(strings.TrimSpace(pemBuff)) - - var b *pem.Block - numBlock := 0 - - var blocks []*pem.Block - for len(remainder) > 0 { - numBlock++ - b, remainder = pem.Decode(remainder) - - if b == nil { - return nil, fmt.Errorf("could not parse block #%d", numBlock) - } - - if b.Type != "CERTIFICATE" { - return nil, fmt.Errorf("block #%d is not a certificate", numBlock) - } - - blocks = append(blocks, b) - } - - return blocks, nil -} - -func Blocks2Certs(blocks []*pem.Block) ([]*x509.Certificate, error) { - var certs []*x509.Certificate - numCert := 0 - for _, b := range blocks { - numCert++ - - c, err := x509.ParseCertificate(b.Bytes) - - if err != nil { - return nil, fmt.Errorf("could not parse block #%d as an x509 certificate", numCert) - } - - certs = append(certs, c) - } - - return certs, nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package cert + +import ( + "bytes" + "crypto/rand" + "crypto/x509" + "encoding/pem" + "errors" + "fmt" + "github.com/michaelquigley/pfxlog" + "math/big" + "net" + "net/url" + "strings" + "time" +) + +type SignFunc func([]byte, *SigningOpts) ([]byte, error) + +type CertPem struct { + Cert *x509.Certificate + Pem []byte +} + +type Signer interface { + Sign([]byte, *SigningOpts) ([]byte, error) + ToPem([]byte) ([]byte, error) + SigningCertPEM() string +} + +type SigningOpts struct { + // Subject Alternate Name values. + DNSNames []string + EmailAddresses []string + IPAddresses []net.IP + URIs []*url.URL +} + +func (so *SigningOpts) Apply(c *x509.Certificate) { + c.DNSNames = so.DNSNames + c.EmailAddresses = so.EmailAddresses + c.IPAddresses = so.IPAddresses + c.URIs = so.URIs +} + +type SerialGenerator interface { + Generate() *big.Int +} + +type DefaultSerialGenerator struct{} + +func (DefaultSerialGenerator) Generate() *big.Int { + //@todo this need to be better, this does not include negative numbers for 20bit values, nor is this managed + r, _ := rand.Int(rand.Reader, big.NewInt(524287)) + + return r +} + +type ServerSigner struct { + caCert *x509.Certificate + caKey interface{} + SerialGenerator SerialGenerator +} + +func NewServerSigner(caCert *x509.Certificate, caKey interface{}) *ServerSigner { + return &ServerSigner{ + caCert: caCert, + caKey: caKey, + SerialGenerator: &DefaultSerialGenerator{}, + } +} + +func (s *ServerSigner) SigningCertPEM() string { + b, err := s.ToPem(s.caCert.Raw) + if err != nil { + pfxlog.Logger().WithError(err).Error("failed to convert signing cert into PEM") + return "" + } + + return string(b) +} + +func (s *ServerSigner) ToPem(raw []byte) ([]byte, error) { + return cert2pem(raw) +} + +func (s *ServerSigner) Sign(csrPem []byte, opts *SigningOpts) ([]byte, error) { + csr, err := ParseCsr(csrPem) + + if err != nil { + return nil, fmt.Errorf("unable to parse PEM bytes as CSR: %s", err) + } + + if err = csr.CheckSignature(); err != nil { + return nil, fmt.Errorf("CSR signature validation failed: %s", err) + } + + // create client certificate template + certTemplate := x509.Certificate{ + Signature: csr.Signature, + PublicKeyAlgorithm: csr.PublicKeyAlgorithm, + PublicKey: csr.PublicKey, + + SerialNumber: s.SerialGenerator.Generate(), + Issuer: s.caCert.Subject, + Subject: csr.Subject, + NotBefore: time.Now().Add(-time.Minute), + NotAfter: time.Now().AddDate(1, 0, 0), //@todo make this an option? + KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageDataEncipherment, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, + IsCA: false, + } + + if opts != nil { + opts.Apply(&certTemplate) + } + + cert, err := x509.CreateCertificate(rand.Reader, &certTemplate, s.caCert, csr.PublicKey, s.caKey) + + if err != nil { + return nil, fmt.Errorf("could not sign cert: %s", err) + } + + return cert, nil +} + +type ClientSigner struct { + caCert *x509.Certificate + caKey interface{} + SerialGenerator SerialGenerator +} + +func (s *ClientSigner) SigningCertPEM() string { + return "" +} + +func NewClientSigner(caCert *x509.Certificate, caKey interface{}) *ClientSigner { + return &ClientSigner{ + caCert: caCert, + caKey: caKey, + SerialGenerator: &DefaultSerialGenerator{}, + } +} + +func (s *ClientSigner) ToPem(raw []byte) ([]byte, error) { + return cert2pem(raw) +} + +func (s *ClientSigner) Sign(csrPem []byte, opts *SigningOpts) ([]byte, error) { + csr, err := ParseCsr(csrPem) + + if err != nil { + return nil, fmt.Errorf("unable to parse PEM bytes as CSR: %s", err) + } + + if err = csr.CheckSignature(); err != nil { + return nil, fmt.Errorf("CSR signature validation failed: %s", err) + } + + // create client certificate template + certTemplate := x509.Certificate{ + Signature: csr.Signature, + + PublicKeyAlgorithm: csr.PublicKeyAlgorithm, + PublicKey: csr.PublicKey, + + SerialNumber: s.SerialGenerator.Generate(), + Issuer: s.caCert.Subject, + Subject: csr.Subject, + NotBefore: time.Now().Add(-time.Minute), + NotAfter: time.Now().AddDate(1, 0, 0), + KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageDataEncipherment, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, + IsCA: false, + } + + if opts != nil { + opts.Apply(&certTemplate) + } + + cert, err := x509.CreateCertificate(rand.Reader, &certTemplate, s.caCert, csr.PublicKey, s.caKey) + + if err != nil { + return nil, fmt.Errorf("could not sign cert: %s", err) + } + + return cert, nil +} + +func cert2pem(raw []byte) ([]byte, error) { + cert := bytes.NewBuffer(make([]byte, 0)) + + err := pem.Encode(cert, &pem.Block{Type: "CERTIFICATE", Bytes: raw}) + + if err != nil { + return nil, fmt.Errorf("could not create pem encoding: %s", err) + } + + return cert.Bytes(), nil +} + +func ParseCsr(csrPem []byte) (*x509.CertificateRequest, error) { + if len(csrPem) == 0 { + return nil, errors.New("csrPem must not be null or empty") + } + + pemBlock, remainder := pem.Decode(csrPem) + if pemBlock == nil { + return nil, fmt.Errorf("could not decode csrPem as PEM") + } + + if remainder == nil || len(remainder) != 0 { + return nil, fmt.Errorf("unexpected PEM blocks at end of CSR") + } + + return x509.ParseCertificateRequest(pemBlock.Bytes) +} + +func PemChain2Blocks(pemBuff string) ([]*pem.Block, error) { + remainder := []byte(strings.TrimSpace(pemBuff)) + + var b *pem.Block + numBlock := 0 + + var blocks []*pem.Block + for len(remainder) > 0 { + numBlock++ + b, remainder = pem.Decode(remainder) + + if b == nil { + return nil, fmt.Errorf("could not parse block #%d", numBlock) + } + + if b.Type != "CERTIFICATE" { + return nil, fmt.Errorf("block #%d is not a certificate", numBlock) + } + + blocks = append(blocks, b) + } + + return blocks, nil +} + +func Blocks2Certs(blocks []*pem.Block) ([]*x509.Certificate, error) { + var certs []*x509.Certificate + numCert := 0 + for _, b := range blocks { + numCert++ + + c, err := x509.ParseCertificate(b.Bytes) + + if err != nil { + return nil, fmt.Errorf("could not parse block #%d as an x509 certificate", numCert) + } + + certs = append(certs, c) + } + + return certs, nil +} diff --git a/internal/cert/fingerprint.go b/internal/cert/fingerprint.go index 81055f990..c2d4ebf2a 100644 --- a/internal/cert/fingerprint.go +++ b/internal/cert/fingerprint.go @@ -1,128 +1,128 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package cert - -import ( - "bytes" - "crypto/sha1" - "crypto/x509" - "encoding/pem" - "fmt" - "strings" -) - -type Fingerprints map[string]interface{} - -func (fingerprints Fingerprints) Contains(fp string) bool { - if _, matchingFingerprints := fingerprints[fp]; matchingFingerprints { - return true - } - return false -} - -func (fingerprints Fingerprints) HasAny(fps []string) (string, bool) { - for _, fp := range fps { - if _, matchingFingerprints := fingerprints[fp]; matchingFingerprints { - return fp, true - } - } - return "", false -} - -func (fingerprints Fingerprints) Prints() []string { - ret := []string{} - - for k := range fingerprints { - ret = append(ret, k) - } - - return ret -} - -func NewFingerprintGenerator() FingerprintGenerator { - return &defaultFingerprintGenerator{} -} - -type FingerprintGenerator interface { - FromCert(cert *x509.Certificate) string - FromCerts(certs []*x509.Certificate) Fingerprints - FromRaw(raw []byte) string - FromPem(pem []byte) string -} - -type defaultFingerprintGenerator struct{} - -func firstCertBlock(pemBytes []byte) (*pem.Block, []byte) { - var block *pem.Block - for len(pemBytes) > 0 { - block, pemBytes = pem.Decode(pemBytes) - if block == nil { - continue - } - if block.Type == "CERTIFICATE" { - return block, pemBytes - } - } - return nil, nil -} - -func (fpg *defaultFingerprintGenerator) FromPem(cert []byte) string { - block, _ := firstCertBlock(cert) - if block == nil { - return "" - } - - derBytes := block.Bytes - - c, err := x509.ParseCertificate(derBytes) - - if err != nil { - return "" - } - - return fpg.FromCert(c) -} - -func (fpg *defaultFingerprintGenerator) FromCert(cert *x509.Certificate) string { - return fpg.FromRaw(cert.Raw) -} - -func (fpg *defaultFingerprintGenerator) FromCerts(certs []*x509.Certificate) Fingerprints { - fps := make(Fingerprints) - - for _, cert := range certs { - fp := fpg.FromCert(cert) - fps[fp] = true - } - return fps -} - -func (fpg *defaultFingerprintGenerator) FromRaw(raw []byte) string { - rawFingerprint := sha1.Sum(raw) - return fpg.toHex(rawFingerprint[:]) -} - -func (fpg *defaultFingerprintGenerator) toHex(f []byte) string { - var buf bytes.Buffer - for i, b := range f { - if i > 0 { - fmt.Fprintf(&buf, ":") - } - fmt.Fprintf(&buf, "%02x", b) - } - return strings.ToUpper(buf.String()) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package cert + +import ( + "bytes" + "crypto/sha1" + "crypto/x509" + "encoding/pem" + "fmt" + "strings" +) + +type Fingerprints map[string]interface{} + +func (fingerprints Fingerprints) Contains(fp string) bool { + if _, matchingFingerprints := fingerprints[fp]; matchingFingerprints { + return true + } + return false +} + +func (fingerprints Fingerprints) HasAny(fps []string) (string, bool) { + for _, fp := range fps { + if _, matchingFingerprints := fingerprints[fp]; matchingFingerprints { + return fp, true + } + } + return "", false +} + +func (fingerprints Fingerprints) Prints() []string { + ret := []string{} + + for k := range fingerprints { + ret = append(ret, k) + } + + return ret +} + +func NewFingerprintGenerator() FingerprintGenerator { + return &defaultFingerprintGenerator{} +} + +type FingerprintGenerator interface { + FromCert(cert *x509.Certificate) string + FromCerts(certs []*x509.Certificate) Fingerprints + FromRaw(raw []byte) string + FromPem(pem []byte) string +} + +type defaultFingerprintGenerator struct{} + +func firstCertBlock(pemBytes []byte) (*pem.Block, []byte) { + var block *pem.Block + for len(pemBytes) > 0 { + block, pemBytes = pem.Decode(pemBytes) + if block == nil { + continue + } + if block.Type == "CERTIFICATE" { + return block, pemBytes + } + } + return nil, nil +} + +func (fpg *defaultFingerprintGenerator) FromPem(cert []byte) string { + block, _ := firstCertBlock(cert) + if block == nil { + return "" + } + + derBytes := block.Bytes + + c, err := x509.ParseCertificate(derBytes) + + if err != nil { + return "" + } + + return fpg.FromCert(c) +} + +func (fpg *defaultFingerprintGenerator) FromCert(cert *x509.Certificate) string { + return fpg.FromRaw(cert.Raw) +} + +func (fpg *defaultFingerprintGenerator) FromCerts(certs []*x509.Certificate) Fingerprints { + fps := make(Fingerprints) + + for _, cert := range certs { + fp := fpg.FromCert(cert) + fps[fp] = true + } + return fps +} + +func (fpg *defaultFingerprintGenerator) FromRaw(raw []byte) string { + rawFingerprint := sha1.Sum(raw) + return fpg.toHex(rawFingerprint[:]) +} + +func (fpg *defaultFingerprintGenerator) toHex(f []byte) string { + var buf bytes.Buffer + for i, b := range f { + if i > 0 { + fmt.Fprintf(&buf, ":") + } + fmt.Fprintf(&buf, "%02x", b) + } + return strings.ToUpper(buf.String()) +} diff --git a/internal/jsonschema/uuid.go b/internal/jsonschema/uuid.go index 0d6676beb..c92daca15 100644 --- a/internal/jsonschema/uuid.go +++ b/internal/jsonschema/uuid.go @@ -1,38 +1,38 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package jsonschema - -import ( - "github.com/google/uuid" -) - -type UuidFormatChecker struct{} - -func (f UuidFormatChecker) IsFormat(input interface{}) bool { - if input == nil { - return true - } - - str, ok := input.(string) - if !ok { - return false - } - - _, err := uuid.Parse(str) - - return err == nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package jsonschema + +import ( + "github.com/google/uuid" +) + +type UuidFormatChecker struct{} + +func (f UuidFormatChecker) IsFormat(input interface{}) bool { + if input == nil { + return true + } + + str, ok := input.(string) + if !ok { + return false + } + + _, err := uuid.Parse(str) + + return err == nil +} diff --git a/internal/jwt/jwt.go b/internal/jwt/jwt.go index 37b893ed7..99d9494ec 100644 --- a/internal/jwt/jwt.go +++ b/internal/jwt/jwt.go @@ -1,44 +1,44 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package jwt - -import ( - "github.com/dgrijalva/jwt-go" -) - -type EnrollmentGenerator interface { - Generate(string, string, jwt.MapClaims) (string, error) -} - -type IdentityEnrollmentJwtGenerator struct { - signingMethod jwt.SigningMethod - issuer string - key interface{} -} - -func NewJwtIdentityEnrollmentGenerator(issuer string, sm jwt.SigningMethod, key interface{}) *IdentityEnrollmentJwtGenerator { - return &IdentityEnrollmentJwtGenerator{ - signingMethod: sm, - issuer: issuer, - key: key, - } -} - -func (j *IdentityEnrollmentJwtGenerator) Generate(subj, jti string, claims jwt.MapClaims) (string, error) { - token := jwt.NewWithClaims(j.signingMethod, claims) - return token.SignedString(j.key) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package jwt + +import ( + "github.com/dgrijalva/jwt-go" +) + +type EnrollmentGenerator interface { + Generate(string, string, jwt.MapClaims) (string, error) +} + +type IdentityEnrollmentJwtGenerator struct { + signingMethod jwt.SigningMethod + issuer string + key interface{} +} + +func NewJwtIdentityEnrollmentGenerator(issuer string, sm jwt.SigningMethod, key interface{}) *IdentityEnrollmentJwtGenerator { + return &IdentityEnrollmentJwtGenerator{ + signingMethod: sm, + issuer: issuer, + key: key, + } +} + +func (j *IdentityEnrollmentJwtGenerator) Generate(subj, jti string, claims jwt.MapClaims) (string, error) { + token := jwt.NewWithClaims(j.signingMethod, claims) + return token.SignedString(j.key) +} diff --git a/internal/pem/pem.go b/internal/pem/pem.go index 36bc094d1..832063c35 100644 --- a/internal/pem/pem.go +++ b/internal/pem/pem.go @@ -1,167 +1,167 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package pem - -import ( - "crypto/ecdsa" - "crypto/rsa" - "crypto/x509" - "encoding/pem" - "fmt" - "io/ioutil" - "strings" -) - -type KeyPair struct { - Key interface{} - EcKey *ecdsa.PrivateKey - RsaKey *rsa.PrivateKey - Cert *x509.Certificate - CertPem []byte - KeyPem []byte -} - -func (kp *KeyPair) IsEc() bool { - return kp.EcKey != nil -} - -func (kp *KeyPair) IsRsa() bool { - return kp.RsaKey != nil -} - -func NewKeyPair(privPath, pubPath, password string) (*KeyPair, error) { - kp := &KeyPair{} - - err := kp.loadKey(privPath, password) - - if err != nil { - return nil, err - } - err = kp.loadCertificate(pubPath) - - if err != nil { - return nil, err - } - - return kp, nil -} - -func (kp *KeyPair) loadKey(privPath, password string) error { - pemBytes, err := ioutil.ReadFile(privPath) - kp.KeyPem = pemBytes - if err != nil { - return err - } - - block := firstKeyBlock(pemBytes) - if block == nil { - return fmt.Errorf("invalid or missing private key input: %s", privPath) - } - - derBytes := block.Bytes - - if x509.IsEncryptedPEMBlock(block) { - derBytes, err = x509.DecryptPEMBlock(block, []byte(password)) - if err != nil { - return err - } - } - - switch block.Type { - case "RSA PRIVATE KEY": - kp.RsaKey, err = x509.ParsePKCS1PrivateKey(derBytes) - if err != nil { - return err - } - kp.Key = kp.RsaKey - case "EC PRIVATE KEY": - kp.EcKey, err = x509.ParseECPrivateKey(derBytes) - if err != nil { - return err - } - kp.Key = kp.EcKey - case "PRIVATE KEY": - k, err := x509.ParsePKCS8PrivateKey(derBytes) - if err != nil { - return err - } - - switch key := k.(type) { - case *rsa.PrivateKey: - kp.RsaKey = key - kp.Key = kp.RsaKey - case *ecdsa.PrivateKey: - kp.EcKey = key - kp.Key = kp.EcKey - default: - return fmt.Errorf("found unsupported private key type(%v) in PKCS#8 wrapping", k) - } - - default: - return fmt.Errorf("unsupported private key: %s", privPath) - } - - return nil -} - -func (kp *KeyPair) loadCertificate(pubPath string) error { - pemBytes, err := ioutil.ReadFile(pubPath) - kp.CertPem = pemBytes - - if err != nil { - return fmt.Errorf("problem loading certificate: %s", err) - } - - block := firstCertBlock(pemBytes) - if block == nil { - return fmt.Errorf("problem loading certificate. invalid format or missing public key input: %s", pubPath) - } - derBytes := block.Bytes - kp.Cert, err = x509.ParseCertificate(derBytes) - - if err != nil { - return fmt.Errorf("problem converting certificate to x509. %s", err) - } - - return nil -} - -func firstKeyBlock(pemBytes []byte) *pem.Block { - var block *pem.Block - for len(pemBytes) > 0 { - block, pemBytes = pem.Decode(pemBytes) - if strings.HasSuffix(block.Type, "PRIVATE KEY") { - return block - } - } - return nil -} - -func firstCertBlock(pemBytes []byte) *pem.Block { - var block *pem.Block - for len(pemBytes) > 0 { - block, pemBytes = pem.Decode(pemBytes) - if block != nil { - if block.Type == "CERTIFICATE" { - return block - } - } else { - return nil - } - } - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package pem + +import ( + "crypto/ecdsa" + "crypto/rsa" + "crypto/x509" + "encoding/pem" + "fmt" + "io/ioutil" + "strings" +) + +type KeyPair struct { + Key interface{} + EcKey *ecdsa.PrivateKey + RsaKey *rsa.PrivateKey + Cert *x509.Certificate + CertPem []byte + KeyPem []byte +} + +func (kp *KeyPair) IsEc() bool { + return kp.EcKey != nil +} + +func (kp *KeyPair) IsRsa() bool { + return kp.RsaKey != nil +} + +func NewKeyPair(privPath, pubPath, password string) (*KeyPair, error) { + kp := &KeyPair{} + + err := kp.loadKey(privPath, password) + + if err != nil { + return nil, err + } + err = kp.loadCertificate(pubPath) + + if err != nil { + return nil, err + } + + return kp, nil +} + +func (kp *KeyPair) loadKey(privPath, password string) error { + pemBytes, err := ioutil.ReadFile(privPath) + kp.KeyPem = pemBytes + if err != nil { + return err + } + + block := firstKeyBlock(pemBytes) + if block == nil { + return fmt.Errorf("invalid or missing private key input: %s", privPath) + } + + derBytes := block.Bytes + + if x509.IsEncryptedPEMBlock(block) { + derBytes, err = x509.DecryptPEMBlock(block, []byte(password)) + if err != nil { + return err + } + } + + switch block.Type { + case "RSA PRIVATE KEY": + kp.RsaKey, err = x509.ParsePKCS1PrivateKey(derBytes) + if err != nil { + return err + } + kp.Key = kp.RsaKey + case "EC PRIVATE KEY": + kp.EcKey, err = x509.ParseECPrivateKey(derBytes) + if err != nil { + return err + } + kp.Key = kp.EcKey + case "PRIVATE KEY": + k, err := x509.ParsePKCS8PrivateKey(derBytes) + if err != nil { + return err + } + + switch key := k.(type) { + case *rsa.PrivateKey: + kp.RsaKey = key + kp.Key = kp.RsaKey + case *ecdsa.PrivateKey: + kp.EcKey = key + kp.Key = kp.EcKey + default: + return fmt.Errorf("found unsupported private key type(%v) in PKCS#8 wrapping", k) + } + + default: + return fmt.Errorf("unsupported private key: %s", privPath) + } + + return nil +} + +func (kp *KeyPair) loadCertificate(pubPath string) error { + pemBytes, err := ioutil.ReadFile(pubPath) + kp.CertPem = pemBytes + + if err != nil { + return fmt.Errorf("problem loading certificate: %s", err) + } + + block := firstCertBlock(pemBytes) + if block == nil { + return fmt.Errorf("problem loading certificate. invalid format or missing public key input: %s", pubPath) + } + derBytes := block.Bytes + kp.Cert, err = x509.ParseCertificate(derBytes) + + if err != nil { + return fmt.Errorf("problem converting certificate to x509. %s", err) + } + + return nil +} + +func firstKeyBlock(pemBytes []byte) *pem.Block { + var block *pem.Block + for len(pemBytes) > 0 { + block, pemBytes = pem.Decode(pemBytes) + if strings.HasSuffix(block.Type, "PRIVATE KEY") { + return block + } + } + return nil +} + +func firstCertBlock(pemBytes []byte) *pem.Block { + var block *pem.Block + for len(pemBytes) > 0 { + block, pemBytes = pem.Decode(pemBytes) + if block != nil { + if block.Type == "CERTIFICATE" { + return block + } + } else { + return nil + } + } + return nil +} diff --git a/internal/util/prompt.go b/internal/util/prompt.go index 884c25c4b..c3b6eac21 100644 --- a/internal/util/prompt.go +++ b/internal/util/prompt.go @@ -1,17 +1,17 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package util diff --git a/internal/version/version.go b/internal/version/version.go index 4ff27145c..1918e17b0 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -1,25 +1,25 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package version - -func GetApiVersion() string { - return "0.0.1" -} - -func GetApiEnrollmentVersion() string { - return "0.0.1" -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package version + +func GetApiVersion() string { + return "0.0.1" +} + +func GetApiEnrollmentVersion() string { + return "0.0.1" +} diff --git a/logconf/logconf.go b/logconf/logconf.go index f7ef4f0a4..c6847f275 100644 --- a/logconf/logconf.go +++ b/logconf/logconf.go @@ -1,84 +1,84 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package logconf - -import ( - "fmt" - "github.com/sirupsen/logrus" - "strings" -) - -type Logging struct { - Level string `yaml:"level"` - Format string `yaml:"format"` -} - -func (l *Logging) SetLoggingOptions() error { - - fl := strings.TrimSpace(l.Level) - - if fl == "" { - fl = "info" - } - - lvl, err := logrus.ParseLevel(fl) - - if err != nil { - return fmt.Errorf("invalid logging level [%s] specified", l.Level) - } - - if logrus.GetLevel() != lvl && (logrus.GetLevel() == logrus.InfoLevel || logrus.GetLevel() < lvl) { - fmt.Printf("Changing log level from %v to %v\n", logrus.GetLevel(), lvl) - logrus.SetLevel(lvl) - } - - fmt, err := parseFormat(l.Format) - - if err != nil { - return err - } - - if fmt != nil { - logrus.SetFormatter(fmt) - } - - return nil -} - -func parseFormat(f string) (logrus.Formatter, error) { - mf := strings.ToLower(strings.TrimSpace(f)) - switch strings.ToLower(mf) { - case "": - return nil, nil - case "default": - return nil, nil - case "text": - return &logrus.TextFormatter{ - DisableColors: true, - FullTimestamp: true, - }, nil - case "json": - return &logrus.JSONFormatter{}, nil - case "console": - return &logrus.TextFormatter{ - ForceColors: true, - }, nil - } - - return nil, fmt.Errorf("invalid log formatter [%s]", f) - -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package logconf + +import ( + "fmt" + "github.com/sirupsen/logrus" + "strings" +) + +type Logging struct { + Level string `yaml:"level"` + Format string `yaml:"format"` +} + +func (l *Logging) SetLoggingOptions() error { + + fl := strings.TrimSpace(l.Level) + + if fl == "" { + fl = "info" + } + + lvl, err := logrus.ParseLevel(fl) + + if err != nil { + return fmt.Errorf("invalid logging level [%s] specified", l.Level) + } + + if logrus.GetLevel() != lvl && (logrus.GetLevel() == logrus.InfoLevel || logrus.GetLevel() < lvl) { + fmt.Printf("Changing log level from %v to %v\n", logrus.GetLevel(), lvl) + logrus.SetLevel(lvl) + } + + fmt, err := parseFormat(l.Format) + + if err != nil { + return err + } + + if fmt != nil { + logrus.SetFormatter(fmt) + } + + return nil +} + +func parseFormat(f string) (logrus.Formatter, error) { + mf := strings.ToLower(strings.TrimSpace(f)) + switch strings.ToLower(mf) { + case "": + return nil, nil + case "default": + return nil, nil + case "text": + return &logrus.TextFormatter{ + DisableColors: true, + FullTimestamp: true, + }, nil + case "json": + return &logrus.JSONFormatter{}, nil + case "console": + return &logrus.TextFormatter{ + ForceColors: true, + }, nil + } + + return nil, fmt.Errorf("invalid log formatter [%s]", f) + +} diff --git a/migration/authenticator_cert_db_model.go b/migration/authenticator_cert_db_model.go index ebed36438..56d1f0408 100644 --- a/migration/authenticator_cert_db_model.go +++ b/migration/authenticator_cert_db_model.go @@ -1,24 +1,24 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -type AuthenticatorCert struct { - BaseDbEntity - Fingerprint *string - AuthenticatorId *string - Authenticator *Authenticator -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +type AuthenticatorCert struct { + BaseDbEntity + Fingerprint *string + AuthenticatorId *string + Authenticator *Authenticator +} diff --git a/migration/authenticator_db_model.go b/migration/authenticator_db_model.go index 3b1859e9b..77be1e99b 100644 --- a/migration/authenticator_db_model.go +++ b/migration/authenticator_db_model.go @@ -1,55 +1,55 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" -) - -type Authenticator struct { - BaseDbEntity - IdentityID *string - Method *string -} - -func (e *Authenticator) BeforeDelete(tx *gorm.DB) error { - return authenticatorHandlersInstance.Delete(tx, e) -} - -type AuthenticatorDeleteHandler func(tx *gorm.DB, i *Authenticator) error - -type AuthenticatorHandlers struct { - deletes []AuthenticatorDeleteHandler -} - -var authenticatorHandlersInstance = &AuthenticatorHandlers{} - -func (ih *AuthenticatorHandlers) AddDeleteHandler(handler AuthenticatorDeleteHandler) { - ih.deletes = append(ih.deletes, handler) -} - -func (ih *AuthenticatorHandlers) Delete(tx *gorm.DB, i *Authenticator) error { - for _, h := range ih.deletes { - err := h(tx, i) - - if err != nil { - return err - } - } - - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" +) + +type Authenticator struct { + BaseDbEntity + IdentityID *string + Method *string +} + +func (e *Authenticator) BeforeDelete(tx *gorm.DB) error { + return authenticatorHandlersInstance.Delete(tx, e) +} + +type AuthenticatorDeleteHandler func(tx *gorm.DB, i *Authenticator) error + +type AuthenticatorHandlers struct { + deletes []AuthenticatorDeleteHandler +} + +var authenticatorHandlersInstance = &AuthenticatorHandlers{} + +func (ih *AuthenticatorHandlers) AddDeleteHandler(handler AuthenticatorDeleteHandler) { + ih.deletes = append(ih.deletes, handler) +} + +func (ih *AuthenticatorHandlers) Delete(tx *gorm.DB, i *Authenticator) error { + for _, h := range ih.deletes { + err := h(tx, i) + + if err != nil { + return err + } + } + + return nil +} diff --git a/migration/authenticator_updb_db_model.go b/migration/authenticator_updb_db_model.go index 85bd7f79d..1d4c81ffd 100644 --- a/migration/authenticator_updb_db_model.go +++ b/migration/authenticator_updb_db_model.go @@ -1,26 +1,26 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -type AuthenticatorUpdb struct { - BaseDbEntity - AuthenticatorId *string - Authenticator *Authenticator - Username *string - Password *string - Salt *string -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +type AuthenticatorUpdb struct { + BaseDbEntity + AuthenticatorId *string + Authenticator *Authenticator + Username *string + Password *string + Salt *string +} diff --git a/migration/base_db_model.go b/migration/base_db_model.go index 0656cf38c..c56ded60a 100644 --- a/migration/base_db_model.go +++ b/migration/base_db_model.go @@ -1,66 +1,66 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" - "time" -) - -type BaseDbEntity struct { - ID string `gorm:"primary_key"` - CreatedAt *time.Time - UpdatedAt *time.Time - Tags *PropertyMap -} - -func NewBaseDbEntity() BaseDbEntity { - return BaseDbEntity{ - Tags: &PropertyMap{}, - ID: NewId(), - } -} - -func (b *BaseDbEntity) GetId() string { - return b.ID -} - -func (b *BaseDbEntity) SetId(id string) { - b.ID = id -} - -func (b *BaseDbEntity) SetUpdatedAt(t *time.Time) { - b.UpdatedAt = t -} - -func (b *BaseDbEntity) SetTags(tags *PropertyMap) { - b.Tags = tags -} - -func (b *BaseDbEntity) GetTags() *PropertyMap { - return b.Tags -} - -func (b *BaseDbEntity) ClearAssociations(typeEntity interface{}, tx *gorm.DB, columns ...string) error { - for _, column := range columns { - res := tx.Model(typeEntity).Association(column).Clear() - if res.Error != nil { - return res.Error - } - } - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" + "time" +) + +type BaseDbEntity struct { + ID string `gorm:"primary_key"` + CreatedAt *time.Time + UpdatedAt *time.Time + Tags *PropertyMap +} + +func NewBaseDbEntity() BaseDbEntity { + return BaseDbEntity{ + Tags: &PropertyMap{}, + ID: NewId(), + } +} + +func (b *BaseDbEntity) GetId() string { + return b.ID +} + +func (b *BaseDbEntity) SetId(id string) { + b.ID = id +} + +func (b *BaseDbEntity) SetUpdatedAt(t *time.Time) { + b.UpdatedAt = t +} + +func (b *BaseDbEntity) SetTags(tags *PropertyMap) { + b.Tags = tags +} + +func (b *BaseDbEntity) GetTags() *PropertyMap { + return b.Tags +} + +func (b *BaseDbEntity) ClearAssociations(typeEntity interface{}, tx *gorm.DB, columns ...string) error { + for _, column := range columns { + res := tx.Model(typeEntity).Association(column).Clear() + if res.Error != nil { + return res.Error + } + } + return nil +} diff --git a/migration/ca_db_model.go b/migration/ca_db_model.go index 35d70f6b1..a286f44b1 100644 --- a/migration/ca_db_model.go +++ b/migration/ca_db_model.go @@ -1,65 +1,65 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" -) - -type CaDeleteHandler func(tx *gorm.DB, ca *Ca) error - -type CaHandlers struct { - deletes []CaDeleteHandler -} - -var caHandlersInstance = &CaHandlers{} - -func (cah *CaHandlers) AddDeleteHandler(handler CaDeleteHandler) { - cah.deletes = append(cah.deletes, handler) -} - -func (cah *CaHandlers) Delete(tx *gorm.DB, ca *Ca) error { - for _, h := range cah.deletes { - err := h(tx, ca) - - if err != nil { - return err - } - } - - return nil -} - -type Ca struct { - BaseDbEntity - Name *string - Fingerprint *string - CertPem *string - IsVerified *bool - VerificationToken *string - IsAutoCaEnrollmentEnabled *bool - IsOttCaEnrollmentEnabled *bool - IsAuthEnabled *bool -} - -func (e *Ca) BeforeDelete(tx *gorm.DB) error { - if err := caHandlersInstance.Delete(tx, e); err != nil { - return err - } - - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" +) + +type CaDeleteHandler func(tx *gorm.DB, ca *Ca) error + +type CaHandlers struct { + deletes []CaDeleteHandler +} + +var caHandlersInstance = &CaHandlers{} + +func (cah *CaHandlers) AddDeleteHandler(handler CaDeleteHandler) { + cah.deletes = append(cah.deletes, handler) +} + +func (cah *CaHandlers) Delete(tx *gorm.DB, ca *Ca) error { + for _, h := range cah.deletes { + err := h(tx, ca) + + if err != nil { + return err + } + } + + return nil +} + +type Ca struct { + BaseDbEntity + Name *string + Fingerprint *string + CertPem *string + IsVerified *bool + VerificationToken *string + IsAutoCaEnrollmentEnabled *bool + IsOttCaEnrollmentEnabled *bool + IsAuthEnabled *bool +} + +func (e *Ca) BeforeDelete(tx *gorm.DB) error { + if err := caHandlersInstance.Delete(tx, e); err != nil { + return err + } + + return nil +} diff --git a/migration/certOLD/a_certOLD-packr.go b/migration/certOLD/a_certOLD-packr.go index 83dfa34a5..f730364c8 100644 --- a/migration/certOLD/a_certOLD-packr.go +++ b/migration/certOLD/a_certOLD-packr.go @@ -1,20 +1,20 @@ -// Code generated by github.com/gobuffalo/packr. DO NOT EDIT. - -package certOLD - -import "github.com/gobuffalo/packr" - -// You can use the "packr clean" command to clean up this, -// and any other packr generated files. -func init() { - packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20180905100349_initial-tables.down.sql", "\"H4sIAAAAAAAA/wEAAP//AAAAAAAAAAA=\"") - packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20180905100349_initial-tables.up.sql", "\"H4sIAAAAAAAA/+RUwXLTMBC9+yv2VmeGYcq1PYlYAQ9GAdVm6Ekj7G2itpEz8pqEMvw7Y5MIp3WDPYETOtma1XtPem93KjlLOaTsdcLhwZBRWCzwpa5piZZMrql0KkdHVRAGAACmAL+yLI7gg4zfM3kN7/g19C8xT0FkSfJiB9AA0zdlil8Af16HADfGLtCtnbEEn5icvmUyfHV+PhkMkDvUhIXSBEBmhRXp1Ro2hpbtLzyUFiHiM5YlKdhyE04eAdTr4jQA0otqr+22Ku2IN/C4Z99/nMHFRXv+SzC5DAKWpFwOsrIBZFEE07m4SiWLRQo9ZWpnlcHmU6mbO5jNJY/fiNbssOPkBCSfccnFlF91uH8DNNWNxl3eMhF/zDjEIuKfe6k7JitVG1vgtlU9F8evBmHn5BjCzmVGEnaf4TLwjI998GVoXXl/v0JLqqTevqprU5zUVy3A8EztQlne4T6JX7XLl9qN7CutPO1QBf7w7Yb8LuGWRsvH7do4rI435VH5/9VYeDaO8HQ2HNb60sOe+RvT4d9JbbP5VGS7/Yy8XO91/QwAAP//+s+d+CUHAAA=\"") - packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190430154639_add-enrollment-certs.down.sql", "\"H4sIAAAAAAAA/0opyi9QKElMyklVqMosyYxPTUlP1UvNK8rPyclNzSuJT04tKikGBAAA//+rh7R4JQAAAA==\"") - packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190430154639_add-enrollment-certs.up.sql", "\"H4sIAAAAAAAA/6SQUU7DMAyG33uK/22bhDjAOEzkJe7ImjpV4qh0iLujhFFg6gMCv9n6P3+ybWJShtIpMK5evWF35keWFEMYWdRYTpq7fQcA3qEU7yBRISWENqxlo2RN5EVxj5pp4AVT8iOlBQMvD436FvvT1h+8Mf2AxD0nFst585D84bX06fuVpsXr+jVda1Nl6aa4zArlF10Pupnbq50hhfqRs9I4Yfb63FpcozAc91RCJef94Y4vk/sXr3TOuOQoa2r3+rY7Huvo9PX8w1P3HgAA//8fQtADFQIAAA==\"") - packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190503092315_add-authenticator-cert-auth-fk.down.sql", "\"H4sIAAAAAAAA/5yRwW4CIRRF93zF3akLTVwbv2XyhDsOGQYMPNrYr2+Y2mQ0to1lSS7nnfuQoMxQOQXiw6vv6M7cSdWBUb0VTbmzzFoMAIhzsCnUKcK7FtBr5x1q9e5gzH9YsWgWH3XJ67p+nCPt9CnTnyNGXrFehDbI7JkZLcti2i3hWQ7GmO0WU3rjnexJ7AhNeOZVL070D3mINYV3wjhiXRhoFbJb3vc5TT/RCgTvAzPnNzhC7MM47zbmK7HHEfvXNzynn/xX049JEWsIL1NdTpdv6KNv27ljoNL8Wv1Wa6IOqVVfNfzqYMxnAAAA//8b8A4mjwIAAA==\"") - packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190503092315_add-authenticator-cert-auth-fk.up.sql", "\"H4sIAAAAAAAA/5xUwW7bOhC86yvmJuklDiC8FA1kpJc2hwK9tTkLDLmyCFOkQK7suMjHF5QsJYrhNCkvhM3hzs7sUMIwebB4MITfmnVFakNXoueGLGsp2PlKkueQAIBQCsszrdD3Wq2T5OOVpLOBvdCWT4pWVb0dcHHVzpPeWGzpgOw1MoenmjxZSeEcb1gnSbJaje1DUS16w7i///4Nu2tsyJKPsEgErRAcNEN6EkwKHXl4t3+PvqO0ASid6Vs7lCOeOaNXlbbZrC0utyNvxCGb9lZ9yrywyrVZXpZMj4ynJ6RlGjdpnNxWrFsKLNpuQuTojJDabpBep6i9a1H8ny9opjUB2VUNPWa1cc7PfPgPWVFghRtcoMhxgZu8LLXlqZOx9Oe8LGVgr+0mXw/eStcdQI86cKwdbcEwbay+4JVJ2gbyDG3ZnXUy0yr+4EOl1SVa4sapUU728+7H3ddfC2kvwYuDNPaQQgTwoaPxaFDwZkLzMS+eWrejeXZaPUfl39OgvOumkuvnVC4uXmkVWz55aZkIoW8poCiLIayx29FrYdXsAvaNlg1C43qj8EBg31Oe9J0S/Je3CSGHvJ5Q3yILZEgyROzuLQ8DBPYNeRqg82BwCyFf/pEfUcVtMRrRii0tmaNh1jFsb8z7PzBLz0+kRH1T0ZH4OOjZP62Oly9h3R5iJ7QZaJ09L7oTnix/oMshCXMwZlvWSfInAAD//yH7bieVBQAA\"") - packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190514084942_remove-old-ott-table.down.sql", "\"H4sIAAAAAAAA/6SRQU/DMAyF7/sVvq2TEBrX8WMiL3ndvKZJlbh0HeK/o3algyIQE77Z8nvvs2wTWEHKew+6iIqBO+BRHIKK9gYhRe9rBDVRNa+KFRGROGpbcRSiUmi9H4dD2RiyJpag9JOFaSr0s2CoJknNqacK/cNkP0nvz7nFfDIxpqy+JCaUSAgW+fvNgnyl0Fgh0Asne+RUPG23m5njumD5A/AerlH1NyLLE8qpU1KcdQGAcyMJ2bCSSo2sXDfUiR7Hli4xYIk8vtv9qnAoufVDVlcsT24b9y+98iHTKccwb61f39a73TDa3968eX4PAAD//9v/oDWYAgAA\"") - packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190514084942_remove-old-ott-table.up.sql", "\"H4sIAAAAAAAA/6RSzW7UQAy+z1P4loRmkVYUUaVXLjxAz9Ew401NZ8aRx9luUR8ebaJJBwRCCF9sf7K+z3+UMooCJWX4Tkoj+gnfYxIOIWLS3JLvgTwmJX0Zr4nyE6YeIuoj+x7wMpNgHq324AStol/jZfZ7rHbKnckY0CmQ7w1sVvMWbKMvWcOqzZ5VWgWqJAtUKe+kdsrmJByrIXfxt2lHVs33xpjDAaz3YMHjyS5B4eHhy2c438KECcUqC5xYgDxkBtLSBcwoIPxsbFAUUPs14G/XOjoUzWt3W6njsMS0EqLuqstCfqTUljFW4zNKsC9t8dF/bMUmz7HthkHxovD6Cs3QXJ0L7J5GpYhZbZxLRQdzsI7SBM1tA+tijh+6n2SKlULl8REv7Skwy64H76A9HuEAd3ADxw5u4K4bBkpaOtmoP3XD4LIKpam7N+ZvT7dtp62A6985u7pvz1q/UgX/24EFI59xXzX5t9v+z/m88FxIr0Jr/ivTHzv7EQAA///u4X2ajwMAAA==\"") - packr.PackJSONBytes("../certOLD/embedded", "schemas/ca.json", "\"H4sIAAAAAAAA/0zLMQ7CMAxG4T2niAwjjffepsIONSo2in8GQNwd0Yn16X3vUisdTWiutAL3mfllsEnlos0VPR4u49ksOM+r3pbkANo1w+m026H9h0W7ucHCsy3bth8H/qtsMiUGlU8p3wAAAP//R6EDwXYAAAA=\"") - packr.PackJSONBytes("../certOLD/embedded", "schemas/ott.json", "\"H4sIAAAAAAAA/xTLwQ3DIAwAwL+nQFafLf6zDS1ucZXYKDgPEmX3iAHuhBDwIQVTwOreEtEhLi8uP47K/rVdyzaiGPVP5TV3Mvf476b4nNZH44nfZgtnRbgA7gAAAP//5oK0DlUAAAA=\"") -} +// Code generated by github.com/gobuffalo/packr. DO NOT EDIT. + +package certOLD + +import "github.com/gobuffalo/packr" + +// You can use the "packr clean" command to clean up this, +// and any other packr generated files. +func init() { + packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20180905100349_initial-tables.down.sql", "\"H4sIAAAAAAAA/wEAAP//AAAAAAAAAAA=\"") + packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20180905100349_initial-tables.up.sql", "\"H4sIAAAAAAAA/+RUwXLTMBC9+yv2VmeGYcq1PYlYAQ9GAdVm6Ekj7G2itpEz8pqEMvw7Y5MIp3WDPYETOtma1XtPem93KjlLOaTsdcLhwZBRWCzwpa5piZZMrql0KkdHVRAGAACmAL+yLI7gg4zfM3kN7/g19C8xT0FkSfJiB9AA0zdlil8Af16HADfGLtCtnbEEn5icvmUyfHV+PhkMkDvUhIXSBEBmhRXp1Ro2hpbtLzyUFiHiM5YlKdhyE04eAdTr4jQA0otqr+22Ku2IN/C4Z99/nMHFRXv+SzC5DAKWpFwOsrIBZFEE07m4SiWLRQo9ZWpnlcHmU6mbO5jNJY/fiNbssOPkBCSfccnFlF91uH8DNNWNxl3eMhF/zDjEIuKfe6k7JitVG1vgtlU9F8evBmHn5BjCzmVGEnaf4TLwjI998GVoXXl/v0JLqqTevqprU5zUVy3A8EztQlne4T6JX7XLl9qN7CutPO1QBf7w7Yb8LuGWRsvH7do4rI435VH5/9VYeDaO8HQ2HNb60sOe+RvT4d9JbbP5VGS7/Yy8XO91/QwAAP//+s+d+CUHAAA=\"") + packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190430154639_add-enrollment-certs.down.sql", "\"H4sIAAAAAAAA/0opyi9QKElMyklVqMosyYxPTUlP1UvNK8rPyclNzSuJT04tKikGBAAA//+rh7R4JQAAAA==\"") + packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190430154639_add-enrollment-certs.up.sql", "\"H4sIAAAAAAAA/6SQUU7DMAyG33uK/22bhDjAOEzkJe7ImjpV4qh0iLujhFFg6gMCv9n6P3+ybWJShtIpMK5evWF35keWFEMYWdRYTpq7fQcA3qEU7yBRISWENqxlo2RN5EVxj5pp4AVT8iOlBQMvD436FvvT1h+8Mf2AxD0nFst585D84bX06fuVpsXr+jVda1Nl6aa4zArlF10Pupnbq50hhfqRs9I4Yfb63FpcozAc91RCJef94Y4vk/sXr3TOuOQoa2r3+rY7Huvo9PX8w1P3HgAA//8fQtADFQIAAA==\"") + packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190503092315_add-authenticator-cert-auth-fk.down.sql", "\"H4sIAAAAAAAA/5yRwW4CIRRF93zF3akLTVwbv2XyhDsOGQYMPNrYr2+Y2mQ0to1lSS7nnfuQoMxQOQXiw6vv6M7cSdWBUb0VTbmzzFoMAIhzsCnUKcK7FtBr5x1q9e5gzH9YsWgWH3XJ67p+nCPt9CnTnyNGXrFehDbI7JkZLcti2i3hWQ7GmO0WU3rjnexJ7AhNeOZVL070D3mINYV3wjhiXRhoFbJb3vc5TT/RCgTvAzPnNzhC7MM47zbmK7HHEfvXNzynn/xX049JEWsIL1NdTpdv6KNv27ljoNL8Wv1Wa6IOqVVfNfzqYMxnAAAA//8b8A4mjwIAAA==\"") + packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190503092315_add-authenticator-cert-auth-fk.up.sql", "\"H4sIAAAAAAAA/5xUwW7bOhC86yvmJuklDiC8FA1kpJc2hwK9tTkLDLmyCFOkQK7suMjHF5QsJYrhNCkvhM3hzs7sUMIwebB4MITfmnVFakNXoueGLGsp2PlKkueQAIBQCsszrdD3Wq2T5OOVpLOBvdCWT4pWVb0dcHHVzpPeWGzpgOw1MoenmjxZSeEcb1gnSbJaje1DUS16w7i///4Nu2tsyJKPsEgErRAcNEN6EkwKHXl4t3+PvqO0ASid6Vs7lCOeOaNXlbbZrC0utyNvxCGb9lZ9yrywyrVZXpZMj4ynJ6RlGjdpnNxWrFsKLNpuQuTojJDabpBep6i9a1H8ny9opjUB2VUNPWa1cc7PfPgPWVFghRtcoMhxgZu8LLXlqZOx9Oe8LGVgr+0mXw/eStcdQI86cKwdbcEwbay+4JVJ2gbyDG3ZnXUy0yr+4EOl1SVa4sapUU728+7H3ddfC2kvwYuDNPaQQgTwoaPxaFDwZkLzMS+eWrejeXZaPUfl39OgvOumkuvnVC4uXmkVWz55aZkIoW8poCiLIayx29FrYdXsAvaNlg1C43qj8EBg31Oe9J0S/Je3CSGHvJ5Q3yILZEgyROzuLQ8DBPYNeRqg82BwCyFf/pEfUcVtMRrRii0tmaNh1jFsb8z7PzBLz0+kRH1T0ZH4OOjZP62Oly9h3R5iJ7QZaJ09L7oTnix/oMshCXMwZlvWSfInAAD//yH7bieVBQAA\"") + packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190514084942_remove-old-ott-table.down.sql", "\"H4sIAAAAAAAA/6SRQU/DMAyF7/sVvq2TEBrX8WMiL3ndvKZJlbh0HeK/o3algyIQE77Z8nvvs2wTWEHKew+6iIqBO+BRHIKK9gYhRe9rBDVRNa+KFRGROGpbcRSiUmi9H4dD2RiyJpag9JOFaSr0s2CoJknNqacK/cNkP0nvz7nFfDIxpqy+JCaUSAgW+fvNgnyl0Fgh0Asne+RUPG23m5njumD5A/AerlH1NyLLE8qpU1KcdQGAcyMJ2bCSSo2sXDfUiR7Hli4xYIk8vtv9qnAoufVDVlcsT24b9y+98iHTKccwb61f39a73TDa3968eX4PAAD//9v/oDWYAgAA\"") + packr.PackJSONBytes("../certOLD/embedded", "db/postgres/migrations/20190514084942_remove-old-ott-table.up.sql", "\"H4sIAAAAAAAA/6RSzW7UQAy+z1P4loRmkVYUUaVXLjxAz9Ew401NZ8aRx9luUR8ebaJJBwRCCF9sf7K+z3+UMooCJWX4Tkoj+gnfYxIOIWLS3JLvgTwmJX0Zr4nyE6YeIuoj+x7wMpNgHq324AStol/jZfZ7rHbKnckY0CmQ7w1sVvMWbKMvWcOqzZ5VWgWqJAtUKe+kdsrmJByrIXfxt2lHVs33xpjDAaz3YMHjyS5B4eHhy2c438KECcUqC5xYgDxkBtLSBcwoIPxsbFAUUPs14G/XOjoUzWt3W6njsMS0EqLuqstCfqTUljFW4zNKsC9t8dF/bMUmz7HthkHxovD6Cs3QXJ0L7J5GpYhZbZxLRQdzsI7SBM1tA+tijh+6n2SKlULl8REv7Skwy64H76A9HuEAd3ADxw5u4K4bBkpaOtmoP3XD4LIKpam7N+ZvT7dtp62A6985u7pvz1q/UgX/24EFI59xXzX5t9v+z/m88FxIr0Jr/ivTHzv7EQAA///u4X2ajwMAAA==\"") + packr.PackJSONBytes("../certOLD/embedded", "schemas/ca.json", "\"H4sIAAAAAAAA/0zLMQ7CMAxG4T2niAwjjffepsIONSo2in8GQNwd0Yn16X3vUisdTWiutAL3mfllsEnlos0VPR4u49ksOM+r3pbkANo1w+m026H9h0W7ucHCsy3bth8H/qtsMiUGlU8p3wAAAP//R6EDwXYAAAA=\"") + packr.PackJSONBytes("../certOLD/embedded", "schemas/ott.json", "\"H4sIAAAAAAAA/xTLwQ3DIAwAwL+nQFafLf6zDS1ucZXYKDgPEmX3iAHuhBDwIQVTwOreEtEhLi8uP47K/rVdyzaiGPVP5TV3Mvf476b4nNZH44nfZgtnRbgA7gAAAP//5oK0DlUAAAA=\"") +} diff --git a/migration/certOLD/migrate.go b/migration/certOLD/migrate.go index 45afa9432..3f6c9b6d1 100644 --- a/migration/certOLD/migrate.go +++ b/migration/certOLD/migrate.go @@ -1,26 +1,26 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package certOLD - -import "github.com/gobuffalo/packr" - -func GetCertMigrations() []*packr.Box { - b := packr.NewBox("../certOLD/embedded") - bs := []*packr.Box{&b} - - return bs -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package certOLD + +import "github.com/gobuffalo/packr" + +func GetCertMigrations() []*packr.Box { + b := packr.NewBox("../certOLD/embedded") + bs := []*packr.Box{&b} + + return bs +} diff --git a/migration/cluster_db_model.go b/migration/cluster_db_model.go index 3ff2b188f..e2ebfa4a2 100644 --- a/migration/cluster_db_model.go +++ b/migration/cluster_db_model.go @@ -1,47 +1,47 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" -) - -type Cluster struct { - BaseDbEntity - Name *string - Gateways []*Gateway `gorm:"PRELOAD:false"` -} - -func (e *Cluster) removeServicesFromCluster(tx *gorm.DB) error { - res := tx.Raw("DELETE service_clusters sc WHERE sc.cluster_id = ?", e.ID) - - if res.Error != nil { - return res.Error - } - - return nil -} - -func (e *Cluster) BeforeDelete(tx *gorm.DB) error { - err := e.removeServicesFromCluster(tx) - - if err != nil { - return err - } - - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" +) + +type Cluster struct { + BaseDbEntity + Name *string + Gateways []*Gateway `gorm:"PRELOAD:false"` +} + +func (e *Cluster) removeServicesFromCluster(tx *gorm.DB) error { + res := tx.Raw("DELETE service_clusters sc WHERE sc.cluster_id = ?", e.ID) + + if res.Error != nil { + return res.Error + } + + return nil +} + +func (e *Cluster) BeforeDelete(tx *gorm.DB) error { + err := e.removeServicesFromCluster(tx) + + if err != nil { + return err + } + + return nil +} diff --git a/migration/enrollment_cert_db_model.go b/migration/enrollment_cert_db_model.go index d0e4c5471..f928181f7 100644 --- a/migration/enrollment_cert_db_model.go +++ b/migration/enrollment_cert_db_model.go @@ -1,25 +1,25 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -type EnrollmentCert struct { - BaseDbEntity - EnrollmentID *string - CaID *string - Ca *Ca - Jwt *string -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +type EnrollmentCert struct { + BaseDbEntity + EnrollmentID *string + CaID *string + Ca *Ca + Jwt *string +} diff --git a/migration/enrollment_db_model.go b/migration/enrollment_db_model.go index 120ac9a03..d538b0533 100644 --- a/migration/enrollment_db_model.go +++ b/migration/enrollment_db_model.go @@ -1,60 +1,60 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" - "time" -) - -type Enrollment struct { - BaseDbEntity - IdentityID *string - Token *string - Method *string - Config interface{} `gorm:"-"` - Enroll func(i *Identity, tx *gorm.DB) error `gorm:"-"` - ExpiresAt *time.Time -} - -func (e *Enrollment) BeforeDelete(tx *gorm.DB) error { - return enrollmentHandlersInstance.Delete(tx, e) -} - -type EnrollmentDeleteHandler func(tx *gorm.DB, i *Enrollment) error - -type EnrollmentHandlers struct { - deletes []EnrollmentDeleteHandler -} - -var enrollmentHandlersInstance = &EnrollmentHandlers{} - -func (ih *EnrollmentHandlers) AddDeleteHandler(handler EnrollmentDeleteHandler) { - ih.deletes = append(ih.deletes, handler) -} - -func (ih *EnrollmentHandlers) Delete(tx *gorm.DB, i *Enrollment) error { - for _, h := range ih.deletes { - err := h(tx, i) - - if err != nil { - return err - } - } - - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" + "time" +) + +type Enrollment struct { + BaseDbEntity + IdentityID *string + Token *string + Method *string + Config interface{} `gorm:"-"` + Enroll func(i *Identity, tx *gorm.DB) error `gorm:"-"` + ExpiresAt *time.Time +} + +func (e *Enrollment) BeforeDelete(tx *gorm.DB) error { + return enrollmentHandlersInstance.Delete(tx, e) +} + +type EnrollmentDeleteHandler func(tx *gorm.DB, i *Enrollment) error + +type EnrollmentHandlers struct { + deletes []EnrollmentDeleteHandler +} + +var enrollmentHandlersInstance = &EnrollmentHandlers{} + +func (ih *EnrollmentHandlers) AddDeleteHandler(handler EnrollmentDeleteHandler) { + ih.deletes = append(ih.deletes, handler) +} + +func (ih *EnrollmentHandlers) Delete(tx *gorm.DB, i *Enrollment) error { + for _, h := range ih.deletes { + err := h(tx, i) + + if err != nil { + return err + } + } + + return nil +} diff --git a/migration/enrollment_updb_db_model.go b/migration/enrollment_updb_db_model.go index d5cf6943c..fab186185 100644 --- a/migration/enrollment_updb_db_model.go +++ b/migration/enrollment_updb_db_model.go @@ -1,24 +1,24 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -type EnrollmentUpdb struct { - BaseDbEntity - EnrollmentID *string - Username *string - Url *string -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +type EnrollmentUpdb struct { + BaseDbEntity + EnrollmentID *string + Username *string + Url *string +} diff --git a/migration/errors.go b/migration/errors.go index cf71af4d6..37594d71c 100644 --- a/migration/errors.go +++ b/migration/errors.go @@ -1,29 +1,29 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -type RecordNotFoundError struct{} - -func (RecordNotFoundError) Error() string { - return "record not found" -} - -func IsErrNotFoundErr(err error) bool { - _, ok := err.(*RecordNotFoundError) - - return ok -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +type RecordNotFoundError struct{} + +func (RecordNotFoundError) Error() string { + return "record not found" +} + +func IsErrNotFoundErr(err error) bool { + _, ok := err.(*RecordNotFoundError) + + return ok +} diff --git a/migration/event_log_db_model.go b/migration/event_log_db_model.go index 9006a1ea3..1591543cd 100644 --- a/migration/event_log_db_model.go +++ b/migration/event_log_db_model.go @@ -1,30 +1,30 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -type EventLog struct { - BaseDbEntity - Type string - ActorType string - ActorId string - EntityType string - EntityId string - FormattedMessage string - FormatString string - FormatData string - Data PropertyMap -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +type EventLog struct { + BaseDbEntity + Type string + ActorType string + ActorId string + EntityType string + EntityId string + FormattedMessage string + FormatString string + FormatData string + Data PropertyMap +} diff --git a/migration/events.go b/migration/events.go index aefcfb7a0..b09586b61 100644 --- a/migration/events.go +++ b/migration/events.go @@ -1,39 +1,39 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import "github.com/kataras/go-events" - -const ( - EventCreate events.EventName = "CREATE" - EventDelete events.EventName = "DELETE" - EventUpdate events.EventName = "UPDATE" - EventPatch events.EventName = "PATCH" -) - -type CrudEventDetails struct { - Entities []BaseDbModel - QueryResult *QueryResult - FieldsAffected []string -} - -func NewCrudEventDetails(qr *QueryResult, entities ...BaseDbModel) *CrudEventDetails { - return &CrudEventDetails{ - Entities: entities, - QueryResult: qr, - } -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import "github.com/kataras/go-events" + +const ( + EventCreate events.EventName = "CREATE" + EventDelete events.EventName = "DELETE" + EventUpdate events.EventName = "UPDATE" + EventPatch events.EventName = "PATCH" +) + +type CrudEventDetails struct { + Entities []BaseDbModel + QueryResult *QueryResult + FieldsAffected []string +} + +func NewCrudEventDetails(qr *QueryResult, entities ...BaseDbModel) *CrudEventDetails { + return &CrudEventDetails{ + Entities: entities, + QueryResult: qr, + } +} diff --git a/migration/gateway_db_model.go b/migration/gateway_db_model.go index 27fde214b..e72c85244 100644 --- a/migration/gateway_db_model.go +++ b/migration/gateway_db_model.go @@ -1,40 +1,40 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "time" -) - -var Online = true -var Offline = false - -type Gateway struct { - BaseDbEntity - Name *string - Fingerprint *string - CertPem *string - ClusterID *string - Cluster *Cluster - IsVerified *bool - EnrollmentToken *string - Hostname *string `gorm:"-"` - EnrollmentJwt *string - EnrollmentCreatedAt *time.Time - EnrollmentExpiresAt *time.Time - GatewayProtocols map[string]string `gorm:"-"` -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "time" +) + +var Online = true +var Offline = false + +type Gateway struct { + BaseDbEntity + Name *string + Fingerprint *string + CertPem *string + ClusterID *string + Cluster *Cluster + IsVerified *bool + EnrollmentToken *string + Hostname *string `gorm:"-"` + EnrollmentJwt *string + EnrollmentCreatedAt *time.Time + EnrollmentExpiresAt *time.Time + GatewayProtocols map[string]string `gorm:"-"` +} diff --git a/migration/geo_region_db_model.go b/migration/geo_region_db_model.go index 2c55160de..1308dd4d0 100644 --- a/migration/geo_region_db_model.go +++ b/migration/geo_region_db_model.go @@ -1,22 +1,22 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -type GeoRegion struct { - BaseDbEntity - Name *string -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +type GeoRegion struct { + BaseDbEntity + Name *string +} diff --git a/migration/identity_type_db_model.go b/migration/identity_type_db_model.go index 4a0572ed4..b1e26eb78 100644 --- a/migration/identity_type_db_model.go +++ b/migration/identity_type_db_model.go @@ -1,22 +1,22 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -type IdentityType struct { - BaseDbEntity - Name *string -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +type IdentityType struct { + BaseDbEntity + Name *string +} diff --git a/migration/network_session_cert_db_model.go b/migration/network_session_cert_db_model.go index bced9bfdb..dc2286e2e 100644 --- a/migration/network_session_cert_db_model.go +++ b/migration/network_session_cert_db_model.go @@ -1,42 +1,42 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "time" -) - -type NetworkSessionCert struct { - BaseDbEntity - NetworkSessionID *string - Cert *string - Fingerprint *string - ValidFrom *time.Time - ValidTo *time.Time -} - -func (e *NetworkSessionCert) GetId() string { - return e.ID -} - -func (e *NetworkSessionCert) SetId(id string) { - e.ID = id -} - -func (e *NetworkSessionCert) SetUpdatedAt(t *time.Time) { - e.UpdatedAt = t -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "time" +) + +type NetworkSessionCert struct { + BaseDbEntity + NetworkSessionID *string + Cert *string + Fingerprint *string + ValidFrom *time.Time + ValidTo *time.Time +} + +func (e *NetworkSessionCert) GetId() string { + return e.ID +} + +func (e *NetworkSessionCert) SetId(id string) { + e.ID = id +} + +func (e *NetworkSessionCert) SetUpdatedAt(t *time.Time) { + e.UpdatedAt = t +} diff --git a/migration/network_session_db_model.go b/migration/network_session_db_model.go index 40d55fd6f..b0ebef462 100644 --- a/migration/network_session_db_model.go +++ b/migration/network_session_db_model.go @@ -1,51 +1,51 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" - "gopkg.in/Masterminds/squirrel.v1" -) - -type NetworkSession struct { - BaseDbEntity - Token *string - SessionID *string - Session *Session - ServiceID *string - Hosting *bool - Certs []*NetworkSessionCert -} - -func (e *NetworkSession) deleteCerts(tx *gorm.DB) error { - sql, args, err := squirrel.Eq{"network_session_id": e.ID}.ToSql() - - if err != nil { - return err - } - - tx.Delete(&NetworkSessionCert{}, sql, args) - - return nil -} - -func (e *NetworkSession) BeforeDelete(tx *gorm.DB) error { - if err := e.deleteCerts(tx); err != nil { - return err - } - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" + "gopkg.in/Masterminds/squirrel.v1" +) + +type NetworkSession struct { + BaseDbEntity + Token *string + SessionID *string + Session *Session + ServiceID *string + Hosting *bool + Certs []*NetworkSessionCert +} + +func (e *NetworkSession) deleteCerts(tx *gorm.DB) error { + sql, args, err := squirrel.Eq{"network_session_id": e.ID}.ToSql() + + if err != nil { + return err + } + + tx.Delete(&NetworkSessionCert{}, sql, args) + + return nil +} + +func (e *NetworkSession) BeforeDelete(tx *gorm.DB) error { + if err := e.deleteCerts(tx); err != nil { + return err + } + return nil +} diff --git a/migration/preloads.go b/migration/preloads.go index 580b95240..a34d3b93a 100644 --- a/migration/preloads.go +++ b/migration/preloads.go @@ -1,38 +1,38 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import "github.com/jinzhu/gorm" - -type Preloads map[string][]interface{} - -func (p Preloads) ApplyToQuery(q *gorm.DB) *gorm.DB { - if p != nil { - for f, c := range p { - if c == nil { - q = q.Preload(f) - } else { - // c[0] = query - // c[1..n] = binds for c[0] - q = q.Preload(f, c...) - } - - } - } - - return q -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import "github.com/jinzhu/gorm" + +type Preloads map[string][]interface{} + +func (p Preloads) ApplyToQuery(q *gorm.DB) *gorm.DB { + if p != nil { + for f, c := range p { + if c == nil { + q = q.Preload(f) + } else { + // c[0] = query + // c[1..n] = binds for c[0] + q = q.Preload(f, c...) + } + + } + } + + return q +} diff --git a/migration/property_map.go b/migration/property_map.go index 993b85784..04312f709 100644 --- a/migration/property_map.go +++ b/migration/property_map.go @@ -1,49 +1,49 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "database/sql/driver" - "encoding/json" - "errors" -) - -type PropertyMap map[string]interface{} - -func (p PropertyMap) Value() (driver.Value, error) { - j, err := json.Marshal(p) - return j, err -} - -func (p *PropertyMap) Scan(src interface{}) error { - source, ok := src.([]byte) - if !ok { - return errors.New("type assertion .([]byte) failed") - } - - var i interface{} - if err := json.Unmarshal(source, &i); err != nil { - return err - } - - *p, ok = i.(map[string]interface{}) - if !ok { - return errors.New("type assertion .(map[string]interface{}) failed") - } - - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "database/sql/driver" + "encoding/json" + "errors" +) + +type PropertyMap map[string]interface{} + +func (p PropertyMap) Value() (driver.Value, error) { + j, err := json.Marshal(p) + return j, err +} + +func (p *PropertyMap) Scan(src interface{}) error { + source, ok := src.([]byte) + if !ok { + return errors.New("type assertion .([]byte) failed") + } + + var i interface{} + if err := json.Unmarshal(source, &i); err != nil { + return err + } + + *p, ok = i.(map[string]interface{}) + if !ok { + return errors.New("type assertion .(map[string]interface{}) failed") + } + + return nil +} diff --git a/migration/query_results.go b/migration/query_results.go index e2b4341db..a26c760e1 100644 --- a/migration/query_results.go +++ b/migration/query_results.go @@ -1,55 +1,55 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "fmt" - "github.com/jinzhu/gorm" -) - -type QueryResult struct { - Value interface{} - Error error - RowsAffected int64 - RecordNotFound bool -} - -func NewQueryResult(db *gorm.DB) *QueryResult { - qr := &QueryResult{} - - if db != nil { - qr.Error = db.Error - qr.Value = db.Value - qr.RowsAffected = db.RowsAffected - } - - if qr.Error != nil && gorm.IsRecordNotFoundError(qr.Error) { - qr.Error = &RecordNotFoundError{} - } - - return qr -} - -func NewQueryResultFromError(err error) *QueryResult { - return &QueryResult{ - Error: err, - } -} - -func NewQueryResultF(err string, args ...interface{}) *QueryResult { - return NewQueryResultFromError(fmt.Errorf(err, args...)) -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "fmt" + "github.com/jinzhu/gorm" +) + +type QueryResult struct { + Value interface{} + Error error + RowsAffected int64 + RecordNotFound bool +} + +func NewQueryResult(db *gorm.DB) *QueryResult { + qr := &QueryResult{} + + if db != nil { + qr.Error = db.Error + qr.Value = db.Value + qr.RowsAffected = db.RowsAffected + } + + if qr.Error != nil && gorm.IsRecordNotFoundError(qr.Error) { + qr.Error = &RecordNotFoundError{} + } + + return qr +} + +func NewQueryResultFromError(err error) *QueryResult { + return &QueryResult{ + Error: err, + } +} + +func NewQueryResultF(err string, args ...interface{}) *QueryResult { + return NewQueryResultFromError(fmt.Errorf(err, args...)) +} diff --git a/migration/service_db_model.go b/migration/service_db_model.go index 228a512eb..b4648a6b9 100644 --- a/migration/service_db_model.go +++ b/migration/service_db_model.go @@ -1,69 +1,69 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" - "gopkg.in/Masterminds/squirrel.v1" -) - -type Service struct { - BaseDbEntity - Name *string - DnsHostname *string - DnsPort *uint16 - Clusters []*Cluster `gorm:"many2many:service_clusters;"` - AppWans []*AppWan `gorm:"many2many:app_wan_services;"` - EndpointAddress *string - EgressRouter *string - HostIds []*Identity `gorm:"many2many:service_hosts"` -} - -func (e *Service) deleteNetworkSessions(tx *gorm.DB) error { - sql, args, err := squirrel.Eq{"service_id": e.ID}.ToSql() - - if err != nil { - return err - } - - ns := make([]*NetworkSession, 0) - - res := tx.Where(sql, args).Find(&ns) - - if res.Error != nil { - return res.Error - } - - for _, n := range ns { - tx.Delete(n) - } - - return nil -} - -func (e *Service) BeforeDelete(tx *gorm.DB) error { - - if err := e.ClearAssociations(e, tx, "AppWans", "Clusters", "HostIds"); err != nil { - return err - } - - if err := e.deleteNetworkSessions(tx); err != nil { - return err - } - - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" + "gopkg.in/Masterminds/squirrel.v1" +) + +type Service struct { + BaseDbEntity + Name *string + DnsHostname *string + DnsPort *uint16 + Clusters []*Cluster `gorm:"many2many:service_clusters;"` + AppWans []*AppWan `gorm:"many2many:app_wan_services;"` + EndpointAddress *string + EgressRouter *string + HostIds []*Identity `gorm:"many2many:service_hosts"` +} + +func (e *Service) deleteNetworkSessions(tx *gorm.DB) error { + sql, args, err := squirrel.Eq{"service_id": e.ID}.ToSql() + + if err != nil { + return err + } + + ns := make([]*NetworkSession, 0) + + res := tx.Where(sql, args).Find(&ns) + + if res.Error != nil { + return res.Error + } + + for _, n := range ns { + tx.Delete(n) + } + + return nil +} + +func (e *Service) BeforeDelete(tx *gorm.DB) error { + + if err := e.ClearAssociations(e, tx, "AppWans", "Clusters", "HostIds"); err != nil { + return err + } + + if err := e.deleteNetworkSessions(tx); err != nil { + return err + } + + return nil +} diff --git a/migration/session_db_model.go b/migration/session_db_model.go index 4315599ce..14c882b23 100644 --- a/migration/session_db_model.go +++ b/migration/session_db_model.go @@ -1,54 +1,54 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" - "gopkg.in/Masterminds/squirrel.v1" -) - -type Session struct { - BaseDbEntity - IdentityID *string - Token *string - Identity *Identity -} - -func (e *Session) BeforeDelete(tx *gorm.DB) error { - store := getDefaultNetworkSessionGormStore() - - sql, args, err := squirrel.Eq{"session_id": e.ID}.ToSql() - - if err != nil { - return nil - } - ns := make([]*NetworkSession, 0) - - res := tx.Where(sql, args).Find(&ns) - - if res.Error != nil { - return res.Error - } - - for _, n := range ns { - if err := store.DeleteWithTx(n, tx); err != nil { - return err - } - } - - return res.Error -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" + "gopkg.in/Masterminds/squirrel.v1" +) + +type Session struct { + BaseDbEntity + IdentityID *string + Token *string + Identity *Identity +} + +func (e *Session) BeforeDelete(tx *gorm.DB) error { + store := getDefaultNetworkSessionGormStore() + + sql, args, err := squirrel.Eq{"session_id": e.ID}.ToSql() + + if err != nil { + return nil + } + ns := make([]*NetworkSession, 0) + + res := tx.Where(sql, args).Find(&ns) + + if res.Error != nil { + return res.Error + } + + for _, n := range ns { + if err := store.DeleteWithTx(n, tx); err != nil { + return err + } + } + + return res.Error +} diff --git a/migration/stores.go b/migration/stores.go index b7f9da82c..b1f9af2d1 100644 --- a/migration/stores.go +++ b/migration/stores.go @@ -1,65 +1,65 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import ( - "github.com/jinzhu/gorm" -) - -type Stores struct { - AppWan AppWanStore - Authenticator AuthenticatorStore - Ca CaStore - Cluster ClusterStore - Enrollment EnrollmentStore - EventLog EventLogStore - Gateway GatewayStore - GeoRegion GeoRegionStore - Identity IdentityStore - IdentityType IdentityTypeStore - NetworkSession NetworkSessionStore - Service ServiceStore - Session SessionStore - NetworkSessionCert *NetworkSessionCertGormStore - AuthenticatorUpdb *AuthenticatorUpdbGormStore - AuthenticatorCert *AuthenticatorCertGormStore - EnrollmentCert *EnrollmentCertGormStore - EnrollmentUpdb *EnrollmentUpdbGormStore -} - -func NewGormStores(db *gorm.DB, dbWithPreloads *gorm.DB) *Stores { - return &Stores{ - AppWan: NewAppWanGormStore(db, dbWithPreloads), - Authenticator: NewAuthenticatorGormStore(db, dbWithPreloads), - Ca: NewCaGormStore(db, dbWithPreloads), - Cluster: NewClusterGormStore(db, dbWithPreloads), - Enrollment: NewEnrollmentGormStore(db, dbWithPreloads), - EventLog: NewEventLogGormStore(db, dbWithPreloads), - Gateway: NewGatewayGormStore(db, dbWithPreloads), - GeoRegion: NewGeoRegionGormStore(db, dbWithPreloads), - Identity: NewIdentityGormStore(db, dbWithPreloads), - IdentityType: NewIdentityTypeGormStore(db, dbWithPreloads), - NetworkSession: NewNetworkSessionGormStore(db, dbWithPreloads), - Service: NewServiceGormStore(db, dbWithPreloads), - Session: NewSessionGormStore(db, dbWithPreloads), - NetworkSessionCert: NewNetworkSessionCertGormStore(db, dbWithPreloads), - AuthenticatorUpdb: NewAuthenticatorUpdbGormStore(db, dbWithPreloads), - AuthenticatorCert: NewAuthenticatorCertGormStore(db, dbWithPreloads), - EnrollmentCert: NewEnrollmentCertGormStore(db, dbWithPreloads), - EnrollmentUpdb: NewEnrollmentUpdbGormStore(db, dbWithPreloads), - } -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import ( + "github.com/jinzhu/gorm" +) + +type Stores struct { + AppWan AppWanStore + Authenticator AuthenticatorStore + Ca CaStore + Cluster ClusterStore + Enrollment EnrollmentStore + EventLog EventLogStore + Gateway GatewayStore + GeoRegion GeoRegionStore + Identity IdentityStore + IdentityType IdentityTypeStore + NetworkSession NetworkSessionStore + Service ServiceStore + Session SessionStore + NetworkSessionCert *NetworkSessionCertGormStore + AuthenticatorUpdb *AuthenticatorUpdbGormStore + AuthenticatorCert *AuthenticatorCertGormStore + EnrollmentCert *EnrollmentCertGormStore + EnrollmentUpdb *EnrollmentUpdbGormStore +} + +func NewGormStores(db *gorm.DB, dbWithPreloads *gorm.DB) *Stores { + return &Stores{ + AppWan: NewAppWanGormStore(db, dbWithPreloads), + Authenticator: NewAuthenticatorGormStore(db, dbWithPreloads), + Ca: NewCaGormStore(db, dbWithPreloads), + Cluster: NewClusterGormStore(db, dbWithPreloads), + Enrollment: NewEnrollmentGormStore(db, dbWithPreloads), + EventLog: NewEventLogGormStore(db, dbWithPreloads), + Gateway: NewGatewayGormStore(db, dbWithPreloads), + GeoRegion: NewGeoRegionGormStore(db, dbWithPreloads), + Identity: NewIdentityGormStore(db, dbWithPreloads), + IdentityType: NewIdentityTypeGormStore(db, dbWithPreloads), + NetworkSession: NewNetworkSessionGormStore(db, dbWithPreloads), + Service: NewServiceGormStore(db, dbWithPreloads), + Session: NewSessionGormStore(db, dbWithPreloads), + NetworkSessionCert: NewNetworkSessionCertGormStore(db, dbWithPreloads), + AuthenticatorUpdb: NewAuthenticatorUpdbGormStore(db, dbWithPreloads), + AuthenticatorCert: NewAuthenticatorCertGormStore(db, dbWithPreloads), + EnrollmentCert: NewEnrollmentCertGormStore(db, dbWithPreloads), + EnrollmentUpdb: NewEnrollmentUpdbGormStore(db, dbWithPreloads), + } +} diff --git a/migration/updbOLD/a_updbOLD-packr.go b/migration/updbOLD/a_updbOLD-packr.go index df43ace81..24cf2e3df 100644 --- a/migration/updbOLD/a_updbOLD-packr.go +++ b/migration/updbOLD/a_updbOLD-packr.go @@ -1,20 +1,20 @@ -// Code generated by github.com/gobuffalo/packr. DO NOT EDIT. - -package updbOLD - -import "github.com/gobuffalo/packr" - -// You can use the "packr clean" command to clean up this, -// and any other packr generated files. -func init() { - packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20180905100348_initial-tables.down.sql", "\"H4sIAAAAAAAA/ypITM5OTE9VyM1ML0osyczPK+YCBAAA///k5Nx8EwAAAA==\"") - packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20180905100348_initial-tables.up.sql", "\"H4sIAAAAAAAA/6SSwU7jMBCG73mKuTWRVqvutT15ExciggOug+jJcmvTGmgSxY4KRbw7cmiqFFXQlDnZmpnvH4//kGLEMDD0P8Gw1VZzJZfqr6jtSuVWL4QtKl6Xcm483wMA0BL2kWVxBDc0vkZ0Bld4BseDpAxIliR/dgAHtq9cy0/Az3EIqI2qcrFW7nyHaHiJqP9vOAxOBhjxbNvMWYBSGLMpKnk2YFEpYZXkwgJYvVbGinUJG21XzRW2Ra4gwhOUJQzyYuMHX3dQyt8BrFiadrZHU+Q9fmHPHby9D2A0avrnXjD2PJQwTE8ykwOiKIIwJVNGUUwYHCnjHbNw/vAEk5Ti+II0ZvM7yQAonmCKSYinHeVdhVbGVbsJd37PSHybYYhJhO+PCrcm47zWuVQvzcAp+f5V4LdtfaScHXvKuJY+Egdr7KXU3fHY+wgAAP//BUpBPy4EAAA=\"") - packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20190506084751_add-authenticator-updb-auth-fk.down.sql", "\"H4sIAAAAAAAA/5yRQW6DMBBF9z7F3yVZJFLWiLOgAX+ChbGRPW6Vnr6CphKJ0lYpS/T85o0tXpmg0nriw6lraC88SdGBQV0nGlNTZttmAwBiLbroyxTg7ALotXEWpThbGfMfV8iaxAXd+pqmH1dk+fqY6C4BI6/Yb6ADEnsmho55M+1GOObKGHM8YopvvIttpRuhEc+6ymxF/4iHFJN5F4wa+0zPTiGn7f8+xeknW4bgfWDiegY1pDyMc/Zgvogzapxfv+GVfvJeS36IilC8f9lqU5y/pY+9lTGWnkrz6+a3rSbqEJfNd4t9V30GAAD//9B9JG2MAgAA\"") - packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20190506084751_add-authenticator-updb-auth-fk.up.sql", "\"H4sIAAAAAAAA/5xUwW7bOhC86yvmZuklDiC8FA1kpJc2hwK9tTkLDLmyCFOkQC7tuMjHF5QsJY7hNCkvhOnhzs7sUMIwebB4MITfmnVNak1XInJLlrUU7Hwde/UQMgAQSuH4P60Qo1arLPt4JelsYC+05ZOidd1sBlxajfOk1xYb2iN/jSzgqSFPVlI4xxtWWZYtl2P7UNSIaBj399+/YXuNNVnyCZaIoBWCg2ZIT4JJoScP73bv0XeQNgClM7GzQznimTN5VWubz9rSclvyRuzzae/Up9wLq1yXF1XF9Mh4esKiWqRNGic3NeuOAouunxAFeiOktmssrhdovOtQ/l8c0UxrArKrW3rMG+Ocn/nwH/KyxBI3uEBZ4AI3RVVpy1MnY+nPRVXJwF7bdbEavJWu34MedeBUO9kCSZ4Dll/wyiRtA3mGtuzOOplrlX7wvtbqEh1x61SR5T/vftx9/TXKeokYTxYpXwuIAN73lI29vpnFYkyGp85taZ6SVs+h+Pe5K+/6qeTqOX9HF6+0Su2evKlchBA7Ciircohl8nJ0VVg1S8eu1bJFaF00Cg8E9pGKLPZK8F9eIUQcknlCfYs8kCHJEKm7tzwMENi15GmAztPALUR8eVAcUOVtORrRiQ0dMyfDrGPYaMz7PyXHnp9ISfqmoiPxYdCzf1odLl/Cuh3EVmgz0Dp7XnQvPFn+QJdDEuZgzLassuxPAAAA//9db58DfwUAAA==\"") - packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20190508132642_add-updb-enrollment-table.down.sql", "\"H4sIAAAAAAAA/0opyi9QKElMyklVqMosyYxPTUlP1UvNK8rPyclNzSuJLy1ISSq2BgQAAP//u+YjMiYAAAA=\"") - packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20190508132642_add-updb-enrollment-table.up.sql", "\"H4sIAAAAAAAA/7SRwU7DMAyG73kK37ZKCAHiNB4mcht3C02cyHEYHeLdES3TOlQhDuCb/zj/9yfuhFAJFNtAcPLqLbk93RJLCiESq63ZtcVsDQCAd7CoWq/7H4uTAtcQzFnoEhcV9KzwjWbzQCNk8RFlhIHGm+nSYsq7/4NfYaztBxDqSYg7Kqs/VOZ4tZAwRpoBLyjdAWV7f/fw2Pw23peRhMWZ0qvO+rwqZ1En3UcqijHD0ethauGUmMBRjzUocDpum3VAdn9jpLgvl6TPJfHq885Gm7f3zW73OdZeNtI8GWM+AgAA//+9sucdhgIAAA==\"") - packr.PackJSONBytes("../updbOLD/embedded", "schema/updb.admin.create.post.json", "\"H4sIAAAAAAAA/5TOv07DQAzH8T1PYVmMcCkSYsgzMLAjBjfnNq4a32E7glL13VHCv6oDEsMtX50/+h0bALySjB3gEFG7tn2XkBvOW07KsSmTZjskKa33A4/kLU0xsIb0FMXSVPM6UR5FU29MwakWj7Tzong943GoPOtlveM+PhvlLCFFaf9opbKFsGMHG9o7Lx+MXyYxnmc9NQAAWMn9tVheAACcnE1pZGwAnpebek4dL66+y9kgDxPdfnkAOIo+sG5jwA7ufyu9/dTb1WrJp8sN/9Tv/tab+Z2ajwAAAP//MCQ4NpsBAAA=\"") - packr.PackJSONBytes("../updbOLD/embedded", "schema/updb.admin.set.put.json", "\"H4sIAAAAAAAA/1zOsU4DMQwG4D1PYUWMkCsLwz0DAzticC/unaueE2JHUKq+O0oQcOrg5dPvX//FAfg7jn4Ev5jlcRi+2PiB4kxByA6pSiznwGnQaaEVdcBqC4nxhJZKqDnuA8aVJeRq4ahJ/H0rtXOm1pr2R5rsxzBGNk6Cp5eSMhVjUj/CAU9KPVDovXKhNufVAQD4jKofqUTvAN56Jm9fLzepX9kMUCsscx/QfWV5Jplt8SM8/St+/unjbtf56tpd3XcAAAD//w9p0/UlAQAA\"") - packr.PackJSONBytes("../updbOLD/embedded", "schema/updb.enroll.post.json", "\"H4sIAAAAAAAA/1zOsU7DQAwG4P2ewjoxwqUsDHkGBnbEcM25iavUPmxHUKq+O8ohIOrg5dPvX/8lAMQ7KrGHOLnXvuu+yOkBy4iJ0Q+ycNFzIulsmPCUrcuLT8hOQ3bRtNSyT8gq85yqmKejCcf7tdbPFdde2R9x8B/LpZCTcJ5fVCqqE1rs4ZBnwxZQfF9IcR30GgAAYs1mH6IlBoC3lqnb18tN6lc2A8yVeGwDmp+In5FHn2IPT/+aP//0cbdrfA3rXcN3AAAA//+i77QqJwEAAA==\"") - packr.PackJSONBytes("../updbOLD/embedded", "schema/updb.user.update.put.json", "\"H4sIAAAAAAAA/6yOv04DMQzG9zyFZTFCriwM9wwM7IghvXy9c9U6IXEEpeq7o7vy59gZLFk/ff75OzsivpHIPfFklvuu+xCTO8QRXmG71DSWk5fU1WHCMdQuNJugJkOwVHzLcetbxbIFg8/N/L4m5dtZbaeM2Z22ewx2ZSFGMUkaDk8lZRQTVO5pFw4VS6DgtUnBXOrZERHx0EqBXu+JWPHGjuhlSee15Pw3/w1WTaoV0fHLRMRH0UfoaBP39PBLw/sPvd9sFnxZff9fsZvn4j4DAAD//xlvefiNAQAA\"") -} +// Code generated by github.com/gobuffalo/packr. DO NOT EDIT. + +package updbOLD + +import "github.com/gobuffalo/packr" + +// You can use the "packr clean" command to clean up this, +// and any other packr generated files. +func init() { + packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20180905100348_initial-tables.down.sql", "\"H4sIAAAAAAAA/ypITM5OTE9VyM1ML0osyczPK+YCBAAA///k5Nx8EwAAAA==\"") + packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20180905100348_initial-tables.up.sql", "\"H4sIAAAAAAAA/6SSwU7jMBCG73mKuTWRVqvutT15ExciggOug+jJcmvTGmgSxY4KRbw7cmiqFFXQlDnZmpnvH4//kGLEMDD0P8Gw1VZzJZfqr6jtSuVWL4QtKl6Xcm483wMA0BL2kWVxBDc0vkZ0Bld4BseDpAxIliR/dgAHtq9cy0/Az3EIqI2qcrFW7nyHaHiJqP9vOAxOBhjxbNvMWYBSGLMpKnk2YFEpYZXkwgJYvVbGinUJG21XzRW2Ra4gwhOUJQzyYuMHX3dQyt8BrFiadrZHU+Q9fmHPHby9D2A0avrnXjD2PJQwTE8ykwOiKIIwJVNGUUwYHCnjHbNw/vAEk5Ti+II0ZvM7yQAonmCKSYinHeVdhVbGVbsJd37PSHybYYhJhO+PCrcm47zWuVQvzcAp+f5V4LdtfaScHXvKuJY+Egdr7KXU3fHY+wgAAP//BUpBPy4EAAA=\"") + packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20190506084751_add-authenticator-updb-auth-fk.down.sql", "\"H4sIAAAAAAAA/5yRQW6DMBBF9z7F3yVZJFLWiLOgAX+ChbGRPW6Vnr6CphKJ0lYpS/T85o0tXpmg0nriw6lraC88SdGBQV0nGlNTZttmAwBiLbroyxTg7ALotXEWpThbGfMfV8iaxAXd+pqmH1dk+fqY6C4BI6/Yb6ADEnsmho55M+1GOObKGHM8YopvvIttpRuhEc+6ymxF/4iHFJN5F4wa+0zPTiGn7f8+xeknW4bgfWDiegY1pDyMc/Zgvogzapxfv+GVfvJeS36IilC8f9lqU5y/pY+9lTGWnkrz6+a3rSbqEJfNd4t9V30GAAD//9B9JG2MAgAA\"") + packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20190506084751_add-authenticator-updb-auth-fk.up.sql", "\"H4sIAAAAAAAA/5xUwW7bOhC86yvmZuklDiC8FA1kpJc2hwK9tTkLDLmyCFOkQC7tuMjHF5QsJY7hNCkvhOnhzs7sUMIwebB4MITfmnVNak1XInJLlrUU7Hwde/UQMgAQSuH4P60Qo1arLPt4JelsYC+05ZOidd1sBlxajfOk1xYb2iN/jSzgqSFPVlI4xxtWWZYtl2P7UNSIaBj399+/YXuNNVnyCZaIoBWCg2ZIT4JJoScP73bv0XeQNgClM7GzQznimTN5VWubz9rSclvyRuzzae/Up9wLq1yXF1XF9Mh4esKiWqRNGic3NeuOAouunxAFeiOktmssrhdovOtQ/l8c0UxrArKrW3rMG+Ocn/nwH/KyxBI3uEBZ4AI3RVVpy1MnY+nPRVXJwF7bdbEavJWu34MedeBUO9kCSZ4Dll/wyiRtA3mGtuzOOplrlX7wvtbqEh1x61SR5T/vftx9/TXKeokYTxYpXwuIAN73lI29vpnFYkyGp85taZ6SVs+h+Pe5K+/6qeTqOX9HF6+0Su2evKlchBA7Ciircohl8nJ0VVg1S8eu1bJFaF00Cg8E9pGKLPZK8F9eIUQcknlCfYs8kCHJEKm7tzwMENi15GmAztPALUR8eVAcUOVtORrRiQ0dMyfDrGPYaMz7PyXHnp9ISfqmoiPxYdCzf1odLl/Cuh3EVmgz0Dp7XnQvPFn+QJdDEuZgzLassuxPAAAA//9db58DfwUAAA==\"") + packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20190508132642_add-updb-enrollment-table.down.sql", "\"H4sIAAAAAAAA/0opyi9QKElMyklVqMosyYxPTUlP1UvNK8rPyclNzSuJLy1ISSq2BgQAAP//u+YjMiYAAAA=\"") + packr.PackJSONBytes("../updbOLD/embedded", "db/postgres/migrations/20190508132642_add-updb-enrollment-table.up.sql", "\"H4sIAAAAAAAA/7SRwU7DMAyG73kK37ZKCAHiNB4mcht3C02cyHEYHeLdES3TOlQhDuCb/zj/9yfuhFAJFNtAcPLqLbk93RJLCiESq63ZtcVsDQCAd7CoWq/7H4uTAtcQzFnoEhcV9KzwjWbzQCNk8RFlhIHGm+nSYsq7/4NfYaztBxDqSYg7Kqs/VOZ4tZAwRpoBLyjdAWV7f/fw2Pw23peRhMWZ0qvO+rwqZ1En3UcqijHD0ethauGUmMBRjzUocDpum3VAdn9jpLgvl6TPJfHq885Gm7f3zW73OdZeNtI8GWM+AgAA//+9sucdhgIAAA==\"") + packr.PackJSONBytes("../updbOLD/embedded", "schema/updb.admin.create.post.json", "\"H4sIAAAAAAAA/5TOv07DQAzH8T1PYVmMcCkSYsgzMLAjBjfnNq4a32E7glL13VHCv6oDEsMtX50/+h0bALySjB3gEFG7tn2XkBvOW07KsSmTZjskKa33A4/kLU0xsIb0FMXSVPM6UR5FU29MwakWj7Tzong943GoPOtlveM+PhvlLCFFaf9opbKFsGMHG9o7Lx+MXyYxnmc9NQAAWMn9tVheAACcnE1pZGwAnpebek4dL66+y9kgDxPdfnkAOIo+sG5jwA7ufyu9/dTb1WrJp8sN/9Tv/tab+Z2ajwAAAP//MCQ4NpsBAAA=\"") + packr.PackJSONBytes("../updbOLD/embedded", "schema/updb.admin.set.put.json", "\"H4sIAAAAAAAA/1zOsU4DMQwG4D1PYUWMkCsLwz0DAzticC/unaueE2JHUKq+O0oQcOrg5dPvX//FAfg7jn4Ev5jlcRi+2PiB4kxByA6pSiznwGnQaaEVdcBqC4nxhJZKqDnuA8aVJeRq4ahJ/H0rtXOm1pr2R5rsxzBGNk6Cp5eSMhVjUj/CAU9KPVDovXKhNufVAQD4jKofqUTvAN56Jm9fLzepX9kMUCsscx/QfWV5Jplt8SM8/St+/unjbtf56tpd3XcAAAD//w9p0/UlAQAA\"") + packr.PackJSONBytes("../updbOLD/embedded", "schema/updb.enroll.post.json", "\"H4sIAAAAAAAA/1zOsU7DQAwG4P2ewjoxwqUsDHkGBnbEcM25iavUPmxHUKq+O8ohIOrg5dPvX/8lAMQ7KrGHOLnXvuu+yOkBy4iJ0Q+ycNFzIulsmPCUrcuLT8hOQ3bRtNSyT8gq85yqmKejCcf7tdbPFdde2R9x8B/LpZCTcJ5fVCqqE1rs4ZBnwxZQfF9IcR30GgAAYs1mH6IlBoC3lqnb18tN6lc2A8yVeGwDmp+In5FHn2IPT/+aP//0cbdrfA3rXcN3AAAA//+i77QqJwEAAA==\"") + packr.PackJSONBytes("../updbOLD/embedded", "schema/updb.user.update.put.json", "\"H4sIAAAAAAAA/6yOv04DMQzG9zyFZTFCriwM9wwM7IghvXy9c9U6IXEEpeq7o7vy59gZLFk/ff75OzsivpHIPfFklvuu+xCTO8QRXmG71DSWk5fU1WHCMdQuNJugJkOwVHzLcetbxbIFg8/N/L4m5dtZbaeM2Z22ewx2ZSFGMUkaDk8lZRQTVO5pFw4VS6DgtUnBXOrZERHx0EqBXu+JWPHGjuhlSee15Pw3/w1WTaoV0fHLRMRH0UfoaBP39PBLw/sPvd9sFnxZff9fsZvn4j4DAAD//xlvefiNAQAA\"") +} diff --git a/migration/updbOLD/migrate.go b/migration/updbOLD/migrate.go index 228084cd8..7819e73bf 100644 --- a/migration/updbOLD/migrate.go +++ b/migration/updbOLD/migrate.go @@ -1,26 +1,26 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package updbOLD - -import "github.com/gobuffalo/packr" - -func GetUpdbMigrations() []*packr.Box { - b := packr.NewBox("../updbOLD/embedded") - bs := []*packr.Box{&b} - - return bs -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package updbOLD + +import "github.com/gobuffalo/packr" + +func GetUpdbMigrations() []*packr.Box { + b := packr.NewBox("../updbOLD/embedded") + bs := []*packr.Box{&b} + + return bs +} diff --git a/migration/util.go b/migration/util.go index 91483f96f..3e6e0581d 100644 --- a/migration/util.go +++ b/migration/util.go @@ -1,29 +1,29 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package migration - -import "github.com/google/uuid" - -func NewId() string { - id, _ := uuid.NewUUID() - return id.String() -} - -func NewIdPtr() *string { - id := NewId() - return &id -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package migration + +import "github.com/google/uuid" + +func NewId() string { + id, _ := uuid.NewUUID() + return id.String() +} + +func NewIdPtr() *string { + id := NewId() + return &id +} diff --git a/pb/edge_ctrl_pb/edge_ctrl.pb.go b/pb/edge_ctrl_pb/edge_ctrl.pb.go index 1793e4f83..85b7f8e00 100644 --- a/pb/edge_ctrl_pb/edge_ctrl.pb.go +++ b/pb/edge_ctrl_pb/edge_ctrl.pb.go @@ -1,898 +1,898 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: edge_ctrl.proto - -package edge_ctrl_pb - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type ContentType int32 - -const ( - ContentType_Zero ContentType = 0 - ContentType_ServerHelloType ContentType = 20000 - ContentType_ClientHelloType ContentType = 20001 - ContentType_ErrorType ContentType = 20002 - ContentType_SessionAddedType ContentType = 20100 - ContentType_SessionUpdatedType ContentType = 20101 - ContentType_SessionRemovedType ContentType = 20102 - ContentType_ApiSessionAddedType ContentType = 20200 - ContentType_ApiSessionUpdatedType ContentType = 20201 - ContentType_ApiSessionRemovedType ContentType = 20202 - ContentType_ApiSessionHeartbeatType ContentType = 20203 - ContentType_EnrollType ContentType = 20300 - ContentType_EnrollCertsType ContentType = 20301 -) - -var ContentType_name = map[int32]string{ - 0: "Zero", - 20000: "ServerHelloType", - 20001: "ClientHelloType", - 20002: "ErrorType", - 20100: "SessionAddedType", - 20101: "SessionUpdatedType", - 20102: "SessionRemovedType", - 20200: "ApiSessionAddedType", - 20201: "ApiSessionUpdatedType", - 20202: "ApiSessionRemovedType", - 20203: "ApiSessionHeartbeatType", - 20300: "EnrollType", - 20301: "EnrollCertsType", -} - -var ContentType_value = map[string]int32{ - "Zero": 0, - "ServerHelloType": 20000, - "ClientHelloType": 20001, - "ErrorType": 20002, - "SessionAddedType": 20100, - "SessionUpdatedType": 20101, - "SessionRemovedType": 20102, - "ApiSessionAddedType": 20200, - "ApiSessionUpdatedType": 20201, - "ApiSessionRemovedType": 20202, - "ApiSessionHeartbeatType": 20203, - "EnrollType": 20300, - "EnrollCertsType": 20301, -} - -func (x ContentType) String() string { - return proto.EnumName(ContentType_name, int32(x)) -} - -func (ContentType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{0} -} - -type ServerHello struct { - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - Data map[string]string `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ServerHello) Reset() { *m = ServerHello{} } -func (m *ServerHello) String() string { return proto.CompactTextString(m) } -func (*ServerHello) ProtoMessage() {} -func (*ServerHello) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{0} -} - -func (m *ServerHello) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ServerHello.Unmarshal(m, b) -} -func (m *ServerHello) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ServerHello.Marshal(b, m, deterministic) -} -func (m *ServerHello) XXX_Merge(src proto.Message) { - xxx_messageInfo_ServerHello.Merge(m, src) -} -func (m *ServerHello) XXX_Size() int { - return xxx_messageInfo_ServerHello.Size(m) -} -func (m *ServerHello) XXX_DiscardUnknown() { - xxx_messageInfo_ServerHello.DiscardUnknown(m) -} - -var xxx_messageInfo_ServerHello proto.InternalMessageInfo - -func (m *ServerHello) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *ServerHello) GetData() map[string]string { - if m != nil { - return m.Data - } - return nil -} - -type ClientHello struct { - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"` - Protocols []string `protobuf:"bytes,3,rep,name=protocols,proto3" json:"protocols,omitempty"` - Data map[string]string `protobuf:"bytes,4,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ClientHello) Reset() { *m = ClientHello{} } -func (m *ClientHello) String() string { return proto.CompactTextString(m) } -func (*ClientHello) ProtoMessage() {} -func (*ClientHello) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{1} -} - -func (m *ClientHello) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ClientHello.Unmarshal(m, b) -} -func (m *ClientHello) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ClientHello.Marshal(b, m, deterministic) -} -func (m *ClientHello) XXX_Merge(src proto.Message) { - xxx_messageInfo_ClientHello.Merge(m, src) -} -func (m *ClientHello) XXX_Size() int { - return xxx_messageInfo_ClientHello.Size(m) -} -func (m *ClientHello) XXX_DiscardUnknown() { - xxx_messageInfo_ClientHello.DiscardUnknown(m) -} - -var xxx_messageInfo_ClientHello proto.InternalMessageInfo - -func (m *ClientHello) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *ClientHello) GetHostname() string { - if m != nil { - return m.Hostname - } - return "" -} - -func (m *ClientHello) GetProtocols() []string { - if m != nil { - return m.Protocols - } - return nil -} - -func (m *ClientHello) GetData() map[string]string { - if m != nil { - return m.Data - } - return nil -} - -type Error struct { - Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - Cause string `protobuf:"bytes,3,opt,name=cause,proto3" json:"cause,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Error) Reset() { *m = Error{} } -func (m *Error) String() string { return proto.CompactTextString(m) } -func (*Error) ProtoMessage() {} -func (*Error) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{2} -} - -func (m *Error) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Error.Unmarshal(m, b) -} -func (m *Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Error.Marshal(b, m, deterministic) -} -func (m *Error) XXX_Merge(src proto.Message) { - xxx_messageInfo_Error.Merge(m, src) -} -func (m *Error) XXX_Size() int { - return xxx_messageInfo_Error.Size(m) -} -func (m *Error) XXX_DiscardUnknown() { - xxx_messageInfo_Error.DiscardUnknown(m) -} - -var xxx_messageInfo_Error proto.InternalMessageInfo - -func (m *Error) GetCode() string { - if m != nil { - return m.Code - } - return "" -} - -func (m *Error) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func (m *Error) GetCause() string { - if m != nil { - return m.Cause - } - return "" -} - -type Dns struct { - Hostname string `protobuf:"bytes,1,opt,name=hostname,proto3" json:"hostname,omitempty"` - Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` - Protocol string `protobuf:"bytes,3,opt,name=protocol,proto3" json:"protocol,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Dns) Reset() { *m = Dns{} } -func (m *Dns) String() string { return proto.CompactTextString(m) } -func (*Dns) ProtoMessage() {} -func (*Dns) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{3} -} - -func (m *Dns) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Dns.Unmarshal(m, b) -} -func (m *Dns) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Dns.Marshal(b, m, deterministic) -} -func (m *Dns) XXX_Merge(src proto.Message) { - xxx_messageInfo_Dns.Merge(m, src) -} -func (m *Dns) XXX_Size() int { - return xxx_messageInfo_Dns.Size(m) -} -func (m *Dns) XXX_DiscardUnknown() { - xxx_messageInfo_Dns.DiscardUnknown(m) -} - -var xxx_messageInfo_Dns proto.InternalMessageInfo - -func (m *Dns) GetHostname() string { - if m != nil { - return m.Hostname - } - return "" -} - -func (m *Dns) GetPort() int32 { - if m != nil { - return m.Port - } - return 0 -} - -func (m *Dns) GetProtocol() string { - if m != nil { - return m.Protocol - } - return "" -} - -type Service struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - SupportedProtocol string `protobuf:"bytes,4,opt,name=supportedProtocol,proto3" json:"supportedProtocol,omitempty"` - EgressRouter string `protobuf:"bytes,5,opt,name=egressRouter,proto3" json:"egressRouter,omitempty"` - EndpointAddress string `protobuf:"bytes,6,opt,name=endpointAddress,proto3" json:"endpointAddress,omitempty"` - Dns *Dns `protobuf:"bytes,8,opt,name=dns,proto3" json:"dns,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Service) Reset() { *m = Service{} } -func (m *Service) String() string { return proto.CompactTextString(m) } -func (*Service) ProtoMessage() {} -func (*Service) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{4} -} - -func (m *Service) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Service.Unmarshal(m, b) -} -func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Service.Marshal(b, m, deterministic) -} -func (m *Service) XXX_Merge(src proto.Message) { - xxx_messageInfo_Service.Merge(m, src) -} -func (m *Service) XXX_Size() int { - return xxx_messageInfo_Service.Size(m) -} -func (m *Service) XXX_DiscardUnknown() { - xxx_messageInfo_Service.DiscardUnknown(m) -} - -var xxx_messageInfo_Service proto.InternalMessageInfo - -func (m *Service) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Service) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Service) GetSupportedProtocol() string { - if m != nil { - return m.SupportedProtocol - } - return "" -} - -func (m *Service) GetEgressRouter() string { - if m != nil { - return m.EgressRouter - } - return "" -} - -func (m *Service) GetEndpointAddress() string { - if m != nil { - return m.EndpointAddress - } - return "" -} - -func (m *Service) GetDns() *Dns { - if m != nil { - return m.Dns - } - return nil -} - -type Session struct { - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - Hosting bool `protobuf:"varint,2,opt,name=hosting,proto3" json:"hosting,omitempty"` - CertFingerprints []string `protobuf:"bytes,3,rep,name=certFingerprints,proto3" json:"certFingerprints,omitempty"` - Urls []string `protobuf:"bytes,4,rep,name=urls,proto3" json:"urls,omitempty"` - Service *Service `protobuf:"bytes,5,opt,name=service,proto3" json:"service,omitempty"` - SessionToken string `protobuf:"bytes,6,opt,name=sessionToken,proto3" json:"sessionToken,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Session) Reset() { *m = Session{} } -func (m *Session) String() string { return proto.CompactTextString(m) } -func (*Session) ProtoMessage() {} -func (*Session) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{5} -} - -func (m *Session) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Session.Unmarshal(m, b) -} -func (m *Session) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Session.Marshal(b, m, deterministic) -} -func (m *Session) XXX_Merge(src proto.Message) { - xxx_messageInfo_Session.Merge(m, src) -} -func (m *Session) XXX_Size() int { - return xxx_messageInfo_Session.Size(m) -} -func (m *Session) XXX_DiscardUnknown() { - xxx_messageInfo_Session.DiscardUnknown(m) -} - -var xxx_messageInfo_Session proto.InternalMessageInfo - -func (m *Session) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -func (m *Session) GetHosting() bool { - if m != nil { - return m.Hosting - } - return false -} - -func (m *Session) GetCertFingerprints() []string { - if m != nil { - return m.CertFingerprints - } - return nil -} - -func (m *Session) GetUrls() []string { - if m != nil { - return m.Urls - } - return nil -} - -func (m *Session) GetService() *Service { - if m != nil { - return m.Service - } - return nil -} - -func (m *Session) GetSessionToken() string { - if m != nil { - return m.SessionToken - } - return "" -} - -type ApiSession struct { - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - CertFingerprints []string `protobuf:"bytes,2,rep,name=certFingerprints,proto3" json:"certFingerprints,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApiSession) Reset() { *m = ApiSession{} } -func (m *ApiSession) String() string { return proto.CompactTextString(m) } -func (*ApiSession) ProtoMessage() {} -func (*ApiSession) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{6} -} - -func (m *ApiSession) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ApiSession.Unmarshal(m, b) -} -func (m *ApiSession) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ApiSession.Marshal(b, m, deterministic) -} -func (m *ApiSession) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApiSession.Merge(m, src) -} -func (m *ApiSession) XXX_Size() int { - return xxx_messageInfo_ApiSession.Size(m) -} -func (m *ApiSession) XXX_DiscardUnknown() { - xxx_messageInfo_ApiSession.DiscardUnknown(m) -} - -var xxx_messageInfo_ApiSession proto.InternalMessageInfo - -func (m *ApiSession) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -func (m *ApiSession) GetCertFingerprints() []string { - if m != nil { - return m.CertFingerprints - } - return nil -} - -type ApiSessionAdded struct { - IsFullState bool `protobuf:"varint,1,opt,name=isFullState,proto3" json:"isFullState,omitempty"` - ApiSessions []*ApiSession `protobuf:"bytes,2,rep,name=apiSessions,proto3" json:"apiSessions,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApiSessionAdded) Reset() { *m = ApiSessionAdded{} } -func (m *ApiSessionAdded) String() string { return proto.CompactTextString(m) } -func (*ApiSessionAdded) ProtoMessage() {} -func (*ApiSessionAdded) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{7} -} - -func (m *ApiSessionAdded) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ApiSessionAdded.Unmarshal(m, b) -} -func (m *ApiSessionAdded) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ApiSessionAdded.Marshal(b, m, deterministic) -} -func (m *ApiSessionAdded) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApiSessionAdded.Merge(m, src) -} -func (m *ApiSessionAdded) XXX_Size() int { - return xxx_messageInfo_ApiSessionAdded.Size(m) -} -func (m *ApiSessionAdded) XXX_DiscardUnknown() { - xxx_messageInfo_ApiSessionAdded.DiscardUnknown(m) -} - -var xxx_messageInfo_ApiSessionAdded proto.InternalMessageInfo - -func (m *ApiSessionAdded) GetIsFullState() bool { - if m != nil { - return m.IsFullState - } - return false -} - -func (m *ApiSessionAdded) GetApiSessions() []*ApiSession { - if m != nil { - return m.ApiSessions - } - return nil -} - -type ApiSessionUpdated struct { - ApiSessions []*ApiSession `protobuf:"bytes,1,rep,name=apiSessions,proto3" json:"apiSessions,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApiSessionUpdated) Reset() { *m = ApiSessionUpdated{} } -func (m *ApiSessionUpdated) String() string { return proto.CompactTextString(m) } -func (*ApiSessionUpdated) ProtoMessage() {} -func (*ApiSessionUpdated) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{8} -} - -func (m *ApiSessionUpdated) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ApiSessionUpdated.Unmarshal(m, b) -} -func (m *ApiSessionUpdated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ApiSessionUpdated.Marshal(b, m, deterministic) -} -func (m *ApiSessionUpdated) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApiSessionUpdated.Merge(m, src) -} -func (m *ApiSessionUpdated) XXX_Size() int { - return xxx_messageInfo_ApiSessionUpdated.Size(m) -} -func (m *ApiSessionUpdated) XXX_DiscardUnknown() { - xxx_messageInfo_ApiSessionUpdated.DiscardUnknown(m) -} - -var xxx_messageInfo_ApiSessionUpdated proto.InternalMessageInfo - -func (m *ApiSessionUpdated) GetApiSessions() []*ApiSession { - if m != nil { - return m.ApiSessions - } - return nil -} - -type ApiSessionRemoved struct { - Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApiSessionRemoved) Reset() { *m = ApiSessionRemoved{} } -func (m *ApiSessionRemoved) String() string { return proto.CompactTextString(m) } -func (*ApiSessionRemoved) ProtoMessage() {} -func (*ApiSessionRemoved) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{9} -} - -func (m *ApiSessionRemoved) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ApiSessionRemoved.Unmarshal(m, b) -} -func (m *ApiSessionRemoved) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ApiSessionRemoved.Marshal(b, m, deterministic) -} -func (m *ApiSessionRemoved) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApiSessionRemoved.Merge(m, src) -} -func (m *ApiSessionRemoved) XXX_Size() int { - return xxx_messageInfo_ApiSessionRemoved.Size(m) -} -func (m *ApiSessionRemoved) XXX_DiscardUnknown() { - xxx_messageInfo_ApiSessionRemoved.DiscardUnknown(m) -} - -var xxx_messageInfo_ApiSessionRemoved proto.InternalMessageInfo - -func (m *ApiSessionRemoved) GetTokens() []string { - if m != nil { - return m.Tokens - } - return nil -} - -type ApiSessionHeartbeat struct { - Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApiSessionHeartbeat) Reset() { *m = ApiSessionHeartbeat{} } -func (m *ApiSessionHeartbeat) String() string { return proto.CompactTextString(m) } -func (*ApiSessionHeartbeat) ProtoMessage() {} -func (*ApiSessionHeartbeat) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{10} -} - -func (m *ApiSessionHeartbeat) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ApiSessionHeartbeat.Unmarshal(m, b) -} -func (m *ApiSessionHeartbeat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ApiSessionHeartbeat.Marshal(b, m, deterministic) -} -func (m *ApiSessionHeartbeat) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApiSessionHeartbeat.Merge(m, src) -} -func (m *ApiSessionHeartbeat) XXX_Size() int { - return xxx_messageInfo_ApiSessionHeartbeat.Size(m) -} -func (m *ApiSessionHeartbeat) XXX_DiscardUnknown() { - xxx_messageInfo_ApiSessionHeartbeat.DiscardUnknown(m) -} - -var xxx_messageInfo_ApiSessionHeartbeat proto.InternalMessageInfo - -func (m *ApiSessionHeartbeat) GetTokens() []string { - if m != nil { - return m.Tokens - } - return nil -} - -type SessionAdded struct { - IsFullState bool `protobuf:"varint,1,opt,name=isFullState,proto3" json:"isFullState,omitempty"` - Sessions []*Session `protobuf:"bytes,2,rep,name=sessions,proto3" json:"sessions,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SessionAdded) Reset() { *m = SessionAdded{} } -func (m *SessionAdded) String() string { return proto.CompactTextString(m) } -func (*SessionAdded) ProtoMessage() {} -func (*SessionAdded) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{11} -} - -func (m *SessionAdded) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SessionAdded.Unmarshal(m, b) -} -func (m *SessionAdded) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SessionAdded.Marshal(b, m, deterministic) -} -func (m *SessionAdded) XXX_Merge(src proto.Message) { - xxx_messageInfo_SessionAdded.Merge(m, src) -} -func (m *SessionAdded) XXX_Size() int { - return xxx_messageInfo_SessionAdded.Size(m) -} -func (m *SessionAdded) XXX_DiscardUnknown() { - xxx_messageInfo_SessionAdded.DiscardUnknown(m) -} - -var xxx_messageInfo_SessionAdded proto.InternalMessageInfo - -func (m *SessionAdded) GetIsFullState() bool { - if m != nil { - return m.IsFullState - } - return false -} - -func (m *SessionAdded) GetSessions() []*Session { - if m != nil { - return m.Sessions - } - return nil -} - -type SessionRemoved struct { - Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SessionRemoved) Reset() { *m = SessionRemoved{} } -func (m *SessionRemoved) String() string { return proto.CompactTextString(m) } -func (*SessionRemoved) ProtoMessage() {} -func (*SessionRemoved) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{12} -} - -func (m *SessionRemoved) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SessionRemoved.Unmarshal(m, b) -} -func (m *SessionRemoved) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SessionRemoved.Marshal(b, m, deterministic) -} -func (m *SessionRemoved) XXX_Merge(src proto.Message) { - xxx_messageInfo_SessionRemoved.Merge(m, src) -} -func (m *SessionRemoved) XXX_Size() int { - return xxx_messageInfo_SessionRemoved.Size(m) -} -func (m *SessionRemoved) XXX_DiscardUnknown() { - xxx_messageInfo_SessionRemoved.DiscardUnknown(m) -} - -var xxx_messageInfo_SessionRemoved proto.InternalMessageInfo - -func (m *SessionRemoved) GetTokens() []string { - if m != nil { - return m.Tokens - } - return nil -} - -type SessionUpdated struct { - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - Urls []string `protobuf:"bytes,2,rep,name=urls,proto3" json:"urls,omitempty"` - Service *Service `protobuf:"bytes,3,opt,name=service,proto3" json:"service,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SessionUpdated) Reset() { *m = SessionUpdated{} } -func (m *SessionUpdated) String() string { return proto.CompactTextString(m) } -func (*SessionUpdated) ProtoMessage() {} -func (*SessionUpdated) Descriptor() ([]byte, []int) { - return fileDescriptor_23f46a161f139ee1, []int{13} -} - -func (m *SessionUpdated) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SessionUpdated.Unmarshal(m, b) -} -func (m *SessionUpdated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SessionUpdated.Marshal(b, m, deterministic) -} -func (m *SessionUpdated) XXX_Merge(src proto.Message) { - xxx_messageInfo_SessionUpdated.Merge(m, src) -} -func (m *SessionUpdated) XXX_Size() int { - return xxx_messageInfo_SessionUpdated.Size(m) -} -func (m *SessionUpdated) XXX_DiscardUnknown() { - xxx_messageInfo_SessionUpdated.DiscardUnknown(m) -} - -var xxx_messageInfo_SessionUpdated proto.InternalMessageInfo - -func (m *SessionUpdated) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -func (m *SessionUpdated) GetUrls() []string { - if m != nil { - return m.Urls - } - return nil -} - -func (m *SessionUpdated) GetService() *Service { - if m != nil { - return m.Service - } - return nil -} - -func init() { - proto.RegisterEnum("edge_ctrl.pb.ContentType", ContentType_name, ContentType_value) - proto.RegisterType((*ServerHello)(nil), "edge_ctrl.pb.ServerHello") - proto.RegisterMapType((map[string]string)(nil), "edge_ctrl.pb.ServerHello.DataEntry") - proto.RegisterType((*ClientHello)(nil), "edge_ctrl.pb.ClientHello") - proto.RegisterMapType((map[string]string)(nil), "edge_ctrl.pb.ClientHello.DataEntry") - proto.RegisterType((*Error)(nil), "edge_ctrl.pb.Error") - proto.RegisterType((*Dns)(nil), "edge_ctrl.pb.Dns") - proto.RegisterType((*Service)(nil), "edge_ctrl.pb.Service") - proto.RegisterType((*Session)(nil), "edge_ctrl.pb.Session") - proto.RegisterType((*ApiSession)(nil), "edge_ctrl.pb.ApiSession") - proto.RegisterType((*ApiSessionAdded)(nil), "edge_ctrl.pb.ApiSessionAdded") - proto.RegisterType((*ApiSessionUpdated)(nil), "edge_ctrl.pb.ApiSessionUpdated") - proto.RegisterType((*ApiSessionRemoved)(nil), "edge_ctrl.pb.ApiSessionRemoved") - proto.RegisterType((*ApiSessionHeartbeat)(nil), "edge_ctrl.pb.ApiSessionHeartbeat") - proto.RegisterType((*SessionAdded)(nil), "edge_ctrl.pb.SessionAdded") - proto.RegisterType((*SessionRemoved)(nil), "edge_ctrl.pb.SessionRemoved") - proto.RegisterType((*SessionUpdated)(nil), "edge_ctrl.pb.SessionUpdated") -} - -func init() { proto.RegisterFile("edge_ctrl.proto", fileDescriptor_23f46a161f139ee1) } - -var fileDescriptor_23f46a161f139ee1 = []byte{ - // 747 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x54, 0xdb, 0x6e, 0xd3, 0x4a, - 0x14, 0x3d, 0xce, 0xa5, 0x4d, 0x76, 0xaa, 0x26, 0x9d, 0x73, 0xda, 0xe3, 0xd3, 0x03, 0x52, 0xe5, - 0xbe, 0x44, 0x05, 0x82, 0x28, 0x0f, 0x45, 0x7d, 0xab, 0x7a, 0x51, 0x25, 0x24, 0x2e, 0x6e, 0x79, - 0xe1, 0x05, 0xb9, 0xf1, 0x28, 0x58, 0x75, 0x3d, 0xd6, 0xcc, 0xa4, 0x52, 0xdf, 0x81, 0x7f, 0x40, - 0x82, 0x0a, 0xf8, 0x11, 0x7e, 0x00, 0x78, 0xe1, 0x27, 0xb8, 0xfc, 0x04, 0x7b, 0xb6, 0x2f, 0xb1, - 0x93, 0x00, 0xad, 0xc4, 0xdb, 0xec, 0xb5, 0xb6, 0x97, 0xf7, 0x5a, 0xde, 0x1e, 0x68, 0x73, 0x7f, - 0xc0, 0x9f, 0xf4, 0xb5, 0x0c, 0x7b, 0xb1, 0x14, 0x5a, 0xb0, 0xb9, 0x02, 0x70, 0xe4, 0xbc, 0xb4, - 0xa0, 0x75, 0xc0, 0xe5, 0x29, 0x97, 0xfb, 0x3c, 0x0c, 0x05, 0xb3, 0x61, 0x16, 0xcf, 0x2a, 0x10, - 0x91, 0x6d, 0xad, 0x58, 0xdd, 0xa6, 0x9b, 0x95, 0x6c, 0x03, 0x6a, 0xbe, 0xa7, 0x3d, 0xbb, 0xb2, - 0x52, 0xed, 0xb6, 0xd6, 0x57, 0x7b, 0x45, 0x99, 0x5e, 0x41, 0xa2, 0xb7, 0x83, 0x5d, 0xbb, 0x91, - 0x96, 0x67, 0x2e, 0x3d, 0xb0, 0xbc, 0x01, 0xcd, 0x1c, 0x62, 0x1d, 0xa8, 0x1e, 0xf3, 0xb3, 0x54, - 0xdb, 0x1c, 0xd9, 0x3f, 0x50, 0x3f, 0xf5, 0xc2, 0x21, 0x47, 0x61, 0x83, 0x25, 0xc5, 0x66, 0xe5, - 0x8e, 0xe5, 0x7c, 0xc6, 0xd9, 0xb6, 0xc3, 0x80, 0x47, 0xfa, 0x77, 0xb3, 0x2d, 0x43, 0xe3, 0xa9, - 0x50, 0x3a, 0xf2, 0x4e, 0x32, 0x99, 0xbc, 0x66, 0x57, 0xa0, 0x49, 0xc6, 0xfb, 0x22, 0x54, 0x76, - 0x15, 0x87, 0x6f, 0xba, 0x23, 0x20, 0x77, 0x55, 0x9b, 0xe6, 0xaa, 0xf0, 0xf2, 0x3f, 0xe7, 0xea, - 0x2e, 0xd4, 0x77, 0xa5, 0x14, 0x92, 0x31, 0xa8, 0xf5, 0x85, 0xcf, 0xd3, 0xa7, 0xe8, 0x6c, 0x2c, - 0x9e, 0x70, 0xa5, 0xbc, 0x41, 0xf6, 0x60, 0x56, 0x1a, 0xc1, 0xbe, 0x37, 0x54, 0x1c, 0x2d, 0x90, - 0x20, 0x15, 0xce, 0x43, 0xa8, 0xee, 0x44, 0xaa, 0xe4, 0xdf, 0x1a, 0xf3, 0x8f, 0xaf, 0x89, 0x85, - 0xd4, 0xa4, 0x57, 0x77, 0xe9, 0x6c, 0xfa, 0xb3, 0x08, 0x52, 0xbd, 0xbc, 0x76, 0x3e, 0x59, 0x30, - 0x6b, 0x3e, 0x67, 0xd0, 0xe7, 0x6c, 0x1e, 0x2a, 0x81, 0x9f, 0x2a, 0xe2, 0xc9, 0x68, 0x15, 0x32, - 0xa6, 0x33, 0xbb, 0x0e, 0x0b, 0x6a, 0x18, 0x1b, 0x59, 0xee, 0x3f, 0xc8, 0x44, 0x6b, 0xd4, 0x30, - 0x49, 0x30, 0x07, 0xe6, 0xf8, 0x40, 0xa2, 0x27, 0x57, 0x0c, 0x35, 0x97, 0x76, 0x9d, 0x1a, 0x4b, - 0x18, 0xeb, 0xe2, 0xd2, 0x46, 0x7e, 0x2c, 0x82, 0x48, 0x6f, 0xf9, 0xbe, 0x21, 0xec, 0x19, 0x6a, - 0x1b, 0x87, 0xd9, 0x2a, 0x54, 0xfd, 0x48, 0xd9, 0x0d, 0x64, 0x5b, 0xeb, 0x0b, 0xe5, 0x8f, 0x87, - 0xb9, 0xb8, 0x86, 0x4d, 0x0d, 0x29, 0x5a, 0x14, 0x4c, 0x51, 0x8b, 0x63, 0x9e, 0x2d, 0x50, 0x52, - 0x98, 0xd4, 0x4d, 0x5c, 0x41, 0x34, 0x20, 0x67, 0x0d, 0x37, 0x2b, 0xd9, 0x1a, 0x74, 0xfa, 0x5c, - 0xea, 0x3d, 0x3c, 0x73, 0x19, 0x4b, 0x7c, 0x75, 0xb6, 0x43, 0x13, 0xb8, 0x09, 0x67, 0x28, 0x71, - 0xc7, 0x6a, 0xc4, 0xd3, 0x99, 0xdd, 0x84, 0x59, 0x95, 0x64, 0x49, 0x4e, 0x5b, 0xeb, 0x8b, 0x93, - 0xff, 0x0d, 0x92, 0x6e, 0xd6, 0x65, 0xf2, 0x51, 0xc9, 0xac, 0x87, 0x34, 0x67, 0x62, 0xbc, 0x84, - 0x39, 0xf7, 0x00, 0xb6, 0xe2, 0xe0, 0xd7, 0x96, 0xa6, 0x0d, 0x5e, 0x99, 0x3e, 0xb8, 0x23, 0xa0, - 0x3d, 0xd2, 0xc3, 0x68, 0xb9, 0xcf, 0x56, 0xa0, 0x15, 0xa8, 0xbd, 0x61, 0x18, 0x1e, 0x68, 0x4f, - 0x27, 0x3b, 0xd5, 0x70, 0x8b, 0x10, 0xdb, 0x84, 0x96, 0x97, 0x3f, 0xa4, 0xd2, 0x5b, 0xc1, 0x2e, - 0xbb, 0x1b, 0xa9, 0xba, 0xc5, 0x66, 0xe7, 0x3e, 0x2c, 0x8c, 0xa8, 0x47, 0x31, 0xfe, 0x4f, 0xf8, - 0xca, 0x31, 0x41, 0xeb, 0x32, 0x82, 0xd7, 0x8a, 0x82, 0x2e, 0x3f, 0x11, 0xa7, 0x28, 0xb8, 0x04, - 0x33, 0x94, 0x45, 0xa2, 0xd5, 0x74, 0xd3, 0xca, 0xb9, 0x01, 0x7f, 0x8f, 0x9a, 0xf7, 0xb9, 0x27, - 0xf5, 0x11, 0xf7, 0xf4, 0x4f, 0xdb, 0xfb, 0x30, 0x77, 0xc9, 0x68, 0x6e, 0x41, 0x43, 0x95, 0x73, - 0x99, 0xf8, 0xea, 0xc9, 0xa0, 0x79, 0x9b, 0xd3, 0x85, 0xf9, 0x0b, 0x4e, 0x7f, 0x9c, 0x77, 0x66, - 0xc1, 0x4d, 0x5f, 0x80, 0x6c, 0x1b, 0x2b, 0xd3, 0xb7, 0xb1, 0x7a, 0x91, 0x6d, 0x5c, 0x7b, 0x5f, - 0xc1, 0x1b, 0x58, 0x44, 0x1a, 0x6f, 0xc1, 0xc3, 0xb3, 0x98, 0xb3, 0x06, 0xd4, 0x1e, 0x73, 0x29, - 0x3a, 0x7f, 0xb1, 0x45, 0x68, 0x17, 0xee, 0x7c, 0x43, 0x76, 0xde, 0xbc, 0xb2, 0x0c, 0x5c, 0xb8, - 0x34, 0x09, 0x7e, 0x8b, 0x70, 0x1b, 0x9a, 0x74, 0xe7, 0x11, 0xf0, 0x0e, 0x81, 0x25, 0xe8, 0x14, - 0x43, 0x25, 0xfc, 0xd9, 0x6b, 0x0b, 0xff, 0x44, 0x56, 0x76, 0x47, 0xcc, 0xf3, 0x12, 0x93, 0x26, - 0x44, 0xcc, 0x0b, 0x64, 0xfe, 0x2b, 0x7e, 0xcf, 0x91, 0xdc, 0x17, 0xa4, 0xfe, 0x87, 0xc5, 0x89, - 0x45, 0x23, 0xf2, 0xeb, 0x38, 0x59, 0x14, 0xfd, 0x86, 0xe4, 0x55, 0xf8, 0x77, 0xca, 0x92, 0x10, - 0xfd, 0x1d, 0xe9, 0x0e, 0xc0, 0x6e, 0x24, 0x45, 0x18, 0x12, 0xf2, 0xe1, 0x9c, 0x9c, 0x27, 0xc8, - 0x36, 0xfe, 0x5e, 0x8a, 0xe0, 0x8f, 0xe7, 0xd6, 0xd1, 0x0c, 0xdd, 0xab, 0xb7, 0x7f, 0x04, 0x00, - 0x00, 0xff, 0xff, 0xa4, 0x2c, 0xb1, 0x89, 0x87, 0x07, 0x00, 0x00, -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: edge_ctrl.proto + +package edge_ctrl_pb + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type ContentType int32 + +const ( + ContentType_Zero ContentType = 0 + ContentType_ServerHelloType ContentType = 20000 + ContentType_ClientHelloType ContentType = 20001 + ContentType_ErrorType ContentType = 20002 + ContentType_SessionAddedType ContentType = 20100 + ContentType_SessionUpdatedType ContentType = 20101 + ContentType_SessionRemovedType ContentType = 20102 + ContentType_ApiSessionAddedType ContentType = 20200 + ContentType_ApiSessionUpdatedType ContentType = 20201 + ContentType_ApiSessionRemovedType ContentType = 20202 + ContentType_ApiSessionHeartbeatType ContentType = 20203 + ContentType_EnrollType ContentType = 20300 + ContentType_EnrollCertsType ContentType = 20301 +) + +var ContentType_name = map[int32]string{ + 0: "Zero", + 20000: "ServerHelloType", + 20001: "ClientHelloType", + 20002: "ErrorType", + 20100: "SessionAddedType", + 20101: "SessionUpdatedType", + 20102: "SessionRemovedType", + 20200: "ApiSessionAddedType", + 20201: "ApiSessionUpdatedType", + 20202: "ApiSessionRemovedType", + 20203: "ApiSessionHeartbeatType", + 20300: "EnrollType", + 20301: "EnrollCertsType", +} + +var ContentType_value = map[string]int32{ + "Zero": 0, + "ServerHelloType": 20000, + "ClientHelloType": 20001, + "ErrorType": 20002, + "SessionAddedType": 20100, + "SessionUpdatedType": 20101, + "SessionRemovedType": 20102, + "ApiSessionAddedType": 20200, + "ApiSessionUpdatedType": 20201, + "ApiSessionRemovedType": 20202, + "ApiSessionHeartbeatType": 20203, + "EnrollType": 20300, + "EnrollCertsType": 20301, +} + +func (x ContentType) String() string { + return proto.EnumName(ContentType_name, int32(x)) +} + +func (ContentType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{0} +} + +type ServerHello struct { + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Data map[string]string `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServerHello) Reset() { *m = ServerHello{} } +func (m *ServerHello) String() string { return proto.CompactTextString(m) } +func (*ServerHello) ProtoMessage() {} +func (*ServerHello) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{0} +} + +func (m *ServerHello) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServerHello.Unmarshal(m, b) +} +func (m *ServerHello) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServerHello.Marshal(b, m, deterministic) +} +func (m *ServerHello) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServerHello.Merge(m, src) +} +func (m *ServerHello) XXX_Size() int { + return xxx_messageInfo_ServerHello.Size(m) +} +func (m *ServerHello) XXX_DiscardUnknown() { + xxx_messageInfo_ServerHello.DiscardUnknown(m) +} + +var xxx_messageInfo_ServerHello proto.InternalMessageInfo + +func (m *ServerHello) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *ServerHello) GetData() map[string]string { + if m != nil { + return m.Data + } + return nil +} + +type ClientHello struct { + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"` + Protocols []string `protobuf:"bytes,3,rep,name=protocols,proto3" json:"protocols,omitempty"` + Data map[string]string `protobuf:"bytes,4,rep,name=data,proto3" json:"data,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ClientHello) Reset() { *m = ClientHello{} } +func (m *ClientHello) String() string { return proto.CompactTextString(m) } +func (*ClientHello) ProtoMessage() {} +func (*ClientHello) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{1} +} + +func (m *ClientHello) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ClientHello.Unmarshal(m, b) +} +func (m *ClientHello) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ClientHello.Marshal(b, m, deterministic) +} +func (m *ClientHello) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClientHello.Merge(m, src) +} +func (m *ClientHello) XXX_Size() int { + return xxx_messageInfo_ClientHello.Size(m) +} +func (m *ClientHello) XXX_DiscardUnknown() { + xxx_messageInfo_ClientHello.DiscardUnknown(m) +} + +var xxx_messageInfo_ClientHello proto.InternalMessageInfo + +func (m *ClientHello) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *ClientHello) GetHostname() string { + if m != nil { + return m.Hostname + } + return "" +} + +func (m *ClientHello) GetProtocols() []string { + if m != nil { + return m.Protocols + } + return nil +} + +func (m *ClientHello) GetData() map[string]string { + if m != nil { + return m.Data + } + return nil +} + +type Error struct { + Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + Cause string `protobuf:"bytes,3,opt,name=cause,proto3" json:"cause,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Error) Reset() { *m = Error{} } +func (m *Error) String() string { return proto.CompactTextString(m) } +func (*Error) ProtoMessage() {} +func (*Error) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{2} +} + +func (m *Error) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Error.Unmarshal(m, b) +} +func (m *Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Error.Marshal(b, m, deterministic) +} +func (m *Error) XXX_Merge(src proto.Message) { + xxx_messageInfo_Error.Merge(m, src) +} +func (m *Error) XXX_Size() int { + return xxx_messageInfo_Error.Size(m) +} +func (m *Error) XXX_DiscardUnknown() { + xxx_messageInfo_Error.DiscardUnknown(m) +} + +var xxx_messageInfo_Error proto.InternalMessageInfo + +func (m *Error) GetCode() string { + if m != nil { + return m.Code + } + return "" +} + +func (m *Error) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func (m *Error) GetCause() string { + if m != nil { + return m.Cause + } + return "" +} + +type Dns struct { + Hostname string `protobuf:"bytes,1,opt,name=hostname,proto3" json:"hostname,omitempty"` + Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` + Protocol string `protobuf:"bytes,3,opt,name=protocol,proto3" json:"protocol,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Dns) Reset() { *m = Dns{} } +func (m *Dns) String() string { return proto.CompactTextString(m) } +func (*Dns) ProtoMessage() {} +func (*Dns) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{3} +} + +func (m *Dns) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Dns.Unmarshal(m, b) +} +func (m *Dns) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Dns.Marshal(b, m, deterministic) +} +func (m *Dns) XXX_Merge(src proto.Message) { + xxx_messageInfo_Dns.Merge(m, src) +} +func (m *Dns) XXX_Size() int { + return xxx_messageInfo_Dns.Size(m) +} +func (m *Dns) XXX_DiscardUnknown() { + xxx_messageInfo_Dns.DiscardUnknown(m) +} + +var xxx_messageInfo_Dns proto.InternalMessageInfo + +func (m *Dns) GetHostname() string { + if m != nil { + return m.Hostname + } + return "" +} + +func (m *Dns) GetPort() int32 { + if m != nil { + return m.Port + } + return 0 +} + +func (m *Dns) GetProtocol() string { + if m != nil { + return m.Protocol + } + return "" +} + +type Service struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + SupportedProtocol string `protobuf:"bytes,4,opt,name=supportedProtocol,proto3" json:"supportedProtocol,omitempty"` + EgressRouter string `protobuf:"bytes,5,opt,name=egressRouter,proto3" json:"egressRouter,omitempty"` + EndpointAddress string `protobuf:"bytes,6,opt,name=endpointAddress,proto3" json:"endpointAddress,omitempty"` + Dns *Dns `protobuf:"bytes,8,opt,name=dns,proto3" json:"dns,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Service) Reset() { *m = Service{} } +func (m *Service) String() string { return proto.CompactTextString(m) } +func (*Service) ProtoMessage() {} +func (*Service) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{4} +} + +func (m *Service) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Service.Unmarshal(m, b) +} +func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Service.Marshal(b, m, deterministic) +} +func (m *Service) XXX_Merge(src proto.Message) { + xxx_messageInfo_Service.Merge(m, src) +} +func (m *Service) XXX_Size() int { + return xxx_messageInfo_Service.Size(m) +} +func (m *Service) XXX_DiscardUnknown() { + xxx_messageInfo_Service.DiscardUnknown(m) +} + +var xxx_messageInfo_Service proto.InternalMessageInfo + +func (m *Service) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *Service) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Service) GetSupportedProtocol() string { + if m != nil { + return m.SupportedProtocol + } + return "" +} + +func (m *Service) GetEgressRouter() string { + if m != nil { + return m.EgressRouter + } + return "" +} + +func (m *Service) GetEndpointAddress() string { + if m != nil { + return m.EndpointAddress + } + return "" +} + +func (m *Service) GetDns() *Dns { + if m != nil { + return m.Dns + } + return nil +} + +type Session struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Hosting bool `protobuf:"varint,2,opt,name=hosting,proto3" json:"hosting,omitempty"` + CertFingerprints []string `protobuf:"bytes,3,rep,name=certFingerprints,proto3" json:"certFingerprints,omitempty"` + Urls []string `protobuf:"bytes,4,rep,name=urls,proto3" json:"urls,omitempty"` + Service *Service `protobuf:"bytes,5,opt,name=service,proto3" json:"service,omitempty"` + SessionToken string `protobuf:"bytes,6,opt,name=sessionToken,proto3" json:"sessionToken,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Session) Reset() { *m = Session{} } +func (m *Session) String() string { return proto.CompactTextString(m) } +func (*Session) ProtoMessage() {} +func (*Session) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{5} +} + +func (m *Session) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Session.Unmarshal(m, b) +} +func (m *Session) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Session.Marshal(b, m, deterministic) +} +func (m *Session) XXX_Merge(src proto.Message) { + xxx_messageInfo_Session.Merge(m, src) +} +func (m *Session) XXX_Size() int { + return xxx_messageInfo_Session.Size(m) +} +func (m *Session) XXX_DiscardUnknown() { + xxx_messageInfo_Session.DiscardUnknown(m) +} + +var xxx_messageInfo_Session proto.InternalMessageInfo + +func (m *Session) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *Session) GetHosting() bool { + if m != nil { + return m.Hosting + } + return false +} + +func (m *Session) GetCertFingerprints() []string { + if m != nil { + return m.CertFingerprints + } + return nil +} + +func (m *Session) GetUrls() []string { + if m != nil { + return m.Urls + } + return nil +} + +func (m *Session) GetService() *Service { + if m != nil { + return m.Service + } + return nil +} + +func (m *Session) GetSessionToken() string { + if m != nil { + return m.SessionToken + } + return "" +} + +type ApiSession struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + CertFingerprints []string `protobuf:"bytes,2,rep,name=certFingerprints,proto3" json:"certFingerprints,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ApiSession) Reset() { *m = ApiSession{} } +func (m *ApiSession) String() string { return proto.CompactTextString(m) } +func (*ApiSession) ProtoMessage() {} +func (*ApiSession) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{6} +} + +func (m *ApiSession) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ApiSession.Unmarshal(m, b) +} +func (m *ApiSession) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ApiSession.Marshal(b, m, deterministic) +} +func (m *ApiSession) XXX_Merge(src proto.Message) { + xxx_messageInfo_ApiSession.Merge(m, src) +} +func (m *ApiSession) XXX_Size() int { + return xxx_messageInfo_ApiSession.Size(m) +} +func (m *ApiSession) XXX_DiscardUnknown() { + xxx_messageInfo_ApiSession.DiscardUnknown(m) +} + +var xxx_messageInfo_ApiSession proto.InternalMessageInfo + +func (m *ApiSession) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *ApiSession) GetCertFingerprints() []string { + if m != nil { + return m.CertFingerprints + } + return nil +} + +type ApiSessionAdded struct { + IsFullState bool `protobuf:"varint,1,opt,name=isFullState,proto3" json:"isFullState,omitempty"` + ApiSessions []*ApiSession `protobuf:"bytes,2,rep,name=apiSessions,proto3" json:"apiSessions,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ApiSessionAdded) Reset() { *m = ApiSessionAdded{} } +func (m *ApiSessionAdded) String() string { return proto.CompactTextString(m) } +func (*ApiSessionAdded) ProtoMessage() {} +func (*ApiSessionAdded) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{7} +} + +func (m *ApiSessionAdded) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ApiSessionAdded.Unmarshal(m, b) +} +func (m *ApiSessionAdded) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ApiSessionAdded.Marshal(b, m, deterministic) +} +func (m *ApiSessionAdded) XXX_Merge(src proto.Message) { + xxx_messageInfo_ApiSessionAdded.Merge(m, src) +} +func (m *ApiSessionAdded) XXX_Size() int { + return xxx_messageInfo_ApiSessionAdded.Size(m) +} +func (m *ApiSessionAdded) XXX_DiscardUnknown() { + xxx_messageInfo_ApiSessionAdded.DiscardUnknown(m) +} + +var xxx_messageInfo_ApiSessionAdded proto.InternalMessageInfo + +func (m *ApiSessionAdded) GetIsFullState() bool { + if m != nil { + return m.IsFullState + } + return false +} + +func (m *ApiSessionAdded) GetApiSessions() []*ApiSession { + if m != nil { + return m.ApiSessions + } + return nil +} + +type ApiSessionUpdated struct { + ApiSessions []*ApiSession `protobuf:"bytes,1,rep,name=apiSessions,proto3" json:"apiSessions,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ApiSessionUpdated) Reset() { *m = ApiSessionUpdated{} } +func (m *ApiSessionUpdated) String() string { return proto.CompactTextString(m) } +func (*ApiSessionUpdated) ProtoMessage() {} +func (*ApiSessionUpdated) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{8} +} + +func (m *ApiSessionUpdated) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ApiSessionUpdated.Unmarshal(m, b) +} +func (m *ApiSessionUpdated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ApiSessionUpdated.Marshal(b, m, deterministic) +} +func (m *ApiSessionUpdated) XXX_Merge(src proto.Message) { + xxx_messageInfo_ApiSessionUpdated.Merge(m, src) +} +func (m *ApiSessionUpdated) XXX_Size() int { + return xxx_messageInfo_ApiSessionUpdated.Size(m) +} +func (m *ApiSessionUpdated) XXX_DiscardUnknown() { + xxx_messageInfo_ApiSessionUpdated.DiscardUnknown(m) +} + +var xxx_messageInfo_ApiSessionUpdated proto.InternalMessageInfo + +func (m *ApiSessionUpdated) GetApiSessions() []*ApiSession { + if m != nil { + return m.ApiSessions + } + return nil +} + +type ApiSessionRemoved struct { + Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ApiSessionRemoved) Reset() { *m = ApiSessionRemoved{} } +func (m *ApiSessionRemoved) String() string { return proto.CompactTextString(m) } +func (*ApiSessionRemoved) ProtoMessage() {} +func (*ApiSessionRemoved) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{9} +} + +func (m *ApiSessionRemoved) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ApiSessionRemoved.Unmarshal(m, b) +} +func (m *ApiSessionRemoved) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ApiSessionRemoved.Marshal(b, m, deterministic) +} +func (m *ApiSessionRemoved) XXX_Merge(src proto.Message) { + xxx_messageInfo_ApiSessionRemoved.Merge(m, src) +} +func (m *ApiSessionRemoved) XXX_Size() int { + return xxx_messageInfo_ApiSessionRemoved.Size(m) +} +func (m *ApiSessionRemoved) XXX_DiscardUnknown() { + xxx_messageInfo_ApiSessionRemoved.DiscardUnknown(m) +} + +var xxx_messageInfo_ApiSessionRemoved proto.InternalMessageInfo + +func (m *ApiSessionRemoved) GetTokens() []string { + if m != nil { + return m.Tokens + } + return nil +} + +type ApiSessionHeartbeat struct { + Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ApiSessionHeartbeat) Reset() { *m = ApiSessionHeartbeat{} } +func (m *ApiSessionHeartbeat) String() string { return proto.CompactTextString(m) } +func (*ApiSessionHeartbeat) ProtoMessage() {} +func (*ApiSessionHeartbeat) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{10} +} + +func (m *ApiSessionHeartbeat) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ApiSessionHeartbeat.Unmarshal(m, b) +} +func (m *ApiSessionHeartbeat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ApiSessionHeartbeat.Marshal(b, m, deterministic) +} +func (m *ApiSessionHeartbeat) XXX_Merge(src proto.Message) { + xxx_messageInfo_ApiSessionHeartbeat.Merge(m, src) +} +func (m *ApiSessionHeartbeat) XXX_Size() int { + return xxx_messageInfo_ApiSessionHeartbeat.Size(m) +} +func (m *ApiSessionHeartbeat) XXX_DiscardUnknown() { + xxx_messageInfo_ApiSessionHeartbeat.DiscardUnknown(m) +} + +var xxx_messageInfo_ApiSessionHeartbeat proto.InternalMessageInfo + +func (m *ApiSessionHeartbeat) GetTokens() []string { + if m != nil { + return m.Tokens + } + return nil +} + +type SessionAdded struct { + IsFullState bool `protobuf:"varint,1,opt,name=isFullState,proto3" json:"isFullState,omitempty"` + Sessions []*Session `protobuf:"bytes,2,rep,name=sessions,proto3" json:"sessions,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SessionAdded) Reset() { *m = SessionAdded{} } +func (m *SessionAdded) String() string { return proto.CompactTextString(m) } +func (*SessionAdded) ProtoMessage() {} +func (*SessionAdded) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{11} +} + +func (m *SessionAdded) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SessionAdded.Unmarshal(m, b) +} +func (m *SessionAdded) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SessionAdded.Marshal(b, m, deterministic) +} +func (m *SessionAdded) XXX_Merge(src proto.Message) { + xxx_messageInfo_SessionAdded.Merge(m, src) +} +func (m *SessionAdded) XXX_Size() int { + return xxx_messageInfo_SessionAdded.Size(m) +} +func (m *SessionAdded) XXX_DiscardUnknown() { + xxx_messageInfo_SessionAdded.DiscardUnknown(m) +} + +var xxx_messageInfo_SessionAdded proto.InternalMessageInfo + +func (m *SessionAdded) GetIsFullState() bool { + if m != nil { + return m.IsFullState + } + return false +} + +func (m *SessionAdded) GetSessions() []*Session { + if m != nil { + return m.Sessions + } + return nil +} + +type SessionRemoved struct { + Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SessionRemoved) Reset() { *m = SessionRemoved{} } +func (m *SessionRemoved) String() string { return proto.CompactTextString(m) } +func (*SessionRemoved) ProtoMessage() {} +func (*SessionRemoved) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{12} +} + +func (m *SessionRemoved) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SessionRemoved.Unmarshal(m, b) +} +func (m *SessionRemoved) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SessionRemoved.Marshal(b, m, deterministic) +} +func (m *SessionRemoved) XXX_Merge(src proto.Message) { + xxx_messageInfo_SessionRemoved.Merge(m, src) +} +func (m *SessionRemoved) XXX_Size() int { + return xxx_messageInfo_SessionRemoved.Size(m) +} +func (m *SessionRemoved) XXX_DiscardUnknown() { + xxx_messageInfo_SessionRemoved.DiscardUnknown(m) +} + +var xxx_messageInfo_SessionRemoved proto.InternalMessageInfo + +func (m *SessionRemoved) GetTokens() []string { + if m != nil { + return m.Tokens + } + return nil +} + +type SessionUpdated struct { + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Urls []string `protobuf:"bytes,2,rep,name=urls,proto3" json:"urls,omitempty"` + Service *Service `protobuf:"bytes,3,opt,name=service,proto3" json:"service,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SessionUpdated) Reset() { *m = SessionUpdated{} } +func (m *SessionUpdated) String() string { return proto.CompactTextString(m) } +func (*SessionUpdated) ProtoMessage() {} +func (*SessionUpdated) Descriptor() ([]byte, []int) { + return fileDescriptor_23f46a161f139ee1, []int{13} +} + +func (m *SessionUpdated) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SessionUpdated.Unmarshal(m, b) +} +func (m *SessionUpdated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SessionUpdated.Marshal(b, m, deterministic) +} +func (m *SessionUpdated) XXX_Merge(src proto.Message) { + xxx_messageInfo_SessionUpdated.Merge(m, src) +} +func (m *SessionUpdated) XXX_Size() int { + return xxx_messageInfo_SessionUpdated.Size(m) +} +func (m *SessionUpdated) XXX_DiscardUnknown() { + xxx_messageInfo_SessionUpdated.DiscardUnknown(m) +} + +var xxx_messageInfo_SessionUpdated proto.InternalMessageInfo + +func (m *SessionUpdated) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *SessionUpdated) GetUrls() []string { + if m != nil { + return m.Urls + } + return nil +} + +func (m *SessionUpdated) GetService() *Service { + if m != nil { + return m.Service + } + return nil +} + +func init() { + proto.RegisterEnum("edge_ctrl.pb.ContentType", ContentType_name, ContentType_value) + proto.RegisterType((*ServerHello)(nil), "edge_ctrl.pb.ServerHello") + proto.RegisterMapType((map[string]string)(nil), "edge_ctrl.pb.ServerHello.DataEntry") + proto.RegisterType((*ClientHello)(nil), "edge_ctrl.pb.ClientHello") + proto.RegisterMapType((map[string]string)(nil), "edge_ctrl.pb.ClientHello.DataEntry") + proto.RegisterType((*Error)(nil), "edge_ctrl.pb.Error") + proto.RegisterType((*Dns)(nil), "edge_ctrl.pb.Dns") + proto.RegisterType((*Service)(nil), "edge_ctrl.pb.Service") + proto.RegisterType((*Session)(nil), "edge_ctrl.pb.Session") + proto.RegisterType((*ApiSession)(nil), "edge_ctrl.pb.ApiSession") + proto.RegisterType((*ApiSessionAdded)(nil), "edge_ctrl.pb.ApiSessionAdded") + proto.RegisterType((*ApiSessionUpdated)(nil), "edge_ctrl.pb.ApiSessionUpdated") + proto.RegisterType((*ApiSessionRemoved)(nil), "edge_ctrl.pb.ApiSessionRemoved") + proto.RegisterType((*ApiSessionHeartbeat)(nil), "edge_ctrl.pb.ApiSessionHeartbeat") + proto.RegisterType((*SessionAdded)(nil), "edge_ctrl.pb.SessionAdded") + proto.RegisterType((*SessionRemoved)(nil), "edge_ctrl.pb.SessionRemoved") + proto.RegisterType((*SessionUpdated)(nil), "edge_ctrl.pb.SessionUpdated") +} + +func init() { proto.RegisterFile("edge_ctrl.proto", fileDescriptor_23f46a161f139ee1) } + +var fileDescriptor_23f46a161f139ee1 = []byte{ + // 747 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x54, 0xdb, 0x6e, 0xd3, 0x4a, + 0x14, 0x3d, 0xce, 0xa5, 0x4d, 0x76, 0xaa, 0x26, 0x9d, 0x73, 0xda, 0xe3, 0xd3, 0x03, 0x52, 0xe5, + 0xbe, 0x44, 0x05, 0x82, 0x28, 0x0f, 0x45, 0x7d, 0xab, 0x7a, 0x51, 0x25, 0x24, 0x2e, 0x6e, 0x79, + 0xe1, 0x05, 0xb9, 0xf1, 0x28, 0x58, 0x75, 0x3d, 0xd6, 0xcc, 0xa4, 0x52, 0xdf, 0x81, 0x7f, 0x40, + 0x82, 0x0a, 0xf8, 0x11, 0x7e, 0x00, 0x78, 0xe1, 0x27, 0xb8, 0xfc, 0x04, 0x7b, 0xb6, 0x2f, 0xb1, + 0x93, 0x00, 0xad, 0xc4, 0xdb, 0xec, 0xb5, 0xb6, 0x97, 0xf7, 0x5a, 0xde, 0x1e, 0x68, 0x73, 0x7f, + 0xc0, 0x9f, 0xf4, 0xb5, 0x0c, 0x7b, 0xb1, 0x14, 0x5a, 0xb0, 0xb9, 0x02, 0x70, 0xe4, 0xbc, 0xb4, + 0xa0, 0x75, 0xc0, 0xe5, 0x29, 0x97, 0xfb, 0x3c, 0x0c, 0x05, 0xb3, 0x61, 0x16, 0xcf, 0x2a, 0x10, + 0x91, 0x6d, 0xad, 0x58, 0xdd, 0xa6, 0x9b, 0x95, 0x6c, 0x03, 0x6a, 0xbe, 0xa7, 0x3d, 0xbb, 0xb2, + 0x52, 0xed, 0xb6, 0xd6, 0x57, 0x7b, 0x45, 0x99, 0x5e, 0x41, 0xa2, 0xb7, 0x83, 0x5d, 0xbb, 0x91, + 0x96, 0x67, 0x2e, 0x3d, 0xb0, 0xbc, 0x01, 0xcd, 0x1c, 0x62, 0x1d, 0xa8, 0x1e, 0xf3, 0xb3, 0x54, + 0xdb, 0x1c, 0xd9, 0x3f, 0x50, 0x3f, 0xf5, 0xc2, 0x21, 0x47, 0x61, 0x83, 0x25, 0xc5, 0x66, 0xe5, + 0x8e, 0xe5, 0x7c, 0xc6, 0xd9, 0xb6, 0xc3, 0x80, 0x47, 0xfa, 0x77, 0xb3, 0x2d, 0x43, 0xe3, 0xa9, + 0x50, 0x3a, 0xf2, 0x4e, 0x32, 0x99, 0xbc, 0x66, 0x57, 0xa0, 0x49, 0xc6, 0xfb, 0x22, 0x54, 0x76, + 0x15, 0x87, 0x6f, 0xba, 0x23, 0x20, 0x77, 0x55, 0x9b, 0xe6, 0xaa, 0xf0, 0xf2, 0x3f, 0xe7, 0xea, + 0x2e, 0xd4, 0x77, 0xa5, 0x14, 0x92, 0x31, 0xa8, 0xf5, 0x85, 0xcf, 0xd3, 0xa7, 0xe8, 0x6c, 0x2c, + 0x9e, 0x70, 0xa5, 0xbc, 0x41, 0xf6, 0x60, 0x56, 0x1a, 0xc1, 0xbe, 0x37, 0x54, 0x1c, 0x2d, 0x90, + 0x20, 0x15, 0xce, 0x43, 0xa8, 0xee, 0x44, 0xaa, 0xe4, 0xdf, 0x1a, 0xf3, 0x8f, 0xaf, 0x89, 0x85, + 0xd4, 0xa4, 0x57, 0x77, 0xe9, 0x6c, 0xfa, 0xb3, 0x08, 0x52, 0xbd, 0xbc, 0x76, 0x3e, 0x59, 0x30, + 0x6b, 0x3e, 0x67, 0xd0, 0xe7, 0x6c, 0x1e, 0x2a, 0x81, 0x9f, 0x2a, 0xe2, 0xc9, 0x68, 0x15, 0x32, + 0xa6, 0x33, 0xbb, 0x0e, 0x0b, 0x6a, 0x18, 0x1b, 0x59, 0xee, 0x3f, 0xc8, 0x44, 0x6b, 0xd4, 0x30, + 0x49, 0x30, 0x07, 0xe6, 0xf8, 0x40, 0xa2, 0x27, 0x57, 0x0c, 0x35, 0x97, 0x76, 0x9d, 0x1a, 0x4b, + 0x18, 0xeb, 0xe2, 0xd2, 0x46, 0x7e, 0x2c, 0x82, 0x48, 0x6f, 0xf9, 0xbe, 0x21, 0xec, 0x19, 0x6a, + 0x1b, 0x87, 0xd9, 0x2a, 0x54, 0xfd, 0x48, 0xd9, 0x0d, 0x64, 0x5b, 0xeb, 0x0b, 0xe5, 0x8f, 0x87, + 0xb9, 0xb8, 0x86, 0x4d, 0x0d, 0x29, 0x5a, 0x14, 0x4c, 0x51, 0x8b, 0x63, 0x9e, 0x2d, 0x50, 0x52, + 0x98, 0xd4, 0x4d, 0x5c, 0x41, 0x34, 0x20, 0x67, 0x0d, 0x37, 0x2b, 0xd9, 0x1a, 0x74, 0xfa, 0x5c, + 0xea, 0x3d, 0x3c, 0x73, 0x19, 0x4b, 0x7c, 0x75, 0xb6, 0x43, 0x13, 0xb8, 0x09, 0x67, 0x28, 0x71, + 0xc7, 0x6a, 0xc4, 0xd3, 0x99, 0xdd, 0x84, 0x59, 0x95, 0x64, 0x49, 0x4e, 0x5b, 0xeb, 0x8b, 0x93, + 0xff, 0x0d, 0x92, 0x6e, 0xd6, 0x65, 0xf2, 0x51, 0xc9, 0xac, 0x87, 0x34, 0x67, 0x62, 0xbc, 0x84, + 0x39, 0xf7, 0x00, 0xb6, 0xe2, 0xe0, 0xd7, 0x96, 0xa6, 0x0d, 0x5e, 0x99, 0x3e, 0xb8, 0x23, 0xa0, + 0x3d, 0xd2, 0xc3, 0x68, 0xb9, 0xcf, 0x56, 0xa0, 0x15, 0xa8, 0xbd, 0x61, 0x18, 0x1e, 0x68, 0x4f, + 0x27, 0x3b, 0xd5, 0x70, 0x8b, 0x10, 0xdb, 0x84, 0x96, 0x97, 0x3f, 0xa4, 0xd2, 0x5b, 0xc1, 0x2e, + 0xbb, 0x1b, 0xa9, 0xba, 0xc5, 0x66, 0xe7, 0x3e, 0x2c, 0x8c, 0xa8, 0x47, 0x31, 0xfe, 0x4f, 0xf8, + 0xca, 0x31, 0x41, 0xeb, 0x32, 0x82, 0xd7, 0x8a, 0x82, 0x2e, 0x3f, 0x11, 0xa7, 0x28, 0xb8, 0x04, + 0x33, 0x94, 0x45, 0xa2, 0xd5, 0x74, 0xd3, 0xca, 0xb9, 0x01, 0x7f, 0x8f, 0x9a, 0xf7, 0xb9, 0x27, + 0xf5, 0x11, 0xf7, 0xf4, 0x4f, 0xdb, 0xfb, 0x30, 0x77, 0xc9, 0x68, 0x6e, 0x41, 0x43, 0x95, 0x73, + 0x99, 0xf8, 0xea, 0xc9, 0xa0, 0x79, 0x9b, 0xd3, 0x85, 0xf9, 0x0b, 0x4e, 0x7f, 0x9c, 0x77, 0x66, + 0xc1, 0x4d, 0x5f, 0x80, 0x6c, 0x1b, 0x2b, 0xd3, 0xb7, 0xb1, 0x7a, 0x91, 0x6d, 0x5c, 0x7b, 0x5f, + 0xc1, 0x1b, 0x58, 0x44, 0x1a, 0x6f, 0xc1, 0xc3, 0xb3, 0x98, 0xb3, 0x06, 0xd4, 0x1e, 0x73, 0x29, + 0x3a, 0x7f, 0xb1, 0x45, 0x68, 0x17, 0xee, 0x7c, 0x43, 0x76, 0xde, 0xbc, 0xb2, 0x0c, 0x5c, 0xb8, + 0x34, 0x09, 0x7e, 0x8b, 0x70, 0x1b, 0x9a, 0x74, 0xe7, 0x11, 0xf0, 0x0e, 0x81, 0x25, 0xe8, 0x14, + 0x43, 0x25, 0xfc, 0xd9, 0x6b, 0x0b, 0xff, 0x44, 0x56, 0x76, 0x47, 0xcc, 0xf3, 0x12, 0x93, 0x26, + 0x44, 0xcc, 0x0b, 0x64, 0xfe, 0x2b, 0x7e, 0xcf, 0x91, 0xdc, 0x17, 0xa4, 0xfe, 0x87, 0xc5, 0x89, + 0x45, 0x23, 0xf2, 0xeb, 0x38, 0x59, 0x14, 0xfd, 0x86, 0xe4, 0x55, 0xf8, 0x77, 0xca, 0x92, 0x10, + 0xfd, 0x1d, 0xe9, 0x0e, 0xc0, 0x6e, 0x24, 0x45, 0x18, 0x12, 0xf2, 0xe1, 0x9c, 0x9c, 0x27, 0xc8, + 0x36, 0xfe, 0x5e, 0x8a, 0xe0, 0x8f, 0xe7, 0xd6, 0xd1, 0x0c, 0xdd, 0xab, 0xb7, 0x7f, 0x04, 0x00, + 0x00, 0xff, 0xff, 0xa4, 0x2c, 0xb1, 0x89, 0x87, 0x07, 0x00, 0x00, +} diff --git a/runner/operation.go b/runner/operation.go index 4b16c61df..68c54ac79 100644 --- a/runner/operation.go +++ b/runner/operation.go @@ -1,65 +1,65 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package runner - -import ( - "github.com/google/uuid" - "time" -) - -type Operation interface { - GetName() string - GetId() uuid.UUID - Run() error - GetFrequency() time.Duration - SetFrequency(duration time.Duration) error -} - -type BaseOperation struct { - Frequency time.Duration - Id uuid.UUID - Name string -} - -func NewBaseOperation(name string, freq time.Duration) *BaseOperation { - return &BaseOperation{ - Name: name, - Id: uuid.New(), - Frequency: freq, - } -} - -func (e *BaseOperation) GetName() string { - return e.Name -} - -func (e *BaseOperation) GetId() uuid.UUID { - if e.Id == uuid.Nil { - e.Id = uuid.New() - } - - return e.Id -} - -func (e *BaseOperation) GetFrequency() time.Duration { - return e.Frequency -} - -func (e *BaseOperation) SetFrequency(f time.Duration) error { - e.Frequency = f - return nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package runner + +import ( + "github.com/google/uuid" + "time" +) + +type Operation interface { + GetName() string + GetId() uuid.UUID + Run() error + GetFrequency() time.Duration + SetFrequency(duration time.Duration) error +} + +type BaseOperation struct { + Frequency time.Duration + Id uuid.UUID + Name string +} + +func NewBaseOperation(name string, freq time.Duration) *BaseOperation { + return &BaseOperation{ + Name: name, + Id: uuid.New(), + Frequency: freq, + } +} + +func (e *BaseOperation) GetName() string { + return e.Name +} + +func (e *BaseOperation) GetId() uuid.UUID { + if e.Id == uuid.Nil { + e.Id = uuid.New() + } + + return e.Id +} + +func (e *BaseOperation) GetFrequency() time.Duration { + return e.Frequency +} + +func (e *BaseOperation) SetFrequency(f time.Duration) error { + e.Frequency = f + return nil +} diff --git a/runner/runner.go b/runner/runner.go index 22f812659..4b80bef07 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -1,161 +1,161 @@ -/* - Copyright 2019 Netfoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package runner - -import ( - "fmt" - "github.com/google/uuid" - "github.com/pkg/errors" - "time" -) - -type ErrorHandler func(error, Operation) - -type Runner interface { - AddOperation(Operation) error - RemoveOperation(Operation) error - RemovePolicyById(uuid.UUID) (Operation, error) - Start() error - Stop() error - IsRunning() bool -} - -type LimitedRunner struct { - minFrequency time.Duration - maxFrequency time.Duration - tickerEnforcers map[uuid.UUID]*tickerEnforcer - isRunning bool - errHandler func(error, Operation) -} - -func (r *LimitedRunner) IsRunning() bool { - return r.isRunning -} - -type tickerEnforcer struct { - Enforcer Operation - Ticker *time.Ticker -} - -func (r *LimitedRunner) AddOperation(e Operation) error { - d := e.GetFrequency() - - if d < r.minFrequency { - return fmt.Errorf("error frequency too small, must be larger than %s", r.minFrequency) - } - - if d > r.maxFrequency { - return fmt.Errorf("error frequency too large, must be smaller than %s", r.minFrequency) - } - - if e.GetId() == uuid.Nil { - return fmt.Errorf("uuid must not be default/nil") - } - - r.tickerEnforcers[e.GetId()] = &tickerEnforcer{ - Enforcer: e, - Ticker: nil, - } - - return nil -} - -func (r *LimitedRunner) RemoveOperation(e Operation) error { - _, err := r.RemovePolicyById(e.GetId()) - - return err -} - -func (r *LimitedRunner) RemovePolicyById(id uuid.UUID) (Operation, error) { - te, ok := r.tickerEnforcers[id] - - if !ok { - return nil, fmt.Errorf("not found by id %s", id.String()) - } - - if te.Ticker != nil { - te.Ticker.Stop() - } - - delete(r.tickerEnforcers, id) - - return te.Enforcer, nil -} - -func (r *LimitedRunner) Start() error { - if r.isRunning { - return errors.New("already running") - } - - r.isRunning = true - - for _, te := range r.tickerEnforcers { - if te.Ticker != nil { - return errors.New("dirty ticker encountered") - } - - te.Ticker = time.NewTicker(te.Enforcer.GetFrequency()) - - go func(ite *tickerEnforcer) { - for v := range ite.Ticker.C { - if v.IsZero() { - return - } - err := ite.Enforcer.Run() - - if err != nil { - if r.errHandler == nil { - panic(err) - } - - r.errHandler(err, ite.Enforcer) - } - } - }(te) - } - return nil -} - -func (r *LimitedRunner) Stop() error { - if !r.isRunning { - return errors.New("not running") - } - - for eId := range r.tickerEnforcers { - _, err := r.RemovePolicyById(eId) - - if err != nil { - return err - } - } - - return nil -} - -func NewRunner(minF, maxF time.Duration, eh ErrorHandler) (Runner, error) { - if minF > maxF { - return nil, fmt.Errorf("min frequency may not be larger than max frequency") - } - - return &LimitedRunner{ - minFrequency: minF, - maxFrequency: maxF, - tickerEnforcers: map[uuid.UUID]*tickerEnforcer{}, - isRunning: false, - errHandler: eh, - }, nil -} +/* + Copyright 2019 Netfoundry, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package runner + +import ( + "fmt" + "github.com/google/uuid" + "github.com/pkg/errors" + "time" +) + +type ErrorHandler func(error, Operation) + +type Runner interface { + AddOperation(Operation) error + RemoveOperation(Operation) error + RemovePolicyById(uuid.UUID) (Operation, error) + Start() error + Stop() error + IsRunning() bool +} + +type LimitedRunner struct { + minFrequency time.Duration + maxFrequency time.Duration + tickerEnforcers map[uuid.UUID]*tickerEnforcer + isRunning bool + errHandler func(error, Operation) +} + +func (r *LimitedRunner) IsRunning() bool { + return r.isRunning +} + +type tickerEnforcer struct { + Enforcer Operation + Ticker *time.Ticker +} + +func (r *LimitedRunner) AddOperation(e Operation) error { + d := e.GetFrequency() + + if d < r.minFrequency { + return fmt.Errorf("error frequency too small, must be larger than %s", r.minFrequency) + } + + if d > r.maxFrequency { + return fmt.Errorf("error frequency too large, must be smaller than %s", r.minFrequency) + } + + if e.GetId() == uuid.Nil { + return fmt.Errorf("uuid must not be default/nil") + } + + r.tickerEnforcers[e.GetId()] = &tickerEnforcer{ + Enforcer: e, + Ticker: nil, + } + + return nil +} + +func (r *LimitedRunner) RemoveOperation(e Operation) error { + _, err := r.RemovePolicyById(e.GetId()) + + return err +} + +func (r *LimitedRunner) RemovePolicyById(id uuid.UUID) (Operation, error) { + te, ok := r.tickerEnforcers[id] + + if !ok { + return nil, fmt.Errorf("not found by id %s", id.String()) + } + + if te.Ticker != nil { + te.Ticker.Stop() + } + + delete(r.tickerEnforcers, id) + + return te.Enforcer, nil +} + +func (r *LimitedRunner) Start() error { + if r.isRunning { + return errors.New("already running") + } + + r.isRunning = true + + for _, te := range r.tickerEnforcers { + if te.Ticker != nil { + return errors.New("dirty ticker encountered") + } + + te.Ticker = time.NewTicker(te.Enforcer.GetFrequency()) + + go func(ite *tickerEnforcer) { + for v := range ite.Ticker.C { + if v.IsZero() { + return + } + err := ite.Enforcer.Run() + + if err != nil { + if r.errHandler == nil { + panic(err) + } + + r.errHandler(err, ite.Enforcer) + } + } + }(te) + } + return nil +} + +func (r *LimitedRunner) Stop() error { + if !r.isRunning { + return errors.New("not running") + } + + for eId := range r.tickerEnforcers { + _, err := r.RemovePolicyById(eId) + + if err != nil { + return err + } + } + + return nil +} + +func NewRunner(minF, maxF time.Duration, eh ErrorHandler) (Runner, error) { + if minF > maxF { + return nil, fmt.Errorf("min frequency may not be larger than max frequency") + } + + return &LimitedRunner{ + minFrequency: minF, + maxFrequency: maxF, + tickerEnforcers: map[uuid.UUID]*tickerEnforcer{}, + isRunning: false, + errHandler: eh, + }, nil +} diff --git a/tunnel/dns/file.go b/tunnel/dns/file.go index 257192fc7..ce54befe3 100644 --- a/tunnel/dns/file.go +++ b/tunnel/dns/file.go @@ -17,23 +17,23 @@ package dns import ( - "bufio" - "fmt" + "sync" "net" "os" - "sync" + "fmt" + "bufio" ) const hostFormat = "%s\t%s\t# NetFoundry" type hostFile struct { - path string + path string mutex sync.Mutex } func NewHostFile(path string) Resolver { return &hostFile{ - path: path, + path: path, mutex: sync.Mutex{}, } } @@ -80,4 +80,4 @@ func (h hostFile) RemoveHostname(s string, ip net.IP) error { func (h hostFile) Cleanup() error { return nil -} +} \ No newline at end of file diff --git a/tunnel/dns/resolver.go b/tunnel/dns/resolver.go index 51b9b193a..a5322aa09 100644 --- a/tunnel/dns/resolver.go +++ b/tunnel/dns/resolver.go @@ -18,7 +18,7 @@ package dns import "net" -type Resolver interface { +type Resolver interface{ AddHostname(string, net.IP) error RemoveHostname(string, net.IP) error Cleanup() error diff --git a/tunnel/intercept/protocols/ip/decode.go b/tunnel/intercept/protocols/ip/decode.go index 26a8848d3..31b31599c 100644 --- a/tunnel/intercept/protocols/ip/decode.go +++ b/tunnel/intercept/protocols/ip/decode.go @@ -45,4 +45,4 @@ func Decode(packet []byte) (net.IP, net.IP, int, []byte, error) { } return src, dst, l4Proto, payload, nil -} +} \ No newline at end of file diff --git a/tunnel/router/router_linux.go b/tunnel/router/router_linux.go index 55cae9666..8c3ee770b 100644 --- a/tunnel/router/router_linux.go +++ b/tunnel/router/router_linux.go @@ -118,6 +118,7 @@ func nlAddrReq(localPrefix, peerPrefix *net.IPNet, ifName string, t netlink.Head Data: append(ifmBytes, attrBytes...), } + _, err = c.Execute(req) if err != nil { var nlErr *netlink.OpError diff --git a/tunnel/udp_vconn/policy.go b/tunnel/udp_vconn/policy.go index 80f047d1c..70b309052 100644 --- a/tunnel/udp_vconn/policy.go +++ b/tunnel/udp_vconn/policy.go @@ -64,3 +64,5 @@ func (policy defaultExpirationPolicy) IsExpired(now, lastUsed time.Time) bool { func (policy defaultExpirationPolicy) PollFrequency() time.Duration { return time.Minute * 1 } + +