diff --git a/io/jsonvconfigmarshaller.go b/io/jsonvconfigmarshaller.go index aaa994d1..1d80b9b6 100644 --- a/io/jsonvconfigmarshaller.go +++ b/io/jsonvconfigmarshaller.go @@ -1,38 +1,37 @@ package io import ( - "encoding/json" - _ "fmt" - "github.com/v2ray/v2ray-core" + "encoding/json" + _ "fmt" + "github.com/v2ray/v2ray-core" ) type JsonVUser struct { - id string `json:"id"` - email string `json:"email"` + id string `json:"id"` + email string `json:"email"` } type JsonVConfig struct { - RunAs string `json:"runas"` - Port uint8 `json:"port"` - Clients []JsonVUser `json:"users"` - Protocol string `json:"protocol"` + RunAs string `json:"runas"` + Port uint8 `json:"port"` + Clients []JsonVUser `json:"users"` + Protocol string `json:"protocol"` } type JsonVConfigUnmarshaller struct { - } func StringToVUser(id string) (u core.VUser, err error) { - return + return } func (*JsonVConfigUnmarshaller) Unmarshall(data []byte) (*core.VConfig, error) { - var jsonConfig JsonVConfig - err := json.Unmarshal(data, &jsonConfig) - if err != nil { - return nil, err - } - var vconfig = new(core.VConfig) - vconfig.RunAs = core.VUser{} - return vconfig, nil -} \ No newline at end of file + var jsonConfig JsonVConfig + err := json.Unmarshal(data, &jsonConfig) + if err != nil { + return nil, err + } + var vconfig = new(core.VConfig) + vconfig.RunAs = core.VUser{} + return vconfig, nil +} diff --git a/io/vmessreader.go b/io/vmessreader.go index 501ca0e2..74ab0c2f 100644 --- a/io/vmessreader.go +++ b/io/vmessreader.go @@ -1,32 +1,32 @@ package io import ( - "net" + "net" ) type VMessInput struct { - version byte - userHash [16]byte - randHash [256]byte - respKey [32]byte - iv [16]byte - command byte - port uint16 - target [256]byte - data []byte + version byte + userHash [16]byte + randHash [256]byte + respKey [32]byte + iv [16]byte + command byte + port uint16 + target [256]byte + data []byte } type VMessReader struct { - conn *net.Conn + conn *net.Conn } func NewVMessReader(conn *net.Conn) (VMessReader, error) { - var reader VMessReader - reader.conn = conn - return reader, nil + var reader VMessReader + reader.conn = conn + return reader, nil } func (*VMessReader) Read() (VMessInput, error) { - var input VMessInput - return input, nil -} \ No newline at end of file + var input VMessInput + return input, nil +} diff --git a/net/vmesshandler.go b/net/vmesshandler.go index b4e15539..8da73623 100644 --- a/net/vmesshandler.go +++ b/net/vmesshandler.go @@ -1,19 +1,17 @@ package net import ( - "net" + "net" ) type VMessHandler struct { - } func (*VMessHandler) Listen(port uint8) error { - listener, err := net.Listen("tcp", ":" + string(port)) - if err != nil { - return err - } - - - return nil + listener, err := net.Listen("tcp", ":"+string(port)) + if err != nil { + return err + } + + return nil } diff --git a/vconfig.go b/vconfig.go index 45c671ae..29ff3b28 100644 --- a/vconfig.go +++ b/vconfig.go @@ -1,20 +1,20 @@ package core type VUser struct { - id VID + id VID } type VConfig struct { - RunAs VUser - Port uint16 - AllowedClients []VUser - AllowedProtocol string + RunAs VUser + Port uint16 + AllowedClients []VUser + AllowedProtocol string } type VConfigMarshaller interface { - Marshal(config VConfig) ([]byte, error) + Marshal(config VConfig) ([]byte, error) } type VConfigUnmarshaller interface { - Unmarshal(data []byte) (VConfig, error) + Unmarshal(data []byte) (VConfig, error) } diff --git a/vid.go b/vid.go index 0aeed0b3..d82b422a 100644 --- a/vid.go +++ b/vid.go @@ -1,8 +1,8 @@ package core import ( - "encoding/hex" - "fmt" + "encoding/hex" + "fmt" ) type VID [16]byte @@ -11,8 +11,8 @@ var byteGroups = []int{8, 4, 4, 4, 12} // TODO: leverage a full functional UUID library func UUIDToVID(uuid string) (v VID, err error) { - text := []byte(uuid) - if len(text) < 32 { + text := []byte(uuid) + if len(text) < 32 { err = fmt.Errorf("uuid: invalid UUID string: %s", text) return } diff --git a/vpoint.go b/vpoint.go index ffb12060..b0b0f94d 100644 --- a/vpoint.go +++ b/vpoint.go @@ -1,27 +1,27 @@ package core import ( - "fmt" + "fmt" ) type VPoint struct { - config VConfig - connHandler ConnectionHandler + config VConfig + connHandler ConnectionHandler } func NewVPoint(config *VConfig) (*VPoint, error) { - var vpoint *VPoint - return vpoint, nil + var vpoint *VPoint + return vpoint, nil } type ConnectionHandler interface { - Listen(port uint16) error + Listen(port uint16) error } func (vp *VPoint) Start() error { - if vp.config.Port <= 0 { - return fmt.Errorf("Invalid port %d", vp.config.Port) - } - vp.connHandler.Listen(vp.config.Port) - return nil -} \ No newline at end of file + if vp.config.Port <= 0 { + return fmt.Errorf("Invalid port %d", vp.config.Port) + } + vp.connHandler.Listen(vp.config.Port) + return nil +}