freedom

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RuleAction_name = map[int32]string{
		0: "Allow",
		1: "Block",
	}
	RuleAction_value = map[string]int32{
		"Allow": 0,
		"Block": 1,
	}
)

Enum value maps for RuleAction.

View Source
var File_proxy_freedom_config_proto protoreflect.FileDescriptor

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int64) ([]byte, error)

func NewPacketReader

func NewPacketReader(conn net.Conn, h *Handler, defaultRule *FinalRule, UDPOverride net.Destination, DialDest net.Destination) buf.Reader

func NewPacketWriter

func NewPacketWriter(conn net.Conn, h *Handler, defaultRule *FinalRule, UDPOverride net.Destination, DialDest net.Destination) buf.Writer

DialDest means the dial target used in the dialer when creating conn

Types

type Config

type Config struct {
	DomainStrategy      internet.DomainStrategy `` /* 148-byte string literal not displayed */
	DestinationOverride *DestinationOverride    `protobuf:"bytes,3,opt,name=destination_override,json=destinationOverride,proto3" json:"destination_override,omitempty"`
	UserLevel           uint32                  `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"`
	Fragment            *Fragment               `protobuf:"bytes,5,opt,name=fragment,proto3" json:"fragment,omitempty"`
	ProxyProtocol       uint32                  `protobuf:"varint,6,opt,name=proxy_protocol,json=proxyProtocol,proto3" json:"proxy_protocol,omitempty"`
	Noises              []*Noise                `protobuf:"bytes,7,rep,name=noises,proto3" json:"noises,omitempty"`
	FinalRules          []*FinalRuleConfig      `protobuf:"bytes,8,rep,name=final_rules,json=finalRules,proto3" json:"final_rules,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated

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

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetDestinationOverride

func (x *Config) GetDestinationOverride() *DestinationOverride

func (*Config) GetDomainStrategy

func (x *Config) GetDomainStrategy() internet.DomainStrategy

func (*Config) GetFinalRules

func (x *Config) GetFinalRules() []*FinalRuleConfig

func (*Config) GetFragment

func (x *Config) GetFragment() *Fragment

func (*Config) GetNoises

func (x *Config) GetNoises() []*Noise

func (*Config) GetProxyProtocol

func (x *Config) GetProxyProtocol() uint32

func (*Config) GetUserLevel

func (x *Config) GetUserLevel() uint32

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

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

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type DestinationOverride

type DestinationOverride struct {
	Server *protocol.ServerEndpoint `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"`
	// contains filtered or unexported fields
}

func (*DestinationOverride) Descriptor deprecated

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

Deprecated: Use DestinationOverride.ProtoReflect.Descriptor instead.

func (*DestinationOverride) GetServer

func (*DestinationOverride) ProtoMessage

func (*DestinationOverride) ProtoMessage()

func (*DestinationOverride) ProtoReflect

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

func (*DestinationOverride) Reset

func (x *DestinationOverride) Reset()

func (*DestinationOverride) String

func (x *DestinationOverride) String() string

type FinalRule

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

func (*FinalRule) Apply

func (r *FinalRule) Apply(network net.Network, address net.Address, port net.Port) bool

type FinalRuleConfig

type FinalRuleConfig struct {
	Action     RuleAction        `protobuf:"varint,1,opt,name=action,proto3,enum=xray.proxy.freedom.RuleAction" json:"action,omitempty"`
	Networks   []net.Network     `protobuf:"varint,2,rep,packed,name=networks,proto3,enum=xray.common.net.Network" json:"networks,omitempty"`
	PortList   *net.PortList     `protobuf:"bytes,3,opt,name=port_list,json=portList,proto3" json:"port_list,omitempty"`
	Ip         []*geodata.IPRule `protobuf:"bytes,4,rep,name=ip,proto3" json:"ip,omitempty"`
	BlockDelay *Range            `protobuf:"bytes,5,opt,name=block_delay,json=blockDelay,proto3" json:"block_delay,omitempty"`
	// contains filtered or unexported fields
}

func (*FinalRuleConfig) Descriptor deprecated

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

Deprecated: Use FinalRuleConfig.ProtoReflect.Descriptor instead.

