From 7d1e3cf8fcf0d35e8a6c0aaa8c837ba9a87612cd Mon Sep 17 00:00:00 2001 From: Yilun Date: Fri, 14 Jul 2023 16:51:57 -0700 Subject: [PATCH] Add TunaMeasureBandwidthBytes config Signed-off-by: Yilun --- config/config.go | 1 + go.mod | 6 +++--- go.sum | 12 ++++++------ nconnect.go | 23 ++++++++++++----------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/config/config.go b/config/config.go index 6d86dd0..52123f1 100644 --- a/config/config.go +++ b/config/config.go @@ -105,6 +105,7 @@ type Config struct { TunaGeoDBPath string `json:"tunaGeoDBPath,omitempty" long:"tuna-geo-db-path" description:"(server only) Path to store Tuna geo db" default:"."` TunaDisableMeasureBandwidth bool `json:"tunaDisableMeasureBandwidth,omitempty" long:"tuna-disable-measure-bandwidth" description:"(server only) Disable Tuna measure bandwidth when selecting service nodes"` TunaMeasureStoragePath string `json:"tunaMeasureStoragePath,omitempty" long:"tuna-measure-storage-path" description:"(server only) Path to store Tuna measurement results" default:"."` + TunaMeasureBandwidthBytes int32 `json:"tunaMeasureBandwidthBytes,omitempty" long:"tuna-measure-bandwidth-bytes" description:"(server only) Tuna measure bandwidth bytes to transmit when selecting service nodes" default:"1"` // UDP config UDP bool `json:"udp,omitempty" long:"udp" description:"Support udp proxy"` diff --git a/go.mod b/go.mod index 45035de..76e0dfc 100644 --- a/go.mod +++ b/go.mod @@ -10,11 +10,11 @@ require ( github.com/jessevdk/go-flags v1.5.0 github.com/nknorg/ncp-go v1.0.6-0.20230228002512-f4cd1740bebd github.com/nknorg/nkn-sdk-go v1.4.6-0.20230404044330-ad192f36d07e - github.com/nknorg/nkn-tuna-session v0.2.6-0.20230512052928-f91bbbdcdaf6 - github.com/nknorg/nkn-tunnel v0.3.5-0.20230621222635-47610787d9ae + github.com/nknorg/nkn-tuna-session v0.2.6-0.20230714232320-9731b0d0271e + github.com/nknorg/nkn-tunnel v0.3.5-0.20230714234115-9f9532fad9f5 github.com/nknorg/nkn/v2 v2.2.0 github.com/nknorg/nkngomobile v0.0.0-20220615081414-671ad1afdfa9 - github.com/nknorg/tuna v0.0.0-20230405223335-eb60c60c5953 + github.com/nknorg/tuna v0.0.0-20230713132943-1604365ad8c9 github.com/shadowsocks/go-shadowsocks2 v0.1.2 github.com/stretchr/testify v1.8.1 github.com/txthinking/brook v0.0.0-20230418095906-76ced63f1803 diff --git a/go.sum b/go.sum index 867bf88..a39e238 100644 --- a/go.sum +++ b/go.sum @@ -114,16 +114,16 @@ github.com/nknorg/ncp-go v1.0.6-0.20230228002512-f4cd1740bebd h1:ZAXKeWKjkbS9QQh github.com/nknorg/ncp-go v1.0.6-0.20230228002512-f4cd1740bebd/go.mod h1:T7ThlxmBjVIv3Ll3gJOHbQTuAFN3ZCYWvbux6JOX5wQ= github.com/nknorg/nkn-sdk-go v1.4.6-0.20230404044330-ad192f36d07e h1:lWKUEfqOJ9NImCX60Bden+Y6VgRDhlx4gc6B09S32RQ= github.com/nknorg/nkn-sdk-go v1.4.6-0.20230404044330-ad192f36d07e/go.mod h1:mnI1+17p2cI+5wv+3CWRyCjSALqUg5k1jTaWC2h0f/M= -github.com/nknorg/nkn-tuna-session v0.2.6-0.20230512052928-f91bbbdcdaf6 h1:S+HzmSp4Yd97+X9xZ5AmcQgkbstEry+hfl8O42dX/kA= -github.com/nknorg/nkn-tuna-session v0.2.6-0.20230512052928-f91bbbdcdaf6/go.mod h1:47W1/1axI4aOkQKtkjjRHW1x2SYrdCRI49LdPWf9vMc= -github.com/nknorg/nkn-tunnel v0.3.5-0.20230621222635-47610787d9ae h1:cuexnKy8/RWm6WBIjqCjaGd/cUHDB1wQsTWiOR2Eagw= -github.com/nknorg/nkn-tunnel v0.3.5-0.20230621222635-47610787d9ae/go.mod h1:rOxPIUgtFwsZG1DEJM6mm/AfH3Z+le+oSEv8WhZ2LQA= +github.com/nknorg/nkn-tuna-session v0.2.6-0.20230714232320-9731b0d0271e h1:cClK7JrQaFbgzCEFYr3+0LCegQni/ZT5Q0gllN2mP2c= +github.com/nknorg/nkn-tuna-session v0.2.6-0.20230714232320-9731b0d0271e/go.mod h1:7WqPG+3rQTW8RiqXopgNqwKp3PFVV/zcoHomH7X8V2A= +github.com/nknorg/nkn-tunnel v0.3.5-0.20230714234115-9f9532fad9f5 h1:i7VZ2bCbpSs7/sgyEoiZHReqRbm4bFmjf0CQwsjeFoU= +github.com/nknorg/nkn-tunnel v0.3.5-0.20230714234115-9f9532fad9f5/go.mod h1:fw7qTKkPNhnmZ5rypS09PRQOi16d42+2QsRUuKPWsN0= github.com/nknorg/nkn/v2 v2.2.0 h1:sXOawvVF/T3bBTuWbzBCyrGuxldA3be+f+BDjoWcOEA= github.com/nknorg/nkn/v2 v2.2.0/go.mod h1:yv3jkg0aOtN9BDHS4yerNSZJtJNBfGvlaD5K6wL6U3E= github.com/nknorg/nkngomobile v0.0.0-20220615081414-671ad1afdfa9 h1:Gr37j7Ttvcn8g7TdC5fs6Y6IJKdmfqCvj03UbsrS77o= github.com/nknorg/nkngomobile v0.0.0-20220615081414-671ad1afdfa9/go.mod h1:zNY9NCyBcJCCDrXhwOjKarkW5cngPs/Z82xVNy/wvEA= -github.com/nknorg/tuna v0.0.0-20230405223335-eb60c60c5953 h1:nF2hRLsUZ+m6kB+LkLVdzlMKU2oFR2Q1qWtHw+0zBiQ= -github.com/nknorg/tuna v0.0.0-20230405223335-eb60c60c5953/go.mod h1:Ngge8vIVM0DPmy6xCT19/zXR3y7FsgiWsyX4V+Uq848= +github.com/nknorg/tuna v0.0.0-20230713132943-1604365ad8c9 h1:9g/qZ56Vut7njbtnfU8gQXonEDbTn8S3fCbEva9dLDY= +github.com/nknorg/tuna v0.0.0-20230713132943-1604365ad8c9/go.mod h1:Ngge8vIVM0DPmy6xCT19/zXR3y7FsgiWsyX4V+Uq848= github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI= github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= diff --git a/nconnect.go b/nconnect.go index 2b33efb..95fa227 100644 --- a/nconnect.go +++ b/nconnect.go @@ -209,17 +209,18 @@ func NewNconnect(opts *config.Opts) (*nconnect, error) { } tsConfig := &ts.Config{ - TunaMaxPrice: opts.TunaMaxPrice, - TunaMinNanoPayFee: opts.TunaMinFee, - TunaNanoPayFeeRatio: opts.TunaFeeRatio, - TunaIPFilter: &geo.IPFilter{Allow: allowedIP, Disallow: disallowedIP}, - TunaNknFilter: &filter.NknFilter{Allow: allowedNknAddrs, Disallow: disallowedNknAddrs}, - TunaServiceName: opts.TunaServiceName, - TunaDownloadGeoDB: !opts.TunaDisableDownloadGeoDB, - TunaGeoDBPath: opts.TunaGeoDBPath, - TunaMeasureBandwidth: !opts.TunaDisableMeasureBandwidth, - TunaMeasureStoragePath: opts.TunaMeasureStoragePath, - TunaMinBalance: opts.TunaMinBalance, + TunaMaxPrice: opts.TunaMaxPrice, + TunaMinNanoPayFee: opts.TunaMinFee, + TunaNanoPayFeeRatio: opts.TunaFeeRatio, + TunaIPFilter: &geo.IPFilter{Allow: allowedIP, Disallow: disallowedIP}, + TunaNknFilter: &filter.NknFilter{Allow: allowedNknAddrs, Disallow: disallowedNknAddrs}, + TunaServiceName: opts.TunaServiceName, + TunaDownloadGeoDB: !opts.TunaDisableDownloadGeoDB, + TunaGeoDBPath: opts.TunaGeoDBPath, + TunaMeasureBandwidth: !opts.TunaDisableMeasureBandwidth, + TunaMeasureStoragePath: opts.TunaMeasureStoragePath, + TunaMeasurementBytesDownLink: opts.TunaMeasureBandwidthBytes, + TunaMinBalance: opts.TunaMinBalance, } if opts.SessionWindowSize > 0 {