1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-06-23 03:10:00 -04:00

Routing Context: Fix GetUser() & Use string for Attributes Value

This commit is contained in:
Vigilans
2020-09-13 00:34:35 +08:00
parent e8a27648a1
commit 5a497890e6
5 changed files with 16 additions and 19 deletions

View File

@@ -53,6 +53,7 @@ type Outbound struct {
Gateway net.Address
}
// SniffingRequest controls the behavior of content sniffing.
type SniffingRequest struct {
OverrideDestinationForProtocol []string
Enabled bool
@@ -65,7 +66,7 @@ type Content struct {
SniffingRequest SniffingRequest
Attributes map[string]interface{}
Attributes map[string]string
SkipRoutePick bool
}
@@ -76,16 +77,18 @@ type Sockopt struct {
Mark int32
}
func (c *Content) SetAttribute(name string, value interface{}) {
// SetAttribute attachs additional string attributes to content.
func (c *Content) SetAttribute(name string, value string) {
if c.Attributes == nil {
c.Attributes = make(map[string]interface{})
c.Attributes = make(map[string]string)
}
c.Attributes[name] = value
}
func (c *Content) Attribute(name string) interface{} {
// Attribute retrieves additional string attributes from content.
func (c *Content) Attribute(name string) string {
if c.Attributes == nil {
return nil
return ""
}
return c.Attributes[name]
}