~apreiml/go-wormhole

ebda5d5978259cd323f7db61a7af9f7f8981ce8d — Armin Preiml 2 years ago 846b4be
remove more unused code
1 files changed, 1 insertions(+), 31 deletions(-)

M wormhole/transit/transit.go
M wormhole/transit/transit.go => wormhole/transit/transit.go +1 -31
@@ 258,7 258,7 @@ func (t *Transit) tryFindChannel() {
	for _, h := range t.hints {
		if h.Type == "direct-tcp-v1" {
			go func(h Hint) {
				conn, err := newTcpDirect(h)
				conn, err := net.Dial("tcp", h.Hostname+":"+strconv.Itoa(h.Port))
				if err != nil {
					log.Print("Direct conn failed ", err)
					return


@@ 401,33 401,3 @@ func (t *Transit) Close() error {
	fmt.Println("transit close")
	return nil
}

type tcpDirectChannel struct {
	rw net.Conn
}

func newTcpDirect(c Hint) (*tcpDirectChannel, error) {
	fmt.Printf("CONNECT %#v\n", c)
	conn, err := net.Dial("tcp", c.Hostname+":"+strconv.Itoa(c.Port))
	if err != nil {
		return nil, err
	}

	return &tcpDirectChannel{conn}, nil
}

func (c *tcpDirectChannel) Read(p []byte) (n int, err error) {
	println("READ ", len(p))
	n, err = c.rw.Read(p)
	println("R ", string(p))
	return
}

func (c *tcpDirectChannel) Write(p []byte) (n int, err error) {
	n, err = c.rw.Write(p)
	return
}

func (c *tcpDirectChannel) Close() error {
	return c.rw.Close()
}