mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 01:27:03 -05:00
get rid of annoying firewall warnings
This commit is contained in:
parent
c3aa839227
commit
b47c1ca609
@ -9,6 +9,7 @@ import (
|
||||
|
||||
var (
|
||||
LocalHostIP = IPAddress([]byte{127, 0, 0, 1})
|
||||
AnyIP = IPAddress([]byte{0, 0, 0, 0})
|
||||
)
|
||||
|
||||
// Address represents a network address to be communicated with. It may be an IP address or domain
|
||||
|
@ -26,6 +26,7 @@ type DokodemoDoor struct {
|
||||
udpHub *hub.UDPHub
|
||||
udpServer *hub.UDPServer
|
||||
listeningPort v2net.Port
|
||||
listeningAddress v2net.Address
|
||||
}
|
||||
|
||||
func NewDokodemoDoor(config *Config, space app.Space) *DokodemoDoor {
|
||||
@ -65,25 +66,26 @@ func (this *DokodemoDoor) Close() {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *DokodemoDoor) Listen(port v2net.Port) error {
|
||||
func (this *DokodemoDoor) Listen(address v2net.Address, port v2net.Port) error {
|
||||
if this.accepting {
|
||||
if this.listeningPort == port {
|
||||
if this.listeningPort == port && this.listeningAddress.Equals(address) {
|
||||
return nil
|
||||
} else {
|
||||
return proxy.ErrorAlreadyListening
|
||||
}
|
||||
}
|
||||
this.listeningPort = port
|
||||
this.listeningAddress = address
|
||||
this.accepting = true
|
||||
|
||||
if this.config.Network.HasNetwork(v2net.TCPNetwork) {
|
||||
err := this.ListenTCP(port)
|
||||
err := this.ListenTCP(address, port)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if this.config.Network.HasNetwork(v2net.UDPNetwork) {
|
||||
err := this.ListenUDP(port)
|
||||
err := this.ListenUDP(address, port)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -91,9 +93,9 @@ func (this *DokodemoDoor) Listen(port v2net.Port) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *DokodemoDoor) ListenUDP(port v2net.Port) error {
|
||||
func (this *DokodemoDoor) ListenUDP(address v2net.Address, port v2net.Port) error {
|
||||
this.udpServer = hub.NewUDPServer(this.packetDispatcher)
|
||||
udpHub, err := hub.ListenUDP(port, this.handleUDPPackets)
|
||||
udpHub, err := hub.ListenUDP(address, port, this.handleUDPPackets)
|
||||
if err != nil {
|
||||
log.Error("Dokodemo failed to listen on port ", port, ": ", err)
|
||||
return err
|
||||
@ -118,8 +120,8 @@ func (this *DokodemoDoor) handleUDPResponse(dest v2net.Destination, payload *all
|
||||
this.udpHub.WriteTo(payload.Value, dest)
|
||||
}
|
||||
|
||||
func (this *DokodemoDoor) ListenTCP(port v2net.Port) error {
|
||||
tcpListener, err := hub.ListenTCP(port, this.HandleTCPConnection, nil)
|
||||
func (this *DokodemoDoor) ListenTCP(address v2net.Address, port v2net.Port) error {
|
||||
tcpListener, err := hub.ListenTCP(address, port, this.HandleTCPConnection, nil)
|
||||
if err != nil {
|
||||
log.Error("Dokodemo: Failed to listen on port ", port, ": ", err)
|
||||
return err
|
||||
|
@ -53,7 +53,7 @@ func TestDokodemoTCP(t *testing.T) {
|
||||
assert.Error(space.Initialize()).IsNil()
|
||||
|
||||
port := v2nettesting.PickPort()
|
||||
err = dokodemo.Listen(port)
|
||||
err = dokodemo.Listen(v2net.LocalHostIP, port)
|
||||
assert.Error(err).IsNil()
|
||||
assert.Port(port).Equals(dokodemo.Port())
|
||||
|
||||
@ -111,7 +111,7 @@ func TestDokodemoUDP(t *testing.T) {
|
||||
assert.Error(space.Initialize()).IsNil()
|
||||
|
||||
port := v2nettesting.PickPort()
|
||||
err = dokodemo.Listen(port)
|
||||
err = dokodemo.Listen(v2net.LocalHostIP, port)
|
||||
assert.Error(err).IsNil()
|
||||
assert.Port(port).Equals(dokodemo.Port())
|
||||
|
||||
|
@ -29,6 +29,7 @@ type HttpProxyServer struct {
|
||||
config *Config
|
||||
tcpListener *hub.TCPHub
|
||||
listeningPort v2net.Port
|
||||
listeningAddress v2net.Address
|
||||
}
|
||||
|
||||
func NewHttpProxyServer(config *Config, packetDispatcher dispatcher.PacketDispatcher) *HttpProxyServer {
|
||||
@ -52,21 +53,22 @@ func (this *HttpProxyServer) Close() {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *HttpProxyServer) Listen(port v2net.Port) error {
|
||||
func (this *HttpProxyServer) Listen(address v2net.Address, port v2net.Port) error {
|
||||
if this.accepting {
|
||||
if this.listeningPort == port {
|
||||
if this.listeningPort == port && this.listeningAddress.Equals(address) {
|
||||
return nil
|
||||
} else {
|
||||
return proxy.ErrorAlreadyListening
|
||||
}
|
||||
}
|
||||
this.listeningPort = port
|
||||
this.listeningAddress = address
|
||||
|
||||
var tlsConfig *tls.Config = nil
|
||||
if this.config.TlsConfig != nil {
|
||||
tlsConfig = this.config.TlsConfig.GetConfig()
|
||||
}
|
||||
tcpListener, err := hub.ListenTCP(port, this.handleConnection, tlsConfig)
|
||||
tcpListener, err := hub.ListenTCP(address, port, this.handleConnection, tlsConfig)
|
||||
if err != nil {
|
||||
log.Error("Http: Failed listen on port ", port, ": ", err)
|
||||
return err
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
testdispatcher "github.com/v2ray/v2ray-core/app/dispatcher/testing"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
|
||||
. "github.com/v2ray/v2ray-core/proxy/http"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
@ -55,7 +56,7 @@ func TestNormalGetRequest(t *testing.T) {
|
||||
defer httpProxy.Close()
|
||||
|
||||
port := v2nettesting.PickPort()
|
||||
err := httpProxy.Listen(port)
|
||||
err := httpProxy.Listen(v2net.LocalHostIP, port)
|
||||
assert.Error(err).IsNil()
|
||||
assert.Port(port).Equals(httpProxy.Port())
|
||||
|
||||
|
@ -17,7 +17,7 @@ const (
|
||||
// An InboundHandler handles inbound network connections to V2Ray.
|
||||
type InboundHandler interface {
|
||||
// Listen starts a InboundHandler by listen on a specific port.
|
||||
Listen(port v2net.Port) error
|
||||
Listen(on v2net.Address, port v2net.Port) error
|
||||
// Close stops the handler to accepting anymore inbound connections.
|
||||
Close()
|
||||
// Port returns the port that the handler is listening on.
|
||||
|
@ -23,6 +23,7 @@ type Server struct {
|
||||
packetDispatcher dispatcher.PacketDispatcher
|
||||
config *Config
|
||||
port v2net.Port
|
||||
address v2net.Address
|
||||
accepting bool
|
||||
tcpHub *hub.TCPHub
|
||||
udpHub *hub.UDPHub
|
||||
@ -55,16 +56,16 @@ func (this *Server) Close() {
|
||||
|
||||
}
|
||||
|
||||
func (this *Server) Listen(port v2net.Port) error {
|
||||
func (this *Server) Listen(address v2net.Address, port v2net.Port) error {
|
||||
if this.accepting {
|
||||
if this.port == port {
|
||||
if this.port == port && this.address.Equals(address) {
|
||||
return nil
|
||||
} else {
|
||||
return proxy.ErrorAlreadyListening
|
||||
}
|
||||
}
|
||||
|
||||
tcpHub, err := hub.ListenTCP(port, this.handleConnection, nil)
|
||||
tcpHub, err := hub.ListenTCP(address, port, this.handleConnection, nil)
|
||||
if err != nil {
|
||||
log.Error("Shadowsocks: Failed to listen TCP on port ", port, ": ", err)
|
||||
return err
|
||||
@ -73,7 +74,7 @@ func (this *Server) Listen(port v2net.Port) error {
|
||||
|
||||
if this.config.UDP {
|
||||
this.udpServer = hub.NewUDPServer(this.packetDispatcher)
|
||||
udpHub, err := hub.ListenUDP(port, this.handlerUDPPayload)
|
||||
udpHub, err := hub.ListenUDP(address, port, this.handlerUDPPayload)
|
||||
if err != nil {
|
||||
log.Error("Shadowsocks: Failed to listen UDP on port ", port, ": ", err)
|
||||
return err
|
||||
@ -82,6 +83,7 @@ func (this *Server) Listen(port v2net.Port) error {
|
||||
}
|
||||
|
||||
this.port = port
|
||||
this.address = address
|
||||
this.accepting = true
|
||||
|
||||
return nil
|
||||
|
@ -34,6 +34,7 @@ type Server struct {
|
||||
udpAddress v2net.Destination
|
||||
udpServer *hub.UDPServer
|
||||
listeningPort v2net.Port
|
||||
listeningAddress v2net.Address
|
||||
}
|
||||
|
||||
// NewServer creates a new Server object.
|
||||
@ -67,17 +68,18 @@ func (this *Server) Close() {
|
||||
}
|
||||
|
||||
// Listen implements InboundHandler.Listen().
|
||||
func (this *Server) Listen(port v2net.Port) error {
|
||||
func (this *Server) Listen(address v2net.Address, port v2net.Port) error {
|
||||
if this.accepting {
|
||||
if this.listeningPort == port {
|
||||
if this.listeningPort == port && this.listeningAddress.Equals(address) {
|
||||
return nil
|
||||
} else {
|
||||
return proxy.ErrorAlreadyListening
|
||||
}
|
||||
}
|
||||
this.listeningPort = port
|
||||
this.listeningAddress = address
|
||||
|
||||
listener, err := hub.ListenTCP(port, this.handleConnection, nil)
|
||||
listener, err := hub.ListenTCP(address, port, this.handleConnection, nil)
|
||||
if err != nil {
|
||||
log.Error("Socks: failed to listen on port ", port, ": ", err)
|
||||
return err
|
||||
@ -87,7 +89,7 @@ func (this *Server) Listen(port v2net.Port) error {
|
||||
this.tcpListener = listener
|
||||
this.tcpMutex.Unlock()
|
||||
if this.config.UDPEnabled {
|
||||
this.listenUDP(port)
|
||||
this.listenUDP(address, port)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ func TestSocksTcpConnect(t *testing.T) {
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
config := &point.Config{
|
||||
Port: port,
|
||||
Port: port,
|
||||
ListenOn: v2net.LocalHostIP,
|
||||
InboundConfig: &point.ConnectionConfig{
|
||||
Protocol: "socks",
|
||||
Settings: []byte(`
|
||||
@ -101,7 +102,8 @@ func TestSocksTcpConnectWithUserPass(t *testing.T) {
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
config := &point.Config{
|
||||
Port: port,
|
||||
Port: port,
|
||||
ListenOn: v2net.LocalHostIP,
|
||||
InboundConfig: &point.ConnectionConfig{
|
||||
Protocol: "socks",
|
||||
Settings: []byte(`
|
||||
@ -168,7 +170,8 @@ func TestSocksTcpConnectWithWrongUserPass(t *testing.T) {
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
config := &point.Config{
|
||||
Port: port,
|
||||
Port: port,
|
||||
ListenOn: v2net.LocalHostIP,
|
||||
InboundConfig: &point.ConnectionConfig{
|
||||
Protocol: "socks",
|
||||
Settings: []byte(`
|
||||
@ -221,7 +224,8 @@ func TestSocksTcpConnectWithWrongAuthMethod(t *testing.T) {
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
config := &point.Config{
|
||||
Port: port,
|
||||
Port: port,
|
||||
ListenOn: v2net.LocalHostIP,
|
||||
InboundConfig: &point.ConnectionConfig{
|
||||
Protocol: "socks",
|
||||
Settings: []byte(`
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/v2ray/v2ray-core/transport/hub"
|
||||
)
|
||||
|
||||
func (this *Server) listenUDP(port v2net.Port) error {
|
||||
func (this *Server) listenUDP(address v2net.Address, port v2net.Port) error {
|
||||
this.udpServer = hub.NewUDPServer(this.packetDispatcher)
|
||||
udpHub, err := hub.ListenUDP(port, this.handleUDPPayload)
|
||||
udpHub, err := hub.ListenUDP(address, port, this.handleUDPPayload)
|
||||
if err != nil {
|
||||
log.Error("Socks: Failed to listen on udp port ", port)
|
||||
return err
|
||||
|
@ -11,13 +11,15 @@ import (
|
||||
|
||||
type InboundConnectionHandler struct {
|
||||
port v2net.Port
|
||||
address v2net.Address
|
||||
PacketDispatcher dispatcher.PacketDispatcher
|
||||
ConnInput io.Reader
|
||||
ConnOutput io.Writer
|
||||
}
|
||||
|
||||
func (this *InboundConnectionHandler) Listen(port v2net.Port) error {
|
||||
func (this *InboundConnectionHandler) Listen(address v2net.Address, port v2net.Port) error {
|
||||
this.port = port
|
||||
this.address = address
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,7 @@ type VMessInboundHandler struct {
|
||||
listener *hub.TCPHub
|
||||
features *FeaturesConfig
|
||||
listeningPort v2net.Port
|
||||
listeningAddress v2net.Address
|
||||
}
|
||||
|
||||
func (this *VMessInboundHandler) Port() v2net.Port {
|
||||
@ -97,17 +98,18 @@ func (this *VMessInboundHandler) GetUser(email string) *protocol.User {
|
||||
return user
|
||||
}
|
||||
|
||||
func (this *VMessInboundHandler) Listen(port v2net.Port) error {
|
||||
func (this *VMessInboundHandler) Listen(address v2net.Address, port v2net.Port) error {
|
||||
if this.accepting {
|
||||
if this.listeningPort == port {
|
||||
if this.listeningPort == port && this.listeningAddress.Equals(address) {
|
||||
return nil
|
||||
} else {
|
||||
return proxy.ErrorAlreadyListening
|
||||
}
|
||||
}
|
||||
this.listeningPort = port
|
||||
this.listeningAddress = address
|
||||
|
||||
tcpListener, err := hub.ListenTCP(port, this.HandleConnection, nil)
|
||||
tcpListener, err := hub.ListenTCP(address, port, this.HandleConnection, nil)
|
||||
if err != nil {
|
||||
log.Error("Unable to listen tcp port ", port, ": ", err)
|
||||
return err
|
||||
|
@ -45,7 +45,8 @@ func TestVMessInAndOut(t *testing.T) {
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
configA := &point.Config{
|
||||
Port: portA,
|
||||
Port: portA,
|
||||
ListenOn: v2net.LocalHostIP,
|
||||
DNSConfig: &dns.Config{
|
||||
NameServers: []v2net.Destination{
|
||||
v2net.UDPDestination(v2net.DomainAddress("localhost"), v2net.Port(53)),
|
||||
@ -90,7 +91,8 @@ func TestVMessInAndOut(t *testing.T) {
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
configB := &point.Config{
|
||||
Port: portB,
|
||||
Port: portB,
|
||||
ListenOn: v2net.LocalHostIP,
|
||||
DNSConfig: &dns.Config{
|
||||
NameServers: []v2net.Destination{
|
||||
v2net.UDPDestination(v2net.DomainAddress("localhost"), v2net.Port(53)),
|
||||
|
@ -33,6 +33,7 @@ type InboundDetourAllocationConfig struct {
|
||||
type InboundDetourConfig struct {
|
||||
Protocol string
|
||||
PortRange v2net.PortRange
|
||||
ListenOn v2net.Address
|
||||
Tag string
|
||||
Allocation *InboundDetourAllocationConfig
|
||||
Settings []byte
|
||||
@ -46,6 +47,7 @@ type OutboundDetourConfig struct {
|
||||
|
||||
type Config struct {
|
||||
Port v2net.Port
|
||||
ListenOn v2net.Address
|
||||
LogConfig *LogConfig
|
||||
RouterConfig *router.Config
|
||||
DNSConfig *dns.Config
|
||||
|
@ -4,6 +4,7 @@ package point
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
@ -21,6 +22,7 @@ const (
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type JsonConfig struct {
|
||||
Port v2net.Port `json:"port"` // Port of this Point server.
|
||||
ListenOn *v2net.AddressJson `json:"listen"`
|
||||
LogConfig *LogConfig `json:"log"`
|
||||
RouterConfig *router.Config `json:"routing"`
|
||||
DNSConfig *dns.Config `json:"dns"`
|
||||
@ -34,6 +36,13 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
return err
|
||||
}
|
||||
this.Port = jsonConfig.Port
|
||||
this.ListenOn = v2net.AnyIP
|
||||
if jsonConfig.ListenOn != nil {
|
||||
if jsonConfig.ListenOn.Address.IsDomain() {
|
||||
return errors.New("Point: Unable to listen on domain address: " + jsonConfig.ListenOn.Address.Domain())
|
||||
}
|
||||
this.ListenOn = jsonConfig.ListenOn.Address
|
||||
}
|
||||
this.LogConfig = jsonConfig.LogConfig
|
||||
this.RouterConfig = jsonConfig.RouterConfig
|
||||
this.InboundConfig = jsonConfig.InboundConfig
|
||||
@ -125,6 +134,7 @@ func (this *InboundDetourConfig) UnmarshalJSON(data []byte) error {
|
||||
type JsonInboundDetourConfig struct {
|
||||
Protocol string `json:"protocol"`
|
||||
PortRange *v2net.PortRange `json:"port"`
|
||||
ListenOn *v2net.AddressJson `json:"listen"`
|
||||
Settings json.RawMessage `json:"settings"`
|
||||
Tag string `json:"tag"`
|
||||
Allocation *InboundDetourAllocationConfig `json:"allocate"`
|
||||
@ -137,6 +147,13 @@ func (this *InboundDetourConfig) UnmarshalJSON(data []byte) error {
|
||||
log.Error("Point: Port range not specified in InboundDetour.")
|
||||
return ErrorBadConfiguration
|
||||
}
|
||||
this.ListenOn = v2net.AnyIP
|
||||
if jsonConfig.ListenOn != nil {
|
||||
if jsonConfig.ListenOn.Address.IsDomain() {
|
||||
return errors.New("Point: Unable to listen on domain address: " + jsonConfig.ListenOn.Address.Domain())
|
||||
}
|
||||
this.ListenOn = jsonConfig.ListenOn.Address
|
||||
}
|
||||
this.Protocol = jsonConfig.Protocol
|
||||
this.PortRange = *jsonConfig.PortRange
|
||||
this.Settings = jsonConfig.Settings
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
|
||||
type InboundConnectionHandlerWithPort struct {
|
||||
port v2net.Port
|
||||
listen v2net.Address
|
||||
handler proxy.InboundHandler
|
||||
}
|
||||
|
||||
@ -39,6 +40,7 @@ func NewInboundDetourHandlerAlways(space app.Space, config *InboundDetourConfig)
|
||||
handler.ich = append(handler.ich, &InboundConnectionHandlerWithPort{
|
||||
port: i,
|
||||
handler: ich,
|
||||
listen: config.ListenOn,
|
||||
})
|
||||
}
|
||||
return handler, nil
|
||||
@ -59,7 +61,7 @@ func (this *InboundDetourHandlerAlways) Close() {
|
||||
func (this *InboundDetourHandlerAlways) Start() error {
|
||||
for _, ich := range this.ich {
|
||||
err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
|
||||
err := ich.handler.Listen(ich.port)
|
||||
err := ich.handler.Listen(ich.listen, ich.port)
|
||||
if err != nil {
|
||||
log.Error("Failed to start inbound detour on port ", ich.port, ": ", err)
|
||||
return err
|
||||
|
@ -91,7 +91,7 @@ func (this *InboundDetourHandlerDynamic) refresh() error {
|
||||
ich.Close()
|
||||
err := retry.Timed(100 /* times */, 1000 /* ms */).On(func() error {
|
||||
port := this.pickUnusedPort()
|
||||
err := ich.Listen(port)
|
||||
err := ich.Listen(this.config.ListenOn, port)
|
||||
if err != nil {
|
||||
log.Error("Point: Failed to start inbound detour on port ", port, ": ", err)
|
||||
return err
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
// Point shell of V2Ray.
|
||||
type Point struct {
|
||||
port v2net.Port
|
||||
listen v2net.Address
|
||||
ich proxy.InboundHandler
|
||||
och proxy.OutboundHandler
|
||||
idh []InboundDetourHandler
|
||||
@ -35,6 +36,7 @@ type Point struct {
|
||||
func NewPoint(pConfig *Config) (*Point, error) {
|
||||
var vpoint = new(Point)
|
||||
vpoint.port = pConfig.Port
|
||||
vpoint.listen = pConfig.ListenOn
|
||||
|
||||
if pConfig.LogConfig != nil {
|
||||
logConfig := pConfig.LogConfig
|
||||
@ -167,7 +169,7 @@ func (this *Point) Start() error {
|
||||
}
|
||||
|
||||
err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
|
||||
err := this.ich.Listen(this.port)
|
||||
err := this.ich.Listen(this.listen, this.port)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"port": 50000,
|
||||
"listen": "127.0.0.1",
|
||||
"inbound": {
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
|
@ -1,9 +1,8 @@
|
||||
{
|
||||
"port": 50001,
|
||||
"listen": "127.0.0.1",
|
||||
"log": {
|
||||
"access": "/tmp/v2ray_access.log",
|
||||
"error": "/tmp/v2ray_error.log",
|
||||
"loglevel": "error"
|
||||
"loglevel": "none"
|
||||
},
|
||||
"inbound": {
|
||||
"protocol": "vmess",
|
||||
@ -29,6 +28,7 @@
|
||||
"inboundDetour": [
|
||||
{
|
||||
"protocol": "vmess",
|
||||
"listen": "127.0.0.1",
|
||||
"port": "50005-50009",
|
||||
"tag": "detour",
|
||||
"settings": {
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"port": 50010,
|
||||
"listen": "127.0.0.1",
|
||||
"inbound": {
|
||||
"protocol": "socks",
|
||||
"settings": {
|
||||
@ -25,6 +26,7 @@
|
||||
"inboundDetour": [
|
||||
{
|
||||
"protocol": "dokodemo-door",
|
||||
"listen": "127.0.0.1",
|
||||
"port": "50011-50015",
|
||||
"settings": {
|
||||
"address": "127.0.0.1",
|
||||
|
@ -1,5 +1,9 @@
|
||||
{
|
||||
"port": 50017,
|
||||
"listen": "127.0.0.1",
|
||||
"log": {
|
||||
"loglevel": "none"
|
||||
},
|
||||
"inbound": {
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
|
@ -1,9 +1,8 @@
|
||||
{
|
||||
"port": 50020,
|
||||
"listen": "127.0.0.1",
|
||||
"log": {
|
||||
"access": "/tmp/v2ray_access_1.log",
|
||||
"error": "/tmp/v2ray_error_1.log",
|
||||
"loglevel": "error"
|
||||
"loglevel": "none"
|
||||
},
|
||||
"inbound": {
|
||||
"protocol": "dokodemo-door",
|
||||
@ -32,6 +31,7 @@
|
||||
{
|
||||
"protocol": "dokodemo-door",
|
||||
"port": 50022,
|
||||
"listen": "127.0.0.1",
|
||||
"settings": {
|
||||
"address": "127.0.0.1",
|
||||
"port": 50025,
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"port": 50021,
|
||||
"listen": "127.0.0.1",
|
||||
"inbound": {
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"port": 50030,
|
||||
"listen": "127.0.0.1",
|
||||
"inbound": {
|
||||
"protocol": "dokodemo-door",
|
||||
"settings": {
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"port": 50031,
|
||||
"listen": "127.0.0.1",
|
||||
"log": {
|
||||
"loglevel": "warning"
|
||||
},
|
||||
@ -27,6 +28,7 @@
|
||||
"inboundDetour": [
|
||||
{
|
||||
"protocol": "vmess",
|
||||
"listen": "127.0.0.1",
|
||||
"port": "50035-50039",
|
||||
"tag": "detour",
|
||||
"settings": {},
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"port": 50040,
|
||||
"listen": "127.0.0.1",
|
||||
"inbound": {
|
||||
"protocol": "http",
|
||||
"settings": {}
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"port": 50041,
|
||||
"listen": "127.0.0.1",
|
||||
"inbound": {
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"port": 50051,
|
||||
"listen": "127.0.0.1",
|
||||
"inbound": {
|
||||
"protocol": "shadowsocks",
|
||||
"settings": {
|
||||
@ -11,6 +12,7 @@
|
||||
{
|
||||
"protocol": "shadowsocks",
|
||||
"port": 50055,
|
||||
"listen": "127.0.0.1",
|
||||
"settings": {
|
||||
"method": "aes-128-cfb",
|
||||
"password": "v2ray-another",
|
||||
@ -20,6 +22,7 @@
|
||||
{
|
||||
"protocol": "shadowsocks",
|
||||
"port": 50056,
|
||||
"listen": "127.0.0.1",
|
||||
"settings": {
|
||||
"method": "chacha20",
|
||||
"password": "new-password",
|
||||
|
@ -27,7 +27,7 @@ func (server *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
func (server *Server) Start() (v2net.Destination, error) {
|
||||
go http.ListenAndServe(":"+server.Port.String(), server)
|
||||
go http.ListenAndServe("127.0.0.1:"+server.Port.String(), server)
|
||||
return v2net.TCPDestination(v2net.LocalHostIP, v2net.Port(server.Port)), nil
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ type Server struct {
|
||||
|
||||
func (server *Server) Start() (v2net.Destination, error) {
|
||||
listener, err := net.ListenTCP("tcp", &net.TCPAddr{
|
||||
IP: []byte{0, 0, 0, 0},
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(server.Port),
|
||||
Zone: "",
|
||||
})
|
||||
|
@ -16,7 +16,7 @@ type Server struct {
|
||||
|
||||
func (server *Server) Start() (v2net.Destination, error) {
|
||||
conn, err := net.ListenUDP("udp", &net.UDPAddr{
|
||||
IP: []byte{0, 0, 0, 0},
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(server.Port),
|
||||
Zone: "",
|
||||
})
|
||||
|
@ -19,9 +19,9 @@ type TCPHub struct {
|
||||
accepting bool
|
||||
}
|
||||
|
||||
func ListenTCP(port v2net.Port, callback ConnectionHandler, tlsConfig *tls.Config) (*TCPHub, error) {
|
||||
func ListenTCP(address v2net.Address, port v2net.Port, callback ConnectionHandler, tlsConfig *tls.Config) (*TCPHub, error) {
|
||||
listener, err := net.ListenTCP("tcp", &net.TCPAddr{
|
||||
IP: []byte{0, 0, 0, 0},
|
||||
IP: address.IP(),
|
||||
Port: int(port),
|
||||
Zone: "",
|
||||
})
|
||||
|
@ -15,9 +15,9 @@ type UDPHub struct {
|
||||
accepting bool
|
||||
}
|
||||
|
||||
func ListenUDP(port v2net.Port, callback UDPPayloadHandler) (*UDPHub, error) {
|
||||
func ListenUDP(address v2net.Address, port v2net.Port, callback UDPPayloadHandler) (*UDPHub, error) {
|
||||
udpConn, err := net.ListenUDP("udp", &net.UDPAddr{
|
||||
IP: []byte{0, 0, 0, 0},
|
||||
IP: address.IP(),
|
||||
Port: int(port),
|
||||
})
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user