subscription

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSubscriptionNameRequired = errors.New("subscription name is required")
	ErrProvidersRequired        = errors.New("at least one provider is required")
	ErrReservedProxyGroup       = errors.New("Proxies proxy-group cannot be deleted")
	ErrReservedProxiesRequired  = errors.New("Proxies proxy-group is required at position 0")
	ErrReservedProxiesNotFirst  = errors.New("Proxies proxy-group must stay first at position 0")
	ErrDuplicateRuleBinding     = errors.New("internal proxy group already bound")
	ErrNotFound                 = errors.New("subscription not found")
)

Functions

This section is empty.

Types

type ClashConfigProxyGroup

type ClashConfigProxyGroup struct {
	ID                  int64         `json:"id"`
	Name                string        `json:"name"`
	Type                string        `json:"type"`
	Position            int64         `json:"position"`
	URL                 string        `json:"url"`
	Interval            int64         `json:"interval"`
	Proxies             []ProxyMember `json:"proxies"`
	BindInternalGroupID int64         `json:"bind_internal_proxy_group_id"`
	IsSystem            bool          `json:"is_system"`
}

type ClashConfigSubscription

type ClashConfigSubscription struct {
	ID          int64                   `json:"id"`
	Name        string                  `json:"name"`
	Providers   []int64                 `json:"providers"`
	ProxyGroups []ClashConfigProxyGroup `json:"proxy_groups"`
	CreatedAt   time.Time               `json:"created_at"`
	UpdatedAt   time.Time               `json:"updated_at"`
}

type CreateClashConfigProxyGroupInput

type CreateClashConfigProxyGroupInput struct {
	Name                string        `json:"name"`
	Type                string        `json:"type"`
	Position            int64         `json:"position"`
	URL                 string        `json:"url"`
	Interval            int64         `json:"interval"`
	Proxies             []ProxyMember `json:"proxies"`
	BindInternalGroupID int64         `json:"bind_internal_proxy_group_id"`
}

type CreateClashConfigSubscriptionInput

type CreateClashConfigSubscriptionInput struct {
	Name        string                             `json:"name"`
	Providers   []int64                            `json:"providers"`
	ProxyGroups []CreateClashConfigProxyGroupInput `json:"proxy_groups"`
}

type CreateProxyProviderSubscriptionInput

type CreateProxyProviderSubscriptionInput struct {
	Name                 string  `json:"name"`
	Providers            []int64 `json:"providers"`
	InternalProxyGroupID int64   `json:"internal_proxy_group_id"`
}

type CreateRuleProviderSubscriptionInput

type CreateRuleProviderSubscriptionInput struct {
	Name                 string  `json:"name"`
	Providers            []int64 `json:"providers"`
	InternalProxyGroupID int64   `json:"internal_proxy_group_id"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

type ProxyMember

type ProxyMember struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type ProxyProviderSubscription

type ProxyProviderSubscription struct {
	ID                   int64     `json:"id"`
	Name                 string    `json:"name"`
	Providers            []int64   `json:"providers"`
	InternalProxyGroupID int64     `json:"internal_proxy_group_id"`
	CreatedAt            time.Time `json:"created_at"`
	UpdatedAt            time.Time `json:"updated_at"`
}

type RenderedContent

type RenderedContent struct {
	ContentType          string
	SubscriptionUserinfo string
	Body                 string
}

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(db *sql.DB) *Repository

func (*Repository) CreateSystemProxyGroup

func (r *Repository) CreateSystemProxyGroup(ctx context.Context, subscriptionID int64, in CreateClashConfigProxyGroupInput) (ClashConfigProxyGroup, error)

func (*Repository) DeleteClashConfig

func (r *Repository) DeleteClashConfig(ctx context.Context, id int64) error

func (*Repository) DeleteProxyProvider

func (r *Repository) DeleteProxyProvider(ctx context.Context, id int64) error

func (*Repository) DeleteRuleProvider

func (r *Repository) DeleteRuleProvider(ctx context.Context, id int64) error

func (*Repository) GetClashConfigByID

func (r *Repository) GetClashConfigByID(ctx context.Context, id int64) (ClashConfigSubscription, error)

func (*Repository) GetProxyProviderByID

func (r *Repository) GetProxyProviderByID(ctx context.Context, id int64) (ProxyProviderSubscription, error)

func (*Repository) GetRuleProviderByID

func (r *Repository) GetRuleProviderByID(ctx context.Context, id int64) (RuleProviderSubscription, error)

func (*Repository) ListClashConfigs

func (r *Repository) ListClashConfigs(ctx context.Context) ([]ClashConfigSubscription, error)

func (*Repository) ListProxyProviders

func (r *Repository) ListProxyProviders(ctx context.Context) ([]ProxyProviderSubscription, error)

func (*Repository) ListRuleProviders

func (r *Repository) ListRuleProviders(ctx context.Context) ([]RuleProviderSubscription, error)

func (*Repository) ProviderReferencedByAnySubscription

func (r *Repository) ProviderReferencedByAnySubscription(ctx context.Context, providerID int64) (bool, error)

type RuleProviderSubscription

type RuleProviderSubscription struct {
	ID                   int64     `json:"id"`
	Name                 string    `json:"name"`
	Providers            []int64   `json:"providers"`
	InternalProxyGroupID int64     `json:"internal_proxy_group_id"`
	CreatedAt            time.Time `json:"created_at"`
	UpdatedAt            time.Time `json:"updated_at"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repo *Repository, providerRepo *provider.Repository, groupSvc *group.Service, ruleRepo *rule.Repository, templatePath string) *Service

