core: v2ray.com/core/transport/internet Index | Files | Directories

package internet

import "v2ray.com/core/transport/internet"

Index

Package Files

config.go config.pb.go connection.go dialer.go errors.generated.go header.go internet.go memory_settings.go sockopt.go sockopt_linux.go system_dialer.go system_listener.go tcp_hub.go

Constants

const (
    // For incoming connections.
    TCP_FASTOPEN = 23
    // For out-going connections.
    TCP_FASTOPEN_CONNECT = 30
)

Variables

var SocketConfig_TCPFastOpenState_name = map[int32]string{
    0:  "AsIs",
    1:  "Enable",
    2:  "Disable",
}
var SocketConfig_TCPFastOpenState_value = map[string]int32{
    "AsIs":    0,
    "Enable":  1,
    "Disable": 2,
}
var SocketConfig_TProxyMode_name = map[int32]string{
    0:  "Off",
    1:  "TProxy",
    2:  "Redirect",
}
var SocketConfig_TProxyMode_value = map[string]int32{
    "Off":      0,
    "TProxy":   1,
    "Redirect": 2,
}
var TransportProtocol_name = map[int32]string{
    0:  "TCP",
    1:  "UDP",
    2:  "MKCP",
    3:  "WebSocket",
    4:  "HTTP",
    5:  "DomainSocket",
}
var TransportProtocol_value = map[string]int32{
    "TCP":          0,
    "UDP":          1,
    "MKCP":         2,
    "WebSocket":    3,
    "HTTP":         4,
    "DomainSocket": 5,
}

func ApplyGlobalTransportSettings Uses

func ApplyGlobalTransportSettings(settings []*TransportConfig) error

func CreateTransportConfig Uses

func CreateTransportConfig(name string) (interface{}, error)

func DialSystem Uses

func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig) (net.Conn, error)

DialSystem calls system dialer to create a network connection.

func ListenSystem Uses

func ListenSystem(ctx context.Context, addr net.Addr, sockopt *SocketConfig) (net.Listener, error)

ListenSystem listens on a local address for incoming TCP connections.

v2ray:api:beta

func ListenSystemPacket Uses

func ListenSystemPacket(ctx context.Context, addr net.Addr, sockopt *SocketConfig) (net.PacketConn, error)

ListenSystemPacket listens on a local address for incoming UDP connections.

v2ray:api:beta

func RegisterDialerController Uses

func RegisterDialerController(ctl func(network, address string, fd uintptr) error) error

RegisterDialerController adds a controller to the effective system dialer. The controller can be used to operate on file descriptors before they are put into use. It only works when effective dialer is the default dialer.

v2ray:api:beta

func RegisterListenerController Uses

func RegisterListenerController(controller func(network, address string, fd uintptr) error) error

RegisterListenerController adds a controller to the effective system listener. The controller can be used to operate on file descriptors before they are put into use.

v2ray:api:beta

func RegisterProtocolConfigCreator Uses

func RegisterProtocolConfigCreator(name string, creator ConfigCreator) error

func RegisterTransportDialer Uses

func RegisterTransportDialer(protocol string, dialer dialFunc) error

RegisterTransportDialer registers a Dialer with given name.

func RegisterTransportListener Uses

func RegisterTransportListener(protocol string, listener ListenFunc) error

func UseAlternativeSystemDialer Uses

func UseAlternativeSystemDialer(dialer SystemDialer)

UseAlternativeSystemDialer replaces the current system dialer with a given one. Caller must ensure there is no race condition.

v2ray:api:stable

type ConfigCreator Uses

type ConfigCreator func() interface{}

type ConnHandler Uses

type ConnHandler func(Connection)

type Connection Uses

type Connection interface {
    net.Conn
}

func Dial Uses

func Dial(ctx context.Context, dest net.Destination, streamSettings *MemoryStreamConfig) (Connection, error)

Dial dials a internet connection towards the given destination.

