mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 17:46:58 -05:00
comments
This commit is contained in:
parent
6797483fe0
commit
484bdeecc9
@ -4,10 +4,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Duration converts Second to time.Duration.
|
||||||
func (s *Second) Duration() time.Duration {
|
func (s *Second) Duration() time.Duration {
|
||||||
return time.Second * time.Duration(s.Value)
|
return time.Second * time.Duration(s.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OverrideWith overrides current Policy with another one.
|
||||||
func (p *Policy) OverrideWith(another *Policy) {
|
func (p *Policy) OverrideWith(another *Policy) {
|
||||||
if another.Timeout != nil {
|
if another.Timeout != nil {
|
||||||
if another.Timeout.Handshake != nil {
|
if another.Timeout.Handshake != nil {
|
||||||
|
@ -7,10 +7,12 @@ import (
|
|||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Instance is an instance of Policy manager.
|
||||||
type Instance struct {
|
type Instance struct {
|
||||||
levels map[uint32]*policy.Policy
|
levels map[uint32]*policy.Policy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates new Policy manager instance.
|
||||||
func New(ctx context.Context, config *policy.Config) (*Instance, error) {
|
func New(ctx context.Context, config *policy.Config) (*Instance, error) {
|
||||||
levels := config.Level
|
levels := config.Level
|
||||||
if levels == nil {
|
if levels == nil {
|
||||||
|
@ -8,12 +8,14 @@ import (
|
|||||||
"v2ray.com/core/common/event"
|
"v2ray.com/core/common/event"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Application is a component that runs in Space.
|
||||||
type Application interface {
|
type Application interface {
|
||||||
Interface() interface{}
|
Interface() interface{}
|
||||||
Start() error
|
Start() error
|
||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateAppFromConfig creates an Application based on its config. Application must have been registered.
|
||||||
func CreateAppFromConfig(ctx context.Context, config interface{}) (Application, error) {
|
func CreateAppFromConfig(ctx context.Context, config interface{}) (Application, error) {
|
||||||
application, err := common.CreateObject(ctx, config)
|
application, err := common.CreateObject(ctx, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -22,6 +22,7 @@ const (
|
|||||||
AddrTypeDomain = 3
|
AddrTypeDomain = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ReadTCPSession reads a Shadowsocks TCP session from the given reader, returns its header and remaining parts.
|
||||||
func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHeader, buf.Reader, error) {
|
func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHeader, buf.Reader, error) {
|
||||||
rawAccount, err := user.GetTypedAccount()
|
rawAccount, err := user.GetTypedAccount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -136,6 +137,7 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
|
|||||||
return request, chunkReader, nil
|
return request, chunkReader, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteTCPRequest writes Shadowsocks request into the given writer, and returns a writer for body.
|
||||||
func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error) {
|
func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error) {
|
||||||
user := request.User
|
user := request.User
|
||||||
rawAccount, err := user.GetTypedAccount()
|
rawAccount, err := user.GetTypedAccount()
|
||||||
|
Loading…
Reference in New Issue
Block a user