mirror of
https://salsa.debian.org/mdosch/go-sendxmpp
synced 2024-11-17 03:25:33 +00:00
Add ALPN support
This should make go-sendxmpp work on servers using ALPN e.g. when using sslh on port 443 to use a httpd and XMPP over TLS on the same port.
This commit is contained in:
parent
a31a70c43d
commit
6907535153
@ -83,7 +83,7 @@ func parseConfig(configPath string) (configuration, error) {
|
||||
|
||||
// Read config file per line.
|
||||
for scanner.Scan() {
|
||||
if strings.HasPrefix(scanner.Text(), "#"){
|
||||
if strings.HasPrefix(scanner.Text(), "#") {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ func parseConfig(configPath string) (configuration, error) {
|
||||
output.port = row[1]
|
||||
default:
|
||||
if len(row) >= 2 {
|
||||
if strings.Contains(scanner.Text(), ";"){
|
||||
if strings.Contains(scanner.Text(), ";") {
|
||||
output.username = strings.Split(row[0], ";")[0]
|
||||
output.jserver = strings.Split(row[0], ";")[1]
|
||||
output.password = row[1]
|
||||
@ -238,15 +238,21 @@ func main() {
|
||||
password = *flagPassword
|
||||
}
|
||||
|
||||
// Use ALPN
|
||||
tlsConfig := xmpp.DefaultConfig
|
||||
tlsConfig.ServerName = strings.Split(server, ":")[0]
|
||||
tlsConfig.NextProtos = append(tlsConfig.NextProtos, "xmpp-client")
|
||||
|
||||
// Set XMPP connection options.
|
||||
options := xmpp.Options{
|
||||
Host: server,
|
||||
User: user,
|
||||
Resource: *flagResource,
|
||||
Password: password,
|
||||
NoTLS: !*flagTLS,
|
||||
StartTLS: *flagStartTLS,
|
||||
Debug: *flagDebug,
|
||||
Host: server,
|
||||
User: user,
|
||||
Resource: *flagResource,
|
||||
Password: password,
|
||||
NoTLS: !*flagTLS,
|
||||
StartTLS: *flagStartTLS,
|
||||
Debug: *flagDebug,
|
||||
TLSConfig: &tlsConfig,
|
||||
}
|
||||
|
||||
// Read message from file.
|
||||
|
Loading…
Reference in New Issue
Block a user