func (*FinalRuleConfig) GetAction

func (x *FinalRuleConfig) GetAction() RuleAction

func (*FinalRuleConfig) GetBlockDelay

func (x *FinalRuleConfig) GetBlockDelay() *Range

func (*FinalRuleConfig) GetIp

func (x *FinalRuleConfig) GetIp() []*geodata.IPRule

func (*FinalRuleConfig) GetNetworks

func (x *FinalRuleConfig) GetNetworks() []net.Network

func (*FinalRuleConfig) GetPortList

func (x *FinalRuleConfig) GetPortList() *net.PortList

func (*FinalRuleConfig) ProtoMessage

func (*FinalRuleConfig) ProtoMessage()

func (*FinalRuleConfig) ProtoReflect

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

func (*FinalRuleConfig) Reset

func (x *FinalRuleConfig) Reset()

func (*FinalRuleConfig) String

func (x *FinalRuleConfig) String() string

type Fragment

type Fragment struct {
	PacketsFrom uint64 `protobuf:"varint,1,opt,name=packets_from,json=packetsFrom,proto3" json:"packets_from,omitempty"`
	PacketsTo   uint64 `protobuf:"varint,2,opt,name=packets_to,json=packetsTo,proto3" json:"packets_to,omitempty"`
	LengthMin   uint64 `protobuf:"varint,3,opt,name=length_min,json=lengthMin,proto3" json:"length_min,omitempty"`
	LengthMax   uint64 `protobuf:"varint,4,opt,name=length_max,json=lengthMax,proto3" json:"length_max,omitempty"`
	IntervalMin uint64 `protobuf:"varint,5,opt,name=interval_min,json=intervalMin,proto3" json:"interval_min,omitempty"`
	IntervalMax uint64 `protobuf:"varint,6,opt,name=interval_max,json=intervalMax,proto3" json:"interval_max,omitempty"`
	MaxSplitMin uint64 `protobuf:"varint,7,opt,name=max_split_min,json=maxSplitMin,proto3" json:"max_split_min,omitempty"`
	MaxSplitMax uint64 `protobuf:"varint,8,opt,name=max_split_max,json=maxSplitMax,proto3" json:"max_split_max,omitempty"`
	// contains filtered or unexported fields
}

func (*Fragment) Descriptor deprecated

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

Deprecated: Use Fragment.ProtoReflect.Descriptor instead.

func (*Fragment) GetIntervalMax

func (x *Fragment) GetIntervalMax() uint64

func (*Fragment) GetIntervalMin

func (x *Fragment) GetIntervalMin() uint64

func (*Fragment) GetLengthMax

func (x *Fragment) GetLengthMax() uint64

func (*Fragment) GetLengthMin

func (x *Fragment) GetLengthMin() uint64

func (*Fragment) GetMaxSplitMax

func (x *Fragment) GetMaxSplitMax() uint64

func (*Fragment) GetMaxSplitMin

func (x *Fragment) GetMaxSplitMin() uint64

func (*Fragment) GetPacketsFrom

func (x *Fragment) GetPacketsFrom() uint64

func (*Fragment) GetPacketsTo

func (x *Fragment) GetPacketsTo() uint64

func (*Fragment) ProtoMessage

func (*Fragment) ProtoMessage()

func (*Fragment) ProtoReflect

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

func (*Fragment) Reset

func (x *Fragment) Reset()

func (*Fragment) String

func (x *Fragment) String() string

type FragmentWriter

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

func (*FragmentWriter) Write

func (f *FragmentWriter) Write(b []byte) (int, error)

type Handler

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

Handler handles Freedom connections.

func (*Handler) Init

func (h *Handler) Init(config *Config, pm policy.Manager) error

Init initializes the Handler with necessary parameters.

func (*Handler) Process

func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error

Process implements proxy.Outbound.

type Noise