type ConnectionAuthenticator Uses

type ConnectionAuthenticator interface {
    Client(net.Conn) net.Conn
    Server(net.Conn) net.Conn
}

func CreateConnectionAuthenticator Uses

func CreateConnectionAuthenticator(config interface{}) (ConnectionAuthenticator, error)

type DefaultListener Uses

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

func (*DefaultListener) Listen Uses

func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *SocketConfig) (net.Listener, error)

func (*DefaultListener) ListenPacket Uses

func (dl *DefaultListener) ListenPacket(ctx context.Context, addr net.Addr, sockopt *SocketConfig) (net.PacketConn, error)

type DefaultSystemDialer Uses

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

func (*DefaultSystemDialer) Dial Uses

func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest net.Destination, sockopt *SocketConfig) (net.Conn, error)

type Dialer Uses

type Dialer interface {
    // Dial dials a system connection to the given destination.
    Dial(ctx context.Context, destination net.Destination) (Connection, error)

    // Address returns the address used by this Dialer. Maybe nil if not known.
    Address() net.Address
}

Dialer is the interface for dialing outbound connections.

type ListenFunc Uses

type ListenFunc func(ctx context.Context, address net.Address, port net.Port, settings *MemoryStreamConfig, handler ConnHandler) (Listener, error)

type Listener Uses

type Listener interface {
    Close() error
    Addr() net.Addr
}

func ListenTCP Uses

func ListenTCP(ctx context.Context, address net.Address, port net.Port, settings *MemoryStreamConfig, handler ConnHandler) (Listener, error)

type MemoryStreamConfig Uses

type MemoryStreamConfig struct {
    ProtocolName     string
    ProtocolSettings interface{}
    SecurityType     string
    SecuritySettings interface{}
    SocketSettings   *SocketConfig
}

MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce number of Protobuf parsing.

func ToMemoryStreamConfig Uses

func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error)

ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input.

type PacketHeader Uses

type PacketHeader interface {
    Size() int32
    Serialize([]byte)
}

func CreatePacketHeader Uses

func CreatePacketHeader(config interface{}) (PacketHeader, error)

type ProxyConfig Uses

type ProxyConfig struct {
    Tag                  string   `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*ProxyConfig) Descriptor Uses

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

func (*ProxyConfig) GetTag Uses

func (m *ProxyConfig) GetTag() string

func (*ProxyConfig) HasTag Uses

func (c *ProxyConfig) HasTag() bool

func (*ProxyConfig) ProtoMessage Uses

func (*ProxyConfig) ProtoMessage()

func (*ProxyConfig) Reset Uses

func (m *ProxyConfig) Reset()

func (*ProxyConfig) String Uses

func (m *ProxyConfig) String() string

func (*ProxyConfig) XXX_DiscardUnknown Uses

func (m *ProxyConfig) XXX_DiscardUnknown()

func (*ProxyConfig) XXX_Marshal Uses

func (m *ProxyConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ProxyConfig) XXX_Merge Uses

func (m *ProxyConfig) XXX_Merge(src proto.Message)

func (*ProxyConfig) XXX_Size Uses

func (m *ProxyConfig) XXX_Size() int

func (*ProxyConfig) XXX_Unmarshal Uses

func (m *ProxyConfig) XXX_Unmarshal(b []byte) error

type SimpleSystemDialer Uses

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

func (*SimpleSystemDialer) Dial Uses

func (v *SimpleSystemDialer) Dial(ctx context.Context, src net.Address, dest net.Destination, sockopt *SocketConfig) (net.Conn, error)

type SocketConfig Uses

type SocketConfig struct {
    // Mark of the connection. If non-zero, the value will be set to SO_MARK.
    Mark int32 `protobuf:"varint,1,opt,name=mark,proto3" json:"mark,omitempty"`
    // TFO is the state of TFO settings.
    Tfo SocketConfig_TCPFastOpenState `protobuf:"varint,2,opt,name=tfo,proto3,enum=v2ray.core.transport.internet.SocketConfig_TCPFastOpenState" json:"tfo,omitempty"`
    // TProxy is for enabling TProxy socket option.
    Tproxy SocketConfig_TProxyMode `protobuf:"varint,3,opt,name=tproxy,proto3,enum=v2ray.core.transport.internet.SocketConfig_TProxyMode" json:"tproxy,omitempty"`
    // ReceiveOriginalDestAddress is for enabling IP_RECVORIGDSTADDR socket option.
    // This option is for UDP only.
    ReceiveOriginalDestAddress bool     `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"`
    BindAddress                []byte   `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"`
    BindPort                   uint32   `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"`
    XXX_NoUnkeyedLiteral       struct{} `json:"-"`
    XXX_unrecognized           []byte   `json:"-"`
    XXX_sizecache              int32    `json:"-"`
}

