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

Commit

Permalink
refactor packages
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Feb 18, 2021
1 parent 1e7e328 commit de360ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
23 changes: 1 addition & 22 deletions event/nattype.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,14 @@ 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.
// 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 {
// 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
Expand Down
21 changes: 21 additions & 0 deletions network/nattype.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit de360ba

Please sign in to comment.