type Noise struct {
	LengthMin uint64 `protobuf:"varint,1,opt,name=length_min,json=lengthMin,proto3" json:"length_min,omitempty"`
	LengthMax uint64 `protobuf:"varint,2,opt,name=length_max,json=lengthMax,proto3" json:"length_max,omitempty"`
	DelayMin  uint64 `protobuf:"varint,3,opt,name=delay_min,json=delayMin,proto3" json:"delay_min,omitempty"`
	DelayMax  uint64 `protobuf:"varint,4,opt,name=delay_max,json=delayMax,proto3" json:"delay_max,omitempty"`
	Packet    []byte `protobuf:"bytes,5,opt,name=packet,proto3" json:"packet,omitempty"`
	ApplyTo   string `protobuf:"bytes,6,opt,name=apply_to,json=applyTo,proto3" json:"apply_to,omitempty"`
	// contains filtered or unexported fields
}

func (*Noise) Descriptor deprecated

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

Deprecated: Use Noise.ProtoReflect.Descriptor instead.

func (*Noise) GetApplyTo

func (x *Noise) GetApplyTo() string

func (*Noise) GetDelayMax

func (x *Noise) GetDelayMax() uint64

func (*Noise) GetDelayMin

func (x *Noise) GetDelayMin() uint64

func (*Noise) GetLengthMax

func (x *Noise) GetLengthMax() uint64

func (*Noise) GetLengthMin

func (x *Noise) GetLengthMin() uint64

func (*Noise) GetPacket

func (x *Noise) GetPacket() []byte

func (*Noise) ProtoMessage

func (*Noise) ProtoMessage()

func (*Noise) ProtoReflect

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

func (*Noise) Reset

func (x *Noise) Reset()

func (*Noise) String

func (x *Noise) String() string

type NoisePacketWriter

type NoisePacketWriter struct {
	buf.Writer

	UDPOverride net.Destination
	// contains filtered or unexported fields
}

func (*NoisePacketWriter) WriteMultiBuffer

func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error

MultiBuffer writer with Noise before first packet

type PacketReader

type PacketReader struct {
	*internet.PacketConnWrapper
	stats.Counter
	Handler           *Handler
	DefaultRule       *FinalRule
	IsOverridden      bool
	InitUnchangedAddr net.Address
	InitChangedAddr   net.Address
}

func (*PacketReader) ReadMultiBuffer

func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error)

type PacketWriter

type PacketWriter struct {
	*internet.PacketConnWrapper
	stats.Counter
	*Handler
	DefaultRule *FinalRule
	UDPOverride net.Destination

	// Dest of udp packets might be a domain, we will resolve them to IP
	// But resolver will return a random one if the domain has many IPs
	// Resulting in these packets being sent to many different IPs randomly
	// So, cache and keep the resolve result
	ResolvedUDPAddr *utils.TypedSyncMap[string, net.Address]
	LocalAddr       net.Address
}

func (*PacketWriter) WriteMultiBuffer

func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error

type Range

type Range struct {
	Min uint64 `protobuf:"varint,1,opt,name=min,proto3" json:"min,omitempty"`
	Max uint64 `protobuf:"varint,2,opt,name=max,proto3" json:"max,omitempty"`
	// contains filtered or unexported fields
}

func (*Range) Descriptor deprecated

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

Deprecated: Use Range.ProtoReflect.Descriptor instead.

func (*Range) GetMax

func (x *Range) GetMax() uint64

func (*Range) GetMin

func (x *Range) GetMin() uint64

func (*Range) ProtoMessage

func (*Range) ProtoMessage()

func (*Range) ProtoReflect

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

func (*Range) Reset

func (x *Range) Reset()

func (*Range) String

func (x *Range) String() string

type RuleAction

type RuleAction int32
const (
	RuleAction_Allow RuleAction = 0
	RuleAction_Block RuleAction = 1
)

func (RuleAction) Descriptor

func (RuleAction) Descriptor() protoreflect.EnumDescriptor

func (RuleAction) Enum

func (x RuleAction) Enum() *RuleAction

func (RuleAction) EnumDescriptor deprecated

func (RuleAction) EnumDescriptor() ([]byte, []int)

Deprecated: Use RuleAction.Descriptor instead.

func (RuleAction) Number

func (x RuleAction) Number() protoreflect.EnumNumber

func (RuleAction) String

func (x RuleAction) String() string

func (RuleAction) Type

Jump to

Keyboard shortcuts

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