Exchange proxy mode via signal (#727)

Before defining if we will use direct or proxy connection we will exchange a 
message with the other peer if the modes match we keep the decision 
from the shouldUseProxy function otherwise we skip using direct connection.

Added a feature support message to the signal protocol
This commit is contained in:
Maycon Santos
2023-03-16 16:46:17 +01:00
committed by GitHub
parent 6143b819c5
commit 731d3ae464
9 changed files with 463 additions and 54 deletions

View File

@ -19,6 +19,16 @@ type Status string
const StreamConnected Status = "Connected"
const StreamDisconnected Status = "Disconnected"
const (
// DirectCheck indicates support to direct mode checks
DirectCheck uint32 = 1
)
// FeaturesSupport register protocol supported features
type FeaturesSupport struct {
DirectCheck bool
}
type Client interface {
io.Closer
StreamConnected() bool
@ -62,3 +72,15 @@ type Credential struct {
UFrag string
Pwd string
}
// ParseFeaturesSupported parses a slice of supported features into FeaturesSupport
func ParseFeaturesSupported(featuresMessage []uint32) FeaturesSupport {
var protoSupport FeaturesSupport
for _, feature := range featuresMessage {
if feature == DirectCheck {
protoSupport.DirectCheck = true
return protoSupport
}
}
return protoSupport
}