func NewClient(addr string) transport.Transport { s := client{ addr: addr, dialer: &websocket.Dialer{}, } return transport.NewLoopTransport(&s) }
func NewTlsServer(addr, certFile, keyFile string) transport.Transport { s := server{ certFile: certFile, keyFile: keyFile, tls: true, server: &http.Server{Addr: addr}, } return transport.NewLoopTransport(&s) }
func NewClient(addr string) (transport.Transport, error) { sock, err := newSock() if err != nil { return nil, err } s := client{ addr: addr, sock: sock, } return transport.NewLoopTransport(&s), nil }
func NewTlsClient(addr string, certFile, keyFile string) (transport.Transport, error) { config := &tls.Config{ NextProtos: []string{"http/1.1"}, } var err error config.Certificates = make([]tls.Certificate, 1) config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile) if err != nil { return nil, err } s := client{ addr: addr, dialer: &websocket.Dialer{ TLSClientConfig: config, }, } return transport.NewLoopTransport(&s), nil }
func NewTlsServer(addr string, certFile, keyFile string) (transport.Transport, error) { sock, err := newSock() if err != nil { return nil, err } config := &tls.Config{} config.Certificates = make([]tls.Certificate, 1) config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile) if err != nil { return nil, err } sock.SetOption(mangos.OptionTlsConfig, config) s := server{ addr: addr, sock: sock, } return transport.NewLoopTransport(&s), nil }
func NewServer(addr string) transport.Transport { s := server{ server: &http.Server{Addr: addr}, } return transport.NewLoopTransport(&s) }