Fix examples

This commit is contained in:
mattn 2014-09-17 12:35:47 +09:00
parent 748282a14a
commit f402673c8c
2 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"crypto/tls"
"github.com/mattn/go-gtk/gtk" "github.com/mattn/go-gtk/gtk"
"github.com/mattn/go-xmpp" "github.com/mattn/go-xmpp"
"log" "log"
@ -56,7 +57,7 @@ func main() {
dialog.AddButton(gtk.STOCK_OK, gtk.RESPONSE_OK) dialog.AddButton(gtk.STOCK_OK, gtk.RESPONSE_OK)
dialog.AddButton(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) dialog.AddButton(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
dialog.SetDefaultResponse(int(gtk.RESPONSE_OK)) dialog.SetDefaultResponse(gtk.RESPONSE_OK)
dialog.SetTransientFor(window) dialog.SetTransientFor(window)
dialog.ShowAll() dialog.ShowAll()
res := dialog.Run() res := dialog.Run()
@ -67,6 +68,11 @@ func main() {
os.Exit(0) os.Exit(0)
} }
xmpp.DefaultConfig = tls.Config {
ServerName: "talk.google.com",
InsecureSkipVerify: false,
}
talk, err := xmpp.NewClient("talk.google.com:443", username_, password_, false) talk, err := xmpp.NewClient("talk.google.com:443", username_, password_, false)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -2,6 +2,7 @@ package main
import ( import (
"bufio" "bufio"
"crypto/tls"
"flag" "flag"
"fmt" "fmt"
"github.com/mattn/go-xmpp" "github.com/mattn/go-xmpp"
@ -17,6 +18,10 @@ var notls = flag.Bool("notls", false, "No TLS")
var debug = flag.Bool("debug", false, "debug output") var debug = flag.Bool("debug", false, "debug output")
var session = flag.Bool("session", false, "use server session") var session = flag.Bool("session", false, "use server session")
func serverName(host string) string {
return strings.Split(host, ":")[0]
}
func main() { func main() {
flag.Usage = func() { flag.Usage = func() {
fmt.Fprintf(os.Stderr, "usage: example [options]\n") fmt.Fprintf(os.Stderr, "usage: example [options]\n")
@ -28,6 +33,13 @@ func main() {
flag.Usage() flag.Usage()
} }
if !*notls {
xmpp.DefaultConfig = tls.Config {
ServerName: serverName(*server),
InsecureSkipVerify: false,
}
}
var talk *xmpp.Client var talk *xmpp.Client
var err error var err error
options := xmpp.Options{Host: *server, options := xmpp.Options{Host: *server,