Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit 7f4262e

Browse files
refactor packages
1 parent 3472931 commit 7f4262e

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

event/nattype.go

+1-22
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,14 @@ package event
22

33
import "github.com/libp2p/go-libp2p-core/network"
44

5-
// NATTransportProtocol is the transport protocol for which the NAT Device Type has been determined.
6-
type NATTransportProtocol int
7-
8-
const (
9-
// NATTransportUDP means that the NAT Device Type has been determined for the UDP Protocol.
10-
NATTransportUDP NATTransportProtocol = iota
11-
// NATTransportTCP means that the NAT Device Type has been determined for the TCP Protocol.
12-
NATTransportTCP
13-
)
14-
15-
func (n NATTransportProtocol) String() string {
16-
switch n {
17-
case 0:
18-
return "UDP"
19-
case 1:
20-
return "TCP"
21-
default:
22-
return "unrecognized"
23-
}
24-
}
25-
265
// EvtNATDeviceTypeChanged is an event struct to be emitted when the type of the NAT device changes for a Transport Protocol.
276
//
287
// Note: This event is meaningful ONLY if the AutoNAT Reachability is Private.
298
// Consumers of this event should ALSO consume the `EvtLocalReachabilityChanged` event and interpret
309
// this event ONLY if the Reachability on the `EvtLocalReachabilityChanged` is Private.
3110
type EvtNATDeviceTypeChanged struct {
3211
// TransportProtocol is the Transport Protocol for which the NAT Device Type has been determined.
33-
TransportProtocol NATTransportProtocol
12+
TransportProtocol network.NATTransportProtocol
3413
// NatDeviceType indicates the type of the NAT Device for the Transport Protocol.
3514
// Currently, it can be either a `Cone NAT` or a `Symmetric NAT`. Please see the detailed documentation
3615
// on `network.NATDeviceType` enumerations for a better understanding of what these types mean and

network/nattype.go

+21
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,24 @@ func (r NATDeviceType) String() string {
3535
return "unrecognized"
3636
}
3737
}
38+
39+
// NATTransportProtocol is the transport protocol for which the NAT Device Type has been determined.
40+
type NATTransportProtocol int
41+
42+
const (
43+
// NATTransportUDP means that the NAT Device Type has been determined for the UDP Protocol.
44+
NATTransportUDP NATTransportProtocol = iota
45+
// NATTransportTCP means that the NAT Device Type has been determined for the TCP Protocol.
46+
NATTransportTCP
47+
)
48+
49+
func (n NATTransportProtocol) String() string {
50+
switch n {
51+
case 0:
52+
return "UDP"
53+
case 1:
54+
return "TCP"
55+
default:
56+
return "unrecognized"
57+
}
58+
}

0 commit comments

Comments
 (0)