1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 09:50:43 +00:00

InboundHandler.Proxy()

This commit is contained in:
Darien Raymond 2017-01-15 00:57:06 +01:00
parent 34a2ae0ab7
commit f2b1d5b60c
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
6 changed files with 42 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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