From 4ee627b786f4dcf14d0c92a5ee9b077a77a54217 Mon Sep 17 00:00:00 2001 From: Hoshikawa Erina Date: Sat, 28 Nov 2020 00:46:21 -0800 Subject: [PATCH] add insecure server support - add mumble-insecure parameter to readme - fix readme.md minor command line error --- README.md | 4 +++- main.go | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b00a2ff..c25fc88 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Usage of mumble-discord-bridge: MUMBLE_PORT mumble port (default 64738) -mumble-username string MUMBLE_USERNAME, mumble username (default "discord-bridge") + -mumble-insecure bool + MUMBLE_INSECURE, allow connection to insecure (invalid TLS cert) mumble server ``` ## Setup @@ -84,7 +86,7 @@ A simple go build command is all that is needed. Ensure the opus library is installed. ```bash -go build *.go -o mumble-discord-bridge +go build -o mumble-discord-bridge *.go ``` ## Known Issues diff --git a/main.go b/main.go index d9587f1..0c2c690 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,11 @@ package main import ( + "crypto/tls" "flag" "fmt" "log" + "net" "os" "os/signal" "strconv" @@ -60,7 +62,7 @@ func main() { mumblePort := flag.Int("mumble-port", lookupEnvOrInt("MUMBLE_PORT", 64738), "MUMBLE_PORT mumble port") mumbleUsername := flag.String("mumble-username", lookupEnvOrString("MUMBLE_USERNAME", "discord-bridge"), "MUMBLE_USERNAME, mumble username") mumblePassword := flag.String("mumble-password", lookupEnvOrString("MUMBLE_PASSWORD", ""), "MUMBLE_PASSWORD, mumble password, optional") - // mumbleInsecure := flag.Bool("mumble-insecure", lookupEnvOrBool("MUMBLE_INSECURE", false), "mumble insecure, env alt MUMBLE_INSECURE") + mumbleInsecure := flag.Bool("mumble-insecure", lookupEnvOrBool("MUMBLE_INSECURE", false), "mumble insecure, env alt MUMBLE_INSECURE") discordToken := flag.String("discord-token", lookupEnvOrString("DISCORD_TOKEN", ""), "DISCORD_TOKEN, discord bot token") discordGID := flag.String("discord-gid", lookupEnvOrString("DISCORD_GID", ""), "DISCORD_GID, discord gid") @@ -124,7 +126,13 @@ func main() { m := MumbleDuplex{} - mumble, err := gumble.Dial(*mumbleAddr+":"+strconv.Itoa(*mumblePort), config) + var tlsConfig tls.Config + if *mumbleInsecure { + tlsConfig.InsecureSkipVerify = true + } + + mumble, err := gumble.DialWithDialer(new(net.Dialer),*mumbleAddr+":"+strconv.Itoa(*mumblePort),config, &tlsConfig) + if err != nil { log.Println(err) return