mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
id of v2ray instance
This commit is contained in:
parent
630a76d06a
commit
fbfbbb8841
11
v2ray.go
11
v2ray.go
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/uuid"
|
||||
)
|
||||
|
||||
// Server is an instance of V2Ray. At any time, there must be at most one Server instance running.
|
||||
@ -28,13 +29,16 @@ type Instance struct {
|
||||
ohm syncOutboundHandlerManager
|
||||
|
||||
features []Feature
|
||||
id uuid.UUID
|
||||
}
|
||||
|
||||
// New returns a new V2Ray instance based on given configuration.
|
||||
// The instance is not started at this point.
|
||||
// To make sure V2Ray instance works properly, the config must contain one Dispatcher, one InboundHandlerManager and one OutboundHandlerManager. Other features are optional.
|
||||
func New(config *Config) (*Instance, error) {
|
||||
var server = new(Instance)
|
||||
var server = &Instance{
|
||||
id: *(uuid.New()),
|
||||
}
|
||||
|
||||
if err := config.Transport.Apply(); err != nil {
|
||||
return nil, err
|
||||
@ -83,6 +87,11 @@ func New(config *Config) (*Instance, error) {
|
||||
return server, nil
|
||||
}
|
||||
|
||||
// ID returns an unique ID for this V2Ray instance.
|
||||
func (s *Instance) ID() uuid.UUID {
|
||||
return s.id
|
||||
}
|
||||
|
||||
// Close shutdown the V2Ray instance.
|
||||
func (s *Instance) Close() {
|
||||
for _, f := range s.features {
|
||||
|
Loading…
Reference in New Issue
Block a user