mirror of https://github.com/v2ray/v2ray-core
Merge branch 'master' of https://github.com/v2ray/v2ray-core
commit
81a147e540
|
@ -37,7 +37,7 @@ func (op *AddUserOperation) ApplyInbound(ctx context.Context, handler core.Inbou
|
||||||
}
|
}
|
||||||
um, ok := p.(proxy.UserManager)
|
um, ok := p.(proxy.UserManager)
|
||||||
if !ok {
|
if !ok {
|
||||||
return newError("proxy is not an UserManager")
|
return newError("proxy is not a UserManager")
|
||||||
}
|
}
|
||||||
return um.AddUser(ctx, op.User)
|
return um.AddUser(ctx, op.User)
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func (op *RemoveUserOperation) ApplyInbound(ctx context.Context, handler core.In
|
||||||
}
|
}
|
||||||
um, ok := p.(proxy.UserManager)
|
um, ok := p.(proxy.UserManager)
|
||||||
if !ok {
|
if !ok {
|
||||||
return newError("proxy is not an UserManager")
|
return newError("proxy is not a UserManager")
|
||||||
}
|
}
|
||||||
return um.RemoveUser(ctx, op.Email)
|
return um.RemoveUser(ctx, op.Email)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,13 @@ import (
|
||||||
"v2ray.com/core/common/serial"
|
"v2ray.com/core/common/serial"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChunkSizeDecoder is an utility class to decode size value from bytes.
|
// ChunkSizeDecoder is a utility class to decode size value from bytes.
|
||||||
type ChunkSizeDecoder interface {
|
type ChunkSizeDecoder interface {
|
||||||
SizeBytes() int
|
SizeBytes() int
|
||||||
Decode([]byte) (uint16, error)
|
Decode([]byte) (uint16, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChunkSizeEncoder is an utility class to encode size value into bytes.
|
// ChunkSizeEncoder is a utility class to encode size value into bytes.
|
||||||
type ChunkSizeEncoder interface {
|
type ChunkSizeEncoder interface {
|
||||||
SizeBytes() int
|
SizeBytes() int
|
||||||
Encode(uint16, []byte) []byte
|
Encode(uint16, []byte) []byte
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
// Account is an user identity used for authentication.
|
// Account is a user identity used for authentication.
|
||||||
type Account interface {
|
type Account interface {
|
||||||
Equals(Account) bool
|
Equals(Account) bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@ const (
|
||||||
userKey key = iota
|
userKey key = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContextWithUser returns a context combined with an User.
|
// ContextWithUser returns a context combined with a User.
|
||||||
func ContextWithUser(ctx context.Context, user *User) context.Context {
|
func ContextWithUser(ctx context.Context, user *User) context.Context {
|
||||||
return context.WithValue(ctx, userKey, user)
|
return context.WithValue(ctx, userKey, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserFromContext extracts an User from the given context, if any.
|
// UserFromContext extracts a User from the given context, if any.
|
||||||
func UserFromContext(ctx context.Context) *User {
|
func UserFromContext(ctx context.Context) *User {
|
||||||
v := ctx.Value(userKey)
|
v := ctx.Value(userKey)
|
||||||
if v == nil {
|
if v == nil {
|
||||||
|
|
|
@ -19,7 +19,7 @@ func DefaultIDHash(key []byte) hash.Hash {
|
||||||
return hmac.New(md5.New, key)
|
return hmac.New(md5.New, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The ID of en entity, in the form of an UUID.
|
// The ID of en entity, in the form of a UUID.
|
||||||
type ID struct {
|
type ID struct {
|
||||||
uuid uuid.UUID
|
uuid uuid.UUID
|
||||||
cmdKey [IDBytesLen]byte
|
cmdKey [IDBytesLen]byte
|
||||||
|
|
|
@ -7,12 +7,12 @@ func ByteToHexString(value byte) string {
|
||||||
return hex.EncodeToString([]byte{value})
|
return hex.EncodeToString([]byte{value})
|
||||||
}
|
}
|
||||||
|
|
||||||
// BytesToUint16 deserializes a byte array to an uint16 in big endian order. The byte array must have at least 2 elements.
|
// BytesToUint16 deserializes a byte array to a uint16 in big endian order. The byte array must have at least 2 elements.
|
||||||
func BytesToUint16(value []byte) uint16 {
|
func BytesToUint16(value []byte) uint16 {
|
||||||
return uint16(value[0])<<8 | uint16(value[1])
|
return uint16(value[0])<<8 | uint16(value[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
// BytesToUint32 deserializes a byte array to an uint32 in big endian order. The byte array must have at least 4 elements.
|
// BytesToUint32 deserializes a byte array to a uint32 in big endian order. The byte array must have at least 4 elements.
|
||||||
func BytesToUint32(value []byte) uint32 {
|
func BytesToUint32(value []byte) uint32 {
|
||||||
return uint32(value[0])<<24 |
|
return uint32(value[0])<<24 |
|
||||||
uint32(value[1])<<16 |
|
uint32(value[1])<<16 |
|
||||||
|
|
|
@ -3,7 +3,7 @@ package serial
|
||||||
import "strconv"
|
import "strconv"
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
// Uint16ToBytes serializes an uint16 into bytes in big endian order.
|
// Uint16ToBytes serializes a uint16 into bytes in big endian order.
|
||||||
func Uint16ToBytes(value uint16, b []byte) []byte {
|
func Uint16ToBytes(value uint16, b []byte) []byte {
|
||||||
return append(b, byte(value>>8), byte(value))
|
return append(b, byte(value>>8), byte(value))
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Done is an utility for notifications of something being done.
|
// Done is a utility for notifications of something being done.
|
||||||
type Done struct {
|
type Done struct {
|
||||||
access sync.Mutex
|
access sync.Mutex
|
||||||
c chan struct{}
|
c chan struct{}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package signal
|
package signal
|
||||||
|
|
||||||
// Notifier is an utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asynchronously.
|
// Notifier is a utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asynchronously.
|
||||||
type Notifier struct {
|
type Notifier struct {
|
||||||
c chan struct{}
|
c chan struct{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,14 +61,14 @@ func (u *UUID) Next() UUID {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates an UUID with random value.
|
// New creates a UUID with random value.
|
||||||
func New() UUID {
|
func New() UUID {
|
||||||
var uuid UUID
|
var uuid UUID
|
||||||
common.Must2(rand.Read(uuid.Bytes()))
|
common.Must2(rand.Read(uuid.Bytes()))
|
||||||
return uuid
|
return uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseBytes converts an UUID in byte form to object.
|
// ParseBytes converts a UUID in byte form to object.
|
||||||
func ParseBytes(b []byte) (UUID, error) {
|
func ParseBytes(b []byte) (UUID, error) {
|
||||||
var uuid UUID
|
var uuid UUID
|
||||||
if len(b) != 16 {
|
if len(b) != 16 {
|
||||||
|
@ -78,7 +78,7 @@ func ParseBytes(b []byte) (UUID, error) {
|
||||||
return uuid, nil
|
return uuid, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseString converts an UUID in string form to object.
|
// ParseString converts a UUID in string form to object.
|
||||||
func ParseString(str string) (UUID, error) {
|
func ParseString(str string) (UUID, error) {
|
||||||
var uuid UUID
|
var uuid UUID
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ type ConfigFormat struct {
|
||||||
Loader ConfigLoader
|
Loader ConfigLoader
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigLoader is an utility to load V2Ray config from external source.
|
// ConfigLoader is a utility to load V2Ray config from external source.
|
||||||
type ConfigLoader func(input io.Reader) (*Config, error)
|
type ConfigLoader func(input io.Reader) (*Config, error)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -19,7 +19,7 @@ var (
|
||||||
version = "3.16"
|
version = "3.16"
|
||||||
build = "Custom"
|
build = "Custom"
|
||||||
codename = "die Commanderin"
|
codename = "die Commanderin"
|
||||||
intro = "An unified platform for anti-censorship."
|
intro = "A unified platform for anti-censorship."
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version returns V2Ray's version as a string, in the form of "x.y.z" where x, y and z are numbers.
|
// Version returns V2Ray's version as a string, in the form of "x.y.z" where x, y and z are numbers.
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"v2ray.com/core/transport/internet"
|
"v2ray.com/core/transport/internet"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server is a HTTP proxy server.
|
// Server is an HTTP proxy server.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
config *ServerConfig
|
config *ServerConfig
|
||||||
v *core.Instance
|
v *core.Instance
|
||||||
|
|
|
@ -41,7 +41,7 @@ type UserManager interface {
|
||||||
// AddUser adds a new user.
|
// AddUser adds a new user.
|
||||||
AddUser(context.Context, *protocol.User) error
|
AddUser(context.Context, *protocol.User) error
|
||||||
|
|
||||||
// RemoveUser removes an user by email.
|
// RemoveUser removes a user by email.
|
||||||
RemoveUser(context.Context, string) error
|
RemoveUser(context.Context, string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ var _ = math.Inf
|
||||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type Account struct {
|
type Account struct {
|
||||||
// ID of the account, in the form of an UUID, e.g., "66ad4540-b58c-4ad2-9926-ea63445a9b57".
|
// ID of the account, in the form of a UUID, e.g., "66ad4540-b58c-4ad2-9926-ea63445a9b57".
|
||||||
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
||||||
// Number of alternative IDs. Client and server must share the same number.
|
// Number of alternative IDs. Client and server must share the same number.
|
||||||
AlterId uint32 `protobuf:"varint,2,opt,name=alter_id,json=alterId" json:"alter_id,omitempty"`
|
AlterId uint32 `protobuf:"varint,2,opt,name=alter_id,json=alterId" json:"alter_id,omitempty"`
|
||||||
|
|
|
@ -9,7 +9,7 @@ option java_multiple_files = true;
|
||||||
import "v2ray.com/core/common/protocol/headers.proto";
|
import "v2ray.com/core/common/protocol/headers.proto";
|
||||||
|
|
||||||
message Account {
|
message Account {
|
||||||
// ID of the account, in the form of an UUID, e.g., "66ad4540-b58c-4ad2-9926-ea63445a9b57".
|
// ID of the account, in the form of a UUID, e.g., "66ad4540-b58c-4ad2-9926-ea63445a9b57".
|
||||||
string id = 1;
|
string id = 1;
|
||||||
// Number of alternative IDs. Client and server must share the same number.
|
// Number of alternative IDs. Client and server must share the same number.
|
||||||
uint32 alter_id = 2;
|
uint32 alter_id = 2;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
type Command byte
|
type Command byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// CommandACK indicates a AckSegment.
|
// CommandACK indicates an AckSegment.
|
||||||
CommandACK Command = 0
|
CommandACK Command = 0
|
||||||
// CommandData indicates a DataSegment.
|
// CommandData indicates a DataSegment.
|
||||||
CommandData Command = 1
|
CommandData Command = 1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*Package websocket implements Websocket transport
|
/*Package websocket implements Websocket transport
|
||||||
|
|
||||||
Websocket transport implements a HTTP(S) compliable, surveillance proof transport method with plausible deniability.
|
Websocket transport implements an HTTP(S) compliable, surveillance proof transport method with plausible deniability.
|
||||||
*/
|
*/
|
||||||
package websocket
|
package websocket
|
||||||
|
|
||||||
|
|
2
v2ray.go
2
v2ray.go
|
@ -94,7 +94,7 @@ func (s *Instance) CreateObject(config interface{}) (interface{}, error) {
|
||||||
return common.CreateObject(ctx, config)
|
return common.CreateObject(ctx, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID returns an unique ID for this V2Ray instance.
|
// ID returns a unique ID for this V2Ray instance.
|
||||||
func (s *Instance) ID() uuid.UUID {
|
func (s *Instance) ID() uuid.UUID {
|
||||||
return s.id
|
return s.id
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue