Do scheme validation in the client
This commit is contained in:
parent
f8bedc55e5
commit
6bc6ae2d28
|
@ -52,6 +52,10 @@ type ProtocolClient struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ProtocolClient) connect() error {
|
func (c *ProtocolClient) connect() error {
|
||||||
|
if c.URI.Scheme != "relay" {
|
||||||
|
return fmt.Errorf("Unsupported relay schema:", c.URI.Scheme)
|
||||||
|
}
|
||||||
|
|
||||||
conn, err := tls.Dial("tcp", c.URI.Host, c.config)
|
conn, err := tls.Dial("tcp", c.URI.Host, c.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -15,6 +15,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetInvitationFromRelay(uri *url.URL, id syncthingprotocol.DeviceID, certs []tls.Certificate) (protocol.SessionInvitation, error) {
|
func GetInvitationFromRelay(uri *url.URL, id syncthingprotocol.DeviceID, certs []tls.Certificate) (protocol.SessionInvitation, error) {
|
||||||
|
if uri.Scheme != "relay" {
|
||||||
|
return protocol.SessionInvitation{}, fmt.Errorf("Unsupported relay schema:", uri.Scheme)
|
||||||
|
}
|
||||||
|
|
||||||
conn, err := tls.Dial("tcp", uri.Host, configForCerts(certs))
|
conn, err := tls.Dial("tcp", uri.Host, configForCerts(certs))
|
||||||
conn.SetDeadline(time.Now().Add(10 * time.Second))
|
conn.SetDeadline(time.Now().Add(10 * time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user