SocketConfig is options to be applied on network sockets.

func (*SocketConfig) Descriptor Uses

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

func (*SocketConfig) GetBindAddress Uses

func (m *SocketConfig) GetBindAddress() []byte

func (*SocketConfig) GetBindPort Uses

func (m *SocketConfig) GetBindPort() uint32

func (*SocketConfig) GetMark Uses

func (m *SocketConfig) GetMark() int32

func (*SocketConfig) GetReceiveOriginalDestAddress Uses

func (m *SocketConfig) GetReceiveOriginalDestAddress() bool

func (*SocketConfig) GetTfo Uses

func (m *SocketConfig) GetTfo() SocketConfig_TCPFastOpenState

func (*SocketConfig) GetTproxy Uses

func (m *SocketConfig) GetTproxy() SocketConfig_TProxyMode

func (*SocketConfig) ProtoMessage Uses

func (*SocketConfig) ProtoMessage()

func (*SocketConfig) Reset Uses

func (m *SocketConfig) Reset()

func (*SocketConfig) String Uses

func (m *SocketConfig) String() string

func (*SocketConfig) XXX_DiscardUnknown Uses

func (m *SocketConfig) XXX_DiscardUnknown()

func (*SocketConfig) XXX_Marshal Uses

func (m *SocketConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SocketConfig) XXX_Merge Uses

func (m *SocketConfig) XXX_Merge(src proto.Message)

func (*SocketConfig) XXX_Size Uses

func (m *SocketConfig) XXX_Size() int

func (*SocketConfig) XXX_Unmarshal Uses

func (m *SocketConfig) XXX_Unmarshal(b []byte) error

type SocketConfig_TCPFastOpenState Uses

type SocketConfig_TCPFastOpenState int32
const (
    // AsIs is to leave the current TFO state as is, unmodified.
    SocketConfig_AsIs SocketConfig_TCPFastOpenState = 0
    // Enable is for enabling TFO explictly.
    SocketConfig_Enable SocketConfig_TCPFastOpenState = 1
    // Disable is for disabling TFO explictly.
    SocketConfig_Disable SocketConfig_TCPFastOpenState = 2
)

func (SocketConfig_TCPFastOpenState) EnumDescriptor Uses

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

func (SocketConfig_TCPFastOpenState) String Uses

func (x SocketConfig_TCPFastOpenState) String() string

type SocketConfig_TProxyMode Uses

type SocketConfig_TProxyMode int32
const (
    // TProxy is off.
    SocketConfig_Off SocketConfig_TProxyMode = 0
    // TProxy mode.
    SocketConfig_TProxy SocketConfig_TProxyMode = 1
    // Redirect mode.
    SocketConfig_Redirect SocketConfig_TProxyMode = 2
)

func (SocketConfig_TProxyMode) EnumDescriptor Uses

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

func (SocketConfig_TProxyMode) IsEnabled Uses

func (m SocketConfig_TProxyMode) IsEnabled() bool

func (SocketConfig_TProxyMode) String Uses

