mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-30 23:37:44 +00:00
option to allow passive connection
This commit is contained in:
18 files changed
+76
-47
No files matched your search
+14
-12
@@ -10,11 +10,12 @@ import (
|
||||
)
|
||||
|
||||
type InboundConnectionConfig struct {
|
||||
Port v2net.Port
|
||||
ListenOn v2net.Address
|
||||
StreamSettings *internet.StreamSettings
|
||||
Protocol string
|
||||
Settings []byte
|
||||
Port v2net.Port
|
||||
ListenOn v2net.Address
|
||||
StreamSettings *internet.StreamSettings
|
||||
Protocol string
|
||||
Settings []byte
|
||||
AllowPassiveConnection bool
|
||||
}
|
||||
|
||||
type OutboundConnectionConfig struct {
|
||||
@@ -43,13 +44,14 @@ type InboundDetourAllocationConfig struct {
|
||||
}
|
||||
|
||||
type InboundDetourConfig struct {
|
||||
Protocol string
|
||||
PortRange v2net.PortRange
|
||||
ListenOn v2net.Address
|
||||
Tag string
|
||||
Allocation *InboundDetourAllocationConfig
|
||||
StreamSettings *internet.StreamSettings
|
||||
Settings []byte
|
||||
Protocol string
|
||||
PortRange v2net.PortRange
|
||||
ListenOn v2net.Address
|
||||
Tag string
|
||||
Allocation *InboundDetourAllocationConfig
|
||||
StreamSettings *internet.StreamSettings
|
||||
Settings []byte
|
||||
AllowPassiveConnection bool
|
||||
}
|
||||
|
||||
type OutboundDetourConfig struct {
|
||||
|
||||
@@ -71,6 +71,7 @@ func (this *InboundConnectionConfig) UnmarshalJSON(data []byte) error {
|
||||
Protocol string `json:"protocol"`
|
||||
StreamSetting *internet.StreamSettings `json:"streamSettings"`
|
||||
Settings json.RawMessage `json:"settings"`
|
||||
AllowPassive bool `json:"allowPassive"`
|
||||
}
|
||||
|
||||
jsonConfig := new(JsonConfig)
|
||||
@@ -91,6 +92,7 @@ func (this *InboundConnectionConfig) UnmarshalJSON(data []byte) error {
|
||||
|
||||
this.Protocol = jsonConfig.Protocol
|
||||
this.Settings = jsonConfig.Settings
|
||||
this.AllowPassiveConnection = jsonConfig.AllowPassive
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -186,6 +188,7 @@ func (this *InboundDetourConfig) UnmarshalJSON(data []byte) error {
|
||||
Tag string `json:"tag"`
|
||||
Allocation *InboundDetourAllocationConfig `json:"allocate"`
|
||||
StreamSetting *internet.StreamSettings `json:"streamSettings"`
|
||||
AllowPassive bool `json:"allowPassive"`
|
||||
}
|
||||
jsonConfig := new(JsonInboundDetourConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
@@ -216,6 +219,7 @@ func (this *InboundDetourConfig) UnmarshalJSON(data []byte) error {
|
||||
if jsonConfig.StreamSetting != nil {
|
||||
this.StreamSettings = jsonConfig.StreamSetting
|
||||
}
|
||||
this.AllowPassiveConnection = jsonConfig.AllowPassive
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,12 @@ func NewInboundDetourHandlerAlways(space app.Space, config *InboundDetourConfig)
|
||||
for i := ports.From; i <= ports.To; i++ {
|
||||
ichConfig := config.Settings
|
||||
ich, err := proxyrepo.CreateInboundHandler(config.Protocol, space, ichConfig, &proxy.InboundHandlerMeta{
|
||||
Address: config.ListenOn,
|
||||
Port: i,
|
||||
Tag: config.Tag,
|
||||
StreamSettings: config.StreamSettings})
|
||||
Address: config.ListenOn,
|
||||
Port: i,
|
||||
Tag: config.Tag,
|
||||
StreamSettings: config.StreamSettings,
|
||||
AllowPassiveConnection: config.AllowPassiveConnection,
|
||||
})
|
||||
if err != nil {
|
||||
log.Error("Failed to create inbound connection handler: ", err)
|
||||
return nil, err
|
||||
|
||||
@@ -33,10 +33,12 @@ func NewInboundDetourHandlerDynamic(space app.Space, config *InboundDetourConfig
|
||||
|
||||
// To test configuration
|
||||
ich, err := proxyrepo.CreateInboundHandler(config.Protocol, space, config.Settings, &proxy.InboundHandlerMeta{
|
||||
Address: config.ListenOn,
|
||||
Port: 0,
|
||||
Tag: config.Tag,
|
||||
StreamSettings: config.StreamSettings})
|
||||
Address: config.ListenOn,
|
||||
Port: 0,
|
||||
Tag: config.Tag,
|
||||
StreamSettings: config.StreamSettings,
|
||||
AllowPassiveConnection: config.AllowPassiveConnection,
|
||||
})
|
||||
if err != nil {
|
||||
log.Error("Point: Failed to create inbound connection handler: ", err)
|
||||
return nil, err
|
||||
|
||||
@@ -93,10 +93,12 @@ func NewPoint(pConfig *Config) (*Point, error) {
|
||||
ichConfig := pConfig.InboundConfig.Settings
|
||||
ich, err := proxyrepo.CreateInboundHandler(
|
||||
pConfig.InboundConfig.Protocol, vpoint.space, ichConfig, &proxy.InboundHandlerMeta{
|
||||
Tag: "system.inbound",
|
||||
Address: pConfig.InboundConfig.ListenOn,
|
||||
Port: vpoint.port,
|
||||
StreamSettings: pConfig.InboundConfig.StreamSettings})
|
||||
Tag: "system.inbound",
|
||||
Address: pConfig.InboundConfig.ListenOn,
|
||||
Port: vpoint.port,
|
||||
StreamSettings: pConfig.InboundConfig.StreamSettings,
|
||||
AllowPassiveConnection: pConfig.InboundConfig.AllowPassiveConnection,
|
||||
})
|
||||
if err != nil {
|
||||
log.Error("Failed to create inbound connection handler: ", err)
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user