You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/vpoint.go

33 lines
734 B

9 years ago
package core
import (
9 years ago
"fmt"
9 years ago
)
type VPoint struct {
9 years ago
config VConfig
connHandler ConnectionHandler
9 years ago
}
9 years ago
// NewVPoint returns a new VPoint server based on given configuration.
// The server is not started at this point.
9 years ago
func NewVPoint(config *VConfig) (*VPoint, error) {
9 years ago
var vpoint = new(VPoint)
vpoint.config = *config
9 years ago
return vpoint, nil
9 years ago
}
type ConnectionHandler interface {
9 years ago
Listen(port uint16) error
9 years ago
}
9 years ago
// 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.
9 years ago
func (vp *VPoint) Start() error {
9 years ago
if vp.config.Port <= 0 {
return fmt.Errorf("Invalid port %d", vp.config.Port)
}
vp.connHandler.Listen(vp.config.Port)
return nil
}