config

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: GPL-3.0 Imports: 39 Imported by: 6

Documentation

Index

Constants

View Source
const (
	DNSRemoteTag       = "dns-remote"
	DNSLocalTag        = "dns-local"
	DNSDirectTag       = "dns-direct"
	DNSBlockTag        = "dns-block"
	DNSFakeTag         = "dns-fake"
	DNSTricksDirectTag = "dns-trick-direct"

	OutboundDirectTag         = "direct"
	OutboundBypassTag         = "bypass"
	OutboundBlockTag          = "block"
	OutboundSelectTag         = "select"
	OutboundURLTestTag        = "auto"
	OutboundDNSTag            = "dns-out"
	OutboundDirectFragmentTag = "direct-fragment"

	InboundTUNTag   = "tun-in"
	InboundMixedTag = "mixed-in"
	InboundDNSTag   = "dns-in"
)
View Source
const (
	WarpOverProxy = "warp_over_proxy"
	ProxyOverWarp = "proxy_over_warp"
)
View Source
const (
	CoreService_ParseConfig_FullMethodName        = "/ConfigOptions.CoreService/ParseConfig"
	CoreService_GenerateFullConfig_FullMethodName = "/ConfigOptions.CoreService/GenerateFullConfig"
)

Variables

View Source
var CoreService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "ConfigOptions.CoreService",
	HandlerType: (*CoreServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ParseConfig",
			Handler:    _CoreService_ParseConfig_Handler,
		},
		{
			MethodName: "GenerateFullConfig",
			Handler:    _CoreService_GenerateFullConfig_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "core.proto",
}

CoreService_ServiceDesc is the grpc.ServiceDesc for CoreService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var OutboundMainProxyTag = OutboundSelectTag

Functions

func ActivateTunnelService

func ActivateTunnelService(opt ConfigOptions) (bool, error)

func BuildConfig

func BuildConfig(opt ConfigOptions, input option.Options) (*option.Options, error)

TODO include selectors

func BuildConfigJson

func BuildConfigJson(configOpt ConfigOptions, input option.Options) (string, error)

func DeactivateTunnelService

func DeactivateTunnelService() (bool, error)

func DeactivateTunnelServiceForce

func DeactivateTunnelServiceForce() (bool, error)

func DeferPanicToError

func DeferPanicToError(name string, err func(error))

func ExecuteCmd

func ExecuteCmd(executablePath string, background bool, args ...string) (string, error)

func ExitTunnelService

func ExitTunnelService() (bool, error)

func GenerateWarpAccount

func GenerateWarpAccount(licenseKey string, accountId string, accessToken string) (string, error)

func GenerateWarpSingbox

func GenerateWarpSingbox(wgConfig WarpWireguardConfig, host string, port uint16, fakePackets string, fakePacketsSize string, fakePacketsDelay string, fakePacketMode string) (*T.Outbound, error)

func ParseConfig

func ParseConfig(path string, debug bool) ([]byte, error)

func ParseConfigContent

func ParseConfigContent(contentstr string, debug bool, configOpt *ConfigOptions, fullConfig bool) ([]byte, error)

func RegisterCoreServiceServer

func RegisterCoreServiceServer(s grpc.ServiceRegistrar, srv CoreServiceServer)

func SaveCurrentConfig

func SaveCurrentConfig(path string, options option.Options) error

func StartGRPCServer

func StartGRPCServer(port uint16) error

func String

func String(s string) *string

func ToJson

func ToJson(options option.Options) (string, error)

Types

type ConfigOptions

type ConfigOptions struct {
	EnableFullConfig bool   `json:"enable-full-config"`
	LogLevel         string `json:"log-level"`
	EnableClashApi   bool   `json:"enable-clash-api"`
	ClashApiPort     uint16 `json:"clash-api-port"`
	ClashApiSecret   string `json:"web-secret"`
	Region           string `json:"region"`
	BlockAds         bool   `json:"block-ads"`
	// GeoIPPath        string      `json:"geoip-path"`
	// GeoSitePath      string      `json:"geosite-path"`
	Rules     []Rule      `json:"rules"`
	Warp      WarpOptions `json:"warp"`
	Warp2     WarpOptions `json:"warp2"`
	Mux       MuxOptions  `json:"mux"`
	TLSTricks TLSTricks   `json:"tls-tricks"`
	DNSOptions
	InboundOptions
	URLTestOptions
	RouteOptions
}

func DefaultConfigOptions

func DefaultConfigOptions() *ConfigOptions

type CoreServiceClient

type CoreServiceClient interface {
	ParseConfig(ctx context.Context, in *ParseConfigRequest, opts ...grpc.CallOption) (*ParseConfigResponse, error)
	GenerateFullConfig(ctx context.Context, in *GenerateConfigRequest, opts ...grpc.CallOption) (*GenerateConfigResponse, error)
}

CoreServiceClient is the client API for CoreService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type CoreServiceServer

type CoreServiceServer interface {
	ParseConfig(context.Context, *ParseConfigRequest) (*ParseConfigResponse, error)
	GenerateFullConfig(context.Context, *GenerateConfigRequest) (*GenerateConfigResponse, error)
	// contains filtered or unexported methods
}

