Darien Raymond 7 năm trước cách đây
mục cha
commit
a3f47f4fa2

+ 2 - 0
app/commander/commander.go

@@ -13,6 +13,7 @@ import (
 	"v2ray.com/core/common/signal"
 )
 
+// Commander is a V2Ray feature that provides gRPC methods to external clients.
 type Commander struct {
 	sync.Mutex
 	server *grpc.Server
@@ -21,6 +22,7 @@ type Commander struct {
 	ohm    core.OutboundHandlerManager
 }
 
+// NewCommander creates a new Commander based on the given config.
 func NewCommander(ctx context.Context, config *Config) (*Commander, error) {
 	v := core.MustFromContext(ctx)
 	c := &Commander{

+ 5 - 0
app/commander/outbound.go

@@ -54,6 +54,7 @@ func (l *OutboundListener) Addr() net.Addr {
 	}
 }
 
+// CommanderOutbound is a core.OutboundHandler that handles gRPC connections.
 type CommanderOutbound struct {
 	tag      string
 	listener *OutboundListener
@@ -61,6 +62,7 @@ type CommanderOutbound struct {
 	closed   bool
 }
 
+// Dispatch implements core.OutboundHandler.
 func (co *CommanderOutbound) Dispatch(ctx context.Context, r ray.OutboundRay) {
 	co.access.RLock()
 
@@ -78,10 +80,12 @@ func (co *CommanderOutbound) Dispatch(ctx context.Context, r ray.OutboundRay) {
 	<-closeSignal.Wait()
 }
 
+// Tag implements core.OutboundHandler.
 func (co *CommanderOutbound) Tag() string {
 	return co.tag
 }
 
+// Start implements common.Runnable.
 func (co *CommanderOutbound) Start() error {
 	co.access.Lock()
 	co.closed = false
@@ -89,6 +93,7 @@ func (co *CommanderOutbound) Start() error {
 	return nil
 }
 
+// Close implements common.Closable.
 func (co *CommanderOutbound) Close() error {
 	co.access.Lock()
 	co.closed = true

+ 2 - 0
app/commander/service.go

@@ -4,6 +4,8 @@ import (
 	"google.golang.org/grpc"
 )
 
+// Service is a Commander service.
 type Service interface {
+	// Register registers the service itself to a gRPC server.
 	Register(*grpc.Server)
 }

+ 1 - 0
app/policy/config.go

@@ -52,6 +52,7 @@ func (p *Policy) overrideWith(another *Policy) {
 	}
 }
 
+// ToCorePolicy converts this Policy to core.Policy.
 func (p *Policy) ToCorePolicy() core.Policy {
 	var cp core.Policy
 	if p.Timeout != nil {

+ 5 - 1
app/proxyman/inbound/inbound.go

@@ -50,7 +50,7 @@ func (m *Manager) AddHandler(ctx context.Context, handler core.InboundHandler) e
 	return nil
 }
 
-// GetHandler returns core.InboundHandlerManager.
+// GetHandler implements core.InboundHandlerManager.
 func (m *Manager) GetHandler(ctx context.Context, tag string) (core.InboundHandler, error) {
 	m.access.RLock()
 	defer m.access.RUnlock()
@@ -62,6 +62,7 @@ func (m *Manager) GetHandler(ctx context.Context, tag string) (core.InboundHandl
 	return handler, nil
 }
 
+// RemoveHandler implements core.InboundHandlerManager.
 func (m *Manager) RemoveHandler(ctx context.Context, tag string) error {
 	if len(tag) == 0 {
 		return core.ErrNoClue
@@ -79,6 +80,7 @@ func (m *Manager) RemoveHandler(ctx context.Context, tag string) error {
 	return core.ErrNoClue
 }
 
+// Start implements common.Runnable.
 func (m *Manager) Start() error {
 	m.access.Lock()
 	defer m.access.Unlock()
@@ -99,6 +101,7 @@ func (m *Manager) Start() error {
 	return nil
 }
 
+// Close implements common.Closable.
 func (m *Manager) Close() error {
 	m.access.Lock()
 	defer m.access.Unlock()
@@ -115,6 +118,7 @@ func (m *Manager) Close() error {
 	return nil
 }
 
+// NewHandler creates a new core.InboundHandler based on the given config.
 func NewHandler(ctx context.Context, config *core.InboundHandlerConfig) (core.InboundHandler, error) {
 	rawReceiverSettings, err := config.ReceiverSettings.GetInstance()
 	if err != nil {

+ 4 - 1
policy.go

@@ -19,8 +19,11 @@ type TimeoutPolicy struct {
 	DownlinkOnly time.Duration
 }
 
+// StatsPolicy contains settings for stats counters.
 type StatsPolicy struct {
-	UserUplink   bool
+	// Whether or not to enable stat counter for user uplink traffic.
+	UserUplink bool
+	// Whether or not to enable stat counter for user downlink traffic.
 	UserDownlink bool
 }
 

+ 1 - 0
v2ray.go

@@ -211,6 +211,7 @@ func (s *Instance) OutboundHandlerManager() OutboundHandlerManager {
 	return &(s.ohm)
 }
 
+// Stats returns the StatManager used by this Instance. If StatManager was not registered before, the returned value doesn't work.
 func (s *Instance) Stats() StatManager {
 	return &(s.stats)
 }