From a6d81cc56dcc338ce628576192da11cf320403d1 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 3 Dec 2018 23:39:21 +0100 Subject: [PATCH] api doc --- common/bytespool/pool.go | 6 ++++++ transport/internet/system_listener.go | 2 ++ transport/internet/tcp_hub.go | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/common/bytespool/pool.go b/common/bytespool/pool.go index b8ab3d7d1..24542ffa8 100644 --- a/common/bytespool/pool.go +++ b/common/bytespool/pool.go @@ -35,6 +35,8 @@ func init() { // GetPool returns a sync.Pool that generates bytes array with at least the given size. // It may return nil if no such pool exists. +// +// v2ray:api:stable func GetPool(size int32) *sync.Pool { for idx, ps := range poolSize { if size <= ps { @@ -45,6 +47,8 @@ func GetPool(size int32) *sync.Pool { } // Alloc returns a byte slice with at least the given size. Minimum size of returned slice is 2048. +// +// v2ray:api:stable func Alloc(size int32) []byte { pool := GetPool(size) if pool != nil { @@ -54,6 +58,8 @@ func Alloc(size int32) []byte { } // Free puts a byte slice into the internal pool. +// +// v2ray:api:stable func Free(b []byte) { size := int32(cap(b)) b = b[0:cap(b)] diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index 26e42dae4..3ab8d3a84 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -58,6 +58,8 @@ func (dl *DefaultListener) ListenPacket(ctx context.Context, addr net.Addr, sock // RegisterListenerController adds a controller to the effective system listener. // The controller can be used to operate on file descriptors before they are put into use. +// +// v2ray:api:beta func RegisterListenerController(controller func(network, address string, fd uintptr) error) error { if controller == nil { return newError("nil listener controller") diff --git a/transport/internet/tcp_hub.go b/transport/internet/tcp_hub.go index 888dec824..16e8a487c 100644 --- a/transport/internet/tcp_hub.go +++ b/transport/internet/tcp_hub.go @@ -52,10 +52,16 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, settings return listener, nil } +// ListenSystem listens on a local address for incoming TCP connections. +// +// v2ray:api:beta func ListenSystem(ctx context.Context, addr net.Addr, sockopt *SocketConfig) (net.Listener, error) { return effectiveListener.Listen(ctx, addr, sockopt) } +// ListenSystemPacket listens on a local address for incoming UDP connections. +// +// v2ray:api:beta func ListenSystemPacket(ctx context.Context, addr net.Addr, sockopt *SocketConfig) (net.PacketConn, error) { return effectiveListener.ListenPacket(ctx, addr, sockopt) }