1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

more comments

This commit is contained in:
V2 Ray 2015-10-15 11:15:59 +00:00
parent a84c03d5db
commit 9071b3ea10
5 changed files with 16 additions and 0 deletions

View File

@ -5,6 +5,8 @@ import (
"github.com/v2ray/v2ray-core/transport/ray" "github.com/v2ray/v2ray-core/transport/ray"
) )
// PacketDispatcher dispatch a packet and possibly further network payload to
// its destination.
type PacketDispatcher interface { type PacketDispatcher interface {
DispatchToOutbound(packet v2net.Packet) ray.InboundRay DispatchToOutbound(packet v2net.Packet) ray.InboundRay
} }

View File

@ -76,18 +76,22 @@ func SetLogLevel(level LogLevel) {
} }
} }
// Debug outputs a debug log with given format and optional arguments.
func Debug(format string, v ...interface{}) { func Debug(format string, v ...interface{}) {
debugLogger.WriteLog("[Debug]", format, v...) debugLogger.WriteLog("[Debug]", format, v...)
} }
// Info outputs an info log with given format and optional arguments.
func Info(format string, v ...interface{}) { func Info(format string, v ...interface{}) {
infoLogger.WriteLog("[Info]", format, v...) infoLogger.WriteLog("[Info]", format, v...)
} }
// Warning outputs a warning log with given format and optional arguments.
func Warning(format string, v ...interface{}) { func Warning(format string, v ...interface{}) {
warningLogger.WriteLog("[Warning]", format, v...) warningLogger.WriteLog("[Warning]", format, v...)
} }
// Error outputs an error log with given format and optional arguments.
func Error(format string, v ...interface{}) { func Error(format string, v ...interface{}) {
errorLogger.WriteLog("[Error]", format, v...) errorLogger.WriteLog("[Error]", format, v...)
} }

View File

@ -4,10 +4,15 @@ import (
"github.com/v2ray/v2ray-core/app" "github.com/v2ray/v2ray-core/app"
) )
// A InboundConnectionHandlerFactory creates InboundConnectionHandler on demand.
type InboundConnectionHandlerFactory interface { type InboundConnectionHandlerFactory interface {
// Create creates a new InboundConnectionHandler with given configuration.
Create(dispatch app.PacketDispatcher, config interface{}) (InboundConnectionHandler, error) Create(dispatch app.PacketDispatcher, config interface{}) (InboundConnectionHandler, error)
} }
// A InboundConnectionHandler handles inbound network connections to V2Ray.
type InboundConnectionHandler interface { type InboundConnectionHandler interface {
// Listen starts a InboundConnectionHandler by listen on a specific port. This method is called
// exactly once during runtime.
Listen(port uint16) error Listen(port uint16) error
} }

View File

@ -5,10 +5,14 @@ import (
"github.com/v2ray/v2ray-core/transport/ray" "github.com/v2ray/v2ray-core/transport/ray"
) )
// An OutboundConnectionHandlerFactory creates OutboundConnectionHandler on demand.
type OutboundConnectionHandlerFactory interface { type OutboundConnectionHandlerFactory interface {
// Create creates a new OutboundConnectionHandler with given config.
Create(config interface{}) (OutboundConnectionHandler, error) Create(config interface{}) (OutboundConnectionHandler, error)
} }
// An OutboundConnectionHandler handles outbound network connection for V2Ray.
type OutboundConnectionHandler interface { type OutboundConnectionHandler interface {
// Dispatch sends one or more Packets to its destination.
Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error
} }

View File

@ -8,6 +8,7 @@ const (
bufferSize = 16 bufferSize = 16
) )
// NewRay creates a new Ray for direct traffic transport.
func NewRay() Ray { func NewRay() Ray {
return &directRay{ return &directRay{
Input: make(chan *alloc.Buffer, bufferSize), Input: make(chan *alloc.Buffer, bufferSize),