tcp context fixes
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Jake Hillion 2021-05-11 21:43:47 +01:00
parent a0654b0016
commit edfd5a9009
3 changed files with 10 additions and 10 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
config.ini
*.conf
logs/
# Created by https://www.toptal.com/developers/gitignore/api/intellij+all,go

View File

@ -53,7 +53,7 @@ func NewFlow() Flow {
}
}
func NewFlowConn(conn Conn) Flow {
func NewFlowConn(ctx context.Context, conn Conn) Flow {
f := Flow{
conn: conn,
isAlive: true,
@ -64,8 +64,8 @@ func NewFlowConn(conn Conn) Flow {
produceErrors: make(chan error),
}
go f.produceMarshalled()
go f.consumeMarshalled()
go f.produceMarshalled(ctx)
go f.consumeMarshalled(ctx)
return f
}
@ -89,7 +89,7 @@ func InitiateFlow(local func() string, remote string) (*InitiatedFlow, error) {
return &f, nil
}
func (f *InitiatedFlow) Reconnect() error {
func (f *InitiatedFlow) Reconnect(ctx context.Context) error {
f.mu.Lock()
defer f.mu.Unlock()
@ -119,8 +119,8 @@ func (f *InitiatedFlow) Reconnect() error {
f.conn = conn
f.isAlive = true
go f.produceMarshalled()
go f.consumeMarshalled()
go f.produceMarshalled(ctx)
go f.consumeMarshalled(ctx)
return nil
}
@ -191,7 +191,7 @@ func (f *Flow) Produce(ctx context.Context, v proxy.MacVerifier) (proxy.Packet,
return proxy.SimplePacket(b), nil
}
func (f *Flow) consumeMarshalled() {
func (f *Flow) consumeMarshalled(ctx context.Context) {
for {
data := <-f.toConsume
@ -208,7 +208,7 @@ func (f *Flow) consumeMarshalled() {
}
}
func (f *Flow) produceMarshalled() {
func (f *Flow) produceMarshalled(ctx context.Context) {
buf := bufio.NewReader(f.conn)
for {

View File

@ -29,7 +29,7 @@ func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() pro
panic(err)
}
f := NewFlowConn(conn)
f := NewFlowConn(ctx, conn)
log.Printf("received new tcp connection: %v\n", f)