CoreServiceServer is the server API for CoreService service. All implementations must embed UnimplementedCoreServiceServer for forward compatibility

type DNSOptions

type DNSOptions struct {
	RemoteDnsAddress        string                `json:"remote-dns-address"`
	RemoteDnsDomainStrategy option.DomainStrategy `json:"remote-dns-domain-strategy"`
	DirectDnsAddress        string                `json:"direct-dns-address"`
	DirectDnsDomainStrategy option.DomainStrategy `json:"direct-dns-domain-strategy"`
	IndependentDNSCache     bool                  `json:"independent-dns-cache"`
	EnableFakeDNS           bool                  `json:"enable-fake-dns"`
	EnableDNSRouting        bool                  `json:"enable-dns-routing"`
}

type DurationInSeconds

type DurationInSeconds int

func (DurationInSeconds) Duration

func (d DurationInSeconds) Duration() time.Duration

func (DurationInSeconds) MarshalJSON

func (d DurationInSeconds) MarshalJSON() ([]byte, error)

func (*DurationInSeconds) UnmarshalJSON

func (d *DurationInSeconds) UnmarshalJSON(bytes []byte) error

type GenerateConfigRequest

type GenerateConfigRequest struct {
	Path  string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	Debug bool   `protobuf:"varint,2,opt,name=debug,proto3" json:"debug,omitempty"`
	// contains filtered or unexported fields
}

func (*GenerateConfigRequest) Descriptor deprecated

func (*GenerateConfigRequest) Descriptor() ([]byte, []int)

Deprecated: Use GenerateConfigRequest.ProtoReflect.Descriptor instead.

func (*GenerateConfigRequest) GetDebug

func (x *GenerateConfigRequest) GetDebug() bool

func (*GenerateConfigRequest) GetPath

func (x *GenerateConfigRequest) GetPath() string

func (*GenerateConfigRequest) ProtoMessage

func (*GenerateConfigRequest) ProtoMessage()

func (*GenerateConfigRequest) ProtoReflect

func (x *GenerateConfigRequest) ProtoReflect() protoreflect.Message

func (*GenerateConfigRequest) Reset

func (x *GenerateConfigRequest) Reset()

func (*GenerateConfigRequest) String

func (x *GenerateConfigRequest) String() string

type GenerateConfigResponse

type GenerateConfigResponse struct {
	Config string  `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
	Error  *string `protobuf:"bytes,2,opt,name=error,proto3,oneof" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*GenerateConfigResponse) Descriptor deprecated

func (*GenerateConfigResponse) Descriptor() ([]byte, []int)

Deprecated: Use GenerateConfigResponse.ProtoReflect.Descriptor instead.

func (*GenerateConfigResponse) GetConfig

func (x *GenerateConfigResponse) GetConfig() string

func (*GenerateConfigResponse) GetError

func (x *GenerateConfigResponse) GetError() string

func (*GenerateConfigResponse) ProtoMessage

func (*GenerateConfigResponse) ProtoMessage()

func (*GenerateConfigResponse) ProtoReflect

func (x *GenerateConfigResponse) ProtoReflect() protoreflect.Message

func (*GenerateConfigResponse) Reset

func (x *GenerateConfigResponse) Reset()

func (*GenerateConfigResponse) String

func (x *GenerateConfigResponse) String() string

type InboundOptions

type InboundOptions struct {
	EnableTun        bool   `json:"enable-tun"`
	EnableTunService bool   `json:"enable-tun-service"`
	SetSystemProxy   bool   `json:"set-system-proxy"`
	MixedPort        uint16 `json:"mixed-port"`
	TProxyPort       uint16 `json:"tproxy-port"`
	LocalDnsPort     uint16 `json:"local-dns-port"`
	MTU              uint32 `json:"mtu"`
	StrictRoute      bool   `json:"strict-route"`
	TUNStack         string `json:"tun-implementation"`
}

type MuxOptions

type MuxOptions struct {
	Enable     bool   `json:"enable"`
	Padding    bool   `json:"padding"`
	MaxStreams int    `json:"max-streams"`
	Protocol   string `json:"protocol"`
}

type ParseConfigRequest

type ParseConfigRequest struct {
	TempPath string `protobuf:"bytes,1,opt,name=tempPath,proto3" json:"tempPath,omitempty"`
	Path     string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
	Debug    bool   `protobuf:"varint,3,opt,name=debug,proto3" json:"debug,omitempty"`
	// contains filtered or unexported fields
}

func (*ParseConfigRequest) Descriptor deprecated

func (*ParseConfigRequest) Descriptor() ([]byte, []int)

Deprecated: Use ParseConfigRequest.ProtoReflect.Descriptor instead.

func (*ParseConfigRequest) GetDebug

func (x *ParseConfigRequest) GetDebug() bool

func (*ParseConfigRequest) GetPath

func (x *ParseConfigRequest) GetPath() string

func (*ParseConfigRequest) GetTempPath

func (x *ParseConfigRequest) GetTempPath() string

func (*ParseConfigRequest) ProtoMessage

