aboutsummaryrefslogtreecommitdiffstats
path: root/lib/send/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/send/parse.go')
-rw-r--r--lib/send/parse.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/send/parse.go b/lib/send/parse.go
new file mode 100644
index 00000000..460e91dc
--- /dev/null
+++ b/lib/send/parse.go
@@ -0,0 +1,32 @@
+package send
+
+import (
+ "fmt"
+ "net/url"
+ "strings"
+)
+
+func parseScheme(uri *url.URL) (protocol string, auth string, err error) {
+ protocol = ""
+ auth = "plain"
+ if uri.Scheme != "" {
+ parts := strings.Split(uri.Scheme, "+")
+ switch len(parts) {
+ case 1:
+ protocol = parts[0]
+ case 2:
+ if parts[1] == "insecure" {
+ protocol = uri.Scheme
+ } else {
+ protocol = parts[0]
+ auth = parts[1]
+ }
+ case 3:
+ protocol = parts[0] + "+" + parts[1]
+ auth = parts[2]
+ default:
+ return "", "", fmt.Errorf("Unknown scheme %s", uri.Scheme)
+ }
+ }
+ return protocol, auth, nil
+}