新增功能: - 新增 TLS 指纹 Profile CRUD 管理(Ent schema + 迁移 + Admin API + 前端管理界面) - 支持账号绑定数据库中的自定义 TLS Profile,或随机选择(profile_id=-1) - HTTPUpstream.DoWithTLS 接口从 bool 改为 *tlsfingerprint.Profile,支持按账号指定 Profile - AccountUsageService 注入 TLSFingerprintProfileService,统一 usage 场景与网关的 Profile 解析逻辑 代码优化: - 删除已被 TLSFingerprintProfileService 完全取代的 registry.go 死代码(418 行) - 提取 3 个 dialer 的重复 TLS 握手逻辑为 performTLSHandshake() 共用函数 - 修复 GetTLSFingerprintProfileID 缺少 json.Number 处理的 bug - gateway_service.Forward 中 ResolveTLSProfile 从重试循环内重复调用改为预解析局部变量 - 删除冗余的 buildClientHelloSpec() 单行 wrapper 和 int64(e.ID) 无效转换 - tls_fingerprint_profile_cache.go 日志从 log.Printf 改为 slog 结构化日志 - dialer_capture_test.go 添加 //go:build integration 标签,防止 CI 失败 - 去重 TestProfileExpectation 类型至共享 test_types_test.go - 修复 9 个测试文件缺少 tlsfingerprint import 的编译错误 - 修复 error_policy_integration_test.go 中 handleError 回调签名被错误替换的问题
882 lines
30 KiB
Go
882 lines
30 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/dialect/sql/sqljson"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
|
"github.com/Wei-Shaw/sub2api/ent/tlsfingerprintprofile"
|
|
)
|
|
|
|
// TLSFingerprintProfileUpdate is the builder for updating TLSFingerprintProfile entities.
|
|
type TLSFingerprintProfileUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *TLSFingerprintProfileMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the TLSFingerprintProfileUpdate builder.
|
|
func (_u *TLSFingerprintProfileUpdate) Where(ps ...predicate.TLSFingerprintProfile) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetUpdatedAt(v time.Time) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetName(v string) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *TLSFingerprintProfileUpdate) SetNillableName(v *string) *TLSFingerprintProfileUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetDescription(v string) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *TLSFingerprintProfileUpdate) SetNillableDescription(v *string) *TLSFingerprintProfileUpdate {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearDescription() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetEnableGrease sets the "enable_grease" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetEnableGrease(v bool) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetEnableGrease(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEnableGrease sets the "enable_grease" field if the given value is not nil.
|
|
func (_u *TLSFingerprintProfileUpdate) SetNillableEnableGrease(v *bool) *TLSFingerprintProfileUpdate {
|
|
if v != nil {
|
|
_u.SetEnableGrease(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCipherSuites sets the "cipher_suites" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetCipherSuites(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetCipherSuites(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendCipherSuites appends value to the "cipher_suites" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendCipherSuites(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendCipherSuites(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearCipherSuites clears the value of the "cipher_suites" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearCipherSuites() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearCipherSuites()
|
|
return _u
|
|
}
|
|
|
|
// SetCurves sets the "curves" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetCurves(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetCurves(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendCurves appends value to the "curves" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendCurves(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendCurves(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearCurves clears the value of the "curves" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearCurves() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearCurves()
|
|
return _u
|
|
}
|
|
|
|
// SetPointFormats sets the "point_formats" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetPointFormats(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetPointFormats(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendPointFormats appends value to the "point_formats" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendPointFormats(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendPointFormats(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPointFormats clears the value of the "point_formats" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearPointFormats() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearPointFormats()
|
|
return _u
|
|
}
|
|
|
|
// SetSignatureAlgorithms sets the "signature_algorithms" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetSignatureAlgorithms(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetSignatureAlgorithms(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendSignatureAlgorithms appends value to the "signature_algorithms" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendSignatureAlgorithms(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendSignatureAlgorithms(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearSignatureAlgorithms clears the value of the "signature_algorithms" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearSignatureAlgorithms() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearSignatureAlgorithms()
|
|
return _u
|
|
}
|
|
|
|
// SetAlpnProtocols sets the "alpn_protocols" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetAlpnProtocols(v []string) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetAlpnProtocols(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendAlpnProtocols appends value to the "alpn_protocols" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendAlpnProtocols(v []string) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendAlpnProtocols(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearAlpnProtocols clears the value of the "alpn_protocols" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearAlpnProtocols() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearAlpnProtocols()
|
|
return _u
|
|
}
|
|
|
|
// SetSupportedVersions sets the "supported_versions" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetSupportedVersions(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetSupportedVersions(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendSupportedVersions appends value to the "supported_versions" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendSupportedVersions(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendSupportedVersions(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearSupportedVersions clears the value of the "supported_versions" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearSupportedVersions() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearSupportedVersions()
|
|
return _u
|
|
}
|
|
|
|
// SetKeyShareGroups sets the "key_share_groups" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetKeyShareGroups(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetKeyShareGroups(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendKeyShareGroups appends value to the "key_share_groups" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendKeyShareGroups(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendKeyShareGroups(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearKeyShareGroups clears the value of the "key_share_groups" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearKeyShareGroups() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearKeyShareGroups()
|
|
return _u
|
|
}
|
|
|
|
// SetPskModes sets the "psk_modes" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetPskModes(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetPskModes(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendPskModes appends value to the "psk_modes" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendPskModes(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendPskModes(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPskModes clears the value of the "psk_modes" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearPskModes() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearPskModes()
|
|
return _u
|
|
}
|
|
|
|
// SetExtensions sets the "extensions" field.
|
|
func (_u *TLSFingerprintProfileUpdate) SetExtensions(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.SetExtensions(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendExtensions appends value to the "extensions" field.
|
|
func (_u *TLSFingerprintProfileUpdate) AppendExtensions(v []uint16) *TLSFingerprintProfileUpdate {
|
|
_u.mutation.AppendExtensions(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearExtensions clears the value of the "extensions" field.
|
|
func (_u *TLSFingerprintProfileUpdate) ClearExtensions() *TLSFingerprintProfileUpdate {
|
|
_u.mutation.ClearExtensions()
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the TLSFingerprintProfileMutation object of the builder.
|
|
func (_u *TLSFingerprintProfileUpdate) Mutation() *TLSFingerprintProfileMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *TLSFingerprintProfileUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *TLSFingerprintProfileUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *TLSFingerprintProfileUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *TLSFingerprintProfileUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *TLSFingerprintProfileUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := tlsfingerprintprofile.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *TLSFingerprintProfileUpdate) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := tlsfingerprintprofile.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TLSFingerprintProfile.name": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *TLSFingerprintProfileUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(tlsfingerprintprofile.Table, tlsfingerprintprofile.Columns, sqlgraph.NewFieldSpec(tlsfingerprintprofile.FieldID, field.TypeInt64))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DescriptionCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.EnableGrease(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldEnableGrease, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.CipherSuites(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldCipherSuites, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedCipherSuites(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldCipherSuites, value)
|
|
})
|
|
}
|
|
if _u.mutation.CipherSuitesCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldCipherSuites, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Curves(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldCurves, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedCurves(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldCurves, value)
|
|
})
|
|
}
|
|
if _u.mutation.CurvesCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldCurves, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.PointFormats(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldPointFormats, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedPointFormats(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldPointFormats, value)
|
|
})
|
|
}
|
|
if _u.mutation.PointFormatsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldPointFormats, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.SignatureAlgorithms(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldSignatureAlgorithms, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedSignatureAlgorithms(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldSignatureAlgorithms, value)
|
|
})
|
|
}
|
|
if _u.mutation.SignatureAlgorithmsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldSignatureAlgorithms, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.AlpnProtocols(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldAlpnProtocols, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedAlpnProtocols(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldAlpnProtocols, value)
|
|
})
|
|
}
|
|
if _u.mutation.AlpnProtocolsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldAlpnProtocols, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.SupportedVersions(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldSupportedVersions, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedSupportedVersions(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldSupportedVersions, value)
|
|
})
|
|
}
|
|
if _u.mutation.SupportedVersionsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldSupportedVersions, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.KeyShareGroups(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldKeyShareGroups, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedKeyShareGroups(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldKeyShareGroups, value)
|
|
})
|
|
}
|
|
if _u.mutation.KeyShareGroupsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldKeyShareGroups, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.PskModes(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldPskModes, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedPskModes(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldPskModes, value)
|
|
})
|
|
}
|
|
if _u.mutation.PskModesCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldPskModes, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Extensions(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldExtensions, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedExtensions(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldExtensions, value)
|
|
})
|
|
}
|
|
if _u.mutation.ExtensionsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldExtensions, field.TypeJSON)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{tlsfingerprintprofile.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// TLSFingerprintProfileUpdateOne is the builder for updating a single TLSFingerprintProfile entity.
|
|
type TLSFingerprintProfileUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *TLSFingerprintProfileMutation
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetUpdatedAt(v time.Time) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetName(v string) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetNillableName(v *string) *TLSFingerprintProfileUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetDescription(v string) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetNillableDescription(v *string) *TLSFingerprintProfileUpdateOne {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearDescription() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetEnableGrease sets the "enable_grease" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetEnableGrease(v bool) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetEnableGrease(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEnableGrease sets the "enable_grease" field if the given value is not nil.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetNillableEnableGrease(v *bool) *TLSFingerprintProfileUpdateOne {
|
|
if v != nil {
|
|
_u.SetEnableGrease(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCipherSuites sets the "cipher_suites" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetCipherSuites(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetCipherSuites(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendCipherSuites appends value to the "cipher_suites" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendCipherSuites(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendCipherSuites(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearCipherSuites clears the value of the "cipher_suites" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearCipherSuites() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearCipherSuites()
|
|
return _u
|
|
}
|
|
|
|
// SetCurves sets the "curves" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetCurves(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetCurves(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendCurves appends value to the "curves" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendCurves(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendCurves(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearCurves clears the value of the "curves" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearCurves() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearCurves()
|
|
return _u
|
|
}
|
|
|
|
// SetPointFormats sets the "point_formats" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetPointFormats(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetPointFormats(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendPointFormats appends value to the "point_formats" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendPointFormats(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendPointFormats(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPointFormats clears the value of the "point_formats" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearPointFormats() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearPointFormats()
|
|
return _u
|
|
}
|
|
|
|
// SetSignatureAlgorithms sets the "signature_algorithms" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetSignatureAlgorithms(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetSignatureAlgorithms(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendSignatureAlgorithms appends value to the "signature_algorithms" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendSignatureAlgorithms(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendSignatureAlgorithms(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearSignatureAlgorithms clears the value of the "signature_algorithms" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearSignatureAlgorithms() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearSignatureAlgorithms()
|
|
return _u
|
|
}
|
|
|
|
// SetAlpnProtocols sets the "alpn_protocols" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetAlpnProtocols(v []string) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetAlpnProtocols(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendAlpnProtocols appends value to the "alpn_protocols" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendAlpnProtocols(v []string) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendAlpnProtocols(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearAlpnProtocols clears the value of the "alpn_protocols" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearAlpnProtocols() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearAlpnProtocols()
|
|
return _u
|
|
}
|
|
|
|
// SetSupportedVersions sets the "supported_versions" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetSupportedVersions(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetSupportedVersions(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendSupportedVersions appends value to the "supported_versions" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendSupportedVersions(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendSupportedVersions(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearSupportedVersions clears the value of the "supported_versions" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearSupportedVersions() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearSupportedVersions()
|
|
return _u
|
|
}
|
|
|
|
// SetKeyShareGroups sets the "key_share_groups" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetKeyShareGroups(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetKeyShareGroups(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendKeyShareGroups appends value to the "key_share_groups" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendKeyShareGroups(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendKeyShareGroups(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearKeyShareGroups clears the value of the "key_share_groups" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearKeyShareGroups() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearKeyShareGroups()
|
|
return _u
|
|
}
|
|
|
|
// SetPskModes sets the "psk_modes" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetPskModes(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetPskModes(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendPskModes appends value to the "psk_modes" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendPskModes(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendPskModes(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPskModes clears the value of the "psk_modes" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearPskModes() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearPskModes()
|
|
return _u
|
|
}
|
|
|
|
// SetExtensions sets the "extensions" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SetExtensions(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.SetExtensions(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendExtensions appends value to the "extensions" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) AppendExtensions(v []uint16) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.AppendExtensions(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearExtensions clears the value of the "extensions" field.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ClearExtensions() *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.ClearExtensions()
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the TLSFingerprintProfileMutation object of the builder.
|
|
func (_u *TLSFingerprintProfileUpdateOne) Mutation() *TLSFingerprintProfileMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the TLSFingerprintProfileUpdate builder.
|
|
func (_u *TLSFingerprintProfileUpdateOne) Where(ps ...predicate.TLSFingerprintProfile) *TLSFingerprintProfileUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *TLSFingerprintProfileUpdateOne) Select(field string, fields ...string) *TLSFingerprintProfileUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated TLSFingerprintProfile entity.
|
|
func (_u *TLSFingerprintProfileUpdateOne) Save(ctx context.Context) (*TLSFingerprintProfile, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *TLSFingerprintProfileUpdateOne) SaveX(ctx context.Context) *TLSFingerprintProfile {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *TLSFingerprintProfileUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *TLSFingerprintProfileUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *TLSFingerprintProfileUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := tlsfingerprintprofile.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *TLSFingerprintProfileUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := tlsfingerprintprofile.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "TLSFingerprintProfile.name": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *TLSFingerprintProfileUpdateOne) sqlSave(ctx context.Context) (_node *TLSFingerprintProfile, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(tlsfingerprintprofile.Table, tlsfingerprintprofile.Columns, sqlgraph.NewFieldSpec(tlsfingerprintprofile.FieldID, field.TypeInt64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "TLSFingerprintProfile.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, tlsfingerprintprofile.FieldID)
|
|
for _, f := range fields {
|
|
if !tlsfingerprintprofile.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != tlsfingerprintprofile.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DescriptionCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.EnableGrease(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldEnableGrease, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.CipherSuites(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldCipherSuites, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedCipherSuites(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldCipherSuites, value)
|
|
})
|
|
}
|
|
if _u.mutation.CipherSuitesCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldCipherSuites, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Curves(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldCurves, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedCurves(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldCurves, value)
|
|
})
|
|
}
|
|
if _u.mutation.CurvesCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldCurves, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.PointFormats(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldPointFormats, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedPointFormats(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldPointFormats, value)
|
|
})
|
|
}
|
|
if _u.mutation.PointFormatsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldPointFormats, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.SignatureAlgorithms(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldSignatureAlgorithms, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedSignatureAlgorithms(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldSignatureAlgorithms, value)
|
|
})
|
|
}
|
|
if _u.mutation.SignatureAlgorithmsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldSignatureAlgorithms, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.AlpnProtocols(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldAlpnProtocols, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedAlpnProtocols(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldAlpnProtocols, value)
|
|
})
|
|
}
|
|
if _u.mutation.AlpnProtocolsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldAlpnProtocols, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.SupportedVersions(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldSupportedVersions, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedSupportedVersions(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldSupportedVersions, value)
|
|
})
|
|
}
|
|
if _u.mutation.SupportedVersionsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldSupportedVersions, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.KeyShareGroups(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldKeyShareGroups, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedKeyShareGroups(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldKeyShareGroups, value)
|
|
})
|
|
}
|
|
if _u.mutation.KeyShareGroupsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldKeyShareGroups, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.PskModes(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldPskModes, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedPskModes(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldPskModes, value)
|
|
})
|
|
}
|
|
if _u.mutation.PskModesCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldPskModes, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Extensions(); ok {
|
|
_spec.SetField(tlsfingerprintprofile.FieldExtensions, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedExtensions(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, tlsfingerprintprofile.FieldExtensions, value)
|
|
})
|
|
}
|
|
if _u.mutation.ExtensionsCleared() {
|
|
_spec.ClearField(tlsfingerprintprofile.FieldExtensions, field.TypeJSON)
|
|
}
|
|
_node = &TLSFingerprintProfile{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{tlsfingerprintprofile.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|