func (x SocketConfig_TProxyMode) String() string

type StatCouterConnection Uses

type StatCouterConnection struct {
    Connection
    Uplink   stats.Counter
    Downlink stats.Counter
}

func (*StatCouterConnection) Read Uses

func (c *StatCouterConnection) Read(b []byte) (int, error)

func (*StatCouterConnection) Write Uses

func (c *StatCouterConnection) Write(b []byte) (int, error)

type StreamConfig Uses

type StreamConfig struct {
    // Effective network. Deprecated. Use the string form below.
    Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=v2ray.core.transport.internet.TransportProtocol" json:"protocol,omitempty"` // Deprecated: Do not use.
    // Effective network.
    ProtocolName      string             `protobuf:"bytes,5,opt,name=protocol_name,json=protocolName,proto3" json:"protocol_name,omitempty"`
    TransportSettings []*TransportConfig `protobuf:"bytes,2,rep,name=transport_settings,json=transportSettings,proto3" json:"transport_settings,omitempty"`
    // Type of security. Must be a message name of the settings proto.
    SecurityType string `protobuf:"bytes,3,opt,name=security_type,json=securityType,proto3" json:"security_type,omitempty"`
    // Settings for transport security. For now the only choice is TLS.
    SecuritySettings     []*serial.TypedMessage `protobuf:"bytes,4,rep,name=security_settings,json=securitySettings,proto3" json:"security_settings,omitempty"`
    SocketSettings       *SocketConfig          `protobuf:"bytes,6,opt,name=socket_settings,json=socketSettings,proto3" json:"socket_settings,omitempty"`
    XXX_NoUnkeyedLiteral struct{}               `json:"-"`
    XXX_unrecognized     []byte                 `json:"-"`
    XXX_sizecache        int32                  `json:"-"`
}

func (*StreamConfig) Descriptor Uses

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

func (*StreamConfig) GetEffectiveProtocol Uses

func (c *StreamConfig) GetEffectiveProtocol() string

func (*StreamConfig) GetEffectiveSecuritySettings Uses

func (c *StreamConfig) GetEffectiveSecuritySettings() (interface{}, error)

func (*StreamConfig) GetEffectiveTransportSettings Uses

func (c *StreamConfig) GetEffectiveTransportSettings() (interface{}, error)

func (*StreamConfig) GetProtocol Uses

func (m *StreamConfig) GetProtocol() TransportProtocol

Deprecated: Do not use.

func (*StreamConfig) GetProtocolName Uses

func (m *StreamConfig) GetProtocolName() string

func (*StreamConfig) GetSecuritySettings Uses

func (m *StreamConfig) GetSecuritySettings() []*serial.TypedMessage

func (*StreamConfig) GetSecurityType Uses

func (m *StreamConfig) GetSecurityType() string

func (*StreamConfig) GetSocketSettings Uses

func (m *StreamConfig) GetSocketSettings() *SocketConfig

func (*StreamConfig) GetTransportSettings Uses

func (m *StreamConfig) GetTransportSettings() []*TransportConfig

func (*StreamConfig) GetTransportSettingsFor Uses

func (c *StreamConfig) GetTransportSettingsFor(protocol string) (interface{}, error)

func (*StreamConfig) HasSecuritySettings Uses

func (c *StreamConfig) HasSecuritySettings() bool

func (*StreamConfig) ProtoMessage Uses

func (*StreamConfig) ProtoMessage()

func (*StreamConfig) Reset Uses

func (m *StreamConfig) Reset()

func (*StreamConfig) String Uses

func (m *StreamConfig) String() string

func (*StreamConfig) XXX_DiscardUnknown Uses

func (m *StreamConfig) XXX_DiscardUnknown()

func (*StreamConfig) XXX_Marshal Uses

func (m *StreamConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StreamConfig) XXX_Merge Uses

func (m *StreamConfig) XXX_Merge(src proto.Message)

