mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-29 02:13:03 +00:00
Chore: Run gofmt (#3990)
This commit is contained in:
parent
bc4bf3d38f
commit
83bab5dd90
@ -28,7 +28,7 @@ func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error)
|
|||||||
}
|
}
|
||||||
return protocolSnifferWithMetadata{protocolSniffer: func(ctx context.Context, bytes []byte) (SniffResult, error) {
|
return protocolSnifferWithMetadata{protocolSniffer: func(ctx context.Context, bytes []byte) (SniffResult, error) {
|
||||||
outbounds := session.OutboundsFromContext(ctx)
|
outbounds := session.OutboundsFromContext(ctx)
|
||||||
ob := outbounds[len(outbounds) - 1]
|
ob := outbounds[len(outbounds)-1]
|
||||||
if ob.Target.Network == net.Network_TCP || ob.Target.Network == net.Network_UDP {
|
if ob.Target.Network == net.Network_TCP || ob.Target.Network == net.Network_UDP {
|
||||||
domainFromFakeDNS := fakeDNSEngine.GetDomainFromFakeDNS(ob.Target.Address)
|
domainFromFakeDNS := fakeDNSEngine.GetDomainFromFakeDNS(ob.Target.Address)
|
||||||
if domainFromFakeDNS != "" {
|
if domainFromFakeDNS != "" {
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
|
|
||||||
"github.com/xtls/xray-core/app/proxyman"
|
"github.com/xtls/xray-core/app/proxyman"
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/errors"
|
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
|
"github.com/xtls/xray-core/common/errors"
|
||||||
"github.com/xtls/xray-core/common/mux"
|
"github.com/xtls/xray-core/common/mux"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/net/cnc"
|
"github.com/xtls/xray-core/common/net/cnc"
|
||||||
|
@ -7,64 +7,64 @@ import (
|
|||||||
/*
|
/*
|
||||||
Split into multiple package, need to be tested separately
|
Split into multiple package, need to be tested separately
|
||||||
|
|
||||||
func TestSelectLeastLoad(t *testing.T) {
|
func TestSelectLeastLoad(t *testing.T) {
|
||||||
settings := &StrategyLeastLoadConfig{
|
settings := &StrategyLeastLoadConfig{
|
||||||
HealthCheck: &HealthPingConfig{
|
HealthCheck: &HealthPingConfig{
|
||||||
SamplingCount: 10,
|
SamplingCount: 10,
|
||||||
},
|
},
|
||||||
Expected: 1,
|
Expected: 1,
|
||||||
MaxRTT: int64(time.Millisecond * time.Duration(800)),
|
MaxRTT: int64(time.Millisecond * time.Duration(800)),
|
||||||
|
}
|
||||||
|
strategy := NewLeastLoadStrategy(settings)
|
||||||
|
// std 40
|
||||||
|
strategy.PutResult("a", time.Millisecond*time.Duration(60))
|
||||||
|
strategy.PutResult("a", time.Millisecond*time.Duration(140))
|
||||||
|
strategy.PutResult("a", time.Millisecond*time.Duration(60))
|
||||||
|
strategy.PutResult("a", time.Millisecond*time.Duration(140))
|
||||||
|
// std 60
|
||||||
|
strategy.PutResult("b", time.Millisecond*time.Duration(40))
|
||||||
|
strategy.PutResult("b", time.Millisecond*time.Duration(160))
|
||||||
|
strategy.PutResult("b", time.Millisecond*time.Duration(40))
|
||||||
|
strategy.PutResult("b", time.Millisecond*time.Duration(160))
|
||||||
|
// std 0, but >MaxRTT
|
||||||
|
strategy.PutResult("c", time.Millisecond*time.Duration(1000))
|
||||||
|
strategy.PutResult("c", time.Millisecond*time.Duration(1000))
|
||||||
|
strategy.PutResult("c", time.Millisecond*time.Duration(1000))
|
||||||
|
strategy.PutResult("c", time.Millisecond*time.Duration(1000))
|
||||||
|
expected := "a"
|
||||||
|
actual := strategy.SelectAndPick([]string{"a", "b", "c", "untested"})
|
||||||
|
if actual != expected {
|
||||||
|
t.Errorf("expected: %v, actual: %v", expected, actual)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
strategy := NewLeastLoadStrategy(settings)
|
|
||||||
// std 40
|
|
||||||
strategy.PutResult("a", time.Millisecond*time.Duration(60))
|
|
||||||
strategy.PutResult("a", time.Millisecond*time.Duration(140))
|
|
||||||
strategy.PutResult("a", time.Millisecond*time.Duration(60))
|
|
||||||
strategy.PutResult("a", time.Millisecond*time.Duration(140))
|
|
||||||
// std 60
|
|
||||||
strategy.PutResult("b", time.Millisecond*time.Duration(40))
|
|
||||||
strategy.PutResult("b", time.Millisecond*time.Duration(160))
|
|
||||||
strategy.PutResult("b", time.Millisecond*time.Duration(40))
|
|
||||||
strategy.PutResult("b", time.Millisecond*time.Duration(160))
|
|
||||||
// std 0, but >MaxRTT
|
|
||||||
strategy.PutResult("c", time.Millisecond*time.Duration(1000))
|
|
||||||
strategy.PutResult("c", time.Millisecond*time.Duration(1000))
|
|
||||||
strategy.PutResult("c", time.Millisecond*time.Duration(1000))
|
|
||||||
strategy.PutResult("c", time.Millisecond*time.Duration(1000))
|
|
||||||
expected := "a"
|
|
||||||
actual := strategy.SelectAndPick([]string{"a", "b", "c", "untested"})
|
|
||||||
if actual != expected {
|
|
||||||
t.Errorf("expected: %v, actual: %v", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSelectLeastLoadWithCost(t *testing.T) {
|
func TestSelectLeastLoadWithCost(t *testing.T) {
|
||||||
settings := &StrategyLeastLoadConfig{
|
settings := &StrategyLeastLoadConfig{
|
||||||
HealthCheck: &HealthPingConfig{
|
HealthCheck: &HealthPingConfig{
|
||||||
SamplingCount: 10,
|
SamplingCount: 10,
|
||||||
},
|
},
|
||||||
Costs: []*StrategyWeight{
|
Costs: []*StrategyWeight{
|
||||||
{Match: "a", Value: 9},
|
{Match: "a", Value: 9},
|
||||||
},
|
},
|
||||||
Expected: 1,
|
Expected: 1,
|
||||||
|
}
|
||||||
|
strategy := NewLeastLoadStrategy(settings, nil)
|
||||||
|
// std 40, std+c 120
|
||||||
|
strategy.PutResult("a", time.Millisecond*time.Duration(60))
|
||||||
|
strategy.PutResult("a", time.Millisecond*time.Duration(140))
|
||||||
|
strategy.PutResult("a", time.Millisecond*time.Duration(60))
|
||||||
|
strategy.PutResult("a", time.Millisecond*time.Duration(140))
|
||||||
|
// std 60
|
||||||
|
strategy.PutResult("b", time.Millisecond*time.Duration(40))
|
||||||
|
strategy.PutResult("b", time.Millisecond*time.Duration(160))
|
||||||
|
strategy.PutResult("b", time.Millisecond*time.Duration(40))
|
||||||
|
strategy.PutResult("b", time.Millisecond*time.Duration(160))
|
||||||
|
expected := "b"
|
||||||
|
actual := strategy.SelectAndPick([]string{"a", "b", "untested"})
|
||||||
|
if actual != expected {
|
||||||
|
t.Errorf("expected: %v, actual: %v", expected, actual)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
strategy := NewLeastLoadStrategy(settings, nil)
|
|
||||||
// std 40, std+c 120
|
|
||||||
strategy.PutResult("a", time.Millisecond*time.Duration(60))
|
|
||||||
strategy.PutResult("a", time.Millisecond*time.Duration(140))
|
|
||||||
strategy.PutResult("a", time.Millisecond*time.Duration(60))
|
|
||||||
strategy.PutResult("a", time.Millisecond*time.Duration(140))
|
|
||||||
// std 60
|
|
||||||
strategy.PutResult("b", time.Millisecond*time.Duration(40))
|
|
||||||
strategy.PutResult("b", time.Millisecond*time.Duration(160))
|
|
||||||
strategy.PutResult("b", time.Millisecond*time.Duration(40))
|
|
||||||
strategy.PutResult("b", time.Millisecond*time.Duration(160))
|
|
||||||
expected := "b"
|
|
||||||
actual := strategy.SelectAndPick([]string{"a", "b", "untested"})
|
|
||||||
if actual != expected {
|
|
||||||
t.Errorf("expected: %v, actual: %v", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
func TestSelectLeastExpected(t *testing.T) {
|
func TestSelectLeastExpected(t *testing.T) {
|
||||||
strategy := &LeastLoadStrategy{
|
strategy := &LeastLoadStrategy{
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// RandomStrategy represents a random balancing strategy
|
// RandomStrategy represents a random balancing strategy
|
||||||
type RandomStrategy struct{
|
type RandomStrategy struct {
|
||||||
FallbackTag string
|
FallbackTag string
|
||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
@ -218,7 +218,7 @@ func (b *Buffer) Cap() int32 {
|
|||||||
// NewWithSize creates a Buffer with 0 length and capacity with at least the given size.
|
// NewWithSize creates a Buffer with 0 length and capacity with at least the given size.
|
||||||
func NewWithSize(size int32) *Buffer {
|
func NewWithSize(size int32) *Buffer {
|
||||||
return &Buffer{
|
return &Buffer{
|
||||||
v: bytespool.Alloc(size),
|
v: bytespool.Alloc(size),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ type SessionKey int
|
|||||||
// ID of a session.
|
// ID of a session.
|
||||||
type ID uint32
|
type ID uint32
|
||||||
|
|
||||||
const(
|
const (
|
||||||
idSessionKey SessionKey = 0
|
idSessionKey SessionKey = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ func ToProtoUser(mu *MemoryUser) *User {
|
|||||||
}
|
}
|
||||||
return &User{
|
return &User{
|
||||||
Account: serial.ToTypedMessage(mu.Account.ToProto()),
|
Account: serial.ToTypedMessage(mu.Account.ToProto()),
|
||||||
Email: mu.Email,
|
Email: mu.Email,
|
||||||
Level: mu.Level,
|
Level: mu.Level,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ func MarshalToJson(v interface{}, insertTypeInfo bool) (string, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func JSONMarshalWithoutEscape(t interface{}) ([]byte, error) {
|
func JSONMarshalWithoutEscape(t interface{}) ([]byte, error) {
|
||||||
buffer := &bytes.Buffer{}
|
buffer := &bytes.Buffer{}
|
||||||
encoder := json.NewEncoder(buffer)
|
encoder := json.NewEncoder(buffer)
|
||||||
encoder.SetIndent("", " ")
|
encoder.SetIndent("", " ")
|
||||||
encoder.SetEscapeHTML(false)
|
encoder.SetEscapeHTML(false)
|
||||||
err := encoder.Encode(t)
|
err := encoder.Encode(t)
|
||||||
return buffer.Bytes(), err
|
return buffer.Bytes(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
||||||
|
@ -148,4 +148,4 @@ func (c *Content) AttributeLen() int {
|
|||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
}()
|
}()
|
||||||
return len(c.Attributes)
|
return len(c.Attributes)
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ func (d *XrayOutboundDialer) DialContext(ctx context.Context, network string, de
|
|||||||
outbounds = []*session.Outbound{{}}
|
outbounds = []*session.Outbound{{}}
|
||||||
ctx = session.ContextWithOutbounds(ctx, outbounds)
|
ctx = session.ContextWithOutbounds(ctx, outbounds)
|
||||||
}
|
}
|
||||||
ob := outbounds[len(outbounds) - 1]
|
ob := outbounds[len(outbounds)-1]
|
||||||
ob.Target = ToDestination(destination, ToNetwork(network))
|
ob.Target = ToDestination(destination, ToNetwork(network))
|
||||||
|
|
||||||
opts := []pipe.Option{pipe.WithSizeLimit(64 * 1024)}
|
opts := []pipe.Option{pipe.WithSizeLimit(64 * 1024)}
|
||||||
uplinkReader, uplinkWriter := pipe.New(opts...)
|
uplinkReader, uplinkWriter := pipe.New(opts...)
|
||||||
downlinkReader, downlinkWriter := pipe.New(opts...)
|
downlinkReader, downlinkWriter := pipe.New(opts...)
|
||||||
|
@ -54,8 +54,8 @@ func TestXrayClose(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(net.LocalHostIP),
|
Address: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
Port: uint32(0),
|
Port: uint32(0),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -125,7 +125,7 @@ func (ctx *Context) GetSkipDNSResolve() bool {
|
|||||||
// AsRoutingContext creates a context from context.context with session info.
|
// AsRoutingContext creates a context from context.context with session info.
|
||||||
func AsRoutingContext(ctx context.Context) routing.Context {
|
func AsRoutingContext(ctx context.Context) routing.Context {
|
||||||
outbounds := session.OutboundsFromContext(ctx)
|
outbounds := session.OutboundsFromContext(ctx)
|
||||||
ob := outbounds[len(outbounds) - 1]
|
ob := outbounds[len(outbounds)-1]
|
||||||
return &Context{
|
return &Context{
|
||||||
Inbound: session.InboundFromContext(ctx),
|
Inbound: session.InboundFromContext(ctx),
|
||||||
Outbound: ob,
|
Outbound: ob,
|
||||||
|
@ -13,7 +13,7 @@ type DNSOutboundConfig struct {
|
|||||||
Port uint16 `json:"port"`
|
Port uint16 `json:"port"`
|
||||||
UserLevel uint32 `json:"userLevel"`
|
UserLevel uint32 `json:"userLevel"`
|
||||||
NonIPQuery string `json:"nonIPQuery"`
|
NonIPQuery string `json:"nonIPQuery"`
|
||||||
BlockTypes []int32 `json:"blockTypes"`
|
BlockTypes []int32 `json:"blockTypes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DNSOutboundConfig) Build() (proto.Message, error) {
|
func (c *DNSOutboundConfig) Build() (proto.Message, error) {
|
||||||
|
@ -6,11 +6,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DokodemoConfig struct {
|
type DokodemoConfig struct {
|
||||||
Host *Address `json:"address"`
|
Host *Address `json:"address"`
|
||||||
PortValue uint16 `json:"port"`
|
PortValue uint16 `json:"port"`
|
||||||
NetworkList *NetworkList `json:"network"`
|
NetworkList *NetworkList `json:"network"`
|
||||||
Redirect bool `json:"followRedirect"`
|
Redirect bool `json:"followRedirect"`
|
||||||
UserLevel uint32 `json:"userLevel"`
|
UserLevel uint32 `json:"userLevel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *DokodemoConfig) Build() (proto.Message, error) {
|
func (v *DokodemoConfig) Build() (proto.Message, error) {
|
||||||
|
@ -2,7 +2,7 @@ package conf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/app/observatory"
|
"github.com/xtls/xray-core/app/observatory"
|
||||||
"github.com/xtls/xray-core/app/observatory/burst"
|
"github.com/xtls/xray-core/app/observatory/burst"
|
||||||
"github.com/xtls/xray-core/infra/conf/cfgcommon/duration"
|
"github.com/xtls/xray-core/infra/conf/cfgcommon/duration"
|
||||||
|
@ -71,9 +71,9 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RouterConfig struct {
|
type RouterConfig struct {
|
||||||
RuleList []json.RawMessage `json:"rules"`
|
RuleList []json.RawMessage `json:"rules"`
|
||||||
DomainStrategy *string `json:"domainStrategy"`
|
DomainStrategy *string `json:"domainStrategy"`
|
||||||
Balancers []*BalancingRule `json:"balancers"`
|
Balancers []*BalancingRule `json:"balancers"`
|
||||||
|
|
||||||
DomainMatcher string `json:"domainMatcher"`
|
DomainMatcher string `json:"domainMatcher"`
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@ package conf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/app/router"
|
|
||||||
"github.com/xtls/xray-core/app/observatory/burst"
|
"github.com/xtls/xray-core/app/observatory/burst"
|
||||||
|
"github.com/xtls/xray-core/app/router"
|
||||||
"github.com/xtls/xray-core/infra/conf/cfgcommon/duration"
|
"github.com/xtls/xray-core/infra/conf/cfgcommon/duration"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,10 +46,10 @@ type strategyLeastLoadConfig struct {
|
|||||||
|
|
||||||
// healthCheckSettings holds settings for health Checker
|
// healthCheckSettings holds settings for health Checker
|
||||||
type healthCheckSettings struct {
|
type healthCheckSettings struct {
|
||||||
Destination string `json:"destination"`
|
Destination string `json:"destination"`
|
||||||
Connectivity string `json:"connectivity"`
|
Connectivity string `json:"connectivity"`
|
||||||
Interval duration.Duration `json:"interval"`
|
Interval duration.Duration `json:"interval"`
|
||||||
SamplingCount int `json:"sampling"`
|
SamplingCount int `json:"sampling"`
|
||||||
Timeout duration.Duration `json:"timeout"`
|
Timeout duration.Duration `json:"timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ func (c *StatsConfig) Build() (*stats.Config, error) {
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
// Deprecated: Global transport config is no longer used
|
// Deprecated: Global transport config is no longer used
|
||||||
// left for returning error
|
// left for returning error
|
||||||
Transport map[string]json.RawMessage `json:"transport"`
|
Transport map[string]json.RawMessage `json:"transport"`
|
||||||
|
|
||||||
LogConfig *LogConfig `json:"log"`
|
LogConfig *LogConfig `json:"log"`
|
||||||
RouterConfig *RouterConfig `json:"routing"`
|
RouterConfig *RouterConfig `json:"routing"`
|
||||||
|
@ -39,7 +39,7 @@ func executeInboundUser(cmd *base.Command, args []string) {
|
|||||||
|
|
||||||
client := handlerService.NewHandlerServiceClient(conn)
|
client := handlerService.NewHandlerServiceClient(conn)
|
||||||
r := &handlerService.GetInboundUserRequest{
|
r := &handlerService.GetInboundUserRequest{
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
Email: email,
|
Email: email,
|
||||||
}
|
}
|
||||||
resp, err := client.GetInboundUsers(ctx, r)
|
resp, err := client.GetInboundUsers(ctx, r)
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
"github.com/xtls/xray-core/main/commands/base"
|
|
||||||
creflect "github.com/xtls/xray-core/common/reflect"
|
creflect "github.com/xtls/xray-core/common/reflect"
|
||||||
|
"github.com/xtls/xray-core/main/commands/base"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
@ -30,9 +30,9 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
|
|||||||
// Process implements OutboundHandler.Dispatch().
|
// Process implements OutboundHandler.Dispatch().
|
||||||
func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {
|
func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {
|
||||||
outbounds := session.OutboundsFromContext(ctx)
|
outbounds := session.OutboundsFromContext(ctx)
|
||||||
ob := outbounds[len(outbounds) - 1]
|
ob := outbounds[len(outbounds)-1]
|
||||||
ob.Name = "blackhole"
|
ob.Name = "blackhole"
|
||||||
|
|
||||||
nBytes := h.response.WriteTo(link.Writer)
|
nBytes := h.response.WriteTo(link.Writer)
|
||||||
if nBytes > 0 {
|
if nBytes > 0 {
|
||||||
// Sleep a little here to make sure the response is sent to client.
|
// Sleep a little here to make sure the response is sent to client.
|
||||||
|
@ -49,7 +49,7 @@ type Handler struct {
|
|||||||
server net.Destination
|
server net.Destination
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
nonIPQuery string
|
nonIPQuery string
|
||||||
blockTypes []int32
|
blockTypes []int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager policy.Manager) error {
|
func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager policy.Manager) error {
|
||||||
|
@ -78,7 +78,7 @@ type UserManager interface {
|
|||||||
|
|
||||||
// RemoveUser removes a user by email.
|
// RemoveUser removes a user by email.
|
||||||
RemoveUser(context.Context, string) error
|
RemoveUser(context.Context, string) error
|
||||||
|
|
||||||
// Get user by email.
|
// Get user by email.
|
||||||
GetUser(context.Context, string) *protocol.MemoryUser
|
GetUser(context.Context, string) *protocol.MemoryUser
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
// MemoryAccount is an account type converted from Account.
|
// MemoryAccount is an account type converted from Account.
|
||||||
type MemoryAccount struct {
|
type MemoryAccount struct {
|
||||||
Cipher Cipher
|
Cipher Cipher
|
||||||
CipherType CipherType
|
CipherType CipherType
|
||||||
Key []byte
|
Key []byte
|
||||||
Password string
|
Password string
|
||||||
|
|
||||||
@ -42,8 +42,8 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool {
|
|||||||
func (a *MemoryAccount) ToProto() proto.Message {
|
func (a *MemoryAccount) ToProto() proto.Message {
|
||||||
return &Account{
|
return &Account{
|
||||||
CipherType: a.CipherType,
|
CipherType: a.CipherType,
|
||||||
Password: a.Password,
|
Password: a.Password,
|
||||||
IvCheck: a.replayFilter != nil,
|
IvCheck: a.replayFilter != nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,10 +117,10 @@ func (a *Account) AsAccount() (protocol.Account, error) {
|
|||||||
return nil, errors.New("failed to get cipher").Base(err)
|
return nil, errors.New("failed to get cipher").Base(err)
|
||||||
}
|
}
|
||||||
return &MemoryAccount{
|
return &MemoryAccount{
|
||||||
Cipher: Cipher,
|
Cipher: Cipher,
|
||||||
CipherType: a.CipherType,
|
CipherType: a.CipherType,
|
||||||
Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()),
|
Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()),
|
||||||
Password: a.Password,
|
Password: a.Password,
|
||||||
replayFilter: func() antireplay.GeneralizedReplayFilter {
|
replayFilter: func() antireplay.GeneralizedReplayFilter {
|
||||||
if a.IvCheck {
|
if a.IvCheck {
|
||||||
return antireplay.NewBloomRing()
|
return antireplay.NewBloomRing()
|
||||||
|
@ -10,9 +10,9 @@ import (
|
|||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
"github.com/xtls/xray-core/common/errors"
|
|
||||||
"github.com/xtls/xray-core/common/crypto"
|
"github.com/xtls/xray-core/common/crypto"
|
||||||
"github.com/xtls/xray-core/common/drain"
|
"github.com/xtls/xray-core/common/drain"
|
||||||
|
"github.com/xtls/xray-core/common/errors"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/protocol"
|
"github.com/xtls/xray-core/common/protocol"
|
||||||
)
|
)
|
||||||
|
@ -8,13 +8,13 @@ import (
|
|||||||
|
|
||||||
// MemoryAccount is an account type converted from Account.
|
// MemoryAccount is an account type converted from Account.
|
||||||
type MemoryAccount struct {
|
type MemoryAccount struct {
|
||||||
Key string
|
Key string
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsAccount implements protocol.AsAccount.
|
// AsAccount implements protocol.AsAccount.
|
||||||
func (u *Account) AsAccount() (protocol.Account, error) {
|
func (u *Account) AsAccount() (protocol.Account, error) {
|
||||||
return &MemoryAccount{
|
return &MemoryAccount{
|
||||||
Key: u.GetKey(),
|
Key: u.GetKey(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ func (i *MultiUserInbound) GetUser(ctx context.Context, email string) *protocol.
|
|||||||
if email == "" {
|
if email == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
i.Lock()
|
i.Lock()
|
||||||
defer i.Unlock()
|
defer i.Unlock()
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
|
|||||||
serverPicker: protocol.NewRoundRobinServerPicker(serverList),
|
serverPicker: protocol.NewRoundRobinServerPicker(serverList),
|
||||||
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
|
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,14 +361,14 @@ func (s *Server) fallback(ctx context.Context, err error, sessionPolicy policy.S
|
|||||||
cs := tlsConn.ConnectionState()
|
cs := tlsConn.ConnectionState()
|
||||||
name = cs.ServerName
|
name = cs.ServerName
|
||||||
alpn = cs.NegotiatedProtocol
|
alpn = cs.NegotiatedProtocol
|
||||||
errors.LogInfo(ctx, "realName = " + name)
|
errors.LogInfo(ctx, "realName = "+name)
|
||||||
errors.LogInfo(ctx, "realAlpn = " + alpn)
|
errors.LogInfo(ctx, "realAlpn = "+alpn)
|
||||||
} else if realityConn, ok := iConn.(*reality.Conn); ok {
|
} else if realityConn, ok := iConn.(*reality.Conn); ok {
|
||||||
cs := realityConn.ConnectionState()
|
cs := realityConn.ConnectionState()
|
||||||
name = cs.ServerName
|
name = cs.ServerName
|
||||||
alpn = cs.NegotiatedProtocol
|
alpn = cs.NegotiatedProtocol
|
||||||
errors.LogInfo(ctx, "realName = " + name)
|
errors.LogInfo(ctx, "realName = "+name)
|
||||||
errors.LogInfo(ctx, "realAlpn = " + alpn)
|
errors.LogInfo(ctx, "realAlpn = "+alpn)
|
||||||
}
|
}
|
||||||
name = strings.ToLower(name)
|
name = strings.ToLower(name)
|
||||||
alpn = strings.ToLower(alpn)
|
alpn = strings.ToLower(alpn)
|
||||||
@ -418,7 +418,7 @@ func (s *Server) fallback(ctx context.Context, err error, sessionPolicy policy.S
|
|||||||
}
|
}
|
||||||
if k == '?' || k == ' ' {
|
if k == '?' || k == ' ' {
|
||||||
path = string(firstBytes[i:j])
|
path = string(firstBytes[i:j])
|
||||||
errors.LogInfo(ctx, "realPath = " + path)
|
errors.LogInfo(ctx, "realPath = "+path)
|
||||||
if pfb[path] == nil {
|
if pfb[path] == nil {
|
||||||
path = ""
|
path = ""
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ func (v *Validator) Get(hash string) *protocol.MemoryUser {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get a trojan user with hashed key, nil if user doesn't exist.
|
// Get a trojan user with hashed key, nil if user doesn't exist.
|
||||||
func (v *Validator) GetByEmail(email string) *protocol.MemoryUser {
|
func (v *Validator) GetByEmail(email string) *protocol.MemoryUser {
|
||||||
u, _ := v.email.Load(email)
|
u, _ := v.email.Load(email)
|
||||||
|
@ -42,8 +42,8 @@ func (a *MemoryAccount) Equals(account protocol.Account) bool {
|
|||||||
|
|
||||||
func (a *MemoryAccount) ToProto() proto.Message {
|
func (a *MemoryAccount) ToProto() proto.Message {
|
||||||
return &Account{
|
return &Account{
|
||||||
Id: a.ID.String(),
|
Id: a.ID.String(),
|
||||||
Flow: a.Flow,
|
Flow: a.Flow,
|
||||||
Encryption: a.Encryption,
|
Encryption: a.Encryption,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ func (a *MemoryAccount) ToProto() proto.Message {
|
|||||||
test = test + "NoTerminationSignal"
|
test = test + "NoTerminationSignal"
|
||||||
}
|
}
|
||||||
return &Account{
|
return &Account{
|
||||||
Id: a.ID.String(),
|
Id: a.ID.String(),
|
||||||
TestsEnabled: test,
|
TestsEnabled: test,
|
||||||
SecuritySettings: &protocol.SecurityConfig{Type: a.Security},
|
SecuritySettings: &protocol.SecurityConfig{Type: a.Security},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import (
|
|||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
"github.com/xtls/xray-core/common/errors"
|
|
||||||
"github.com/xtls/xray-core/common/dice"
|
"github.com/xtls/xray-core/common/dice"
|
||||||
|
"github.com/xtls/xray-core/common/errors"
|
||||||
"github.com/xtls/xray-core/common/log"
|
"github.com/xtls/xray-core/common/log"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/protocol"
|
"github.com/xtls/xray-core/common/protocol"
|
||||||
|
@ -303,8 +303,8 @@ func TestCommanderAddRemoveUser(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -458,8 +458,8 @@ func TestCommanderStats(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -480,8 +480,8 @@ func TestCommanderStats(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -85,8 +85,8 @@ func TestDokodemoTCP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -181,8 +181,8 @@ func TestDokodemoUDP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_UDP},
|
Networks: []net.Network{net.Network_UDP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -53,8 +53,8 @@ func TestPassiveConnection(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -161,8 +161,8 @@ func TestProxy(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -299,8 +299,8 @@ func TestProxyOverKCP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -386,8 +386,8 @@ func TestBlackhole(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -397,8 +397,8 @@ func TestBlackhole(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest2.Address),
|
Address: net.NewIPOrDomain(dest2.Address),
|
||||||
Port: uint32(dest2.Port),
|
Port: uint32(dest2.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -512,8 +512,8 @@ func TestUDPConnection(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_UDP},
|
Networks: []net.Network{net.Network_UDP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -556,8 +556,8 @@ func TestDomainSniffing(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(net.LocalHostIP),
|
Address: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
Port: 443,
|
Port: 443,
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -110,8 +110,8 @@ func TestVMessClosing(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -214,8 +214,8 @@ func TestZeroBuffer(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -76,8 +76,8 @@ func TestReverseProxy(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -141,8 +141,8 @@ func TestReverseProxy(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -255,8 +255,8 @@ func TestReverseProxyLongRunning(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -334,8 +334,8 @@ func TestReverseProxyLongRunning(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -64,8 +64,8 @@ func TestSocksBridgeTCP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -143,8 +143,8 @@ func TestSocksWithHttpRequest(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -213,8 +213,8 @@ func TestSocksBridageUDP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_UDP},
|
Networks: []net.Network{net.Network_UDP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -247,8 +247,8 @@ func TestSocksBridageUDP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_UDP},
|
Networks: []net.Network{net.Network_UDP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -328,8 +328,8 @@ func TestSocksBridageUDPWithRouting(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_UDP},
|
Networks: []net.Network{net.Network_UDP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -366,8 +366,8 @@ func TestSocksBridageUDPWithRouting(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_UDP},
|
Networks: []net.Network{net.Network_UDP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -81,8 +81,8 @@ func TestSimpleTLSConnection(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -196,8 +196,8 @@ func TestAutoIssuingCertificate(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -301,8 +301,8 @@ func TestTLSOverKCP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -401,8 +401,8 @@ func TestTLSOverWebSocket(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -426,7 +426,7 @@ func TestTLSOverWebSocket(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
ProtocolName: "websocket",
|
ProtocolName: "websocket",
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "websocket",
|
ProtocolName: "websocket",
|
||||||
@ -475,11 +475,11 @@ func TestHTTP2(t *testing.T) {
|
|||||||
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}},
|
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}},
|
||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
ProtocolName: "http",
|
ProtocolName: "http",
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "http",
|
ProtocolName: "http",
|
||||||
Settings: serial.ToTypedMessage(&http.Config{
|
Settings: serial.ToTypedMessage(&http.Config{
|
||||||
Host: []string{"example.com"},
|
Host: []string{"example.com"},
|
||||||
Path: "/testpath",
|
Path: "/testpath",
|
||||||
}),
|
}),
|
||||||
@ -520,8 +520,8 @@ func TestHTTP2(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -545,11 +545,11 @@ func TestHTTP2(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
ProtocolName: "http",
|
ProtocolName: "http",
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "http",
|
ProtocolName: "http",
|
||||||
Settings: serial.ToTypedMessage(&http.Config{
|
Settings: serial.ToTypedMessage(&http.Config{
|
||||||
Host: []string{"example.com"},
|
Host: []string{"example.com"},
|
||||||
Path: "/testpath",
|
Path: "/testpath",
|
||||||
}),
|
}),
|
||||||
@ -639,8 +639,8 @@ func TestGRPC(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -755,8 +755,8 @@ func TestGRPCMultiMode(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -866,8 +866,8 @@ func TestSimpleTLSConnectionPinned(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -968,8 +968,8 @@ func TestSimpleTLSConnectionPinnedWrongCert(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -1069,8 +1069,8 @@ func TestUTLSConnectionPinned(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -1172,8 +1172,8 @@ func TestUTLSConnectionPinnedWrongCert(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -42,7 +42,7 @@ func TestHTTPConnectionHeader(t *testing.T) {
|
|||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
Settings: serial.ToTypedMessage(&tcptransport.Config{
|
Settings: serial.ToTypedMessage(&tcptransport.Config{
|
||||||
HeaderSettings: serial.ToTypedMessage(&http.Config{}),
|
HeaderSettings: serial.ToTypedMessage(&http.Config{}),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -76,8 +76,8 @@ func TestHTTPConnectionHeader(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -104,7 +104,7 @@ func TestHTTPConnectionHeader(t *testing.T) {
|
|||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
Settings: serial.ToTypedMessage(&tcptransport.Config{
|
Settings: serial.ToTypedMessage(&tcptransport.Config{
|
||||||
HeaderSettings: serial.ToTypedMessage(&http.Config{}),
|
HeaderSettings: serial.ToTypedMessage(&http.Config{}),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -85,8 +85,8 @@ func TestVless(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -190,8 +190,8 @@ func TestVlessTls(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -215,7 +215,7 @@ func TestVlessTls(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
@ -313,8 +313,8 @@ func TestVlessXtlsVision(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -339,7 +339,7 @@ func TestVlessXtlsVision(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
@ -403,12 +403,12 @@ func TestVlessXtlsVisionReality(t *testing.T) {
|
|||||||
SecurityType: serial.GetMessageType(&reality.Config{}),
|
SecurityType: serial.GetMessageType(&reality.Config{}),
|
||||||
SecuritySettings: []*serial.TypedMessage{
|
SecuritySettings: []*serial.TypedMessage{
|
||||||
serial.ToTypedMessage(&reality.Config{
|
serial.ToTypedMessage(&reality.Config{
|
||||||
Show: true,
|
Show: true,
|
||||||
Dest: "www.google.com:443", // use google for now, may fail in some region
|
Dest: "www.google.com:443", // use google for now, may fail in some region
|
||||||
ServerNames: []string{"www.google.com"},
|
ServerNames: []string{"www.google.com"},
|
||||||
PrivateKey: privateKey,
|
PrivateKey: privateKey,
|
||||||
ShortIds: shortIds,
|
ShortIds: shortIds,
|
||||||
Type: "tcp",
|
Type: "tcp",
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -447,8 +447,8 @@ func TestVlessXtlsVisionReality(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -473,7 +473,7 @@ func TestVlessXtlsVisionReality(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "tcp",
|
ProtocolName: "tcp",
|
||||||
@ -483,12 +483,12 @@ func TestVlessXtlsVisionReality(t *testing.T) {
|
|||||||
SecurityType: serial.GetMessageType(&reality.Config{}),
|
SecurityType: serial.GetMessageType(&reality.Config{}),
|
||||||
SecuritySettings: []*serial.TypedMessage{
|
SecuritySettings: []*serial.TypedMessage{
|
||||||
serial.ToTypedMessage(&reality.Config{
|
serial.ToTypedMessage(&reality.Config{
|
||||||
Show: true,
|
Show: true,
|
||||||
Fingerprint: "chrome",
|
Fingerprint: "chrome",
|
||||||
ServerName: "www.google.com",
|
ServerName: "www.google.com",
|
||||||
PublicKey: publicKey,
|
PublicKey: publicKey,
|
||||||
ShortId: shortIds[0],
|
ShortId: shortIds[0],
|
||||||
SpiderX: "/",
|
SpiderX: "/",
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -71,8 +71,8 @@ func TestVMessDynamicPort(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -131,8 +131,8 @@ func TestVMessDynamicPort(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -223,8 +223,8 @@ func TestVMessGCM(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -325,8 +325,8 @@ func TestVMessGCMReadv(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -430,8 +430,8 @@ func TestVMessGCMUDP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_UDP},
|
Networks: []net.Network{net.Network_UDP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -529,8 +529,8 @@ func TestVMessChacha20(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -629,8 +629,8 @@ func TestVMessNone(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -731,8 +731,8 @@ func TestVMessKCP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -802,11 +802,11 @@ func TestVMessKCPLarge(t *testing.T) {
|
|||||||
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}},
|
PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}},
|
||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
ProtocolName: "mkcp",
|
ProtocolName: "mkcp",
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "mkcp",
|
ProtocolName: "mkcp",
|
||||||
Settings: serial.ToTypedMessage(&kcp.Config{
|
Settings: serial.ToTypedMessage(&kcp.Config{
|
||||||
ReadBuffer: &kcp.ReadBuffer{
|
ReadBuffer: &kcp.ReadBuffer{
|
||||||
Size: 512 * 1024,
|
Size: 512 * 1024,
|
||||||
},
|
},
|
||||||
@ -857,8 +857,8 @@ func TestVMessKCPLarge(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -885,11 +885,11 @@ func TestVMessKCPLarge(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
ProtocolName: "mkcp",
|
ProtocolName: "mkcp",
|
||||||
TransportSettings: []*internet.TransportConfig{
|
TransportSettings: []*internet.TransportConfig{
|
||||||
{
|
{
|
||||||
ProtocolName: "mkcp",
|
ProtocolName: "mkcp",
|
||||||
Settings: serial.ToTypedMessage(&kcp.Config{
|
Settings: serial.ToTypedMessage(&kcp.Config{
|
||||||
ReadBuffer: &kcp.ReadBuffer{
|
ReadBuffer: &kcp.ReadBuffer{
|
||||||
Size: 512 * 1024,
|
Size: 512 * 1024,
|
||||||
},
|
},
|
||||||
@ -984,8 +984,8 @@ func TestVMessGCMMux(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -1100,8 +1100,8 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -1111,8 +1111,8 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(udpDest.Address),
|
Address: net.NewIPOrDomain(udpDest.Address),
|
||||||
Port: uint32(udpDest.Port),
|
Port: uint32(udpDest.Port),
|
||||||
Networks: []net.Network{net.Network_UDP},
|
Networks: []net.Network{net.Network_UDP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -1224,8 +1224,8 @@ func TestVMessZero(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -1323,8 +1323,8 @@ func TestVMessGCMLengthAuth(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@ -1427,8 +1427,8 @@ func TestVMessGCMLengthAuthPlusNoTerminationSignal(t *testing.T) {
|
|||||||
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
||||||
}),
|
}),
|
||||||
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
||||||
Address: net.NewIPOrDomain(dest.Address),
|
Address: net.NewIPOrDomain(dest.Address),
|
||||||
Port: uint32(dest.Port),
|
Port: uint32(dest.Port),
|
||||||
Networks: []net.Network{net.Network_TCP},
|
Networks: []net.Network{net.Network_TCP},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -56,7 +56,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
|
|||||||
}
|
}
|
||||||
client := encoding.NewGRPCServiceClient(conn)
|
client := encoding.NewGRPCServiceClient(conn)
|
||||||
if grpcSettings.MultiMode {
|
if grpcSettings.MultiMode {
|
||||||
errors.LogDebug(ctx, "using gRPC multi mode service name: `" + grpcSettings.getServiceName() + "` stream name: `" + grpcSettings.getTunMultiStreamName() + "`")
|
errors.LogDebug(ctx, "using gRPC multi mode service name: `"+grpcSettings.getServiceName()+"` stream name: `"+grpcSettings.getTunMultiStreamName()+"`")
|
||||||
grpcService, err := client.(encoding.GRPCServiceClientX).TunMultiCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunMultiStreamName())
|
grpcService, err := client.(encoding.GRPCServiceClientX).TunMultiCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunMultiStreamName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("Cannot dial gRPC").Base(err)
|
return nil, errors.New("Cannot dial gRPC").Base(err)
|
||||||
@ -64,7 +64,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
|
|||||||
return encoding.NewMultiHunkConn(grpcService, nil), nil
|
return encoding.NewMultiHunkConn(grpcService, nil), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
errors.LogDebug(ctx, "using gRPC tun mode service name: `" + grpcSettings.getServiceName() + "` stream name: `" + grpcSettings.getTunStreamName() + "`")
|
errors.LogDebug(ctx, "using gRPC tun mode service name: `"+grpcSettings.getServiceName()+"` stream name: `"+grpcSettings.getTunStreamName()+"`")
|
||||||
grpcService, err := client.(encoding.GRPCServiceClientX).TunCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunStreamName())
|
grpcService, err := client.(encoding.GRPCServiceClientX).TunCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunStreamName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("Cannot dial gRPC").Base(err)
|
return nil, errors.New("Cannot dial gRPC").Base(err)
|
||||||
|
@ -120,7 +120,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errors.LogDebug(ctx, "gRPC listen for service name `" + grpcSettings.getServiceName() + "` tun `" + grpcSettings.getTunStreamName() + "` multi tun `" + grpcSettings.getTunMultiStreamName() + "`")
|
errors.LogDebug(ctx, "gRPC listen for service name `"+grpcSettings.getServiceName()+"` tun `"+grpcSettings.getTunStreamName()+"` multi tun `"+grpcSettings.getTunMultiStreamName()+"`")
|
||||||
encoding.RegisterGRPCServiceServerX(s, listener, grpcSettings.getServiceName(), grpcSettings.getTunStreamName(), grpcSettings.getTunMultiStreamName())
|
encoding.RegisterGRPCServiceServerX(s, listener, grpcSettings.getServiceName(), grpcSettings.getTunStreamName(), grpcSettings.getTunMultiStreamName())
|
||||||
|
|
||||||
if config := reality.ConfigFromStreamSettings(settings); config != nil {
|
if config := reality.ConfigFromStreamSettings(settings); config != nil {
|
||||||
|
@ -103,7 +103,7 @@ func TestH3Connection(t *testing.T) {
|
|||||||
SecurityType: "tls",
|
SecurityType: "tls",
|
||||||
SecuritySettings: &tls.Config{
|
SecuritySettings: &tls.Config{
|
||||||
NextProtocol: []string{"h3"},
|
NextProtocol: []string{"h3"},
|
||||||
Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.example.com")))},
|
Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.example.com")))},
|
||||||
},
|
},
|
||||||
}, func(conn stat.Connection) {
|
}, func(conn stat.Connection) {
|
||||||
go func() {
|
go func() {
|
||||||
@ -133,7 +133,7 @@ func TestH3Connection(t *testing.T) {
|
|||||||
ProtocolSettings: &Config{},
|
ProtocolSettings: &Config{},
|
||||||
SecurityType: "tls",
|
SecurityType: "tls",
|
||||||
SecuritySettings: &tls.Config{
|
SecuritySettings: &tls.Config{
|
||||||
NextProtocol: []string{"h3"},
|
NextProtocol: []string{"h3"},
|
||||||
ServerName: "www.example.com",
|
ServerName: "www.example.com",
|
||||||
AllowInsecure: true,
|
AllowInsecure: true,
|
||||||
},
|
},
|
||||||
|
@ -141,8 +141,8 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||||||
isH3 := len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "h3"
|
isH3 := len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "h3"
|
||||||
listener := &Listener{
|
listener := &Listener{
|
||||||
handler: handler,
|
handler: handler,
|
||||||
config: httpSettings,
|
config: httpSettings,
|
||||||
isH3: isH3,
|
isH3: isH3,
|
||||||
}
|
}
|
||||||
if port == net.Port(0) { // unix
|
if port == net.Port(0) { // unix
|
||||||
listener.local = &net.UnixAddr{
|
listener.local = &net.UnixAddr{
|
||||||
@ -168,7 +168,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||||||
if isH3 {
|
if isH3 {
|
||||||
Conn, err := internet.ListenSystemPacket(context.Background(), listener.local, streamSettings.SocketSettings)
|
Conn, err := internet.ListenSystemPacket(context.Background(), listener.local, streamSettings.SocketSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err)
|
return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err)
|
||||||
}
|
}
|
||||||
h3listener, err := quic.ListenEarly(Conn, tlsConfig, nil)
|
h3listener, err := quic.ListenEarly(Conn, tlsConfig, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -188,7 +188,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||||||
var server *http.Server
|
var server *http.Server
|
||||||
if config == nil {
|
if config == nil {
|
||||||
h2s := &http2.Server{}
|
h2s := &http2.Server{}
|
||||||
|
|
||||||
server = &http.Server{
|
server = &http.Server{
|
||||||
Addr: serial.Concat(address, ":", port),
|
Addr: serial.Concat(address, ":", port),
|
||||||
Handler: h2c.NewHandler(listener, h2s),
|
Handler: h2c.NewHandler(listener, h2s),
|
||||||
@ -202,7 +202,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||||||
ReadHeaderTimeout: time.Second * 4,
|
ReadHeaderTimeout: time.Second * 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.server = server
|
listener.server = server
|
||||||
go func() {
|
go func() {
|
||||||
var streamListener net.Listener
|
var streamListener net.Listener
|
||||||
@ -226,7 +226,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config == nil {
|
if config == nil {
|
||||||
if config := reality.ConfigFromStreamSettings(streamSettings); config != nil {
|
if config := reality.ConfigFromStreamSettings(streamSettings); config != nil {
|
||||||
streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig())
|
streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig())
|
||||||
@ -241,7 +241,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||||||
errors.LogInfoInner(ctx, err, "stopping serving TLS H2")
|
errors.LogInfoInner(ctx, err, "stopping serving TLS H2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
return listener, nil
|
return listener, nil
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package tls
|
package tls
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
@ -10,7 +11,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"bytes"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common/errors"
|
"github.com/xtls/xray-core/common/errors"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
@ -70,7 +70,7 @@ func (c *Config) BuildCertificates() []*tls.Certificate {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
index := len(certs) - 1
|
index := len(certs) - 1
|
||||||
setupOcspTicker(entry, func(isReloaded, isOcspstapling bool){
|
setupOcspTicker(entry, func(isReloaded, isOcspstapling bool) {
|
||||||
cert := certs[index]
|
cert := certs[index]
|
||||||
if isReloaded {
|
if isReloaded {
|
||||||
if newKeyPair := getX509KeyPair(); newKeyPair != nil {
|
if newKeyPair := getX509KeyPair(); newKeyPair != nil {
|
||||||
@ -162,7 +162,7 @@ func (c *Config) getCustomCA() []*Certificate {
|
|||||||
for _, certificate := range c.Certificate {
|
for _, certificate := range c.Certificate {
|
||||||
if certificate.Usage == Certificate_AUTHORITY_ISSUE {
|
if certificate.Usage == Certificate_AUTHORITY_ISSUE {
|
||||||
certs = append(certs, certificate)
|
certs = append(certs, certificate)
|
||||||
setupOcspTicker(certificate, func(isReloaded, isOcspstapling bool){ })
|
setupOcspTicker(certificate, func(isReloaded, isOcspstapling bool) {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return certs
|
return certs
|
||||||
|
@ -47,11 +47,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (p *pipe) Len() int32 {
|
func (p *pipe) Len() int32 {
|
||||||
data := p.data
|
data := p.data
|
||||||
if data == nil {
|
if data == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return data.Len()
|
return data.Len()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pipe) getState(forRead bool) error {
|
func (p *pipe) getState(forRead bool) error {
|
||||||
|
@ -20,7 +20,7 @@ func (w *Writer) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) Len() int32 {
|
func (w *Writer) Len() int32 {
|
||||||
return w.pipe.Len()
|
return w.pipe.Len()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interrupt implements common.Interruptible.
|
// Interrupt implements common.Interruptible.
|
||||||
|
Loading…
Reference in New Issue
Block a user