Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support bandwidth configuration #645

Merged
merged 8 commits into from
Sep 26, 2024
4 changes: 3 additions & 1 deletion component/outbound/dialer/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ func NewGlobalOption(global *config.Global, log *logrus.Logger) *GlobalOption {
ExtraOption: D.ExtraOption{
AllowInsecure: global.AllowInsecure,
TlsImplementation: global.TlsImplementation,
UtlsImitate: global.UtlsImitate},
UtlsImitate: global.UtlsImitate,
BandwidthMaxTx: global.BandwidthMaxTx,
BandwidthMaxRx: global.BandwidthMaxRx},
Log: log,
TcpCheckOptionRaw: TcpCheckOptionRaw{Raw: global.TcpCheckUrl, Log: log, ResolverNetwork: common.MagicNetwork("udp", global.SoMarkFromDae, global.Mptcp), Method: global.TcpCheckHttpMethod},
CheckDnsOptionRaw: CheckDnsOptionRaw{Raw: global.UdpCheckDns, ResolverNetwork: common.MagicNetwork("udp", global.SoMarkFromDae, global.Mptcp), Somark: global.SoMarkFromDae},
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type Global struct {
UtlsImitate string `mapstructure:"utls_imitate" default:"chrome_auto"`
PprofPort uint16 `mapstructure:"pprof_port" default:"0"`
Mptcp bool `mapstructure:"mptcp" default:"false"`
// TODO: support input in human-readable format (e.g., 100Mbps, 1Gbps)
BandwidthMaxTx uint64 `mapstructure:"bandwidth_max_tx" default:"0"`
BandwidthMaxRx uint64 `mapstructure:"bandwidth_max_rx" default:"0"`
}

type Utls struct {
Expand Down
5 changes: 5 additions & 0 deletions example.dae
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ global {
# Multipath TCP (MPTCP) support. If is true, dae will try to use MPTCP to connect all nodes, but it will only take
# effects when the node supports MPTCP. It can use for load balance and failover to multiple interfaces and IPs.
mptcp: false

# The maximum bandwidth for accessing the Internet. It is useful for some specific protocols (e.g., Hysteria2),
# which will perform better with bandwith information provided. The unit is **byte** per second.
bandwidth_max_tx: 26214400 # 200Mbps == 25MB/s == 26214400 B/s uplink
mnixry marked this conversation as resolved.
Show resolved Hide resolved
bandwidth_max_rx: 131072000 # 1Gbps == 125MB/s == 131072000 B/s downlink
}

# Subscriptions defined here will be resolved as nodes and merged as a part of the global node pool.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ require (
google.golang.org/grpc v1.57.0 // indirect
)

// replace github.com/daeuniverse/outbound => ../outbound
replace github.com/daeuniverse/outbound => github.com/mnixry/outbound v0.0.0-20240919190537-75554f8247d9

// replace github.com/daeuniverse/quic-go => ../quic-go

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d h1:hnC39MjR7xt5kZjrKlef7DXKFDkiX8MIcDXYC/6Jf9Q=
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d/go.mod h1:VGWGgv7pCP5WGyHGUyb9+nq/gW0yBm+i/GfCNATOJ1M=
github.com/daeuniverse/outbound v0.0.0-20240911144232-d470a59233a5 h1:L450vqT1TO+Ygzd8buBMna8d4/0asT0q74qitGTWSl4=
github.com/daeuniverse/outbound v0.0.0-20240911144232-d470a59233a5/go.mod h1:0dkFMC58MVUWMB19jwQuXEg1G16uAIAtdAU7v+yWXYs=
github.com/daeuniverse/quic-go v0.0.0-20240413031024-943f218e0810 h1:YtEYouFaNrg9sV9vf3UabvKShKn6sD0QaCdOxCwaF3g=
github.com/daeuniverse/quic-go v0.0.0-20240413031024-943f218e0810/go.mod h1:61o2uZUGLrlv1i+oO2rx9sVX0vbf8cHzdSHt7h6lMnM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -113,6 +111,8 @@ github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Cl
github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=
github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4=
github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY=
github.com/mnixry/outbound v0.0.0-20240919190537-75554f8247d9 h1:yZqhyMYwxnPYf/dhuiCemGj03RCplvj6+sO+lZojJHw=
github.com/mnixry/outbound v0.0.0-20240919190537-75554f8247d9/go.mod h1:0dkFMC58MVUWMB19jwQuXEg1G16uAIAtdAU7v+yWXYs=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
Loading