Compare commits
79 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae7ca4b083 | ||
|
|
9991981828 | ||
|
|
4c771697ec | ||
|
|
cbd47f60a1 | ||
|
|
e9bb79487e | ||
|
|
47e085c435 | ||
|
|
2128ed9b9c | ||
|
|
b2e0a80efd | ||
|
|
baa77a4e7c | ||
|
|
5250b00581 | ||
|
|
0138c3a329 | ||
|
|
8c1f5c47b0 | ||
|
|
4890a0f70a | ||
|
|
48e9cc4a46 | ||
|
|
402e539999 | ||
|
|
6b56f539e5 | ||
|
|
feef801cb9 | ||
|
|
6a8b1c9885 | ||
|
|
eb4e70ed25 | ||
|
|
8ca6553ac5 | ||
|
|
bd9727cb58 | ||
|
|
799d186f85 | ||
|
|
c3c3261579 | ||
|
|
97c6776809 | ||
|
|
4e4acc327d | ||
|
|
f73251f57d | ||
|
|
d9350839f3 | ||
|
|
25269adaae | ||
|
|
351337fcbc | ||
|
|
505b6b6c9e | ||
|
|
1b6a5001e8 | ||
|
|
443a3f3ec3 | ||
|
|
e4861c3fa1 | ||
|
|
8ba8528c98 | ||
|
|
4d0b1c7e0c | ||
|
|
3de4223023 | ||
|
|
5f29576049 | ||
|
|
4adb8117f8 | ||
|
|
2d304b19b8 | ||
|
|
8e605cce67 | ||
|
|
0d53785620 | ||
|
|
73ee81da78 | ||
|
|
a600fc9cd3 | ||
|
|
cc0b2fd74f | ||
|
|
e54cfa7765 | ||
|
|
7c5c600e31 | ||
|
|
c6f9126ae2 | ||
|
|
5478e6a956 | ||
|
|
3945e94f71 | ||
|
|
9cd3618d9b | ||
|
|
4389ffb397 | ||
|
|
debb72c2d3 | ||
|
|
b314f7e96c | ||
|
|
823e519d58 | ||
|
|
5a54390f1d | ||
|
|
704d3af982 | ||
|
|
96b48f2bbc | ||
|
|
4a1c9be931 | ||
|
|
f0dc9e0577 | ||
|
|
1cf38864de | ||
|
|
5f9e7e981c | ||
|
|
7073467128 | ||
|
|
adc4b945e7 | ||
|
|
12f6a1e3ce | ||
|
|
4f89360902 | ||
|
|
d422dc6b85 | ||
|
|
0dc678e38a | ||
|
|
05de67318b | ||
|
|
575e916088 | ||
|
|
489795dba0 | ||
|
|
3e8fc126b8 | ||
|
|
64c3d76fb2 | ||
|
|
3bd3ef5f78 | ||
|
|
827eeeb506 | ||
|
|
36cf357984 | ||
|
|
46140bbdb5 | ||
|
|
6a671f67bc | ||
|
|
ea991f5a97 | ||
|
|
5bcbf29fc6 |
800
build/rpc.json
800
build/rpc.json
File diff suppressed because it is too large
Load Diff
@@ -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 main
|
||||
|
||||
|
||||
18
go.mod
18
go.mod
@@ -1,21 +1,19 @@
|
||||
module github.com/TeaOSLab/EdgeCommon
|
||||
|
||||
go 1.18
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/iwind/TeaGo v0.0.0-20230623080147-cd1e53b4915f
|
||||
github.com/tdewolff/minify/v2 v2.12.7
|
||||
golang.org/x/net v0.8.0
|
||||
google.golang.org/grpc v1.45.0
|
||||
google.golang.org/protobuf v1.27.1
|
||||
golang.org/x/net v0.24.0
|
||||
google.golang.org/grpc v1.62.0
|
||||
google.golang.org/protobuf v1.33.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/tdewolff/parse/v2 v2.6.6 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/text v0.8.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240228224816-df926f6c8641 // indirect
|
||||
)
|
||||
|
||||
164
go.sum
164
go.sum
@@ -1,156 +1,38 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/djherbis/atime v1.1.0/go.mod h1:28OF6Y8s3NQWwacXc5eZTsEsiMzp7LF8MbXE+XJPdBE=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
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 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
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/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/iwind/TeaGo v0.0.0-20230623080147-cd1e53b4915f h1:xo6XmXLtveKcwcZAXV6VMxkWNzy/2dStfHEnyowsGAE=
|
||||
github.com/iwind/TeaGo v0.0.0-20230623080147-cd1e53b4915f/go.mod h1:fi/Pq+/5m2HZoseM+39dMF57ANXRt6w4PkGu3NXPc5s=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tdewolff/minify/v2 v2.12.7 h1:pBzz2tAfz5VghOXiQIsSta6srhmTeinQPjRDHWoumCA=
|
||||
github.com/tdewolff/minify/v2 v2.12.7/go.mod h1:ZRKTheiOGyLSK8hOZWWv+YoJAECzDivNgAlVYDHp/Ws=
|
||||
github.com/tdewolff/parse/v2 v2.6.6 h1:Yld+0CrKUJaCV78DL1G2nk3C9lKrxyRTux5aaK/AkDo=
|
||||
github.com/tdewolff/parse/v2 v2.6.6/go.mod h1:woz0cgbLwFdtbjJu8PIKxhW05KplTFQkOdX78o+Jgrs=
|
||||
github.com/tdewolff/test v1.0.7/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
||||
github.com/tdewolff/test v1.0.9 h1:SswqJCmeN4B+9gEAi/5uqT0qpi1y2/2O47V/1hhGZT0=
|
||||
github.com/tdewolff/test v1.0.9/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
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-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e h1:fNKDNuUyC4WH+inqDMpfXDdfvwfYILbsX+oskGZ8hxg=
|
||||
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M=
|
||||
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||
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=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
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/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk=
|
||||
google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
||||
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
||||
@@ -1,41 +1,10 @@
|
||||
package configutils
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"math/big"
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IPString2Long 将IP转换为整型
|
||||
// 注意IPv6没有顺序
|
||||
func IPString2Long(ip string) uint64 {
|
||||
if len(ip) == 0 {
|
||||
return 0
|
||||
}
|
||||
var netIP = net.ParseIP(ip)
|
||||
if len(netIP) == 0 {
|
||||
return 0
|
||||
}
|
||||
return IP2Long(netIP)
|
||||
}
|
||||
|
||||
// IP2Long 将IP对象转换为整型
|
||||
func IP2Long(netIP net.IP) uint64 {
|
||||
if len(netIP) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var b4 = netIP.To4()
|
||||
if b4 != nil {
|
||||
return uint64(binary.BigEndian.Uint32(b4.To4()))
|
||||
}
|
||||
|
||||
var i = big.NewInt(0)
|
||||
i.SetBytes(netIP.To16())
|
||||
return i.Uint64()
|
||||
}
|
||||
|
||||
// IsIPv4 检查是否为IPv4
|
||||
func IsIPv4(netIP net.IP) bool {
|
||||
if len(netIP) == 0 {
|
||||
@@ -69,28 +38,6 @@ func IPVersion(netIP net.IP) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// ParseCIDR 计算CIDR最大值
|
||||
func ParseCIDR(cidr string) (ipFrom string, ipTo string, err error) {
|
||||
_, ipNet, err := net.ParseCIDR(cidr)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
ipFrom = ipNet.IP.String()
|
||||
Loop:
|
||||
for i := len(ipNet.Mask) - 1; i >= 0; i-- {
|
||||
for j := 7; j >= 0; j-- {
|
||||
var m = ipNet.Mask[i] >> (7 - j) & 1 // 读取某位bit
|
||||
if m == 0 {
|
||||
ipNet.IP[i] |= 1 << j // 将此位置为1
|
||||
} else {
|
||||
break Loop
|
||||
}
|
||||
}
|
||||
}
|
||||
ipTo = ipNet.IP.String()
|
||||
return
|
||||
}
|
||||
|
||||
// QuoteIP 为IPv6加上括号
|
||||
func QuoteIP(ip string) string {
|
||||
if len(ip) == 0 {
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
// Copyright 2021 GoEdge CDN goedge.cdn@gmail.com. All rights reserved.
|
||||
|
||||
package configutils_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseCIDR(t *testing.T) {
|
||||
t.Log(configutils.ParseCIDR("192.168.1.1/32"))
|
||||
t.Log(configutils.ParseCIDR("192.168.1.1/24"))
|
||||
t.Log(configutils.ParseCIDR("192.168.1.1/16"))
|
||||
}
|
||||
|
||||
func TestIPString2Long(t *testing.T) {
|
||||
for _, ip := range []string{"127.0.0.1", "192.168.1.100", "::1", "fd00:6868:6868:0:10ac:d056:3bf6:7452", "fd00:6868:6868:0:10ac:d056:3bf6:7453", "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "wrong ip"} {
|
||||
t.Log(fmt.Sprintf("%42s", ip), "=>", configutils.IPString2Long(ip))
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsIPv4(t *testing.T) {
|
||||
t.Log(configutils.IsIPv4(net.ParseIP("192.168.1.100")))
|
||||
t.Log(configutils.IsIPv4(net.ParseIP("::1")))
|
||||
@@ -40,7 +27,6 @@ func TestIPVersion(t *testing.T) {
|
||||
a.IsTrue(configutils.IPVersion(net.ParseIP("2001:0db8:85a3:0000:0000:8a2e:0370:7334")) == 6)
|
||||
}
|
||||
|
||||
|
||||
func TestQuoteIP(t *testing.T) {
|
||||
t.Log(configutils.QuoteIP(configutils.QuoteIP("2001:da8:22::10")))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
package configutils
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// VariableHolder 变量信息存储类型
|
||||
type VariableHolder string
|
||||
type VariableHolders = []interface{}
|
||||
type VariableHolder struct {
|
||||
Param string
|
||||
Modifiers []string
|
||||
}
|
||||
type VariableHolders = []any
|
||||
|
||||
var variableMapping = map[string][]interface{}{} // source => [holder1, ...]
|
||||
var variableLocker = sync.RWMutex{}
|
||||
var regexpNamedVariable = regexp.MustCompile(`\${[@\w.-]+}`)
|
||||
var variableMapping = map[string][]any{} // source => [holder1, ...]
|
||||
var variableLocker = &sync.RWMutex{}
|
||||
var regexpNamedVariable = regexp.MustCompile(`\${[@\w.|-]+}`)
|
||||
|
||||
var stringBuilderPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &strings.Builder{}
|
||||
},
|
||||
}
|
||||
@@ -46,7 +56,11 @@ func ParseVariables(source string, replacer func(varName string) (value string))
|
||||
var h = holders[0]
|
||||
holder, ok := h.(VariableHolder)
|
||||
if ok {
|
||||
return replacer(string(holder))
|
||||
var value = replacer(holder.Param)
|
||||
if holder.Modifiers != nil {
|
||||
value = doStringModifiers(value, holder.Modifiers)
|
||||
}
|
||||
return replacer(value)
|
||||
}
|
||||
return source
|
||||
}
|
||||
@@ -58,7 +72,11 @@ func ParseVariables(source string, replacer func(varName string) (value string))
|
||||
for _, h := range holders {
|
||||
holder, ok := h.(VariableHolder)
|
||||
if ok {
|
||||
builder.WriteString(replacer(string(holder)))
|
||||
var value = replacer(holder.Param)
|
||||
if holder.Modifiers != nil {
|
||||
value = doStringModifiers(value, holder.Modifiers)
|
||||
}
|
||||
builder.WriteString(value)
|
||||
} else {
|
||||
builder.Write(h.([]byte))
|
||||
}
|
||||
@@ -86,11 +104,15 @@ func ParseVariablesFromHolders(holders VariableHolders, replacer func(varName st
|
||||
}
|
||||
|
||||
// replace
|
||||
result := strings.Builder{}
|
||||
var result = strings.Builder{}
|
||||
for _, h := range holders {
|
||||
holder, ok := h.(VariableHolder)
|
||||
if ok {
|
||||
result.WriteString(replacer(string(holder)))
|
||||
var value = replacer(holder.Param)
|
||||
if holder.Modifiers != nil {
|
||||
value = doStringModifiers(value, holder.Modifiers)
|
||||
}
|
||||
result.WriteString(value)
|
||||
} else {
|
||||
result.Write(h.([]byte))
|
||||
}
|
||||
@@ -100,12 +122,24 @@ func ParseVariablesFromHolders(holders VariableHolders, replacer func(varName st
|
||||
|
||||
// ParseHolders 分析占位
|
||||
func ParseHolders(source string) (holders VariableHolders) {
|
||||
indexes := regexpNamedVariable.FindAllStringIndex(source, -1)
|
||||
before := 0
|
||||
var indexes = regexpNamedVariable.FindAllStringIndex(source, -1)
|
||||
var before = 0
|
||||
for _, loc := range indexes {
|
||||
holders = append(holders, []byte(source[before:loc[0]]))
|
||||
holder := source[loc[0]+2 : loc[1]-1]
|
||||
holders = append(holders, VariableHolder(holder))
|
||||
var holder = source[loc[0]+2 : loc[1]-1]
|
||||
|
||||
if strings.Contains(holder, "|") {
|
||||
var holderPieces = strings.Split(holder, "|")
|
||||
holders = append(holders, VariableHolder{
|
||||
Param: holderPieces[0],
|
||||
Modifiers: holderPieces[1:],
|
||||
})
|
||||
} else {
|
||||
holders = append(holders, VariableHolder{
|
||||
Param: holder,
|
||||
Modifiers: nil,
|
||||
})
|
||||
}
|
||||
before = loc[1]
|
||||
}
|
||||
if before < len(source) {
|
||||
@@ -121,3 +155,39 @@ func HasVariables(source string) bool {
|
||||
}
|
||||
return regexpNamedVariable.MatchString(source)
|
||||
}
|
||||
|
||||
// 执行变量后的修饰符
|
||||
func doStringModifiers(value string, modifiers []string) string {
|
||||
for _, modifier := range modifiers {
|
||||
switch modifier {
|
||||
case "urlEncode":
|
||||
value = url.QueryEscape(value)
|
||||
case "urlDecode":
|
||||
value2, err := url.QueryUnescape(value)
|
||||
if err == nil {
|
||||
value = value2
|
||||
}
|
||||
case "base64Encode":
|
||||
value = base64.StdEncoding.EncodeToString([]byte(value))
|
||||
case "base64Decode":
|
||||
value2, err := base64.StdEncoding.DecodeString(value)
|
||||
if err == nil {
|
||||
value = string(value2)
|
||||
}
|
||||
case "md5":
|
||||
value = stringutil.Md5(value)
|
||||
case "sha1":
|
||||
value = fmt.Sprintf("%x", sha1.Sum([]byte(value)))
|
||||
case "sha256":
|
||||
value = fmt.Sprintf("%x", sha256.Sum256([]byte(value)))
|
||||
case "toLowerCase":
|
||||
value = strings.ToLower(value)
|
||||
case "toUpperCase":
|
||||
value = strings.ToUpper(value)
|
||||
case "quote":
|
||||
value = strconv.Quote(value)
|
||||
|
||||
}
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package configutils
|
||||
package configutils_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -8,48 +10,151 @@ import (
|
||||
)
|
||||
|
||||
func TestParseVariables(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
|
||||
{
|
||||
v := ParseVariables("hello, ${name}, world", func(s string) string {
|
||||
var v = configutils.ParseVariables("hello, ${name}, world", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
t.Log(v)
|
||||
a.IsTrue(v == "hello, Lu, world")
|
||||
}
|
||||
{
|
||||
v := ParseVariables("hello, world", func(s string) string {
|
||||
var v = configutils.ParseVariables("hello, world", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
t.Log(v)
|
||||
a.IsTrue(v == "hello, world")
|
||||
}
|
||||
{
|
||||
v := ParseVariables("${name}", func(s string) string {
|
||||
var v = configutils.ParseVariables("${name}", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
t.Log(v)
|
||||
a.IsTrue(v == "Lu")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseNoVariables(t *testing.T) {
|
||||
for i := 0; i < 2; i++ {
|
||||
v := ParseVariables("hello, world", func(s string) string {
|
||||
var v = configutils.ParseVariables("hello, world", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
t.Log(v)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseVariables_Modifier(t *testing.T) {
|
||||
t.Log(configutils.ParseVariables("${url|urlEncode}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "url":
|
||||
return "/hello/world?a=1"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${url|urlDecode}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "url":
|
||||
return "%2Fhello%2Fworld%3Fa%3D1"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${url|urlDecode|urlEncode}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "url":
|
||||
return "%2Fhello%2Fworld%3Fa%3D1"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${var|base64Encode}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "123456"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${var|base64Encode|base64Decode}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "123456"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${var|md5}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "123456"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${var|sha1}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "123456"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${var|sha256}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "123456"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${var|toLowerCase}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "ABC"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log(configutils.ParseVariables("${var|toUpperCase}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "abc"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
|
||||
// quote
|
||||
t.Log("quote(abc)", "=>", configutils.ParseVariables("${var|quote}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "abc"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log("quote(\"ABC\"123)", "=>", configutils.ParseVariables("${var|quote}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "\"ABC\"123"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
t.Log("quote('ABC'123)", "=>", configutils.ParseVariables("${var|quote}", func(varName string) (value string) {
|
||||
switch varName {
|
||||
case "var":
|
||||
return "'ABC'123"
|
||||
}
|
||||
return "${" + varName + "}"
|
||||
}))
|
||||
}
|
||||
|
||||
func TestParseHolders(t *testing.T) {
|
||||
var holders = ParseHolders("hello, ${name}, world")
|
||||
var holders = configutils.ParseHolders("hello, ${name|urlencode}, world")
|
||||
t.Log("===holders begin===")
|
||||
for _, h := range holders {
|
||||
t.Log(types.String(h))
|
||||
}
|
||||
t.Log("===holders end===")
|
||||
|
||||
t.Log("parse result:", ParseVariablesFromHolders(holders, func(s string) string {
|
||||
t.Log("parse result:", configutils.ParseVariablesFromHolders(holders, func(s string) string {
|
||||
return "[" + s + "]"
|
||||
}))
|
||||
}
|
||||
|
||||
func BenchmarkParseVariables(b *testing.B) {
|
||||
_ = ParseVariables("hello, ${name}, ${age}, ${gender}, ${home}, world", func(s string) string {
|
||||
_ = configutils.ParseVariables("hello, ${name}, ${age}, ${gender}, ${home}, world", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
|
||||
@@ -57,7 +162,7 @@ func BenchmarkParseVariables(b *testing.B) {
|
||||
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
for pb.Next() {
|
||||
_ = ParseVariables("hello, ${name}, ${age}, ${gender}, ${home}, world", func(s string) string {
|
||||
_ = configutils.ParseVariables("hello, ${name}, ${age}, ${gender}, ${home}, world", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
}
|
||||
@@ -65,10 +170,10 @@ func BenchmarkParseVariables(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkParseVariablesFromHolders(b *testing.B) {
|
||||
var holders = ParseHolders("hello, ${name}, ${age}, ${gender}, ${home}, world")
|
||||
var holders = configutils.ParseHolders("hello, ${name}, ${age}, ${gender}, ${home}, world")
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = ParseVariablesFromHolders(holders, func(s string) string {
|
||||
_ = configutils.ParseVariablesFromHolders(holders, func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
}
|
||||
@@ -76,7 +181,7 @@ func BenchmarkParseVariablesFromHolders(b *testing.B) {
|
||||
|
||||
func BenchmarkParseVariablesUnique(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = ParseVariables("hello, ${name} "+strconv.Itoa(i), func(s string) string {
|
||||
_ = configutils.ParseVariables("hello, ${name} "+strconv.Itoa(i%100_000), func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
}
|
||||
@@ -86,7 +191,7 @@ func BenchmarkParseVariablesUnique_Single(b *testing.B) {
|
||||
runtime.GOMAXPROCS(1)
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = ParseVariables("${name}", func(s string) string {
|
||||
_ = configutils.ParseVariables("${name}", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
}
|
||||
@@ -94,7 +199,7 @@ func BenchmarkParseVariablesUnique_Single(b *testing.B) {
|
||||
|
||||
func BenchmarkParseNoVariables(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = ParseVariables("hello, world", func(s string) string {
|
||||
_ = configutils.ParseVariables("hello, world", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
}
|
||||
@@ -102,7 +207,7 @@ func BenchmarkParseNoVariables(b *testing.B) {
|
||||
|
||||
func BenchmarkParseEmpty(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = ParseVariables("", func(s string) string {
|
||||
_ = configutils.ParseVariables("", func(s string) string {
|
||||
return "Lu"
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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 dnsconfigs
|
||||
|
||||
|
||||
3
pkg/iplibrary/.gitignore
vendored
3
pkg/iplibrary/.gitignore
vendored
@@ -1 +1,2 @@
|
||||
*-plus.db
|
||||
*-plus.db
|
||||
internal-ip-library-test.db
|
||||
@@ -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 iplibrary
|
||||
|
||||
@@ -33,7 +33,7 @@ func InitDefault() error {
|
||||
}
|
||||
|
||||
var library = NewIPLibrary()
|
||||
err := library.InitFromData(ipLibraryData, "")
|
||||
err := library.InitFromData(ipLibraryData, "", ReaderVersionV1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -66,18 +66,18 @@ func LookupIPSummaries(ipList []string) map[string]string /** ip => summary **/
|
||||
}
|
||||
|
||||
type IPLibrary struct {
|
||||
reader *Reader
|
||||
reader ReaderInterface
|
||||
}
|
||||
|
||||
func NewIPLibrary() *IPLibrary {
|
||||
return &IPLibrary{}
|
||||
}
|
||||
|
||||
func NewIPLibraryWithReader(reader *Reader) *IPLibrary {
|
||||
func NewIPLibraryWithReader(reader ReaderInterface) *IPLibrary {
|
||||
return &IPLibrary{reader: reader}
|
||||
}
|
||||
|
||||
func (this *IPLibrary) InitFromData(data []byte, password string) error {
|
||||
func (this *IPLibrary) InitFromData(data []byte, password string, version ReaderVersion) error {
|
||||
if len(data) == 0 || this.reader != nil {
|
||||
return nil
|
||||
}
|
||||
@@ -99,7 +99,12 @@ func (this *IPLibrary) InitFromData(data []byte, password string) error {
|
||||
_ = gzipReader.Close()
|
||||
}()
|
||||
|
||||
libReader, err := NewReader(gzipReader)
|
||||
var libReader ReaderInterface
|
||||
if version == ReaderVersionV2 {
|
||||
libReader, err = NewReaderV2(gzipReader)
|
||||
} else {
|
||||
libReader, err = NewReaderV1(gzipReader)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -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 iplibrary_test
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestIPLibrary_Init(t *testing.T) {
|
||||
var lib = iplibrary.NewIPLibrary()
|
||||
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "")
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "", iplibrary.ReaderVersionV1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -38,7 +38,7 @@ func TestIPLibrary_Lookup(t *testing.T) {
|
||||
|
||||
var before = time.Now()
|
||||
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "")
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "", iplibrary.ReaderVersionV1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func TestIPLibrary_Lookup(t *testing.T) {
|
||||
|
||||
func TestIPLibrary_LookupIP(t *testing.T) {
|
||||
var lib = iplibrary.NewIPLibrary()
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "")
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "", iplibrary.ReaderVersionV1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func TestIPLibrary_LookupIP(t *testing.T) {
|
||||
|
||||
func TestIPLibrary_LookupIP_Summary(t *testing.T) {
|
||||
var lib = iplibrary.NewIPLibrary()
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "")
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "", iplibrary.ReaderVersionV1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func TestIPLibrary_LookupIPSummaries(t *testing.T) {
|
||||
|
||||
func BenchmarkIPLibrary_Lookup(b *testing.B) {
|
||||
var lib = iplibrary.NewIPLibrary()
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "")
|
||||
err := lib.InitFromData(iplibrary.DefaultIPLibraryData(), "", iplibrary.ReaderVersionV1)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -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 iplibrary
|
||||
|
||||
|
||||
@@ -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 iplibrary
|
||||
|
||||
@@ -6,20 +6,34 @@ import (
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
|
||||
type ipv4Item struct {
|
||||
type ipv4ItemV1 struct {
|
||||
IPFrom uint32
|
||||
IPTo uint32
|
||||
|
||||
Region *ipRegion
|
||||
}
|
||||
|
||||
type ipv6Item struct {
|
||||
type ipv6ItemV1 struct {
|
||||
IPFrom uint64
|
||||
IPTo uint64
|
||||
|
||||
Region *ipRegion
|
||||
}
|
||||
|
||||
type ipv4ItemV2 struct {
|
||||
IPFrom [4]byte
|
||||
IPTo [4]byte
|
||||
|
||||
Region *ipRegion
|
||||
}
|
||||
|
||||
type ipv6ItemV2 struct {
|
||||
IPFrom [16]byte
|
||||
IPTo [16]byte
|
||||
|
||||
Region *ipRegion
|
||||
}
|
||||
|
||||
type ipRegion struct {
|
||||
CountryId uint16
|
||||
ProvinceId uint16
|
||||
|
||||
@@ -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 iplibrary
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// 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 iplibrary_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 iplibrary
|
||||
|
||||
|
||||
@@ -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 iplibrary
|
||||
|
||||
|
||||
@@ -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 iplibrary
|
||||
|
||||
|
||||
@@ -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 iplibrary_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 iplibrary_test
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
// 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 iplibrary
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"io"
|
||||
"math/big"
|
||||
"net"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -20,8 +23,8 @@ type Reader struct {
|
||||
|
||||
regionMap map[string]*ipRegion // 缓存重复的区域用来节约内存
|
||||
|
||||
ipV4Items []ipv4Item
|
||||
ipV6Items []ipv6Item
|
||||
ipV4Items []ipv4ItemV1
|
||||
ipV6Items []ipv6ItemV1
|
||||
|
||||
lastIPFrom uint64
|
||||
lastCountryId uint16
|
||||
@@ -31,11 +34,18 @@ type Reader struct {
|
||||
lastProviderId uint16
|
||||
}
|
||||
|
||||
// NewReader 创建新Reader对象
|
||||
func NewReader(reader io.Reader) (*Reader, error) {
|
||||
// NewReaderV1 创建新Reader对象
|
||||
func NewReaderV1(reader io.Reader) (*Reader, error) {
|
||||
var libReader = &Reader{
|
||||
regionMap: map[string]*ipRegion{},
|
||||
}
|
||||
|
||||
if runtime.NumCPU() >= 4 /** CPU数量较多的通常有着大内存 **/ {
|
||||
libReader.ipV4Items = make([]ipv4ItemV1, 0, 6_000_000)
|
||||
} else {
|
||||
libReader.ipV4Items = make([]ipv4ItemV1, 0, 600_000)
|
||||
}
|
||||
|
||||
err := libReader.load(reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -123,7 +133,7 @@ func (this *Reader) Lookup(ip net.IP) *QueryResult {
|
||||
return &QueryResult{}
|
||||
}
|
||||
|
||||
var ipLong = configutils.IP2Long(ip)
|
||||
var ipLong = this.ip2long(ip)
|
||||
var isV4 = configutils.IsIPv4(ip)
|
||||
var resultItem any
|
||||
if isV4 {
|
||||
@@ -162,11 +172,11 @@ func (this *Reader) Meta() *Meta {
|
||||
return this.meta
|
||||
}
|
||||
|
||||
func (this *Reader) IPv4Items() []ipv4Item {
|
||||
func (this *Reader) IPv4Items() []ipv4ItemV1 {
|
||||
return this.ipV4Items
|
||||
}
|
||||
|
||||
func (this *Reader) IPv6Items() []ipv6Item {
|
||||
func (this *Reader) IPv6Items() []ipv6ItemV1 {
|
||||
return this.ipV6Items
|
||||
}
|
||||
|
||||
@@ -296,13 +306,13 @@ func (this *Reader) parseLine(line []byte) error {
|
||||
}
|
||||
|
||||
if version == "4" {
|
||||
this.ipV4Items = append(this.ipV4Items, ipv4Item{
|
||||
this.ipV4Items = append(this.ipV4Items, ipv4ItemV1{
|
||||
IPFrom: uint32(ipFrom),
|
||||
IPTo: uint32(ipTo),
|
||||
Region: region,
|
||||
})
|
||||
} else {
|
||||
this.ipV6Items = append(this.ipV6Items, ipv6Item{
|
||||
this.ipV6Items = append(this.ipV6Items, ipv6ItemV1{
|
||||
IPFrom: ipFrom,
|
||||
IPTo: ipTo,
|
||||
Region: region,
|
||||
@@ -320,3 +330,18 @@ func (this *Reader) decodeUint64(s string) uint64 {
|
||||
i, _ := strconv.ParseUint(s, 10, 64)
|
||||
return i
|
||||
}
|
||||
|
||||
func (this *Reader) ip2long(netIP net.IP) uint64 {
|
||||
if len(netIP) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var b4 = netIP.To4()
|
||||
if b4 != nil {
|
||||
return uint64(binary.BigEndian.Uint32(b4.To4()))
|
||||
}
|
||||
|
||||
var i = big.NewInt(0)
|
||||
i.SetBytes(netIP.To16())
|
||||
return i.Uint64()
|
||||
}
|
||||
|
||||
@@ -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 iplibrary
|
||||
|
||||
@@ -9,10 +9,12 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FileReader struct {
|
||||
rawReader *Reader
|
||||
rawReader ReaderInterface
|
||||
//password string
|
||||
}
|
||||
|
||||
@@ -25,10 +27,15 @@ func NewFileReader(path string, password string) (*FileReader, error) {
|
||||
_ = fp.Close()
|
||||
}()
|
||||
|
||||
return NewFileDataReader(fp, password)
|
||||
var version = ReaderVersionV1
|
||||
if strings.HasSuffix(filepath.Base(path), ".v2.db") {
|
||||
version = ReaderVersionV2
|
||||
}
|
||||
|
||||
return NewFileDataReader(fp, password, version)
|
||||
}
|
||||
|
||||
func NewFileDataReader(dataReader io.Reader, password string) (*FileReader, error) {
|
||||
func NewFileDataReader(dataReader io.Reader, password string, readerVersion ReaderVersion) (*FileReader, error) {
|
||||
if len(password) > 0 {
|
||||
data, err := io.ReadAll(dataReader)
|
||||
if err != nil {
|
||||
@@ -48,7 +55,12 @@ func NewFileDataReader(dataReader io.Reader, password string) (*FileReader, erro
|
||||
return nil, fmt.Errorf("create gzip reader failed: %w", err)
|
||||
}
|
||||
|
||||
reader, err := NewReader(gzReader)
|
||||
var reader ReaderInterface
|
||||
if readerVersion == ReaderVersionV2 {
|
||||
reader, err = NewReaderV2(gzReader)
|
||||
} else {
|
||||
reader, err = NewReaderV1(gzReader)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -59,13 +71,13 @@ func NewFileDataReader(dataReader io.Reader, password string) (*FileReader, erro
|
||||
}
|
||||
|
||||
func (this *FileReader) Meta() *Meta {
|
||||
return this.rawReader.meta
|
||||
return this.rawReader.Meta()
|
||||
}
|
||||
|
||||
func (this *FileReader) Lookup(ip net.IP) *QueryResult {
|
||||
return this.rawReader.Lookup(ip)
|
||||
}
|
||||
|
||||
func (this *FileReader) RawReader() *Reader {
|
||||
func (this *FileReader) RawReader() ReaderInterface {
|
||||
return this.rawReader
|
||||
}
|
||||
|
||||
@@ -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 iplibrary_test
|
||||
|
||||
@@ -6,12 +6,13 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewFileReader(t *testing.T) {
|
||||
reader, err := iplibrary.NewFileReader("./ip-20c1461c.db", "123456")
|
||||
reader, err := iplibrary.NewFileReader("./default_ip_library_plus_test.go", stringutil.Md5("123456"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
18
pkg/iplibrary/reader_interface.go
Normal file
18
pkg/iplibrary/reader_interface.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package iplibrary
|
||||
|
||||
import "net"
|
||||
|
||||
type ReaderVersion = int
|
||||
|
||||
const (
|
||||
ReaderVersionV1 ReaderVersion = 0
|
||||
ReaderVersionV2 ReaderVersion = 2
|
||||
)
|
||||
|
||||
type ReaderInterface interface {
|
||||
Meta() *Meta
|
||||
Lookup(ip net.IP) *QueryResult
|
||||
Destroy()
|
||||
}
|
||||
@@ -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 iplibrary
|
||||
|
||||
@@ -213,13 +213,21 @@ func (this *QueryResult) RegionSummary() string {
|
||||
func (this *QueryResult) realCountryId() uint16 {
|
||||
if this.item != nil {
|
||||
switch item := this.item.(type) {
|
||||
case *ipv4Item:
|
||||
case *ipv4ItemV1:
|
||||
return item.Region.CountryId
|
||||
case ipv4Item:
|
||||
case ipv4ItemV1:
|
||||
return item.Region.CountryId
|
||||
case *ipv6Item:
|
||||
case *ipv6ItemV1:
|
||||
return item.Region.CountryId
|
||||
case ipv6Item:
|
||||
case ipv6ItemV1:
|
||||
return item.Region.CountryId
|
||||
case *ipv4ItemV2:
|
||||
return item.Region.CountryId
|
||||
case ipv4ItemV2:
|
||||
return item.Region.CountryId
|
||||
case *ipv6ItemV2:
|
||||
return item.Region.CountryId
|
||||
case ipv6ItemV2:
|
||||
return item.Region.CountryId
|
||||
}
|
||||
|
||||
@@ -230,13 +238,21 @@ func (this *QueryResult) realCountryId() uint16 {
|
||||
func (this *QueryResult) realProvinceId() uint16 {
|
||||
if this.item != nil {
|
||||
switch item := this.item.(type) {
|
||||
case *ipv4Item:
|
||||
case *ipv4ItemV1:
|
||||
return item.Region.ProvinceId
|
||||
case ipv4Item:
|
||||
case ipv4ItemV1:
|
||||
return item.Region.ProvinceId
|
||||
case *ipv6Item:
|
||||
case *ipv6ItemV1:
|
||||
return item.Region.ProvinceId
|
||||
case ipv6Item:
|
||||
case ipv6ItemV1:
|
||||
return item.Region.ProvinceId
|
||||
case *ipv4ItemV2:
|
||||
return item.Region.ProvinceId
|
||||
case ipv4ItemV2:
|
||||
return item.Region.ProvinceId
|
||||
case *ipv6ItemV2:
|
||||
return item.Region.ProvinceId
|
||||
case ipv6ItemV2:
|
||||
return item.Region.ProvinceId
|
||||
}
|
||||
|
||||
@@ -247,13 +263,21 @@ func (this *QueryResult) realProvinceId() uint16 {
|
||||
func (this *QueryResult) realCityId() uint32 {
|
||||
if this.item != nil {
|
||||
switch item := this.item.(type) {
|
||||
case *ipv4Item:
|
||||
case *ipv4ItemV1:
|
||||
return item.Region.CityId
|
||||
case ipv4Item:
|
||||
case ipv4ItemV1:
|
||||
return item.Region.CityId
|
||||
case *ipv6Item:
|
||||
case *ipv6ItemV1:
|
||||
return item.Region.CityId
|
||||
case ipv6Item:
|
||||
case ipv6ItemV1:
|
||||
return item.Region.CityId
|
||||
case *ipv4ItemV2:
|
||||
return item.Region.CityId
|
||||
case ipv4ItemV2:
|
||||
return item.Region.CityId
|
||||
case *ipv6ItemV2:
|
||||
return item.Region.CityId
|
||||
case ipv6ItemV2:
|
||||
return item.Region.CityId
|
||||
}
|
||||
|
||||
@@ -264,13 +288,21 @@ func (this *QueryResult) realCityId() uint32 {
|
||||
func (this *QueryResult) realTownId() uint32 {
|
||||
if this.item != nil {
|
||||
switch item := this.item.(type) {
|
||||
case *ipv4Item:
|
||||
case *ipv4ItemV1:
|
||||
return item.Region.TownId
|
||||
case ipv4Item:
|
||||
case ipv4ItemV1:
|
||||
return item.Region.TownId
|
||||
case *ipv6Item:
|
||||
case *ipv6ItemV1:
|
||||
return item.Region.TownId
|
||||
case ipv6Item:
|
||||
case ipv6ItemV1:
|
||||
return item.Region.TownId
|
||||
case *ipv4ItemV2:
|
||||
return item.Region.TownId
|
||||
case ipv4ItemV2:
|
||||
return item.Region.TownId
|
||||
case *ipv6ItemV2:
|
||||
return item.Region.TownId
|
||||
case ipv6ItemV2:
|
||||
return item.Region.TownId
|
||||
}
|
||||
|
||||
@@ -281,13 +313,21 @@ func (this *QueryResult) realTownId() uint32 {
|
||||
func (this *QueryResult) realProviderId() uint16 {
|
||||
if this.item != nil {
|
||||
switch item := this.item.(type) {
|
||||
case *ipv4Item:
|
||||
case *ipv4ItemV1:
|
||||
return item.Region.ProviderId
|
||||
case ipv4Item:
|
||||
case ipv4ItemV1:
|
||||
return item.Region.ProviderId
|
||||
case *ipv6Item:
|
||||
case *ipv6ItemV1:
|
||||
return item.Region.ProviderId
|
||||
case ipv6Item:
|
||||
case ipv6ItemV1:
|
||||
return item.Region.ProviderId
|
||||
case *ipv4ItemV2:
|
||||
return item.Region.ProviderId
|
||||
case ipv4ItemV2:
|
||||
return item.Region.ProviderId
|
||||
case *ipv6ItemV2:
|
||||
return item.Region.ProviderId
|
||||
case ipv6ItemV2:
|
||||
return item.Region.ProviderId
|
||||
}
|
||||
|
||||
|
||||
@@ -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 iplibrary_test
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
func TestNewReader(t *testing.T) {
|
||||
var buf = &bytes.Buffer{}
|
||||
var writer = iplibrary.NewWriter(buf, &iplibrary.Meta{
|
||||
var writer = iplibrary.NewWriterV1(buf, &iplibrary.Meta{
|
||||
Author: "GoEdge <https://goedge.cn>",
|
||||
})
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestNewReader(t *testing.T) {
|
||||
|
||||
var stat = &runtime.MemStats{}
|
||||
runtime.ReadMemStats(stat)
|
||||
reader, err := iplibrary.NewReader(buf)
|
||||
reader, err := iplibrary.NewReaderV2(buf)
|
||||
|
||||
var stat2 = &runtime.MemStats{}
|
||||
runtime.ReadMemStats(stat2)
|
||||
@@ -115,7 +115,7 @@ func BenchmarkNewReader(b *testing.B) {
|
||||
runtime.GOMAXPROCS(1)
|
||||
|
||||
var buf = &bytes.Buffer{}
|
||||
var writer = iplibrary.NewWriter(buf, &iplibrary.Meta{
|
||||
var writer = iplibrary.NewWriterV1(buf, &iplibrary.Meta{
|
||||
Author: "GoEdge <https://goedge.cn>",
|
||||
})
|
||||
|
||||
@@ -135,7 +135,7 @@ func BenchmarkNewReader(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
reader, err := iplibrary.NewReader(buf)
|
||||
reader, err := iplibrary.NewReaderV2(buf)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
360
pkg/iplibrary/reader_v2.go
Normal file
360
pkg/iplibrary/reader_v2.go
Normal file
@@ -0,0 +1,360 @@
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package iplibrary
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ReaderV2 IP库Reader V2
|
||||
type ReaderV2 struct {
|
||||
meta *Meta
|
||||
|
||||
regionMap map[string]*ipRegion // 缓存重复的区域用来节约内存
|
||||
|
||||
ipV4Items []ipv4ItemV2
|
||||
ipV6Items []ipv6ItemV2
|
||||
|
||||
lastCountryId uint16
|
||||
lastProvinceId uint16
|
||||
lastCityId uint32
|
||||
lastTownId uint32
|
||||
lastProviderId uint16
|
||||
}
|
||||
|
||||
// NewReaderV2 创建新Reader对象
|
||||
func NewReaderV2(reader io.Reader) (*ReaderV2, error) {
|
||||
var libReader = &ReaderV2{
|
||||
regionMap: map[string]*ipRegion{},
|
||||
}
|
||||
|
||||
if runtime.NumCPU() >= 4 /** CPU数量较多的通常有着大内存 **/ {
|
||||
libReader.ipV4Items = make([]ipv4ItemV2, 0, 6_000_000)
|
||||
} else {
|
||||
libReader.ipV4Items = make([]ipv4ItemV2, 0, 600_000)
|
||||
}
|
||||
|
||||
err := libReader.load(reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return libReader, nil
|
||||
}
|
||||
|
||||
// 从Reader中加载数据
|
||||
func (this *ReaderV2) load(reader io.Reader) error {
|
||||
var buf = make([]byte, 1024)
|
||||
var metaLine []byte
|
||||
var metaLineFound = false
|
||||
var dataBuf = []byte{}
|
||||
for {
|
||||
n, err := reader.Read(buf)
|
||||
if n > 0 {
|
||||
var data = buf[:n]
|
||||
dataBuf = append(dataBuf, data...)
|
||||
if metaLineFound {
|
||||
left, err := this.parse(dataBuf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dataBuf = left
|
||||
} else {
|
||||
var index = bytes.IndexByte(dataBuf, '\n')
|
||||
if index > 0 {
|
||||
metaLine = dataBuf[:index]
|
||||
dataBuf = dataBuf[index+1:]
|
||||
metaLineFound = true
|
||||
var meta = &Meta{}
|
||||
err = json.Unmarshal(metaLine, &meta)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
meta.Init()
|
||||
this.meta = meta
|
||||
|
||||
left, err := this.parse(dataBuf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dataBuf = left
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
return err
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(this.ipV4Items, func(i, j int) bool {
|
||||
var from0 = this.ipV4Items[i].IPFrom
|
||||
var to0 = this.ipV4Items[i].IPTo
|
||||
var from1 = this.ipV4Items[j].IPFrom
|
||||
var to1 = this.ipV4Items[j].IPTo
|
||||
if from0 == from1 {
|
||||
return bytes.Compare(to0[:], to1[:]) < 0
|
||||
}
|
||||
return bytes.Compare(from0[:], from1[:]) < 0
|
||||
})
|
||||
|
||||
sort.Slice(this.ipV6Items, func(i, j int) bool {
|
||||
var from0 = this.ipV6Items[i].IPFrom
|
||||
var to0 = this.ipV6Items[i].IPTo
|
||||
var from1 = this.ipV6Items[j].IPFrom
|
||||
var to1 = this.ipV6Items[j].IPTo
|
||||
if from0 == from1 {
|
||||
return bytes.Compare(to0[:], to1[:]) < 0
|
||||
}
|
||||
return bytes.Compare(from0[:], from1[:]) < 0
|
||||
})
|
||||
|
||||
// 清理内存
|
||||
this.regionMap = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *ReaderV2) Lookup(ip net.IP) *QueryResult {
|
||||
if ip == nil {
|
||||
return &QueryResult{}
|
||||
}
|
||||
|
||||
var isV4 = ip.To4() != nil
|
||||
var resultItem any
|
||||
if isV4 {
|
||||
sort.Search(len(this.ipV4Items), func(i int) bool {
|
||||
var item = this.ipV4Items[i]
|
||||
if bytes.Compare(item.IPFrom[:], ip) <= 0 {
|
||||
if bytes.Compare(item.IPTo[:], ip) >= 0 {
|
||||
resultItem = item
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
} else {
|
||||
sort.Search(len(this.ipV6Items), func(i int) bool {
|
||||
var item = this.ipV6Items[i]
|
||||
if bytes.Compare(item.IPFrom[:], ip) <= 0 {
|
||||
if bytes.Compare(item.IPTo[:], ip) >= 0 {
|
||||
resultItem = item
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
return &QueryResult{
|
||||
item: resultItem,
|
||||
meta: this.meta,
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ReaderV2) Meta() *Meta {
|
||||
return this.meta
|
||||
}
|
||||
|
||||
func (this *ReaderV2) IPv4Items() []ipv4ItemV2 {
|
||||
return this.ipV4Items
|
||||
}
|
||||
|
||||
func (this *ReaderV2) IPv6Items() []ipv6ItemV2 {
|
||||
return this.ipV6Items
|
||||
}
|
||||
|
||||
func (this *ReaderV2) Destroy() {
|
||||
this.meta = nil
|
||||
this.regionMap = nil
|
||||
this.ipV4Items = nil
|
||||
this.ipV6Items = nil
|
||||
}
|
||||
|
||||
// 分析数据
|
||||
func (this *ReaderV2) parse(data []byte) (left []byte, err error) {
|
||||
if len(data) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for {
|
||||
if len(data) == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
var offset int
|
||||
if data[0] == '|' {
|
||||
offset = 1 + 8 + 1
|
||||
} else if data[0] == '4' {
|
||||
offset = 2 + 8 + 1
|
||||
} else if data[0] == '6' {
|
||||
offset = 2 + 32 + 1
|
||||
}
|
||||
|
||||
var index = bytes.IndexByte(data[offset:], '\n')
|
||||
if index >= 0 {
|
||||
index += offset
|
||||
var line = data[:index]
|
||||
err = this.parseLine(line)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data = data[index+1:]
|
||||
} else {
|
||||
left = data
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 单行分析
|
||||
func (this *ReaderV2) parseLine(line []byte) error {
|
||||
if len(line) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
const maxPieces = 8
|
||||
var pieces []string
|
||||
|
||||
var offset int
|
||||
if line[0] == '|' {
|
||||
offset = 1 + 8 + 1
|
||||
pieces = append(pieces, "", string(line[1:5]), string(line[5:9]))
|
||||
} else if line[0] == '4' {
|
||||
offset = 2 + 8 + 1
|
||||
pieces = append(pieces, "", string(line[2:6]), string(line[6:10]))
|
||||
} else if line[0] == '6' {
|
||||
offset = 2 + 32 + 1
|
||||
pieces = append(pieces, "6", string(line[2:18]), string(line[18:34]))
|
||||
}
|
||||
|
||||
pieces = append(pieces, strings.Split(string(line[offset:]), "|")...)
|
||||
|
||||
var countPieces = len(pieces)
|
||||
if countPieces < maxPieces { // 补足一行
|
||||
for i := 0; i < maxPieces-countPieces; i++ {
|
||||
pieces = append(pieces, "")
|
||||
}
|
||||
} else if countPieces > maxPieces {
|
||||
return errors.New("invalid ip definition '" + string(line) + "'")
|
||||
}
|
||||
|
||||
var version = pieces[0]
|
||||
if len(version) == 0 {
|
||||
version = "4"
|
||||
}
|
||||
|
||||
if version != "4" && version != "6" {
|
||||
return errors.New("invalid ip version '" + string(line) + "'")
|
||||
}
|
||||
|
||||
// ip range
|
||||
var ipFromV4 [4]byte
|
||||
var ipToV4 [4]byte
|
||||
|
||||
var ipFromV6 [16]byte
|
||||
var ipToV6 [16]byte
|
||||
|
||||
if version == "6" {
|
||||
ipFromV6 = [16]byte([]byte(pieces[1]))
|
||||
ipToV6 = [16]byte([]byte(pieces[2]))
|
||||
} else {
|
||||
ipFromV4 = [4]byte([]byte(pieces[1]))
|
||||
ipToV4 = [4]byte([]byte(pieces[2]))
|
||||
}
|
||||
|
||||
// country
|
||||
var countryId uint16
|
||||
if pieces[3] == "+" {
|
||||
countryId = this.lastCountryId
|
||||
} else {
|
||||
countryId = uint16(this.decodeUint64(pieces[3]))
|
||||
}
|
||||
this.lastCountryId = countryId
|
||||
|
||||
var provinceId uint16
|
||||
if pieces[4] == "+" {
|
||||
provinceId = this.lastProvinceId
|
||||
} else {
|
||||
provinceId = uint16(this.decodeUint64(pieces[4]))
|
||||
}
|
||||
this.lastProvinceId = provinceId
|
||||
|
||||
// city
|
||||
var cityId uint32
|
||||
if pieces[5] == "+" {
|
||||
cityId = this.lastCityId
|
||||
} else {
|
||||
cityId = uint32(this.decodeUint64(pieces[5]))
|
||||
}
|
||||
this.lastCityId = cityId
|
||||
|
||||
// town
|
||||
var townId uint32
|
||||
if pieces[6] == "+" {
|
||||
townId = this.lastTownId
|
||||
} else {
|
||||
townId = uint32(this.decodeUint64(pieces[6]))
|
||||
}
|
||||
this.lastTownId = townId
|
||||
|
||||
// provider
|
||||
var providerId uint16
|
||||
if pieces[7] == "+" {
|
||||
providerId = this.lastProviderId
|
||||
} else {
|
||||
providerId = uint16(this.decodeUint64(pieces[7]))
|
||||
}
|
||||
this.lastProviderId = providerId
|
||||
|
||||
var hash = HashRegion(countryId, provinceId, cityId, townId, providerId)
|
||||
|
||||
region, ok := this.regionMap[hash]
|
||||
if !ok {
|
||||
region = &ipRegion{
|
||||
CountryId: countryId,
|
||||
ProvinceId: provinceId,
|
||||
CityId: cityId,
|
||||
TownId: townId,
|
||||
ProviderId: providerId,
|
||||
}
|
||||
this.regionMap[hash] = region
|
||||
}
|
||||
|
||||
if version == "4" {
|
||||
this.ipV4Items = append(this.ipV4Items, ipv4ItemV2{
|
||||
IPFrom: ipFromV4,
|
||||
IPTo: ipToV4,
|
||||
Region: region,
|
||||
})
|
||||
} else {
|
||||
this.ipV6Items = append(this.ipV6Items, ipv6ItemV2{
|
||||
IPFrom: ipFromV6,
|
||||
IPTo: ipToV6,
|
||||
Region: region,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *ReaderV2) decodeUint64(s string) uint64 {
|
||||
if this.meta != nil && this.meta.Version == Version2 {
|
||||
i, _ := strconv.ParseUint(s, 32, 64)
|
||||
return i
|
||||
}
|
||||
i, _ := strconv.ParseUint(s, 10, 64)
|
||||
return i
|
||||
}
|
||||
@@ -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 iplibrary
|
||||
|
||||
|
||||
@@ -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 iplibrary_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 iplibrary
|
||||
|
||||
@@ -214,7 +214,12 @@ func (this *Updater) Loop() error {
|
||||
func (this *Updater) loadFile(fp *os.File) error {
|
||||
this.source.LogInfo("load ip library from '" + fp.Name() + "' ...")
|
||||
|
||||
fileReader, err := NewFileDataReader(fp, "")
|
||||
var version = ReaderVersionV1
|
||||
if strings.HasSuffix(fp.Name(), ".v2.db") {
|
||||
version = ReaderVersionV2
|
||||
}
|
||||
|
||||
fileReader, err := NewFileDataReader(fp, "", version)
|
||||
if err != nil {
|
||||
return fmt.Errorf("load ip library from reader failed: %w", err)
|
||||
}
|
||||
|
||||
@@ -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 iplibrary_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 iplibrary
|
||||
|
||||
|
||||
@@ -1,44 +1,21 @@
|
||||
// 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 iplibrary
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"hash"
|
||||
"io"
|
||||
"math/big"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type hashWriter struct {
|
||||
rawWriter io.Writer
|
||||
hash hash.Hash
|
||||
}
|
||||
|
||||
func newHashWriter(writer io.Writer) *hashWriter {
|
||||
return &hashWriter{
|
||||
rawWriter: writer,
|
||||
hash: md5.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func (this *hashWriter) Write(p []byte) (n int, err error) {
|
||||
n, err = this.rawWriter.Write(p)
|
||||
this.hash.Write(p)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *hashWriter) Sum() string {
|
||||
return fmt.Sprintf("%x", this.hash.Sum(nil))
|
||||
}
|
||||
|
||||
type Writer struct {
|
||||
type WriterV1 struct {
|
||||
writer *hashWriter
|
||||
meta *Meta
|
||||
|
||||
@@ -50,21 +27,21 @@ type Writer struct {
|
||||
lastProviderId int64
|
||||
}
|
||||
|
||||
func NewWriter(writer io.Writer, meta *Meta) *Writer {
|
||||
func NewWriterV1(writer io.Writer, meta *Meta) *WriterV1 {
|
||||
if meta == nil {
|
||||
meta = &Meta{}
|
||||
}
|
||||
meta.Version = Version2
|
||||
meta.CreatedAt = time.Now().Unix()
|
||||
|
||||
var libWriter = &Writer{
|
||||
var libWriter = &WriterV1{
|
||||
writer: newHashWriter(writer),
|
||||
meta: meta,
|
||||
}
|
||||
return libWriter
|
||||
}
|
||||
|
||||
func (this *Writer) WriteMeta() error {
|
||||
func (this *WriterV1) WriteMeta() error {
|
||||
metaJSON, err := json.Marshal(this.meta)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -77,7 +54,7 @@ func (this *Writer) WriteMeta() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *Writer) Write(ipFrom string, ipTo string, countryId int64, provinceId int64, cityId int64, townId int64, providerId int64) error {
|
||||
func (this *WriterV1) Write(ipFrom string, ipTo string, countryId int64, provinceId int64, cityId int64, townId int64, providerId int64) error {
|
||||
// validate IP
|
||||
var fromIP = net.ParseIP(ipFrom)
|
||||
if fromIP == nil {
|
||||
@@ -100,11 +77,14 @@ func (this *Writer) Write(ipFrom string, ipTo string, countryId int64, provinceI
|
||||
pieces = append(pieces, "")
|
||||
} else {
|
||||
pieces = append(pieces, "6")
|
||||
|
||||
// we do NOT support v6 yet
|
||||
return nil
|
||||
}
|
||||
|
||||
// 1
|
||||
var fromIPLong = configutils.IP2Long(fromIP)
|
||||
var toIPLong = configutils.IP2Long(toIP)
|
||||
var fromIPLong = this.ip2long(fromIP)
|
||||
var toIPLong = this.ip2long(toIP)
|
||||
|
||||
if toIPLong < fromIPLong {
|
||||
fromIPLong, toIPLong = toIPLong, fromIPLong
|
||||
@@ -193,10 +173,25 @@ func (this *Writer) Write(ipFrom string, ipTo string, countryId int64, provinceI
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *Writer) Sum() string {
|
||||
func (this *WriterV1) Sum() string {
|
||||
return this.writer.Sum()
|
||||
}
|
||||
|
||||
func (this *Writer) formatUint64(i uint64) string {
|
||||
func (this *WriterV1) formatUint64(i uint64) string {
|
||||
return strconv.FormatUint(i, 32)
|
||||
}
|
||||
|
||||
func (this *WriterV1) ip2long(netIP net.IP) uint64 {
|
||||
if len(netIP) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var b4 = netIP.To4()
|
||||
if b4 != nil {
|
||||
return uint64(binary.BigEndian.Uint32(b4.To4()))
|
||||
}
|
||||
|
||||
var i = big.NewInt(0)
|
||||
i.SetBytes(netIP.To16())
|
||||
return i.Uint64()
|
||||
}
|
||||
|
||||
@@ -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 iplibrary
|
||||
|
||||
@@ -12,7 +12,7 @@ type FileWriter struct {
|
||||
gzWriter *gzip.Writer
|
||||
password string
|
||||
|
||||
rawWriter *Writer
|
||||
rawWriter WriterInterface
|
||||
}
|
||||
|
||||
func NewFileWriter(path string, meta *Meta, password string) (*FileWriter, error) {
|
||||
@@ -29,7 +29,7 @@ func NewFileWriter(path string, meta *Meta, password string) (*FileWriter, error
|
||||
var writer = &FileWriter{
|
||||
fp: fp,
|
||||
gzWriter: gzWriter,
|
||||
rawWriter: NewWriter(gzWriter, meta),
|
||||
rawWriter: NewWriterV1(gzWriter, meta),
|
||||
password: password,
|
||||
}
|
||||
return writer, nil
|
||||
@@ -64,11 +64,13 @@ func (this *FileWriter) Close() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(data) > 0 {
|
||||
encodedData, err := NewEncrypt().Encode(data, this.password)
|
||||
if err != nil {
|
||||
return err
|
||||
encodedData, encodeErr := NewEncrypt().Encode(data, this.password)
|
||||
if encodeErr != nil {
|
||||
return encodeErr
|
||||
}
|
||||
_ = os.Remove(filePath)
|
||||
err = os.WriteFile(filePath, encodedData, 0666)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -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 iplibrary_test
|
||||
|
||||
@@ -6,13 +6,14 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewFileWriter(t *testing.T) {
|
||||
writer, err := iplibrary.NewFileWriter("./internal-ip-library-test.db", &iplibrary.Meta{
|
||||
Author: "GoEdge",
|
||||
}, "")
|
||||
}, stringutil.Md5("123456"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
9
pkg/iplibrary/writer_interface.go
Normal file
9
pkg/iplibrary/writer_interface.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package iplibrary
|
||||
|
||||
type WriterInterface interface {
|
||||
WriteMeta() error
|
||||
Write(ipFrom string, ipTo string, countryId int64, provinceId int64, cityId int64, townId int64, providerId int64) error
|
||||
Sum() string
|
||||
}
|
||||
190
pkg/iplibrary/writer_v2.go
Normal file
190
pkg/iplibrary/writer_v2.go
Normal file
@@ -0,0 +1,190 @@
|
||||
// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package iplibrary
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type hashWriter struct {
|
||||
rawWriter io.Writer
|
||||
hash hash.Hash
|
||||
}
|
||||
|
||||
func newHashWriter(writer io.Writer) *hashWriter {
|
||||
return &hashWriter{
|
||||
rawWriter: writer,
|
||||
hash: md5.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func (this *hashWriter) Write(p []byte) (n int, err error) {
|
||||
n, err = this.rawWriter.Write(p)
|
||||
this.hash.Write(p)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *hashWriter) Sum() string {
|
||||
return fmt.Sprintf("%x", this.hash.Sum(nil))
|
||||
}
|
||||
|
||||
type WriterV2 struct {
|
||||
writer *hashWriter
|
||||
meta *Meta
|
||||
|
||||
lastCountryId int64
|
||||
lastProvinceId int64
|
||||
lastCityId int64
|
||||
lastTownId int64
|
||||
lastProviderId int64
|
||||
}
|
||||
|
||||
func NewWriterV2(writer io.Writer, meta *Meta) *WriterV2 {
|
||||
if meta == nil {
|
||||
meta = &Meta{}
|
||||
}
|
||||
meta.Version = Version2
|
||||
meta.CreatedAt = time.Now().Unix()
|
||||
|
||||
var libWriter = &WriterV2{
|
||||
writer: newHashWriter(writer),
|
||||
meta: meta,
|
||||
}
|
||||
return libWriter
|
||||
}
|
||||
|
||||
func (this *WriterV2) WriteMeta() error {
|
||||
metaJSON, err := json.Marshal(this.meta)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = this.writer.Write(metaJSON)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = this.writer.Write([]byte("\n"))
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *WriterV2) Write(ipFrom string, ipTo string, countryId int64, provinceId int64, cityId int64, townId int64, providerId int64) error {
|
||||
// validate IP
|
||||
var fromIP = net.ParseIP(ipFrom)
|
||||
if fromIP == nil {
|
||||
return errors.New("invalid 'ipFrom': '" + ipFrom + "'")
|
||||
}
|
||||
var fromIsIPv4 = fromIP.To4() != nil
|
||||
var toIP = net.ParseIP(ipTo)
|
||||
if toIP == nil {
|
||||
return errors.New("invalid 'ipTo': " + ipTo)
|
||||
}
|
||||
var toIsIPv4 = toIP.To4() != nil
|
||||
if fromIsIPv4 != toIsIPv4 {
|
||||
return errors.New("'ipFrom(" + ipFrom + ")' and 'ipTo(" + ipTo + ")' should have the same IP version")
|
||||
}
|
||||
|
||||
var pieces = []string{}
|
||||
|
||||
// 0
|
||||
if fromIsIPv4 {
|
||||
pieces = append(pieces, "")
|
||||
} else {
|
||||
pieces = append(pieces, "6")
|
||||
}
|
||||
|
||||
// 1
|
||||
if bytes.Compare(fromIP, toIP) > 0 {
|
||||
fromIP, toIP = toIP, fromIP
|
||||
}
|
||||
|
||||
if fromIsIPv4 {
|
||||
pieces = append(pieces, string(fromIP.To4())+string(toIP.To4()))
|
||||
} else {
|
||||
pieces = append(pieces, string(fromIP.To16())+string(toIP.To16()))
|
||||
}
|
||||
|
||||
// 2
|
||||
if countryId > 0 {
|
||||
if countryId == this.lastCountryId {
|
||||
pieces = append(pieces, "+")
|
||||
} else {
|
||||
pieces = append(pieces, this.formatUint64(uint64(countryId)))
|
||||
}
|
||||
} else {
|
||||
pieces = append(pieces, "")
|
||||
}
|
||||
this.lastCountryId = countryId
|
||||
|
||||
// 3
|
||||
if provinceId > 0 {
|
||||
if provinceId == this.lastProvinceId {
|
||||
pieces = append(pieces, "+")
|
||||
} else {
|
||||
pieces = append(pieces, this.formatUint64(uint64(provinceId)))
|
||||
}
|
||||
} else {
|
||||
pieces = append(pieces, "")
|
||||
}
|
||||
this.lastProvinceId = provinceId
|
||||
|
||||
// 4
|
||||
if cityId > 0 {
|
||||
if cityId == this.lastCityId {
|
||||
pieces = append(pieces, "+")
|
||||
} else {
|
||||
pieces = append(pieces, this.formatUint64(uint64(cityId)))
|
||||
}
|
||||
} else {
|
||||
pieces = append(pieces, "")
|
||||
}
|
||||
this.lastCityId = cityId
|
||||
|
||||
// 5
|
||||
if townId > 0 {
|
||||
if townId == this.lastTownId {
|
||||
pieces = append(pieces, "+")
|
||||
} else {
|
||||
pieces = append(pieces, this.formatUint64(uint64(townId)))
|
||||
}
|
||||
} else {
|
||||
pieces = append(pieces, "")
|
||||
}
|
||||
this.lastTownId = townId
|
||||
|
||||
// 6
|
||||
if providerId > 0 {
|
||||
if providerId == this.lastProviderId {
|
||||
pieces = append(pieces, "+")
|
||||
} else {
|
||||
pieces = append(pieces, this.formatUint64(uint64(providerId)))
|
||||
}
|
||||
} else {
|
||||
pieces = append(pieces, "")
|
||||
}
|
||||
this.lastProviderId = providerId
|
||||
|
||||
_, err := this.writer.Write([]byte(strings.TrimRight(strings.Join(pieces, "|"), "|")))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = this.writer.Write([]byte("\n"))
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *WriterV2) Sum() string {
|
||||
return this.writer.Sum()
|
||||
}
|
||||
|
||||
func (this *WriterV2) formatUint64(i uint64) string {
|
||||
return strconv.FormatUint(i, 32)
|
||||
}
|
||||
@@ -1,16 +1,18 @@
|
||||
// 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 iplibrary_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewWriter(t *testing.T) {
|
||||
//write
|
||||
var buf = &bytes.Buffer{}
|
||||
var writer = iplibrary.NewWriter(buf, &iplibrary.Meta{
|
||||
var writer = iplibrary.NewWriterV1(buf, &iplibrary.Meta{
|
||||
Author: "GoEdge <https://goedge.cn>",
|
||||
})
|
||||
|
||||
@@ -39,6 +41,27 @@ func TestNewWriter(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = writer.Write("10.0.0.1", "10.0.0.2", 101, 201, 301, 401, 501)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = writer.Write("10.0.0.3", "10.0.0.4", 101, 201, 301, 401, 501)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Log(buf.String())
|
||||
t.Log("sum:", writer.Sum())
|
||||
|
||||
// read
|
||||
reader, err := iplibrary.NewReaderV2(buf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
logs.PrintAsJSON(reader.IPv4Items(), t)
|
||||
logs.PrintAsJSON(reader.IPv6Items(), t)
|
||||
|
||||
_ = reader
|
||||
}
|
||||
78
pkg/iputils/cidr.go
Normal file
78
pkg/iputils/cidr.go
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package iputils
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
type CIDR struct {
|
||||
rawIPNet *net.IPNet
|
||||
}
|
||||
|
||||
func ParseCIDR(s string) (*CIDR, error) {
|
||||
_, ipNet, err := net.ParseCIDR(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &CIDR{
|
||||
rawIPNet: ipNet,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (this *CIDR) IsIPv4() bool {
|
||||
return this.rawIPNet.IP.To4() != nil
|
||||
}
|
||||
|
||||
func (this *CIDR) IsIPv6() bool {
|
||||
return this.rawIPNet.IP.To4() == nil
|
||||
}
|
||||
|
||||
func (this *CIDR) From() net.IP {
|
||||
return this.rawIPNet.IP
|
||||
}
|
||||
|
||||
func (this *CIDR) To() net.IP {
|
||||
var start = this.rawIPNet.IP.To4()
|
||||
if start != nil {
|
||||
return bitsOr(bitsAnd(start, this.rawIPNet.Mask), bitsXor(this.rawIPNet.Mask[:4], []byte{0xff, 0xff, 0xff, 0xff}))
|
||||
}
|
||||
|
||||
start = this.rawIPNet.IP.To16()
|
||||
return bitsOr(bitsAnd(start, this.rawIPNet.Mask), bitsXor(this.rawIPNet.Mask[:16], []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}))
|
||||
}
|
||||
|
||||
func (this *CIDR) Contains(ip net.IP) bool {
|
||||
return this.rawIPNet.Contains(ip)
|
||||
}
|
||||
|
||||
func (this *CIDR) String() string {
|
||||
return this.rawIPNet.String()
|
||||
}
|
||||
|
||||
func bitsAnd(x []byte, y []byte) []byte {
|
||||
var l = len(x)
|
||||
var z = make([]byte, l)
|
||||
for i := 0; i < l; i++ {
|
||||
z[i] = x[i] & y[i]
|
||||
}
|
||||
return z
|
||||
}
|
||||
|
||||
func bitsOr(x []byte, y []byte) []byte {
|
||||
var l = len(x)
|
||||
var z = make([]byte, l)
|
||||
for i := 0; i < l; i++ {
|
||||
z[i] = x[i] | y[i]
|
||||
}
|
||||
return z
|
||||
}
|
||||
|
||||
func bitsXor(x []byte, y []byte) []byte {
|
||||
var l = len(x)
|
||||
var z = make([]byte, l)
|
||||
for i := 0; i < l; i++ {
|
||||
z[i] = x[i] ^ y[i]
|
||||
}
|
||||
return z
|
||||
}
|
||||
21
pkg/iputils/cidr_test.go
Normal file
21
pkg/iputils/cidr_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package iputils_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseCIDR(t *testing.T) {
|
||||
for _, cidrString := range []string{
|
||||
"192.168.2.100/24",
|
||||
"2607:5300:203:afac::/125",
|
||||
} {
|
||||
cidr, err := iputils.ParseCIDR(cidrString)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(cidr, "=> [", cidr.From(), "-", cidr.To(), "]")
|
||||
}
|
||||
}
|
||||
260
pkg/iputils/ip.go
Normal file
260
pkg/iputils/ip.go
Normal file
@@ -0,0 +1,260 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package iputils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"math"
|
||||
"math/big"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type IP struct {
|
||||
rawIP net.IP
|
||||
bigInt *big.Int
|
||||
}
|
||||
|
||||
var uint32BigInt = big.NewInt(int64(math.MaxUint32))
|
||||
|
||||
func ParseIP(ipString string) IP {
|
||||
return NewIP(net.ParseIP(ipString))
|
||||
}
|
||||
|
||||
func NewIP(rawIP net.IP) IP {
|
||||
if rawIP == nil {
|
||||
return IP{}
|
||||
}
|
||||
|
||||
if rawIP.To4() == nil {
|
||||
var bigInt = big.NewInt(0)
|
||||
bigInt.SetBytes(rawIP.To16())
|
||||
bigInt.Add(bigInt, uint32BigInt)
|
||||
return IP{
|
||||
rawIP: rawIP,
|
||||
bigInt: bigInt,
|
||||
}
|
||||
}
|
||||
|
||||
return IP{
|
||||
rawIP: rawIP,
|
||||
}
|
||||
}
|
||||
|
||||
func IsIPv4(ipString string) bool {
|
||||
var rawIP = net.ParseIP(ipString)
|
||||
return rawIP != nil && rawIP.To4() != nil
|
||||
}
|
||||
|
||||
func IsIPv6(ipString string) bool {
|
||||
var rawIP = net.ParseIP(ipString)
|
||||
return rawIP != nil && rawIP.To4() == nil && rawIP.To16() != nil
|
||||
}
|
||||
|
||||
func IsSameVersion(ip1 string, ip2 string) bool {
|
||||
return IsIPv4(ip1) == IsIPv4(ip2)
|
||||
}
|
||||
|
||||
func IsValid(ipString string) bool {
|
||||
return net.ParseIP(ipString) != nil
|
||||
}
|
||||
|
||||
func CompareLong(i1 string, i2 string) int {
|
||||
if i1 == "" {
|
||||
i1 = "0"
|
||||
}
|
||||
if i2 == "" {
|
||||
i2 = "0"
|
||||
}
|
||||
|
||||
var l = len(i1) - len(i2)
|
||||
if l > 0 {
|
||||
return 1
|
||||
}
|
||||
if l < 0 {
|
||||
return -1
|
||||
}
|
||||
|
||||
if i1 > i2 {
|
||||
return 1
|
||||
}
|
||||
if i1 < i2 {
|
||||
return -1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
var bigIntPool = &sync.Pool{
|
||||
New: func() any {
|
||||
return big.NewInt(0)
|
||||
},
|
||||
}
|
||||
|
||||
func ToLong(ip string) string {
|
||||
var rawIP = net.ParseIP(ip)
|
||||
if rawIP == nil {
|
||||
return "0"
|
||||
}
|
||||
|
||||
var i4 = rawIP.To4()
|
||||
if i4 != nil {
|
||||
return strconv.FormatUint(uint64(binary.BigEndian.Uint32(i4)), 10)
|
||||
}
|
||||
|
||||
var bigInt = bigIntPool.Get().(*big.Int)
|
||||
bigInt.SetBytes(rawIP.To16())
|
||||
bigInt.Add(bigInt, uint32BigInt)
|
||||
var s = bigInt.String()
|
||||
bigIntPool.Put(bigInt)
|
||||
return s
|
||||
}
|
||||
|
||||
func ToHex(ip string) string {
|
||||
if len(ip) == 0 {
|
||||
return ""
|
||||
}
|
||||
var rawIP = net.ParseIP(ip)
|
||||
if rawIP == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
if rawIP.To4() != nil {
|
||||
return hex.EncodeToString(rawIP.To4())
|
||||
}
|
||||
|
||||
return hex.EncodeToString(rawIP.To16())
|
||||
}
|
||||
|
||||
func ToBytes(ip string) []byte {
|
||||
if len(ip) == 0 {
|
||||
return nil
|
||||
}
|
||||
var rawIP = net.ParseIP(ip)
|
||||
if rawIP == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if rawIP.To4() != nil {
|
||||
return rawIP.To4()
|
||||
}
|
||||
|
||||
return rawIP.To16()
|
||||
}
|
||||
|
||||
func CompareBytes(b1 []byte, b2 []byte) int {
|
||||
var l1 = len(b1)
|
||||
var l2 = len(b2)
|
||||
if l1 < l2 {
|
||||
return -1
|
||||
}
|
||||
if l1 > l2 {
|
||||
return 1
|
||||
}
|
||||
return bytes.Compare(b1, b2)
|
||||
}
|
||||
|
||||
func CompareIP(ip1 string, ip2 string) int {
|
||||
return CompareBytes(ToBytes(ip1), ToBytes(ip2))
|
||||
}
|
||||
|
||||
func ToLittleLong(ip string) string {
|
||||
var rawIP = net.ParseIP(ip)
|
||||
if rawIP == nil {
|
||||
return "0"
|
||||
}
|
||||
|
||||
var i4 = rawIP.To4()
|
||||
if i4 != nil {
|
||||
return strconv.FormatUint(uint64(binary.BigEndian.Uint32(i4)), 10)
|
||||
}
|
||||
|
||||
var bigInt = bigIntPool.Get().(*big.Int)
|
||||
bigInt.SetBytes(rawIP.To16())
|
||||
var s = bigInt.String()
|
||||
bigIntPool.Put(bigInt)
|
||||
return s
|
||||
}
|
||||
|
||||
func (this IP) ToLong() string {
|
||||
if this.rawIP == nil {
|
||||
return "0"
|
||||
}
|
||||
if this.bigInt != nil {
|
||||
return this.bigInt.String()
|
||||
}
|
||||
return strconv.FormatUint(uint64(binary.BigEndian.Uint32(this.rawIP.To4())), 10)
|
||||
}
|
||||
|
||||
func (this IP) Mod(d int) int {
|
||||
if this.rawIP == nil {
|
||||
return 0
|
||||
}
|
||||
if this.bigInt != nil {
|
||||
return int(this.bigInt.Mod(this.bigInt, big.NewInt(int64(d))).Int64())
|
||||
}
|
||||
return int(binary.BigEndian.Uint32(this.rawIP.To4()) % uint32(d))
|
||||
}
|
||||
|
||||
func (this IP) Compare(anotherIP IP) int {
|
||||
if this.rawIP == nil {
|
||||
if anotherIP.rawIP == nil {
|
||||
return 0
|
||||
}
|
||||
return -1
|
||||
} else if anotherIP.rawIP == nil {
|
||||
return 1
|
||||
}
|
||||
|
||||
if this.bigInt != nil {
|
||||
if anotherIP.bigInt == nil {
|
||||
return 1 // IPv6 always greater than IPv4
|
||||
}
|
||||
return this.bigInt.Cmp(anotherIP.bigInt)
|
||||
}
|
||||
|
||||
if anotherIP.bigInt == nil {
|
||||
var i1 = binary.BigEndian.Uint32(this.rawIP.To4())
|
||||
var i2 = binary.BigEndian.Uint32(anotherIP.rawIP.To4())
|
||||
|
||||
if i1 > i2 {
|
||||
return 1
|
||||
}
|
||||
if i1 < i2 {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
func (this IP) Between(ipFrom IP, ipTo IP) bool {
|
||||
return ipFrom.Compare(this) <= 0 && ipTo.Compare(this) >= 0
|
||||
}
|
||||
|
||||
func (this IP) IsIPv4() bool {
|
||||
return this.rawIP != nil && this.bigInt == nil
|
||||
}
|
||||
|
||||
func (this IP) IsIPv6() bool {
|
||||
return this.bigInt != nil
|
||||
}
|
||||
|
||||
func (this IP) IsValid() bool {
|
||||
return this.rawIP != nil
|
||||
}
|
||||
|
||||
func (this IP) Raw() net.IP {
|
||||
return this.rawIP
|
||||
}
|
||||
|
||||
func (this IP) String() string {
|
||||
if this.rawIP == nil {
|
||||
return ""
|
||||
}
|
||||
return this.rawIP.String()
|
||||
}
|
||||
258
pkg/iputils/ip_test.go
Normal file
258
pkg/iputils/ip_test.go
Normal file
@@ -0,0 +1,258 @@
|
||||
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package iputils_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/iputils"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIP_ParseIP(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
|
||||
{
|
||||
var i = iputils.ParseIP("127.0.0.1")
|
||||
a.IsTrue(i.IsIPv4())
|
||||
a.IsFalse(i.IsIPv6())
|
||||
a.IsTrue(i.IsValid())
|
||||
a.IsTrue(iputils.IsIPv4("127.0.0.1"))
|
||||
a.IsFalse(iputils.IsIPv6("127.0.0.1"))
|
||||
t.Log(i.String(), i.ToLong())
|
||||
t.Log("raw:", i.Raw())
|
||||
a.IsTrue(iputils.IsValid("127.0.0.1"))
|
||||
}
|
||||
|
||||
{
|
||||
var i = iputils.ParseIP("0.0.0.1")
|
||||
a.IsTrue(i.IsIPv4())
|
||||
a.IsFalse(i.IsIPv6())
|
||||
t.Log(i.String(), i.ToLong())
|
||||
}
|
||||
|
||||
for j := 0; j < 3; j++ /** repeat test **/ {
|
||||
var i = iputils.ParseIP("::1")
|
||||
a.IsFalse(i.IsIPv4())
|
||||
a.IsTrue(i.IsIPv6())
|
||||
a.IsTrue(i.IsValid())
|
||||
t.Log(i.String(), i.ToLong())
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
var i = iputils.ParseIP("2001:db8:0:1::1:101")
|
||||
t.Log(i.String(), i.ToLong())
|
||||
a.IsFalse(i.IsIPv4())
|
||||
a.IsTrue(i.IsIPv6())
|
||||
a.IsFalse(iputils.IsIPv4("2001:db8:0:1::1:101"))
|
||||
a.IsTrue(iputils.IsIPv6("2001:db8:0:1::1:101"))
|
||||
a.IsTrue(i.IsValid())
|
||||
}
|
||||
|
||||
{
|
||||
var i = iputils.ParseIP("2001:db8:0:1::1:102")
|
||||
t.Log(i.String(), i.ToLong())
|
||||
a.IsFalse(i.IsIPv4())
|
||||
a.IsTrue(i.IsIPv6())
|
||||
a.IsTrue(i.IsValid())
|
||||
}
|
||||
|
||||
{
|
||||
var i = iputils.ParseIP("2001:db8:0:1::2:101")
|
||||
t.Log(i.String(), i.ToLong())
|
||||
a.IsFalse(i.IsIPv4())
|
||||
a.IsTrue(i.IsIPv6())
|
||||
a.IsTrue(i.IsValid())
|
||||
a.IsTrue(iputils.IsValid("2001:db8:0:1::2:101"))
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var i = iputils.ParseIP("WRONG IP")
|
||||
t.Log(i.String(), i.ToLong())
|
||||
a.IsFalse(i.IsIPv4())
|
||||
a.IsFalse(i.IsIPv6())
|
||||
a.IsFalse(i.IsValid())
|
||||
a.IsFalse(iputils.IsValid("WRONG IP"))
|
||||
a.IsFalse(iputils.IsIPv4("WRONG IP"))
|
||||
a.IsFalse(iputils.IsIPv6("WRONG IP"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestIP_Mod(t *testing.T) {
|
||||
for _, ip := range []string{
|
||||
"127.0.0.1",
|
||||
"::1",
|
||||
"2001:db8:0:1::1:101",
|
||||
"2001:db8:0:1::1:102",
|
||||
"WRONG IP",
|
||||
} {
|
||||
var i = iputils.ParseIP(ip)
|
||||
t.Log(ip, "=>", i.ToLong(), "=>", i.Mod(5))
|
||||
}
|
||||
}
|
||||
|
||||
func TestIP_Compare(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("127.0.0.1")
|
||||
var i2 = iputils.ParseIP("127.0.0.1")
|
||||
a.IsTrue(i1.Compare(i2) == 0)
|
||||
}
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("127.0.0.1")
|
||||
var i2 = iputils.ParseIP("127.0.0.2")
|
||||
a.IsTrue(i1.Compare(i2) == -1)
|
||||
}
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("127.0.0.2")
|
||||
var i2 = iputils.ParseIP("127.0.0.1")
|
||||
a.IsTrue(i1.Compare(i2) == 1)
|
||||
}
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("2001:db8:0:1::101")
|
||||
var i2 = iputils.ParseIP("127.0.0.1")
|
||||
a.IsTrue(i1.Compare(i2) == 1)
|
||||
}
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("127.0.0.1")
|
||||
var i2 = iputils.ParseIP("2001:db8:0:1::101")
|
||||
a.IsTrue(i1.Compare(i2) == -1)
|
||||
}
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("2001:db8:0:1::101")
|
||||
var i2 = iputils.ParseIP("2001:db8:0:1::101")
|
||||
a.IsTrue(i1.Compare(i2) == 0)
|
||||
}
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("2001:db8:0:1::101")
|
||||
var i2 = iputils.ParseIP("2001:db8:0:1::102")
|
||||
a.IsTrue(i1.Compare(i2) == -1)
|
||||
}
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("2001:db8:0:1::102")
|
||||
var i2 = iputils.ParseIP("2001:db8:0:1::101")
|
||||
a.IsTrue(i1.Compare(i2) == 1)
|
||||
}
|
||||
|
||||
{
|
||||
var i1 = iputils.ParseIP("2001:db8:0:1::2:100")
|
||||
var i2 = iputils.ParseIP("2001:db8:0:1::1:101")
|
||||
a.IsTrue(i1.Compare(i2) == 1)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIP_Between(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
a.IsTrue(iputils.ParseIP("127.0.0.2").Between(iputils.ParseIP("127.0.0.1"), iputils.ParseIP("127.0.0.3")))
|
||||
a.IsTrue(iputils.ParseIP("127.0.0.1").Between(iputils.ParseIP("127.0.0.1"), iputils.ParseIP("127.0.0.3")))
|
||||
a.IsFalse(iputils.ParseIP("127.0.0.2").Between(iputils.ParseIP("127.0.0.3"), iputils.ParseIP("127.0.0.4")))
|
||||
a.IsFalse(iputils.ParseIP("127.0.0.5").Between(iputils.ParseIP("127.0.0.3"), iputils.ParseIP("127.0.0.4")))
|
||||
a.IsFalse(iputils.ParseIP("127.0.0.2").Between(iputils.ParseIP("127.0.0.3"), iputils.ParseIP("127.0.0.1")))
|
||||
}
|
||||
|
||||
func TestIP_ToLong(t *testing.T) {
|
||||
for _, ip := range []string{
|
||||
"127.0.0.1",
|
||||
"192.168.1.100",
|
||||
"::1",
|
||||
"fd00:6868:6868:0:10ac:d056:3bf6:7452",
|
||||
"fd00:6868:6868:0:10ac:d056:3bf6:7453",
|
||||
"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||
"2001:db8:0:1::101",
|
||||
"2001:db8:0:2::101",
|
||||
"wrong ip",
|
||||
} {
|
||||
var goIP = iputils.ParseIP(ip)
|
||||
t.Log(ip, "=>", "\n", goIP.String(), "\n", "=>", "\n", "long1:", goIP.ToLong(), "\n", "long2:", iputils.ToLong(ip), "\n", "little long:", iputils.ToLittleLong(ip))
|
||||
}
|
||||
}
|
||||
|
||||
func TestIP_CompareLong(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
a.IsTrue(iputils.CompareLong("1", "2") == -1)
|
||||
a.IsTrue(iputils.CompareLong("11", "2") == 1)
|
||||
a.IsTrue(iputils.CompareLong("11", "22") == -1)
|
||||
a.IsTrue(iputils.CompareLong("22", "101") == -1)
|
||||
a.IsTrue(iputils.CompareLong("33", "22") == 1)
|
||||
a.IsTrue(iputils.CompareLong("101", "22") == 1)
|
||||
a.IsTrue(iputils.CompareLong("22", "22") == 0)
|
||||
}
|
||||
|
||||
func TestIP_Memory(t *testing.T) {
|
||||
var list []iputils.IP
|
||||
|
||||
var stat1 = &runtime.MemStats{}
|
||||
runtime.ReadMemStats(stat1)
|
||||
|
||||
for i := 0; i < 1_000_000; i++ {
|
||||
list = append(list, iputils.ParseIP("fd00:6868:6868:0:10ac:d056:3bf6:7452"))
|
||||
}
|
||||
|
||||
//runtime.GC()
|
||||
|
||||
var stat2 = &runtime.MemStats{}
|
||||
runtime.ReadMemStats(stat2)
|
||||
|
||||
t.Log((stat2.Alloc-stat1.Alloc)>>10, "KB", (stat2.HeapInuse-stat1.HeapInuse)>>10, "KB")
|
||||
|
||||
// hold the memory
|
||||
for _, v := range list {
|
||||
_ = v
|
||||
}
|
||||
}
|
||||
|
||||
func TestToBytes(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
a.IsTrue(len(iputils.ToBytes("a")) == 0)
|
||||
a.IsTrue(len(iputils.ToBytes("192.168.1.100")) == 4)
|
||||
a.IsTrue(len(iputils.ToBytes("::1")) == 16)
|
||||
}
|
||||
|
||||
func TestCompareIP(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
a.IsTrue(iputils.CompareIP("a", "b") == 0)
|
||||
a.IsTrue(iputils.CompareIP("192.168.1.100", "192.168.1.1") > 0)
|
||||
a.IsTrue(iputils.CompareIP("192.168.1.100", "10.168.1.1") > 0)
|
||||
a.IsTrue(iputils.CompareIP("192.168.1.100", "192.168.2.1") < 0)
|
||||
a.IsTrue(iputils.CompareIP("192.168.1.100", "::1") < 0)
|
||||
a.IsTrue(iputils.CompareIP("::1", "192.168.1.100") > 0)
|
||||
a.IsTrue(iputils.CompareIP("192.168.1.100", "192.168.1.100") == 0)
|
||||
}
|
||||
|
||||
func TestIsSameVersion(t *testing.T) {
|
||||
var a = assert.NewAssertion(t)
|
||||
a.IsTrue(iputils.IsSameVersion("192.168.1.1", "10.0.0.1"))
|
||||
a.IsTrue(iputils.IsSameVersion("::1", "::5"))
|
||||
a.IsFalse(iputils.IsSameVersion("192.168.1.1", "::5"))
|
||||
}
|
||||
|
||||
func BenchmarkParse(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
iputils.ParseIP("fd00:6868:6868:0:10ac:d056:3bf6:7452")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkToLongV4(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
iputils.ToLong("192.168.2.100")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkToLongV6(b *testing.B) {
|
||||
runtime.GOMAXPROCS(1)
|
||||
b.ReportAllocs()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
iputils.ToLong("fd00:6868:6868:0:10ac:d056:3bf6:7452")
|
||||
}
|
||||
}
|
||||
@@ -266,9 +266,12 @@ const (
|
||||
Node_LogInstallNodeRemotely langs.MessageCode = "node@log_install_node_remotely" // 远程安装节点 %d
|
||||
Node_LogStartNodeRemotely langs.MessageCode = "node@log_start_node_remotely" // 远程启动节点 %d
|
||||
Node_LogStopNodeRemotely langs.MessageCode = "node@log_stop_node_remotely" // 远程停止节点 %d
|
||||
Node_LogUninstallNodeRemotely langs.MessageCode = "node@log_uninstall_node_remotely" // 远程卸载节点 %d
|
||||
Node_LogUpNode langs.MessageCode = "node@log_up_node" // 手动上线节点 %d
|
||||
Node_LogUpdateNode langs.MessageCode = "node@log_update_node" // 修改节点 %d 基本信息
|
||||
Node_LogUpdateNodeInstallationStatus langs.MessageCode = "node@log_update_node_installation_status" // 修改节点安装状态 %d
|
||||
Node_LogUpdateNodeOff langs.MessageCode = "node@log_update_node_off" // 停用节点 %d
|
||||
Node_LogUpdateNodeOn langs.MessageCode = "node@log_update_node_on" // 启用节点 %d
|
||||
Node_LogUpgradeNodeRemotely langs.MessageCode = "node@log_upgrade_node_remotely" // 远程升级节点 %d
|
||||
Node_UngroupedLabel langs.MessageCode = "node@ungrouped_label" // 未分组
|
||||
NodeAction_LogCopyNodeActionsToCluster langs.MessageCode = "node_action@log_copy_node_actions_to_cluster" // 复制节点 %d 调度动作到集群
|
||||
@@ -449,6 +452,11 @@ const (
|
||||
Plan_LogDeletePlan langs.MessageCode = "plan@log_delete_plan" // 删除套餐 %d
|
||||
Plan_LogSortPlans langs.MessageCode = "plan@log_sort_plans" // 对套餐进行排序
|
||||
Plan_LogUpdatePlan langs.MessageCode = "plan@log_update_plan" // 修改套餐 %d
|
||||
Post_LogCreatePost langs.MessageCode = "post@log_create_post" // 创建文章 %d
|
||||
Post_LogDeletePost langs.MessageCode = "post@log_delete_post" // 删除文章 %d
|
||||
Post_LogPublishPost langs.MessageCode = "post@log_publish_post" // 发布文章 %d
|
||||
Post_LogUpdatePost langs.MessageCode = "post@log_update_post" // 修改文章 %d
|
||||
Post_ProductGlobal langs.MessageCode = "post@product_global" // 全站
|
||||
RegionCity_LogAddRegionCityCode langs.MessageCode = "region_city@log_add_region_city_code" // 添加城市/市 %d 别名 %s
|
||||
RegionCity_LogUpdateRegionCityCustom langs.MessageCode = "region_city@log_update_region_city_custom" // 定制城市 %d 信息
|
||||
RegionCountry_LogAddRegionCountryCode langs.MessageCode = "region_country@log_add_region_country_code" // 添加国家/地区 %d 别名 %s
|
||||
@@ -486,6 +494,7 @@ const (
|
||||
Server_LogCopyServerConfigs langs.MessageCode = "server@log_copy_server_configs" // 从网站 %d 中同步配置 %s
|
||||
Server_LogCreateServer langs.MessageCode = "server@log_create_server" // 创建网站 %d
|
||||
Server_LogDeleteServer langs.MessageCode = "server@log_delete_server" // 删除网站 %d
|
||||
Server_LogDeleteServers langs.MessageCode = "server@log_delete_servers" // 批量删除网站
|
||||
Server_LogDisableServer langs.MessageCode = "server@log_disable_server" // 停用网站 %d
|
||||
Server_LogEnableServer langs.MessageCode = "server@log_enable_server" // 启用网站 %d
|
||||
Server_LogSubmitAuditingServer langs.MessageCode = "server@log_submit_auditing_server" // 提交网站 %d 域名审核
|
||||
@@ -516,6 +525,7 @@ const (
|
||||
Server_MenuSettingHTTPProxy langs.MessageCode = "server@menu_setting_http_proxy" // HTTP代理
|
||||
Server_MenuSettingHTTPS langs.MessageCode = "server@menu_setting_https" // HTTPS
|
||||
Server_MenuSettingLocations langs.MessageCode = "server@menu_setting_locations" // 路由规则
|
||||
Server_MenuSettingMultimedia langs.MessageCode = "server@menu_setting_multimedia" // 音视频设置
|
||||
Server_MenuSettingOptimization langs.MessageCode = "server@menu_setting_optimization" // 页面优化
|
||||
Server_MenuSettingOrigins langs.MessageCode = "server@menu_setting_origins" // 源站
|
||||
Server_MenuSettingOthers langs.MessageCode = "server@menu_setting_others" // 其他设置
|
||||
@@ -535,7 +545,6 @@ const (
|
||||
Server_MenuSettingUAM langs.MessageCode = "server@menu_setting_uam" // 5秒盾
|
||||
Server_MenuSettingUDP langs.MessageCode = "server@menu_setting_udp" // UDP
|
||||
Server_MenuSettingUDPProxy langs.MessageCode = "server@menu_setting_udp_proxy" // UDP代理
|
||||
Server_MenuSettingUnix langs.MessageCode = "server@menu_setting_unix" // Unix
|
||||
Server_MenuSettingUserAgents langs.MessageCode = "server@menu_setting_user_agents" // UA名单
|
||||
Server_MenuSettingWAF langs.MessageCode = "server@menu_setting_waf" // WAF
|
||||
Server_MenuSettingWebP langs.MessageCode = "server@menu_setting_webp" // WebP
|
||||
@@ -581,6 +590,7 @@ const (
|
||||
ServerGroup_LogDeleteServerGroup langs.MessageCode = "server_group@log_delete_server_group" // 删除网站分组 %d
|
||||
ServerGroup_LogSortServerGroups langs.MessageCode = "server_group@log_sort_server_groups" // 修改网站分组排序
|
||||
ServerGroup_LogUpdateServerGroup langs.MessageCode = "server_group@log_update_server_group" // 修改网站分组 %d
|
||||
ServerHls_LogUpdateHls langs.MessageCode = "server_hls@log_update_hls" // 修改Web %d 的HLS设置
|
||||
ServerHTTP3_LogUpdateClusterHTTP3Policy langs.MessageCode = "server_http3@log_update_cluster_http3_policy" // 修改集群 %d 的HTTP3策略设置
|
||||
ServerHTTP_LogUpdateHTTPSettings langs.MessageCode = "server_http@log_update_http_settings" // 修改网站 %d 的HTTP设置
|
||||
ServerHTTPHeader_LogCreateDeletingHeader langs.MessageCode = "server_http_header@log_create_deleting_header" // 添加删除的报头 HeaderPolicyId: %d, Name: %s
|
||||
@@ -597,6 +607,7 @@ const (
|
||||
ServerOrigin_LogCreateOrigin langs.MessageCode = "server_origin@log_create_origin" // 创建源站 %d
|
||||
ServerOrigin_LogDeleteOrigin langs.MessageCode = "server_origin@log_delete_origin" // 删除源站 %d
|
||||
ServerOrigin_LogUpdateOrigin langs.MessageCode = "server_origin@log_update_origin" // 修改源站 %d
|
||||
ServerOrigin_LogUpdateOriginIsOn langs.MessageCode = "server_origin@log_update_origin_is_on" // 修改源站 %d 启用状态
|
||||
ServerPage_LogCreatePage langs.MessageCode = "server_page@log_create_page" // 创建自定义页面 %d
|
||||
ServerPage_LogUpdateClusterPages langs.MessageCode = "server_page@log_update_cluster_pages" // 修改集群 %d 自定义页面策略
|
||||
ServerPage_LogUpdatePage langs.MessageCode = "server_page@log_update_page" // 修改自定义页面 %d
|
||||
|
||||
@@ -267,9 +267,12 @@ func init() {
|
||||
"node@log_install_node_remotely": "",
|
||||
"node@log_start_node_remotely": "",
|
||||
"node@log_stop_node_remotely": "",
|
||||
"node@log_uninstall_node_remotely": "",
|
||||
"node@log_up_node": "",
|
||||
"node@log_update_node": "",
|
||||
"node@log_update_node_installation_status": "",
|
||||
"node@log_update_node_off": "",
|
||||
"node@log_update_node_on": "",
|
||||
"node@log_upgrade_node_remotely": "",
|
||||
"node@ungrouped_label": "",
|
||||
"node_action@log_copy_node_actions_to_cluster": "",
|
||||
@@ -450,6 +453,11 @@ func init() {
|
||||
"plan@log_delete_plan": "",
|
||||
"plan@log_sort_plans": "",
|
||||
"plan@log_update_plan": "",
|
||||
"post@log_create_post": "",
|
||||
"post@log_delete_post": "",
|
||||
"post@log_publish_post": "",
|
||||
"post@log_update_post": "",
|
||||
"post@product_global": "",
|
||||
"region_city@log_add_region_city_code": "",
|
||||
"region_city@log_update_region_city_custom": "",
|
||||
"region_country@log_add_region_country_code": "",
|
||||
@@ -487,6 +495,7 @@ func init() {
|
||||
"server@log_copy_server_configs": "从网站 %d 中同步配置 %s",
|
||||
"server@log_create_server": "创建网站 %d",
|
||||
"server@log_delete_server": "删除网站 %d",
|
||||
"server@log_delete_servers": "",
|
||||
"server@log_disable_server": "停用网站 %d",
|
||||
"server@log_enable_server": "启用网站 %d",
|
||||
"server@log_submit_auditing_server": "提交网站 %d 域名审核",
|
||||
@@ -517,6 +526,7 @@ func init() {
|
||||
"server@menu_setting_http_proxy": "HTTP Reverse Proxy",
|
||||
"server@menu_setting_https": "HTTPS",
|
||||
"server@menu_setting_locations": "Locations",
|
||||
"server@menu_setting_multimedia": "Audios & Videos",
|
||||
"server@menu_setting_optimization": "Content Optimizations",
|
||||
"server@menu_setting_origins": "Origin Sites",
|
||||
"server@menu_setting_others": "Others",
|
||||
@@ -536,7 +546,6 @@ func init() {
|
||||
"server@menu_setting_uam": "UAM",
|
||||
"server@menu_setting_udp": "UDP",
|
||||
"server@menu_setting_udp_proxy": "UDP Reverse Proxy",
|
||||
"server@menu_setting_unix": "Unix",
|
||||
"server@menu_setting_user_agents": "UA List",
|
||||
"server@menu_setting_waf": "WAF",
|
||||
"server@menu_setting_webp": "WebP",
|
||||
@@ -582,6 +591,7 @@ func init() {
|
||||
"server_group@log_delete_server_group": "",
|
||||
"server_group@log_sort_server_groups": "",
|
||||
"server_group@log_update_server_group": "",
|
||||
"server_hls@log_update_hls": "",
|
||||
"server_http3@log_update_cluster_http3_policy": "",
|
||||
"server_http@log_update_http_settings": "",
|
||||
"server_http_header@log_create_deleting_header": "",
|
||||
@@ -598,6 +608,7 @@ func init() {
|
||||
"server_origin@log_create_origin": "",
|
||||
"server_origin@log_delete_origin": "",
|
||||
"server_origin@log_update_origin": "",
|
||||
"server_origin@log_update_origin_is_on": "",
|
||||
"server_page@log_create_page": "",
|
||||
"server_page@log_update_cluster_pages": "",
|
||||
"server_page@log_update_page": "",
|
||||
|
||||
@@ -267,9 +267,12 @@ func init() {
|
||||
"node@log_install_node_remotely": "远程安装节点 %d",
|
||||
"node@log_start_node_remotely": "远程启动节点 %d",
|
||||
"node@log_stop_node_remotely": "远程停止节点 %d",
|
||||
"node@log_uninstall_node_remotely": "远程卸载节点 %d",
|
||||
"node@log_up_node": "手动上线节点 %d",
|
||||
"node@log_update_node": "修改节点 %d 基本信息",
|
||||
"node@log_update_node_installation_status": "修改节点安装状态 %d",
|
||||
"node@log_update_node_off": "停用节点 %d",
|
||||
"node@log_update_node_on": "启用节点 %d",
|
||||
"node@log_upgrade_node_remotely": "远程升级节点 %d",
|
||||
"node@ungrouped_label": "未分组",
|
||||
"node_action@log_copy_node_actions_to_cluster": "复制节点 %d 调度动作到集群",
|
||||
@@ -450,6 +453,11 @@ func init() {
|
||||
"plan@log_delete_plan": "删除套餐 %d",
|
||||
"plan@log_sort_plans": "对套餐进行排序",
|
||||
"plan@log_update_plan": "修改套餐 %d",
|
||||
"post@log_create_post": "创建文章 %d",
|
||||
"post@log_delete_post": "删除文章 %d",
|
||||
"post@log_publish_post": "发布文章 %d",
|
||||
"post@log_update_post": "修改文章 %d",
|
||||
"post@product_global": "全站",
|
||||
"region_city@log_add_region_city_code": "添加城市/市 %d 别名 %s",
|
||||
"region_city@log_update_region_city_custom": "定制城市 %d 信息",
|
||||
"region_country@log_add_region_country_code": "添加国家/地区 %d 别名 %s",
|
||||
@@ -487,6 +495,7 @@ func init() {
|
||||
"server@log_copy_server_configs": "从网站 %d 中同步配置 %s",
|
||||
"server@log_create_server": "创建网站 %d",
|
||||
"server@log_delete_server": "删除网站 %d",
|
||||
"server@log_delete_servers": "批量删除网站",
|
||||
"server@log_disable_server": "停用网站 %d",
|
||||
"server@log_enable_server": "启用网站 %d",
|
||||
"server@log_submit_auditing_server": "提交网站 %d 域名审核",
|
||||
@@ -517,6 +526,7 @@ func init() {
|
||||
"server@menu_setting_http_proxy": "HTTP代理",
|
||||
"server@menu_setting_https": "HTTPS",
|
||||
"server@menu_setting_locations": "路由规则",
|
||||
"server@menu_setting_multimedia": "音视频设置",
|
||||
"server@menu_setting_optimization": "页面优化",
|
||||
"server@menu_setting_origins": "源站",
|
||||
"server@menu_setting_others": "其他设置",
|
||||
@@ -536,7 +546,6 @@ func init() {
|
||||
"server@menu_setting_uam": "5秒盾",
|
||||
"server@menu_setting_udp": "UDP",
|
||||
"server@menu_setting_udp_proxy": "UDP代理",
|
||||
"server@menu_setting_unix": "Unix",
|
||||
"server@menu_setting_user_agents": "UA名单",
|
||||
"server@menu_setting_waf": "WAF",
|
||||
"server@menu_setting_webp": "WebP",
|
||||
@@ -582,6 +591,7 @@ func init() {
|
||||
"server_group@log_delete_server_group": "删除网站分组 %d",
|
||||
"server_group@log_sort_server_groups": "修改网站分组排序",
|
||||
"server_group@log_update_server_group": "修改网站分组 %d",
|
||||
"server_hls@log_update_hls": "修改Web %d 的HLS设置",
|
||||
"server_http3@log_update_cluster_http3_policy": "修改集群 %d 的HTTP3策略设置",
|
||||
"server_http@log_update_http_settings": "修改网站 %d 的HTTP设置",
|
||||
"server_http_header@log_create_deleting_header": "添加删除的报头 HeaderPolicyId: %d, Name: %s",
|
||||
@@ -598,6 +608,7 @@ func init() {
|
||||
"server_origin@log_create_origin": "创建源站 %d",
|
||||
"server_origin@log_delete_origin": "删除源站 %d",
|
||||
"server_origin@log_update_origin": "修改源站 %d",
|
||||
"server_origin@log_update_origin_is_on": "修改源站 %d 启用状态",
|
||||
"server_page@log_create_page": "创建自定义页面 %d",
|
||||
"server_page@log_update_cluster_pages": "修改集群 %d 自定义页面策略",
|
||||
"server_page@log_update_page": "修改自定义页面 %d",
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
"menu_setting_others": "Others",
|
||||
"menu_setting_tcp": "TCP",
|
||||
"menu_setting_tls": "TLS",
|
||||
"menu_setting_unix": "Unix",
|
||||
"menu_setting_udp": "UDP",
|
||||
"menu_setting_delete": "Delete",
|
||||
"menu_setting_http_proxy": "HTTP Reverse Proxy", // in site groups
|
||||
@@ -56,6 +55,7 @@
|
||||
"menu_setting_udp_proxy": "UDP Reverse Proxy", // in site groups
|
||||
"menu_setting_plan": "Plan",
|
||||
"menu_setting_group": "Group",
|
||||
"menu_setting_multimedia": "Audios & Videos",
|
||||
|
||||
"menu_setting_uam": "UAM",
|
||||
"menu_setting_cc": "CC Protection",
|
||||
|
||||
@@ -8,8 +8,11 @@
|
||||
"log_upgrade_node_remotely": "远程升级节点 %d",
|
||||
"log_start_node_remotely": "远程启动节点 %d",
|
||||
"log_stop_node_remotely": "远程停止节点 %d",
|
||||
"log_uninstall_node_remotely": "远程卸载节点 %d",
|
||||
"log_update_node": "修改节点 %d 基本信息",
|
||||
"log_update_node_installation_status": "修改节点安装状态 %d",
|
||||
"log_up_node": "手动上线节点 %d",
|
||||
"log_update_node_on": "启用节点 %d",
|
||||
"log_update_node_off": "停用节点 %d",
|
||||
"log_delete_node_from_cluster": "从集群 %d 中删除节点 %d"
|
||||
}
|
||||
8
pkg/langs/protos/zh-cn/post.json
Normal file
8
pkg/langs/protos/zh-cn/post.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"product_global": "全站",
|
||||
|
||||
"log_create_post": "创建文章 %d",
|
||||
"log_publish_post": "发布文章 %d",
|
||||
"log_delete_post": "删除文章 %d",
|
||||
"log_update_post": "修改文章 %d"
|
||||
}
|
||||
@@ -48,7 +48,6 @@
|
||||
"menu_setting_others": "其他设置",
|
||||
"menu_setting_tcp": "TCP",
|
||||
"menu_setting_tls": "TLS",
|
||||
"menu_setting_unix": "Unix",
|
||||
"menu_setting_udp": "UDP",
|
||||
"menu_setting_delete": "删除",
|
||||
"menu_setting_http_proxy": "HTTP代理", // 网站分组中使用
|
||||
@@ -56,6 +55,7 @@
|
||||
"menu_setting_udp_proxy": "UDP代理", // 网站分组中使用
|
||||
"menu_setting_plan": "套餐",
|
||||
"menu_setting_group": "分组",
|
||||
"menu_setting_multimedia": "音视频设置",
|
||||
|
||||
"menu_setting_uam": "5秒盾",
|
||||
"menu_setting_cc": "CC防护",
|
||||
@@ -84,5 +84,6 @@
|
||||
"log_enable_server": "启用网站 %d",
|
||||
"log_disable_server": "停用网站 %d",
|
||||
"log_update_server_name": "修改网站 %d 名称",
|
||||
"log_update_server_is_on":"修改网站 %d 启用状态"
|
||||
"log_update_server_is_on":"修改网站 %d 启用状态",
|
||||
"log_delete_servers": "批量删除网站"
|
||||
}
|
||||
3
pkg/langs/protos/zh-cn/server_hls.json
Normal file
3
pkg/langs/protos/zh-cn/server_hls.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"log_update_hls": "修改Web %d 的HLS设置"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"log_create_origin": "创建源站 %d",
|
||||
"log_delete_origin": "删除源站 %d",
|
||||
"log_update_origin": "修改源站 %d"
|
||||
"log_update_origin": "修改源站 %d",
|
||||
"log_update_origin_is_on": "修改源站 %d 启用状态"
|
||||
}
|
||||
@@ -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 monitorconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ var httpCCPolicyLocker = &sync.RWMutex{}
|
||||
var http3PolicyLocker = &sync.RWMutex{}
|
||||
var httpPagesPolicyLocker = &sync.RWMutex{}
|
||||
var webPPolicyLocker = &sync.RWMutex{}
|
||||
var plansLocker = &sync.RWMutex{}
|
||||
|
||||
type ServerError struct {
|
||||
Id int64
|
||||
@@ -89,6 +90,9 @@ type NodeConfig struct {
|
||||
Clock *ClockConfig `yaml:"clock" json:"clock"` // 时钟配置
|
||||
AutoInstallNftables bool `yaml:"autoInstallNftables" json:"autoInstallNftables"` // 自动安装nftables
|
||||
AutoSystemTuning bool `yaml:"autoSystemTuning" json:"autoSystemTuning"` // 自动调整系统参数
|
||||
AutoTrimDisks bool `yaml:"autoTrimDisks" json:"autoTrimDisks"` // 自动执行TRIM
|
||||
MaxConcurrentReads int `yaml:"maxConcurrentReads" json:"maxConcurrentReads"` // 最大并发读
|
||||
MaxConcurrentWrites int `yaml:"maxConcurrentWrites" json:"maxConcurrentWrites"` // 最大并发写
|
||||
|
||||
// 指标
|
||||
MetricItems []*serverconfigs.MetricItemConfig `yaml:"metricItems" json:"metricItems"`
|
||||
@@ -99,16 +103,20 @@ type NodeConfig struct {
|
||||
// 脚本
|
||||
CommonScripts []*serverconfigs.CommonScript `yaml:"commonScripts" json:"commonScripts"`
|
||||
|
||||
WebPImagePolicies map[int64]*WebPImagePolicy `yaml:"webpImagePolicies" json:"webpImagePolicies"` // WebP相关配置,clusterId => *WebPImagePolicy
|
||||
UAMPolicies map[int64]*UAMPolicy `yaml:"uamPolicies" json:"uamPolicies"` // UAM相关配置,clusterId => *UAMPolicy
|
||||
HTTPCCPolicies map[int64]*HTTPCCPolicy `yaml:"httpCCPolicies" json:"httpCCPolicies"` // CC相关配置, clusterId => *HTTPCCPolicy
|
||||
HTTP3Policies map[int64]*HTTP3Policy `yaml:"http3Policies" json:"http3Policies"` // HTTP3相关配置, clusterId => *HTTP3Policy
|
||||
HTTPPagesPolicies map[int64]*HTTPPagesPolicy `yaml:"httpPagesPolicies" json:"httpPagesPolicies"` // 自定义页面,clusterId => *HTTPPagesPolicy
|
||||
NetworkSecurityPolicy *NetworkSecurityPolicy `yaml:"networkSecurityPolicy" json:"networkSecurityPolicy"` // 网络安全策略
|
||||
WebPImagePolicies map[int64]*WebPImagePolicy `yaml:"webpImagePolicies" json:"webpImagePolicies"` // WebP相关配置,clusterId => *WebPImagePolicy
|
||||
UAMPolicies map[int64]*UAMPolicy `yaml:"uamPolicies" json:"uamPolicies"` // UAM相关配置,clusterId => *UAMPolicy
|
||||
HTTPCCPolicies map[int64]*HTTPCCPolicy `yaml:"httpCCPolicies" json:"httpCCPolicies"` // CC相关配置, clusterId => *HTTPCCPolicy
|
||||
HTTP3Policies map[int64]*HTTP3Policy `yaml:"http3Policies" json:"http3Policies"` // HTTP3相关配置, clusterId => *HTTP3Policy
|
||||
HTTPPagesPolicies map[int64]*HTTPPagesPolicy `yaml:"httpPagesPolicies" json:"httpPagesPolicies"` // 自定义页面,clusterId => *HTTPPagesPolicy
|
||||
NetworkSecurityPolicy *NetworkSecurityPolicy `yaml:"networkSecurityPolicy" json:"networkSecurityPolicy"` // 网络安全策略
|
||||
Plans map[int64]*serverconfigs.PlanConfig `yaml:"plans" json:"plans"` // 套餐 plan id => *serverconfigs.PlanConfig
|
||||
|
||||
// DNS
|
||||
DNSResolver *DNSResolverConfig `yaml:"dnsResolver" json:"dnsResolver"`
|
||||
|
||||
// Cluster
|
||||
ClusterSecret string `yaml:"clusterSecret" json:"clusterSecret"`
|
||||
|
||||
paddedId string
|
||||
|
||||
// firewall
|
||||
@@ -214,6 +222,9 @@ func CloneNodeConfig(nodeConfig *NodeConfig) (*NodeConfig, error) {
|
||||
webPPolicyLocker.RLock()
|
||||
defer webPPolicyLocker.RUnlock()
|
||||
|
||||
plansLocker.RLock()
|
||||
defer plansLocker.RUnlock()
|
||||
|
||||
var newConfigValue = reflect.Indirect(reflect.ValueOf(&NodeConfig{}))
|
||||
var oldValue = reflect.Indirect(reflect.ValueOf(nodeConfig))
|
||||
var valueType = oldValue.Type()
|
||||
@@ -444,6 +455,19 @@ func (this *NodeConfig) Init(ctx context.Context) (err error, serverErrors []*Se
|
||||
}
|
||||
httpPagesPolicyLocker.RUnlock()
|
||||
|
||||
// plans
|
||||
plansLocker.RLock()
|
||||
if len(this.Plans) > 0 {
|
||||
for _, plan := range this.Plans {
|
||||
err = plan.Init()
|
||||
if err != nil {
|
||||
plansLocker.RUnlock()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
plansLocker.RUnlock()
|
||||
|
||||
// dns resolver
|
||||
if this.DNSResolver != nil {
|
||||
err = this.DNSResolver.Init()
|
||||
@@ -606,9 +630,21 @@ func (this *NodeConfig) lookupWeb(server *serverconfigs.ServerConfig, web *serve
|
||||
if (web.FirewallPolicy.BlockOptions == nil || !web.FirewallPolicy.BlockOptions.IsPrior) && server.HTTPFirewallPolicy.BlockOptions != nil {
|
||||
web.FirewallPolicy.BlockOptions = server.HTTPFirewallPolicy.BlockOptions
|
||||
}
|
||||
if (web.FirewallPolicy.PageOptions == nil || !web.FirewallPolicy.PageOptions.IsPrior) && server.HTTPFirewallPolicy.PageOptions != nil {
|
||||
web.FirewallPolicy.PageOptions = server.HTTPFirewallPolicy.PageOptions
|
||||
}
|
||||
if (web.FirewallPolicy.CaptchaOptions == nil || !web.FirewallPolicy.CaptchaOptions.IsPrior) && server.HTTPFirewallPolicy.CaptchaOptions != nil {
|
||||
web.FirewallPolicy.CaptchaOptions = server.HTTPFirewallPolicy.CaptchaOptions
|
||||
}
|
||||
if (web.FirewallPolicy.Get302Options == nil || !web.FirewallPolicy.Get302Options.IsPrior) && server.HTTPFirewallPolicy.Get302Options != nil {
|
||||
web.FirewallPolicy.Get302Options = server.HTTPFirewallPolicy.Get302Options
|
||||
}
|
||||
if (web.FirewallPolicy.Post307Options == nil || !web.FirewallPolicy.Post307Options.IsPrior) && server.HTTPFirewallPolicy.Post307Options != nil {
|
||||
web.FirewallPolicy.Post307Options = server.HTTPFirewallPolicy.Post307Options
|
||||
}
|
||||
if (web.FirewallPolicy.JSCookieOptions == nil || !web.FirewallPolicy.JSCookieOptions.IsPrior) && server.HTTPFirewallPolicy.JSCookieOptions != nil {
|
||||
web.FirewallPolicy.JSCookieOptions = server.HTTPFirewallPolicy.JSCookieOptions
|
||||
}
|
||||
if (web.FirewallPolicy.SYNFlood == nil || !web.FirewallPolicy.SYNFlood.IsPrior) && server.HTTPFirewallPolicy.SYNFlood != nil {
|
||||
web.FirewallPolicy.SYNFlood = server.HTTPFirewallPolicy.SYNFlood
|
||||
}
|
||||
@@ -784,6 +820,27 @@ func (this *NodeConfig) FindHTTPPagesPolicyWithClusterId(clusterId int64) *HTTPP
|
||||
return this.HTTPPagesPolicies[clusterId]
|
||||
}
|
||||
|
||||
// UpdatePlans 更新套餐
|
||||
func (this *NodeConfig) UpdatePlans(planMap map[int64]*serverconfigs.PlanConfig) {
|
||||
plansLocker.Lock()
|
||||
this.Plans = planMap
|
||||
plansLocker.Unlock()
|
||||
}
|
||||
|
||||
// FindAllPlans 查找所有套餐
|
||||
func (this *NodeConfig) FindAllPlans() map[int64]*serverconfigs.PlanConfig {
|
||||
plansLocker.RLock()
|
||||
defer plansLocker.RUnlock()
|
||||
return this.Plans
|
||||
}
|
||||
|
||||
// 查找单个套餐
|
||||
func (this *NodeConfig) FindPlan(planId int64) *serverconfigs.PlanConfig {
|
||||
plansLocker.RLock()
|
||||
defer plansLocker.RUnlock()
|
||||
return this.Plans[planId]
|
||||
}
|
||||
|
||||
// SecretHash 对Id和Secret的Hash计算
|
||||
func (this *NodeConfig) SecretHash() string {
|
||||
return this.secretHash
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
|
||||
@@ -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 nodeconfigs
|
||||
|
||||
@@ -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 nodeutils
|
||||
|
||||
|
||||
@@ -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 nodeutils
|
||||
|
||||
|
||||
@@ -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 nodeutils
|
||||
|
||||
|
||||
@@ -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 nodeutils
|
||||
|
||||
|
||||
@@ -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 reporterconfigs
|
||||
|
||||
|
||||
@@ -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 reporterconfigs
|
||||
|
||||
|
||||
@@ -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 reporterconfigs
|
||||
|
||||
|
||||
@@ -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 reporterconfigs
|
||||
|
||||
|
||||
@@ -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 reporterconfigs
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ func (this *HTTPFirewallPolicyDAO) FindEnabledPolicyIPListIdWithType(ctx context
|
||||
return this.FindEnabledPolicyWhiteIPListId(ctx, policyId)
|
||||
case ipconfigs.IPListTypeBlack:
|
||||
return this.FindEnabledPolicyBlackIPListId(ctx, policyId)
|
||||
case ipconfigs.IPListTypeGrey:
|
||||
return this.FindEnabledPolicyGreyIPListId(ctx, policyId)
|
||||
default:
|
||||
return 0, errors.New("invalid ip list type '" + listType + "'")
|
||||
}
|
||||
@@ -89,7 +91,7 @@ func (this *HTTPFirewallPolicyDAO) FindEnabledPolicyWhiteIPListId(ctx context.Co
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
listId := createResp.IpListId
|
||||
var listId = createResp.IpListId
|
||||
config.Inbound.AllowListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
ListId: listId,
|
||||
@@ -133,7 +135,7 @@ func (this *HTTPFirewallPolicyDAO) FindEnabledPolicyBlackIPListId(ctx context.Co
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
listId := createResp.IpListId
|
||||
var listId = createResp.IpListId
|
||||
config.Inbound.DenyListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
ListId: listId,
|
||||
@@ -155,6 +157,50 @@ func (this *HTTPFirewallPolicyDAO) FindEnabledPolicyBlackIPListId(ctx context.Co
|
||||
return config.Inbound.DenyListRef.ListId, nil
|
||||
}
|
||||
|
||||
// FindEnabledPolicyGreyIPListId 查找WAF的灰名单
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledPolicyGreyIPListId(ctx context.Context, policyId int64) (int64, error) {
|
||||
config, err := this.FindEnabledHTTPFirewallPolicyConfig(ctx, policyId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if config == nil {
|
||||
return 0, errors.New("not found")
|
||||
}
|
||||
if config.Inbound == nil {
|
||||
config.Inbound = &firewallconfigs.HTTPFirewallInboundConfig{IsOn: true}
|
||||
}
|
||||
if config.Inbound.GreyListRef == nil || config.Inbound.GreyListRef.ListId == 0 {
|
||||
createResp, err := this.RPC().IPListRPC().CreateIPList(ctx, &pb.CreateIPListRequest{
|
||||
Type: "grey",
|
||||
Name: "灰名单",
|
||||
Code: "grey",
|
||||
TimeoutJSON: nil,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var listId = createResp.IpListId
|
||||
config.Inbound.GreyListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
ListId: listId,
|
||||
}
|
||||
inboundJSON, err := json.Marshal(config.Inbound)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
_, err = this.RPC().HTTPFirewallPolicyRPC().UpdateHTTPFirewallInboundConfig(ctx, &pb.UpdateHTTPFirewallInboundConfigRequest{
|
||||
HttpFirewallPolicyId: policyId,
|
||||
InboundJSON: inboundJSON,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return listId, nil
|
||||
}
|
||||
|
||||
return config.Inbound.GreyListRef.ListId, nil
|
||||
}
|
||||
|
||||
// FindEnabledHTTPFirewallPolicyWithServerId 根据服务Id查找WAF策略
|
||||
func (this *HTTPFirewallPolicyDAO) FindEnabledHTTPFirewallPolicyWithServerId(ctx context.Context, serverId int64) (*pb.HTTPFirewallPolicy, error) {
|
||||
serverResp, err := this.RPC().ServerRPC().FindEnabledServer(ctx, &pb.FindEnabledServerRequest{ServerId: serverId})
|
||||
@@ -202,7 +248,7 @@ func (this *HTTPFirewallPolicyDAO) FindHTTPFirewallActionConfigs(ctx context.Con
|
||||
return nil, err
|
||||
}
|
||||
if listId == 0 {
|
||||
action.Options["ipListName"] = "全局黑名单"
|
||||
action.Options["ipListName"] = firewallconfigs.FindGlobalListNameWithType(action.Options.GetString("type"))
|
||||
} else if listResp.IpList != nil {
|
||||
action.Options["ipListName"] = listResp.IpList.Name
|
||||
} else {
|
||||
|
||||
@@ -15,7 +15,7 @@ type IPListDAO struct {
|
||||
BaseDAO
|
||||
}
|
||||
|
||||
// FindAllowIPListIdWithServerId 查找服务的允许IP列表
|
||||
// FindAllowIPListIdWithServerId 查找网站的允许IP列表
|
||||
func (this *IPListDAO) FindAllowIPListIdWithServerId(ctx context.Context, serverId int64) (int64, error) {
|
||||
webConfig, err := SharedHTTPWebDAO.FindWebConfigWithServerId(ctx, serverId)
|
||||
if err != nil {
|
||||
@@ -30,7 +30,7 @@ func (this *IPListDAO) FindAllowIPListIdWithServerId(ctx context.Context, server
|
||||
return webConfig.FirewallPolicy.Inbound.AllowListRef.ListId, nil
|
||||
}
|
||||
|
||||
// FindDenyIPListIdWithServerId 查找服务的禁止IP列表
|
||||
// FindDenyIPListIdWithServerId 查找网站的禁止IP列表
|
||||
func (this *IPListDAO) FindDenyIPListIdWithServerId(ctx context.Context, serverId int64) (int64, error) {
|
||||
webConfig, err := SharedHTTPWebDAO.FindWebConfigWithServerId(ctx, serverId)
|
||||
if err != nil {
|
||||
@@ -45,6 +45,21 @@ func (this *IPListDAO) FindDenyIPListIdWithServerId(ctx context.Context, serverI
|
||||
return webConfig.FirewallPolicy.Inbound.DenyListRef.ListId, nil
|
||||
}
|
||||
|
||||
// FindGreyIPListIdWithServerId 查找网站的IP灰名单
|
||||
func (this *IPListDAO) FindGreyIPListIdWithServerId(ctx context.Context, serverId int64) (int64, error) {
|
||||
webConfig, err := SharedHTTPWebDAO.FindWebConfigWithServerId(ctx, serverId)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if webConfig == nil {
|
||||
return 0, nil
|
||||
}
|
||||
if webConfig.FirewallPolicy == nil || webConfig.FirewallPolicy.Inbound == nil || webConfig.FirewallPolicy.Inbound.GreyListRef == nil {
|
||||
return 0, nil
|
||||
}
|
||||
return webConfig.FirewallPolicy.Inbound.GreyListRef.ListId, nil
|
||||
}
|
||||
|
||||
// CreateIPListForServerId 为服务创建IP名单
|
||||
func (this *IPListDAO) CreateIPListForServerId(ctx context.Context, serverId int64, listType string) (int64, error) {
|
||||
webConfig, err := SharedHTTPWebDAO.FindWebConfigWithServerId(ctx, serverId)
|
||||
@@ -72,13 +87,13 @@ func (this *IPListDAO) CreateIPListForServerId(ctx context.Context, serverId int
|
||||
}
|
||||
}
|
||||
|
||||
inbound := webConfig.FirewallPolicy.Inbound
|
||||
var inbound = webConfig.FirewallPolicy.Inbound
|
||||
if inbound == nil {
|
||||
inbound = &firewallconfigs.HTTPFirewallInboundConfig{
|
||||
IsOn: true,
|
||||
}
|
||||
}
|
||||
if listType == "white" {
|
||||
if listType == ipconfigs.IPListTypeWhite {
|
||||
if inbound.AllowListRef == nil {
|
||||
inbound.AllowListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
@@ -87,7 +102,7 @@ func (this *IPListDAO) CreateIPListForServerId(ctx context.Context, serverId int
|
||||
if inbound.AllowListRef.ListId > 0 {
|
||||
return inbound.AllowListRef.ListId, nil
|
||||
}
|
||||
} else if listType == "black" {
|
||||
} else if listType == ipconfigs.IPListTypeBlack {
|
||||
if inbound.DenyListRef == nil {
|
||||
inbound.DenyListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
@@ -96,6 +111,15 @@ func (this *IPListDAO) CreateIPListForServerId(ctx context.Context, serverId int
|
||||
if inbound.DenyListRef.ListId > 0 {
|
||||
return inbound.DenyListRef.ListId, nil
|
||||
}
|
||||
} else if listType == ipconfigs.IPListTypeGrey {
|
||||
if inbound.GreyListRef == nil {
|
||||
inbound.GreyListRef = &ipconfigs.IPListRef{
|
||||
IsOn: true,
|
||||
}
|
||||
}
|
||||
if inbound.GreyListRef.ListId > 0 {
|
||||
return inbound.DenyListRef.ListId, nil
|
||||
}
|
||||
}
|
||||
|
||||
ipListResp, err := this.RPC().IPListRPC().CreateIPList(ctx, &pb.CreateIPListRequest{
|
||||
@@ -109,10 +133,12 @@ func (this *IPListDAO) CreateIPListForServerId(ctx context.Context, serverId int
|
||||
return 0, errors.Wrap(err)
|
||||
}
|
||||
|
||||
if listType == "white" {
|
||||
if listType == ipconfigs.IPListTypeWhite {
|
||||
inbound.AllowListRef.ListId = ipListResp.IpListId
|
||||
} else if listType == "black" {
|
||||
} else if listType == ipconfigs.IPListTypeBlack {
|
||||
inbound.DenyListRef.ListId = ipListResp.IpListId
|
||||
} else if listType == ipconfigs.IPListTypeGrey {
|
||||
inbound.GreyListRef.ListId = ipListResp.IpListId
|
||||
}
|
||||
inboundJSON, err := json.Marshal(inbound)
|
||||
if err != 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 errors
|
||||
|
||||
|
||||
37
pkg/rpc/jsons/bit_size_capacity.md
Normal file
37
pkg/rpc/jsons/bit_size_capacity.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# 比特位尺寸
|
||||
## 定义
|
||||
~~~json
|
||||
{
|
||||
"count": "数量",
|
||||
"unit": "单位"
|
||||
}
|
||||
~~~
|
||||
|
||||
其中:
|
||||
* `数量` - 必须是一个整数数字
|
||||
* `单位` - 有以下几个值:
|
||||
* `b` - 比特
|
||||
* `kb` - Kb
|
||||
* `mb` - Mb
|
||||
* `gb` - Gb
|
||||
* `tb` - Tb
|
||||
* `pb` - Pb
|
||||
* `eb` - Eb
|
||||
|
||||
## 示例
|
||||
100Mb:
|
||||
~~~
|
||||
{
|
||||
"count": 100,
|
||||
"unit": "mb"
|
||||
}
|
||||
~~~
|
||||
|
||||
|
||||
32Gb:
|
||||
~~~
|
||||
{
|
||||
"count": 32,
|
||||
"unit": "gb"
|
||||
}
|
||||
~~~
|
||||
@@ -4,7 +4,9 @@
|
||||
{
|
||||
"isPrior": "是否覆盖上级配置",
|
||||
"isOn": "是否启用配置",
|
||||
"firewallPolicyId": "WAF策略ID"
|
||||
"firewallPolicyId": "WAF策略ID",
|
||||
"ignoreGlobalRules": "是否忽略系统定义的全局规则",
|
||||
"defaultCaptchaType": "默认人机识别方式,可以选none(不设置)、default(默认)、oneClick(单击验证)、slide(滑动解锁)、geetest(极验)"
|
||||
}
|
||||
~~~
|
||||
|
||||
@@ -13,6 +15,8 @@
|
||||
{
|
||||
"isPrior": true,
|
||||
"isOn": true,
|
||||
"firewallPolicyId": 123
|
||||
"firewallPolicyId": 123,
|
||||
"ignoreGlobalRules": false,
|
||||
"defaultCaptchaType": "none"
|
||||
}
|
||||
~~~
|
||||
37
pkg/rpc/jsons/size_capacity.md
Normal file
37
pkg/rpc/jsons/size_capacity.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# 容量
|
||||
## 定义
|
||||
~~~json
|
||||
{
|
||||
"count": "数量",
|
||||
"unit": "单位"
|
||||
}
|
||||
~~~
|
||||
|
||||
其中:
|
||||
* `数量` - 必须是一个整数数字
|
||||
* `单位` - 有以下几个值:
|
||||
* `byte` - 字节
|
||||
* `kb` - KB
|
||||
* `mb` - MB
|
||||
* `gb` - GB
|
||||
* `tb` - TB
|
||||
* `pb` - PB
|
||||
* `eb` - EB
|
||||
|
||||
## 示例
|
||||
100MB:
|
||||
~~~
|
||||
{
|
||||
"count": 100,
|
||||
"unit": "mb"
|
||||
}
|
||||
~~~
|
||||
|
||||
|
||||
32GB:
|
||||
~~~
|
||||
{
|
||||
"count": 32,
|
||||
"unit": "gb"
|
||||
}
|
||||
~~~
|
||||
@@ -31,6 +31,7 @@ type DNSProvider struct {
|
||||
TypeName string `protobuf:"bytes,4,opt,name=typeName,proto3" json:"typeName,omitempty"`
|
||||
ApiParamsJSON []byte `protobuf:"bytes,5,opt,name=apiParamsJSON,proto3" json:"apiParamsJSON,omitempty"`
|
||||
DataUpdatedAt int64 `protobuf:"varint,6,opt,name=dataUpdatedAt,proto3" json:"dataUpdatedAt,omitempty"`
|
||||
MinTTL int32 `protobuf:"varint,7,opt,name=minTTL,proto3" json:"minTTL,omitempty"` // 最小TTL
|
||||
}
|
||||
|
||||
func (x *DNSProvider) Reset() {
|
||||
@@ -107,12 +108,19 @@ func (x *DNSProvider) GetDataUpdatedAt() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DNSProvider) GetMinTTL() int32 {
|
||||
if x != nil {
|
||||
return x.MinTTL
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_models_model_dns_provider_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_dns_provider_proto_rawDesc = []byte{
|
||||
0x0a, 0x1f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x64,
|
||||
0x6e, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xad, 0x01, 0x0a, 0x0b, 0x44, 0x4e, 0x53, 0x50, 0x72, 0x6f,
|
||||
0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xc5, 0x01, 0x0a, 0x0b, 0x44, 0x4e, 0x53, 0x50, 0x72, 0x6f,
|
||||
0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||
@@ -123,8 +131,9 @@ var file_models_model_dns_provider_proto_rawDesc = []byte{
|
||||
0x52, 0x0d, 0x61, 0x70, 0x69, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12,
|
||||
0x24, 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74,
|
||||
0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x55, 0x70, 0x64, 0x61,
|
||||
0x74, 0x65, 0x64, 0x41, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x69, 0x6e, 0x54, 0x54, 0x4c, 0x18,
|
||||
0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6d, 0x69, 0x6e, 0x54, 0x54, 0x4c, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -25,15 +25,16 @@ type HTTPCacheTaskKey struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 缓存键ID
|
||||
TaskId int64 `protobuf:"varint,2,opt,name=taskId,proto3" json:"taskId,omitempty"` // 任务ID
|
||||
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` // 缓存键
|
||||
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"` // 操作类型:purge|fetch
|
||||
KeyType string `protobuf:"bytes,5,opt,name=keyType,proto3" json:"keyType,omitempty"` // 键类型:key|prefix
|
||||
IsDone bool `protobuf:"varint,6,opt,name=isDone,proto3" json:"isDone,omitempty"` // 是否已完成
|
||||
IsDoing bool `protobuf:"varint,9,opt,name=isDoing,proto3" json:"isDoing,omitempty"` // 是否执行中
|
||||
ErrorsJSON []byte `protobuf:"bytes,7,opt,name=errorsJSON,proto3" json:"errorsJSON,omitempty"` // 错误信息
|
||||
NodeClusterId int64 `protobuf:"varint,8,opt,name=nodeClusterId,proto3" json:"nodeClusterId,omitempty"` // 所属集群ID
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 缓存键ID
|
||||
TaskId int64 `protobuf:"varint,2,opt,name=taskId,proto3" json:"taskId,omitempty"` // 任务ID
|
||||
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` // 缓存键
|
||||
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"` // 操作类型:purge|fetch
|
||||
KeyType string `protobuf:"bytes,5,opt,name=keyType,proto3" json:"keyType,omitempty"` // 键类型:key|prefix
|
||||
IsDone bool `protobuf:"varint,6,opt,name=isDone,proto3" json:"isDone,omitempty"` // 是否已完成
|
||||
IsDoing bool `protobuf:"varint,9,opt,name=isDoing,proto3" json:"isDoing,omitempty"` // 是否执行中
|
||||
ErrorsJSON []byte `protobuf:"bytes,7,opt,name=errorsJSON,proto3" json:"errorsJSON,omitempty"` // 错误信息
|
||||
NodeClusterId int64 `protobuf:"varint,8,opt,name=nodeClusterId,proto3" json:"nodeClusterId,omitempty"` // 所属集群ID
|
||||
NodeCluster *NodeCluster `protobuf:"bytes,30,opt,name=nodeCluster,proto3" json:"nodeCluster,omitempty"` // 所属集群,不一定有内容
|
||||
}
|
||||
|
||||
func (x *HTTPCacheTaskKey) Reset() {
|
||||
@@ -131,29 +132,41 @@ func (x *HTTPCacheTaskKey) GetNodeClusterId() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *HTTPCacheTaskKey) GetNodeCluster() *NodeCluster {
|
||||
if x != nil {
|
||||
return x.NodeCluster
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_models_model_http_cache_task_key_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_http_cache_task_key_proto_rawDesc = []byte{
|
||||
0x0a, 0x26, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x68,
|
||||
0x74, 0x74, 0x70, 0x5f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x6b,
|
||||
0x65, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xf2, 0x01, 0x0a,
|
||||
0x10, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x4b, 0x65,
|
||||
0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69,
|
||||
0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74,
|
||||
0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,
|
||||
0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x07, 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x44,
|
||||
0x6f, 0x6e, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x44, 0x6f, 0x6e,
|
||||
0x65, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x44, 0x6f, 0x69, 0x6e, 0x67, 0x18, 0x09, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x44, 0x6f, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x65,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
||||
0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x24, 0x0a, 0x0d, 0x6e,
|
||||
0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x08, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49,
|
||||
0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
0x65, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x1f, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f,
|
||||
0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x02,
|
||||
0x0a, 0x10, 0x48, 0x54, 0x54, 0x50, 0x43, 0x61, 0x63, 0x68, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x4b,
|
||||
0x65, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02,
|
||||
0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
|
||||
0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
|
||||
0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73,
|
||||
0x44, 0x6f, 0x6e, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x44, 0x6f,
|
||||
0x6e, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x44, 0x6f, 0x69, 0x6e, 0x67, 0x18, 0x09, 0x20,
|
||||
0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x44, 0x6f, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a,
|
||||
0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c,
|
||||
0x52, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x24, 0x0a, 0x0d,
|
||||
0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x08, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72,
|
||||
0x49, 0x64, 0x12, 0x31, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65,
|
||||
0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64,
|
||||
0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c,
|
||||
0x75, 0x73, 0x74, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -171,13 +184,15 @@ func file_models_model_http_cache_task_key_proto_rawDescGZIP() []byte {
|
||||
var file_models_model_http_cache_task_key_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_models_model_http_cache_task_key_proto_goTypes = []interface{}{
|
||||
(*HTTPCacheTaskKey)(nil), // 0: pb.HTTPCacheTaskKey
|
||||
(*NodeCluster)(nil), // 1: pb.NodeCluster
|
||||
}
|
||||
var file_models_model_http_cache_task_key_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
1, // 0: pb.HTTPCacheTaskKey.nodeCluster:type_name -> pb.NodeCluster
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_models_model_http_cache_task_key_proto_init() }
|
||||
@@ -185,6 +200,7 @@ func file_models_model_http_cache_task_key_proto_init() {
|
||||
if File_models_model_http_cache_task_key_proto != nil {
|
||||
return
|
||||
}
|
||||
file_models_model_node_cluster_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_models_model_http_cache_task_key_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*HTTPCacheTaskKey); i {
|
||||
|
||||
@@ -26,18 +26,20 @@ type HTTPFirewallPolicy struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 策略ID
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // 名称
|
||||
Mode string `protobuf:"bytes,7,opt,name=mode,proto3" json:"mode,omitempty"` // 模式
|
||||
IsOn bool `protobuf:"varint,3,opt,name=isOn,proto3" json:"isOn,omitempty"` // 是否启用
|
||||
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` // 描述
|
||||
InboundJSON []byte `protobuf:"bytes,5,opt,name=inboundJSON,proto3" json:"inboundJSON,omitempty"` // 入站配置
|
||||
OutboundJSON []byte `protobuf:"bytes,6,opt,name=outboundJSON,proto3" json:"outboundJSON,omitempty"` // 出站配置
|
||||
ServerId int64 `protobuf:"varint,8,opt,name=serverId,proto3" json:"serverId,omitempty"` // 所属网站ID(如果为0表示公共策略)
|
||||
UseLocalFirewall bool `protobuf:"varint,9,opt,name=useLocalFirewall,proto3" json:"useLocalFirewall,omitempty"` // 是否使用本机防火墙
|
||||
SynFloodJSON []byte `protobuf:"bytes,10,opt,name=synFloodJSON,proto3" json:"synFloodJSON,omitempty"` // synflood配置
|
||||
BlockOptionsJSON []byte `protobuf:"bytes,11,opt,name=blockOptionsJSON,proto3" json:"blockOptionsJSON,omitempty"` // 拦截配置
|
||||
CaptchaOptionsJSON []byte `protobuf:"bytes,12,opt,name=captchaOptionsJSON,proto3" json:"captchaOptionsJSON,omitempty"` // 人机识别配置
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 策略ID
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // 名称
|
||||
Mode string `protobuf:"bytes,7,opt,name=mode,proto3" json:"mode,omitempty"` // 模式
|
||||
IsOn bool `protobuf:"varint,3,opt,name=isOn,proto3" json:"isOn,omitempty"` // 是否启用
|
||||
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` // 描述
|
||||
InboundJSON []byte `protobuf:"bytes,5,opt,name=inboundJSON,proto3" json:"inboundJSON,omitempty"` // 入站配置
|
||||
OutboundJSON []byte `protobuf:"bytes,6,opt,name=outboundJSON,proto3" json:"outboundJSON,omitempty"` // 出站配置
|
||||
ServerId int64 `protobuf:"varint,8,opt,name=serverId,proto3" json:"serverId,omitempty"` // 所属网站ID(如果为0表示公共策略)
|
||||
UseLocalFirewall bool `protobuf:"varint,9,opt,name=useLocalFirewall,proto3" json:"useLocalFirewall,omitempty"` // 是否使用本机防火墙
|
||||
SynFloodJSON []byte `protobuf:"bytes,10,opt,name=synFloodJSON,proto3" json:"synFloodJSON,omitempty"` // synflood配置
|
||||
BlockOptionsJSON []byte `protobuf:"bytes,11,opt,name=blockOptionsJSON,proto3" json:"blockOptionsJSON,omitempty"` // 阻止动作配置
|
||||
PageOptionsJSON []byte `protobuf:"bytes,13,opt,name=pageOptionsJSON,proto3" json:"pageOptionsJSON,omitempty"` // 显示网页动作配置
|
||||
CaptchaOptionsJSON []byte `protobuf:"bytes,12,opt,name=captchaOptionsJSON,proto3" json:"captchaOptionsJSON,omitempty"` // 人机识别配置
|
||||
JsCookieOptionsJSON []byte `protobuf:"bytes,14,opt,name=jsCookieOptionsJSON,proto3" json:"jsCookieOptionsJSON,omitempty"` // JSCookie动作配置
|
||||
}
|
||||
|
||||
func (x *HTTPFirewallPolicy) Reset() {
|
||||
@@ -149,6 +151,13 @@ func (x *HTTPFirewallPolicy) GetBlockOptionsJSON() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *HTTPFirewallPolicy) GetPageOptionsJSON() []byte {
|
||||
if x != nil {
|
||||
return x.PageOptionsJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *HTTPFirewallPolicy) GetCaptchaOptionsJSON() []byte {
|
||||
if x != nil {
|
||||
return x.CaptchaOptionsJSON
|
||||
@@ -156,12 +165,19 @@ func (x *HTTPFirewallPolicy) GetCaptchaOptionsJSON() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *HTTPFirewallPolicy) GetJsCookieOptionsJSON() []byte {
|
||||
if x != nil {
|
||||
return x.JsCookieOptionsJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_models_model_http_firewall_policy_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_http_firewall_policy_proto_rawDesc = []byte{
|
||||
0x0a, 0x27, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x68,
|
||||
0x74, 0x74, 0x70, 0x5f, 0x66, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x5f, 0x70, 0x6f, 0x6c,
|
||||
0x69, 0x63, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x90, 0x03,
|
||||
0x69, 0x63, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xec, 0x03,
|
||||
0x0a, 0x12, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f,
|
||||
0x6c, 0x69, 0x63, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||
@@ -184,10 +200,16 @@ var file_models_model_http_firewall_policy_proto_rawDesc = []byte{
|
||||
0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x2a, 0x0a, 0x10, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4f, 0x70, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10,
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e,
|
||||
0x12, 0x2e, 0x0a, 0x12, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x4f, 0x70, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x63, 0x61,
|
||||
0x12, 0x28, 0x0a, 0x0f, 0x70, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a,
|
||||
0x53, 0x4f, 0x4e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x70, 0x61, 0x67, 0x65, 0x4f,
|
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x2e, 0x0a, 0x12, 0x63, 0x61,
|
||||
0x70, 0x74, 0x63, 0x68, 0x61, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e,
|
||||
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x4f,
|
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x30, 0x0a, 0x13, 0x6a, 0x73,
|
||||
0x43, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f,
|
||||
0x4e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x13, 0x6a, 0x73, 0x43, 0x6f, 0x6f, 0x6b, 0x69,
|
||||
0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x42, 0x06, 0x5a, 0x04,
|
||||
0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -26,6 +26,7 @@ type IPItem struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Value string `protobuf:"bytes,22,opt,name=value,proto3" json:"value,omitempty"` // 原始值,比如单个IP、IP范围或者CIDR
|
||||
IpFrom string `protobuf:"bytes,2,opt,name=ipFrom,proto3" json:"ipFrom,omitempty"`
|
||||
IpTo string `protobuf:"bytes,3,opt,name=ipTo,proto3" json:"ipTo,omitempty"`
|
||||
Version int64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"`
|
||||
@@ -93,6 +94,13 @@ func (x *IPItem) GetId() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *IPItem) GetValue() string {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *IPItem) GetIpFrom() string {
|
||||
if x != nil {
|
||||
return x.IpFrom
|
||||
@@ -291,76 +299,77 @@ var file_models_model_ip_item_proto_rawDesc = []byte{
|
||||
0x6f, 0x1a, 0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xba, 0x08, 0x0a, 0x06, 0x49, 0x50, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd0, 0x08, 0x0a, 0x06, 0x49, 0x50, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x69, 0x70, 0x46, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x69, 0x70, 0x46, 0x72, 0x6f, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x70, 0x54, 0x6f,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x70, 0x54, 0x6f, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76,
|
||||
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65,
|
||||
0x64, 0x41, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x78, 0x70, 0x69, 0x72,
|
||||
0x65, 0x64, 0x41, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x06,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x6c, 0x69, 0x73, 0x74, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6c, 0x69,
|
||||
0x73, 0x74, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
|
||||
0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x44, 0x65, 0x6c, 0x65, 0x74,
|
||||
0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x4c,
|
||||
0x65, 0x76, 0x65, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x76, 0x65, 0x6e,
|
||||
0x74, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x69, 0x73, 0x74, 0x54, 0x79,
|
||||
0x70, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x69, 0x73, 0x74, 0x54, 0x79,
|
||||
0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18, 0x14,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f,
|
||||
0x64, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64,
|
||||
0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64,
|
||||
0x12, 0x22, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64,
|
||||
0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f,
|
||||
0x64, 0x65, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x73, 0x6f,
|
||||
0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x3e, 0x0a, 0x1a,
|
||||
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61,
|
||||
0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x1a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65,
|
||||
0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x64, 0x12, 0x44, 0x0a, 0x1d,
|
||||
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61,
|
||||
0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x18, 0x12, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x1d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46,
|
||||
0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70,
|
||||
0x49, 0x64, 0x12, 0x40, 0x0a, 0x1b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50,
|
||||
0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x65, 0x74, 0x49,
|
||||
0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x03, 0x52, 0x1b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48,
|
||||
0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x53,
|
||||
0x65, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x52, 0x65, 0x61, 0x64, 0x18, 0x15,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x52, 0x65, 0x61, 0x64, 0x12, 0x2e, 0x0a, 0x0c,
|
||||
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x1e, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0c,
|
||||
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x22, 0x0a, 0x06,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x22, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70,
|
||||
0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x12, 0x52, 0x0a, 0x18, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69,
|
||||
0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x1f, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65,
|
||||
0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x18, 0x73, 0x6f, 0x75, 0x72,
|
||||
0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f,
|
||||
0x6c, 0x69, 0x63, 0x79, 0x12, 0x5b, 0x0a, 0x1b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54,
|
||||
0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x47, 0x72,
|
||||
0x6f, 0x75, 0x70, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x48,
|
||||
0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x47,
|
||||
0x72, 0x6f, 0x75, 0x70, 0x52, 0x1b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50,
|
||||
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x70, 0x46, 0x72, 0x6f, 0x6d,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x70, 0x46, 0x72, 0x6f, 0x6d, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x69, 0x70, 0x54, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x70,
|
||||
0x54, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09,
|
||||
0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x41, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x09, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65,
|
||||
0x61, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73,
|
||||
0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x73, 0x74, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x06, 0x6c, 0x69, 0x73, 0x74, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73,
|
||||
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69,
|
||||
0x73, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65,
|
||||
0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a,
|
||||
0x65, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x6c, 0x69, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x6c, 0x69, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x47, 0x6c,
|
||||
0x6f, 0x62, 0x61, 0x6c, 0x18, 0x14, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x47, 0x6c,
|
||||
0x6f, 0x62, 0x61, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41,
|
||||
0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
|
||||
0x41, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x0d, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
|
||||
0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x73, 0x6f,
|
||||
0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x6f,
|
||||
0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x10, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x49, 0x64, 0x12, 0x3e, 0x0a, 0x1a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50,
|
||||
0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x64,
|
||||
0x18, 0x11, 0x20, 0x01, 0x28, 0x03, 0x52, 0x1a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54,
|
||||
0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
|
||||
0x49, 0x64, 0x12, 0x44, 0x0a, 0x1d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50,
|
||||
0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75,
|
||||
0x70, 0x12, 0x55, 0x0a, 0x19, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46,
|
||||
0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x65, 0x74, 0x18, 0x21,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69,
|
||||
0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x65, 0x74, 0x52, 0x19, 0x73,
|
||||
0x70, 0x49, 0x64, 0x18, 0x12, 0x20, 0x01, 0x28, 0x03, 0x52, 0x1d, 0x73, 0x6f, 0x75, 0x72, 0x63,
|
||||
0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c,
|
||||
0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x40, 0x0a, 0x1b, 0x73, 0x6f, 0x75, 0x72,
|
||||
0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75,
|
||||
0x6c, 0x65, 0x53, 0x65, 0x74, 0x49, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x03, 0x52, 0x1b, 0x73,
|
||||
0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c,
|
||||
0x6c, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x65, 0x74, 0x12, 0x28, 0x0a, 0x0a, 0x73, 0x6f, 0x75, 0x72,
|
||||
0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x18, 0x23, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70,
|
||||
0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f,
|
||||
0x64, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
0x6c, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x65, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73,
|
||||
0x52, 0x65, 0x61, 0x64, 0x18, 0x15, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x52, 0x65,
|
||||
0x61, 0x64, 0x12, 0x2e, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x52, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x12, 0x22, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x22, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x52, 0x0a, 0x18, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
|
||||
0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69,
|
||||
0x63, 0x79, 0x18, 0x1f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x54,
|
||||
0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
|
||||
0x52, 0x18, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65,
|
||||
0x77, 0x61, 0x6c, 0x6c, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x5b, 0x0a, 0x1b, 0x73, 0x6f,
|
||||
0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c,
|
||||
0x52, 0x75, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x19, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c,
|
||||
0x6c, 0x52, 0x75, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x1b, 0x73, 0x6f, 0x75, 0x72,
|
||||
0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75,
|
||||
0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x55, 0x0a, 0x19, 0x73, 0x6f, 0x75, 0x72, 0x63,
|
||||
0x65, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c,
|
||||
0x65, 0x53, 0x65, 0x74, 0x18, 0x21, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x2e,
|
||||
0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65,
|
||||
0x53, 0x65, 0x74, 0x52, 0x19, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x48, 0x54, 0x54, 0x50, 0x46,
|
||||
0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x65, 0x74, 0x12, 0x28,
|
||||
0x0a, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x18, 0x23, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x73, 0x6f,
|
||||
0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
190
pkg/rpc/pb/model_login_ticket.pb.go
Normal file
190
pkg/rpc/pb/model_login_ticket.pb.go
Normal file
@@ -0,0 +1,190 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v3.19.4
|
||||
// source: models/model_login_ticket.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 登录票据
|
||||
type LoginTicket struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // ID
|
||||
ExpiresAt int64 `protobuf:"varint,2,opt,name=expiresAt,proto3" json:"expiresAt,omitempty"` // 过期时间
|
||||
Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` // 票据值
|
||||
AdminId int64 `protobuf:"varint,4,opt,name=adminId,proto3" json:"adminId,omitempty"` // 管理员ID
|
||||
UserId int64 `protobuf:"varint,5,opt,name=userId,proto3" json:"userId,omitempty"` // 用户ID
|
||||
Ip string `protobuf:"bytes,6,opt,name=ip,proto3" json:"ip,omitempty"` // 登录时客户端IP
|
||||
}
|
||||
|
||||
func (x *LoginTicket) Reset() {
|
||||
*x = LoginTicket{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_models_model_login_ticket_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *LoginTicket) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*LoginTicket) ProtoMessage() {}
|
||||
|
||||
func (x *LoginTicket) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_models_model_login_ticket_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use LoginTicket.ProtoReflect.Descriptor instead.
|
||||
func (*LoginTicket) Descriptor() ([]byte, []int) {
|
||||
return file_models_model_login_ticket_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *LoginTicket) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *LoginTicket) GetExpiresAt() int64 {
|
||||
if x != nil {
|
||||
return x.ExpiresAt
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *LoginTicket) GetValue() string {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *LoginTicket) GetAdminId() int64 {
|
||||
if x != nil {
|
||||
return x.AdminId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *LoginTicket) GetUserId() int64 {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *LoginTicket) GetIp() string {
|
||||
if x != nil {
|
||||
return x.Ip
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_models_model_login_ticket_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_login_ticket_proto_rawDesc = []byte{
|
||||
0x0a, 0x1f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6c,
|
||||
0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x93, 0x01, 0x0a, 0x0b, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x54,
|
||||
0x69, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73,
|
||||
0x41, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65,
|
||||
0x73, 0x41, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x6d,
|
||||
0x69, 0x6e, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x64, 0x6d, 0x69,
|
||||
0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69,
|
||||
0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_models_model_login_ticket_proto_rawDescOnce sync.Once
|
||||
file_models_model_login_ticket_proto_rawDescData = file_models_model_login_ticket_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_models_model_login_ticket_proto_rawDescGZIP() []byte {
|
||||
file_models_model_login_ticket_proto_rawDescOnce.Do(func() {
|
||||
file_models_model_login_ticket_proto_rawDescData = protoimpl.X.CompressGZIP(file_models_model_login_ticket_proto_rawDescData)
|
||||
})
|
||||
return file_models_model_login_ticket_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_models_model_login_ticket_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_models_model_login_ticket_proto_goTypes = []interface{}{
|
||||
(*LoginTicket)(nil), // 0: pb.LoginTicket
|
||||
}
|
||||
var file_models_model_login_ticket_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_models_model_login_ticket_proto_init() }
|
||||
func file_models_model_login_ticket_proto_init() {
|
||||
if File_models_model_login_ticket_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_models_model_login_ticket_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*LoginTicket); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_models_model_login_ticket_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_models_model_login_ticket_proto_goTypes,
|
||||
DependencyIndexes: file_models_model_login_ticket_proto_depIdxs,
|
||||
MessageInfos: file_models_model_login_ticket_proto_msgTypes,
|
||||
}.Build()
|
||||
File_models_model_login_ticket_proto = out.File
|
||||
file_models_model_login_ticket_proto_rawDesc = nil
|
||||
file_models_model_login_ticket_proto_goTypes = nil
|
||||
file_models_model_login_ticket_proto_depIdxs = nil
|
||||
}
|
||||
@@ -46,7 +46,10 @@ type NodeCluster struct {
|
||||
AutoRemoteStart bool `protobuf:"varint,19,opt,name=autoRemoteStart,proto3" json:"autoRemoteStart,omitempty"`
|
||||
AutoInstallNftables bool `protobuf:"varint,20,opt,name=autoInstallNftables,proto3" json:"autoInstallNftables,omitempty"`
|
||||
SshParamsJSON []byte `protobuf:"bytes,21,opt,name=sshParamsJSON,proto3" json:"sshParamsJSON,omitempty"`
|
||||
AutoSystemTuning bool `protobuf:"varint,23,opt,name=autoSystemTuning,proto3" json:"autoSystemTuning,omitempty"` // 是否自动调节系统参数
|
||||
AutoSystemTuning bool `protobuf:"varint,23,opt,name=autoSystemTuning,proto3" json:"autoSystemTuning,omitempty"` // 是否自动调节系统参数
|
||||
AutoTrimDisks bool `protobuf:"varint,24,opt,name=autoTrimDisks,proto3" json:"autoTrimDisks,omitempty"` // 是否自动TRIM硬盘
|
||||
MaxConcurrentReads int32 `protobuf:"varint,25,opt,name=maxConcurrentReads,proto3" json:"maxConcurrentReads,omitempty"` // 最大并发读
|
||||
MaxConcurrentWrites int32 `protobuf:"varint,26,opt,name=maxConcurrentWrites,proto3" json:"maxConcurrentWrites,omitempty"` // 最大并发写
|
||||
}
|
||||
|
||||
func (x *NodeCluster) Reset() {
|
||||
@@ -235,12 +238,33 @@ func (x *NodeCluster) GetAutoSystemTuning() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *NodeCluster) GetAutoTrimDisks() bool {
|
||||
if x != nil {
|
||||
return x.AutoTrimDisks
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *NodeCluster) GetMaxConcurrentReads() int32 {
|
||||
if x != nil {
|
||||
return x.MaxConcurrentReads
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *NodeCluster) GetMaxConcurrentWrites() int32 {
|
||||
if x != nil {
|
||||
return x.MaxConcurrentWrites
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_models_model_node_cluster_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_node_cluster_proto_rawDesc = []byte{
|
||||
0x0a, 0x1f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e,
|
||||
0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xf3, 0x05, 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c,
|
||||
0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xfb, 0x06, 0x0a, 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c,
|
||||
0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65,
|
||||
@@ -287,8 +311,17 @@ var file_models_model_node_cluster_proto_rawDesc = []byte{
|
||||
0x52, 0x0d, 0x73, 0x73, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12,
|
||||
0x2a, 0x0a, 0x10, 0x61, 0x75, 0x74, 0x6f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x54, 0x75, 0x6e,
|
||||
0x69, 0x6e, 0x67, 0x18, 0x17, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x61, 0x75, 0x74, 0x6f, 0x53,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x54, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x54, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x24, 0x0a, 0x0d, 0x61,
|
||||
0x75, 0x74, 0x6f, 0x54, 0x72, 0x69, 0x6d, 0x44, 0x69, 0x73, 0x6b, 0x73, 0x18, 0x18, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x6f, 0x54, 0x72, 0x69, 0x6d, 0x44, 0x69, 0x73, 0x6b,
|
||||
0x73, 0x12, 0x2e, 0x0a, 0x12, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65,
|
||||
0x6e, 0x74, 0x52, 0x65, 0x61, 0x64, 0x73, 0x18, 0x19, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x6d,
|
||||
0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x61, 0x64,
|
||||
0x73, 0x12, 0x30, 0x0a, 0x13, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65,
|
||||
0x6e, 0x74, 0x57, 0x72, 0x69, 0x74, 0x65, 0x73, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x13,
|
||||
0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x57, 0x72, 0x69,
|
||||
0x74, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -31,6 +31,7 @@ type Plan struct {
|
||||
Description string `protobuf:"bytes,21,opt,name=description,proto3" json:"description,omitempty"` // 套餐简介
|
||||
ClusterId int64 `protobuf:"varint,4,opt,name=clusterId,proto3" json:"clusterId,omitempty"` // 集群ID
|
||||
TrafficLimitJSON []byte `protobuf:"bytes,5,opt,name=trafficLimitJSON,proto3" json:"trafficLimitJSON,omitempty"` // 流量限制
|
||||
BandwidthLimitPerNodeJSON []byte `protobuf:"bytes,22,opt,name=bandwidthLimitPerNodeJSON,proto3" json:"bandwidthLimitPerNodeJSON,omitempty"` // 单节点带宽限制
|
||||
HasFullFeatures bool `protobuf:"varint,20,opt,name=hasFullFeatures,proto3" json:"hasFullFeatures,omitempty"` // 是否有所有权限
|
||||
FeaturesJSON []byte `protobuf:"bytes,6,opt,name=featuresJSON,proto3" json:"featuresJSON,omitempty"` // 权限列表,[code1, code2, ...]
|
||||
PriceType string `protobuf:"bytes,7,opt,name=priceType,proto3" json:"priceType,omitempty"` // 价格类型:traffic, bandwidth, period
|
||||
@@ -46,6 +47,7 @@ type Plan struct {
|
||||
MonthlyRequests int64 `protobuf:"varint,17,opt,name=monthlyRequests,proto3" json:"monthlyRequests,omitempty"` // 每月访问量额度
|
||||
DailyWebsocketConnections int64 `protobuf:"varint,18,opt,name=dailyWebsocketConnections,proto3" json:"dailyWebsocketConnections,omitempty"` // 每日Websocket连接数额度
|
||||
MonthlyWebsocketConnections int64 `protobuf:"varint,19,opt,name=monthlyWebsocketConnections,proto3" json:"monthlyWebsocketConnections,omitempty"` // 每月Websocket连接数额度
|
||||
MaxUploadSizeJSON []byte `protobuf:"bytes,23,opt,name=maxUploadSizeJSON,proto3" json:"maxUploadSizeJSON,omitempty"` // 文件最大上传尺寸 @link json:size_capacity
|
||||
}
|
||||
|
||||
func (x *Plan) Reset() {
|
||||
@@ -122,6 +124,13 @@ func (x *Plan) GetTrafficLimitJSON() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Plan) GetBandwidthLimitPerNodeJSON() []byte {
|
||||
if x != nil {
|
||||
return x.BandwidthLimitPerNodeJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Plan) GetHasFullFeatures() bool {
|
||||
if x != nil {
|
||||
return x.HasFullFeatures
|
||||
@@ -227,11 +236,18 @@ func (x *Plan) GetMonthlyWebsocketConnections() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Plan) GetMaxUploadSizeJSON() []byte {
|
||||
if x != nil {
|
||||
return x.MaxUploadSizeJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_models_model_plan_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_plan_proto_rawDesc = []byte{
|
||||
0x0a, 0x17, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x70,
|
||||
0x6c, 0x61, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xc0, 0x06,
|
||||
0x6c, 0x61, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xac, 0x07,
|
||||
0x0a, 0x04, 0x50, 0x6c, 0x61, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
|
||||
@@ -242,49 +258,56 @@ var file_models_model_plan_proto_rawDesc = []byte{
|
||||
0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a,
|
||||
0x0a, 0x10, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4a, 0x53,
|
||||
0x4f, 0x4e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69,
|
||||
0x63, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x28, 0x0a, 0x0f, 0x68, 0x61,
|
||||
0x73, 0x46, 0x75, 0x6c, 0x6c, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x14, 0x20,
|
||||
0x01, 0x28, 0x08, 0x52, 0x0f, 0x68, 0x61, 0x73, 0x46, 0x75, 0x6c, 0x6c, 0x46, 0x65, 0x61, 0x74,
|
||||
0x75, 0x72, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73,
|
||||
0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x66, 0x65, 0x61, 0x74,
|
||||
0x75, 0x72, 0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x69, 0x63,
|
||||
0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x69,
|
||||
0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69,
|
||||
0x63, 0x50, 0x72, 0x69, 0x63, 0x65, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c,
|
||||
0x52, 0x10, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x50, 0x72, 0x69, 0x63, 0x65, 0x4a, 0x53,
|
||||
0x4f, 0x4e, 0x12, 0x2e, 0x0a, 0x12, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x50,
|
||||
0x72, 0x69, 0x63, 0x65, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12,
|
||||
0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x50, 0x72, 0x69, 0x63, 0x65, 0x4a, 0x53,
|
||||
0x4f, 0x4e, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x50, 0x72, 0x69,
|
||||
0x63, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c,
|
||||
0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x65, 0x61, 0x73, 0x6f, 0x6e,
|
||||
0x61, 0x6c, 0x6c, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x01, 0x52,
|
||||
0x0f, 0x73, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x6c, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65,
|
||||
0x12, 0x20, 0x0a, 0x0b, 0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18,
|
||||
0x0b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x50, 0x72, 0x69,
|
||||
0x63, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x3c, 0x0a, 0x19, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x19, 0x74, 0x6f, 0x74, 0x61, 0x6c,
|
||||
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10,
|
||||
0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73,
|
||||
0x12, 0x24, 0x0a, 0x0d, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c,
|
||||
0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x0f, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73,
|
||||
0x12, 0x3c, 0x0a, 0x19, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b,
|
||||
0x65, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x12, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x19, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63,
|
||||
0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x40,
|
||||
0x0a, 0x1b, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b,
|
||||
0x65, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x13, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x1b, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x57, 0x65, 0x62, 0x73,
|
||||
0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x63, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x3c, 0x0a, 0x19, 0x62, 0x61,
|
||||
0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x50, 0x65, 0x72, 0x4e,
|
||||
0x6f, 0x64, 0x65, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x19, 0x62,
|
||||
0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x50, 0x65, 0x72,
|
||||
0x4e, 0x6f, 0x64, 0x65, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x28, 0x0a, 0x0f, 0x68, 0x61, 0x73, 0x46,
|
||||
0x75, 0x6c, 0x6c, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28,
|
||||
0x08, 0x52, 0x0f, 0x68, 0x61, 0x73, 0x46, 0x75, 0x6c, 0x6c, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72,
|
||||
0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x4a, 0x53,
|
||||
0x4f, 0x4e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72,
|
||||
0x65, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x69, 0x63, 0x65, 0x54,
|
||||
0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x69, 0x63, 0x65,
|
||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x50,
|
||||
0x72, 0x69, 0x63, 0x65, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10,
|
||||
0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x50, 0x72, 0x69, 0x63, 0x65, 0x4a, 0x53, 0x4f, 0x4e,
|
||||
0x12, 0x2e, 0x0a, 0x12, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x50, 0x72, 0x69,
|
||||
0x63, 0x65, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x62, 0x61,
|
||||
0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x50, 0x72, 0x69, 0x63, 0x65, 0x4a, 0x53, 0x4f, 0x4e,
|
||||
0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65,
|
||||
0x18, 0x09, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x50,
|
||||
0x72, 0x69, 0x63, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x61, 0x6c,
|
||||
0x6c, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0f, 0x73,
|
||||
0x65, 0x61, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x6c, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x20,
|
||||
0x0a, 0x0b, 0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x0b, 0x20,
|
||||
0x01, 0x28, 0x01, 0x52, 0x0b, 0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65,
|
||||
0x12, 0x22, 0x0a, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73,
|
||||
0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x73, 0x12, 0x3c, 0x0a, 0x19, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x19, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x12, 0x2a, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x6f,
|
||||
0x74, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x24,
|
||||
0x0a, 0x0d, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18,
|
||||
0x10, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6d,
|
||||
0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x3c,
|
||||
0x0a, 0x19, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74,
|
||||
0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x12, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x19, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x40, 0x0a, 0x1b,
|
||||
0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74,
|
||||
0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x13, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x1b, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63,
|
||||
0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2c,
|
||||
0x0a, 0x11, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x4a,
|
||||
0x53, 0x4f, 0x4e, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x6d, 0x61, 0x78, 0x55, 0x70,
|
||||
0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x4a, 0x53, 0x4f, 0x4e, 0x42, 0x06, 0x5a, 0x04,
|
||||
0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
246
pkg/rpc/pb/model_post.pb.go
Normal file
246
pkg/rpc/pb/model_post.pb.go
Normal file
@@ -0,0 +1,246 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v3.19.4
|
||||
// source: models/model_post.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 文章
|
||||
type Post struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // ID
|
||||
PostCategoryId int64 `protobuf:"varint,2,opt,name=postCategoryId,proto3" json:"postCategoryId,omitempty"` // 分类ID
|
||||
ProductCode string `protobuf:"bytes,3,opt,name=productCode,proto3" json:"productCode,omitempty"` // 产品代号
|
||||
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"` // 类型:normal, url
|
||||
Subject string `protobuf:"bytes,5,opt,name=subject,proto3" json:"subject,omitempty"` // 标题
|
||||
Url string `protobuf:"bytes,6,opt,name=url,proto3" json:"url,omitempty"` // URL
|
||||
Body string `protobuf:"bytes,7,opt,name=body,proto3" json:"body,omitempty"` // 内容
|
||||
CreatedAt int64 `protobuf:"varint,8,opt,name=createdAt,proto3" json:"createdAt,omitempty"` // 创建时间
|
||||
IsPublished bool `protobuf:"varint,9,opt,name=isPublished,proto3" json:"isPublished,omitempty"` // 是否已发布
|
||||
PublishedAt int64 `protobuf:"varint,10,opt,name=publishedAt,proto3" json:"publishedAt,omitempty"` // 发布时间
|
||||
PostCategory *PostCategory `protobuf:"bytes,30,opt,name=postCategory,proto3" json:"postCategory,omitempty"` // 分类信息
|
||||
}
|
||||
|
||||
func (x *Post) Reset() {
|
||||
*x = Post{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_models_model_post_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Post) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Post) ProtoMessage() {}
|
||||
|
||||
func (x *Post) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_models_model_post_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Post.ProtoReflect.Descriptor instead.
|
||||
func (*Post) Descriptor() ([]byte, []int) {
|
||||
return file_models_model_post_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Post) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Post) GetPostCategoryId() int64 {
|
||||
if x != nil {
|
||||
return x.PostCategoryId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Post) GetProductCode() string {
|
||||
if x != nil {
|
||||
return x.ProductCode
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Post) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Post) GetSubject() string {
|
||||
if x != nil {
|
||||
return x.Subject
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Post) GetUrl() string {
|
||||
if x != nil {
|
||||
return x.Url
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Post) GetBody() string {
|
||||
if x != nil {
|
||||
return x.Body
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Post) GetCreatedAt() int64 {
|
||||
if x != nil {
|
||||
return x.CreatedAt
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Post) GetIsPublished() bool {
|
||||
if x != nil {
|
||||
return x.IsPublished
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *Post) GetPublishedAt() int64 {
|
||||
if x != nil {
|
||||
return x.PublishedAt
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Post) GetPostCategory() *PostCategory {
|
||||
if x != nil {
|
||||
return x.PostCategory
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_models_model_post_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_post_proto_rawDesc = []byte{
|
||||
0x0a, 0x17, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x70,
|
||||
0x6f, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x20, 0x6d,
|
||||
0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x70, 0x6f, 0x73, 0x74,
|
||||
0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0xcc, 0x02, 0x0a, 0x04, 0x50, 0x6f, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x6f, 0x73, 0x74,
|
||||
0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x0e, 0x70, 0x6f, 0x73, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64,
|
||||
0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x43, 0x6f,
|
||||
0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75,
|
||||
0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
|
||||
0x64, 0x41, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74,
|
||||
0x65, 0x64, 0x41, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x73, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73,
|
||||
0x68, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x50, 0x75, 0x62,
|
||||
0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73,
|
||||
0x68, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x70, 0x75, 0x62,
|
||||
0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x41, 0x74, 0x12, 0x34, 0x0a, 0x0c, 0x70, 0x6f, 0x73, 0x74,
|
||||
0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10,
|
||||
0x2e, 0x70, 0x62, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
|
||||
0x52, 0x0c, 0x70, 0x6f, 0x73, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x42, 0x06,
|
||||
0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_models_model_post_proto_rawDescOnce sync.Once
|
||||
file_models_model_post_proto_rawDescData = file_models_model_post_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_models_model_post_proto_rawDescGZIP() []byte {
|
||||
file_models_model_post_proto_rawDescOnce.Do(func() {
|
||||
file_models_model_post_proto_rawDescData = protoimpl.X.CompressGZIP(file_models_model_post_proto_rawDescData)
|
||||
})
|
||||
return file_models_model_post_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_models_model_post_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_models_model_post_proto_goTypes = []interface{}{
|
||||
(*Post)(nil), // 0: pb.Post
|
||||
(*PostCategory)(nil), // 1: pb.PostCategory
|
||||
}
|
||||
var file_models_model_post_proto_depIdxs = []int32{
|
||||
1, // 0: pb.Post.postCategory:type_name -> pb.PostCategory
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_models_model_post_proto_init() }
|
||||
func file_models_model_post_proto_init() {
|
||||
if File_models_model_post_proto != nil {
|
||||
return
|
||||
}
|
||||
file_models_model_post_category_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_models_model_post_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Post); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_models_model_post_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_models_model_post_proto_goTypes,
|
||||
DependencyIndexes: file_models_model_post_proto_depIdxs,
|
||||
MessageInfos: file_models_model_post_proto_msgTypes,
|
||||
}.Build()
|
||||
File_models_model_post_proto = out.File
|
||||
file_models_model_post_proto_rawDesc = nil
|
||||
file_models_model_post_proto_goTypes = nil
|
||||
file_models_model_post_proto_depIdxs = nil
|
||||
}
|
||||
171
pkg/rpc/pb/model_post_category.pb.go
Normal file
171
pkg/rpc/pb/model_post_category.pb.go
Normal file
@@ -0,0 +1,171 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v3.19.4
|
||||
// source: models/model_post_category.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 文章分类
|
||||
type PostCategory struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // ID
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // 名称
|
||||
Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` // 文章代号
|
||||
IsOn bool `protobuf:"varint,4,opt,name=isOn,proto3" json:"isOn,omitempty"` // 是否启用
|
||||
}
|
||||
|
||||
func (x *PostCategory) Reset() {
|
||||
*x = PostCategory{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_models_model_post_category_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PostCategory) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PostCategory) ProtoMessage() {}
|
||||
|
||||
func (x *PostCategory) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_models_model_post_category_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PostCategory.ProtoReflect.Descriptor instead.
|
||||
func (*PostCategory) Descriptor() ([]byte, []int) {
|
||||
return file_models_model_post_category_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *PostCategory) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PostCategory) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PostCategory) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PostCategory) GetIsOn() bool {
|
||||
if x != nil {
|
||||
return x.IsOn
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_models_model_post_category_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_post_category_proto_rawDesc = []byte{
|
||||
0x0a, 0x20, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x70,
|
||||
0x6f, 0x73, 0x74, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x5a, 0x0a, 0x0c, 0x50, 0x6f, 0x73, 0x74, 0x43, 0x61,
|
||||
0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f,
|
||||
0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73,
|
||||
0x4f, 0x6e, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_models_model_post_category_proto_rawDescOnce sync.Once
|
||||
file_models_model_post_category_proto_rawDescData = file_models_model_post_category_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_models_model_post_category_proto_rawDescGZIP() []byte {
|
||||
file_models_model_post_category_proto_rawDescOnce.Do(func() {
|
||||
file_models_model_post_category_proto_rawDescData = protoimpl.X.CompressGZIP(file_models_model_post_category_proto_rawDescData)
|
||||
})
|
||||
return file_models_model_post_category_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_models_model_post_category_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_models_model_post_category_proto_goTypes = []interface{}{
|
||||
(*PostCategory)(nil), // 0: pb.PostCategory
|
||||
}
|
||||
var file_models_model_post_category_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_models_model_post_category_proto_init() }
|
||||
func file_models_model_post_category_proto_init() {
|
||||
if File_models_model_post_category_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_models_model_post_category_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PostCategory); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_models_model_post_category_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_models_model_post_category_proto_goTypes,
|
||||
DependencyIndexes: file_models_model_post_category_proto_depIdxs,
|
||||
MessageInfos: file_models_model_post_category_proto_msgTypes,
|
||||
}.Build()
|
||||
File_models_model_post_category_proto = out.File
|
||||
file_models_model_post_category_proto_rawDesc = nil
|
||||
file_models_model_post_category_proto_goTypes = nil
|
||||
file_models_model_post_category_proto_depIdxs = nil
|
||||
}
|
||||
@@ -33,7 +33,8 @@ type RegionCountry struct {
|
||||
CustomName string `protobuf:"bytes,5,opt,name=customName,proto3" json:"customName,omitempty"`
|
||||
CustomCodes []string `protobuf:"bytes,6,rep,name=customCodes,proto3" json:"customCodes,omitempty"`
|
||||
DisplayName string `protobuf:"bytes,7,opt,name=displayName,proto3" json:"displayName,omitempty"`
|
||||
IsCommon bool `protobuf:"varint,8,opt,name=isCommon,proto3" json:"isCommon,omitempty"` // 是否常用
|
||||
IsCommon bool `protobuf:"varint,8,opt,name=isCommon,proto3" json:"isCommon,omitempty"` // 是否常用
|
||||
RouteCode string `protobuf:"bytes,9,opt,name=routeCode,proto3" json:"routeCode,omitempty"` // 线路代号
|
||||
}
|
||||
|
||||
func (x *RegionCountry) Reset() {
|
||||
@@ -124,12 +125,19 @@ func (x *RegionCountry) GetIsCommon() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *RegionCountry) GetRouteCode() string {
|
||||
if x != nil {
|
||||
return x.RouteCode
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_models_model_region_country_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_region_country_proto_rawDesc = []byte{
|
||||
0x0a, 0x21, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x72,
|
||||
0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xe1, 0x01, 0x0a, 0x0d, 0x52, 0x65, 0x67, 0x69,
|
||||
0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xff, 0x01, 0x0a, 0x0d, 0x52, 0x65, 0x67, 0x69,
|
||||
0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
|
||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a,
|
||||
@@ -143,8 +151,10 @@ var file_models_model_region_country_proto_rawDesc = []byte{
|
||||
0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x69, 0x73, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28,
|
||||
0x08, 0x52, 0x08, 0x69, 0x73, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x08, 0x52, 0x08, 0x69, 0x73, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x72,
|
||||
0x6f, 0x75, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||
0x72, 0x6f, 0x75, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -20,18 +20,20 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// 省份|州|区域信息
|
||||
type RegionProvince struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Codes []string `protobuf:"bytes,3,rep,name=codes,proto3" json:"codes,omitempty"`
|
||||
RegionCountryId int64 `protobuf:"varint,4,opt,name=regionCountryId,proto3" json:"regionCountryId,omitempty"`
|
||||
CustomName string `protobuf:"bytes,5,opt,name=customName,proto3" json:"customName,omitempty"`
|
||||
CustomCodes []string `protobuf:"bytes,6,rep,name=customCodes,proto3" json:"customCodes,omitempty"`
|
||||
DisplayName string `protobuf:"bytes,7,opt,name=displayName,proto3" json:"displayName,omitempty"`
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Codes []string `protobuf:"bytes,3,rep,name=codes,proto3" json:"codes,omitempty"`
|
||||
RegionCountryId int64 `protobuf:"varint,4,opt,name=regionCountryId,proto3" json:"regionCountryId,omitempty"`
|
||||
CustomName string `protobuf:"bytes,5,opt,name=customName,proto3" json:"customName,omitempty"`
|
||||
CustomCodes []string `protobuf:"bytes,6,rep,name=customCodes,proto3" json:"customCodes,omitempty"`
|
||||
DisplayName string `protobuf:"bytes,7,opt,name=displayName,proto3" json:"displayName,omitempty"`
|
||||
RegionCountry *RegionCountry `protobuf:"bytes,30,opt,name=regionCountry,proto3" json:"regionCountry,omitempty"` // 国家|地区信息
|
||||
}
|
||||
|
||||
func (x *RegionProvince) Reset() {
|
||||
@@ -115,27 +117,39 @@ func (x *RegionProvince) GetDisplayName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RegionProvince) GetRegionCountry() *RegionCountry {
|
||||
if x != nil {
|
||||
return x.RegionCountry
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_models_model_region_province_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_region_province_proto_rawDesc = []byte{
|
||||
0x0a, 0x22, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x72,
|
||||
0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xd8, 0x01, 0x0a, 0x0e, 0x52, 0x65, 0x67,
|
||||
0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e,
|
||||
0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
|
||||
0x14, 0x0a, 0x05, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05,
|
||||
0x63, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x43,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f,
|
||||
0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x49, 0x64, 0x12,
|
||||
0x1e, 0x0a, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12,
|
||||
0x20, 0x0a, 0x0b, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x06,
|
||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x64, 0x65,
|
||||
0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65,
|
||||
0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e,
|
||||
0x61, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x21, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73,
|
||||
0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x91, 0x02, 0x0a, 0x0e,
|
||||
0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28,
|
||||
0x09, 0x52, 0x05, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x65, 0x67, 0x69,
|
||||
0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x0f, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79,
|
||||
0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4e, 0x61, 0x6d, 0x65,
|
||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4e, 0x61,
|
||||
0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x6f, 0x64, 0x65,
|
||||
0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43,
|
||||
0x6f, 0x64, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e,
|
||||
0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c,
|
||||
0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x0d, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e,
|
||||
0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e,
|
||||
0x70, 0x62, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79,
|
||||
0x52, 0x0d, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x42,
|
||||
0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -153,13 +167,15 @@ func file_models_model_region_province_proto_rawDescGZIP() []byte {
|
||||
var file_models_model_region_province_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_models_model_region_province_proto_goTypes = []interface{}{
|
||||
(*RegionProvince)(nil), // 0: pb.RegionProvince
|
||||
(*RegionCountry)(nil), // 1: pb.RegionCountry
|
||||
}
|
||||
var file_models_model_region_province_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
1, // 0: pb.RegionProvince.regionCountry:type_name -> pb.RegionCountry
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_models_model_region_province_proto_init() }
|
||||
@@ -167,6 +183,7 @@ func file_models_model_region_province_proto_init() {
|
||||
if File_models_model_region_province_proto != nil {
|
||||
return
|
||||
}
|
||||
file_models_model_region_country_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_models_model_region_province_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*RegionProvince); i {
|
||||
|
||||
@@ -50,7 +50,6 @@ type Server struct {
|
||||
HttpsJSON []byte `protobuf:"bytes,10,opt,name=httpsJSON,proto3" json:"httpsJSON,omitempty"`
|
||||
TcpJSON []byte `protobuf:"bytes,11,opt,name=tcpJSON,proto3" json:"tcpJSON,omitempty"`
|
||||
TlsJSON []byte `protobuf:"bytes,12,opt,name=tlsJSON,proto3" json:"tlsJSON,omitempty"`
|
||||
UnixJSON []byte `protobuf:"bytes,13,opt,name=unixJSON,proto3" json:"unixJSON,omitempty"`
|
||||
UdpJSON []byte `protobuf:"bytes,14,opt,name=udpJSON,proto3" json:"udpJSON,omitempty"`
|
||||
WebId int64 `protobuf:"varint,15,opt,name=webId,proto3" json:"webId,omitempty"`
|
||||
ReverseProxyJSON []byte `protobuf:"bytes,16,opt,name=reverseProxyJSON,proto3" json:"reverseProxyJSON,omitempty"`
|
||||
@@ -263,13 +262,6 @@ func (x *Server) GetTlsJSON() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Server) GetUnixJSON() []byte {
|
||||
if x != nil {
|
||||
return x.UnixJSON
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Server) GetUdpJSON() []byte {
|
||||
if x != nil {
|
||||
return x.UdpJSON
|
||||
@@ -353,7 +345,7 @@ var file_models_model_server_proto_rawDesc = []byte{
|
||||
0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x6d, 0x6f, 0x64, 0x65,
|
||||
0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x61, 0x75, 0x64, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65,
|
||||
0x73, 0x75, 0x6c, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbc, 0x09, 0x0a, 0x06, 0x53,
|
||||
0x73, 0x75, 0x6c, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa0, 0x09, 0x0a, 0x06, 0x53,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x18, 0x12, 0x20,
|
||||
0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||
@@ -403,34 +395,32 @@ var file_models_model_server_proto_rawDesc = []byte{
|
||||
0x4e, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0b, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x52, 0x07, 0x74, 0x63, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x74,
|
||||
0x6c, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x6c,
|
||||
0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x69, 0x78, 0x4a, 0x53, 0x4f,
|
||||
0x4e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x75, 0x6e, 0x69, 0x78, 0x4a, 0x53, 0x4f,
|
||||
0x4e, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x0e, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x52, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x14, 0x0a, 0x05, 0x77,
|
||||
0x65, 0x62, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x77, 0x65, 0x62, 0x49,
|
||||
0x64, 0x12, 0x2a, 0x0a, 0x10, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78,
|
||||
0x79, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x72, 0x65, 0x76,
|
||||
0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x24, 0x0a,
|
||||
0x0d, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x1a,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x54,
|
||||
0x69, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68,
|
||||
0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x62, 0x61, 0x6e,
|
||||
0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x22, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x0d, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x73, 0x12, 0x30, 0x0a, 0x13, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x23, 0x20, 0x01, 0x28, 0x03, 0x52, 0x13,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x73, 0x12, 0x31, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74,
|
||||
0x65, 0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f,
|
||||
0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43,
|
||||
0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70,
|
||||
0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0c, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0x1c, 0x0a, 0x04, 0x75,
|
||||
0x73, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x55,
|
||||
0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e,
|
||||
0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x75, 0x64, 0x70, 0x4a, 0x53, 0x4f, 0x4e, 0x12,
|
||||
0x14, 0x0a, 0x05, 0x77, 0x65, 0x62, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05,
|
||||
0x77, 0x65, 0x62, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65,
|
||||
0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
||||
0x10, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4a, 0x53, 0x4f,
|
||||
0x4e, 0x12, 0x24, 0x0a, 0x0d, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x54, 0x69,
|
||||
0x6d, 0x65, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69,
|
||||
0x64, 0x74, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x62, 0x61, 0x6e, 0x64, 0x77,
|
||||
0x69, 0x64, 0x74, 0x68, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x0e, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12,
|
||||
0x24, 0x0a, 0x0d, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73,
|
||||
0x18, 0x22, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x30, 0x0a, 0x13, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x74,
|
||||
0x74, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x23, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x13, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x6b, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x31, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43,
|
||||
0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70,
|
||||
0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x0b, 0x6e,
|
||||
0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x0c, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, 0x1f, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75,
|
||||
0x70, 0x52, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12,
|
||||
0x1c, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e,
|
||||
0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -42,6 +42,7 @@ type ServerBandwidthStat struct {
|
||||
CountAttackRequests int64 `protobuf:"varint,14,opt,name=countAttackRequests,proto3" json:"countAttackRequests,omitempty"` // 总攻击请求数
|
||||
UserPlanId int64 `protobuf:"varint,15,opt,name=userPlanId,proto3" json:"userPlanId,omitempty"` // 绑定的用户套餐ID
|
||||
CountWebsocketConnections int64 `protobuf:"varint,16,opt,name=countWebsocketConnections,proto3" json:"countWebsocketConnections,omitempty"` // Websocket连接数
|
||||
CountIPs int64 `protobuf:"varint,17,opt,name=countIPs,proto3" json:"countIPs,omitempty"` // 总IP数
|
||||
}
|
||||
|
||||
func (x *ServerBandwidthStat) Reset() {
|
||||
@@ -188,12 +189,19 @@ func (x *ServerBandwidthStat) GetCountWebsocketConnections() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ServerBandwidthStat) GetCountIPs() int64 {
|
||||
if x != nil {
|
||||
return x.CountIPs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_models_model_server_bandwidth_stat_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_server_bandwidth_stat_proto_rawDesc = []byte{
|
||||
0x0a, 0x28, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x5f,
|
||||
0x73, 0x74, 0x61, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x9d,
|
||||
0x73, 0x74, 0x61, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xb9,
|
||||
0x04, 0x0a, 0x13, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x42, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64,
|
||||
0x74, 0x68, 0x53, 0x74, 0x61, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
|
||||
@@ -227,8 +235,10 @@ var file_models_model_server_bandwidth_stat_proto_rawDesc = []byte{
|
||||
0x12, 0x3c, 0x0a, 0x19, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b,
|
||||
0x65, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x10, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x19, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63,
|
||||
0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x06,
|
||||
0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x50, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x08, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x50, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -37,11 +37,12 @@ type ServerDailyStat struct {
|
||||
CountAttackRequests int64 `protobuf:"varint,8,opt,name=countAttackRequests,proto3" json:"countAttackRequests,omitempty"`
|
||||
AttackBytes int64 `protobuf:"varint,9,opt,name=attackBytes,proto3" json:"attackBytes,omitempty"`
|
||||
CheckTrafficLimiting bool `protobuf:"varint,10,opt,name=checkTrafficLimiting,proto3" json:"checkTrafficLimiting,omitempty"`
|
||||
PlanId int64 `protobuf:"varint,11,opt,name=planId,proto3" json:"planId,omitempty"`
|
||||
Day string `protobuf:"bytes,12,opt,name=day,proto3" json:"day,omitempty"`
|
||||
PlanId int64 `protobuf:"varint,11,opt,name=planId,proto3" json:"planId,omitempty"` // 套餐ID
|
||||
Day string `protobuf:"bytes,12,opt,name=day,proto3" json:"day,omitempty"` // 日期 YYYYMMDD
|
||||
Hour string `protobuf:"bytes,13,opt,name=hour,proto3" json:"hour,omitempty"`
|
||||
TimeFrom string `protobuf:"bytes,14,opt,name=timeFrom,proto3" json:"timeFrom,omitempty"`
|
||||
TimeTo string `protobuf:"bytes,15,opt,name=timeTo,proto3" json:"timeTo,omitempty"`
|
||||
CountIPs int64 `protobuf:"varint,17,opt,name=countIPs,proto3" json:"countIPs,omitempty"` // 独立IP数量
|
||||
}
|
||||
|
||||
func (x *ServerDailyStat) Reset() {
|
||||
@@ -188,12 +189,19 @@ func (x *ServerDailyStat) GetTimeTo() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ServerDailyStat) GetCountIPs() int64 {
|
||||
if x != nil {
|
||||
return x.CountIPs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_models_model_server_daily_stat_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_server_daily_stat_proto_rawDesc = []byte{
|
||||
0x0a, 0x24, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x73, 0x74, 0x61, 0x74,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x91, 0x04, 0x0a, 0x0f, 0x53,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0xad, 0x04, 0x0a, 0x0f, 0x53,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x44, 0x61, 0x69, 0x6c, 0x79, 0x53, 0x74, 0x61, 0x74, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73,
|
||||
@@ -226,8 +234,10 @@ var file_models_model_server_daily_stat_proto_rawDesc = []byte{
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x75, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x69, 0x6d, 0x65, 0x54, 0x6f,
|
||||
0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x69, 0x6d, 0x65, 0x54, 0x6f, 0x42, 0x06,
|
||||
0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x69, 0x6d, 0x65, 0x54, 0x6f, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x50, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x08, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x50, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,7 @@ const (
|
||||
AdminService_LoginAdmin_FullMethodName = "/pb.AdminService/loginAdmin"
|
||||
AdminService_CheckAdminExists_FullMethodName = "/pb.AdminService/checkAdminExists"
|
||||
AdminService_CheckAdminUsername_FullMethodName = "/pb.AdminService/checkAdminUsername"
|
||||
AdminService_FindAdminWithUsername_FullMethodName = "/pb.AdminService/findAdminWithUsername"
|
||||
AdminService_FindAdminFullname_FullMethodName = "/pb.AdminService/findAdminFullname"
|
||||
AdminService_FindEnabledAdmin_FullMethodName = "/pb.AdminService/findEnabledAdmin"
|
||||
AdminService_CreateOrUpdateAdmin_FullMethodName = "/pb.AdminService/createOrUpdateAdmin"
|
||||
@@ -47,8 +48,10 @@ type AdminServiceClient interface {
|
||||
LoginAdmin(ctx context.Context, in *LoginAdminRequest, opts ...grpc.CallOption) (*LoginAdminResponse, error)
|
||||
// 检查管理员是否存在
|
||||
CheckAdminExists(ctx context.Context, in *CheckAdminExistsRequest, opts ...grpc.CallOption) (*CheckAdminExistsResponse, error)
|
||||
// 检查用户名是否存在
|
||||
// 检查管理员用户名是否存在
|
||||
CheckAdminUsername(ctx context.Context, in *CheckAdminUsernameRequest, opts ...grpc.CallOption) (*CheckAdminUsernameResponse, error)
|
||||
// 使用用管理员户名查找管理员信息
|
||||
FindAdminWithUsername(ctx context.Context, in *FindAdminWithUsernameRequest, opts ...grpc.CallOption) (*FindAdminWithUsernameResponse, error)
|
||||
// 获取管理员名称
|
||||
FindAdminFullname(ctx context.Context, in *FindAdminFullnameRequest, opts ...grpc.CallOption) (*FindAdminFullnameResponse, error)
|
||||
// 获取管理员信息
|
||||
@@ -116,6 +119,15 @@ func (c *adminServiceClient) CheckAdminUsername(ctx context.Context, in *CheckAd
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *adminServiceClient) FindAdminWithUsername(ctx context.Context, in *FindAdminWithUsernameRequest, opts ...grpc.CallOption) (*FindAdminWithUsernameResponse, error) {
|
||||
out := new(FindAdminWithUsernameResponse)
|
||||
err := c.cc.Invoke(ctx, AdminService_FindAdminWithUsername_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *adminServiceClient) FindAdminFullname(ctx context.Context, in *FindAdminFullnameRequest, opts ...grpc.CallOption) (*FindAdminFullnameResponse, error) {
|
||||
out := new(FindAdminFullnameResponse)
|
||||
err := c.cc.Invoke(ctx, AdminService_FindAdminFullname_FullMethodName, in, out, opts...)
|
||||
@@ -259,8 +271,10 @@ type AdminServiceServer interface {
|
||||
LoginAdmin(context.Context, *LoginAdminRequest) (*LoginAdminResponse, error)
|
||||
// 检查管理员是否存在
|
||||
CheckAdminExists(context.Context, *CheckAdminExistsRequest) (*CheckAdminExistsResponse, error)
|
||||
// 检查用户名是否存在
|
||||
// 检查管理员用户名是否存在
|
||||
CheckAdminUsername(context.Context, *CheckAdminUsernameRequest) (*CheckAdminUsernameResponse, error)
|
||||
// 使用用管理员户名查找管理员信息
|
||||
FindAdminWithUsername(context.Context, *FindAdminWithUsernameRequest) (*FindAdminWithUsernameResponse, error)
|
||||
// 获取管理员名称
|
||||
FindAdminFullname(context.Context, *FindAdminFullnameRequest) (*FindAdminFullnameResponse, error)
|
||||
// 获取管理员信息
|
||||
@@ -306,6 +320,9 @@ func (UnimplementedAdminServiceServer) CheckAdminExists(context.Context, *CheckA
|
||||
func (UnimplementedAdminServiceServer) CheckAdminUsername(context.Context, *CheckAdminUsernameRequest) (*CheckAdminUsernameResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CheckAdminUsername not implemented")
|
||||
}
|
||||
func (UnimplementedAdminServiceServer) FindAdminWithUsername(context.Context, *FindAdminWithUsernameRequest) (*FindAdminWithUsernameResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FindAdminWithUsername not implemented")
|
||||
}
|
||||
func (UnimplementedAdminServiceServer) FindAdminFullname(context.Context, *FindAdminFullnameRequest) (*FindAdminFullnameResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FindAdminFullname not implemented")
|
||||
}
|
||||
@@ -417,6 +434,24 @@ func _AdminService_CheckAdminUsername_Handler(srv interface{}, ctx context.Conte
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AdminService_FindAdminWithUsername_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindAdminWithUsernameRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AdminServiceServer).FindAdminWithUsername(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AdminService_FindAdminWithUsername_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AdminServiceServer).FindAdminWithUsername(ctx, req.(*FindAdminWithUsernameRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AdminService_FindAdminFullname_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FindAdminFullnameRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -706,6 +741,10 @@ var AdminService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "checkAdminUsername",
|
||||
Handler: _AdminService_CheckAdminUsername_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "findAdminWithUsername",
|
||||
Handler: _AdminService_FindAdminWithUsername_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "findAdminFullname",
|
||||
Handler: _AdminService_FindAdminFullname_Handler,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user