This commit is contained in:
Darien Raymond 2018-10-14 08:23:49 +02:00
parent 98e330513d
commit cb8e7dc9a0
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 7 additions and 2 deletions

View File

@ -310,10 +310,12 @@ func NewServer(ctx context.Context) *Server {
return s
}
// Type implements common.HasType.
func (s *Server) Type() interface{} {
return s.dispatcher.Type()
}
// Dispatch impliments routing.Dispatcher
func (s *Server) Dispatch(ctx context.Context, dest net.Destination) (*vio.Link, error) {
if dest.Address != muxCoolAddress {
return s.dispatcher.Dispatch(ctx, dest)

View File

@ -3,17 +3,18 @@ package internet
import (
"context"
"v2ray.com/core/common/session"
"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)
var (
transportDialerCache = make(map[string]Dialer)
)
// RegisterTransportDialer registers a Dialer with given name.
func RegisterTransportDialer(protocol string, dialer Dialer) error {
if _, found := transportDialerCache[protocol]; found {
return newError(protocol, " dialer already registered").AtError()

View File

@ -1,5 +1,6 @@
package internet
// MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce number of Protobuf parsing.
type MemoryStreamConfig struct {
ProtocolName string
ProtocolSettings interface{}
@ -8,6 +9,7 @@ type MemoryStreamConfig struct {
SocketSettings *SocketConfig
}
// ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input.
func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error) {
ets, err := s.GetEffectiveTransportSettings()
if err != nil {