Skip to content

Commit

Permalink
mark the inner loop
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Dec 10, 2024
1 parent 655736c commit 35c4bb1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hopper.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,22 +234,23 @@ func (l *Listener) switcher() {
return
}

RESULTS_LOOP:
for _, res := range results {
switch res.Operation {
case gaio.OpWrite:
// done writting to proxy connection.
if res.Error != nil {
l.logger.Printf("[switcher]gaio.OpWrite: %v, %v, %v, %v", res.Error, res.Conn.RemoteAddr(), res.Conn.LocalAddr(), res.Context)
l.removeClient(res.Conn.RemoteAddr())
continue
continue RESULTS_LOOP
}

case gaio.OpRead:
// any read error from the proxy connection cleans the other side(client).
if res.Error != nil {
l.logger.Printf("[switcher]gaio.OpRead: %v, %v, %v, %v", res.Error, res.Conn.RemoteAddr(), res.Conn.LocalAddr(), res.Context)
l.removeClient(res.Conn.RemoteAddr())
continue
continue RESULTS_LOOP
}

// received data from the proxy connection.
Expand All @@ -259,15 +260,15 @@ func (l *Listener) switcher() {
dataFromProxy, err := decryptPacket(l.crypterOut, dataFromProxy)
if err != nil {
l.logger.Println("[switcher]decryptPacket:", err)
continue
continue RESULTS_LOOP
}

// onNextHopIn callback
if l.onNextHopIn != nil {
dataFromProxy = l.onNextHopIn(res.Conn.RemoteAddr(), res.Context.(net.Addr), dataFromProxy)
// blackhole the packet if the callback returns nil.
if dataFromProxy == nil {
continue
continue RESULTS_LOOP
}
}

Expand Down

0 comments on commit 35c4bb1

Please sign in to comment.