mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 00:21:29 +00:00
parent
800b3bd3fe
commit
9ad26fa049
|
@ -58,7 +58,7 @@ type Handler struct {
|
||||||
downlinkCounter stats.Counter
|
downlinkCounter stats.Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHandler create a new Handler based on the given configuration.
|
// NewHandler creates a new Handler based on the given configuration.
|
||||||
func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbound.Handler, error) {
|
func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbound.Handler, error) {
|
||||||
v := core.MustFromContext(ctx)
|
v := core.MustFromContext(ctx)
|
||||||
uplinkCounter, downlinkCounter := getStatCounter(v, config.Tag)
|
uplinkCounter, downlinkCounter := getStatCounter(v, config.Tag)
|
||||||
|
|
|
@ -122,7 +122,7 @@ func (*Router) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type implement common.HasType.
|
// Type implements common.HasType.
|
||||||
func (*Router) Type() interface{} {
|
func (*Router) Type() interface{} {
|
||||||
return routing.RouterType()
|
return routing.RouterType()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
const replayFilterCapacity = 100000
|
const replayFilterCapacity = 100000
|
||||||
|
|
||||||
// ReplayFilter check for replay attacks.
|
// ReplayFilter checks for replay attacks.
|
||||||
type ReplayFilter struct {
|
type ReplayFilter struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
poolA *cuckoo.Filter
|
poolA *cuckoo.Filter
|
||||||
|
@ -31,7 +31,7 @@ func (filter *ReplayFilter) Interval() int64 {
|
||||||
return filter.interval
|
return filter.interval
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check determine if there are duplicate records.
|
// Check determines if there are duplicate records.
|
||||||
func (filter *ReplayFilter) Check(sum []byte) bool {
|
func (filter *ReplayFilter) Check(sum []byte) bool {
|
||||||
filter.lock.Lock()
|
filter.lock.Lock()
|
||||||
defer filter.lock.Unlock()
|
defer filter.lock.Unlock()
|
||||||
|
|
|
@ -53,7 +53,7 @@ func MergeBytes(dest MultiBuffer, src []byte) MultiBuffer {
|
||||||
return dest
|
return dest
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseMulti release all content of the MultiBuffer, and returns an empty MultiBuffer.
|
// ReleaseMulti releases all content of the MultiBuffer, and returns an empty MultiBuffer.
|
||||||
func ReleaseMulti(mb MultiBuffer) MultiBuffer {
|
func ReleaseMulti(mb MultiBuffer) MultiBuffer {
|
||||||
for i := range mb {
|
for i := range mb {
|
||||||
mb[i].Release()
|
mb[i].Release()
|
||||||
|
@ -235,7 +235,7 @@ func (mb MultiBuffer) Len() int32 {
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsEmpty return true if the MultiBuffer has no content.
|
// IsEmpty returns true if the MultiBuffer has no content.
|
||||||
func (mb MultiBuffer) IsEmpty() bool {
|
func (mb MultiBuffer) IsEmpty() bool {
|
||||||
for _, b := range mb {
|
for _, b := range mb {
|
||||||
if !b.IsEmpty() {
|
if !b.IsEmpty() {
|
||||||
|
@ -283,14 +283,14 @@ func (c *MultiBufferContainer) Write(b []byte) (int, error) {
|
||||||
return len(b), nil
|
return len(b), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteMultiBuffer implement Writer.
|
// WriteMultiBuffer implements Writer.
|
||||||
func (c *MultiBufferContainer) WriteMultiBuffer(b MultiBuffer) error {
|
func (c *MultiBufferContainer) WriteMultiBuffer(b MultiBuffer) error {
|
||||||
mb, _ := MergeMulti(c.MultiBuffer, b)
|
mb, _ := MergeMulti(c.MultiBuffer, b)
|
||||||
c.MultiBuffer = mb
|
c.MultiBuffer = mb
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close implement io.Closer.
|
// Close implements io.Closer.
|
||||||
func (c *MultiBufferContainer) Close() error {
|
func (c *MultiBufferContainer) Close() error {
|
||||||
c.MultiBuffer = ReleaseMulti(c.MultiBuffer)
|
c.MultiBuffer = ReleaseMulti(c.MultiBuffer)
|
||||||
return nil
|
return nil
|
||||||
|
|
2
common/cache/lru.go
vendored
2
common/cache/lru.go
vendored
|
@ -26,7 +26,7 @@ type lruElement struct {
|
||||||
value interface{}
|
value interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLru init a lru cache
|
// NewLru initializes a lru cache
|
||||||
func NewLru(cap int) Lru {
|
func NewLru(cap int) Lru {
|
||||||
return &lru{
|
return &lru{
|
||||||
capacity: cap,
|
capacity: cap,
|
||||||
|
|
|
@ -34,7 +34,7 @@ func Record(msg Message) {
|
||||||
|
|
||||||
var logHandler syncHandler
|
var logHandler syncHandler
|
||||||
|
|
||||||
// RegisterHandler register a new handler as current log handler. Previous registered handler will be discarded.
|
// RegisterHandler registers a new handler as current log handler. Previous registered handler will be discarded.
|
||||||
func RegisterHandler(handler Handler) {
|
func RegisterHandler(handler Handler) {
|
||||||
if handler == nil {
|
if handler == nil {
|
||||||
panic("Log handler is nil")
|
panic("Log handler is nil")
|
||||||
|
|
|
@ -22,7 +22,7 @@ func GetToolLocation(file string) string {
|
||||||
return filepath.Join(toolPath, file)
|
return filepath.Join(toolPath, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetLocation search for `file` in certain locations
|
// GetAssetLocation searches for `file` in certain locations
|
||||||
func GetAssetLocation(file string) string {
|
func GetAssetLocation(file string) string {
|
||||||
const name = "xray.location.asset"
|
const name = "xray.location.asset"
|
||||||
assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
|
assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
|
||||||
|
|
|
@ -20,7 +20,7 @@ func GetToolLocation(file string) string {
|
||||||
return filepath.Join(toolPath, file+".exe")
|
return filepath.Join(toolPath, file+".exe")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetLocation search for `file` in the excutable dir
|
// GetAssetLocation searches for `file` in the excutable dir
|
||||||
func GetAssetLocation(file string) string {
|
func GetAssetLocation(file string) string {
|
||||||
const name = "xray.location.asset"
|
const name = "xray.location.asset"
|
||||||
assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
|
assetPath := NewEnvFlag(name).GetValue(getExecutableDir)
|
||||||
|
|
|
@ -22,7 +22,7 @@ func ParseXForwardedFor(header http.Header) []net.Address {
|
||||||
return addrs
|
return addrs
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveHopByHopHeaders remove hop by hop headers in http header list.
|
// RemoveHopByHopHeaders removes hop by hop headers in http header list.
|
||||||
func RemoveHopByHopHeaders(header http.Header) {
|
func RemoveHopByHopHeaders(header http.Header) {
|
||||||
// Strip hop-by-hop header based on RFC:
|
// Strip hop-by-hop header based on RFC:
|
||||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.5.1
|
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.5.1
|
||||||
|
|
|
@ -17,7 +17,7 @@ type pkcs8 struct {
|
||||||
Version int
|
Version int
|
||||||
Algo pkix.AlgorithmIdentifier
|
Algo pkix.AlgorithmIdentifier
|
||||||
PrivateKey []byte
|
PrivateKey []byte
|
||||||
// optional attributes omitted.
|
// Optional attributes omitted.
|
||||||
}
|
}
|
||||||
|
|
||||||
type pkcs1AdditionalRSAPrime struct {
|
type pkcs1AdditionalRSAPrime struct {
|
||||||
|
|
Loading…
Reference in a new issue