mirror of https://github.com/v2ray/v2ray-core
comments
parent
98e330513d
commit
cb8e7dc9a0
|
@ -310,10 +310,12 @@ func NewServer(ctx context.Context) *Server {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type implements common.HasType.
|
||||||
func (s *Server) Type() interface{} {
|
func (s *Server) Type() interface{} {
|
||||||
return s.dispatcher.Type()
|
return s.dispatcher.Type()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dispatch impliments routing.Dispatcher
|
||||||
func (s *Server) Dispatch(ctx context.Context, dest net.Destination) (*vio.Link, error) {
|
func (s *Server) Dispatch(ctx context.Context, dest net.Destination) (*vio.Link, error) {
|
||||||
if dest.Address != muxCoolAddress {
|
if dest.Address != muxCoolAddress {
|
||||||
return s.dispatcher.Dispatch(ctx, dest)
|
return s.dispatcher.Dispatch(ctx, dest)
|
||||||
|
|
|
@ -3,17 +3,18 @@ package internet
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"v2ray.com/core/common/session"
|
|
||||||
|
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
|
"v2ray.com/core/common/session"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Dialer is an interface to dial network connection to a specific destination.
|
||||||
type Dialer func(ctx context.Context, dest net.Destination) (Connection, error)
|
type Dialer func(ctx context.Context, dest net.Destination) (Connection, error)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
transportDialerCache = make(map[string]Dialer)
|
transportDialerCache = make(map[string]Dialer)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RegisterTransportDialer registers a Dialer with given name.
|
||||||
func RegisterTransportDialer(protocol string, dialer Dialer) error {
|
func RegisterTransportDialer(protocol string, dialer Dialer) error {
|
||||||
if _, found := transportDialerCache[protocol]; found {
|
if _, found := transportDialerCache[protocol]; found {
|
||||||
return newError(protocol, " dialer already registered").AtError()
|
return newError(protocol, " dialer already registered").AtError()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package internet
|
package internet
|
||||||
|
|
||||||
|
// MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce number of Protobuf parsing.
|
||||||
type MemoryStreamConfig struct {
|
type MemoryStreamConfig struct {
|
||||||
ProtocolName string
|
ProtocolName string
|
||||||
ProtocolSettings interface{}
|
ProtocolSettings interface{}
|
||||||
|
@ -8,6 +9,7 @@ type MemoryStreamConfig struct {
|
||||||
SocketSettings *SocketConfig
|
SocketSettings *SocketConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input.
|
||||||
func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error) {
|
func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error) {
|
||||||
ets, err := s.GetEffectiveTransportSettings()
|
ets, err := s.GetEffectiveTransportSettings()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue