Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f61dbb42c5 | ||
|
|
40b7bf03b5 | ||
|
|
a3b2a4a5fc | ||
|
|
4b85c79336 | ||
|
|
e36fe95fd2 | ||
|
|
21a09a72fe | ||
|
|
074e070fe0 | ||
|
|
b58fbc1a3d | ||
|
|
c43e603172 | ||
|
|
b1c26cf4d8 | ||
|
|
fe6e18b8b6 | ||
|
|
1df73859f0 | ||
|
|
1579102b02 | ||
|
|
401dff2bdb | ||
|
|
c0eac9c246 | ||
|
|
0feb16682c | ||
|
|
ad4170fce1 | ||
|
|
71864f8785 | ||
|
|
457dacf9e0 | ||
|
|
e1b9c152d4 | ||
|
|
6361655beb | ||
|
|
a8061c9bf4 | ||
|
|
b7fe1b5b92 | ||
|
|
efe38c7b25 | ||
|
|
8f75042563 | ||
|
|
7172d23f96 | ||
|
|
cda24afca8 | ||
|
|
c6b2c3a004 | ||
|
|
4f59b231b9 | ||
|
|
080119c10a | ||
|
|
00aea25617 | ||
|
|
7ecdb0fc5c | ||
|
|
8ee7130ce9 | ||
|
|
b82ae7274b | ||
|
|
d6de9b5b09 | ||
|
|
f3ed064c10 | ||
|
|
00d8588abd | ||
|
|
a987837904 |
3
build/configs/.gitignore
vendored
3
build/configs/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
api.yaml
|
||||
db.yaml
|
||||
db.yaml
|
||||
.db.yaml
|
||||
@@ -1,16 +1,5 @@
|
||||
default:
|
||||
db: "prod"
|
||||
prefix: ""
|
||||
|
||||
dbs:
|
||||
prod:
|
||||
driver: "mysql"
|
||||
dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge?charset=utf8mb4&timeout=30s"
|
||||
prefix: "edge"
|
||||
models:
|
||||
package: internal/web/models
|
||||
|
||||
|
||||
fields:
|
||||
bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X", "retry40X", "autoSystemTuning", "disableDefaultDB", "autoTrimDisks" ]
|
||||
|
||||
user: root
|
||||
password: 123456
|
||||
host: 127.0.0.1:3306
|
||||
database: db_edge
|
||||
boolFields: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X", "retry40X", "autoSystemTuning", "disableDefaultDB", "autoTrimDisks", "enableGlobalPages", "ignoreLocal", "ignoreSearchEngine" ]
|
||||
44
go.mod
44
go.mod
@@ -5,42 +5,42 @@ go 1.21
|
||||
replace github.com/TeaOSLab/EdgeCommon => ../EdgeCommon
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.1.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0
|
||||
github.com/TeaOSLab/EdgeCommon v0.0.0-00010101000000-000000000000
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.587
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.712
|
||||
github.com/andybalholm/brotli v1.0.4
|
||||
github.com/aws/aws-sdk-go v1.40.45
|
||||
github.com/cespare/xxhash v1.1.0
|
||||
github.com/fsnotify/fsnotify v1.6.0
|
||||
github.com/go-acme/lego/v4 v4.10.2
|
||||
github.com/fsnotify/fsnotify v1.7.0
|
||||
github.com/go-acme/lego/v4 v4.15.0
|
||||
github.com/go-sql-driver/mysql v1.7.0
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
|
||||
github.com/iwind/TeaGo v0.0.0-20240312020455-6f20b5121caf
|
||||
github.com/iwind/TeaGo v0.0.0-20240508072741-7647e70b7070
|
||||
github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62
|
||||
github.com/miekg/dns v1.1.50
|
||||
github.com/miekg/dns v1.1.58
|
||||
github.com/mozillazg/go-pinyin v0.18.0
|
||||
github.com/pkg/sftp v1.12.0
|
||||
github.com/shirou/gopsutil/v3 v3.22.2
|
||||
github.com/smartwalle/alipay/v3 v3.2.20
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.801
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.801
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.898
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.898
|
||||
github.com/volcengine/volc-sdk-golang v1.0.124
|
||||
golang.org/x/crypto v0.22.0
|
||||
golang.org/x/net v0.24.0
|
||||
golang.org/x/sys v0.19.0
|
||||
google.golang.org/grpc v1.62.0
|
||||
google.golang.org/grpc v1.63.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
@@ -50,7 +50,7 @@ require (
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/smartwalle/ncrypto v1.0.4 // indirect
|
||||
@@ -60,11 +60,11 @@ require (
|
||||
github.com/tklauser/go-sysconf v0.3.9 // indirect
|
||||
github.com/tklauser/numcpus v0.3.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/mod v0.8.0 // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/tools v0.6.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240228224816-df926f6c8641 // indirect
|
||||
golang.org/x/tools v0.20.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/ini.v1 v1.66.6 // indirect
|
||||
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
)
|
||||
|
||||
99
go.sum
99
go.sum
@@ -31,16 +31,16 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 h1:9kDVnTz3vbfweTqAUmk/a/pH5pWFCHtvRpHYC0G/dcA=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0/go.mod h1:3Ug6Qzto9anB6mGlEdgYMDF5zHQ+wwhEaYR4s17PHMw=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.1.0 h1:8iR6OLffWWorFdzL2JFCab5xpD8VKEE2DUBBl+HNTDY=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.1.0/go.mod h1:copqlcjMWc/wgQ1N2fzsJFQxDdqKGg1EQt8T5wJMOGE=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 h1:E+OJmp2tPvt1W+amx48v1eqbjDYsgN+RzP4q16yV5eM=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 h1:FDif4R1+UUR+00q6wquyX90K7A8dN+R5E8GEadoP7sU=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2/go.mod h1:aiYBYui4BJ/BJCAIKs92XiPyQfTaBWqvHujDwKb6CBU=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 h1:lpOxwrQ919lCZoNCd69rVt8u1eLZuMORrGXqy8sNf3c=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0/go.mod h1:fSvRkb8d26z9dbL40Uf/OO6Vo9iExtZK3D0ulRV+8M0=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
@@ -65,8 +65,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.587 h1:R7QQjLc0y4eI2fqHrW2bsjhYzAQqpI1yxi11gZiETYU=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.587/go.mod h1:CJJYa1ZMxjlN/NbXEwmejEnBkhi0DV+Yb3B2lxf+74o=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.712 h1:lM7JnA9dEdDFH9XOgRNQMDTQnOjlLkDTNA7c0aWTQ30=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.712/go.mod h1:SOSDHfe1kX91v3W5QiBsWSLqeLxImobbMX1mxrFHsVQ=
|
||||
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
@@ -90,8 +90,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
|
||||
github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg=
|
||||
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
|
||||
github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4=
|
||||
github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
@@ -143,12 +143,16 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2
|
||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-acme/lego/v4 v4.15.0 h1:A7MHEU3b+TDFqhC/HmzMJnzPbyeaYvMZQBbqgvbThhU=
|
||||
github.com/go-acme/lego/v4 v4.15.0/go.mod h1:eeGhjW4zWT7Ccqa3sY7ayEqFLCAICx+mXgkMHKIkLxg=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA=
|
||||
github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs=
|
||||
@@ -172,8 +176,8 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
|
||||
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
|
||||
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
|
||||
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
@@ -203,8 +207,6 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
@@ -286,8 +288,8 @@ github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOc
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/iwind/TeaGo v0.0.0-20240312020455-6f20b5121caf h1:WA9qgiynESu/DDTnLH6npRI5AK6UL9qwJ2YZ5qhJX5E=
|
||||
github.com/iwind/TeaGo v0.0.0-20240312020455-6f20b5121caf/go.mod h1:SfqVbWyIPdVflyA6lMgicZzsoGS8pyeLiTRe8/CIpGI=
|
||||
github.com/iwind/TeaGo v0.0.0-20240508072741-7647e70b7070 h1:0YHZBcuXYbvtQ0XfEdtzr/XybiMrwD8vV1lvgAwzUW4=
|
||||
github.com/iwind/TeaGo v0.0.0-20240508072741-7647e70b7070/go.mod h1:SfqVbWyIPdVflyA6lMgicZzsoGS8pyeLiTRe8/CIpGI=
|
||||
github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62 h1:HJH6RDheAY156DnIfJSD/bEvqyXzsZuE2gzs8PuUjoo=
|
||||
github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA=
|
||||
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
|
||||
@@ -301,13 +303,11 @@ github.com/jhump/gopoet v0.1.0/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+
|
||||
github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7UvLHRQ=
|
||||
github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E=
|
||||
github.com/jhump/protoreflect v1.12.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
@@ -356,8 +356,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
|
||||
github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
|
||||
github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA=
|
||||
github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
|
||||
github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4=
|
||||
github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY=
|
||||
github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
|
||||
github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
|
||||
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
|
||||
@@ -407,8 +407,8 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T
|
||||
github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM=
|
||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
@@ -483,14 +483,14 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
|
||||
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.801 h1:zLWU179K63I2oLFIl9gXJ/NVfh7qDOVUARksccRDknE=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.801/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.801 h1:rb+yIO9B0B2ErwwOYsWrN9F1yG2v7Rx2wUL49j54y8k=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.801/go.mod h1:UwvDuz7b/sYx5Mc2qBz3ra6O9AWvvEWkmMEIei3kSFg=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.898 h1:ERwcXqhc94L9cFxtiI0pvt7IJtlHl/p/Jayl3mLw+ms=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.898/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.898 h1:LoYv5u+gUoFpU/AmIuTRG/2KiEkdm9gCC0dTvk8WITQ=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.898/go.mod h1:c1j6YQ+vCbeA8kJ59Im4UnMd1GxovlpPBDhGZoewfn8=
|
||||
github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo=
|
||||
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
|
||||
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
|
||||
@@ -540,6 +540,7 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
@@ -593,8 +594,9 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -634,7 +636,6 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
@@ -663,8 +664,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -723,14 +724,13 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -816,11 +816,11 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
|
||||
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
|
||||
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -883,8 +883,8 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240228224816-df926f6c8641 h1:DKU1r6Tj5s1vlU/moGhuGz7E3xRfwjdAfDzbsaQJtEY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240228224816-df926f6c8641/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
@@ -902,8 +902,8 @@ google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk=
|
||||
google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
||||
google.golang.org/grpc v1.63.1 h1:pNClQmvdlyNUiwFETOux/PYqfhmA7BrswEdGRnib1fA=
|
||||
google.golang.org/grpc v1.63.1/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
@@ -930,12 +930,9 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI=
|
||||
gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
|
||||
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package acme
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DNSProvider struct {
|
||||
@@ -29,7 +30,10 @@ func NewDNSProvider(raw dnsclients.ProviderInterface, dnsDomain string) *DNSProv
|
||||
|
||||
func (this *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
_ = os.Setenv("LEGO_DISABLE_CNAME_SUPPORT", "true")
|
||||
fqdn, value := dns01.GetRecord(domain, keyAuth)
|
||||
var info = dns01.GetChallengeInfo(domain, keyAuth)
|
||||
|
||||
var fqdn = info.EffectiveFQDN
|
||||
var value = info.Value
|
||||
|
||||
// 设置记录
|
||||
var index = strings.Index(fqdn, "."+this.dnsDomain)
|
||||
@@ -66,6 +70,7 @@ func (this *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
Type: dnstypes.RecordTypeTXT,
|
||||
Value: value,
|
||||
Route: this.raw.DefaultRoute(),
|
||||
TTL: this.raw.MinTTL(),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create DNS record failed: %w", err)
|
||||
@@ -74,6 +79,10 @@ func (this *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *DNSProvider) Timeout() (timeout, interval time.Duration) {
|
||||
return 2 * time.Minute, 2 * time.Second
|
||||
}
|
||||
|
||||
func (this *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package acme
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package acme
|
||||
|
||||
@@ -28,56 +28,63 @@ func SharedAPIConfig() (*APIConfig, error) {
|
||||
}
|
||||
|
||||
// 候选文件
|
||||
localFile := Tea.ConfigFile("api.yaml")
|
||||
isFromLocal := false
|
||||
paths := []string{localFile}
|
||||
homeDir, homeErr := os.UserHomeDir()
|
||||
if homeErr == nil {
|
||||
paths = append(paths, homeDir+"/."+teaconst.ProcessName+"/api.yaml")
|
||||
}
|
||||
paths = append(paths, "/etc/"+teaconst.ProcessName+"/api.yaml")
|
||||
|
||||
// 依次检查文件
|
||||
var data []byte
|
||||
var err error
|
||||
for _, path := range paths {
|
||||
data, err = os.ReadFile(path)
|
||||
if err == nil {
|
||||
if path == localFile {
|
||||
isFromLocal = true
|
||||
}
|
||||
break
|
||||
var config = &APIConfig{}
|
||||
{
|
||||
var localFile = Tea.ConfigFile("api.yaml")
|
||||
var isFromLocal = false
|
||||
var paths = []string{localFile}
|
||||
homeDir, homeErr := os.UserHomeDir()
|
||||
if homeErr == nil {
|
||||
paths = append(paths, homeDir+"/."+teaconst.ProcessName+"/api.yaml")
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
paths = append(paths, "/etc/"+teaconst.ProcessName+"/api.yaml")
|
||||
|
||||
// 解析内容
|
||||
config := &APIConfig{}
|
||||
err = yaml.Unmarshal(data, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 依次检查文件
|
||||
var data []byte
|
||||
var err error
|
||||
var firstErr error
|
||||
for _, path := range paths {
|
||||
data, err = os.ReadFile(path)
|
||||
if err != nil {
|
||||
if firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
} else {
|
||||
if path == localFile {
|
||||
isFromLocal = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if firstErr != nil {
|
||||
return nil, firstErr
|
||||
}
|
||||
|
||||
if !isFromLocal {
|
||||
// 恢复文件
|
||||
_ = os.WriteFile(localFile, data, 0666)
|
||||
// 解析内容
|
||||
err = yaml.Unmarshal(data, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !isFromLocal {
|
||||
// 恢复文件
|
||||
_ = os.WriteFile(localFile, data, 0666)
|
||||
}
|
||||
}
|
||||
|
||||
// 恢复数据库文件
|
||||
{
|
||||
dbConfigFile := Tea.ConfigFile("db.yaml")
|
||||
var dbConfigFile = Tea.ConfigFile("db.yaml")
|
||||
_, err := os.Stat(dbConfigFile)
|
||||
if err != nil {
|
||||
paths := []string{}
|
||||
var paths = []string{}
|
||||
homeDir, homeErr := os.UserHomeDir()
|
||||
if homeErr == nil {
|
||||
paths = append(paths, homeDir+"/."+teaconst.ProcessName+"/db.yaml")
|
||||
}
|
||||
paths = append(paths, "/etc/"+teaconst.ProcessName+"/db.yaml")
|
||||
for _, path := range paths {
|
||||
_, err := os.Stat(path)
|
||||
_, err = os.Stat(path)
|
||||
if err == nil {
|
||||
data, err := os.ReadFile(path)
|
||||
if err == nil {
|
||||
@@ -112,9 +119,9 @@ func (this *APIConfig) WriteFile(path string) error {
|
||||
}
|
||||
|
||||
// 生成备份文件
|
||||
filename := filepath.Base(path)
|
||||
var filename = filepath.Base(path)
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
backupDirs := []string{"/etc/edge-api"}
|
||||
var backupDirs = []string{"/etc/edge-api"}
|
||||
if len(homeDir) > 0 {
|
||||
backupDirs = append(backupDirs, homeDir+"/.edge-api")
|
||||
}
|
||||
@@ -135,7 +142,7 @@ func (this *APIConfig) WriteFile(path string) error {
|
||||
|
||||
// ResetAPIConfig 重置配置
|
||||
func ResetAPIConfig() error {
|
||||
for _, filename := range []string{"api.yaml", "db.yaml"} {
|
||||
for _, filename := range []string{"api.yaml", "db.yaml", ".db.yaml"} {
|
||||
// 重置 configs/api.yaml
|
||||
{
|
||||
var configFile = Tea.ConfigFile(filename)
|
||||
|
||||
25
internal/configs/db_config.go
Normal file
25
internal/configs/db_config.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package configs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"gopkg.in/yaml.v3"
|
||||
"os"
|
||||
)
|
||||
|
||||
func LoadDBConfig() (*dbs.Config, error) {
|
||||
var config = &dbs.Config{}
|
||||
for _, filename := range []string{".db.yaml", "db.yaml"} {
|
||||
configData, err := os.ReadFile(Tea.ConfigFile(filename))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
err = yaml.Unmarshal(configData, config)
|
||||
return config, err
|
||||
}
|
||||
|
||||
return nil, errors.New("could not find database config file '.db.yaml' or 'db.yaml'")
|
||||
}
|
||||
58
internal/configs/simple_db_config.go
Normal file
58
internal/configs/simple_db_config.go
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package configs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"gopkg.in/yaml.v3"
|
||||
"net/url"
|
||||
"os"
|
||||
)
|
||||
|
||||
type SimpleDBConfig struct {
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Database string `yaml:"database"`
|
||||
Host string `yaml:"host"`
|
||||
BoolFields []string `yaml:"boolFields,omitempty"`
|
||||
}
|
||||
|
||||
func ParseSimpleDBConfig(data []byte) (*SimpleDBConfig, error) {
|
||||
var config = &SimpleDBConfig{}
|
||||
err := yaml.Unmarshal(data, config)
|
||||
return config, err
|
||||
}
|
||||
|
||||
func (this *SimpleDBConfig) GenerateOldConfig() error {
|
||||
var dbConfig = &dbs.DBConfig{
|
||||
Driver: "mysql",
|
||||
Dsn: url.QueryEscape(this.User) + ":" + url.QueryEscape(this.Password) + "@tcp(" + this.Host + ")/" + url.PathEscape(this.Database) + "?charset=utf8mb4&timeout=30s&multiStatements=true",
|
||||
Prefix: "edge",
|
||||
}
|
||||
dbConfig.Models.Package = "internal/db/models"
|
||||
|
||||
var config = &dbs.Config{
|
||||
DBs: map[string]*dbs.DBConfig{
|
||||
Tea.Env: dbConfig,
|
||||
},
|
||||
}
|
||||
config.Default.DB = Tea.Env
|
||||
config.Fields = map[string][]string{
|
||||
"bool": this.BoolFields,
|
||||
}
|
||||
|
||||
oldConfigYAML, encodeErr := yaml.Marshal(config)
|
||||
if encodeErr != nil {
|
||||
return encodeErr
|
||||
}
|
||||
|
||||
var targetFile = Tea.ConfigFile(".db.yaml")
|
||||
err := os.WriteFile(targetFile, oldConfigYAML, 0666)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create database config file failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
//go:build !plus
|
||||
// +build !plus
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package teaconst
|
||||
|
||||
const (
|
||||
Version = "1.3.6"
|
||||
Version = "1.3.9"
|
||||
|
||||
ProductName = "Edge API"
|
||||
ProcessName = "edge-api"
|
||||
@@ -11,14 +11,11 @@ const (
|
||||
|
||||
Role = "api"
|
||||
|
||||
EncryptKey = "8f983f4d69b83aaa0d74b21a212f6967"
|
||||
EncryptMethod = "aes-256-cfb"
|
||||
|
||||
ErrServer = "服务器出了点小问题,请稍后重试"
|
||||
|
||||
SystemdServiceName = "edge-api"
|
||||
|
||||
// 其他节点版本号,用来检测是否有需要升级的节点
|
||||
|
||||
NodeVersion = "1.3.6"
|
||||
NodeVersion = "1.3.9"
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package teaconst
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package teaconst
|
||||
|
||||
|
||||
@@ -266,7 +266,6 @@ func (this *ACMETaskDAO) FindACMETaskUserId(tx *dbs.Tx, taskId int64) (userId in
|
||||
FindInt64Col(0)
|
||||
}
|
||||
|
||||
|
||||
// UpdateACMETaskCert 设置任务关联的证书
|
||||
func (this *ACMETaskDAO) UpdateACMETaskCert(tx *dbs.Tx, taskId int64, certId int64) error {
|
||||
if taskId <= 0 {
|
||||
@@ -387,6 +386,7 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
|
||||
errMsg = "暂不支持此类型的DNS服务商 '" + dnsProvider.Type + "'"
|
||||
return
|
||||
}
|
||||
providerInterface.SetMinTTL(int32(dnsProvider.MinTTL))
|
||||
apiParams, err := dnsProvider.DecodeAPIParams()
|
||||
if err != nil {
|
||||
errMsg = "解析DNS服务商API参数时出错:" + err.Error()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
//go:build !plus
|
||||
// +build !plus
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -67,7 +67,7 @@ func (this *DNSProviderDAO) FindEnabledDNSProvider(tx *dbs.Tx, id int64) (*DNSPr
|
||||
}
|
||||
|
||||
// CreateDNSProvider 创建服务商
|
||||
func (this *DNSProviderDAO) CreateDNSProvider(tx *dbs.Tx, adminId int64, userId int64, providerType string, name string, apiParamsJSON []byte) (int64, error) {
|
||||
func (this *DNSProviderDAO) CreateDNSProvider(tx *dbs.Tx, adminId int64, userId int64, providerType string, name string, apiParamsJSON []byte, minTTL int32) (int64, error) {
|
||||
var op = NewDNSProviderOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
@@ -76,6 +76,11 @@ func (this *DNSProviderDAO) CreateDNSProvider(tx *dbs.Tx, adminId int64, userId
|
||||
if len(apiParamsJSON) > 0 {
|
||||
op.ApiParams = apiParamsJSON
|
||||
}
|
||||
|
||||
if minTTL >= 0 {
|
||||
op.MinTTL = minTTL
|
||||
}
|
||||
|
||||
op.State = DNSProviderStateEnabled
|
||||
err := this.Save(tx, op)
|
||||
if err != nil {
|
||||
@@ -85,7 +90,7 @@ func (this *DNSProviderDAO) CreateDNSProvider(tx *dbs.Tx, adminId int64, userId
|
||||
}
|
||||
|
||||
// UpdateDNSProvider 修改服务商
|
||||
func (this *DNSProviderDAO) UpdateDNSProvider(tx *dbs.Tx, dnsProviderId int64, name string, apiParamsJSON []byte) error {
|
||||
func (this *DNSProviderDAO) UpdateDNSProvider(tx *dbs.Tx, dnsProviderId int64, name string, apiParamsJSON []byte, minTTL int32) error {
|
||||
if dnsProviderId <= 0 {
|
||||
return errors.New("invalid dnsProviderId")
|
||||
}
|
||||
@@ -99,6 +104,10 @@ func (this *DNSProviderDAO) UpdateDNSProvider(tx *dbs.Tx, dnsProviderId int64, n
|
||||
op.ApiParams = apiParamsJSON
|
||||
}
|
||||
|
||||
if minTTL >= 0 {
|
||||
op.MinTTL = minTTL
|
||||
}
|
||||
|
||||
err := this.Save(tx, op)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -2,6 +2,19 @@ package dns
|
||||
|
||||
import "github.com/iwind/TeaGo/dbs"
|
||||
|
||||
const (
|
||||
DNSProviderField_Id dbs.FieldName = "id" // ID
|
||||
DNSProviderField_Name dbs.FieldName = "name" // 名称
|
||||
DNSProviderField_AdminId dbs.FieldName = "adminId" // 管理员ID
|
||||
DNSProviderField_UserId dbs.FieldName = "userId" // 用户ID
|
||||
DNSProviderField_Type dbs.FieldName = "type" // 供应商类型
|
||||
DNSProviderField_ApiParams dbs.FieldName = "apiParams" // API参数
|
||||
DNSProviderField_CreatedAt dbs.FieldName = "createdAt" // 创建时间
|
||||
DNSProviderField_State dbs.FieldName = "state" // 状态
|
||||
DNSProviderField_DataUpdatedAt dbs.FieldName = "dataUpdatedAt" // 数据同步时间
|
||||
DNSProviderField_MinTTL dbs.FieldName = "minTTL" // 最小TTL
|
||||
)
|
||||
|
||||
// DNSProvider DNS服务商
|
||||
type DNSProvider struct {
|
||||
Id uint32 `field:"id"` // ID
|
||||
@@ -13,18 +26,20 @@ type DNSProvider struct {
|
||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||
State uint8 `field:"state"` // 状态
|
||||
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据同步时间
|
||||
MinTTL uint32 `field:"minTTL"` // 最小TTL
|
||||
}
|
||||
|
||||
type DNSProviderOperator struct {
|
||||
Id interface{} // ID
|
||||
Name interface{} // 名称
|
||||
AdminId interface{} // 管理员ID
|
||||
UserId interface{} // 用户ID
|
||||
Type interface{} // 供应商类型
|
||||
ApiParams interface{} // API参数
|
||||
CreatedAt interface{} // 创建时间
|
||||
State interface{} // 状态
|
||||
DataUpdatedAt interface{} // 数据同步时间
|
||||
Id any // ID
|
||||
Name any // 名称
|
||||
AdminId any // 管理员ID
|
||||
UserId any // 用户ID
|
||||
Type any // 供应商类型
|
||||
ApiParams any // API参数
|
||||
CreatedAt any // 创建时间
|
||||
State any // 状态
|
||||
DataUpdatedAt any // 数据同步时间
|
||||
MinTTL any // 最小TTL
|
||||
}
|
||||
|
||||
func NewDNSProviderOperator() *DNSProviderOperator {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package dnsutils
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package dnsutils
|
||||
|
||||
|
||||
@@ -520,14 +520,27 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx,
|
||||
|
||||
// keyword
|
||||
if len(ip) > 0 {
|
||||
// TODO 支持IPv6范围
|
||||
if tableQuery.hasRemoteAddrField {
|
||||
// IP格式
|
||||
if strings.Contains(ip, ",") || strings.Contains(ip, "-") {
|
||||
rangeConfig, err := shared.ParseIPRange(ip)
|
||||
if err == nil {
|
||||
rangeConfig, parseErr := shared.ParseIPRange(ip)
|
||||
if parseErr == nil {
|
||||
if len(rangeConfig.IPFrom) > 0 && len(rangeConfig.IPTo) > 0 {
|
||||
query.Between("INET_ATON(remoteAddr)", iputils.ToLong(rangeConfig.IPFrom), iputils.ToLong(rangeConfig.IPTo))
|
||||
if iputils.IsIPv6(rangeConfig.IPFrom) || iputils.IsIPv6(rangeConfig.IPTo) {
|
||||
var ipFromHex = iputils.ToHex(rangeConfig.IPFrom)
|
||||
var ipToHex = iputils.ToHex(rangeConfig.IPTo)
|
||||
if ipFromHex > ipToHex {
|
||||
ipFromHex, ipToHex = ipToHex, ipFromHex
|
||||
}
|
||||
query.Between("HEX(INET6_ATON(remoteAddr))", ipFromHex, ipToHex)
|
||||
} else {
|
||||
var ipFromLong = iputils.ToLong(rangeConfig.IPFrom)
|
||||
var ipToLong = iputils.ToLong(rangeConfig.IPTo)
|
||||
if ipFromLong > ipToLong {
|
||||
ipFromLong, ipToLong = ipToLong, ipFromLong
|
||||
}
|
||||
query.Between("INET_ATON(remoteAddr)", ipFromLong, ipToLong)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package models
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package models_test
|
||||
|
||||
|
||||
@@ -165,17 +165,15 @@ func (this *HTTPCachePolicyDAO) CreateDefaultCachePolicy(tx *dbs.Tx, name string
|
||||
Count: 256,
|
||||
Unit: shared.SizeCapacityUnitMB,
|
||||
}
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
maxSizeJSON, err := maxSize.AsJSON()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var storageOptions = &serverconfigs.HTTPFileCacheStorage{
|
||||
Dir: "/opt/cache",
|
||||
EnableMMAP: true,
|
||||
Dir: "/opt/cache",
|
||||
EnableMMAP: false,
|
||||
EnableIncompletePartialContent: true,
|
||||
MemoryPolicy: &serverconfigs.HTTPCachePolicy{
|
||||
Capacity: &shared.SizeCapacity{
|
||||
Count: 1,
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ipconfigs"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
@@ -238,7 +239,7 @@ func (this *HTTPFirewallPolicyDAO) CreateDefaultFirewallPolicy(tx *dbs.Tx, name
|
||||
return 0, err
|
||||
}
|
||||
|
||||
err = this.UpdateFirewallPolicyInboundAndOutbound(tx, policyId, inboundConfigJSON, outboundConfigJSON, false)
|
||||
err = this.UpdateFirewallPolicyInboundAndOutbound(tx, policyId, 0, 0, inboundConfigJSON, outboundConfigJSON, false)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -247,10 +248,60 @@ func (this *HTTPFirewallPolicyDAO) CreateDefaultFirewallPolicy(tx *dbs.Tx, name
|
||||
}
|
||||
|
||||
// UpdateFirewallPolicyInboundAndOutbound 修改策略的Inbound和Outbound
|
||||
func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInboundAndOutbound(tx *dbs.Tx, policyId int64, inboundJSON []byte, outboundJSON []byte, shouldNotify bool) error {
|
||||
func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInboundAndOutbound(tx *dbs.Tx, policyId int64, userId int64, serverId int64, inboundJSON []byte, outboundJSON []byte, shouldNotify bool) error {
|
||||
if policyId <= 0 {
|
||||
return errors.New("invalid policyId")
|
||||
}
|
||||
|
||||
// 创建默认的Inbound
|
||||
var inboundConfig = &firewallconfigs.HTTPFirewallInboundConfig{IsOn: true}
|
||||
if inboundJSON != nil {
|
||||
err := json.Unmarshal(inboundJSON, inboundConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// IP名单
|
||||
if inboundConfig.AllowListRef == nil {
|
||||
listId, createListErr := SharedIPListDAO.CreateIPList(tx, userId, serverId, ipconfigs.IPListTypeWhite, "白名单", "", nil, "", false, false)
|
||||
if createListErr != nil {
|
||||
return createListErr
|
||||
}
|
||||
inboundConfig.AllowListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
ListId: listId,
|
||||
}
|
||||
}
|
||||
|
||||
if inboundConfig.DenyListRef == nil {
|
||||
listId, createListErr := SharedIPListDAO.CreateIPList(tx, userId, serverId, ipconfigs.IPListTypeBlack, "黑名单", "", nil, "", false, false)
|
||||
if createListErr != nil {
|
||||
return createListErr
|
||||
}
|
||||
inboundConfig.DenyListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
ListId: listId,
|
||||
}
|
||||
}
|
||||
|
||||
if inboundConfig.GreyListRef == nil {
|
||||
listId, createListErr := SharedIPListDAO.CreateIPList(tx, userId, serverId, ipconfigs.IPListTypeGrey, "灰名单", "", nil, "", false, false)
|
||||
if createListErr != nil {
|
||||
return createListErr
|
||||
}
|
||||
inboundConfig.GreyListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
ListId: listId,
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
inboundJSON, err = json.Marshal(inboundConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var op = NewHTTPFirewallPolicyOperator()
|
||||
op.Id = policyId
|
||||
if len(inboundJSON) > 0 {
|
||||
@@ -263,7 +314,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInboundAndOutbound(tx *db
|
||||
} else {
|
||||
op.Outbound = "null"
|
||||
}
|
||||
err := this.Save(tx, op)
|
||||
err = this.Save(tx, op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -645,7 +696,7 @@ func (this *HTTPFirewallPolicyDAO) FindEnabledFirewallPolicyIdsWithIPListId(tx *
|
||||
ones, err := this.Query(tx).
|
||||
ResultPk().
|
||||
State(HTTPFirewallPolicyStateEnabled).
|
||||
Where("(JSON_CONTAINS(inbound, :listQuery, '$.whiteListRef') OR JSON_CONTAINS(inbound, :listQuery, '$.blackListRef') OR JSON_CONTAINS(inbound, :listQuery, '$.publicWhiteListRefs') OR JSON_CONTAINS(inbound, :listQuery, '$.publicBlackListRefs'))").
|
||||
Where("(JSON_CONTAINS(inbound, :listQuery, '$.whiteListRef') OR JSON_CONTAINS(inbound, :listQuery, '$.blackListRef') OR JSON_CONTAINS(inbound, :listQuery, '$.publicWhiteListRefs') OR JSON_CONTAINS(inbound, :listQuery, '$.publicBlackListRefs') OR JSON_CONTAINS(inbound, :listQuery, '$.publicGreyListRefs'))").
|
||||
Param("listQuery", maps.Map{"isOn": true, "listId": ipListId}.AsJSON()).
|
||||
FindAll()
|
||||
if err != nil {
|
||||
@@ -663,7 +714,7 @@ func (this *HTTPFirewallPolicyDAO) FindEnabledFirewallPolicyIdsWithIPListId(tx *
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledFirewallPolicyWithIPListId(tx *dbs.Tx, ipListId int64) (*HTTPFirewallPolicy, error) {
|
||||
one, err := this.Query(tx).
|
||||
State(HTTPFirewallPolicyStateEnabled).
|
||||
Where("(JSON_CONTAINS(inbound, :listQuery, '$.whiteListRef') OR JSON_CONTAINS(inbound, :listQuery, '$.blackListRef'))").
|
||||
Where("(JSON_CONTAINS(inbound, :listQuery, '$.whiteListRef') OR JSON_CONTAINS(inbound, :listQuery, '$.blackListRef') OR JSON_CONTAINS(inbound, :listQuery, '$.greyListRef'))").
|
||||
Param("listQuery", maps.Map{"isOn": true, "listId": ipListId}.AsJSON()).
|
||||
Find()
|
||||
if err != nil || one == nil {
|
||||
|
||||
@@ -99,7 +99,8 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
|
||||
config.Description = set.Description
|
||||
config.Code = set.Code
|
||||
config.Connector = set.Connector
|
||||
config.IgnoreLocal = set.IgnoreLocal == 1
|
||||
config.IgnoreLocal = set.IgnoreLocal
|
||||
config.IgnoreSearchEngine = set.IgnoreSearchEngine
|
||||
|
||||
if IsNotNull(set.Rules) {
|
||||
var ruleRefs = []*firewallconfigs.HTTPFirewallRuleRef{}
|
||||
@@ -135,7 +136,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
|
||||
var ipListId = actionConfig.Options.GetInt64("ipListId")
|
||||
if ipListId <= 0 { // default list id
|
||||
if forNode {
|
||||
actionConfig.Options["ipListId"] = firewallconfigs.GlobalListId
|
||||
actionConfig.Options["ipListId"] = firewallconfigs.FindGlobalListIdWithType(actionConfig.Options.GetString("type"))
|
||||
}
|
||||
actionConfig.Options["ipListIsDeleted"] = false
|
||||
} else {
|
||||
@@ -164,6 +165,7 @@ func (this *HTTPFirewallRuleSetDAO) CreateOrUpdateSetFromConfig(tx *dbs.Tx, setC
|
||||
op.Description = setConfig.Description
|
||||
op.Connector = setConfig.Connector
|
||||
op.IgnoreLocal = setConfig.IgnoreLocal
|
||||
op.IgnoreSearchEngine = setConfig.IgnoreSearchEngine
|
||||
|
||||
if len(setConfig.Actions) == 0 {
|
||||
op.Actions = "[]"
|
||||
|
||||
@@ -2,41 +2,62 @@ package models
|
||||
|
||||
import "github.com/iwind/TeaGo/dbs"
|
||||
|
||||
const (
|
||||
HTTPFirewallRuleSetField_Id dbs.FieldName = "id" // ID
|
||||
HTTPFirewallRuleSetField_IsOn dbs.FieldName = "isOn" // 是否启用
|
||||
HTTPFirewallRuleSetField_Code dbs.FieldName = "code" // 代号
|
||||
HTTPFirewallRuleSetField_Name dbs.FieldName = "name" // 名称
|
||||
HTTPFirewallRuleSetField_Description dbs.FieldName = "description" // 描述
|
||||
HTTPFirewallRuleSetField_CreatedAt dbs.FieldName = "createdAt" // 创建时间
|
||||
HTTPFirewallRuleSetField_Rules dbs.FieldName = "rules" // 规则列表
|
||||
HTTPFirewallRuleSetField_Connector dbs.FieldName = "connector" // 规则之间的关系
|
||||
HTTPFirewallRuleSetField_State dbs.FieldName = "state" // 状态
|
||||
HTTPFirewallRuleSetField_AdminId dbs.FieldName = "adminId" // 管理员ID
|
||||
HTTPFirewallRuleSetField_UserId dbs.FieldName = "userId" // 用户ID
|
||||
HTTPFirewallRuleSetField_Action dbs.FieldName = "action" // 执行的动作(过期)
|
||||
HTTPFirewallRuleSetField_ActionOptions dbs.FieldName = "actionOptions" // 动作的选项(过期)
|
||||
HTTPFirewallRuleSetField_Actions dbs.FieldName = "actions" // 一组动作
|
||||
HTTPFirewallRuleSetField_IgnoreLocal dbs.FieldName = "ignoreLocal" // 忽略局域网请求
|
||||
HTTPFirewallRuleSetField_IgnoreSearchEngine dbs.FieldName = "ignoreSearchEngine" // 忽略搜索引擎
|
||||
)
|
||||
|
||||
// HTTPFirewallRuleSet 防火墙规则集
|
||||
type HTTPFirewallRuleSet struct {
|
||||
Id uint32 `field:"id"` // ID
|
||||
IsOn bool `field:"isOn"` // 是否启用
|
||||
Code string `field:"code"` // 代号
|
||||
Name string `field:"name"` // 名称
|
||||
Description string `field:"description"` // 描述
|
||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||
Rules dbs.JSON `field:"rules"` // 规则列表
|
||||
Connector string `field:"connector"` // 规则之间的关系
|
||||
State uint8 `field:"state"` // 状态
|
||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||
UserId uint32 `field:"userId"` // 用户ID
|
||||
Action string `field:"action"` // 执行的动作(过期)
|
||||
ActionOptions dbs.JSON `field:"actionOptions"` // 动作的选项(过期)
|
||||
Actions dbs.JSON `field:"actions"` // 一组动作
|
||||
IgnoreLocal uint8 `field:"ignoreLocal"` // 忽略局域网请求
|
||||
Id uint32 `field:"id"` // ID
|
||||
IsOn bool `field:"isOn"` // 是否启用
|
||||
Code string `field:"code"` // 代号
|
||||
Name string `field:"name"` // 名称
|
||||
Description string `field:"description"` // 描述
|
||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||
Rules dbs.JSON `field:"rules"` // 规则列表
|
||||
Connector string `field:"connector"` // 规则之间的关系
|
||||
State uint8 `field:"state"` // 状态
|
||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||
UserId uint32 `field:"userId"` // 用户ID
|
||||
Action string `field:"action"` // 执行的动作(过期)
|
||||
ActionOptions dbs.JSON `field:"actionOptions"` // 动作的选项(过期)
|
||||
Actions dbs.JSON `field:"actions"` // 一组动作
|
||||
IgnoreLocal bool `field:"ignoreLocal"` // 忽略局域网请求
|
||||
IgnoreSearchEngine bool `field:"ignoreSearchEngine"` // 忽略搜索引擎
|
||||
}
|
||||
|
||||
type HTTPFirewallRuleSetOperator struct {
|
||||
Id interface{} // ID
|
||||
IsOn interface{} // 是否启用
|
||||
Code interface{} // 代号
|
||||
Name interface{} // 名称
|
||||
Description interface{} // 描述
|
||||
CreatedAt interface{} // 创建时间
|
||||
Rules interface{} // 规则列表
|
||||
Connector interface{} // 规则之间的关系
|
||||
State interface{} // 状态
|
||||
AdminId interface{} // 管理员ID
|
||||
UserId interface{} // 用户ID
|
||||
Action interface{} // 执行的动作(过期)
|
||||
ActionOptions interface{} // 动作的选项(过期)
|
||||
Actions interface{} // 一组动作
|
||||
IgnoreLocal interface{} // 忽略局域网请求
|
||||
Id any // ID
|
||||
IsOn any // 是否启用
|
||||
Code any // 代号
|
||||
Name any // 名称
|
||||
Description any // 描述
|
||||
CreatedAt any // 创建时间
|
||||
Rules any // 规则列表
|
||||
Connector any // 规则之间的关系
|
||||
State any // 状态
|
||||
AdminId any // 管理员ID
|
||||
UserId any // 用户ID
|
||||
Action any // 执行的动作(过期)
|
||||
ActionOptions any // 动作的选项(过期)
|
||||
Actions any // 一组动作
|
||||
IgnoreLocal any // 忽略局域网请求
|
||||
IgnoreSearchEngine any // 忽略搜索引擎
|
||||
}
|
||||
|
||||
func NewHTTPFirewallRuleSetOperator() *HTTPFirewallRuleSetOperator {
|
||||
|
||||
@@ -231,6 +231,8 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, isLocationOrGr
|
||||
}
|
||||
|
||||
// pages
|
||||
config.EnableGlobalPages = web.EnableGlobalPages
|
||||
|
||||
// TODO 检查forNode参数
|
||||
if IsNotNull(web.Pages) {
|
||||
var pages = []*serverconfigs.HTTPPageConfig{}
|
||||
@@ -758,6 +760,22 @@ func (this *HTTPWebDAO) UpdateWebPages(tx *dbs.Tx, webId int64, pagesJSON []byte
|
||||
return this.NotifyUpdate(tx, webId)
|
||||
}
|
||||
|
||||
// UpdateGlobalPagesEnabled 设置是否启用系统配置的自定义页面
|
||||
func (this *HTTPWebDAO) UpdateGlobalPagesEnabled(tx *dbs.Tx, webId int64, isEnabled bool) error {
|
||||
if webId <= 0 {
|
||||
return errors.New("invalid webId")
|
||||
}
|
||||
err := this.Query(tx).
|
||||
Pk(webId).
|
||||
Set(HTTPWebField_EnableGlobalPages, isEnabled).
|
||||
UpdateQuickly()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return this.NotifyUpdate(tx, webId)
|
||||
}
|
||||
|
||||
// UpdateWebShutdown 更改Shutdown配置
|
||||
func (this *HTTPWebDAO) UpdateWebShutdown(tx *dbs.Tx, webId int64, shutdownJSON []byte) error {
|
||||
if webId <= 0 {
|
||||
|
||||
@@ -14,6 +14,7 @@ const (
|
||||
HTTPWebField_Charset dbs.FieldName = "charset" // 字符集
|
||||
HTTPWebField_Shutdown dbs.FieldName = "shutdown" // 临时关闭页面配置
|
||||
HTTPWebField_Pages dbs.FieldName = "pages" // 特殊页面
|
||||
HTTPWebField_EnableGlobalPages dbs.FieldName = "enableGlobalPages" // 是否启用系统配置的自定义页面
|
||||
HTTPWebField_RedirectToHttps dbs.FieldName = "redirectToHttps" // 跳转到HTTPS设置
|
||||
HTTPWebField_Indexes dbs.FieldName = "indexes" // 首页文件列表
|
||||
HTTPWebField_MaxRequestBodySize dbs.FieldName = "maxRequestBodySize" // 最大允许的请求内容尺寸
|
||||
@@ -57,6 +58,7 @@ type HTTPWeb struct {
|
||||
Charset dbs.JSON `field:"charset"` // 字符集
|
||||
Shutdown dbs.JSON `field:"shutdown"` // 临时关闭页面配置
|
||||
Pages dbs.JSON `field:"pages"` // 特殊页面
|
||||
EnableGlobalPages bool `field:"enableGlobalPages"` // 是否启用系统配置的自定义页面
|
||||
RedirectToHttps dbs.JSON `field:"redirectToHttps"` // 跳转到HTTPS设置
|
||||
Indexes dbs.JSON `field:"indexes"` // 首页文件列表
|
||||
MaxRequestBodySize dbs.JSON `field:"maxRequestBodySize"` // 最大允许的请求内容尺寸
|
||||
@@ -99,6 +101,7 @@ type HTTPWebOperator struct {
|
||||
Charset any // 字符集
|
||||
Shutdown any // 临时关闭页面配置
|
||||
Pages any // 特殊页面
|
||||
EnableGlobalPages any // 是否启用系统配置的自定义页面
|
||||
RedirectToHttps any // 跳转到HTTPS设置
|
||||
Indexes any // 首页文件列表
|
||||
MaxRequestBodySize any // 最大允许的请求内容尺寸
|
||||
|
||||
@@ -76,7 +76,7 @@ func (this *IPItemDAO) EnableIPItem(tx *dbs.Tx, id int64) error {
|
||||
}
|
||||
|
||||
// DisableIPItem 禁用条目
|
||||
func (this *IPItemDAO) DisableIPItem(tx *dbs.Tx, id int64, sourceUserId int64) error {
|
||||
func (this *IPItemDAO) DisableIPItem(tx *dbs.Tx, itemId int64, sourceUserId int64) error {
|
||||
version, err := SharedIPListDAO.IncreaseVersion(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -91,7 +91,7 @@ func (this *IPItemDAO) DisableIPItem(tx *dbs.Tx, id int64, sourceUserId int64) e
|
||||
}
|
||||
|
||||
_, err = query.
|
||||
Pk(id).
|
||||
Pk(itemId).
|
||||
Set("state", IPItemStateDisabled).
|
||||
Set("version", version).
|
||||
Update()
|
||||
@@ -99,7 +99,7 @@ func (this *IPItemDAO) DisableIPItem(tx *dbs.Tx, id int64, sourceUserId int64) e
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return this.NotifyUpdate(tx, id)
|
||||
return this.NotifyUpdate(tx, itemId)
|
||||
}
|
||||
|
||||
// DisableIPItemsWithIP 禁用某个IP相关条目
|
||||
@@ -297,7 +297,7 @@ func (this *IPItemDAO) DeleteOldItemWithValue(tx *dbs.Tx, listId int64, value st
|
||||
}
|
||||
ones, err := this.Query(tx).
|
||||
ResultPk().
|
||||
UseIndex("ipFrom").
|
||||
UseIndex("value").
|
||||
Attr("listId", listId).
|
||||
Attr("value", value).
|
||||
Attr("state", IPItemStateEnabled).
|
||||
@@ -390,7 +390,7 @@ func (this *IPItemDAO) CreateIPItem(tx *dbs.Tx,
|
||||
op.SourceUserId = userId
|
||||
}
|
||||
|
||||
var autoAdded = listId == firewallconfigs.GlobalListId || sourceNodeId > 0 || sourceServerId > 0 || sourceHTTPFirewallPolicyId > 0
|
||||
var autoAdded = firewallconfigs.IsGlobalListId(listId) || sourceNodeId > 0 || sourceServerId > 0 || sourceHTTPFirewallPolicyId > 0
|
||||
if autoAdded {
|
||||
op.IsRead = 0
|
||||
}
|
||||
@@ -477,7 +477,7 @@ func (this *IPItemDAO) CountIPItemsWithListId(tx *dbs.Tx, listId int64, sourceUs
|
||||
State(IPItemStateEnabled).
|
||||
Attr("listId", listId)
|
||||
if sourceUserId > 0 {
|
||||
if listId <= 0 || listId == firewallconfigs.GlobalListId {
|
||||
if listId <= 0 || firewallconfigs.IsGlobalListId(listId) {
|
||||
query.Attr("sourceUserId", sourceUserId)
|
||||
}
|
||||
}
|
||||
@@ -503,7 +503,7 @@ func (this *IPItemDAO) ListIPItemsWithListId(tx *dbs.Tx, listId int64, sourceUse
|
||||
State(IPItemStateEnabled).
|
||||
Attr("listId", listId)
|
||||
if sourceUserId > 0 {
|
||||
if listId <= 0 || listId == firewallconfigs.GlobalListId {
|
||||
if listId <= 0 || firewallconfigs.IsGlobalListId(listId) {
|
||||
query.Attr("sourceUserId", sourceUserId)
|
||||
}
|
||||
}
|
||||
@@ -600,13 +600,25 @@ func (this *IPItemDAO) ExistsEnabledItem(tx *dbs.Tx, itemId int64) (bool, error)
|
||||
}
|
||||
|
||||
// CountAllEnabledIPItems 计算数量
|
||||
func (this *IPItemDAO) CountAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, keyword string, ip string, listId int64, unread bool, eventLevel string, listType string) (int64, error) {
|
||||
func (this *IPItemDAO) CountAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, keyword string, ip string, listId int64, unread bool, eventLevel string, listType string, isGlobal bool) (int64, error) {
|
||||
var query = this.Query(tx)
|
||||
var globalListIdStrings = strings.Join(firewallconfigs.FindGlobalListIdStrings(), ",")
|
||||
if len(listType) > 0 {
|
||||
var globalListId = firewallconfigs.FindGlobalListIdWithType(listType)
|
||||
if globalListId > 0 {
|
||||
globalListIdStrings = types.String(globalListId)
|
||||
}
|
||||
}
|
||||
|
||||
if sourceUserId > 0 {
|
||||
if listId <= 0 {
|
||||
query.Where("((listId=" + types.String(firewallconfigs.GlobalListId) + " AND sourceUserId=:sourceUserId) OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE userId=:sourceUserId AND state=1))")
|
||||
if isGlobal {
|
||||
query.Where("(listId IN (" + globalListIdStrings + ") AND sourceUserId=:sourceUserId)")
|
||||
} else {
|
||||
query.Where("((listId IN (" + globalListIdStrings + ") AND sourceUserId=:sourceUserId) OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE userId=:sourceUserId AND state=1))")
|
||||
}
|
||||
query.Param("sourceUserId", sourceUserId)
|
||||
} else if listId == firewallconfigs.GlobalListId {
|
||||
} else if firewallconfigs.IsGlobalListId(listId) {
|
||||
query.Attr("sourceUserId", sourceUserId)
|
||||
query.UseIndex("sourceUserId")
|
||||
}
|
||||
@@ -631,10 +643,18 @@ func (this *IPItemDAO) CountAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, ke
|
||||
query.Attr("listId", listId)
|
||||
} else {
|
||||
if len(listType) > 0 {
|
||||
query.Where("(listId=" + types.String(firewallconfigs.GlobalListId) + " OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1 AND type=:listType))")
|
||||
if isGlobal {
|
||||
query.Where("(listId IN (" + globalListIdStrings + "))")
|
||||
} else {
|
||||
query.Where("(listId IN (" + globalListIdStrings + ") OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1 AND type=:listType))")
|
||||
}
|
||||
query.Param("listType", listType)
|
||||
} else {
|
||||
query.Where("(listId=" + types.String(firewallconfigs.GlobalListId) + " OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1))")
|
||||
if isGlobal {
|
||||
query.Where("(listId IN (" + globalListIdStrings + "))")
|
||||
} else {
|
||||
query.Where("(listId IN (" + globalListIdStrings + ") OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1))")
|
||||
}
|
||||
}
|
||||
}
|
||||
if unread {
|
||||
@@ -652,13 +672,25 @@ func (this *IPItemDAO) CountAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, ke
|
||||
}
|
||||
|
||||
// ListAllEnabledIPItems 搜索所有IP
|
||||
func (this *IPItemDAO) ListAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, keyword string, ip string, listId int64, unread bool, eventLevel string, listType string, offset int64, size int64) (result []*IPItem, err error) {
|
||||
func (this *IPItemDAO) ListAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, keyword string, ip string, listId int64, unread bool, eventLevel string, listType string, isGlobal bool, offset int64, size int64) (result []*IPItem, err error) {
|
||||
var globalListIdStrings = strings.Join(firewallconfigs.FindGlobalListIdStrings(), ",")
|
||||
if len(listType) > 0 {
|
||||
var globalListId = firewallconfigs.FindGlobalListIdWithType(listType)
|
||||
if globalListId > 0 {
|
||||
globalListIdStrings = types.String(globalListId)
|
||||
}
|
||||
}
|
||||
|
||||
var query = this.Query(tx)
|
||||
if sourceUserId > 0 {
|
||||
if listId <= 0 {
|
||||
query.Where("((listId=" + types.String(firewallconfigs.GlobalListId) + " AND sourceUserId=:sourceUserId) OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE userId=:sourceUserId AND state=1))")
|
||||
if isGlobal {
|
||||
query.Where("(listId IN (" + globalListIdStrings + ") AND sourceUserId=:sourceUserId)")
|
||||
} else {
|
||||
query.Where("((listId IN (" + globalListIdStrings + ") AND sourceUserId=:sourceUserId) OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE userId=:sourceUserId AND state=1))")
|
||||
}
|
||||
query.Param("sourceUserId", sourceUserId)
|
||||
} else if listId == firewallconfigs.GlobalListId {
|
||||
} else if firewallconfigs.IsGlobalListId(listId) {
|
||||
query.Attr("sourceUserId", sourceUserId)
|
||||
query.UseIndex("sourceUserId")
|
||||
}
|
||||
@@ -683,10 +715,18 @@ func (this *IPItemDAO) ListAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, key
|
||||
query.Attr("listId", listId)
|
||||
} else {
|
||||
if len(listType) > 0 {
|
||||
query.Where("(listId=" + types.String(firewallconfigs.GlobalListId) + " OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1 AND type=:listType))")
|
||||
if isGlobal {
|
||||
query.Where("(listId IN (" + globalListIdStrings + "))")
|
||||
} else {
|
||||
query.Where("(listId IN (" + globalListIdStrings + ") OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1 AND type=:listType))")
|
||||
}
|
||||
query.Param("listType", listType)
|
||||
} else {
|
||||
query.Where("(listId=" + types.String(firewallconfigs.GlobalListId) + " OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1))")
|
||||
if isGlobal {
|
||||
query.Where("(listId IN (" + globalListIdStrings + "))")
|
||||
} else {
|
||||
query.Where("(listId IN (" + globalListIdStrings + ") OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1))")
|
||||
}
|
||||
}
|
||||
}
|
||||
if unread {
|
||||
@@ -709,12 +749,20 @@ func (this *IPItemDAO) ListAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, key
|
||||
|
||||
// ListAllIPItemIds 搜索所有IP Id列表
|
||||
func (this *IPItemDAO) ListAllIPItemIds(tx *dbs.Tx, sourceUserId int64, keyword string, ip string, listId int64, unread bool, eventLevel string, listType string, offset int64, size int64) (itemIds []int64, err error) {
|
||||
var globalListIdStrings = strings.Join(firewallconfigs.FindGlobalListIdStrings(), ",")
|
||||
if len(listType) > 0 {
|
||||
var globalListId = firewallconfigs.FindGlobalListIdWithType(listType)
|
||||
if globalListId > 0 {
|
||||
globalListIdStrings = types.String(globalListId)
|
||||
}
|
||||
}
|
||||
|
||||
var query = this.Query(tx)
|
||||
if sourceUserId > 0 {
|
||||
if listId <= 0 {
|
||||
query.Where("((listId=" + types.String(firewallconfigs.GlobalListId) + " AND sourceUserId=:sourceUserId) OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE userId=:sourceUserId AND state=1))")
|
||||
query.Where("((listId IN (" + globalListIdStrings + ") AND sourceUserId=:sourceUserId) OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE userId=:sourceUserId AND state=1))")
|
||||
query.Param("sourceUserId", sourceUserId)
|
||||
} else if listId == firewallconfigs.GlobalListId {
|
||||
} else if firewallconfigs.IsGlobalListId(listId) {
|
||||
query.Attr("sourceUserId", sourceUserId)
|
||||
query.UseIndex("sourceUserId")
|
||||
}
|
||||
@@ -733,10 +781,10 @@ func (this *IPItemDAO) ListAllIPItemIds(tx *dbs.Tx, sourceUserId int64, keyword
|
||||
query.Attr("listId", listId)
|
||||
} else {
|
||||
if len(listType) > 0 {
|
||||
query.Where("(listId=" + types.String(firewallconfigs.GlobalListId) + " OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1 AND type=:listType))")
|
||||
query.Where("(listId IN (" + globalListIdStrings + ") OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1 AND type=:listType))")
|
||||
query.Param("listType", listType)
|
||||
} else {
|
||||
query.Where("(listId=" + types.String(firewallconfigs.GlobalListId) + " OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1))")
|
||||
query.Where("(listId IN (" + globalListIdStrings + ") OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE state=1))")
|
||||
}
|
||||
}
|
||||
if unread {
|
||||
@@ -888,7 +936,7 @@ func (this *IPItemDAO) NotifyUpdate(tx *dbs.Tx, itemId int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if listId == firewallconfigs.GlobalListId {
|
||||
if firewallconfigs.IsGlobalListId(listId) {
|
||||
sourceNodeId, err := this.Query(tx).
|
||||
Pk(itemId).
|
||||
Result("sourceNodeId").
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestIPItemDAO_CreateManyIPs(t *testing.T) {
|
||||
var n = 10
|
||||
for i := 0; i < n; i++ {
|
||||
var ip = "192." + types.String(rands.Int(0, 255)) + "." + types.String(rands.Int(0, 255)) + "." + types.String(rands.Int(0, 255))
|
||||
itemId, err := dao.CreateIPItem(tx, firewallconfigs.GlobalListId, ip, ip, "", time.Now().Unix()+86400, "test", models.IPItemTypeIPv4, "warning", 0, 0, 0, 0, 0, 0, 0, false)
|
||||
itemId, err := dao.CreateIPItem(tx, firewallconfigs.GlobalBlackListId, ip, ip, "", time.Now().Unix()+86400, "test", models.IPItemTypeIPv4, "warning", 0, 0, 0, 0, 0, 0, 0, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -21,8 +22,8 @@ const (
|
||||
)
|
||||
|
||||
var listTypeCacheMap = map[int64]*IPList{} // listId => *IPList
|
||||
var DefaultGlobalIPList = &IPList{
|
||||
Id: uint32(firewallconfigs.GlobalListId),
|
||||
var DefaultGlobalBlackIPList = &IPList{
|
||||
Id: uint32(firewallconfigs.GlobalBlackListId),
|
||||
Name: "系统黑名单",
|
||||
IsPublic: true,
|
||||
IsGlobal: true,
|
||||
@@ -31,6 +32,28 @@ var DefaultGlobalIPList = &IPList{
|
||||
IsOn: true,
|
||||
}
|
||||
|
||||
var DefaultGlobalWhiteIPList = &IPList{
|
||||
Id: uint32(firewallconfigs.GlobalWhiteListId),
|
||||
Name: "系统白名单",
|
||||
IsPublic: true,
|
||||
IsGlobal: true,
|
||||
Type: "white",
|
||||
State: IPListStateEnabled,
|
||||
IsOn: true,
|
||||
}
|
||||
|
||||
var DefaultGlobalGreyIPList = &IPList{
|
||||
Id: uint32(firewallconfigs.GlobalGreyListId),
|
||||
Name: "系统灰名单",
|
||||
IsPublic: true,
|
||||
IsGlobal: true,
|
||||
Type: "grey",
|
||||
State: IPListStateEnabled,
|
||||
IsOn: true,
|
||||
}
|
||||
|
||||
var ipListCodeRegexp = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)
|
||||
|
||||
type IPListDAO dbs.DAO
|
||||
|
||||
func NewIPListDAO() *IPListDAO {
|
||||
@@ -76,8 +99,9 @@ func (this *IPListDAO) DisableIPList(tx *dbs.Tx, listId int64) error {
|
||||
|
||||
// FindEnabledIPList 查找启用中的条目
|
||||
func (this *IPListDAO) FindEnabledIPList(tx *dbs.Tx, id int64, cacheMap *utils.CacheMap) (*IPList, error) {
|
||||
if id == firewallconfigs.GlobalListId {
|
||||
return DefaultGlobalIPList, nil
|
||||
globalList, ok := this.findGlobalList(id)
|
||||
if ok {
|
||||
return globalList, nil
|
||||
}
|
||||
|
||||
var cacheKey = this.Table + ":FindEnabledIPList:" + types.String(id)
|
||||
@@ -113,9 +137,9 @@ func (this *IPListDAO) FindIPListName(tx *dbs.Tx, id int64) (string, error) {
|
||||
|
||||
// FindIPListCacheable 获取名单
|
||||
func (this *IPListDAO) FindIPListCacheable(tx *dbs.Tx, listId int64) (*IPList, error) {
|
||||
// 全局黑名单
|
||||
if listId == firewallconfigs.GlobalListId {
|
||||
return DefaultGlobalIPList, nil
|
||||
globalList, ok := this.findGlobalList(listId)
|
||||
if ok {
|
||||
return globalList, nil
|
||||
}
|
||||
|
||||
// 检查缓存
|
||||
@@ -162,7 +186,21 @@ func (this *IPListDAO) CreateIPList(tx *dbs.Tx, userId int64, serverId int64, li
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return types.Int64(op.Id), nil
|
||||
var newListId = types.Int64(op.Id)
|
||||
|
||||
// 防止和全局名单ID冲突
|
||||
if lists.ContainsInt64(firewallconfigs.FindGlobalListIds(), newListId) {
|
||||
// 先删除
|
||||
err = this.Query(tx).Pk(newListId).DeleteQuickly()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// 自动创建下一个
|
||||
return this.CreateIPList(tx, userId, serverId, listType, name, code, timeoutJSON, description, isPublic, isGlobal)
|
||||
}
|
||||
|
||||
return newListId, nil
|
||||
}
|
||||
|
||||
// UpdateIPList 修改名单
|
||||
@@ -226,7 +264,7 @@ func (this *IPListDAO) CountAllEnabledIPLists(tx *dbs.Tx, listType string, isPub
|
||||
Attr("type", listType).
|
||||
Attr("isPublic", isPublic)
|
||||
if len(keyword) > 0 {
|
||||
query.Where("(name LIKE :keyword OR description LIKE :keyword)").
|
||||
query.Where("(name LIKE :keyword OR description LIKE :keyword OR code LIKE :keyword)").
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
}
|
||||
return query.Count()
|
||||
@@ -239,7 +277,7 @@ func (this *IPListDAO) ListEnabledIPLists(tx *dbs.Tx, listType string, isPublic
|
||||
Attr("type", listType).
|
||||
Attr("isPublic", isPublic)
|
||||
if len(keyword) > 0 {
|
||||
query.Where("(name LIKE :keyword OR description LIKE :keyword)").
|
||||
query.Where("(name LIKE :keyword OR description LIKE :keyword OR code LIKE :keyword)").
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
}
|
||||
_, err = query.Offset(offset).
|
||||
@@ -352,3 +390,34 @@ func (this *IPListDAO) FindServerIdWithListId(tx *dbs.Tx, listId int64) (serverI
|
||||
FindInt64Col(0)
|
||||
return
|
||||
}
|
||||
|
||||
// FindIPListIdWithCode 根据IP名单代号查找名单ID
|
||||
func (this *IPListDAO) FindIPListIdWithCode(tx *dbs.Tx, listCode string) (int64, error) {
|
||||
if len(listCode) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
return this.Query(tx).
|
||||
ResultPk().
|
||||
State(IPListStateEnabled).
|
||||
Attr("code", listCode).
|
||||
FindInt64Col(0)
|
||||
}
|
||||
|
||||
// ValidateIPListCode 校验IP名单代号格式
|
||||
func (this *IPListDAO) ValidateIPListCode(code string) bool {
|
||||
return ipListCodeRegexp.MatchString(code)
|
||||
}
|
||||
|
||||
// 查找ID对应的全局名单
|
||||
func (this *IPListDAO) findGlobalList(id int64) (list *IPList, ok bool) {
|
||||
switch id {
|
||||
case firewallconfigs.GlobalBlackListId:
|
||||
return DefaultGlobalBlackIPList, true
|
||||
case firewallconfigs.GlobalWhiteListId:
|
||||
return DefaultGlobalWhiteIPList, true
|
||||
case firewallconfigs.GlobalGreyListId:
|
||||
return DefaultGlobalGreyIPList, true
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ func (this *LoginSessionDAO) WriteSessionValue(tx *dbs.Tx, sid string, key strin
|
||||
return err
|
||||
}
|
||||
var sessionId int64
|
||||
var isNewSession = false
|
||||
var valueMap = maps.Map{}
|
||||
if sessionOne != nil {
|
||||
var session = sessionOne.(*LoginSession)
|
||||
@@ -113,7 +112,6 @@ func (this *LoginSessionDAO) WriteSessionValue(tx *dbs.Tx, sid string, key strin
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
isNewSession = true
|
||||
}
|
||||
|
||||
var sessionOp = NewLoginSessionOperator()
|
||||
@@ -133,24 +131,17 @@ func (this *LoginSessionDAO) WriteSessionValue(tx *dbs.Tx, sid string, key strin
|
||||
if adminId > 0 || userId > 0 {
|
||||
sessionOp.AdminId = adminId
|
||||
sessionOp.UserId = userId
|
||||
|
||||
if isNewSession {
|
||||
// 删除此用户之前创建的SESSION,不再保存以往的SESSION,避免安全问题
|
||||
err = this.Query(tx).
|
||||
ResultPk().
|
||||
Attr("adminId", adminId).
|
||||
Attr("userId", userId).
|
||||
Neq("sid", sid).
|
||||
DeleteQuickly()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 写入数据
|
||||
valueMap[key] = value
|
||||
sessionOp.Values = valueMap.AsJSON()
|
||||
|
||||
// IP
|
||||
if key == "@ip" {
|
||||
sessionOp.Ip = value
|
||||
}
|
||||
|
||||
return this.Save(tx, sessionOp)
|
||||
}
|
||||
|
||||
@@ -182,3 +173,45 @@ func (this *LoginSessionDAO) FindSession(tx *dbs.Tx, sid string) (*LoginSession,
|
||||
}
|
||||
return session, nil
|
||||
}
|
||||
|
||||
func (this *LoginSessionDAO) ClearOldSessions(tx *dbs.Tx, adminId int64, userId int64, sid string, ip string) error {
|
||||
// 删除此用户之前创建的SESSION
|
||||
err := this.Query(tx).
|
||||
Attr("adminId", adminId).
|
||||
Attr("userId", userId).
|
||||
Neq("sid", sid).
|
||||
Neq("ip", ip). // 同一个IP允许多个SID,因为有人可能会同时使用手机端和PC端
|
||||
DeleteQuickly()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 删除过多的SESSION
|
||||
oldOnes, queryErr := this.Query(tx).
|
||||
ResultPk().
|
||||
Attr("adminId", adminId).
|
||||
Attr("userId", userId).
|
||||
Neq("sid", sid).
|
||||
AscPk().
|
||||
FindAll()
|
||||
if queryErr != nil {
|
||||
return queryErr
|
||||
}
|
||||
var oldCount = len(oldOnes)
|
||||
if oldCount > 3 {
|
||||
for _, oldOne := range oldOnes[:oldCount-3] {
|
||||
var oldId = oldOne.(*LoginSession).Id
|
||||
if oldOne.(*LoginSession).Sid == sid {
|
||||
continue
|
||||
}
|
||||
err = this.Query(tx).
|
||||
Pk(oldId).
|
||||
DeleteQuickly()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
121
internal/db/models/login_ticket_dao.go
Normal file
121
internal/db/models/login_ticket_dao.go
Normal file
@@ -0,0 +1,121 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/goman"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if !teaconst.IsMain {
|
||||
return
|
||||
}
|
||||
|
||||
// 清理过期的票据
|
||||
var ticker = time.NewTicker(time.Duration(rands.Int(36, 48)) * time.Hour)
|
||||
goman.New(func() {
|
||||
for range ticker.C {
|
||||
err := SharedLoginTicketDAO.CleanExpiredTickets(nil)
|
||||
if err != nil {
|
||||
remotelogs.Error("LoginTicketDAO", "clean expired tickets failed: "+err.Error())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type LoginTicketDAO dbs.DAO
|
||||
|
||||
func NewLoginTicketDAO() *LoginTicketDAO {
|
||||
return dbs.NewDAO(&LoginTicketDAO{
|
||||
DAOObject: dbs.DAOObject{
|
||||
DB: Tea.Env,
|
||||
Table: "edgeLoginTickets",
|
||||
Model: new(LoginTicket),
|
||||
PkName: "id",
|
||||
},
|
||||
}).(*LoginTicketDAO)
|
||||
}
|
||||
|
||||
var SharedLoginTicketDAO *LoginTicketDAO
|
||||
|
||||
func init() {
|
||||
dbs.OnReady(func() {
|
||||
SharedLoginTicketDAO = NewLoginTicketDAO()
|
||||
})
|
||||
}
|
||||
|
||||
// CreateLoginTicket 创建票据
|
||||
func (this *LoginTicketDAO) CreateLoginTicket(tx *dbs.Tx, adminId int64, userId int64, ip string) (ticketValue string, err error) {
|
||||
if adminId <= 0 && userId <= 0 {
|
||||
err = errors.New("either 'adminId' or 'userId' must be greater than 0")
|
||||
return
|
||||
}
|
||||
|
||||
if len(ip) > 0 && !iputils.IsValid(ip) {
|
||||
err = errors.New("invalid ip: '" + ip + "'")
|
||||
return
|
||||
}
|
||||
|
||||
ticketValue = stringutil.Md5(types.String(adminId) + "@" + types.String(userId) + types.String(time.Now().UnixNano()) + "@" + types.String(rand.Int63()) + "@" + ip)
|
||||
|
||||
var op = NewLoginTicketOperator()
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.ExpiresAt = time.Now().Unix() + 600 /* 10 minutes */
|
||||
op.Ip = ip
|
||||
op.Value = ticketValue
|
||||
err = this.Save(tx, op)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return ticketValue, nil
|
||||
}
|
||||
|
||||
// FindLoginTicketWithValue 查找票据
|
||||
func (this *LoginTicketDAO) FindLoginTicketWithValue(tx *dbs.Tx, value string) (*LoginTicket, error) {
|
||||
if len(value) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if len(value) != 32 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
one, err := this.Query(tx).
|
||||
Attr("value", value).
|
||||
Gt("expiresAt", time.Now().Unix()).
|
||||
Find()
|
||||
if one == nil || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ticket = one.(*LoginTicket)
|
||||
|
||||
// delete the ticket
|
||||
err = this.Query(tx).
|
||||
Pk(ticket.Id).
|
||||
DeleteQuickly()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ticket, nil
|
||||
}
|
||||
|
||||
// CleanExpiredTickets 清理过期的票据
|
||||
func (this *LoginTicketDAO) CleanExpiredTickets(tx *dbs.Tx) error {
|
||||
return this.Query(tx).
|
||||
Lt("expiresAt", time.Now().Unix()).
|
||||
DeleteQuickly()
|
||||
}
|
||||
6
internal/db/models/login_ticket_dao_test.go
Normal file
6
internal/db/models/login_ticket_dao_test.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package models_test
|
||||
|
||||
import (
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/iwind/TeaGo/bootstrap"
|
||||
)
|
||||
35
internal/db/models/login_ticket_model.go
Normal file
35
internal/db/models/login_ticket_model.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package models
|
||||
|
||||
import "github.com/iwind/TeaGo/dbs"
|
||||
|
||||
const (
|
||||
LoginTicketField_Id dbs.FieldName = "id" // ID
|
||||
LoginTicketField_ExpiresAt dbs.FieldName = "expiresAt" // 过期时间
|
||||
LoginTicketField_Value dbs.FieldName = "value" // 票据值
|
||||
LoginTicketField_AdminId dbs.FieldName = "adminId" // 管理员ID
|
||||
LoginTicketField_UserId dbs.FieldName = "userId" // 用户ID
|
||||
LoginTicketField_Ip dbs.FieldName = "ip" // 用户IP
|
||||
)
|
||||
|
||||
// LoginTicket 登录票据
|
||||
type LoginTicket struct {
|
||||
Id uint64 `field:"id"` // ID
|
||||
ExpiresAt uint64 `field:"expiresAt"` // 过期时间
|
||||
Value string `field:"value"` // 票据值
|
||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||
UserId uint32 `field:"userId"` // 用户ID
|
||||
Ip string `field:"ip"` // 用户IP
|
||||
}
|
||||
|
||||
type LoginTicketOperator struct {
|
||||
Id any // ID
|
||||
ExpiresAt any // 过期时间
|
||||
Value any // 票据值
|
||||
AdminId any // 管理员ID
|
||||
UserId any // 用户ID
|
||||
Ip any // 用户IP
|
||||
}
|
||||
|
||||
func NewLoginTicketOperator() *LoginTicketOperator {
|
||||
return &LoginTicketOperator{}
|
||||
}
|
||||
1
internal/db/models/login_ticket_model_ext.go
Normal file
1
internal/db/models/login_ticket_model_ext.go
Normal file
@@ -0,0 +1 @@
|
||||
package models
|
||||
@@ -126,7 +126,7 @@ func (this *NodeClusterDAO) FindAllEnableClusterIds(tx *dbs.Tx) (result []int64,
|
||||
}
|
||||
|
||||
// CreateCluster 创建集群
|
||||
func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, dnsTTL int32, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map, globalServerConfig *serverconfigs.GlobalServerConfig, autoInstallNftables bool, autoSystemTuning bool, autoTrimDisks bool) (clusterId int64, err error) {
|
||||
func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, dnsTTL int32, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map, globalServerConfig *serverconfigs.GlobalServerConfig, autoInstallNftables bool, autoSystemTuning bool, autoTrimDisks bool, maxConcurrentReads int32, maxConcurrentWrites int32) (clusterId int64, err error) {
|
||||
uniqueId, err := this.GenUniqueId(tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -191,6 +191,14 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
||||
op.AutoInstallNftables = autoInstallNftables
|
||||
op.AutoSystemTuning = autoSystemTuning
|
||||
op.AutoTrimDisks = autoTrimDisks
|
||||
|
||||
if maxConcurrentReads > 0 {
|
||||
op.MaxConcurrentReads = maxConcurrentReads
|
||||
}
|
||||
if maxConcurrentWrites > 0 {
|
||||
op.MaxConcurrentWrites = maxConcurrentWrites
|
||||
}
|
||||
|
||||
op.State = NodeClusterStateEnabled
|
||||
err = this.Save(tx, op)
|
||||
if err != nil {
|
||||
@@ -201,7 +209,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
||||
}
|
||||
|
||||
// UpdateCluster 修改集群
|
||||
func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string, grantId int64, installDir string, timezone string, nodeMaxThreads int32, autoOpenPorts bool, clockConfig *nodeconfigs.ClockConfig, autoRemoteStart bool, autoInstallTables bool, sshParams *nodeconfigs.SSHParams, autoSystemTuning bool, autoTrimDisks bool) error {
|
||||
func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string, grantId int64, installDir string, timezone string, nodeMaxThreads int32, autoOpenPorts bool, clockConfig *nodeconfigs.ClockConfig, autoRemoteStart bool, autoInstallTables bool, sshParams *nodeconfigs.SSHParams, autoSystemTuning bool, autoTrimDisks bool, maxConcurrentReads int32, maxConcurrentWrites int32) error {
|
||||
if clusterId <= 0 {
|
||||
return errors.New("invalid clusterId")
|
||||
}
|
||||
@@ -231,6 +239,13 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
|
||||
op.AutoSystemTuning = autoSystemTuning
|
||||
op.AutoTrimDisks = autoTrimDisks
|
||||
|
||||
if maxConcurrentReads >= 0 {
|
||||
op.MaxConcurrentReads = maxConcurrentReads
|
||||
}
|
||||
if maxConcurrentWrites >= 0 {
|
||||
op.MaxConcurrentWrites = maxConcurrentWrites
|
||||
}
|
||||
|
||||
if sshParams != nil {
|
||||
sshParamsJSON, err := json.Marshal(sshParams)
|
||||
if err != nil {
|
||||
@@ -1030,7 +1045,7 @@ func (this *NodeClusterDAO) FindClusterBasicInfo(tx *dbs.Tx, clusterId int64, ca
|
||||
cluster, err := this.Query(tx).
|
||||
Pk(clusterId).
|
||||
State(NodeClusterStateEnabled).
|
||||
Result("id", "name", "timeZone", "nodeMaxThreads", "cachePolicyId", "httpFirewallPolicyId", "autoOpenPorts", "webp", "uam", "cc", "httpPages", "http3", "isOn", "ddosProtection", "clock", "globalServerConfig", "autoInstallNftables", "autoSystemTuning", "networkSecurity", "autoTrimDisks", "secret").
|
||||
Result("id", "name", "timeZone", "nodeMaxThreads", "cachePolicyId", "httpFirewallPolicyId", "autoOpenPorts", "webp", "uam", "cc", "httpPages", "http3", "isOn", "ddosProtection", "clock", "globalServerConfig", "autoInstallNftables", "autoSystemTuning", "networkSecurity", "autoTrimDisks", "maxConcurrentReads", "maxConcurrentWrites", "secret").
|
||||
Find()
|
||||
if err != nil || cluster == nil {
|
||||
return nil, err
|
||||
|
||||
@@ -46,6 +46,8 @@ const (
|
||||
NodeClusterField_AutoSystemTuning dbs.FieldName = "autoSystemTuning" // 是否自动调整系统参数
|
||||
NodeClusterField_NetworkSecurity dbs.FieldName = "networkSecurity" // 网络安全策略
|
||||
NodeClusterField_AutoTrimDisks dbs.FieldName = "autoTrimDisks" // 是否自动执行TRIM
|
||||
NodeClusterField_MaxConcurrentReads dbs.FieldName = "maxConcurrentReads" // 节点并发读限制
|
||||
NodeClusterField_MaxConcurrentWrites dbs.FieldName = "maxConcurrentWrites" // 节点并发写限制
|
||||
)
|
||||
|
||||
// NodeCluster 节点集群
|
||||
@@ -93,6 +95,8 @@ type NodeCluster struct {
|
||||
AutoSystemTuning bool `field:"autoSystemTuning"` // 是否自动调整系统参数
|
||||
NetworkSecurity dbs.JSON `field:"networkSecurity"` // 网络安全策略
|
||||
AutoTrimDisks bool `field:"autoTrimDisks"` // 是否自动执行TRIM
|
||||
MaxConcurrentReads uint32 `field:"maxConcurrentReads"` // 节点并发读限制
|
||||
MaxConcurrentWrites uint32 `field:"maxConcurrentWrites"` // 节点并发写限制
|
||||
}
|
||||
|
||||
type NodeClusterOperator struct {
|
||||
@@ -139,6 +143,8 @@ type NodeClusterOperator struct {
|
||||
AutoSystemTuning any // 是否自动调整系统参数
|
||||
NetworkSecurity any // 网络安全策略
|
||||
AutoTrimDisks any // 是否自动执行TRIM
|
||||
MaxConcurrentReads any // 节点并发读限制
|
||||
MaxConcurrentWrites any // 节点并发写限制
|
||||
}
|
||||
|
||||
func NewNodeClusterOperator() *NodeClusterOperator {
|
||||
|
||||
@@ -1254,6 +1254,8 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, dataMap *shared
|
||||
config.AutoInstallNftables = nodeCluster.AutoInstallNftables
|
||||
config.AutoSystemTuning = nodeCluster.AutoSystemTuning
|
||||
config.AutoTrimDisks = nodeCluster.AutoTrimDisks
|
||||
config.MaxConcurrentReads = int(nodeCluster.MaxConcurrentReads)
|
||||
config.MaxConcurrentWrites = int(nodeCluster.MaxConcurrentWrites)
|
||||
}
|
||||
|
||||
// 安全设置
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
//go:build !plus
|
||||
// +build !plus
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
//go:build !plus
|
||||
// +build !plus
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -540,10 +540,26 @@ func (this *OriginDAO) ComposeOriginConfig(tx *dbs.Tx, originId int64, dataMap *
|
||||
|
||||
// CheckUserOrigin 检查源站权限
|
||||
func (this *OriginDAO) CheckUserOrigin(tx *dbs.Tx, userId int64, originId int64) error {
|
||||
reverseProxyId, err := SharedReverseProxyDAO.FindReverseProxyContainsOriginId(tx, originId)
|
||||
if originId <= 0 {
|
||||
return ErrNotFound
|
||||
}
|
||||
|
||||
// 快速查找
|
||||
reverseProxyId, err := this.Query(tx).
|
||||
Pk(originId).
|
||||
Result(OriginField_ReverseProxyId).
|
||||
FindInt64Col(0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 再次查找
|
||||
if reverseProxyId <= 0 {
|
||||
reverseProxyId, err = SharedReverseProxyDAO.FindReverseProxyContainsOriginId(tx, originId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if reverseProxyId == 0 {
|
||||
// 这里我们不允许源站没有被使用
|
||||
return ErrNotFound
|
||||
@@ -562,6 +578,18 @@ func (this *OriginDAO) ExistsOrigin(tx *dbs.Tx, originId int64) (bool, error) {
|
||||
Exist()
|
||||
}
|
||||
|
||||
// UpdateOriginReverseProxyId 设置源站所属反向代理ID
|
||||
func (this *OriginDAO) UpdateOriginReverseProxyId(tx *dbs.Tx, originId int64, reverseProxyId int64) error {
|
||||
if originId <= 0 || reverseProxyId <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return this.Query(tx).
|
||||
Pk(originId).
|
||||
Set(OriginField_ReverseProxyId, reverseProxyId).
|
||||
UpdateQuickly()
|
||||
}
|
||||
|
||||
// NotifyUpdate 通知更新
|
||||
func (this *OriginDAO) NotifyUpdate(tx *dbs.Tx, originId int64) error {
|
||||
reverseProxyId, err := SharedReverseProxyDAO.FindReverseProxyContainsOriginId(tx, originId)
|
||||
|
||||
@@ -2,11 +2,45 @@ package models
|
||||
|
||||
import "github.com/iwind/TeaGo/dbs"
|
||||
|
||||
const (
|
||||
OriginField_Id dbs.FieldName = "id" // ID
|
||||
OriginField_AdminId dbs.FieldName = "adminId" // 管理员ID
|
||||
OriginField_UserId dbs.FieldName = "userId" // 用户ID
|
||||
OriginField_ReverseProxyId dbs.FieldName = "reverseProxyId" // 所属反向代理ID
|
||||
OriginField_IsOn dbs.FieldName = "isOn" // 是否启用
|
||||
OriginField_Name dbs.FieldName = "name" // 名称
|
||||
OriginField_Version dbs.FieldName = "version" // 版本
|
||||
OriginField_Addr dbs.FieldName = "addr" // 地址
|
||||
OriginField_Oss dbs.FieldName = "oss" // OSS配置
|
||||
OriginField_Description dbs.FieldName = "description" // 描述
|
||||
OriginField_Code dbs.FieldName = "code" // 代号
|
||||
OriginField_Weight dbs.FieldName = "weight" // 权重
|
||||
OriginField_ConnTimeout dbs.FieldName = "connTimeout" // 连接超时
|
||||
OriginField_ReadTimeout dbs.FieldName = "readTimeout" // 读超时
|
||||
OriginField_IdleTimeout dbs.FieldName = "idleTimeout" // 空闲连接超时
|
||||
OriginField_MaxFails dbs.FieldName = "maxFails" // 最多失败次数
|
||||
OriginField_MaxConns dbs.FieldName = "maxConns" // 最大并发连接数
|
||||
OriginField_MaxIdleConns dbs.FieldName = "maxIdleConns" // 最多空闲连接数
|
||||
OriginField_HttpRequestURI dbs.FieldName = "httpRequestURI" // 转发后的请求URI
|
||||
OriginField_HttpRequestHeader dbs.FieldName = "httpRequestHeader" // 请求Header配置
|
||||
OriginField_HttpResponseHeader dbs.FieldName = "httpResponseHeader" // 响应Header配置
|
||||
OriginField_Host dbs.FieldName = "host" // 自定义主机名
|
||||
OriginField_HealthCheck dbs.FieldName = "healthCheck" // 健康检查设置
|
||||
OriginField_Cert dbs.FieldName = "cert" // 证书设置
|
||||
OriginField_Ftp dbs.FieldName = "ftp" // FTP相关设置
|
||||
OriginField_CreatedAt dbs.FieldName = "createdAt" // 创建时间
|
||||
OriginField_Domains dbs.FieldName = "domains" // 所属域名
|
||||
OriginField_FollowPort dbs.FieldName = "followPort" // 端口跟随
|
||||
OriginField_State dbs.FieldName = "state" // 状态
|
||||
OriginField_Http2Enabled dbs.FieldName = "http2Enabled" // 是否支持HTTP/2
|
||||
)
|
||||
|
||||
// Origin 源站
|
||||
type Origin struct {
|
||||
Id uint32 `field:"id"` // ID
|
||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||
UserId uint32 `field:"userId"` // 用户ID
|
||||
ReverseProxyId uint64 `field:"reverseProxyId"` // 所属反向代理ID
|
||||
IsOn bool `field:"isOn"` // 是否启用
|
||||
Name string `field:"name"` // 名称
|
||||
Version uint32 `field:"version"` // 版本
|
||||
@@ -39,6 +73,7 @@ type OriginOperator struct {
|
||||
Id any // ID
|
||||
AdminId any // 管理员ID
|
||||
UserId any // 用户ID
|
||||
ReverseProxyId any // 所属反向代理ID
|
||||
IsOn any // 是否启用
|
||||
Name any // 名称
|
||||
Version any // 版本
|
||||
|
||||
@@ -3,6 +3,7 @@ package models
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
@@ -213,7 +214,24 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(tx *dbs.Tx, reverseProxyI
|
||||
}
|
||||
|
||||
// CreateReverseProxy 创建反向代理
|
||||
func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userId int64, schedulingJSON []byte, primaryOriginsJSON []byte, backupOriginsJSON []byte) (int64, error) {
|
||||
func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userId int64, schedulingJSON []byte, primaryOriginRefsJSON []byte, backupOriginRefsJSON []byte) (int64, error) {
|
||||
// decode origins
|
||||
var primaryOriginRefs []*serverconfigs.OriginRef
|
||||
if len(primaryOriginRefsJSON) > 0 {
|
||||
err := json.Unmarshal(primaryOriginRefsJSON, &primaryOriginRefs)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("decode 'primaryOriginRefs' failed: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
var backupOriginRefs []*serverconfigs.OriginRef
|
||||
if len(backupOriginRefsJSON) > 0 {
|
||||
err := json.Unmarshal(backupOriginRefsJSON, &backupOriginRefs)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("decode 'backupOriginRefs' failed: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
var op = NewReverseProxyOperator()
|
||||
op.IsOn = true
|
||||
op.State = ReverseProxyStateEnabled
|
||||
@@ -233,18 +251,35 @@ func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userI
|
||||
if IsNotNull(schedulingJSON) {
|
||||
op.Scheduling = string(schedulingJSON)
|
||||
}
|
||||
if IsNotNull(primaryOriginsJSON) {
|
||||
op.PrimaryOrigins = string(primaryOriginsJSON)
|
||||
if IsNotNull(primaryOriginRefsJSON) {
|
||||
op.PrimaryOrigins = string(primaryOriginRefsJSON)
|
||||
}
|
||||
if IsNotNull(backupOriginsJSON) {
|
||||
op.BackupOrigins = string(backupOriginsJSON)
|
||||
if IsNotNull(backupOriginRefsJSON) {
|
||||
op.BackupOrigins = string(backupOriginRefsJSON)
|
||||
}
|
||||
err = this.Save(tx, op)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return types.Int64(op.Id), nil
|
||||
var reverseProxyId = types.Int64(op.Id)
|
||||
|
||||
// set 'reverseProxyId' of origins
|
||||
for _, originRef := range primaryOriginRefs {
|
||||
err = SharedOriginDAO.UpdateOriginReverseProxyId(tx, originRef.OriginId, reverseProxyId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, originRef := range backupOriginRefs {
|
||||
err = SharedOriginDAO.UpdateOriginReverseProxyId(tx, originRef.OriginId, reverseProxyId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
return reverseProxyId, nil
|
||||
}
|
||||
|
||||
// CloneReverseProxy 复制反向代理
|
||||
@@ -376,14 +411,30 @@ func (this *ReverseProxyDAO) UpdateReverseProxyScheduling(tx *dbs.Tx, reversePro
|
||||
}
|
||||
|
||||
// UpdateReverseProxyPrimaryOrigins 修改主要源站
|
||||
func (this *ReverseProxyDAO) UpdateReverseProxyPrimaryOrigins(tx *dbs.Tx, reverseProxyId int64, originRefs []byte) error {
|
||||
func (this *ReverseProxyDAO) UpdateReverseProxyPrimaryOrigins(tx *dbs.Tx, reverseProxyId int64, originRefsJSON []byte) error {
|
||||
if reverseProxyId <= 0 {
|
||||
return errors.New("invalid reverseProxyId")
|
||||
}
|
||||
|
||||
// set 'reverseProxyId' of origins
|
||||
if len(originRefsJSON) > 0 {
|
||||
var originRefs []*serverconfigs.OriginRef
|
||||
err := json.Unmarshal(originRefsJSON, &originRefs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("decode 'originRefs' failed: " + err.Error())
|
||||
}
|
||||
for _, originRef := range originRefs {
|
||||
err = SharedOriginDAO.UpdateOriginReverseProxyId(tx, originRef.OriginId, reverseProxyId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var op = NewReverseProxyOperator()
|
||||
op.Id = reverseProxyId
|
||||
if len(originRefs) > 0 {
|
||||
op.PrimaryOrigins = originRefs
|
||||
if len(originRefsJSON) > 0 {
|
||||
op.PrimaryOrigins = originRefsJSON
|
||||
} else {
|
||||
op.PrimaryOrigins = "[]"
|
||||
}
|
||||
@@ -395,14 +446,30 @@ func (this *ReverseProxyDAO) UpdateReverseProxyPrimaryOrigins(tx *dbs.Tx, revers
|
||||
}
|
||||
|
||||
// UpdateReverseProxyBackupOrigins 修改备用源站
|
||||
func (this *ReverseProxyDAO) UpdateReverseProxyBackupOrigins(tx *dbs.Tx, reverseProxyId int64, origins []byte) error {
|
||||
func (this *ReverseProxyDAO) UpdateReverseProxyBackupOrigins(tx *dbs.Tx, reverseProxyId int64, originRefsJSON []byte) error {
|
||||
if reverseProxyId <= 0 {
|
||||
return errors.New("invalid reverseProxyId")
|
||||
}
|
||||
|
||||
// set 'reverseProxyId' of origins
|
||||
if len(originRefsJSON) > 0 {
|
||||
var originRefs []*serverconfigs.OriginRef
|
||||
err := json.Unmarshal(originRefsJSON, &originRefs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("decode 'originRefs' failed: " + err.Error())
|
||||
}
|
||||
for _, originRef := range originRefs {
|
||||
err = SharedOriginDAO.UpdateOriginReverseProxyId(tx, originRef.OriginId, reverseProxyId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var op = NewReverseProxyOperator()
|
||||
op.Id = reverseProxyId
|
||||
if len(origins) > 0 {
|
||||
op.BackupOrigins = origins
|
||||
if len(originRefsJSON) > 0 {
|
||||
op.BackupOrigins = originRefsJSON
|
||||
} else {
|
||||
op.BackupOrigins = "[]"
|
||||
}
|
||||
|
||||
@@ -818,8 +818,15 @@ func (this *ServerDAO) CountAllEnabledServersMatch(tx *dbs.Tx, groupId int64, ke
|
||||
Param("serverId", keyword).
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
} else {
|
||||
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword)").
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
if regexp.MustCompile(`^[a-z0-9.-]+$`).MatchString(keyword) {
|
||||
// 可以搜索源站
|
||||
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword OR JSON_EXTRACT(reverseProxy, '$.reverseProxyId') IN (SELECT reverseProxyId FROM " + SharedOriginDAO.Table + " WHERE reverseProxyId > 0 AND JSON_EXTRACT(addr, '$.host')=:fullKeyword))")
|
||||
query.Param("keyword", dbutils.QuoteLike(keyword))
|
||||
query.Param("fullKeyword", keyword)
|
||||
} else {
|
||||
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword)").
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
}
|
||||
}
|
||||
}
|
||||
if userId > 0 {
|
||||
@@ -861,7 +868,7 @@ func (this *ServerDAO) CountAllEnabledServersMatch(tx *dbs.Tx, groupId int64, ke
|
||||
//
|
||||
// groupId 分组ID,如果为-1,则搜索没有分组的服务
|
||||
func (this *ServerDAO) ListEnabledServersMatch(tx *dbs.Tx, offset int64, size int64, groupId int64, keyword string, userId int64, clusterId int64, auditingFlag int32, protocolFamilies []string, order string) (result []*Server, err error) {
|
||||
query := this.Query(tx).
|
||||
var query = this.Query(tx).
|
||||
State(ServerStateEnabled).
|
||||
Offset(offset).
|
||||
Limit(size).
|
||||
@@ -880,8 +887,15 @@ func (this *ServerDAO) ListEnabledServersMatch(tx *dbs.Tx, offset int64, size in
|
||||
Param("serverId", keyword).
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
} else {
|
||||
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword)").
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
if regexp.MustCompile(`^[a-z0-9.-]+$`).MatchString(keyword) {
|
||||
// 可以搜索源站
|
||||
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword OR JSON_EXTRACT(reverseProxy, '$.reverseProxyId') IN (SELECT reverseProxyId FROM " + SharedOriginDAO.Table + " WHERE reverseProxyId > 0 AND JSON_EXTRACT(addr, '$.host')=:fullKeyword))")
|
||||
query.Param("keyword", dbutils.QuoteLike(keyword))
|
||||
query.Param("fullKeyword", keyword)
|
||||
} else {
|
||||
query.Where("(name LIKE :keyword OR serverNames LIKE :keyword)").
|
||||
Param("keyword", dbutils.QuoteLike(keyword))
|
||||
}
|
||||
}
|
||||
}
|
||||
if userId > 0 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestServerDAO_CreateManyServers(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
serverId, err := dao.CreateServer(tx, 0, 0, serverconfigs.ServerTypeHTTPProxy, "TEST"+types.String(i), "", serverNamesJSON, false, nil, nil, nil, nil, nil, nil, nil, 0, nil, 1, nil, nil, nil, 0)
|
||||
serverId, err := dao.CreateServer(tx, 0, 0, serverconfigs.ServerTypeHTTPProxy, "TEST"+types.String(i), "", serverNamesJSON, false, nil, nil, nil, nil, nil, nil, 0, nil, 0, nil, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -85,6 +85,22 @@ func (this *TrafficDailyStatDAO) IncreaseDailyStat(tx *dbs.Tx, day string, bytes
|
||||
return nil
|
||||
}
|
||||
|
||||
// IncreaseIPs 增加独立IP统计数据
|
||||
func (this *TrafficDailyStatDAO) IncreaseIPs(tx *dbs.Tx, day string, countIPs int64) error {
|
||||
if len(day) != 8 {
|
||||
return errors.New("invalid day '" + day + "'")
|
||||
}
|
||||
|
||||
return this.Query(tx).
|
||||
Param("countIPs", countIPs).
|
||||
InsertOrUpdateQuickly(maps.Map{
|
||||
"day": day,
|
||||
"countIPs": countIPs,
|
||||
}, maps.Map{
|
||||
"countIPs": dbs.SQL("countIPs+:countIPs"),
|
||||
})
|
||||
}
|
||||
|
||||
// FindDailyStats 获取日期之间统计
|
||||
func (this *TrafficDailyStatDAO) FindDailyStats(tx *dbs.Tx, dayFrom string, dayTo string) (result []*TrafficDailyStat, err error) {
|
||||
ones, err := this.Query(tx).
|
||||
|
||||
@@ -11,10 +11,20 @@ import (
|
||||
func TestTrafficDailyStatDAO_IncreaseDayBytes(t *testing.T) {
|
||||
dbs.NotifyReady()
|
||||
|
||||
now := time.Now()
|
||||
var now = time.Now()
|
||||
err := SharedTrafficDailyStatDAO.IncreaseDailyStat(nil, timeutil.Format("Ymd"), 1, 1, 1, 1, 1, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("ok", time.Since(now).Seconds()*1000, "ms")
|
||||
}
|
||||
|
||||
func TestTrafficDailyStatDAO_IncreaseIPs(t *testing.T) {
|
||||
dbs.NotifyReady()
|
||||
|
||||
var tx *dbs.Tx
|
||||
err := SharedTrafficDailyStatDAO.IncreaseIPs(tx, timeutil.Format("Ymd"), 123)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
package stats
|
||||
|
||||
import "github.com/iwind/TeaGo/dbs"
|
||||
|
||||
const (
|
||||
TrafficDailyStatField_Id dbs.FieldName = "id" // ID
|
||||
TrafficDailyStatField_Day dbs.FieldName = "day" // YYYYMMDD
|
||||
TrafficDailyStatField_CachedBytes dbs.FieldName = "cachedBytes" // 缓存流量
|
||||
TrafficDailyStatField_Bytes dbs.FieldName = "bytes" // 流量字节
|
||||
TrafficDailyStatField_CountRequests dbs.FieldName = "countRequests" // 请求数
|
||||
TrafficDailyStatField_CountCachedRequests dbs.FieldName = "countCachedRequests" // 缓存请求数
|
||||
TrafficDailyStatField_CountAttackRequests dbs.FieldName = "countAttackRequests" // 攻击量
|
||||
TrafficDailyStatField_AttackBytes dbs.FieldName = "attackBytes" // 攻击流量
|
||||
TrafficDailyStatField_CountIPs dbs.FieldName = "countIPs" // 独立IP数
|
||||
)
|
||||
|
||||
// TrafficDailyStat 总的流量统计(按天)
|
||||
type TrafficDailyStat struct {
|
||||
Id uint64 `field:"id"` // ID
|
||||
@@ -10,17 +24,19 @@ type TrafficDailyStat struct {
|
||||
CountCachedRequests uint64 `field:"countCachedRequests"` // 缓存请求数
|
||||
CountAttackRequests uint64 `field:"countAttackRequests"` // 攻击量
|
||||
AttackBytes uint64 `field:"attackBytes"` // 攻击流量
|
||||
CountIPs uint64 `field:"countIPs"` // 独立IP数
|
||||
}
|
||||
|
||||
type TrafficDailyStatOperator struct {
|
||||
Id interface{} // ID
|
||||
Day interface{} // YYYYMMDD
|
||||
CachedBytes interface{} // 缓存流量
|
||||
Bytes interface{} // 流量字节
|
||||
CountRequests interface{} // 请求数
|
||||
CountCachedRequests interface{} // 缓存请求数
|
||||
CountAttackRequests interface{} // 攻击量
|
||||
AttackBytes interface{} // 攻击流量
|
||||
Id any // ID
|
||||
Day any // YYYYMMDD
|
||||
CachedBytes any // 缓存流量
|
||||
Bytes any // 流量字节
|
||||
CountRequests any // 请求数
|
||||
CountCachedRequests any // 缓存请求数
|
||||
CountAttackRequests any // 攻击量
|
||||
AttackBytes any // 攻击流量
|
||||
CountIPs any // 独立IP数
|
||||
}
|
||||
|
||||
func NewTrafficDailyStatOperator() *TrafficDailyStatOperator {
|
||||
|
||||
@@ -322,8 +322,8 @@ func (this *UserDAO) UpdateUserPassword(tx *dbs.Tx, userId int64, password strin
|
||||
}
|
||||
|
||||
// CountAllEnabledUsers 计算用户数量
|
||||
func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword string, isVerifying bool) (int64, error) {
|
||||
query := this.Query(tx)
|
||||
func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword string, isVerifying bool, mobileIsVerifiedFlag int32) (int64, error) {
|
||||
var query = this.Query(tx)
|
||||
query.State(UserStateEnabled)
|
||||
if clusterId > 0 {
|
||||
query.Attr("clusterId", clusterId)
|
||||
@@ -336,6 +336,14 @@ func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword s
|
||||
query.Where("(isVerified=0 OR (id IN (SELECT userId FROM " + SharedUserIdentityDAO.Table + " WHERE status=:identityStatus AND state=1)))")
|
||||
query.Param("identityStatus", userconfigs.UserIdentityStatusSubmitted)
|
||||
}
|
||||
|
||||
// 手机号是否已验证
|
||||
if mobileIsVerifiedFlag == 1 {
|
||||
query.Where("LENGTH(verifiedMobile)>0")
|
||||
} else if mobileIsVerifiedFlag == 0 {
|
||||
query.Where("(verifiedMobile IS NULL OR LENGTH(verifiedMobile)=0)")
|
||||
}
|
||||
|
||||
return query.Count()
|
||||
}
|
||||
|
||||
@@ -349,8 +357,8 @@ func (this *UserDAO) CountAllVerifyingUsers(tx *dbs.Tx) (int64, error) {
|
||||
}
|
||||
|
||||
// ListEnabledUsers 列出单页用户
|
||||
func (this *UserDAO) ListEnabledUsers(tx *dbs.Tx, clusterId int64, keyword string, isVerifying bool, offset int64, size int64) (result []*User, err error) {
|
||||
query := this.Query(tx)
|
||||
func (this *UserDAO) ListEnabledUsers(tx *dbs.Tx, clusterId int64, keyword string, isVerifying bool, mobileIsVerifiedFlag int32, offset int64, size int64) (result []*User, err error) {
|
||||
var query = this.Query(tx)
|
||||
query.State(UserStateEnabled)
|
||||
if clusterId > 0 {
|
||||
query.Attr("clusterId", clusterId)
|
||||
@@ -363,6 +371,14 @@ func (this *UserDAO) ListEnabledUsers(tx *dbs.Tx, clusterId int64, keyword strin
|
||||
query.Where("(isVerified=0 OR (id IN (SELECT userId FROM " + SharedUserIdentityDAO.Table + " WHERE status=:identityStatus AND state=1)))")
|
||||
query.Param("identityStatus", userconfigs.UserIdentityStatusSubmitted)
|
||||
}
|
||||
|
||||
// 手机号是否已验证
|
||||
if mobileIsVerifiedFlag == 1 {
|
||||
query.Where("LENGTH(verifiedMobile)>0")
|
||||
} else if mobileIsVerifiedFlag == 0 {
|
||||
query.Where("(verifiedMobile IS NULL OR LENGTH(verifiedMobile)=0)")
|
||||
}
|
||||
|
||||
_, err = query.
|
||||
DescPk().
|
||||
Offset(offset).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package models
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dbutils
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dbutils_test
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package dbutils_test
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package cloudflare
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnspod
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnsclients
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package dnsclients_test
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package edgeapi
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package huaweidns
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package huaweidns
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package huaweidns
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package huaweidns
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user