builder

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildConfig

type BuildConfig struct {
	Isnew bool

	DefaultBuilt bool

	DefaultDnsServerTag string
	DefaultOutbound     string
	DefaultInbound      string

	//DnsOpt *option.DNSOptions
	RouteOpt *option.RouteOptions
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(ctx context.Context, path string, store *ConfigStore, logger *zap.Logger) (*BuildConfig, error)

func (*BuildConfig) AddCacheFile

func (b *BuildConfig) AddCacheFile() error

func (*BuildConfig) AddClashApi

func (b *BuildConfig) AddClashApi() error

func (*BuildConfig) AddDnsRule

func (b *BuildConfig) AddDnsRule(tagName string, server string) error

func (*BuildConfig) AddDnsRuleObj

func (b *BuildConfig) AddDnsRuleObj(rule option.DNSRule) error

func (*BuildConfig) AddDnsServer

func (b *BuildConfig) AddDnsServer(dnsServer option.DNSServerOptions) error

func (*BuildConfig) AddDnsServerRaw

func (b *BuildConfig) AddDnsServerRaw(in []byte) error

func (*BuildConfig) AddExperminatl

func (b *BuildConfig) AddExperminatl() error

optional

func (*BuildConfig) AddExtranalOutbound

func (b *BuildConfig) AddExtranalOutbound() error

get the outbound from user

func (*BuildConfig) AddInbound

func (b *BuildConfig) AddInbound(preName string) error

Inbounds handling

func (*BuildConfig) AddOutbound

func (b *BuildConfig) AddOutbound(sboxot db.Config, serverIN sbox.Inboud, sni string) error

this can add outbound via userconfig only support vless ws

func (*BuildConfig) AddRawDns

func (b *BuildConfig) AddRawDns(in []byte, tagName string) error

func (*BuildConfig) AddRawOut

func (b *BuildConfig) AddRawOut(out *option.Outbound) error

func (*BuildConfig) AddRawRoute

func (b *BuildConfig) AddRawRoute(in []byte, ref string) error

func (*BuildConfig) AddRouteRule

func (b *BuildConfig) AddRouteRule(tagName string, outbound string) error

func (*BuildConfig) AddRouteRuleOb

func (b *BuildConfig) AddRouteRuleOb(rule option.Rule) error

func (*BuildConfig) AddRouteRuleSet

func (b *BuildConfig) AddRouteRuleSet(ruleset option.RuleSet) error

func (*BuildConfig) AddRouteRuleSetRaw

func (b *BuildConfig) AddRouteRuleSetRaw(rulesetraw []byte) error

func (*BuildConfig) AddToSelector

func (b *BuildConfig) AddToSelector(tag string)

func (*BuildConfig) AddoutJson

func (b *BuildConfig) AddoutJson(bound []byte) error

func (*BuildConfig) BuildDefault

func (b *BuildConfig) BuildDefault() error

BuildDefault

func (*BuildConfig) BuildDefaultDns

func (b *BuildConfig) BuildDefaultDns() error

DNS handlin

func (*BuildConfig) BuildDefaultInbounds

func (b *BuildConfig) BuildDefaultInbounds() error

func (*BuildConfig) BuildDefaultLog

func (b *BuildConfig) BuildDefaultLog() error

func (*BuildConfig) BuildDefaultOutbound

func (b *BuildConfig) BuildDefaultOutbound() error

Outbounds handling

func (*BuildConfig) BuildDefaultRoute

func (b *BuildConfig) BuildDefaultRoute() error

Routing Handling

func (*BuildConfig) CacheFile

func (b *BuildConfig) CacheFile() error

func (*BuildConfig) ChageTransport

func (b *BuildConfig) ChageTransport(tag string, transport *option.V2RayTransportOptions) error

func (*BuildConfig) ChangeCache

func (b *BuildConfig) ChangeCache(changer, val string) error

func (*BuildConfig) ChangeClash

func (b *BuildConfig) ChangeClash(changer, val string) error

func (*BuildConfig) ChangeDialer

func (b *BuildConfig) ChangeDialer(outname, changer, value string) error

func (*BuildConfig) ChangeDnsServerOpts

func (b *BuildConfig) ChangeDnsServerOpts(tag, changer, val string) error

func (*BuildConfig) ChangeInboundOption

func (b *BuildConfig) ChangeInboundOption(inname, changer, value string) error

func (*BuildConfig) ChangeMultiplex

func (b *BuildConfig) ChangeMultiplex(outname, changer, value string) error

func (*BuildConfig) ChangeRuleSet

func (b *BuildConfig) ChangeRuleSet(rulesetatg, changer, val string) error

func (*BuildConfig) ChangeSelfInbound

func (b *BuildConfig) ChangeSelfInbound(inname, changer, value string) error

func (*BuildConfig) ChangeSelfOutbound

func (b *BuildConfig) ChangeSelfOutbound(outname, changer, value string) error

func (*BuildConfig) ChangeServer

func (b *BuildConfig) ChangeServer(outname string, newserver string) error

func (*BuildConfig) ChangeSni

func (b *BuildConfig) ChangeSni(outname string, newsni string) error

func (*BuildConfig) ChangeTLS

func (b *BuildConfig) ChangeTLS(outname, changer, value string) error

func (*BuildConfig) ChangeTlsSettings

func (b *BuildConfig) ChangeTlsSettings(tag string, Tls *option.OutboundTLSOptions) error

func (*BuildConfig) ChangeTransport

func (b *BuildConfig) ChangeTransport(outname, changer, value string) error

func (*BuildConfig) ChangeUUID

func (b *BuildConfig) ChangeUUID(outname string, newuuid string) error

func (*BuildConfig) CheckDnsRule

func (b *BuildConfig) CheckDnsRule(tag string) bool

func (*BuildConfig) CheckDnsServer

func (b *BuildConfig) CheckDnsServer(tag string) bool

func (*BuildConfig) CheckOutbound

func (b *BuildConfig) CheckOutbound(tag string) bool

func (*BuildConfig) CheckRule

func (b *BuildConfig) CheckRule(tag string) bool

func (*BuildConfig) CheckRuleSet

func (b *BuildConfig) CheckRuleSet(tag string) bool

func (*BuildConfig) Close

func (b *BuildConfig) Close() error

func (*BuildConfig) DnsClient

func (b *BuildConfig) DnsClient() error

func (*BuildConfig) Export

func (b *BuildConfig) Export() any

func (*BuildConfig) ExportAllInbounds

func (b *BuildConfig) ExportAllInbounds() any

func (*BuildConfig) ExportAllOutbounds

func (b *BuildConfig) ExportAllOutbounds() any

func (*BuildConfig) ExportDns

func (b *BuildConfig) ExportDns() any

func (*BuildConfig) ExportDnsRule

func (b *BuildConfig) ExportDnsRule(tag string) any

func (*BuildConfig) ExportDnsServer

func (b *BuildConfig) ExportDnsServer(tag string) any

func (*BuildConfig) ExportExpermental

func (b *BuildConfig) ExportExpermental() any

func (*BuildConfig) ExportInbound

func (b *BuildConfig) ExportInbound(tag string) any

func (*BuildConfig) ExportOutbound

func (b *BuildConfig) ExportOutbound(tag string) any

func (*BuildConfig) ExportRoute

func (b *BuildConfig) ExportRoute() any

func (*BuildConfig) ExportRouteRule

func (b *BuildConfig) ExportRouteRule(tag string) any

func (*BuildConfig) ExportRuleSet

func (b *BuildConfig) ExportRuleSet(tag string) any

func (*BuildConfig) GetAllInNames

func (b *BuildConfig) GetAllInNames() []string

func (*BuildConfig) GetAllOutNames

func (b *BuildConfig) GetAllOutNames() []string

func (*BuildConfig) GetDnsRule

func (b *BuildConfig) GetDnsRule(tag string) option.DNSRule

func (*BuildConfig) GetDnsRules

func (b *BuildConfig) GetDnsRules() map[string]*option.DNSRule

func (*BuildConfig) GetDnsServer

func (b *BuildConfig) GetDnsServer(tag string) (*option.DNSServerOptions, error)

func (*BuildConfig) GetDnsServers

func (b *BuildConfig) GetDnsServers() map[string]*option.DNSServerOptions

func (*BuildConfig) GetInType

func (b *BuildConfig) GetInType(inname string) string

func (*BuildConfig) GetOutNames

func (b *BuildConfig) GetOutNames() []string

func (*BuildConfig) GetRouteRule

func (b *BuildConfig) GetRouteRule(tag string) option.Rule

func (*BuildConfig) GetRouteRuleSet

func (b *BuildConfig) GetRouteRuleSet(tag string) (*option.RuleSet, error)

func (*BuildConfig) GetRouteRuleSetTags

func (b *BuildConfig) GetRouteRuleSetTags() []string

func (*BuildConfig) GetRouteRuleSets

func (b *BuildConfig) GetRouteRuleSets() map[string]*option.RuleSet

func (*BuildConfig) GetRouteRules

func (b *BuildConfig) GetRouteRules() map[string]*option.Rule

func (*BuildConfig) GetSelector

func (b *BuildConfig) GetSelector() *option.Outbound

func (*BuildConfig) OutType

func (b *BuildConfig) OutType(tag string) string

func (*BuildConfig) RemoveCacehFile

func (b *BuildConfig) RemoveCacehFile()

func (*BuildConfig) RemoveClashApi

func (b *BuildConfig) RemoveClashApi()

func (*BuildConfig) RemoveDnsRule

func (b *BuildConfig) RemoveDnsRule(ruleTag string)

func (*BuildConfig) RemoveDnsServer

func (b *BuildConfig) RemoveDnsServer(tag string) error

func (*BuildConfig) RemoveInbound

func (b *BuildConfig) RemoveInbound(tagName string) error

func (*BuildConfig) RemoveOutbound

func (b *BuildConfig) RemoveOutbound(tagName string) error

func (*BuildConfig) RemoveRouteRule

func (b *BuildConfig) RemoveRouteRule(tag string)

should update fetched rules again after

func (*BuildConfig) RemoveRouteRuleSet

func (b *BuildConfig) RemoveRouteRuleSet(tag string) error

func (*BuildConfig) RemoveSelector

func (b *BuildConfig) RemoveSelector(tag string)

func (*BuildConfig) RemoveTls

func (b *BuildConfig) RemoveTls(tag string) error

func (*BuildConfig) SetDefaultDns

func (b *BuildConfig) SetDefaultDns(serverTag string) error

func (*BuildConfig) SetExportCallback

func (b *BuildConfig) SetExportCallback(callback func(b []byte) any)

func (*BuildConfig) SetListToDnsRule

func (b *BuildConfig) SetListToDnsRule(tagname, listname string, listable []string) error

func (*BuildConfig) SetListTorule

func (b *BuildConfig) SetListTorule(tagname, listname string, listable []string) error

func (*BuildConfig) SetRouteFinal

func (b *BuildConfig) SetRouteFinal(final string) error

func (*BuildConfig) SetRuleOutbound

func (b *BuildConfig) SetRuleOutbound(tagname, outname string) error

type ConfigStore

type ConfigStore struct {
	DnsRuleTags   []string
	RouteRuleTags []string
	DnsServerTags []string
	// contains filtered or unexported fields
}

Main config store object

func NewConfStore

func NewConfStore(path string) (*ConfigStore, error)

func (*ConfigStore) AllDnsRule

func (c *ConfigStore) AllDnsRule() []DnsRule

func (*ConfigStore) AllDnsServer

func (c *ConfigStore) AllDnsServer() []DnsServer

func (*ConfigStore) AllRUleSet

func (c *ConfigStore) AllRUleSet() []RuleSet

func (*ConfigStore) AllRouteRulesWithReq

func (c *ConfigStore) AllRouteRulesWithReq() []RouteRule

return all rules with requrments

func (*ConfigStore) Alloutbounds

func (c *ConfigStore) Alloutbounds() []string

func (*ConfigStore) DefaultDns

func (c *ConfigStore) DefaultDns() option.DNSServerOptions

func (*ConfigStore) DnsRuleByname

func (c *ConfigStore) DnsRuleByname(name string) (option.DNSRule, error)

func (*ConfigStore) DnsRuleMust

func (c *ConfigStore) DnsRuleMust(tag string) DnsRule

func (*ConfigStore) DnsServerbyTag

func (c *ConfigStore) DnsServerbyTag(tag string) (DnsServer, error)

func (*ConfigStore) FullDnsRuleByname

func (c *ConfigStore) FullDnsRuleByname(name string) (DnsRule, bool)

func (*ConfigStore) FullRuleByname

func (c *ConfigStore) FullRuleByname(name string) (RouteRule, bool)

func (*ConfigStore) GetOutbound

func (c *ConfigStore) GetOutbound(refName string) (Outbound, error)

func (*ConfigStore) RouteRuleByname

func (c *ConfigStore) RouteRuleByname(name string) (option.Rule, error)

func (*ConfigStore) RuleSetBytag

func (c *ConfigStore) RuleSetBytag(tag string) (RuleSet, error)

type DnsRule

type DnsRule struct {
	Rule       option.DNSRule `json:"rule,omitempty"`
	Info       string         `json:"info,omitempty"`
	Reqirments ReqirmentsRule `json:"reqirments,omitempty"`
}

type DnsServer

type DnsServer struct {
	Server option.DNSServerOptions `json:"server,omitempty"`
	Info   string                  `json:"info,omitempty"`
}

type OptionsEntry

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

copied struct from sing box

type Outbound

type Outbound struct {
	Out        option.Outbound    `json:"out,omitempty"`
	Info       string             `json:"info,omitempty"`
	Reqirments ReqirmentsOutbound `json:"reqirments,omitempty"`
	Price      int64              `json:"price,omitempty"` //TODO: may be later
}

func (*Outbound) FillReqirments

func (o *Outbound) FillReqirments(callback func(msg any) (string, error)) error

type ReqirmentsOutbound

type ReqirmentsOutbound struct {
	NeedUUID          bool `json:"uuid,omitempty"`
	NeedServer        bool `json:"server,omitempty"`
	NeedPort          bool `json:"port,omitempty"`
	NeedSni           bool `json:"server_name,omitempty"`
	NeedTag           bool `json:"tag,omitempty"`
	NeedTransportHost bool `json:"transporthost,omitempty"`
}

common requrments for all outbounds common

type ReqirmentsRule

type ReqirmentsRule struct {
	IsStatic        bool `json:"static,omitempty"`
	NeedPort        bool `json:"needport,omitempty"`
	NeedPortRange   bool `json:"needportRange,omitempty"`
	NeedDomain      bool `json:"needdomain,omitempty"`
	NeedProtocole   bool `json:"needprotocole,omitempty"`
	NeedIp_cidr     bool `json:"needip_cidr,omitempty"`
	NeedRuleSet     bool `json:"needruleSet,omitempty"`
	NeedToChangeOut bool `json:"changeout,omitempty"`
}

func (*ReqirmentsRule) FillReqirments

func (r *ReqirmentsRule) FillReqirments(callback common.Callbackreciver, sendreciver common.Sendreciver, ruleany any) error

callback reciver should support even msgs without buttons

type RouteRule

type RouteRule struct {
	Rule       option.Rule    `json:"rule,omitempty"`
	Info       string         `json:"info,omitempty"` // info about rule object
	Reqirments ReqirmentsRule `json:"reqirments,omitempty"`
}

type RuleSet

type RuleSet struct {
	RuleSet option.RuleSet `json:"rule_set,omitempty"`
	Info    string         `json:"info,omitempty"`
}

type RuleSetter

type RuleSetter interface {
	SetOut(out string)
	SetList(name string, list []string) error
}

type StoreOption

type StoreOption struct {
	AllDnsRule    []DnsRule   `json:"dnsrules,omitempty"`
	AllDnsServer  []DnsServer `json:"dns_servers,omitempty"`
	AllRouteRules []RouteRule `json:"routerule,omitempty"`
	AllRuleSet    []RuleSet   `json:"ruleset,omitempty"`
	AllOutbounds  []Outbound  `json:"outbounds,omitempty"`
}

Jump to

Keyboard shortcuts

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