2014-01-23 19:15:53 +00:00
|
|
|
package socks5
|
|
|
|
|
2016-03-08 14:29:11 +00:00
|
|
|
import (
|
2020-04-19 09:08:22 +00:00
|
|
|
"context"
|
2016-03-08 14:29:11 +00:00
|
|
|
"testing"
|
|
|
|
)
|
2014-01-23 19:15:53 +00:00
|
|
|
|
|
|
|
func TestPermitCommand(t *testing.T) {
|
2016-03-08 14:29:11 +00:00
|
|
|
ctx := context.Background()
|
2014-01-23 19:15:53 +00:00
|
|
|
r := &PermitCommand{true, false, false}
|
|
|
|
|
2020-04-19 15:40:14 +00:00
|
|
|
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: ConnectCommand}}); !ok {
|
2014-01-23 19:15:53 +00:00
|
|
|
t.Fatalf("expect connect")
|
|
|
|
}
|
|
|
|
|
2020-04-19 15:40:14 +00:00
|
|
|
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: BindCommand}}); ok {
|
2014-01-23 19:15:53 +00:00
|
|
|
t.Fatalf("do not expect bind")
|
|
|
|
}
|
|
|
|
|
2020-04-19 15:40:14 +00:00
|
|
|
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: AssociateCommand}}); ok {
|
2014-01-23 19:15:53 +00:00
|
|
|
t.Fatalf("do not expect associate")
|
|
|
|
}
|
|
|
|
}
|