mirror of
https://github.com/v2ray/v2ray-core.git
synced 2024-04-21 12:31:52 +00:00
Apply sockopt from inbound config to dokodemo tproxy's response connection
This commit is contained in:
@@ -10,6 +10,7 @@ const (
|
||||
outboundSessionKey
|
||||
contentSessionKey
|
||||
muxPreferedSessionKey
|
||||
sockoptSessionKey
|
||||
)
|
||||
|
||||
// ContextWithID returns a new context with the given ID.
|
||||
@@ -70,3 +71,16 @@ func MuxPreferedFromContext(ctx context.Context) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ContextWithSockopt returns a new context with Socket configs included
|
||||
func ContextWithSockopt(ctx context.Context, s *Sockopt) context.Context {
|
||||
return context.WithValue(ctx, sockoptSessionKey, s)
|
||||
}
|
||||
|
||||
// SockoptFromContext returns Socket configs in this context, or nil if not contained.
|
||||
func SockoptFromContext(ctx context.Context) *Sockopt {
|
||||
if sockopt, ok := ctx.Value(sockoptSessionKey).(*Sockopt); ok {
|
||||
return sockopt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -72,6 +72,12 @@ type Content struct {
|
||||
SkipRoutePick bool
|
||||
}
|
||||
|
||||
// Sockopt is the settings for socket connection.
|
||||
type Sockopt struct {
|
||||
// Mark of the socket connection.
|
||||
Mark int32
|
||||
}
|
||||
|
||||
func (c *Content) SetAttribute(name string, value interface{}) {
|
||||
if c.Attributes == nil {
|
||||
c.Attributes = make(map[string]interface{})
|
||||
|
||||
Reference in New Issue
Block a user