mirror of https://github.com/v2ray/v2ray-core
parent
34a2ae0ab7
commit
f2b1d5b60c
|
@ -40,6 +40,9 @@ func New(ctx context.Context, config *Config) (*DokodemoDoor, error) {
|
|||
if meta == nil {
|
||||
return nil, errors.New("Dokodemo: No outbound meta in context.")
|
||||
}
|
||||
if config.NetworkList == nil || config.NetworkList.Size() == 0 {
|
||||
return nil, errors.New("DokodemoDoor: No network specified.")
|
||||
}
|
||||
d := &DokodemoDoor{
|
||||
config: config,
|
||||
address: config.GetPredefinedAddress(),
|
||||
|
@ -76,16 +79,16 @@ func (v *DokodemoDoor) Close() {
|
|||
}
|
||||
}
|
||||
|
||||
func (v *DokodemoDoor) Network() net.NetworkList {
|
||||
return *(v.config.NetworkList)
|
||||
}
|
||||
|
||||
func (v *DokodemoDoor) Start() error {
|
||||
if v.accepting {
|
||||
return nil
|
||||
}
|
||||
v.accepting = true
|
||||
|
||||
if v.config.NetworkList == nil || v.config.NetworkList.Size() == 0 {
|
||||
return errors.New("DokodemoDoor: No network specified.")
|
||||
}
|
||||
|
||||
if v.config.NetworkList.HasNetwork(net.Network_TCP) {
|
||||
err := v.ListenTCP()
|
||||
if err != nil {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -8,8 +9,6 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"context"
|
||||
|
||||
"v2ray.com/core/app"
|
||||
"v2ray.com/core/app/dispatcher"
|
||||
"v2ray.com/core/common"
|
||||
|
@ -62,6 +61,12 @@ func (v *Server) Port() v2net.Port {
|
|||
return v.meta.Port
|
||||
}
|
||||
|
||||
func (v *Server) Network() v2net.NetworkList {
|
||||
return v2net.NetworkList{
|
||||
Network: []v2net.Network{v2net.Network_TCP},
|
||||
}
|
||||
}
|
||||
|
||||
// Close implements InboundHandler.Close().
|
||||
func (v *Server) Close() {
|
||||
v.accepting = false
|
||||
|
|
|
@ -54,6 +54,8 @@ type InboundHandler interface {
|
|||
Close()
|
||||
// Port returns the port that the handler is listening on.
|
||||
Port() net.Port
|
||||
|
||||
Network() net.NetworkList
|
||||
}
|
||||
|
||||
// An OutboundHandler handles outbound network connection for V2Ray.
|
||||
|
|
|
@ -67,6 +67,16 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
|
|||
return s, nil
|
||||
}
|
||||
|
||||
func (v *Server) Network() net.NetworkList {
|
||||
list := net.NetworkList{
|
||||
Network: []net.Network{net.Network_TCP},
|
||||
}
|
||||
if v.config.UdpEnabled {
|
||||
list.Network = append(list.Network, net.Network_UDP)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
func (v *Server) Port() net.Port {
|
||||
return v.meta.Port
|
||||
}
|
||||
|
|
|
@ -59,6 +59,16 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
|
|||
return s, nil
|
||||
}
|
||||
|
||||
func (v *Server) Network() net.NetworkList {
|
||||
list := net.NetworkList{
|
||||
Network: []net.Network{net.Network_TCP},
|
||||
}
|
||||
if v.config.UdpEnabled {
|
||||
list.Network = append(list.Network, net.Network_UDP)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// Port implements InboundHandler.Port().
|
||||
func (v *Server) Port() net.Port {
|
||||
return v.meta.Port
|
||||
|
|
|
@ -120,6 +120,12 @@ func New(ctx context.Context, config *Config) (*VMessInboundHandler, error) {
|
|||
return handler, nil
|
||||
}
|
||||
|
||||
func (v *VMessInboundHandler) Network() net.NetworkList {
|
||||
return net.NetworkList{
|
||||
Network: []net.Network{net.Network_TCP},
|
||||
}
|
||||
}
|
||||
|
||||
func (v *VMessInboundHandler) Port() net.Port {
|
||||
return v.meta.Port
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue