Пример #1
0
// workerID is the ID for this transport endpoint.
// addr is the networking address to listen to.
func (s *System) NewTransport(workerID n.WorkerID, addr net.Addr) n.Transport {
	u := tele.NewStructOverTCP()
	l := newListener(workerID, os.Getpid(), u.Listen(addr))
	return &Transport{
		WorkerID: workerID,
		Dialer:   newDialer(l.Addr(), u),
		Listener: l,
	}
}
Пример #2
0
func NewServer(inAddr, outAddr string) (*Server, error) {
	t := tele.NewStructOverTCP()
	l := t.Listen(tcp.Addr(outAddr))
	if outAddr == "" {
		outAddr = l.Addr().String()
		fmt.Println(outAddr)
	}
	srv := &Server{frame: trace.NewFrame("tele", "server"), tele: t, inAddr: inAddr, outAddr: outAddr}
	srv.frame.Bind(srv)
	go srv.loop(l)
	return srv, nil
}
Пример #3
0
// workerID is the ID for this transport endpoint.
// addr is the networking address to listen to.
func (s *System) NewTransport(workerID n.WorkerID, addr net.Addr, key []byte) n.Transport {
	var u *blend.Transport
	if len(key) == 0 {
		u = tele.NewStructOverTCP()
	} else {
		u = tele.NewStructOverTCPWithHMAC(key)
	}
	l := newListener(workerID, os.Getpid(), u.Listen(addr))
	return &Transport{
		WorkerID: workerID,
		Dialer:   newDialer(l.Addr(), u),
		Listener: l,
	}
}
Пример #4
0
func NewClient(inAddr, outAddr string) {
	cli := &Client{frame: trace.NewFrame("tele", "client"), outAddr: outAddr}
	cli.frame.Bind(cli)

	// Make teleport transport
	t := tele.NewStructOverTCP()

	// Listen on input TCP address
	l, err := net.Listen("tcp", inAddr)
	if err != nil {
		cli.frame.Printf("listen on teleport address %s (%s)", inAddr, err)
		os.Exit(1)
	}
	if inAddr == "" {
		inAddr = l.Addr().String()
		fmt.Println(inAddr)
	}
	cli.tele, cli.inAddr = t, inAddr
	go cli.loop(l)
	return
}