Darien Raymond 7 tahun lalu
induk
melakukan
484bdeecc9
4 mengubah file dengan 8 tambahan dan 0 penghapusan
  1. 2 0
      app/policy/config.go
  2. 2 0
      app/policy/manager/manager.go
  3. 2 0
      app/space.go
  4. 2 0
      proxy/shadowsocks/protocol.go

+ 2 - 0
app/policy/config.go

@@ -4,10 +4,12 @@ import (
 	"time"
 )
 
+// Duration converts Second to time.Duration.
 func (s *Second) Duration() time.Duration {
 	return time.Second * time.Duration(s.Value)
 }
 
+// OverrideWith overrides current Policy with another one.
 func (p *Policy) OverrideWith(another *Policy) {
 	if another.Timeout != nil {
 		if another.Timeout.Handshake != nil {

+ 2 - 0
app/policy/manager/manager.go

@@ -7,10 +7,12 @@ import (
 	"v2ray.com/core/common"
 )
 
+// Instance is an instance of Policy manager.
 type Instance struct {
 	levels map[uint32]*policy.Policy
 }
 
+// New creates new Policy manager instance.
 func New(ctx context.Context, config *policy.Config) (*Instance, error) {
 	levels := config.Level
 	if levels == nil {

+ 2 - 0
app/space.go

@@ -8,12 +8,14 @@ import (
 	"v2ray.com/core/common/event"
 )
 
+// Application is a component that runs in Space.
 type Application interface {
 	Interface() interface{}
 	Start() error
 	Close()
 }
 
+// CreateAppFromConfig creates an Application based on its config. Application must have been registered.
 func CreateAppFromConfig(ctx context.Context, config interface{}) (Application, error) {
 	application, err := common.CreateObject(ctx, config)
 	if err != nil {

+ 2 - 0
proxy/shadowsocks/protocol.go

@@ -22,6 +22,7 @@ const (
 	AddrTypeDomain = 3
 )
 
+// ReadTCPSession reads a Shadowsocks TCP session from the given reader, returns its header and remaining parts.
 func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHeader, buf.Reader, error) {
 	rawAccount, err := user.GetTypedAccount()
 	if err != nil {
@@ -136,6 +137,7 @@ func ReadTCPSession(user *protocol.User, reader io.Reader) (*protocol.RequestHea
 	return request, chunkReader, nil
 }
 
+// WriteTCPRequest writes Shadowsocks request into the given writer, and returns a writer for body.
 func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error) {
 	user := request.User
 	rawAccount, err := user.GetTypedAccount()