func (*ParseConfigRequest) ProtoMessage()

func (*ParseConfigRequest) ProtoReflect

func (x *ParseConfigRequest) ProtoReflect() protoreflect.Message

func (*ParseConfigRequest) Reset

func (x *ParseConfigRequest) Reset()

func (*ParseConfigRequest) String

func (x *ParseConfigRequest) String() string

type ParseConfigResponse

type ParseConfigResponse struct {
	Error *string `protobuf:"bytes,1,opt,name=error,proto3,oneof" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*ParseConfigResponse) Descriptor deprecated

func (*ParseConfigResponse) Descriptor() ([]byte, []int)

Deprecated: Use ParseConfigResponse.ProtoReflect.Descriptor instead.

func (*ParseConfigResponse) GetError

func (x *ParseConfigResponse) GetError() string

func (*ParseConfigResponse) ProtoMessage

func (*ParseConfigResponse) ProtoMessage()

func (*ParseConfigResponse) ProtoReflect

func (x *ParseConfigResponse) ProtoReflect() protoreflect.Message

func (*ParseConfigResponse) Reset

func (x *ParseConfigResponse) Reset()

func (*ParseConfigResponse) String

func (x *ParseConfigResponse) String() string

type RouteOptions

type RouteOptions struct {
	ResolveDestination     bool                  `json:"resolve-destination"`
	IPv6Mode               option.DomainStrategy `json:"ipv6-mode"`
	BypassLAN              bool                  `json:"bypass-lan"`
	AllowConnectionFromLAN bool                  `json:"allow-connection-from-lan"`
}

type Rule

type Rule struct {
	RuleSetUrl string `json:"rule-set-url"`
	Domains    string `json:"domains"`
	IP         string `json:"ip"`
	Port       string `json:"port"`
	Network    string `json:"network"`
	Protocol   string `json:"protocol"`
	Outbound   string `json:"outbound"`
}

func (*Rule) MakeDNSRule

func (r *Rule) MakeDNSRule() option.DefaultDNSRule

func (*Rule) MakeRule

func (r *Rule) MakeRule() option.DefaultRule

type SingboxConfig

type SingboxConfig struct {
	Type          string   `json:"type"`
	Tag           string   `json:"tag"`
	Server        string   `json:"server"`
	ServerPort    int      `json:"server_port"`
	LocalAddress  []string `json:"local_address"`
	PrivateKey    string   `json:"private_key"`
	PeerPublicKey string   `json:"peer_public_key"`
	Reserved      []int    `json:"reserved"`
	MTU           int      `json:"mtu"`
}

type TLSTricks

type TLSTricks struct {
	EnableFragment bool   `json:"enable-fragment"`
	FragmentSize   string `json:"fragment-size"`
	FragmentSleep  string `json:"fragment-sleep"`
	MixedSNICase   bool   `json:"mixed-sni-case"`
	EnablePadding  bool   `json:"enable-padding"`
	PaddingSize    string `json:"padding-size"`
}

type URLTestOptions

type URLTestOptions struct {
	ConnectionTestUrl string            `json:"connection-test-url"`
	URLTestInterval   DurationInSeconds `json:"url-test-interval"`
}

type UnimplementedCoreServiceServer

type UnimplementedCoreServiceServer struct {
}

UnimplementedCoreServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedCoreServiceServer) GenerateFullConfig

func (UnimplementedCoreServiceServer) ParseConfig

type UnsafeCoreServiceServer

type UnsafeCoreServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeCoreServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to CoreServiceServer will result in compilation errors.

type WarpAccount

type WarpAccount struct {
	AccountID   string `json:"account-id"`
	AccessToken string `json:"access-token"`
}

type WarpGenerationResponse

type WarpGenerationResponse struct {
	WarpAccount
	Log    string              `json:"log"`
	Config WarpWireguardConfig `json:"config"`
}

type WarpOptions

type WarpOptions struct {
	EnableWarp         bool                `json:"enable"`
	Mode               string              `json:"mode"`
	WireguardConfigStr string              `json:"wireguard-config"`
	WireguardConfig    WarpWireguardConfig `json:"wireguardConfig"` // TODO check
	FakePackets        string              `json:"noise"`
	FakePacketSize     string              `json:"noise-size"`
	FakePacketDelay    string              `json:"noise-delay"`
	FakePacketMode     string              `json:"noise-mode"`
	CleanIP            string              `json:"clean-ip"`
	CleanPort          uint16              `json:"clean-port"`
	Account            WarpAccount
}

type WarpWireguardConfig

type WarpWireguardConfig struct {
	PrivateKey       string `json:"private-key"`
	LocalAddressIPv4 string `json:"local-address-ipv4"`
	LocalAddressIPv6 string `json:"local-address-ipv6"`
	PeerPublicKey    string `json:"peer-public-key"`
	ClientID         string `json:"client-id"`
}

func GenerateWarpInfo

func GenerateWarpInfo(license string, oldAccountId string, oldAccessToken string) (*warp.Identity, string, *WarpWireguardConfig, error)

Jump to

Keyboard shortcuts

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