File
Blob: spec/tun/alpn.go
| 1 | package tun |
| 2 | |
| 3 | import ( |
| 4 | "go.miragespace.co/specter/spec/protocol" |
| 5 | |
| 6 | "google.golang.org/protobuf/proto" |
| 7 | ) |
| 8 | |
| 9 | var alpnNameMap map[int32]string = make(map[int32]string) |
| 10 | |
| 11 | func init() { |
| 12 | m := &protocol.Link{} |
| 13 | len := m.GetAlpn().Enum().Descriptor().Values().Len() |
| 14 | for i := range len { |
| 15 | num := m.GetAlpn().Enum().Descriptor().Values().Get(i).Number() |
| 16 | name := proto.GetExtension(m.GetAlpn().Descriptor().Values().ByNumber(num).Options(), protocol.E_AlpnName).(string) |
| 17 | alpnNameMap[int32(num)] = name |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | func ALPN(a protocol.Link_ALPN) string { |
| 22 | return alpnNameMap[int32(a.Number())] |
| 23 | } |