From 306ae93503e84c46e47610d657eebab9388e4970 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Mon, 7 Sep 2015 12:00:46 +0200 Subject: [PATCH] documentation --- core.go | 2 ++ io/vmessreader.go | 1 + vconfig.go | 21 +++++++++++++++++---- vid.go | 1 + vpoint.go | 7 ++++++- 5 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 core.go diff --git a/core.go b/core.go new file mode 100644 index 00000000..9ad48eae --- /dev/null +++ b/core.go @@ -0,0 +1,2 @@ +// Package core provides common definitions and functionalities of V2Ray. +package core diff --git a/io/vmessreader.go b/io/vmessreader.go index 74ab0c2f..5a7744c1 100644 --- a/io/vmessreader.go +++ b/io/vmessreader.go @@ -4,6 +4,7 @@ import ( "net" ) +// VMessInput implements the input message of VMess protocol. type VMessInput struct { version byte userHash [16]byte diff --git a/vconfig.go b/vconfig.go index 29ff3b28..6d3bac66 100644 --- a/vconfig.go +++ b/vconfig.go @@ -1,14 +1,27 @@ package core +// User account that is used for connection to a VPoint type VUser struct { + // The ID of this VUser. This ID is served as an access token. + // It is not necessary to be permanent. id VID } +// The next VPoint server in the connection chain. +type VNext struct { + // Address of VNext server, in the form of "IP:Port" + ServerAddress string + // User accounts for accessing VNext. + User []VUser +} + +// The config for VPoint server. type VConfig struct { - RunAs VUser - Port uint16 - AllowedClients []VUser - AllowedProtocol string + // Port of this VPoint server. + Port uint16 + AllowedClients []VUser + ClientProtocol string + VNextList []VNext } type VConfigMarshaller interface { diff --git a/vid.go b/vid.go index d82b422a..29ca2042 100644 --- a/vid.go +++ b/vid.go @@ -5,6 +5,7 @@ import ( "fmt" ) +// The ID of en entity, in the form of an UUID. type VID [16]byte var byteGroups = []int{8, 4, 4, 4, 12} diff --git a/vpoint.go b/vpoint.go index b0b0f94d..b0c97c02 100644 --- a/vpoint.go +++ b/vpoint.go @@ -9,8 +9,11 @@ type VPoint struct { connHandler ConnectionHandler } +// NewVPoint returns a new VPoint server based on given configuration. +// The server is not started at this point. func NewVPoint(config *VConfig) (*VPoint, error) { - var vpoint *VPoint + var vpoint = new(VPoint) + vpoint.config = *config return vpoint, nil } @@ -18,6 +21,8 @@ type ConnectionHandler interface { Listen(port uint16) error } +// Start starts the VPoint server, and return any error during the process. +// In the case of any errors, the state of the server is unpredicatable. func (vp *VPoint) Start() error { if vp.config.Port <= 0 { return fmt.Errorf("Invalid port %d", vp.config.Port)