-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: hysteria1 outbound should be closed when proxy removed
- Loading branch information
Showing
7 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package outbound | ||
|
||
import ( | ||
"context" | ||
"runtime" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestHysteria2GC(t *testing.T) { | ||
option := Hysteria2Option{} | ||
option.Server = "127.0.0.1" | ||
option.Ports = "200,204,401-429,501-503" | ||
option.HopInterval = 30 | ||
option.Password = "password" | ||
option.Obfs = "salamander" | ||
option.ObfsPassword = "password" | ||
option.SNI = "example.com" | ||
option.ALPN = []string{"h3"} | ||
hy, err := NewHysteria2(option) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
closeCh := make(chan struct{}) | ||
hy.closeCh = closeCh | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) | ||
defer cancel() | ||
|
||
hy = nil | ||
runtime.GC() | ||
select { | ||
case <-closeCh: | ||
return | ||
case <-ctx.Done(): | ||
t.Error("timeout not GC") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package outbound | ||
|
||
import ( | ||
"context" | ||
"runtime" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestHysteriaGC(t *testing.T) { | ||
option := HysteriaOption{} | ||
option.Server = "127.0.0.1" | ||
option.Ports = "200,204,401-429,501-503" | ||
option.Protocol = "udp" | ||
option.Up = "1Mbps" | ||
option.Down = "1Mbps" | ||
option.HopInterval = 30 | ||
option.Obfs = "salamander" | ||
option.SNI = "example.com" | ||
option.ALPN = []string{"h3"} | ||
hy, err := NewHysteria(option) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
closeCh := make(chan struct{}) | ||
hy.closeCh = closeCh | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) | ||
defer cancel() | ||
|
||
hy = nil | ||
runtime.GC() | ||
select { | ||
case <-closeCh: | ||
return | ||
case <-ctx.Done(): | ||
t.Error("timeout not GC") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters