epdisc: add NAT_TYPE_NONE

Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
Steffen Vogel
2022-10-13 17:48:46 +02:00
parent 3644945dc1
commit 538400fd4d
4 changed files with 42 additions and 21 deletions

View File

@@ -141,7 +141,9 @@ func (e *Interface) Marshal() *protoepdisc.Interface {
MuxSrflxPort: uint32(e.udpMuxSrflxPort),
}
if e.nat != nil {
if e.nat == nil {
is.NatType = protoepdisc.NATType_NAT_NONE
} else {
is.NatType = protoepdisc.NATType_NAT_NFTABLES
}

View File

@@ -157,16 +157,19 @@ func (Reachability) EnumDescriptor() ([]byte, []int) {
type NATType int32
const (
NATType_NAT_NFTABLES NATType = 0
NATType_NAT_NONE NATType = 0
NATType_NAT_NFTABLES NATType = 1
)
// Enum value maps for NATType.
var (
NATType_name = map[int32]string{
0: "NAT_NFTABLES",
0: "NAT_NONE",
1: "NAT_NFTABLES",
}
NATType_value = map[string]int32{
"NAT_NFTABLES": 0,
"NAT_NONE": 0,
"NAT_NFTABLES": 1,
}
)
@@ -361,7 +364,7 @@ func (x *Interface) GetNatType() NATType {
if x != nil {
return x.NatType
}
return NATType_NAT_NFTABLES
return NATType_NAT_NONE
}
func (x *Interface) GetMuxPort() uint32 {
@@ -567,17 +570,18 @@ var file_feature_epdisc_proto_rawDesc = []byte{
0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x5f, 0x54, 0x43, 0x50, 0x10,
0x02, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x45, 0x4c, 0x41, 0x59, 0x5f, 0x55, 0x44, 0x50, 0x10, 0x03,
0x12, 0x0d, 0x0a, 0x09, 0x52, 0x45, 0x4c, 0x41, 0x59, 0x5f, 0x54, 0x43, 0x50, 0x10, 0x04, 0x12,
0x0a, 0x0a, 0x06, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x44, 0x10, 0x05, 0x2a, 0x1b, 0x0a, 0x07, 0x4e,
0x41, 0x54, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x4e, 0x41, 0x54, 0x5f, 0x4e, 0x46,
0x54, 0x41, 0x42, 0x4c, 0x45, 0x53, 0x10, 0x00, 0x2a, 0x49, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x78,
0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x4f, 0x5f, 0x50, 0x52, 0x4f, 0x58,
0x59, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x42, 0x49, 0x4e, 0x44,
0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x5f, 0x43, 0x4f, 0x4e,
0x4e, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x5f, 0x4e, 0x41,
0x54, 0x10, 0x03, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70,
0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65,
0x2f, 0x65, 0x70, 0x64, 0x69, 0x73, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x0a, 0x0a, 0x06, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x44, 0x10, 0x05, 0x2a, 0x29, 0x0a, 0x07, 0x4e,
0x41, 0x54, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x41, 0x54, 0x5f, 0x4e, 0x4f,
0x4e, 0x45, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x4e, 0x41, 0x54, 0x5f, 0x4e, 0x46, 0x54, 0x41,
0x42, 0x4c, 0x45, 0x53, 0x10, 0x01, 0x2a, 0x49, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x54,
0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x4f, 0x5f, 0x50, 0x52, 0x4f, 0x58, 0x59, 0x10,
0x00, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x42, 0x49, 0x4e, 0x44, 0x10, 0x01,
0x12, 0x0f, 0x0a, 0x0b, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x5f, 0x43, 0x4f, 0x4e, 0x4e, 0x10,
0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x4b, 0x45, 0x52, 0x4e, 0x45, 0x4c, 0x5f, 0x4e, 0x41, 0x54, 0x10,
0x03, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x73, 0x74, 0x76, 0x30, 0x67, 0x2f, 0x63, 0x75, 0x6e, 0x69, 0x63, 0x75, 0x2f, 0x70, 0x6b, 0x67,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2f, 0x65,
0x70, 0x64, 0x69, 0x73, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@@ -173,16 +173,30 @@ func (cp *CandidatePair) ToString() string {
}
func (c *Candidate) ToString() string {
return fmt.Sprintf("%s[%s, %s:%d]", ice.CandidateType(c.Type), ice.NetworkType(c.NetworkType), c.Address, c.Port)
var addr string
switch c.NetworkType {
case NetworkType_NETWORK_TYPE_UDP6, NetworkType_NETWORK_TYPE_TCP6:
addr = fmt.Sprintf("[%s]", c.Address)
case NetworkType_NETWORK_TYPE_UDP4, NetworkType_NETWORK_TYPE_TCP4:
addr = c.Address
}
return fmt.Sprintf("%s[%s, %s:%d]", ice.CandidateType(c.Type), ice.NetworkType(c.NetworkType), addr, c.Port)
}
func (cs *CandidateStats) ToString() string {
return fmt.Sprintf("%s[%s, %s:%d]", ice.CandidateType(cs.CandidateType), ice.NetworkType(cs.NetworkType), cs.Ip, cs.Port)
var addr string
switch cs.NetworkType {
case NetworkType_NETWORK_TYPE_UDP6, NetworkType_NETWORK_TYPE_TCP6:
addr = fmt.Sprintf("[%s]", cs.Ip)
case NetworkType_NETWORK_TYPE_UDP4, NetworkType_NETWORK_TYPE_TCP4:
addr = cs.Ip
}
return fmt.Sprintf("%s[%s, %s:%d]", ice.CandidateType(cs.CandidateType), ice.NetworkType(cs.NetworkType), addr, cs.Port)
}
func (cs *CandidateStats) Dump(wr io.Writer) error {
// wri := util.NewIndenter(wr, " ")
if _, err := fmt.Fprintf(wr, t.Mods("candidate", t.Bold, t.FgMagenta)+": "+t.Mods("%s", t.FgMagenta)+"\n", cs.ToString()); err != nil {
return err
}

View File

@@ -33,7 +33,8 @@ enum Reachability {
}
enum NATType {
NAT_NFTABLES = 0;
NAT_NONE = 0;
NAT_NFTABLES = 1;
}
enum ProxyType {