debug cleanup and src/dst unswap

This commit is contained in:
AJ ONeal 2020-07-21 00:36:03 -06:00
parent 2b5ddb0407
commit da34e64e07
2 changed files with 10 additions and 9 deletions

View File

@ -2,7 +2,6 @@ package telebit
import ( import (
"bufio" "bufio"
"fmt"
"net" "net"
"time" "time"
) )
@ -84,14 +83,14 @@ func (c *Conn) LocalAddr() net.Addr {
// LocalAddr returns the local network address. // LocalAddr returns the local network address.
func (c *Conn) LocalAddr() net.Addr { func (c *Conn) LocalAddr() net.Addr {
fmt.Println("[warn] LocalAddr() address source/target switch?") //fmt.Println("[warn] LocalAddr() address source/target switch?")
return &c.relaySourceAddr return &c.relayTargetAddr
} }
// RemoteAddr returns the remote network address. // RemoteAddr returns the remote network address.
func (c *Conn) RemoteAddr() net.Addr { func (c *Conn) RemoteAddr() net.Addr {
fmt.Println("[warn] RemoteAddr() address source/target switch?") //fmt.Println("[warn] RemoteAddr() address source/target switch?")
return &c.relayTargetAddr return &c.relaySourceAddr
} }
// SetDeadline sets the read and write deadlines associated // SetDeadline sets the read and write deadlines associated

View File

@ -167,8 +167,8 @@ func (l *Listener) getPipe(src, dst *Addr, count int) net.Conn {
rawPipe, pipe := net.Pipe() rawPipe, pipe := net.Pipe()
newconn := &Conn{ newconn := &Conn{
//updated: time.Now(), //updated: time.Now(),
relaySourceAddr: *dst, relaySourceAddr: *src,
relayTargetAddr: *src, relayTargetAddr: *dst,
relay: rawPipe, relay: rawPipe,
} }
l.conns[connID] = pipe l.conns[connID] = pipe
@ -184,10 +184,12 @@ func (l *Listener) getPipe(src, dst *Addr, count int) net.Conn {
newconn.Close() newconn.Close()
pipe.Close() pipe.Close()
if nil != err { if nil != err {
fmt.Fprintf(os.Stderr, "[debug] [ln-pipe] encode stream ended:\n%+v\n%+v\n%q\n", *src, *dst, err) fmt.Fprintf(os.Stderr, "[ln-pipe] encode stream ended:\n%+v\n%+v\n%q\n", *src, *dst, err)
} else { } else {
if dbg.Debug {
fmt.Fprintf(os.Stderr, "[debug] [ln-pipe] encode stream ended gracefully:\n%+v\n%+v\n", *src, *dst) fmt.Fprintf(os.Stderr, "[debug] [ln-pipe] encode stream ended gracefully:\n%+v\n%+v\n", *src, *dst)
} }
}
}() }()
return pipe return pipe