func (*StreamConfig) XXX_Size Uses

func (m *StreamConfig) XXX_Size() int

func (*StreamConfig) XXX_Unmarshal Uses

func (m *StreamConfig) XXX_Unmarshal(b []byte) error

type SystemDialer Uses

type SystemDialer interface {
    Dial(ctx context.Context, source net.Address, destination net.Destination, sockopt *SocketConfig) (net.Conn, error)
}

func WithAdapter Uses

func WithAdapter(dialer SystemDialerAdapter) SystemDialer

type SystemDialerAdapter Uses

type SystemDialerAdapter interface {
    Dial(network string, address string) (net.Conn, error)
}

type TransportConfig Uses

type TransportConfig struct {
    // Type of network that this settings supports.
    // Deprecated. Use the string form below.
    Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=v2ray.core.transport.internet.TransportProtocol" json:"protocol,omitempty"`
    // Type of network that this settings supports.
    ProtocolName string `protobuf:"bytes,3,opt,name=protocol_name,json=protocolName,proto3" json:"protocol_name,omitempty"`
    // Specific settings. Must be of the transports.
    Settings             *serial.TypedMessage `protobuf:"bytes,2,opt,name=settings,proto3" json:"settings,omitempty"`
    XXX_NoUnkeyedLiteral struct{}             `json:"-"`
    XXX_unrecognized     []byte               `json:"-"`
    XXX_sizecache        int32                `json:"-"`
}

func (*TransportConfig) Descriptor Uses

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

func (*TransportConfig) GetProtocol Uses

func (m *TransportConfig) GetProtocol() TransportProtocol

func (*TransportConfig) GetProtocolName Uses

func (m *TransportConfig) GetProtocolName() string

func (*TransportConfig) GetSettings Uses

func (m *TransportConfig) GetSettings() *serial.TypedMessage

func (*TransportConfig) GetTypedSettings Uses

func (c *TransportConfig) GetTypedSettings() (interface{}, error)

func (*TransportConfig) GetUnifiedProtocolName Uses

func (c *TransportConfig) GetUnifiedProtocolName() string

func (*TransportConfig) ProtoMessage Uses

func (*TransportConfig) ProtoMessage()

func (*TransportConfig) Reset Uses

func (m *TransportConfig) Reset()

func (*TransportConfig) String Uses

func (m *TransportConfig) String() string

func (*TransportConfig) XXX_DiscardUnknown Uses

func (m *TransportConfig) XXX_DiscardUnknown()

func (*TransportConfig) XXX_Marshal Uses

func (m *TransportConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TransportConfig) XXX_Merge Uses

func (m *TransportConfig) XXX_Merge(src proto.Message)

func (*TransportConfig) XXX_Size Uses

func (m *TransportConfig) XXX_Size() int

func (*TransportConfig) XXX_Unmarshal Uses

func (m *TransportConfig) XXX_Unmarshal(b []byte) error

type TransportProtocol Uses

type TransportProtocol int32
const (
    TransportProtocol_TCP          TransportProtocol = 0
    TransportProtocol_UDP          TransportProtocol = 1
    TransportProtocol_MKCP         TransportProtocol = 2
    TransportProtocol_WebSocket    TransportProtocol = 3
    TransportProtocol_HTTP         TransportProtocol = 4
    TransportProtocol_DomainSocket TransportProtocol = 5
)

func (TransportProtocol) EnumDescriptor Uses

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

func (TransportProtocol) String Uses

func (x TransportProtocol) String() string

Directories

PathSynopsis
domainsocket
headers/http
headers/noop
headers/srtp
headers/tls
headers/utp
headers/wechat
headers/wireguard
http
kcpPackage kcp - A Fast and Reliable ARQ Protocol
quic
tcp
tls
udp
websocketPackage websocket implements Websocket transport

Package internet imports 15 packages (graph) and is imported by 182 packages. Updated 2019-11-02. Refresh now. Tools for package owners.