removed tcp write buffers
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
785aa37e87
commit
29ada58125
@ -1,7 +1,6 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
@ -76,13 +75,13 @@ func (p Proxy) AddConsumer(c Consumer) {
|
||||
if reconnectable {
|
||||
var err error
|
||||
for once := true; err != nil || once; once = false {
|
||||
fmt.Printf("attempting to connect `%v`\n", c)
|
||||
log.Printf("attempting to connect `%v`\n", c)
|
||||
err = c.(Reconnectable).Reconnect()
|
||||
if !once {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
fmt.Printf("connected `%v`\n", c)
|
||||
log.Printf("connected `%v`\n", c)
|
||||
}
|
||||
|
||||
for c.IsAlive() {
|
||||
@ -93,7 +92,7 @@ func (p Proxy) AddConsumer(c Consumer) {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("closed connection `%v`\n", c)
|
||||
log.Printf("closed connection `%v`\n", c)
|
||||
}()
|
||||
}
|
||||
|
||||
@ -105,13 +104,13 @@ func (p Proxy) AddProducer(pr Producer, v MacVerifier) {
|
||||
if reconnectable {
|
||||
var err error
|
||||
for once := true; err != nil || once; once = false {
|
||||
fmt.Printf("attempting to connect `%v`\n", pr)
|
||||
log.Printf("attempting to connect `%v`\n", pr)
|
||||
err = pr.(Reconnectable).Reconnect()
|
||||
if !once {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
fmt.Printf("connected `%v`\n", pr)
|
||||
log.Printf("connected `%v`\n", pr)
|
||||
}
|
||||
|
||||
for pr.IsAlive() {
|
||||
@ -124,6 +123,6 @@ func (p Proxy) AddProducer(pr Producer, v MacVerifier) {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("closed connection `%v`\n", pr)
|
||||
log.Printf("closed connection `%v`\n", pr)
|
||||
}()
|
||||
}
|
||||
|
@ -60,8 +60,12 @@ func (f *InitiatedFlow) Reconnect() error {
|
||||
return err
|
||||
}
|
||||
|
||||
f.conn, err = net.DialTCP("tcp", localAddr, remoteAddr)
|
||||
conn, err := net.DialTCP("tcp", localAddr, remoteAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = conn.SetWriteBuffer(0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package tcp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"mpbl3p/proxy"
|
||||
"net"
|
||||
)
|
||||
@ -24,9 +24,14 @@ func NewListener(p *proxy.Proxy, local string, v proxy.MacVerifier) error {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = conn.SetWriteBuffer(0)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
f := Flow{conn: conn, isAlive: true}
|
||||
|
||||
fmt.Printf("received new connection: %v\n", f)
|
||||
log.Printf("received new connection: %v\n", f)
|
||||
|
||||
p.AddConsumer(&f)
|
||||
p.AddProducer(&f, v)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package tun
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pkg/taptun"
|
||||
"io"
|
||||
"log"
|
||||
@ -85,7 +84,7 @@ func (t *SourceSink) Sink(packet proxy.Packet) error {
|
||||
switch err.(type) {
|
||||
case *os.PathError:
|
||||
bad += 1
|
||||
fmt.Printf("packet loss: %f%%\n", bad*100/(good+bad))
|
||||
log.Printf("packet loss: %f%%\n", bad*100/(good+bad))
|
||||
return nil
|
||||
default:
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user