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 }
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 }