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

format code

This commit is contained in:
V2Ray 2015-09-06 22:10:42 +02:00
parent 530f749aa3
commit a45498da45
6 changed files with 66 additions and 69 deletions

View File

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

View File

@ -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
}
var input VMessInput
return input, nil
}

View File

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

View File

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

8
vid.go
View File

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

View File

@ -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
}
if vp.config.Port <= 0 {
return fmt.Errorf("Invalid port %d", vp.config.Port)
}
vp.connHandler.Listen(vp.config.Port)
return nil
}