func (*Service) BuildClashConfigContent

func (s *Service) BuildClashConfigContent(ctx context.Context, id int64) (RenderedContent, error)

func (*Service) BuildProxyProviderContent

func (s *Service) BuildProxyProviderContent(ctx context.Context, id int64) (RenderedContent, error)

func (*Service) BuildRuleProviderContent

func (s *Service) BuildRuleProviderContent(ctx context.Context, id int64) (RenderedContent, error)

func (*Service) DeleteClashConfig

func (s *Service) DeleteClashConfig(ctx context.Context, id int64) error

func (*Service) DeleteProxyProvider

func (s *Service) DeleteProxyProvider(ctx context.Context, id int64) error

func (*Service) DeleteRuleProvider

func (s *Service) DeleteRuleProvider(ctx context.Context, id int64) error

func (*Service) GetClashConfigByID

func (s *Service) GetClashConfigByID(ctx context.Context, id int64) (ClashConfigSubscription, error)

func (*Service) GetProxyProviderByID

func (s *Service) GetProxyProviderByID(ctx context.Context, id int64) (ProxyProviderSubscription, error)

func (*Service) GetRuleProviderByID

func (s *Service) GetRuleProviderByID(ctx context.Context, id int64) (RuleProviderSubscription, error)

func (*Service) ListClashConfigs

func (s *Service) ListClashConfigs(ctx context.Context) ([]ClashConfigSubscription, error)

func (*Service) ListProxyProviders

func (s *Service) ListProxyProviders(ctx context.Context) ([]ProxyProviderSubscription, error)

func (*Service) ListRuleProviders

func (s *Service) ListRuleProviders(ctx context.Context) ([]RuleProviderSubscription, error)

func (*Service) ProviderReferencedByAnySubscription

func (s *Service) ProviderReferencedByAnySubscription(ctx context.Context, providerID int64) (bool, error)

type UpdateClashConfigSubscriptionInput

type UpdateClashConfigSubscriptionInput struct {
	Name        string                             `json:"name"`
	Providers   []int64                            `json:"providers"`
	ProxyGroups []CreateClashConfigProxyGroupInput `json:"proxy_groups"`
}

type UpdateProxyProviderSubscriptionInput

type UpdateProxyProviderSubscriptionInput struct {
	Name                 string  `json:"name"`
	Providers            []int64 `json:"providers"`
	InternalProxyGroupID int64   `json:"internal_proxy_group_id"`
}

type UpdateRuleProviderSubscriptionInput

type UpdateRuleProviderSubscriptionInput struct {
	Name                 string  `json:"name"`
	Providers            []int64 `json:"providers"`
	InternalProxyGroupID int64   `json:"internal_proxy_group_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL