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
// Package proxy contains all proxies used by V2Ray.
//
// To implement an inbound or outbound proxy, one needs to do the following:
// 1. Implement the interface(s) below.
// 2. Register a config creator through common.RegisterConfig.
package proxy
 
import (
    "context"
    "time"
 
    "github.com/v2fly/v2ray-core/v5/common/net"
    "github.com/v2fly/v2ray-core/v5/common/protocol"
    "github.com/v2fly/v2ray-core/v5/features/routing"
    "github.com/v2fly/v2ray-core/v5/transport"
    "github.com/v2fly/v2ray-core/v5/transport/internet"
)
 
// A timeout for reading the first payload from the client, used in 0-RTT optimizations.
const FirstPayloadTimeout = 100 * time.Millisecond
 
// An Inbound processes inbound connections.
type Inbound interface {
    // Network returns a list of networks that this inbound supports. Connections with not-supported networks will not be passed into Process().
    Network() []net.Network
 
    // Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound.
    Process(context.Context, net.Network, internet.Connection, routing.Dispatcher) error
}
 
// An Outbound process outbound connections.
type Outbound interface {
    // Process processes the given connection. The given dialer may be used to dial a system outbound connection.
    Process(context.Context, *transport.Link, internet.Dialer) error
}
 
// UserManager is the interface for Inbounds and Outbounds that can manage their users.
type UserManager interface {
    // AddUser adds a new user.
    AddUser(context.Context, *protocol.MemoryUser) error
 
    // RemoveUser removes a user by email.
    RemoveUser(context.Context, string) error
}
 
type GetInbound interface {
    GetInbound() Inbound
}
 
type GetOutbound interface {
    GetOutbound() Outbound
}