Hunter0x7c7
2022-08-11 a82f9cb69f63aaeba40c024960deda7d75b9fece
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package routing
 
import (
    "github.com/v2fly/v2ray-core/v5/common"
    "github.com/v2fly/v2ray-core/v5/features"
)
 
// Router is a feature to choose an outbound tag for the given request.
//
// v2ray:api:stable
type Router interface {
    features.Feature
 
    // PickRoute returns a route decision based on the given routing context.
    PickRoute(ctx Context) (Route, error)
}
 
// Route is the routing result of Router feature.
//
// v2ray:api:stable
type Route interface {
    // A Route is also a routing context.
    Context
 
    // GetOutboundGroupTags returns the detoured outbound group tags in sequence before a final outbound is chosen.
    GetOutboundGroupTags() []string
 
    // GetOutboundTag returns the tag of the outbound the connection was dispatched to.
    GetOutboundTag() string
}
 
// RouterType return the type of Router interface. Can be used to implement common.HasType.
//
// v2ray:api:stable
func RouterType() interface{} {
    return (*Router)(nil)
}
 
// DefaultRouter is an implementation of Router, which always returns ErrNoClue for routing decisions.
type DefaultRouter struct{}
 
// Type implements common.HasType.
func (DefaultRouter) Type() interface{} {
    return RouterType()
}
 
// PickRoute implements Router.
func (DefaultRouter) PickRoute(ctx Context) (Route, error) {
    return nil, common.ErrNoClue
}
 
// Start implements common.Runnable.
func (DefaultRouter) Start() error {
    return nil
}
 
// Close implements common.Closable.
func (DefaultRouter) Close() error {
    return nil
}