Skip to content

Commit

Permalink
Add config for tuna nanopay txn fee
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed Mar 16, 2022
1 parent 628533f commit 013b427
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ type Config struct {

Tuna bool `json:"tuna,omitempty" short:"t" long:"tuna" description:"Enable tuna sessions"`
TunaMaxPrice string `json:"tunaMaxPrice,omitempty" long:"tuna-max-price" description:"(server only) Tuna max price in unit of NKN/MB. Can also be a url where the price will be get dynamically at launch." default:"0.01"`
TunaMinFee string `json:"tunaMinFee,omitempty" long:"tuna-min-fee" description:"(server only) Tuna nanopay minimal txn fee" default:"0.00001"`
TunaFeeRatio float64 `json:"tunaFeeRatio,omitempty" long:"tuna-fee-ratio" description:"(server only) Tuna nanopay txn fee ratio" default:"0.1"`
TunaCountry []string `json:"tunaCountry,omitempty" long:"tuna-country" description:"(server only) Tuna service node allowed country code, e.g. US. All countries will be allowed if not provided"`
TunaServiceName string `json:"tunaServiceName,omitempty" long:"tuna-service-name" description:"(server only) Tuna reverse service name"`
TunaAllowNknAddr []string `json:"tunaAllowNknAddr,omitempty" long:"tuna-allow-nkn-addr" description:"(server only) Tuna service node allowed NKN address. All NKN address will be allowed if not provided"`
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ require (
github.com/imdario/mergo v0.3.9
github.com/jessevdk/go-flags v1.4.0
github.com/nknorg/ncp-go v1.0.4-0.20220224111535-206abfb10fe8
github.com/nknorg/nkn-sdk-go v1.3.9
github.com/nknorg/nkn-tuna-session v0.2.3
github.com/nknorg/nkn-tunnel v0.3.3
github.com/nknorg/nkn-sdk-go v1.4.0
github.com/nknorg/nkn-tuna-session v0.2.5-0.20220316092834-0446308e0a84
github.com/nknorg/nkn-tunnel v0.3.4
github.com/nknorg/nkn/v2 v2.1.8
github.com/nknorg/nkngomobile v0.0.0-20220125080321-848ddd2e5157
github.com/nknorg/tuna v0.0.0-20220302233614-3ae01fd5b74f
github.com/nknorg/tuna v0.0.0-20220314110655-e94a8631389d
github.com/shadowsocks/go-shadowsocks2 v0.1.2
github.com/songgao/water v0.0.0-20190725173103-fd331bda3f4b
gopkg.in/natefinch/lumberjack.v2 v2.0.0
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ github.com/nknorg/ncp-go v1.0.3/go.mod h1:ALtnk9lKKSwoOXatbfLLQvQWGkRnJomrmbTZjv
github.com/nknorg/ncp-go v1.0.4-0.20220224111535-206abfb10fe8 h1:TZixgFaQI8UaA9cKJ0DX/m48AnLWbsnNw+9SoNY/HNY=
github.com/nknorg/ncp-go v1.0.4-0.20220224111535-206abfb10fe8/go.mod h1:ALtnk9lKKSwoOXatbfLLQvQWGkRnJomrmbTZjvg810E=
github.com/nknorg/nkn-sdk-go v1.3.7/go.mod h1:JSksFP+VQ0S54Ztiht6WHC3tNZklcGg+JaxENuFnqRc=
github.com/nknorg/nkn-sdk-go v1.3.9 h1:I/18Tf/D7cALo9foMUAvnK2wEJML+cQuC2erDCDdJZA=
github.com/nknorg/nkn-sdk-go v1.3.9/go.mod h1:/2FtpRM4mWpze03V8FIoESQCa6wCdPRPQO9HqpIMNYw=
github.com/nknorg/nkn-tuna-session v0.2.3 h1:DBv0DomiDhbxSCNyaVBDtm+cjkWMeJkiqy3bnk7t2FA=
github.com/nknorg/nkn-tuna-session v0.2.3/go.mod h1:s7W6GmPfFULKonw32En4vqqmkqNYRepWuZY2vudqX2Q=
github.com/nknorg/nkn-tunnel v0.3.3 h1:4D3DCtkCPx4RqpfqCCMip01uirO2uaST+R7lU9gBkHc=
github.com/nknorg/nkn-tunnel v0.3.3/go.mod h1:vK/Jn15Wr3TH4d0Yq2kASGPeA5mBMK33ZkMyuTHkkBA=
github.com/nknorg/nkn-sdk-go v1.4.0 h1:1rBhjLBfAoOWIkvV837nkjQ9CdTa+X1kmR8a1kLhGtM=
github.com/nknorg/nkn-sdk-go v1.4.0/go.mod h1:/2FtpRM4mWpze03V8FIoESQCa6wCdPRPQO9HqpIMNYw=
github.com/nknorg/nkn-tuna-session v0.2.5-0.20220316092834-0446308e0a84 h1:Dy27irtZ1+CEy7pNRqrMCkIfuGvusIKkMM611dw+xm4=
github.com/nknorg/nkn-tuna-session v0.2.5-0.20220316092834-0446308e0a84/go.mod h1:KhlcmTIZW8U+5A5/jwpOp6kOJrFZDsqQiKlQmD5p9+s=
github.com/nknorg/nkn-tunnel v0.3.4 h1:i4KVKATjFPdV3j6LZaTaT+l4k5/wzgkAPnjoiRoUA3E=
github.com/nknorg/nkn-tunnel v0.3.4/go.mod h1:cneKiKItaOJva3i2cD24NruuSOe/l9Kx4+he9KPxNxM=
github.com/nknorg/nkn/v2 v2.0.6/go.mod h1:cXl2WTv72trEXKJiNH0dCMygMtL8nJne07dWajDlRIo=
github.com/nknorg/nkn/v2 v2.1.7/go.mod h1:4xzrHJCI/FDFZmlt606Mn9ScKY4UUCFoaWydL1TzQRs=
github.com/nknorg/nkn/v2 v2.1.8 h1:h25rqQ0E8CvlN8Jm4zF6CBBLgwdoSS7HHdrU4ZYcmjA=
Expand All @@ -286,8 +286,8 @@ github.com/nknorg/nnet v0.0.0-20200521002812-357d1b11179f/go.mod h1:4DHEQEMhlRGI
github.com/nknorg/nnet v0.0.0-20210516000534-f80d3763d1bd/go.mod h1:4DHEQEMhlRGIKGSyhATdjeusdqaHafDatadtpeHBpvI=
github.com/nknorg/nnet v0.0.0-20220217113219-4d27780990b1/go.mod h1:4DHEQEMhlRGIKGSyhATdjeusdqaHafDatadtpeHBpvI=
github.com/nknorg/portmapper v0.0.0-20200114081049-1c03cdccc283/go.mod h1:dL4PQJ4670oTO6LqvkjrBQEkD+iMiOYjlKRBBw55Csg=
github.com/nknorg/tuna v0.0.0-20220302233614-3ae01fd5b74f h1:coJ3HqMLh8dk3PFJ8O/pQYgeEkYECYG9N5AMEtbBnyM=
github.com/nknorg/tuna v0.0.0-20220302233614-3ae01fd5b74f/go.mod h1:wK0ppDQvQmnWatTmjMlaKdkYoLKrZnPgqJwvM8VYJ3g=
github.com/nknorg/tuna v0.0.0-20220314110655-e94a8631389d h1:4O2Jj8GH6l1FjDcqzz1n4N3lVLsf8rtVAfhDM53Odik=
github.com/nknorg/tuna v0.0.0-20220314110655-e94a8631389d/go.mod h1:fOsOYvGJqwhLxgDaeWxCrO/13sSmx6URQjMjPPAITFI=
github.com/nrdcg/auroradns v1.0.1/go.mod h1:y4pc0i9QXYlFCWrhWrUSIETnZgrf4KuwjDIWmmXo3JI=
github.com/nrdcg/dnspod-go v0.4.0/go.mod h1:vZSoFSFeQVm2gWLMkyX61LZ8HI3BaqtHZWgPTGKr6KQ=
github.com/nrdcg/goinwx v0.7.0/go.mod h1:4tKJOCi/1lTxuw9/yB2Ez0aojwtUCSkckjc22eALpqE=
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ func main() {

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,
Expand Down Expand Up @@ -494,7 +496,7 @@ func getRemotePrice(url string) (string, error) {
client := http.Client{
Timeout: 10 * time.Second,
}
resp, err := client.Get(opts.TunaMaxPrice)
resp, err := client.Get(url)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 013b427

Please sign in to comment.