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/optimize(hy2): support human-readable bandwidth configuration #666

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion component/outbound/dialer_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/daeuniverse/dae/component/outbound/dialer"
"github.com/daeuniverse/dae/pkg/logger"
"github.com/daeuniverse/outbound/pkg/fastrand"
"github.com/sirupsen/logrus"
)

const (
Expand All @@ -26,7 +27,11 @@ var TestNetworkType = &dialer.NetworkType{
IsDns: false,
}

var log = logger.NewLogger("trace", false, nil)
var log = logrus.New()

func init() {
logger.SetLogger(log, "trace", false, nil)
}

func newDirectDialer(option *dialer.GlobalOption, fullcone bool) *dialer.Dialer {
_d, p := dialer.NewDirectDialer(option, true)
Expand Down
5 changes: 2 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ 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"`
BandwidthMaxTx string `mapstructure:"bandwidth_max_tx" default:"0"`
BandwidthMaxRx string `mapstructure:"bandwidth_max_rx" default:"0"`
}

type Utls struct {
Expand Down
9 changes: 5 additions & 4 deletions example.dae
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ global {
# 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
bandwidth_max_rx: 131072000 # 1Gbps == 125MB/s == 131072000 B/s downlink
# 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 can be b, kb, mb, gb, tb or bytes per second.
# supported formats: https://v2.hysteria.network/docs/advanced/Full-Client-Config/#bandwidth
bandwidth_max_tx: '200 mbps' # uplink, or '200 m' or '200 mb' or '200 mbps' or 25000000(which is 200/8*1000*1000)
bandwidth_max_rx: '1 gbps' # downlink, or '1 g' or '1 gb' or '1 gbps' or 125000000(which is 1000/8*1000*1000)
mzz2017 marked this conversation as resolved.
Show resolved Hide resolved
}

# 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 @@ -8,7 +8,7 @@ require (
github.com/bits-and-blooms/bloom/v3 v3.7.0
github.com/cilium/ebpf v0.15.0
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d
github.com/daeuniverse/outbound v0.0.0-20240928042419-b1e258193113
github.com/daeuniverse/outbound v0.0.0-20241026154416-424675853298
github.com/fsnotify/fsnotify v1.7.0
github.com/json-iterator/go v1.1.12
github.com/mholt/archiver/v3 v3.5.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c276
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-20240928042419-b1e258193113 h1:m2GVle7Mdllco1bUshzvFz4RXI+2Nif1mTGaJsE91+w=
github.com/daeuniverse/outbound v0.0.0-20240928042419-b1e258193113/go.mod h1:aR0y8VzpD7RJ5ZGD5ooe0MC6wfTzkIEYaGyxztJqG94=
github.com/daeuniverse/outbound v0.0.0-20241026154416-424675853298 h1:MSTgM94DnFdOKO3/m0UjTwGML7Fv7EJe7c5OL4YmymI=
github.com/daeuniverse/outbound v0.0.0-20241026154416-424675853298/go.mod h1:aR0y8VzpD7RJ5ZGD5ooe0MC6wfTzkIEYaGyxztJqG94=
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
Loading