Browse Source

documentation

pull/298/head
V2Ray 9 years ago
parent
commit
306ae93503
  1. 2
      core.go
  2. 1
      io/vmessreader.go
  3. 21
      vconfig.go
  4. 1
      vid.go
  5. 7
      vpoint.go

2
core.go

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

1
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

21
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 {

1
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}

7
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)

Loading…
Cancel
Save