mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
Merge branch 'master' into websockwt
This commit is contained in:
+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)
|
||||
@@ -80,7 +81,7 @@ func (this *InboundConnectionConfig) UnmarshalJSON(data []byte) error {
|
||||
this.Port = v2net.Port(jsonConfig.Port)
|
||||
this.ListenOn = v2net.AnyIP
|
||||
if jsonConfig.Listen != nil {
|
||||
if jsonConfig.Listen.Address.IsDomain() {
|
||||
if jsonConfig.Listen.Address.Family().IsDomain() {
|
||||
return errors.New("Point: Unable to listen on domain address: " + jsonConfig.Listen.Address.Domain())
|
||||
}
|
||||
this.ListenOn = jsonConfig.Listen.Address
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -110,7 +112,7 @@ func (this *OutboundConnectionConfig) UnmarshalJSON(data []byte) error {
|
||||
|
||||
if jsonConfig.SendThrough != nil {
|
||||
address := jsonConfig.SendThrough.Address
|
||||
if address.IsDomain() {
|
||||
if address.Family().IsDomain() {
|
||||
return errors.New("Point: Unable to send through: " + address.String())
|
||||
}
|
||||
this.SendThrough = address
|
||||
@@ -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 {
|
||||
@@ -197,7 +200,7 @@ func (this *InboundDetourConfig) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
this.ListenOn = v2net.AnyIP
|
||||
if jsonConfig.ListenOn != nil {
|
||||
if jsonConfig.ListenOn.Address.IsDomain() {
|
||||
if jsonConfig.ListenOn.Address.Family().IsDomain() {
|
||||
return errors.New("Point: Unable to listen on domain address: " + jsonConfig.ListenOn.Address.Domain())
|
||||
}
|
||||
this.ListenOn = jsonConfig.ListenOn.Address
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -237,7 +241,7 @@ func (this *OutboundDetourConfig) UnmarshalJSON(data []byte) error {
|
||||
|
||||
if jsonConfig.SendThrough != nil {
|
||||
address := jsonConfig.SendThrough.Address
|
||||
if address.IsDomain() {
|
||||
if address.Family().IsDomain() {
|
||||
return errors.New("Point: Unable to send through: " + address.String())
|
||||
}
|
||||
this.SendThrough = address
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"github.com/v2ray/v2ray-core"
|
||||
_ "github.com/v2ray/v2ray-core/app/router/rules"
|
||||
@@ -29,6 +30,7 @@ import (
|
||||
|
||||
_ "github.com/v2ray/v2ray-core/transport/internet/authenticators/noop"
|
||||
_ "github.com/v2ray/v2ray-core/transport/internet/authenticators/srtp"
|
||||
_ "github.com/v2ray/v2ray-core/transport/internet/authenticators/utp"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -107,7 +109,7 @@ func main() {
|
||||
|
||||
if point := startV2Ray(); point != nil {
|
||||
osSignals := make(chan os.Signal, 1)
|
||||
signal.Notify(osSignals, os.Interrupt, os.Kill)
|
||||
signal.Notify(osSignals, os.Interrupt, os.Kill, syscall.SIGTERM)
|
||||
|
||||
<-osSignals
|
||||
point.Close()
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// +build coveragemain
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRunMainForCoverage(t *testing.T) {
|
||||
main()
|
||||
}
|
||||
@@ -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