File tree Expand file tree Collapse file tree 4 files changed +20
-22
lines changed
Expand file tree Collapse file tree 4 files changed +20
-22
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package libp2p
33import (
44 "time"
55
6- "github.com/ipfs/go-ipfs-config"
6+ config "github.com/ipfs/go-ipfs-config"
77 "github.com/libp2p/go-libp2p"
88)
99
@@ -13,14 +13,12 @@ func AutoNATService(throttle *config.AutoNATThrottleConfig) func() Libp2pOpts {
1313 return func () (opts Libp2pOpts ) {
1414 opts .Opts = append (opts .Opts , libp2p .EnableNATService ())
1515 if throttle != nil {
16- global := throttle .GlobalLimit
17- peer := throttle .PeerLimit
18- interval := time .Duration (throttle .Interval )
19- if interval == 0 {
20- interval = time .Minute
21- }
2216 opts .Opts = append (opts .Opts ,
23- libp2p .AutoNATServiceRateLimit (global , peer , interval ),
17+ libp2p .AutoNATServiceRateLimit (
18+ throttle .GlobalLimit ,
19+ throttle .PeerLimit ,
20+ throttle .Interval .WithDefault (time .Minute ),
21+ ),
2422 )
2523 }
2624 return opts
Original file line number Diff line number Diff line change @@ -24,24 +24,22 @@ func RelayService(enable bool, relayOpts config.RelayService) func() (opts Libp2
2424 return func () (opts Libp2pOpts , err error ) {
2525 if enable {
2626 r := relay .DefaultResources ()
27- if i := int64 ( relayOpts .Limit . Data . WithDefault ( 0 )); i > 0 {
28- r .Limit .Data = i
29- }
30- /* TODO: swap when https://github.com/ipfs/go-ipfs-config/pull/148 lands
31- if i := int(relayOpts.Limit.Duration.WithDefault(0)); i > 0 { */
32- if i := int ( relayOpts .Limit .Duration ); i > 0 {
33- r . Limit . Duration = time . Duration ( relayOpts . Limit . Duration )
27+ if relayOpts .Limit != nil {
28+ if i := int64 ( relayOpts .Limit .Data . WithDefault ( 0 )); i > 0 {
29+ r . Limit . Data = i
30+ }
31+ if i := int (relayOpts .Limit .Duration .WithDefault (0 )); i > 0 {
32+ r .Limit .Duration = time . Duration ( i )
33+ }
3434 }
3535 if i := int (relayOpts .MaxCircuits .WithDefault (0 )); i > 0 {
3636 r .MaxCircuits = i
3737 }
3838 if i := int (relayOpts .BufferSize .WithDefault (0 )); i > 0 {
3939 r .BufferSize = i
4040 }
41- /* TODO: swap when https://github.com/ipfs/go-ipfs-config/pull/148 lands
42- if i := int(relayOpts.ReservationTTL.WithDefault(0)); i > 0 { */
43- if i := int (relayOpts .ReservationTTL ); i > 0 {
44- r .ReservationTTL = time .Duration (relayOpts .ReservationTTL )
41+ if i := int (relayOpts .ReservationTTL .WithDefault (0 )); i > 0 {
42+ r .ReservationTTL = time .Duration (i )
4543 }
4644 if i := int (relayOpts .MaxReservations .WithDefault (0 )); i > 0 {
4745 r .MaxReservations = i
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ require (
3030 github.com/ipfs/go-ipfs-blockstore v0.1.6
3131 github.com/ipfs/go-ipfs-chunker v0.0.5
3232 github.com/ipfs/go-ipfs-cmds v0.6.0
33- github.com/ipfs/go-ipfs-config v0.16.1-0.20211026210306-0fb5b58a4e11
33+ github.com/ipfs/go-ipfs-config v0.16.1-0.20211027175806-8e9dc6a34ccb
3434 github.com/ipfs/go-ipfs-exchange-interface v0.0.1
3535 github.com/ipfs/go-ipfs-exchange-offline v0.0.1
3636 github.com/ipfs/go-ipfs-files v0.0.9
Original file line number Diff line number Diff line change @@ -463,8 +463,10 @@ github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7Na
463463github.com/ipfs/go-ipfs-chunker v0.0.5 /go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8 =
464464github.com/ipfs/go-ipfs-cmds v0.6.0 h1:yAxdowQZzoFKjcLI08sXVNnqVj3jnABbf9smrPQmBsw =
465465github.com/ipfs/go-ipfs-cmds v0.6.0 /go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk =
466- github.com/ipfs/go-ipfs-config v0.16.1-0.20211026210306-0fb5b58a4e11 h1:2dQQwVI/WAmmWBJc8SkEQsQOTw99vMFqcfMw0PnNbJ0 =
467- github.com/ipfs/go-ipfs-config v0.16.1-0.20211026210306-0fb5b58a4e11 /go.mod h1:wz2lKzOjgJeYJa6zx8W9VT7mz+iSd0laBMqS/9wmX6A =
466+ github.com/ipfs/go-ipfs-config v0.16.1-0.20211027170342-c46fe1bdc3f6 h1:OZmM5FOD8OW7p7stULH3p4+TaOQ45lHTI4GXhfk2tus =
467+ github.com/ipfs/go-ipfs-config v0.16.1-0.20211027170342-c46fe1bdc3f6 /go.mod h1:wz2lKzOjgJeYJa6zx8W9VT7mz+iSd0laBMqS/9wmX6A =
468+ github.com/ipfs/go-ipfs-config v0.16.1-0.20211027175806-8e9dc6a34ccb h1:mBnVO/t/X1qOLOI6qlnvisaTiZCV+Cc/3oM1ZMfMm0Q =
469+ github.com/ipfs/go-ipfs-config v0.16.1-0.20211027175806-8e9dc6a34ccb /go.mod h1:wz2lKzOjgJeYJa6zx8W9VT7mz+iSd0laBMqS/9wmX6A =
468470github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8 /go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw =
469471github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ =
470472github.com/ipfs/go-ipfs-delay v0.0.1 /go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw =
You can’t perform that action at this time.
0 commit comments