From c68c78d4120ecde3eb24f4431dcf2bab820dcb5d Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sun, 28 Jun 2015 20:34:28 +0100 Subject: [PATCH] Do scheme validation in the client --- client/client.go | 4 ++++ client/methods.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/client/client.go b/client/client.go index b48320fd2..d05944aca 100644 --- a/client/client.go +++ b/client/client.go @@ -52,6 +52,10 @@ type ProtocolClient struct { } 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) if err != nil { return err diff --git a/client/methods.go b/client/methods.go index 1d457e294..c9b7a265c 100644 --- a/client/methods.go +++ b/client/methods.go @@ -15,6 +15,10 @@ import ( ) 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.SetDeadline(time.Now().Add(10 * time.Second)) if err != nil {