Make easier to extend the list of known proxy types

And include iptproxy as a valid proxy type.
This commit is contained in:
meskio 2022-03-11 14:32:35 +01:00
parent bd636a1374
commit b265bd3092
No known key found for this signature in database
GPG key ID: 52B8F5AC97A2DA86
4 changed files with 57 additions and 64 deletions

View file

@ -12,14 +12,17 @@ import (
)
const (
version = "1.2"
ProxyStandalone = "standalone"
ProxyWebext = "webext"
ProxyBadge = "badge"
ProxyUnknown = "unknown"
version = "1.2"
ProxyUnknown = "unknown"
)
var KnownProxyTypes = map[string]bool{
"standalone": true,
"webext": true,
"badge": true,
"iptproxy": true,
}
/* Version 1.2 specification:
== ProxyPollRequest ==
@ -138,11 +141,7 @@ func DecodeProxyPollRequest(data []byte) (sid string, proxyType string, natType
// we don't reject polls with an unknown proxy type because we encourage
// projects that embed proxy code to include their own type
switch message.Type {
case ProxyStandalone:
case ProxyWebext:
case ProxyBadge:
default:
if !KnownProxyTypes[message.Type] {
message.Type = ProxyUnknown
}