Add uid and app status in routing rule

This commit is contained in:
世界 2021-08-27 13:00:13 +08:00
parent 707efd6d12
commit 16d96aa54d
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
12 changed files with 429 additions and 133 deletions

View file

@ -40,4 +40,8 @@ type Context interface {
// GetSkipDNSResolve returns a flag switch for weather skip dns resolve during route pick.
GetSkipDNSResolve() bool
GetUid() uint32
GetAppStatus() []string
}

View file

@ -122,6 +122,21 @@ func (ctx *Context) GetSkipDNSResolve() bool {
return ctx.Content.SkipDNSResolve
}
// GetUid implements routing.Context.
func (ctx *Context) GetUid() uint32 {
if ctx.Inbound == nil {
return 0
}
return ctx.Inbound.Uid
}
func (ctx *Context) GetAppStatus() []string {
if ctx.Inbound == nil {
return nil
}
return ctx.Inbound.AppStatus
}
// AsRoutingContext creates a context from context.context with session info.
func AsRoutingContext(ctx context.Context) routing.Context {
return &Context{