mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-17 00:23:56 +00:00
feat: now able to limit ip range for token now (close #1275)
This commit is contained in:
19
common/network/ip_test.go
Normal file
19
common/network/ip_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestIsIpInSubnet(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ip1 := "192.168.0.5"
|
||||
ip2 := "125.216.250.89"
|
||||
subnet := "192.168.0.0/24"
|
||||
Convey("TestIsIpInSubnet", t, func() {
|
||||
So(IsIpInSubnet(ctx, ip1, subnet), ShouldBeTrue)
|
||||
So(IsIpInSubnet(ctx, ip2, subnet), ShouldBeFalse)
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user