1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

documentation

This commit is contained in:
V2Ray 2015-09-07 12:00:46 +02:00
parent b5a46dec8e
commit 306ae93503
5 changed files with 27 additions and 5 deletions

2
core.go Normal file
View File

@ -0,0 +1,2 @@
// Package core provides common definitions and functionalities of V2Ray.
package core

View File

@ -4,6 +4,7 @@ import (
"net" "net"
) )
// VMessInput implements the input message of VMess protocol.
type VMessInput struct { type VMessInput struct {
version byte version byte
userHash [16]byte userHash [16]byte

View File

@ -1,14 +1,27 @@
package core package core
// User account that is used for connection to a VPoint
type VUser struct { 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 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 { type VConfig struct {
RunAs VUser // Port of this VPoint server.
Port uint16 Port uint16
AllowedClients []VUser AllowedClients []VUser
AllowedProtocol string ClientProtocol string
VNextList []VNext
} }
type VConfigMarshaller interface { type VConfigMarshaller interface {

1
vid.go
View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
) )
// The ID of en entity, in the form of an UUID.
type VID [16]byte type VID [16]byte
var byteGroups = []int{8, 4, 4, 4, 12} var byteGroups = []int{8, 4, 4, 4, 12}

View File

@ -9,8 +9,11 @@ type VPoint struct {
connHandler ConnectionHandler 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) { func NewVPoint(config *VConfig) (*VPoint, error) {
var vpoint *VPoint var vpoint = new(VPoint)
vpoint.config = *config
return vpoint, nil return vpoint, nil
} }
@ -18,6 +21,8 @@ type ConnectionHandler interface {
Listen(port uint16) error 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 { func (vp *VPoint) Start() error {
if vp.config.Port <= 0 { if vp.config.Port <= 0 {
return fmt.Errorf("Invalid port %d", vp.config.Port) return fmt.Errorf("Invalid port %d", vp.config.Port)