From 1fed07094b95083b717c6be3b01221b0dbd9ca31 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Wed, 27 Jan 2021 17:13:13 +0530 Subject: [PATCH 01/17] event for NAT device type --- event/nattype.go | 8 ++++++++ network/nattype.go | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 event/nattype.go create mode 100644 network/nattype.go diff --git a/event/nattype.go b/event/nattype.go new file mode 100644 index 00000000..74e1c86b --- /dev/null +++ b/event/nattype.go @@ -0,0 +1,8 @@ +package event + +import "github.com/libp2p/go-libp2p-core/network" + +// EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes. +type EvtNATDeviceTypeChanged struct { + NatDeviceType network.NATDeviceType +} diff --git a/network/nattype.go b/network/nattype.go new file mode 100644 index 00000000..a60e3e8e --- /dev/null +++ b/network/nattype.go @@ -0,0 +1,18 @@ +package network + +// NATDeviceType indicates the type of the NAT device i.e. whether it is a Hard or an Easy NAT. +type NATDeviceType int + +const ( + // NATDeviceTypeUnknown indicates that the type of the NAT device is unknown. + NATDeviceTypeUnknown NATDeviceType = iota + + // NATDeviceTypeEasy indicates that the NAT device is an Easy NAT i.e. it supports consistent endpoint translation. + // NAT traversal via hole punching is possible with this NAT type if the remote peer is also behind an Easy NAT. + NATDeviceTypeEasy + + // NATDeviceTypeHard indicates that the NAT device is a Hard NAT that does NOT support + // consistent endpoint translation. + // NAT traversal via hole-punching is NOT possible with this NAT type irrespective of the remote peer's NAT type. + NATDeviceTypeHard +) From 7262bc034e1cc88d82c187d0ae656634b9108de8 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Wed, 27 Jan 2021 17:47:30 +0530 Subject: [PATCH 02/17] emit NAT type --- network/nattype.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/network/nattype.go b/network/nattype.go index a60e3e8e..589c814b 100644 --- a/network/nattype.go +++ b/network/nattype.go @@ -16,3 +16,11 @@ const ( // NAT traversal via hole-punching is NOT possible with this NAT type irrespective of the remote peer's NAT type. NATDeviceTypeHard ) + +func (r NATDeviceType) String() string { + str := [...]string{"Unknown", "Easy", "Hard"} + if r < 0 || int(r) >= len(str) { + return "(unrecognized)" + } + return str[r] +} From 3267df19099a1ba68aa32103b13e925efeb2ef04 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Wed, 27 Jan 2021 20:13:36 +0530 Subject: [PATCH 03/17] add transport protocol to NAT event --- event/nattype.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/event/nattype.go b/event/nattype.go index 74e1c86b..97f1a463 100644 --- a/event/nattype.go +++ b/event/nattype.go @@ -2,7 +2,18 @@ package event import "github.com/libp2p/go-libp2p-core/network" +// NATDeviceProtocol is the transport protocol for which the NAT Device Type has been determined. +type NATDeviceProtocol int + +const ( + // NATDeviceUDP means that the NAT Device Type has been determined for the UDP Protocol. + NATDeviceUDP NATDeviceProtocol = iota + // NATDeviceTCP means that the NAT Device Type has been determined for the TCP Protocol. + NATDeviceTCP +) + // EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes. type EvtNATDeviceTypeChanged struct { + Protocol NATDeviceProtocol NatDeviceType network.NATDeviceType } From 3723a852faa92486baf95367a8f39af15c9fab63 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Thu, 28 Jan 2021 15:10:21 +0530 Subject: [PATCH 04/17] event changes --- event/nattype.go | 25 +++++++++++++++++-------- network/nattype.go | 23 ++++++++++++++--------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/event/nattype.go b/event/nattype.go index 97f1a463..5bad1650 100644 --- a/event/nattype.go +++ b/event/nattype.go @@ -2,18 +2,27 @@ package event import "github.com/libp2p/go-libp2p-core/network" -// NATDeviceProtocol is the transport protocol for which the NAT Device Type has been determined. -type NATDeviceProtocol int +// NATTransportProtocol is the transport protocol for which the NAT Device Type has been determined. +type NATTransportProtocol int const ( - // NATDeviceUDP means that the NAT Device Type has been determined for the UDP Protocol. - NATDeviceUDP NATDeviceProtocol = iota - // NATDeviceTCP means that the NAT Device Type has been determined for the TCP Protocol. - NATDeviceTCP + // NATTransportUDP means that the NAT Device Type has been determined for the UDP Protocol. + NATTransportUDP NATTransportProtocol = iota + // NATTransportTCP means that the NAT Device Type has been determined for the TCP Protocol. + NATTransportTCP ) -// EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes. +// EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes for a Transport Protocol. +// +// Note: This event is meaningful ONLY if the AutoNAT Reachability is Private. +// Consumers of this event should ALSO consume the `EvtLocalReachabilityChanged` event and interpret +// this event ONLY if the Reachability on the `EvtLocalReachabilityChanged` is Private. type EvtNATDeviceTypeChanged struct { - Protocol NATDeviceProtocol + // TransportProtocol is the Transport Protocol for which the NAT Device Type has been determined. + TransportProtocol NATTransportProtocol + // NatDeviceType indicates the type of the NAT Device for the Transport Protocol. + // Currently, it can be either a `Cone NAT` or a `Symmetric NAT`. Please see the detailed documentation + // on `network.NATDeviceType` enumerations for a better understanding of what these types mean and + // how they impact Connectivity and Hole Punching. NatDeviceType network.NATDeviceType } diff --git a/network/nattype.go b/network/nattype.go index 589c814b..91d9a5fb 100644 --- a/network/nattype.go +++ b/network/nattype.go @@ -1,24 +1,29 @@ package network -// NATDeviceType indicates the type of the NAT device i.e. whether it is a Hard or an Easy NAT. +// NATDeviceType indicates the type of the NAT device. type NATDeviceType int const ( // NATDeviceTypeUnknown indicates that the type of the NAT device is unknown. NATDeviceTypeUnknown NATDeviceType = iota - // NATDeviceTypeEasy indicates that the NAT device is an Easy NAT i.e. it supports consistent endpoint translation. - // NAT traversal via hole punching is possible with this NAT type if the remote peer is also behind an Easy NAT. - NATDeviceTypeEasy + // NATDeviceTypeCone indicates that the NAT device is a Cone NAT. + // A Cone NAT is a NAT where all outgoing connections from the same source IP address and port are mapped by the NAT device + // to the same IP address and port irrespective of the destination address. + // With Regards to Internet Society RFC 3489, this could be either a Full Cone NAT, a Restricted Cone NAT or a + // Port Restricted Cone NAT. However, we do NOT differentiate between them here and simply classify all such NATs as a Cone NAT. + // NAT traversal with hole punching is possible with a Cone NAT if the remote peer is ALSO behind a Cone NAT. + NATDeviceTypeCone - // NATDeviceTypeHard indicates that the NAT device is a Hard NAT that does NOT support - // consistent endpoint translation. - // NAT traversal via hole-punching is NOT possible with this NAT type irrespective of the remote peer's NAT type. - NATDeviceTypeHard + // NATDeviceTypeHard indicates that the NAT device is a Symmetric NAT. + // A Symmetric NAT maps outgoing connections with different destination addresses to different IP addresses and ports + // even if they originate from the same source IP address and port. + // NAT traversal with hole-punching is currently NOT possible in libp2p with Symmetric NATs irrespective of the remote peer's NAT type. + NATDeviceTypeSymmetric ) func (r NATDeviceType) String() string { - str := [...]string{"Unknown", "Easy", "Hard"} + str := [...]string{"Unknown", "Cone", "Symmetric"} if r < 0 || int(r) >= len(str) { return "(unrecognized)" } From dfdf87fb04a03cd92b967368242f6dde82175cce Mon Sep 17 00:00:00 2001 From: Aarsh Shah Date: Mon, 1 Feb 2021 16:31:06 +0530 Subject: [PATCH 05/17] Update network/nattype.go Co-authored-by: Marten Seemann --- network/nattype.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/nattype.go b/network/nattype.go index 91d9a5fb..65b97c36 100644 --- a/network/nattype.go +++ b/network/nattype.go @@ -10,7 +10,7 @@ const ( // NATDeviceTypeCone indicates that the NAT device is a Cone NAT. // A Cone NAT is a NAT where all outgoing connections from the same source IP address and port are mapped by the NAT device // to the same IP address and port irrespective of the destination address. - // With Regards to Internet Society RFC 3489, this could be either a Full Cone NAT, a Restricted Cone NAT or a + // With regards to RFC 3489, this could be either a Full Cone NAT, a Restricted Cone NAT or a // Port Restricted Cone NAT. However, we do NOT differentiate between them here and simply classify all such NATs as a Cone NAT. // NAT traversal with hole punching is possible with a Cone NAT if the remote peer is ALSO behind a Cone NAT. NATDeviceTypeCone From 0d8b8c2f5a40b52fb5b245ad9f594974351f65ae Mon Sep 17 00:00:00 2001 From: Aarsh Shah Date: Mon, 1 Feb 2021 16:31:53 +0530 Subject: [PATCH 06/17] Update network/nattype.go Co-authored-by: Marten Seemann --- network/nattype.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/nattype.go b/network/nattype.go index 65b97c36..f3b879d7 100644 --- a/network/nattype.go +++ b/network/nattype.go @@ -15,7 +15,7 @@ const ( // NAT traversal with hole punching is possible with a Cone NAT if the remote peer is ALSO behind a Cone NAT. NATDeviceTypeCone - // NATDeviceTypeHard indicates that the NAT device is a Symmetric NAT. + // NATDeviceTypeSymmetric indicates that the NAT device is a Symmetric NAT. // A Symmetric NAT maps outgoing connections with different destination addresses to different IP addresses and ports // even if they originate from the same source IP address and port. // NAT traversal with hole-punching is currently NOT possible in libp2p with Symmetric NATs irrespective of the remote peer's NAT type. From ccd3fb866cc8de73d4cecba988496d3d817edd1d Mon Sep 17 00:00:00 2001 From: Aarsh Shah Date: Mon, 1 Feb 2021 16:32:07 +0530 Subject: [PATCH 07/17] Update network/nattype.go Co-authored-by: Marten Seemann --- network/nattype.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/nattype.go b/network/nattype.go index f3b879d7..62c55194 100644 --- a/network/nattype.go +++ b/network/nattype.go @@ -16,7 +16,7 @@ const ( NATDeviceTypeCone // NATDeviceTypeSymmetric indicates that the NAT device is a Symmetric NAT. - // A Symmetric NAT maps outgoing connections with different destination addresses to different IP addresses and ports + // A Symmetric NAT maps outgoing connections with different destination addresses to different IP addresses and ports, // even if they originate from the same source IP address and port. // NAT traversal with hole-punching is currently NOT possible in libp2p with Symmetric NATs irrespective of the remote peer's NAT type. NATDeviceTypeSymmetric From 5dc9f7fb766d70c7fdb59e4f1552b0570b09b11b Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Mon, 1 Feb 2021 16:41:01 +0530 Subject: [PATCH 08/17] removed alloc --- network/nattype.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/network/nattype.go b/network/nattype.go index 62c55194..af9d25d2 100644 --- a/network/nattype.go +++ b/network/nattype.go @@ -12,7 +12,8 @@ const ( // to the same IP address and port irrespective of the destination address. // With regards to RFC 3489, this could be either a Full Cone NAT, a Restricted Cone NAT or a // Port Restricted Cone NAT. However, we do NOT differentiate between them here and simply classify all such NATs as a Cone NAT. - // NAT traversal with hole punching is possible with a Cone NAT if the remote peer is ALSO behind a Cone NAT. + // NAT traversal with hole punching is possible with a Cone NAT ONLY if the remote peer is ALSO behind a Cone NAT. + // If the remote peer is behind a Symmetric NAT, hole punching will fail. NATDeviceTypeCone // NATDeviceTypeSymmetric indicates that the NAT device is a Symmetric NAT. @@ -23,9 +24,14 @@ const ( ) func (r NATDeviceType) String() string { - str := [...]string{"Unknown", "Cone", "Symmetric"} - if r < 0 || int(r) >= len(str) { - return "(unrecognized)" + switch r { + case 0: + return "Unknown" + case 1: + return "Cone" + case 2: + return "Symmetric" + default: + return "unrecognized" } - return str[r] } From 347293138838efd4dfa2e0612041c27e01141ab4 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Mon, 1 Feb 2021 17:59:16 +0530 Subject: [PATCH 09/17] NAT protocol to string --- event/nattype.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/event/nattype.go b/event/nattype.go index 5bad1650..e3819246 100644 --- a/event/nattype.go +++ b/event/nattype.go @@ -12,6 +12,17 @@ const ( NATTransportTCP ) +func (n NATTransportProtocol) String() string { + switch n { + case 0: + return "UDP" + case 1: + return "TCP" + default: + return "unrecognized" + } +} + // EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes for a Transport Protocol. // // Note: This event is meaningful ONLY if the AutoNAT Reachability is Private. From 7f4262e33da34147fa5bddbdf0c5099461c9fbea Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Tue, 2 Feb 2021 12:55:42 +0530 Subject: [PATCH 10/17] refactor packages --- event/nattype.go | 23 +---------------------- network/nattype.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/event/nattype.go b/event/nattype.go index e3819246..a24eb1a1 100644 --- a/event/nattype.go +++ b/event/nattype.go @@ -2,27 +2,6 @@ package event import "github.com/libp2p/go-libp2p-core/network" -// NATTransportProtocol is the transport protocol for which the NAT Device Type has been determined. -type NATTransportProtocol int - -const ( - // NATTransportUDP means that the NAT Device Type has been determined for the UDP Protocol. - NATTransportUDP NATTransportProtocol = iota - // NATTransportTCP means that the NAT Device Type has been determined for the TCP Protocol. - NATTransportTCP -) - -func (n NATTransportProtocol) String() string { - switch n { - case 0: - return "UDP" - case 1: - return "TCP" - default: - return "unrecognized" - } -} - // EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes for a Transport Protocol. // // Note: This event is meaningful ONLY if the AutoNAT Reachability is Private. @@ -30,7 +9,7 @@ func (n NATTransportProtocol) String() string { // this event ONLY if the Reachability on the `EvtLocalReachabilityChanged` is Private. type EvtNATDeviceTypeChanged struct { // TransportProtocol is the Transport Protocol for which the NAT Device Type has been determined. - TransportProtocol NATTransportProtocol + TransportProtocol network.NATTransportProtocol // NatDeviceType indicates the type of the NAT Device for the Transport Protocol. // Currently, it can be either a `Cone NAT` or a `Symmetric NAT`. Please see the detailed documentation // on `network.NATDeviceType` enumerations for a better understanding of what these types mean and diff --git a/network/nattype.go b/network/nattype.go index af9d25d2..bc95d687 100644 --- a/network/nattype.go +++ b/network/nattype.go @@ -35,3 +35,24 @@ func (r NATDeviceType) String() string { return "unrecognized" } } + +// NATTransportProtocol is the transport protocol for which the NAT Device Type has been determined. +type NATTransportProtocol int + +const ( + // NATTransportUDP means that the NAT Device Type has been determined for the UDP Protocol. + NATTransportUDP NATTransportProtocol = iota + // NATTransportTCP means that the NAT Device Type has been determined for the TCP Protocol. + NATTransportTCP +) + +func (n NATTransportProtocol) String() string { + switch n { + case 0: + return "UDP" + case 1: + return "TCP" + default: + return "unrecognized" + } +} From 51a83acbce5f12271f340ad8bb020a5baea51af9 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 26 Aug 2019 14:23:23 +0300 Subject: [PATCH 11/17] Add SecureMuxer interface to facilitate simultaneous open --- sec/security.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sec/security.go b/sec/security.go index 95c8e6a6..42321d18 100644 --- a/sec/security.go +++ b/sec/security.go @@ -24,3 +24,17 @@ type SecureTransport interface { // SecureOutbound secures an outbound connection. SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (SecureConn, error) } + +// A SecureMuxer is a wrapper around SecureTransport which can select security protocols +// and open outbound connections with simultaneous open. +type SecureMuxer interface { + // SecureInbound secures an inbound connection. + // The returned boolean indicates whether the connection should be trated as a server + // connection; in the case of SecureInbound it should always be true. + SecureInbound(ctx context.Context, insecure net.Conn) (SecureConn, bool, error) + + // SecureOutbound secures an outbound connection. + // The returned boolean indicates whether the connection should be treated as a server + // connection due to simultaneous open. + SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (SecureConn, bool, error) +} From eb55f850ea76bb5bef124258c14fc86b4a54eebd Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 21 Sep 2019 14:26:35 +0300 Subject: [PATCH 12/17] set the remote peer id in insecure transport when initialized without keys --- sec/insecure/insecure.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sec/insecure/insecure.go b/sec/insecure/insecure.go index eb8dc442..4134d95e 100644 --- a/sec/insecure/insecure.go +++ b/sec/insecure/insecure.go @@ -108,6 +108,11 @@ func (t *Transport) SecureOutbound(ctx context.Context, insecure net.Conn, p pee p, conn.remote) } + if t.key == nil && conn.remote == "" { + // set the remote peer id if we were initialiazed without keys + conn.remote = p + } + return conn, nil } From a7e5cf01c1430b4a2de8162ead527b7ef3d67516 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Thu, 14 Jan 2021 14:03:53 +0530 Subject: [PATCH 13/17] force direct dial --- network/context.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/network/context.go b/network/context.go index 9025f83a..2732ecaa 100644 --- a/network/context.go +++ b/network/context.go @@ -12,8 +12,10 @@ var DialPeerTimeout = 60 * time.Second type noDialCtxKey struct{} type dialPeerTimeoutCtxKey struct{} +type forceDirectDialCtxKey struct{} var noDial = noDialCtxKey{} +var forceDirectDial = forceDirectDialCtxKey{} // WithNoDial constructs a new context with an option that instructs the network // to not attempt a new dial when opening a stream. @@ -21,6 +23,22 @@ func WithNoDial(ctx context.Context, reason string) context.Context { return context.WithValue(ctx, noDial, reason) } +// WithForceDirectDial constructs a new context with an option that instructs the network +// to attempt to force a direct connection to a peer via a dial even if a proxied connection to it already exists. +func WithForceDirectDial(ctx context.Context, reason string) context.Context { + return context.WithValue(ctx, forceDirectDial, reason) +} + +// GetForceDirectDial returns true if the force direct dial option is set in the context. +func GetForceDirectDial(ctx context.Context) (forceDirect bool, reason string) { + v := ctx.Value(forceDirectDial) + if v != nil { + return true, v.(string) + } + + return false, "" +} + // GetNoDial returns true if the no dial option is set in the context. func GetNoDial(ctx context.Context) (nodial bool, reason string) { v := ctx.Value(noDial) From d9c724a0baa73d175b53bca0cf1e810ddec44429 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Thu, 14 Jan 2021 14:05:34 +0530 Subject: [PATCH 14/17] force direct dial --- network/context.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/network/context.go b/network/context.go index 2732ecaa..98914938 100644 --- a/network/context.go +++ b/network/context.go @@ -23,12 +23,14 @@ func WithNoDial(ctx context.Context, reason string) context.Context { return context.WithValue(ctx, noDial, reason) } +// EXPERIMENTAL: We might go ahead with introducing a new API in the Network to accomplish this later on. // WithForceDirectDial constructs a new context with an option that instructs the network // to attempt to force a direct connection to a peer via a dial even if a proxied connection to it already exists. func WithForceDirectDial(ctx context.Context, reason string) context.Context { return context.WithValue(ctx, forceDirectDial, reason) } +// EXPERIMENTAL: We might go ahead with introducing a new API in the Network to accomplish this later on. // GetForceDirectDial returns true if the force direct dial option is set in the context. func GetForceDirectDial(ctx context.Context) (forceDirect bool, reason string) { v := ctx.Value(forceDirectDial) From 1959400f19f3a43ca2996770d041453d71085c11 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Thu, 14 Jan 2021 16:11:48 +0530 Subject: [PATCH 15/17] hole punch event --- event/holepunch.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 event/holepunch.go diff --git a/event/holepunch.go b/event/holepunch.go new file mode 100644 index 00000000..a2e1e21b --- /dev/null +++ b/event/holepunch.go @@ -0,0 +1,18 @@ +package event + +import ( + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" +) + +// EvtHolePunchConnSuccessful is emitted when a hole punching attempt to establish a direct +// connection with a peer is successful. +type EvtHolePunchConnSuccessful struct { + // Peer is the ID of the peer we hole punched with + Peer peer.ID + // ProxyConn is the proxy connection over which we co-ordinated hole punching. + // In the current implementation, this connection will be closed after a grace period. + // It is the user's responsibility to migrate all streams from this connection to the new hole + // punched connection. + ProxyConn network.Conn +} From 65f60e0c09e991471873d01f53616461e39048cf Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Thu, 14 Jan 2021 18:14:26 +0530 Subject: [PATCH 16/17] remove event --- event/holepunch.go | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 event/holepunch.go diff --git a/event/holepunch.go b/event/holepunch.go deleted file mode 100644 index a2e1e21b..00000000 --- a/event/holepunch.go +++ /dev/null @@ -1,18 +0,0 @@ -package event - -import ( - "github.com/libp2p/go-libp2p-core/network" - "github.com/libp2p/go-libp2p-core/peer" -) - -// EvtHolePunchConnSuccessful is emitted when a hole punching attempt to establish a direct -// connection with a peer is successful. -type EvtHolePunchConnSuccessful struct { - // Peer is the ID of the peer we hole punched with - Peer peer.ID - // ProxyConn is the proxy connection over which we co-ordinated hole punching. - // In the current implementation, this connection will be closed after a grace period. - // It is the user's responsibility to migrate all streams from this connection to the new hole - // punched connection. - ProxyConn network.Conn -} From 7116e2835272977eb9d831dba6b6e25fbf3c2317 Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Thu, 21 Jan 2021 12:43:35 +0530 Subject: [PATCH 17/17] interface changes --- network/context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/context.go b/network/context.go index 98914938..19fc2c7b 100644 --- a/network/context.go +++ b/network/context.go @@ -23,14 +23,14 @@ func WithNoDial(ctx context.Context, reason string) context.Context { return context.WithValue(ctx, noDial, reason) } -// EXPERIMENTAL: We might go ahead with introducing a new API in the Network to accomplish this later on. +// EXPERIMENTAL // WithForceDirectDial constructs a new context with an option that instructs the network // to attempt to force a direct connection to a peer via a dial even if a proxied connection to it already exists. func WithForceDirectDial(ctx context.Context, reason string) context.Context { return context.WithValue(ctx, forceDirectDial, reason) } -// EXPERIMENTAL: We might go ahead with introducing a new API in the Network to accomplish this later on. +// EXPERIMENTAL // GetForceDirectDial returns true if the force direct dial option is set in the context. func GetForceDirectDial(ctx context.Context) (forceDirect bool, reason string) { v := ctx.Value(forceDirectDial)