-
Notifications
You must be signed in to change notification settings - Fork 2
/
nattype.go
72 lines (61 loc) · 2.13 KB
/
nattype.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package stun
type NatType uint
const (
/// <summary>
/// UDP is always blocked.
/// </summary>
UdpBlocked NatType = iota
/// <summary>
/// No NAT, public IP, no firewall.
/// </summary>
OpenInternet
/// <summary>
/// No NAT, public IP, but symmetric UDP firewall.
/// </summary>
SymmetricUdpFirewall
/// <summary>
/// A full cone NAT is one where all requests from the same internal IP address and port are
/// mapped to the same external IP address and port. Furthermore, any external host can send
/// a packet to the internal host, by sending a packet to the mapped external address.
/// </summary>
FullCone
/// <summary>
/// A restricted cone NAT is one where all requests from the same internal IP address and
/// port are mapped to the same external IP address and port. Unlike a full cone NAT, an external
/// host (with IP address X) can send a packet to the internal host only if the internal host
/// had previously sent a packet to IP address X.
/// </summary>
RestrictedCone
/// <summary>
/// A port restricted cone NAT is like a restricted cone NAT, but the restriction
/// includes port numbers. Specifically, an external host can send a packet, with source IP
/// address X and source port P, to the internal host only if the internal host had previously
/// sent a packet to IP address X and port P.
/// </summary>
PortRestrictedCone
/// <summary>
/// A symmetric NAT is one where all requests from the same internal IP address and port,
/// to a specific destination IP address and port, are mapped to the same external IP address and
/// port. If the same host sends a packet with the same source address and port, but to
/// a different destination, a different mapping is used. Furthermore, only the external host that
/// receives a packet can send a UDP packet back to the internal host.
/// </summary>
Symmetric
Unknown
)
var natTypeNames = []string{
"UdpBlocked",
"OpenInternet",
"SymmetricUdpFirewall",
"FullCone",
"RestrictedCone",
"PortRestrictedCone",
"Symmetric",
"Unknown",
}
func (natType NatType) String() string {
if natType <= Unknown {
return natTypeNames[natType]
}
return ""
}