Beispiel #1
0
func NewClient(addr string) transport.Transport {
	s := client{
		addr:   addr,
		dialer: &websocket.Dialer{},
	}
	return transport.NewLoopTransport(&s)
}
Beispiel #2
0
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)
}
Beispiel #3
0
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
}
Beispiel #4
0
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
}
Beispiel #5
0
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
}
Beispiel #6
0
func NewServer(addr string) transport.Transport {
	s := server{
		server: &http.Server{Addr: addr},
	}
	return transport.NewLoopTransport(&s)
}