Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57247d0f5b | ||
|
|
813267c50f | ||
|
|
b8078e73b2 | ||
|
|
f958c57984 | ||
|
|
30bfbdc01e | ||
|
|
314362c24d | ||
|
|
8582715be7 | ||
|
|
74e585263c |
7
go.mod
7
go.mod
@@ -1,6 +1,6 @@
|
|||||||
module github.com/TeaOSLab/EdgeAPI
|
module github.com/TeaOSLab/EdgeAPI
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
replace github.com/TeaOSLab/EdgeCommon => ../EdgeCommon
|
replace github.com/TeaOSLab/EdgeCommon => ../EdgeCommon
|
||||||
|
|
||||||
@@ -12,13 +12,12 @@ require (
|
|||||||
github.com/go-acme/lego/v4 v4.5.2
|
github.com/go-acme/lego/v4 v4.5.2
|
||||||
github.com/go-sql-driver/mysql v1.5.0
|
github.com/go-sql-driver/mysql v1.5.0
|
||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.5.2
|
||||||
github.com/iwind/TeaGo v0.0.0-20220304043459-0dd944a5b475
|
github.com/iwind/TeaGo v0.0.0-20220321132348-7da816422f25 // indirect
|
||||||
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3
|
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/mozillazg/go-pinyin v0.18.0
|
github.com/mozillazg/go-pinyin v0.18.0
|
||||||
github.com/pkg/sftp v1.12.0
|
github.com/pkg/sftp v1.12.0
|
||||||
github.com/shirou/gopsutil/v3 v3.22.2 // indirect
|
github.com/shirou/gopsutil/v3 v3.22.2
|
||||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
|
||||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
|
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
|
||||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8
|
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8
|
||||||
google.golang.org/grpc v1.45.0
|
google.golang.org/grpc v1.45.0
|
||||||
|
|||||||
23
go.sum
23
go.sum
@@ -176,7 +176,6 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
|
|||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
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.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
||||||
@@ -238,8 +237,13 @@ github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df/go.mod h1:QMZY7/J/KSQEhK
|
|||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/infobloxopen/infoblox-go-client v1.1.1/go.mod h1:BXiw7S2b9qJoM8MS40vfgCNB2NLHGusk1DtO16BD9zI=
|
github.com/infobloxopen/infoblox-go-client v1.1.1/go.mod h1:BXiw7S2b9qJoM8MS40vfgCNB2NLHGusk1DtO16BD9zI=
|
||||||
github.com/iwind/TeaGo v0.0.0-20210411134150-ddf57e240c2f/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
|
github.com/iwind/TeaGo v0.0.0-20210411134150-ddf57e240c2f/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
|
||||||
github.com/iwind/TeaGo v0.0.0-20220304043459-0dd944a5b475 h1:EseyfFaQOjWanGiby9KMw7PjDBMg/95tLDgIw/ns0Cw=
|
|
||||||
github.com/iwind/TeaGo v0.0.0-20220304043459-0dd944a5b475/go.mod h1:HRHK0zoC/og3c9/hKosD9yYVMTnnzm3PgXUdhRYHaLc=
|
github.com/iwind/TeaGo v0.0.0-20220304043459-0dd944a5b475/go.mod h1:HRHK0zoC/og3c9/hKosD9yYVMTnnzm3PgXUdhRYHaLc=
|
||||||
|
github.com/iwind/TeaGo v0.0.0-20220321112016-5a2cd71d3151 h1:jksmjwlGC8QMpyHZmzxr7J+3NeMOr9Zy2+yNJxVSIjI=
|
||||||
|
github.com/iwind/TeaGo v0.0.0-20220321112016-5a2cd71d3151/go.mod h1:HRHK0zoC/og3c9/hKosD9yYVMTnnzm3PgXUdhRYHaLc=
|
||||||
|
github.com/iwind/TeaGo v0.0.0-20220321131553-fd7b112ba7e7 h1:gdMQZQk/aXfNuKuWCBQhP3byy5Dr8XHMe5+GXdGHcPQ=
|
||||||
|
github.com/iwind/TeaGo v0.0.0-20220321131553-fd7b112ba7e7/go.mod h1:HRHK0zoC/og3c9/hKosD9yYVMTnnzm3PgXUdhRYHaLc=
|
||||||
|
github.com/iwind/TeaGo v0.0.0-20220321132348-7da816422f25 h1:UpJ52iq8FEz2OeaXFhW1kuYeqVRUQ/5N+NVHvVuTnvw=
|
||||||
|
github.com/iwind/TeaGo v0.0.0-20220321132348-7da816422f25/go.mod h1:HRHK0zoC/og3c9/hKosD9yYVMTnnzm3PgXUdhRYHaLc=
|
||||||
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3 h1:aBSonas7vFcgTj9u96/bWGILGv1ZbUSTLiOzcI1ZT6c=
|
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3 h1:aBSonas7vFcgTj9u96/bWGILGv1ZbUSTLiOzcI1ZT6c=
|
||||||
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA=
|
github.com/iwind/gosock v0.0.0-20210722083328-12b2d66abec3/go.mod h1:H5Q7SXwbx3a97ecJkaS2sD77gspzE7HFUafBO0peEyA=
|
||||||
github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
|
github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
|
||||||
@@ -283,6 +287,7 @@ github.com/liquidweb/go-lwApi v0.0.0-20190605172801-52a4864d2738/go.mod h1:0sYF9
|
|||||||
github.com/liquidweb/go-lwApi v0.0.5/go.mod h1:0sYF9rMXb0vlG+4SzdiGMXHheCZxjguMq+Zb4S2BfBs=
|
github.com/liquidweb/go-lwApi v0.0.5/go.mod h1:0sYF9rMXb0vlG+4SzdiGMXHheCZxjguMq+Zb4S2BfBs=
|
||||||
github.com/liquidweb/liquidweb-cli v0.6.9/go.mod h1:cE1uvQ+x24NGUL75D0QagOFCG8Wdvmwu8aL9TLmA/eQ=
|
github.com/liquidweb/liquidweb-cli v0.6.9/go.mod h1:cE1uvQ+x24NGUL75D0QagOFCG8Wdvmwu8aL9TLmA/eQ=
|
||||||
github.com/liquidweb/liquidweb-go v1.6.3/go.mod h1:SuXXp+thr28LnjEw18AYtWwIbWMHSUiajPQs8T9c/Rc=
|
github.com/liquidweb/liquidweb-go v1.6.3/go.mod h1:SuXXp+thr28LnjEw18AYtWwIbWMHSUiajPQs8T9c/Rc=
|
||||||
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||||
@@ -371,6 +376,7 @@ github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw
|
|||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||||
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||||
github.com/pquerna/otp v1.3.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
|
github.com/pquerna/otp v1.3.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
@@ -398,8 +404,6 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
|
|||||||
github.com/sacloud/libsacloud v1.36.2/go.mod h1:P7YAOVmnIn3DKHqCZcUKYUXmSwGBm3yS7IBEjKVSrjg=
|
github.com/sacloud/libsacloud v1.36.2/go.mod h1:P7YAOVmnIn3DKHqCZcUKYUXmSwGBm3yS7IBEjKVSrjg=
|
||||||
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210127161313-bd30bebeac4f/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
|
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210127161313-bd30bebeac4f/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
|
||||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||||
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
|
|
||||||
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
|
||||||
github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks=
|
github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks=
|
||||||
github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY=
|
github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
@@ -440,12 +444,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/tklauser/go-sysconf v0.3.6 h1:oc1sJWvKkmvIxhDHeKWvZS4f6AW+YcoguSfRF2/Hmo4=
|
|
||||||
github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
|
|
||||||
github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo=
|
github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo=
|
||||||
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
|
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
|
||||||
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
|
|
||||||
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
|
|
||||||
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
|
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
|
||||||
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
|
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
@@ -627,7 +627,6 @@ golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/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-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@@ -635,8 +634,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs=
|
|
||||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
|
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
|
||||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
@@ -735,8 +732,6 @@ google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfG
|
|||||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
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-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
google.golang.org/genproto v0.0.0-20220303160752-862486edd9cc h1:fb/ViRpv3ln/LvbqZtTpoOd1YQDNH12gaGZreoSFovE=
|
|
||||||
google.golang.org/genproto v0.0.0-20220303160752-862486edd9cc/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI=
|
|
||||||
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e h1:fNKDNuUyC4WH+inqDMpfXDdfvwfYILbsX+oskGZ8hxg=
|
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/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.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
@@ -750,8 +745,6 @@ google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
|
|||||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
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.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||||
google.golang.org/grpc v1.44.0 h1:weqSxi/TMs1SqFRMHCtBgXRs8k3X39QIDEZ0pRcttUg=
|
|
||||||
google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
|
||||||
google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M=
|
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/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-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func (this *StorageManager) Loop() error {
|
|||||||
}
|
}
|
||||||
var policyIds = []int64{}
|
var policyIds = []int64{}
|
||||||
for _, policy := range policies {
|
for _, policy := range policies {
|
||||||
if policy.IsOn == 1 {
|
if policy.IsOn {
|
||||||
policyIds = append(policyIds, int64(policy.Id))
|
policyIds = append(policyIds, int64(policy.Id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ func (this *StorageManager) Loop() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(policy.Options) > 0 {
|
if len(policy.Options) > 0 {
|
||||||
err = json.Unmarshal([]byte(policy.Options), storage.Config())
|
err = json.Unmarshal(policy.Options, storage.Config())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
remotelogs.Error("ACCESS_LOG_STORAGE_MANAGER", "unmarshal policy '"+types.String(policyId)+"' config failed: "+err.Error())
|
remotelogs.Error("ACCESS_LOG_STORAGE_MANAGER", "unmarshal policy '"+types.String(policyId)+"' config failed: "+err.Error())
|
||||||
storage.SetOk(false)
|
storage.SetOk(false)
|
||||||
@@ -110,7 +110,7 @@ func (this *StorageManager) Loop() error {
|
|||||||
remotelogs.Println("ACCESS_LOG_STORAGE_MANAGER", "restart policy '"+types.String(policyId)+"'")
|
remotelogs.Println("ACCESS_LOG_STORAGE_MANAGER", "restart policy '"+types.String(policyId)+"'")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
storage, err := this.createStorage(policy.Type, []byte(policy.Options))
|
storage, err := this.createStorage(policy.Type, policy.Options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
remotelogs.Error("ACCESS_LOG_STORAGE_MANAGER", "create policy '"+types.String(policyId)+"' failed: "+err.Error())
|
remotelogs.Error("ACCESS_LOG_STORAGE_MANAGER", "create policy '"+types.String(policyId)+"' failed: "+err.Error())
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package teaconst
|
package teaconst
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "0.4.5"
|
Version = "0.4.6"
|
||||||
|
|
||||||
ProductName = "Edge API"
|
ProductName = "Edge API"
|
||||||
ProcessName = "edge-api"
|
ProcessName = "edge-api"
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
package accounts
|
package accounts
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// UserAccountLog 用户账户日志
|
// UserAccountLog 用户账户日志
|
||||||
type UserAccountLog struct {
|
type UserAccountLog struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
UserId uint64 `field:"userId"` // 用户ID
|
UserId uint64 `field:"userId"` // 用户ID
|
||||||
AccountId uint64 `field:"accountId"` // 账户ID
|
AccountId uint64 `field:"accountId"` // 账户ID
|
||||||
Delta float64 `field:"delta"` // 操作余额的数量(可为负)
|
Delta float64 `field:"delta"` // 操作余额的数量(可为负)
|
||||||
DeltaFrozen float64 `field:"deltaFrozen"` // 操作冻结的数量(可为负)
|
DeltaFrozen float64 `field:"deltaFrozen"` // 操作冻结的数量(可为负)
|
||||||
Total float64 `field:"total"` // 操作后余额
|
Total float64 `field:"total"` // 操作后余额
|
||||||
TotalFrozen float64 `field:"totalFrozen"` // 操作后冻结余额
|
TotalFrozen float64 `field:"totalFrozen"` // 操作后冻结余额
|
||||||
EventType string `field:"eventType"` // 类型
|
EventType string `field:"eventType"` // 类型
|
||||||
Description string `field:"description"` // 描述文字
|
Description string `field:"description"` // 描述文字
|
||||||
Day string `field:"day"` // YYYYMMDD
|
Day string `field:"day"` // YYYYMMDD
|
||||||
CreatedAt uint64 `field:"createdAt"` // 时间
|
CreatedAt uint64 `field:"createdAt"` // 时间
|
||||||
Params string `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserAccountLogOperator struct {
|
type UserAccountLogOperator struct {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package acme
|
|||||||
// ACMEProviderAccount ACME提供商
|
// ACMEProviderAccount ACME提供商
|
||||||
type ACMEProviderAccount struct {
|
type ACMEProviderAccount struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
ProviderCode string `field:"providerCode"` // 代号
|
ProviderCode string `field:"providerCode"` // 代号
|
||||||
Error string `field:"error"` // 最后一条错误信息
|
Error string `field:"error"` // 最后一条错误信息
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
|
|||||||
errMsg = "找不到要执行的任务"
|
errMsg = "找不到要执行的任务"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if task.IsOn != 1 {
|
if !task.IsOn {
|
||||||
errMsg = "任务没有启用"
|
errMsg = "任务没有启用"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -330,7 +330,7 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
|
|||||||
})
|
})
|
||||||
|
|
||||||
if len(user.Registration) > 0 {
|
if len(user.Registration) > 0 {
|
||||||
err = remoteUser.SetRegistration([]byte(user.Registration))
|
err = remoteUser.SetRegistration(user.Registration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg = "设置注册信息时出错:" + err.Error()
|
errMsg = "设置注册信息时出错:" + err.Error()
|
||||||
return
|
return
|
||||||
@@ -453,7 +453,7 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = models.SharedSSLCertDAO.UpdateCert(tx, resultCertId, cert.IsOn == 1, cert.Name, cert.Description, cert.ServerName, cert.IsCA == 1, certData, keyData, sslConfig.TimeBeginAt, sslConfig.TimeEndAt, sslConfig.DNSNames, sslConfig.CommonNames)
|
err = models.SharedSSLCertDAO.UpdateCert(tx, resultCertId, cert.IsOn, cert.Name, cert.Description, cert.ServerName, cert.IsCA, certData, keyData, sslConfig.TimeBeginAt, sslConfig.TimeEndAt, sslConfig.DNSNames, sslConfig.CommonNames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg = "证书生成成功,但是修改数据库中的证书信息时出错:" + err.Error()
|
errMsg = "证书生成成功,但是修改数据库中的证书信息时出错:" + err.Error()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package acme
|
package acme
|
||||||
|
|
||||||
// ACME任务运行日志
|
// ACMETaskLog ACME任务运行日志
|
||||||
type ACMETaskLog struct {
|
type ACMETaskLog struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
TaskId uint64 `field:"taskId"` // 任务ID
|
TaskId uint64 `field:"taskId"` // 任务ID
|
||||||
IsOk uint8 `field:"isOk"` // 是否成功
|
IsOk bool `field:"isOk"` // 是否成功
|
||||||
Error string `field:"error"` // 错误信息
|
Error string `field:"error"` // 错误信息
|
||||||
CreatedAt uint64 `field:"createdAt"` // 运行时间
|
CreatedAt uint64 `field:"createdAt"` // 运行时间
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
package acme
|
package acme
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// ACMETask ACME任务
|
// ACMETask ACME任务
|
||||||
type ACMETask struct {
|
type ACMETask struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
AcmeUserId uint32 `field:"acmeUserId"` // ACME用户ID
|
AcmeUserId uint32 `field:"acmeUserId"` // ACME用户ID
|
||||||
DnsDomain string `field:"dnsDomain"` // DNS主域名
|
DnsDomain string `field:"dnsDomain"` // DNS主域名
|
||||||
DnsProviderId uint64 `field:"dnsProviderId"` // DNS服务商
|
DnsProviderId uint64 `field:"dnsProviderId"` // DNS服务商
|
||||||
Domains string `field:"domains"` // 证书域名
|
Domains dbs.JSON `field:"domains"` // 证书域名
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CertId uint64 `field:"certId"` // 生成的证书ID
|
CertId uint64 `field:"certId"` // 生成的证书ID
|
||||||
AutoRenew uint8 `field:"autoRenew"` // 是否自动更新
|
AutoRenew uint8 `field:"autoRenew"` // 是否自动更新
|
||||||
AuthType string `field:"authType"` // 认证类型
|
AuthType string `field:"authType"` // 认证类型
|
||||||
AuthURL string `field:"authURL"` // 认证URL
|
AuthURL string `field:"authURL"` // 认证URL
|
||||||
}
|
}
|
||||||
|
|
||||||
type ACMETaskOperator struct {
|
type ACMETaskOperator struct {
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import (
|
|||||||
"github.com/iwind/TeaGo/logs"
|
"github.com/iwind/TeaGo/logs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 将域名解析成字符串数组
|
// DecodeDomains 将域名解析成字符串数组
|
||||||
func (this *ACMETask) DecodeDomains() []string {
|
func (this *ACMETask) DecodeDomains() []string {
|
||||||
if len(this.Domains) == 0 || this.Domains == "null" {
|
if len(this.Domains) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
result := []string{}
|
result := []string{}
|
||||||
err := json.Unmarshal([]byte(this.Domains), &result)
|
err := json.Unmarshal(this.Domains, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error(err)
|
logs.Error(err)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package acme
|
package acme
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// ACMEUser ACME用户
|
// ACMEUser ACME用户
|
||||||
type ACMEUser struct {
|
type ACMEUser struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
PrivateKey string `field:"privateKey"` // 私钥
|
PrivateKey string `field:"privateKey"` // 私钥
|
||||||
Email string `field:"email"` // E-mail
|
Email string `field:"email"` // E-mail
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
Description string `field:"description"` // 备注介绍
|
Description string `field:"description"` // 备注介绍
|
||||||
Registration string `field:"registration"` // 注册信息
|
Registration dbs.JSON `field:"registration"` // 注册信息
|
||||||
ProviderCode string `field:"providerCode"` // 服务商代号
|
ProviderCode string `field:"providerCode"` // 服务商代号
|
||||||
AccountId uint64 `field:"accountId"` // 提供商ID
|
AccountId uint64 `field:"accountId"` // 提供商ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type ACMEUserOperator struct {
|
type ACMEUserOperator struct {
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// Admin 管理员
|
// Admin 管理员
|
||||||
type Admin struct {
|
type Admin struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Username string `field:"username"` // 用户名
|
Username string `field:"username"` // 用户名
|
||||||
Password string `field:"password"` // 密码
|
Password string `field:"password"` // 密码
|
||||||
Fullname string `field:"fullname"` // 全名
|
Fullname string `field:"fullname"` // 全名
|
||||||
IsSuper uint8 `field:"isSuper"` // 是否为超级管理员
|
IsSuper bool `field:"isSuper"` // 是否为超级管理员
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
UpdatedAt uint64 `field:"updatedAt"` // 修改时间
|
UpdatedAt uint64 `field:"updatedAt"` // 修改时间
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
Modules string `field:"modules"` // 允许的模块
|
Modules dbs.JSON `field:"modules"` // 允许的模块
|
||||||
CanLogin uint8 `field:"canLogin"` // 是否可以登录
|
CanLogin uint8 `field:"canLogin"` // 是否可以登录
|
||||||
Theme string `field:"theme"` // 模板设置
|
Theme string `field:"theme"` // 模板设置
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminOperator struct {
|
type AdminOperator struct {
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// API节点
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
|
// APINode API节点
|
||||||
type APINode struct {
|
type APINode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
ClusterId uint32 `field:"clusterId"` // 专用集群ID
|
ClusterId uint32 `field:"clusterId"` // 专用集群ID
|
||||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Http string `field:"http"` // 监听的HTTP配置
|
Http dbs.JSON `field:"http"` // 监听的HTTP配置
|
||||||
Https string `field:"https"` // 监听的HTTPS配置
|
Https dbs.JSON `field:"https"` // 监听的HTTPS配置
|
||||||
RestIsOn uint8 `field:"restIsOn"` // 是否开放REST
|
RestIsOn uint8 `field:"restIsOn"` // 是否开放REST
|
||||||
RestHTTP string `field:"restHTTP"` // REST HTTP配置
|
RestHTTP dbs.JSON `field:"restHTTP"` // REST HTTP配置
|
||||||
RestHTTPS string `field:"restHTTPS"` // REST HTTPS配置
|
RestHTTPS dbs.JSON `field:"restHTTPS"` // REST HTTPS配置
|
||||||
AccessAddrs string `field:"accessAddrs"` // 外部访问地址
|
AccessAddrs dbs.JSON `field:"accessAddrs"` // 外部访问地址
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
Weight uint32 `field:"weight"` // 权重
|
Weight uint32 `field:"weight"` // 权重
|
||||||
Status string `field:"status"` // 运行状态
|
Status dbs.JSON `field:"status"` // 运行状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type APINodeOperator struct {
|
type APINodeOperator struct {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func (this *APINode) DecodeHTTP() (*serverconfigs.HTTPProtocolConfig, error) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPProtocolConfig{}
|
config := &serverconfigs.HTTPProtocolConfig{}
|
||||||
err := json.Unmarshal([]byte(this.Http), config)
|
err := json.Unmarshal(this.Http, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ func (this *APINode) DecodeHTTPS(tx *dbs.Tx, cacheMap *utils.CacheMap) (*serverc
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPSProtocolConfig{}
|
config := &serverconfigs.HTTPSProtocolConfig{}
|
||||||
err := json.Unmarshal([]byte(this.Https), config)
|
err := json.Unmarshal(this.Https, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ func (this *APINode) DecodeAccessAddrs() ([]*serverconfigs.NetworkAddressConfig,
|
|||||||
}
|
}
|
||||||
|
|
||||||
addrConfigs := []*serverconfigs.NetworkAddressConfig{}
|
addrConfigs := []*serverconfigs.NetworkAddressConfig{}
|
||||||
err := json.Unmarshal([]byte(this.AccessAddrs), &addrConfigs)
|
err := json.Unmarshal(this.AccessAddrs, &addrConfigs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ func (this *APINode) DecodeRestHTTP() (*serverconfigs.HTTPProtocolConfig, error)
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPProtocolConfig{}
|
config := &serverconfigs.HTTPProtocolConfig{}
|
||||||
err := json.Unmarshal([]byte(this.RestHTTP), config)
|
err := json.Unmarshal(this.RestHTTP, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ func (this *APINode) DecodeRestHTTPS(tx *dbs.Tx, cacheMap *utils.CacheMap) (*ser
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPSProtocolConfig{}
|
config := &serverconfigs.HTTPSProtocolConfig{}
|
||||||
err := json.Unmarshal([]byte(this.RestHTTPS), config)
|
err := json.Unmarshal(this.RestHTTPS, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
package authority
|
package authority
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// AuthorityKey 企业版认证信息
|
// AuthorityKey 企业版认证信息
|
||||||
type AuthorityKey struct {
|
type AuthorityKey struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Value string `field:"value"` // Key值
|
Value string `field:"value"` // Key值
|
||||||
DayFrom string `field:"dayFrom"` // 开始日期
|
DayFrom string `field:"dayFrom"` // 开始日期
|
||||||
DayTo string `field:"dayTo"` // 结束日期
|
DayTo string `field:"dayTo"` // 结束日期
|
||||||
Hostname string `field:"hostname"` // Hostname
|
Hostname string `field:"hostname"` // Hostname
|
||||||
MacAddresses string `field:"macAddresses"` // MAC地址
|
MacAddresses dbs.JSON `field:"macAddresses"` // MAC地址
|
||||||
UpdatedAt uint64 `field:"updatedAt"` // 创建/修改时间
|
UpdatedAt uint64 `field:"updatedAt"` // 创建/修改时间
|
||||||
Company string `field:"company"` // 公司组织
|
Company string `field:"company"` // 公司组织
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthorityKeyOperator struct {
|
type AuthorityKeyOperator struct {
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
package authority
|
package authority
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// AuthorityNode 监控节点
|
// AuthorityNode 监控节点
|
||||||
type AuthorityNode struct {
|
type AuthorityNode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
Weight uint32 `field:"weight"` // 权重
|
Weight uint32 `field:"weight"` // 权重
|
||||||
Status string `field:"status"` // 运行状态
|
Status dbs.JSON `field:"status"` // 运行状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthorityNodeOperator struct {
|
type AuthorityNodeOperator struct {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 终端浏览器信息
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
|
// ClientBrowser 终端浏览器信息
|
||||||
type ClientBrowser struct {
|
type ClientBrowser struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 浏览器名称
|
Name string `field:"name"` // 浏览器名称
|
||||||
Codes string `field:"codes"` // 代号
|
Codes dbs.JSON `field:"codes"` // 代号
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientBrowserOperator struct {
|
type ClientBrowserOperator struct {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 终端操作系统信息
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
|
// ClientSystem 终端操作系统信息
|
||||||
type ClientSystem struct {
|
type ClientSystem struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 系统名称
|
Name string `field:"name"` // 系统名称
|
||||||
Codes string `field:"codes"` // 代号
|
Codes dbs.JSON `field:"codes"` // 代号
|
||||||
State uint8 `field:"state"` //
|
State uint8 `field:"state"` //
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientSystemOperator struct {
|
type ClientSystemOperator struct {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 数据库节点
|
// DBNode 数据库节点
|
||||||
type DBNode struct {
|
type DBNode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Role string `field:"role"` // 数据库角色
|
Role string `field:"role"` // 数据库角色
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
package dns
|
package dns
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// DNSDomain 管理的域名
|
// DNSDomain 管理的域名
|
||||||
type DNSDomain struct {
|
type DNSDomain struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
ProviderId uint32 `field:"providerId"` // 服务商ID
|
ProviderId uint32 `field:"providerId"` // 服务商ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否可用
|
IsOn bool `field:"isOn"` // 是否可用
|
||||||
Name string `field:"name"` // 域名
|
Name string `field:"name"` // 域名
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据更新时间
|
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据更新时间
|
||||||
DataError string `field:"dataError"` // 数据更新错误
|
DataError string `field:"dataError"` // 数据更新错误
|
||||||
Data string `field:"data"` // 原始数据信息
|
Data string `field:"data"` // 原始数据信息
|
||||||
Records string `field:"records"` // 所有解析记录
|
Records dbs.JSON `field:"records"` // 所有解析记录
|
||||||
Routes string `field:"routes"` // 线路数据
|
Routes dbs.JSON `field:"routes"` // 线路数据
|
||||||
IsUp uint8 `field:"isUp"` // 是否在线
|
IsUp bool `field:"isUp"` // 是否在线
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
IsDeleted uint8 `field:"isDeleted"` // 是否已删除
|
IsDeleted bool `field:"isDeleted"` // 是否已删除
|
||||||
}
|
}
|
||||||
|
|
||||||
type DNSDomainOperator struct {
|
type DNSDomainOperator struct {
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import (
|
|||||||
|
|
||||||
// DecodeRoutes 获取所有的线路
|
// DecodeRoutes 获取所有的线路
|
||||||
func (this *DNSDomain) DecodeRoutes() ([]*dnstypes.Route, error) {
|
func (this *DNSDomain) DecodeRoutes() ([]*dnstypes.Route, error) {
|
||||||
if len(this.Routes) == 0 || this.Routes == "null" {
|
if len(this.Routes) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
result := []*dnstypes.Route{}
|
result := []*dnstypes.Route{}
|
||||||
err := json.Unmarshal([]byte(this.Routes), &result)
|
err := json.Unmarshal(this.Routes, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -35,11 +35,11 @@ func (this *DNSDomain) ContainsRouteCode(route string) (bool, error) {
|
|||||||
// DecodeRecords 获取所有的记录
|
// DecodeRecords 获取所有的记录
|
||||||
func (this *DNSDomain) DecodeRecords() ([]*dnstypes.Record, error) {
|
func (this *DNSDomain) DecodeRecords() ([]*dnstypes.Record, error) {
|
||||||
records := this.Records
|
records := this.Records
|
||||||
if len(records) == 0 || records == "null" {
|
if len(records) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
result := []*dnstypes.Record{}
|
result := []*dnstypes.Record{}
|
||||||
err := json.Unmarshal([]byte(records), &result)
|
err := json.Unmarshal(records, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
package dns
|
package dns
|
||||||
|
|
||||||
// DNS服务商
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
|
// DNSProvider DNS服务商
|
||||||
type DNSProvider struct {
|
type DNSProvider struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
Type string `field:"type"` // 供应商类型
|
Type string `field:"type"` // 供应商类型
|
||||||
ApiParams string `field:"apiParams"` // API参数
|
ApiParams dbs.JSON `field:"apiParams"` // API参数
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据同步时间
|
DataUpdatedAt uint64 `field:"dataUpdatedAt"` // 数据同步时间
|
||||||
}
|
}
|
||||||
|
|
||||||
type DNSProviderOperator struct {
|
type DNSProviderOperator struct {
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import (
|
|||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 获取API参数
|
// DecodeAPIParams 获取API参数
|
||||||
func (this *DNSProvider) DecodeAPIParams() (maps.Map, error) {
|
func (this *DNSProvider) DecodeAPIParams() (maps.Map, error) {
|
||||||
if len(this.ApiParams) == 0 || this.ApiParams == "null" {
|
if len(this.ApiParams) == 0 {
|
||||||
return maps.Map{}, nil
|
return maps.Map{}, nil
|
||||||
}
|
}
|
||||||
result := maps.Map{}
|
result := maps.Map{}
|
||||||
err := json.Unmarshal([]byte(this.ApiParams), &result)
|
err := json.Unmarshal(this.ApiParams, &result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ type DNSTask struct {
|
|||||||
DomainId uint32 `field:"domainId"` // 域名ID
|
DomainId uint32 `field:"domainId"` // 域名ID
|
||||||
Type string `field:"type"` // 任务类型
|
Type string `field:"type"` // 任务类型
|
||||||
UpdatedAt uint64 `field:"updatedAt"` // 更新时间
|
UpdatedAt uint64 `field:"updatedAt"` // 更新时间
|
||||||
IsDone uint8 `field:"isDone"` // 是否已完成
|
IsDone bool `field:"isDone"` // 是否已完成
|
||||||
IsOk uint8 `field:"isOk"` // 是否成功
|
IsOk bool `field:"isOk"` // 是否成功
|
||||||
Error string `field:"error"` // 错误信息
|
Error string `field:"error"` // 错误信息
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package models
|
|||||||
type FileChunk struct {
|
type FileChunk struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
FileId uint32 `field:"fileId"` // 文件ID
|
FileId uint32 `field:"fileId"` // 文件ID
|
||||||
Data string `field:"data"` // 分块内容
|
Data []byte `field:"data"` // 分块内容
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileChunkOperator struct {
|
type FileChunkOperator struct {
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ type File struct {
|
|||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
IsFinished uint8 `field:"isFinished"` // 是否已完成上传
|
IsFinished bool `field:"isFinished"` // 是否已完成上传
|
||||||
IsPublic uint8 `field:"isPublic"` // 是否可以公开访问
|
IsPublic bool `field:"isPublic"` // 是否可以公开访问
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileOperator struct {
|
type FileOperator struct {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ Loop:
|
|||||||
|
|
||||||
// CreateHTTPAccessLog 写入单条访问日志
|
// CreateHTTPAccessLog 写入单条访问日志
|
||||||
func (this *HTTPAccessLogDAO) CreateHTTPAccessLog(tx *dbs.Tx, dao *HTTPAccessLogDAO, accessLog *pb.HTTPAccessLog) error {
|
func (this *HTTPAccessLogDAO) CreateHTTPAccessLog(tx *dbs.Tx, dao *HTTPAccessLogDAO, accessLog *pb.HTTPAccessLog) error {
|
||||||
var day = timeutil.Format("Ymd", time.Unix(accessLog.Timestamp, 0))
|
var day = timeutil.FormatTime("Ymd", accessLog.Timestamp)
|
||||||
tableDef, err := SharedHTTPAccessLogManager.FindTable(dao.Instance, day, true)
|
tableDef, err := SharedHTTPAccessLogManager.FindTable(dao.Instance, day, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -221,10 +221,26 @@ func (this *HTTPAccessLogDAO) CreateHTTPAccessLog(tx *dbs.Tx, dao *HTTPAccessLog
|
|||||||
Sets(fields).
|
Sets(fields).
|
||||||
Insert()
|
Insert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
// 错误重试
|
||||||
|
if CheckSQLErrCode(err, 1146) { // Error 1146: Table 'xxx' doesn't exist
|
||||||
|
err = SharedHTTPAccessLogManager.CreateTable(dao.Instance, tableDef.Name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新尝试
|
||||||
|
lastId, err = dao.Query(tx).
|
||||||
|
Table(tableDef.Name).
|
||||||
|
Sets(fields).
|
||||||
|
Insert()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if accessLogEnableAutoPartial && accessLogRowsPerTable > 0 && lastId%accessLogRowsPerTable == 0 {
|
if accessLogEnableAutoPartial && accessLogRowsPerTable > 0 && lastId >= accessLogRowsPerTable {
|
||||||
SharedHTTPAccessLogManager.ResetTable(dao.Instance, day)
|
SharedHTTPAccessLogManager.ResetTable(dao.Instance, day)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package models
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||||
"github.com/go-sql-driver/mysql"
|
|
||||||
"github.com/iwind/TeaGo/dbs"
|
"github.com/iwind/TeaGo/dbs"
|
||||||
"github.com/iwind/TeaGo/lists"
|
"github.com/iwind/TeaGo/lists"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
@@ -60,7 +59,15 @@ func (this *HTTPAccessLogManager) FindTableNames(db *dbs.DB, day string) ([]stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 排序
|
// 排序
|
||||||
sort.Strings(results)
|
// 这里不能直接使用sort.Strings(),因为表名里面可能大小写混合
|
||||||
|
sort.Slice(results, func(i, j int) bool {
|
||||||
|
var name1 = results[i]
|
||||||
|
var name2 = results[j]
|
||||||
|
if len(name1) < len(name2) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return strings.ToLower(name1) < strings.ToLower(name2)
|
||||||
|
})
|
||||||
|
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
@@ -133,7 +140,8 @@ func (this *HTTPAccessLogManager) FindTable(db *dbs.DB, day string, force bool)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var cacheKey = config.Dsn
|
var cachePrefix = config.Dsn
|
||||||
|
var cacheKey = this.composeTableCacheKey(cachePrefix, day)
|
||||||
def, ok := this.currentTableMapping[cacheKey]
|
def, ok := this.currentTableMapping[cacheKey]
|
||||||
if ok {
|
if ok {
|
||||||
return def, nil
|
return def, nil
|
||||||
@@ -144,7 +152,22 @@ func (this *HTTPAccessLogManager) FindTable(db *dbs.DB, day string, force bool)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentTableMapping[cacheKey] = def
|
// 只有存在的表格才缓存
|
||||||
|
if def != nil && def.Exists {
|
||||||
|
this.currentTableMapping[cacheKey] = def
|
||||||
|
|
||||||
|
// 清除过时缓存
|
||||||
|
for oldCacheKey := range this.currentTableMapping {
|
||||||
|
var dayIndex = strings.LastIndex(oldCacheKey, "_")
|
||||||
|
if dayIndex > 0 {
|
||||||
|
var oldPrefix = oldCacheKey[:dayIndex]
|
||||||
|
var oldDay = oldCacheKey[dayIndex+1:]
|
||||||
|
if oldPrefix == cachePrefix && oldDay < day {
|
||||||
|
delete(this.currentTableMapping, oldCacheKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return def, nil
|
return def, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,14 +175,7 @@ func (this *HTTPAccessLogManager) FindTable(db *dbs.DB, day string, force bool)
|
|||||||
func (this *HTTPAccessLogManager) CreateTable(db *dbs.DB, tableName string) error {
|
func (this *HTTPAccessLogManager) CreateTable(db *dbs.DB, tableName string) error {
|
||||||
_, err := db.Exec("CREATE TABLE `" + tableName + "` (\n `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `serverId` int(11) unsigned DEFAULT '0' COMMENT '服务ID',\n `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n `status` int(3) unsigned DEFAULT '0' COMMENT '状态码',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `content` json DEFAULT NULL COMMENT '日志内容',\n `requestId` varchar(128) DEFAULT NULL COMMENT '请求ID',\n `firewallPolicyId` int(11) unsigned DEFAULT '0' COMMENT 'WAF策略ID',\n `firewallRuleGroupId` int(11) unsigned DEFAULT '0' COMMENT 'WAF分组ID',\n `firewallRuleSetId` int(11) unsigned DEFAULT '0' COMMENT 'WAF集ID',\n `firewallRuleId` int(11) unsigned DEFAULT '0' COMMENT 'WAF规则ID',\n `remoteAddr` varchar(64) DEFAULT NULL COMMENT 'IP地址',\n `domain` varchar(128) DEFAULT NULL COMMENT '域名',\n `requestBody` mediumblob COMMENT '请求内容',\n `responseBody` mediumblob COMMENT '响应内容',\n PRIMARY KEY (`id`),\n KEY `serverId` (`serverId`),\n KEY `nodeId` (`nodeId`),\n KEY `serverId_status` (`serverId`,`status`),\n KEY `requestId` (`requestId`),\n KEY `firewallPolicyId` (`firewallPolicyId`),\n KEY `firewallRuleGroupId` (`firewallRuleGroupId`),\n KEY `firewallRuleSetId` (`firewallRuleSetId`),\n KEY `firewallRuleId` (`firewallRuleId`),\n KEY `remoteAddr` (`remoteAddr`),\n KEY `domain` (`domain`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='访问日志';")
|
_, err := db.Exec("CREATE TABLE `" + tableName + "` (\n `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `serverId` int(11) unsigned DEFAULT '0' COMMENT '服务ID',\n `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n `status` int(3) unsigned DEFAULT '0' COMMENT '状态码',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `content` json DEFAULT NULL COMMENT '日志内容',\n `requestId` varchar(128) DEFAULT NULL COMMENT '请求ID',\n `firewallPolicyId` int(11) unsigned DEFAULT '0' COMMENT 'WAF策略ID',\n `firewallRuleGroupId` int(11) unsigned DEFAULT '0' COMMENT 'WAF分组ID',\n `firewallRuleSetId` int(11) unsigned DEFAULT '0' COMMENT 'WAF集ID',\n `firewallRuleId` int(11) unsigned DEFAULT '0' COMMENT 'WAF规则ID',\n `remoteAddr` varchar(64) DEFAULT NULL COMMENT 'IP地址',\n `domain` varchar(128) DEFAULT NULL COMMENT '域名',\n `requestBody` mediumblob COMMENT '请求内容',\n `responseBody` mediumblob COMMENT '响应内容',\n PRIMARY KEY (`id`),\n KEY `serverId` (`serverId`),\n KEY `nodeId` (`nodeId`),\n KEY `serverId_status` (`serverId`,`status`),\n KEY `requestId` (`requestId`),\n KEY `firewallPolicyId` (`firewallPolicyId`),\n KEY `firewallRuleGroupId` (`firewallRuleGroupId`),\n KEY `firewallRuleSetId` (`firewallRuleSetId`),\n KEY `firewallRuleId` (`firewallRuleId`),\n KEY `remoteAddr` (`remoteAddr`),\n KEY `domain` (`domain`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='访问日志';")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 快速判断错误方法
|
if CheckSQLErrCode(err, 1050) { // Error 1050: Table 'xxx' already exists
|
||||||
mysqlErr, ok := err.(*mysql.MySQLError)
|
|
||||||
if ok && mysqlErr.Number == 1050 { // Error 1050: Table 'xxx' already exists
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 防止二次包装过程中错误丢失的保底错误判断方法
|
|
||||||
if strings.Contains(err.Error(), "Error 1050") {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +194,7 @@ func (this *HTTPAccessLogManager) ResetTable(db *dbs.DB, day string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
delete(this.currentTableMapping, config.Dsn)
|
delete(this.currentTableMapping, this.composeTableCacheKey(config.Dsn, day))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找某个表格
|
// 查找某个表格
|
||||||
@@ -295,3 +311,9 @@ func (this *HTTPAccessLogManager) checkTableFields(db *dbs.DB, tableName string)
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 组合表格的缓存Key
|
||||||
|
func (this *HTTPAccessLogManager) composeTableCacheKey(dsn string, day string) string {
|
||||||
|
// 注意:格式一定要固定,下面清除缓存的时候需要用到
|
||||||
|
return dsn + "_" + day
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPAccessLog 访问日志
|
// HTTPAccessLog 访问日志
|
||||||
type HTTPAccessLog struct {
|
type HTTPAccessLog struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
ServerId uint32 `field:"serverId"` // 服务ID
|
ServerId uint32 `field:"serverId"` // 服务ID
|
||||||
NodeId uint32 `field:"nodeId"` // 节点ID
|
NodeId uint32 `field:"nodeId"` // 节点ID
|
||||||
Status uint32 `field:"status"` // 状态码
|
Status uint32 `field:"status"` // 状态码
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Content string `field:"content"` // 日志内容
|
Content dbs.JSON `field:"content"` // 日志内容
|
||||||
RequestId string `field:"requestId"` // 请求ID
|
RequestId string `field:"requestId"` // 请求ID
|
||||||
FirewallPolicyId uint32 `field:"firewallPolicyId"` // WAF策略ID
|
FirewallPolicyId uint32 `field:"firewallPolicyId"` // WAF策略ID
|
||||||
FirewallRuleGroupId uint32 `field:"firewallRuleGroupId"` // WAF分组ID
|
FirewallRuleGroupId uint32 `field:"firewallRuleGroupId"` // WAF分组ID
|
||||||
FirewallRuleSetId uint32 `field:"firewallRuleSetId"` // WAF集ID
|
FirewallRuleSetId uint32 `field:"firewallRuleSetId"` // WAF集ID
|
||||||
FirewallRuleId uint32 `field:"firewallRuleId"` // WAF规则ID
|
FirewallRuleId uint32 `field:"firewallRuleId"` // WAF规则ID
|
||||||
RemoteAddr string `field:"remoteAddr"` // IP地址
|
RemoteAddr string `field:"remoteAddr"` // IP地址
|
||||||
Domain string `field:"domain"` // 域名
|
Domain string `field:"domain"` // 域名
|
||||||
RequestBody string `field:"requestBody"` // 请求内容
|
RequestBody []byte `field:"requestBody"` // 请求内容
|
||||||
ResponseBody string `field:"responseBody"` // 响应内容
|
ResponseBody []byte `field:"responseBody"` // 响应内容
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPAccessLogOperator struct {
|
type HTTPAccessLogOperator struct {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import (
|
|||||||
// ToPB 转换成PB对象
|
// ToPB 转换成PB对象
|
||||||
func (this *HTTPAccessLog) ToPB() (*pb.HTTPAccessLog, error) {
|
func (this *HTTPAccessLog) ToPB() (*pb.HTTPAccessLog, error) {
|
||||||
p := &pb.HTTPAccessLog{}
|
p := &pb.HTTPAccessLog{}
|
||||||
err := json.Unmarshal([]byte(this.Content), p)
|
err := json.Unmarshal(this.Content, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
p.RequestId = this.RequestId
|
p.RequestId = this.RequestId
|
||||||
p.RequestBody = []byte(this.RequestBody)
|
p.RequestBody = this.RequestBody
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ func (this *HTTPAccessLogPolicyDAO) UpdatePolicy(tx *dbs.Tx, policyId int64, nam
|
|||||||
op.Version = dbs.SQL("version+1")
|
op.Version = dbs.SQL("version+1")
|
||||||
} else {
|
} else {
|
||||||
var m1 = maps.Map{}
|
var m1 = maps.Map{}
|
||||||
_ = json.Unmarshal([]byte(oldPolicy.Options), &m1)
|
_ = json.Unmarshal(oldPolicy.Options, &m1)
|
||||||
|
|
||||||
var m2 = maps.Map{}
|
var m2 = maps.Map{}
|
||||||
_ = json.Unmarshal(optionsJSON, &m2)
|
_ = json.Unmarshal(optionsJSON, &m2)
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPAccessLogPolicy 访问日志策略
|
// HTTPAccessLogPolicy 访问日志策略
|
||||||
type HTTPAccessLogPolicy struct {
|
type HTTPAccessLogPolicy struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Type string `field:"type"` // 存储类型
|
Type string `field:"type"` // 存储类型
|
||||||
Options string `field:"options"` // 存储选项
|
Options dbs.JSON `field:"options"` // 存储选项
|
||||||
Conds string `field:"conds"` // 请求条件
|
Conds dbs.JSON `field:"conds"` // 请求条件
|
||||||
IsPublic uint8 `field:"isPublic"` // 是否为公用
|
IsPublic bool `field:"isPublic"` // 是否为公用
|
||||||
Version uint32 `field:"version"` // 版本号
|
Version uint32 `field:"version"` // 版本号
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPAccessLogPolicyOperator struct {
|
type HTTPAccessLogPolicyOperator struct {
|
||||||
|
|||||||
@@ -116,13 +116,13 @@ func (this *HTTPAuthPolicyDAO) ComposePolicyConfig(tx *dbs.Tx, policyId int64, c
|
|||||||
var config = &serverconfigs.HTTPAuthPolicy{
|
var config = &serverconfigs.HTTPAuthPolicy{
|
||||||
Id: int64(policy.Id),
|
Id: int64(policy.Id),
|
||||||
Name: policy.Name,
|
Name: policy.Name,
|
||||||
IsOn: policy.IsOn == 1,
|
IsOn: policy.IsOn,
|
||||||
Type: policy.Type,
|
Type: policy.Type,
|
||||||
}
|
}
|
||||||
|
|
||||||
var params map[string]interface{}
|
var params map[string]interface{}
|
||||||
if IsNotNull(policy.Params) {
|
if IsNotNull(policy.Params) {
|
||||||
err = json.Unmarshal([]byte(policy.Params), ¶ms)
|
err = json.Unmarshal(policy.Params, ¶ms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPAuthPolicy HTTP认证策略
|
// HTTPAuthPolicy HTTP认证策略
|
||||||
type HTTPAuthPolicy struct {
|
type HTTPAuthPolicy struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
Params string `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPAuthPolicyOperator struct {
|
type HTTPAuthPolicyOperator struct {
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPBrotliCompressionConfig{}
|
config := &serverconfigs.HTTPBrotliCompressionConfig{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
if IsNotNull(policy.MinLength) {
|
if IsNotNull(policy.MinLength) {
|
||||||
minLengthConfig := &shared.SizeCapacity{}
|
minLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal([]byte(policy.MinLength), minLengthConfig)
|
err = json.Unmarshal(policy.MinLength, minLengthConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
|
|||||||
}
|
}
|
||||||
if IsNotNull(policy.MaxLength) {
|
if IsNotNull(policy.MaxLength) {
|
||||||
maxLengthConfig := &shared.SizeCapacity{}
|
maxLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal([]byte(policy.MaxLength), maxLengthConfig)
|
err = json.Unmarshal(policy.MaxLength, maxLengthConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ func (this *HTTPBrotliPolicyDAO) ComposeBrotliConfig(tx *dbs.Tx, policyId int64)
|
|||||||
|
|
||||||
if IsNotNull(policy.Conds) {
|
if IsNotNull(policy.Conds) {
|
||||||
condsConfig := &shared.HTTPRequestCondsConfig{}
|
condsConfig := &shared.HTTPRequestCondsConfig{}
|
||||||
err = json.Unmarshal([]byte(policy.Conds), condsConfig)
|
err = json.Unmarshal(policy.Conds, condsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPBrotliPolicy Gzip配置
|
// HTTPBrotliPolicy Gzip配置
|
||||||
type HTTPBrotliPolicy struct {
|
type HTTPBrotliPolicy struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Level uint32 `field:"level"` // 压缩级别
|
Level uint32 `field:"level"` // 压缩级别
|
||||||
MinLength string `field:"minLength"` // 可压缩最小值
|
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
||||||
MaxLength string `field:"maxLength"` // 可压缩最大值
|
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Conds string `field:"conds"` // 条件
|
Conds dbs.JSON `field:"conds"` // 条件
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPBrotliPolicyOperator struct {
|
type HTTPBrotliPolicyOperator struct {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
|
|||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPCachePolicy{}
|
config := &serverconfigs.HTTPCachePolicy{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
config.Name = policy.Name
|
config.Name = policy.Name
|
||||||
config.Description = policy.Description
|
config.Description = policy.Description
|
||||||
config.SyncCompressionCache = policy.SyncCompressionCache == 1
|
config.SyncCompressionCache = policy.SyncCompressionCache == 1
|
||||||
@@ -260,7 +260,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
|
|||||||
// capacity
|
// capacity
|
||||||
if IsNotNull(policy.Capacity) {
|
if IsNotNull(policy.Capacity) {
|
||||||
capacityConfig := &shared.SizeCapacity{}
|
capacityConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal([]byte(policy.Capacity), capacityConfig)
|
err = json.Unmarshal(policy.Capacity, capacityConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
|
|||||||
// max size
|
// max size
|
||||||
if IsNotNull(policy.MaxSize) {
|
if IsNotNull(policy.MaxSize) {
|
||||||
maxSizeConfig := &shared.SizeCapacity{}
|
maxSizeConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal([]byte(policy.MaxSize), maxSizeConfig)
|
err = json.Unmarshal(policy.MaxSize, maxSizeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
|
|||||||
// options
|
// options
|
||||||
if IsNotNull(policy.Options) {
|
if IsNotNull(policy.Options) {
|
||||||
m := map[string]interface{}{}
|
m := map[string]interface{}{}
|
||||||
err = json.Unmarshal([]byte(policy.Options), &m)
|
err = json.Unmarshal(policy.Options, &m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err)
|
return nil, errors.Wrap(err)
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ func (this *HTTPCachePolicyDAO) ComposeCachePolicy(tx *dbs.Tx, policyId int64, c
|
|||||||
// refs
|
// refs
|
||||||
if IsNotNull(policy.Refs) {
|
if IsNotNull(policy.Refs) {
|
||||||
refs := []*serverconfigs.HTTPCacheRef{}
|
refs := []*serverconfigs.HTTPCacheRef{}
|
||||||
err = json.Unmarshal([]byte(policy.Refs), &refs)
|
err = json.Unmarshal(policy.Refs, &refs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPCachePolicy HTTP缓存策略
|
// HTTPCachePolicy HTTP缓存策略
|
||||||
type HTTPCachePolicy struct {
|
type HTTPCachePolicy struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Capacity string `field:"capacity"` // 容量数据
|
Capacity dbs.JSON `field:"capacity"` // 容量数据
|
||||||
MaxKeys uint64 `field:"maxKeys"` // 最多Key值
|
MaxKeys uint64 `field:"maxKeys"` // 最多Key值
|
||||||
MaxSize string `field:"maxSize"` // 最大缓存内容尺寸
|
MaxSize dbs.JSON `field:"maxSize"` // 最大缓存内容尺寸
|
||||||
Type string `field:"type"` // 存储类型
|
Type string `field:"type"` // 存储类型
|
||||||
Options string `field:"options"` // 存储选项
|
Options dbs.JSON `field:"options"` // 存储选项
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Refs string `field:"refs"` // 默认的缓存设置
|
Refs dbs.JSON `field:"refs"` // 默认的缓存设置
|
||||||
SyncCompressionCache uint8 `field:"syncCompressionCache"` // 是否同步写入压缩缓存
|
SyncCompressionCache uint8 `field:"syncCompressionCache"` // 是否同步写入压缩缓存
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPCachePolicyOperator struct {
|
type HTTPCachePolicyOperator struct {
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPDeflateCompressionConfig{}
|
config := &serverconfigs.HTTPDeflateCompressionConfig{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
if IsNotNull(policy.MinLength) {
|
if IsNotNull(policy.MinLength) {
|
||||||
minLengthConfig := &shared.SizeCapacity{}
|
minLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal([]byte(policy.MinLength), minLengthConfig)
|
err = json.Unmarshal(policy.MinLength, minLengthConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
|
|||||||
}
|
}
|
||||||
if IsNotNull(policy.MaxLength) {
|
if IsNotNull(policy.MaxLength) {
|
||||||
maxLengthConfig := &shared.SizeCapacity{}
|
maxLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal([]byte(policy.MaxLength), maxLengthConfig)
|
err = json.Unmarshal(policy.MaxLength, maxLengthConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ func (this *HTTPDeflatePolicyDAO) ComposeDeflateConfig(tx *dbs.Tx, policyId int6
|
|||||||
|
|
||||||
if IsNotNull(policy.Conds) {
|
if IsNotNull(policy.Conds) {
|
||||||
condsConfig := &shared.HTTPRequestCondsConfig{}
|
condsConfig := &shared.HTTPRequestCondsConfig{}
|
||||||
err = json.Unmarshal([]byte(policy.Conds), condsConfig)
|
err = json.Unmarshal(policy.Conds, condsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPDeflatePolicy Gzip配置
|
// HTTPDeflatePolicy Gzip配置
|
||||||
type HTTPDeflatePolicy struct {
|
type HTTPDeflatePolicy struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Level uint32 `field:"level"` // 压缩级别
|
Level uint32 `field:"level"` // 压缩级别
|
||||||
MinLength string `field:"minLength"` // 可压缩最小值
|
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
||||||
MaxLength string `field:"maxLength"` // 可压缩最大值
|
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Conds string `field:"conds"` // 条件
|
Conds dbs.JSON `field:"conds"` // 条件
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPDeflatePolicyOperator struct {
|
type HTTPDeflatePolicyOperator struct {
|
||||||
|
|||||||
@@ -81,12 +81,12 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
|
|||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPFastcgiConfig{}
|
config := &serverconfigs.HTTPFastcgiConfig{}
|
||||||
config.Id = int64(fastcgi.Id)
|
config.Id = int64(fastcgi.Id)
|
||||||
config.IsOn = fastcgi.IsOn == 1
|
config.IsOn = fastcgi.IsOn
|
||||||
config.Address = fastcgi.Address
|
config.Address = fastcgi.Address
|
||||||
|
|
||||||
if IsNotNull(fastcgi.Params) {
|
if IsNotNull(fastcgi.Params) {
|
||||||
params := []*serverconfigs.HTTPFastcgiParam{}
|
params := []*serverconfigs.HTTPFastcgiParam{}
|
||||||
err = json.Unmarshal([]byte(fastcgi.Params), ¶ms)
|
err = json.Unmarshal(fastcgi.Params, ¶ms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
|
|||||||
|
|
||||||
if IsNotNull(fastcgi.ReadTimeout) {
|
if IsNotNull(fastcgi.ReadTimeout) {
|
||||||
duration := &shared.TimeDuration{}
|
duration := &shared.TimeDuration{}
|
||||||
err = json.Unmarshal([]byte(fastcgi.ReadTimeout), duration)
|
err = json.Unmarshal(fastcgi.ReadTimeout, duration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ func (this *HTTPFastcgiDAO) ComposeFastcgiConfig(tx *dbs.Tx, fastcgiId int64) (*
|
|||||||
|
|
||||||
if IsNotNull(fastcgi.ConnTimeout) {
|
if IsNotNull(fastcgi.ConnTimeout) {
|
||||||
duration := &shared.TimeDuration{}
|
duration := &shared.TimeDuration{}
|
||||||
err = json.Unmarshal([]byte(fastcgi.ConnTimeout), duration)
|
err = json.Unmarshal(fastcgi.ConnTimeout, duration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPFastcgi Fastcgi设置
|
// HTTPFastcgi Fastcgi设置
|
||||||
type HTTPFastcgi struct {
|
type HTTPFastcgi struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Address string `field:"address"` // 地址
|
Address string `field:"address"` // 地址
|
||||||
Params string `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
ReadTimeout string `field:"readTimeout"` // 读取超时
|
ReadTimeout dbs.JSON `field:"readTimeout"` // 读取超时
|
||||||
ConnTimeout string `field:"connTimeout"` // 连接超时
|
ConnTimeout dbs.JSON `field:"connTimeout"` // 连接超时
|
||||||
PoolSize uint32 `field:"poolSize"` // 连接池尺寸
|
PoolSize uint32 `field:"poolSize"` // 连接池尺寸
|
||||||
PathInfoPattern string `field:"pathInfoPattern"` // PATH_INFO匹配
|
PathInfoPattern string `field:"pathInfoPattern"` // PATH_INFO匹配
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPFastcgiOperator struct {
|
type HTTPFastcgiOperator struct {
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
|
|||||||
|
|
||||||
config := &firewallconfigs.HTTPFirewallPolicy{}
|
config := &firewallconfigs.HTTPFirewallPolicy{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
config.Name = policy.Name
|
config.Name = policy.Name
|
||||||
config.Description = policy.Description
|
config.Description = policy.Description
|
||||||
config.UseLocalFirewall = policy.UseLocalFirewall == 1
|
config.UseLocalFirewall = policy.UseLocalFirewall == 1
|
||||||
@@ -379,7 +379,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
|
|||||||
// Inbound
|
// Inbound
|
||||||
inbound := &firewallconfigs.HTTPFirewallInboundConfig{}
|
inbound := &firewallconfigs.HTTPFirewallInboundConfig{}
|
||||||
if IsNotNull(policy.Inbound) {
|
if IsNotNull(policy.Inbound) {
|
||||||
err = json.Unmarshal([]byte(policy.Inbound), inbound)
|
err = json.Unmarshal(policy.Inbound, inbound)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -407,7 +407,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
|
|||||||
// Outbound
|
// Outbound
|
||||||
outbound := &firewallconfigs.HTTPFirewallOutboundConfig{}
|
outbound := &firewallconfigs.HTTPFirewallOutboundConfig{}
|
||||||
if IsNotNull(policy.Outbound) {
|
if IsNotNull(policy.Outbound) {
|
||||||
err = json.Unmarshal([]byte(policy.Outbound), outbound)
|
err = json.Unmarshal(policy.Outbound, outbound)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -435,7 +435,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
|
|||||||
// Block动作配置
|
// Block动作配置
|
||||||
if IsNotNull(policy.BlockOptions) {
|
if IsNotNull(policy.BlockOptions) {
|
||||||
blockAction := &firewallconfigs.HTTPFirewallBlockAction{}
|
blockAction := &firewallconfigs.HTTPFirewallBlockAction{}
|
||||||
err = json.Unmarshal([]byte(policy.BlockOptions), blockAction)
|
err = json.Unmarshal(policy.BlockOptions, blockAction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config, err
|
return config, err
|
||||||
}
|
}
|
||||||
@@ -443,9 +443,9 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// syn flood
|
// syn flood
|
||||||
if len(policy.SynFlood) > 0 {
|
if IsNotNull(policy.SynFlood) {
|
||||||
var synFloodConfig = &firewallconfigs.SYNFloodConfig{}
|
var synFloodConfig = &firewallconfigs.SYNFloodConfig{}
|
||||||
err = json.Unmarshal([]byte(policy.SynFlood), synFloodConfig)
|
err = json.Unmarshal(policy.SynFlood, synFloodConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPFirewallPolicy HTTP防火墙
|
// HTTPFirewallPolicy HTTP防火墙
|
||||||
type HTTPFirewallPolicy struct {
|
type HTTPFirewallPolicy struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
ServerId uint32 `field:"serverId"` // 服务ID
|
ServerId uint32 `field:"serverId"` // 服务ID
|
||||||
GroupId uint32 `field:"groupId"` // 服务分组ID
|
GroupId uint32 `field:"groupId"` // 服务分组ID
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Inbound string `field:"inbound"` // 入站规则
|
Inbound dbs.JSON `field:"inbound"` // 入站规则
|
||||||
Outbound string `field:"outbound"` // 出站规则
|
Outbound dbs.JSON `field:"outbound"` // 出站规则
|
||||||
BlockOptions string `field:"blockOptions"` // BLOCK选项
|
BlockOptions dbs.JSON `field:"blockOptions"` // BLOCK选项
|
||||||
Mode string `field:"mode"` // 模式
|
Mode string `field:"mode"` // 模式
|
||||||
UseLocalFirewall uint8 `field:"useLocalFirewall"` // 是否自动使用本地防火墙
|
UseLocalFirewall uint8 `field:"useLocalFirewall"` // 是否自动使用本地防火墙
|
||||||
SynFlood string `field:"synFlood"` // SynFlood防御设置
|
SynFlood dbs.JSON `field:"synFlood"` // SynFlood防御设置
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPFirewallPolicyOperator struct {
|
type HTTPFirewallPolicyOperator struct {
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化
|
// Init 初始化
|
||||||
func (this *HTTPFirewallRuleDAO) Init() {
|
func (this *HTTPFirewallRuleDAO) Init() {
|
||||||
_ = this.DAOObject.Init()
|
_ = this.DAOObject.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 启用条目
|
// EnableHTTPFirewallRule 启用条目
|
||||||
func (this *HTTPFirewallRuleDAO) EnableHTTPFirewallRule(tx *dbs.Tx, id int64) error {
|
func (this *HTTPFirewallRuleDAO) EnableHTTPFirewallRule(tx *dbs.Tx, id int64) error {
|
||||||
_, err := this.Query(tx).
|
_, err := this.Query(tx).
|
||||||
Pk(id).
|
Pk(id).
|
||||||
@@ -49,7 +49,7 @@ func (this *HTTPFirewallRuleDAO) EnableHTTPFirewallRule(tx *dbs.Tx, id int64) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 禁用条目
|
// DisableHTTPFirewallRule 禁用条目
|
||||||
func (this *HTTPFirewallRuleDAO) DisableHTTPFirewallRule(tx *dbs.Tx, ruleId int64) error {
|
func (this *HTTPFirewallRuleDAO) DisableHTTPFirewallRule(tx *dbs.Tx, ruleId int64) error {
|
||||||
_, err := this.Query(tx).
|
_, err := this.Query(tx).
|
||||||
Pk(ruleId).
|
Pk(ruleId).
|
||||||
@@ -61,7 +61,7 @@ func (this *HTTPFirewallRuleDAO) DisableHTTPFirewallRule(tx *dbs.Tx, ruleId int6
|
|||||||
return this.NotifyUpdate(tx, ruleId)
|
return this.NotifyUpdate(tx, ruleId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找启用中的条目
|
// FindEnabledHTTPFirewallRule 查找启用中的条目
|
||||||
func (this *HTTPFirewallRuleDAO) FindEnabledHTTPFirewallRule(tx *dbs.Tx, id int64) (*HTTPFirewallRule, error) {
|
func (this *HTTPFirewallRuleDAO) FindEnabledHTTPFirewallRule(tx *dbs.Tx, id int64) (*HTTPFirewallRule, error) {
|
||||||
result, err := this.Query(tx).
|
result, err := this.Query(tx).
|
||||||
Pk(id).
|
Pk(id).
|
||||||
@@ -73,7 +73,7 @@ func (this *HTTPFirewallRuleDAO) FindEnabledHTTPFirewallRule(tx *dbs.Tx, id int6
|
|||||||
return result.(*HTTPFirewallRule), err
|
return result.(*HTTPFirewallRule), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 组合配置
|
// ComposeFirewallRule 组合配置
|
||||||
func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (*firewallconfigs.HTTPFirewallRule, error) {
|
func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (*firewallconfigs.HTTPFirewallRule, error) {
|
||||||
rule, err := this.FindEnabledHTTPFirewallRule(tx, ruleId)
|
rule, err := this.FindEnabledHTTPFirewallRule(tx, ruleId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -84,12 +84,12 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
|
|||||||
}
|
}
|
||||||
config := &firewallconfigs.HTTPFirewallRule{}
|
config := &firewallconfigs.HTTPFirewallRule{}
|
||||||
config.Id = int64(rule.Id)
|
config.Id = int64(rule.Id)
|
||||||
config.IsOn = rule.IsOn == 1
|
config.IsOn = rule.IsOn
|
||||||
config.Param = rule.Param
|
config.Param = rule.Param
|
||||||
|
|
||||||
paramFilters := []*firewallconfigs.ParamFilter{}
|
paramFilters := []*firewallconfigs.ParamFilter{}
|
||||||
if IsNotNull(rule.ParamFilters) {
|
if IsNotNull(rule.ParamFilters) {
|
||||||
err = json.Unmarshal([]byte(rule.ParamFilters), ¶mFilters)
|
err = json.Unmarshal(rule.ParamFilters, ¶mFilters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -98,11 +98,11 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
|
|||||||
|
|
||||||
config.Operator = rule.Operator
|
config.Operator = rule.Operator
|
||||||
config.Value = rule.Value
|
config.Value = rule.Value
|
||||||
config.IsCaseInsensitive = rule.IsCaseInsensitive == 1
|
config.IsCaseInsensitive = rule.IsCaseInsensitive
|
||||||
|
|
||||||
if IsNotNull(rule.CheckpointOptions) {
|
if IsNotNull(rule.CheckpointOptions) {
|
||||||
checkpointOptions := map[string]interface{}{}
|
checkpointOptions := map[string]interface{}{}
|
||||||
err = json.Unmarshal([]byte(rule.CheckpointOptions), &checkpointOptions)
|
err = json.Unmarshal(rule.CheckpointOptions, &checkpointOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ func (this *HTTPFirewallRuleDAO) ComposeFirewallRule(tx *dbs.Tx, ruleId int64) (
|
|||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从配置中配置规则
|
// CreateOrUpdateRuleFromConfig 从配置中配置规则
|
||||||
func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleConfig *firewallconfigs.HTTPFirewallRule) (int64, error) {
|
func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleConfig *firewallconfigs.HTTPFirewallRule) (int64, error) {
|
||||||
op := NewHTTPFirewallRuleOperator()
|
op := NewHTTPFirewallRuleOperator()
|
||||||
op.Id = ruleConfig.Id
|
op.Id = ruleConfig.Id
|
||||||
@@ -160,7 +160,7 @@ func (this *HTTPFirewallRuleDAO) CreateOrUpdateRuleFromConfig(tx *dbs.Tx, ruleCo
|
|||||||
return types.Int64(op.Id), nil
|
return types.Int64(op.Id), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通知更新
|
// NotifyUpdate 通知更新
|
||||||
func (this *HTTPFirewallRuleDAO) NotifyUpdate(tx *dbs.Tx, ruleId int64) error {
|
func (this *HTTPFirewallRuleDAO) NotifyUpdate(tx *dbs.Tx, ruleId int64) error {
|
||||||
setId, err := SharedHTTPFirewallRuleSetDAO.FindEnabledRuleSetIdWithRuleId(tx, ruleId)
|
setId, err := SharedHTTPFirewallRuleSetDAO.FindEnabledRuleSetIdWithRuleId(tx, ruleId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -91,15 +91,15 @@ func (this *HTTPFirewallRuleGroupDAO) ComposeFirewallRuleGroup(tx *dbs.Tx, group
|
|||||||
}
|
}
|
||||||
config := &firewallconfigs.HTTPFirewallRuleGroup{}
|
config := &firewallconfigs.HTTPFirewallRuleGroup{}
|
||||||
config.Id = int64(group.Id)
|
config.Id = int64(group.Id)
|
||||||
config.IsOn = group.IsOn == 1
|
config.IsOn = group.IsOn
|
||||||
config.Name = group.Name
|
config.Name = group.Name
|
||||||
config.Description = group.Description
|
config.Description = group.Description
|
||||||
config.Code = group.Code
|
config.Code = group.Code
|
||||||
config.IsTemplate = group.IsTemplate == 1
|
config.IsTemplate = group.IsTemplate
|
||||||
|
|
||||||
if IsNotNull(group.Sets) {
|
if IsNotNull(group.Sets) {
|
||||||
setRefs := []*firewallconfigs.HTTPFirewallRuleSetRef{}
|
setRefs := []*firewallconfigs.HTTPFirewallRuleSetRef{}
|
||||||
err = json.Unmarshal([]byte(group.Sets), &setRefs)
|
err = json.Unmarshal(group.Sets, &setRefs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPFirewallRuleGroup 防火墙规则分组
|
// HTTPFirewallRuleGroup 防火墙规则分组
|
||||||
type HTTPFirewallRuleGroup struct {
|
type HTTPFirewallRuleGroup struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Code string `field:"code"` // 代号
|
Code string `field:"code"` // 代号
|
||||||
IsTemplate uint8 `field:"isTemplate"` // 是否为预置模板
|
IsTemplate bool `field:"isTemplate"` // 是否为预置模板
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
Sets string `field:"sets"` // 规则集列表
|
Sets dbs.JSON `field:"sets"` // 规则集列表
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPFirewallRuleGroupOperator struct {
|
type HTTPFirewallRuleGroupOperator struct {
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 防火墙规则
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
|
// HTTPFirewallRule 防火墙规则
|
||||||
type HTTPFirewallRule struct {
|
type HTTPFirewallRule struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Description string `field:"description"` // 说明
|
Description string `field:"description"` // 说明
|
||||||
Param string `field:"param"` // 参数
|
Param string `field:"param"` // 参数
|
||||||
ParamFilters string `field:"paramFilters"` // 处理器
|
ParamFilters dbs.JSON `field:"paramFilters"` // 处理器
|
||||||
Operator string `field:"operator"` // 操作符
|
Operator string `field:"operator"` // 操作符
|
||||||
Value string `field:"value"` // 对比值
|
Value string `field:"value"` // 对比值
|
||||||
IsCaseInsensitive uint8 `field:"isCaseInsensitive"` // 是否大小写不敏感
|
IsCaseInsensitive bool `field:"isCaseInsensitive"` // 是否大小写不敏感
|
||||||
CheckpointOptions string `field:"checkpointOptions"` // 检查点参数
|
CheckpointOptions dbs.JSON `field:"checkpointOptions"` // 检查点参数
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPFirewallRuleOperator struct {
|
type HTTPFirewallRuleOperator struct {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
|
|||||||
}
|
}
|
||||||
config := &firewallconfigs.HTTPFirewallRuleSet{}
|
config := &firewallconfigs.HTTPFirewallRuleSet{}
|
||||||
config.Id = int64(set.Id)
|
config.Id = int64(set.Id)
|
||||||
config.IsOn = set.IsOn == 1
|
config.IsOn = set.IsOn
|
||||||
config.Name = set.Name
|
config.Name = set.Name
|
||||||
config.Description = set.Description
|
config.Description = set.Description
|
||||||
config.Code = set.Code
|
config.Code = set.Code
|
||||||
@@ -103,7 +103,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
|
|||||||
|
|
||||||
if IsNotNull(set.Rules) {
|
if IsNotNull(set.Rules) {
|
||||||
ruleRefs := []*firewallconfigs.HTTPFirewallRuleRef{}
|
ruleRefs := []*firewallconfigs.HTTPFirewallRuleRef{}
|
||||||
err = json.Unmarshal([]byte(set.Rules), &ruleRefs)
|
err = json.Unmarshal(set.Rules, &ruleRefs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ func (this *HTTPFirewallRuleSetDAO) ComposeFirewallRuleSet(tx *dbs.Tx, setId int
|
|||||||
|
|
||||||
var actionConfigs = []*firewallconfigs.HTTPFirewallActionConfig{}
|
var actionConfigs = []*firewallconfigs.HTTPFirewallActionConfig{}
|
||||||
if len(set.Actions) > 0 {
|
if len(set.Actions) > 0 {
|
||||||
err = json.Unmarshal([]byte(set.Actions), &actionConfigs)
|
err = json.Unmarshal(set.Actions, &actionConfigs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPFirewallRuleSet 防火墙规则集
|
// HTTPFirewallRuleSet 防火墙规则集
|
||||||
type HTTPFirewallRuleSet struct {
|
type HTTPFirewallRuleSet struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Code string `field:"code"` // 代号
|
Code string `field:"code"` // 代号
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Rules string `field:"rules"` // 规则列表
|
Rules dbs.JSON `field:"rules"` // 规则列表
|
||||||
Connector string `field:"connector"` // 规则之间的关系
|
Connector string `field:"connector"` // 规则之间的关系
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
Action string `field:"action"` // 执行的动作(过期)
|
Action string `field:"action"` // 执行的动作(过期)
|
||||||
ActionOptions string `field:"actionOptions"` // 动作的选项(过期)
|
ActionOptions dbs.JSON `field:"actionOptions"` // 动作的选项(过期)
|
||||||
Actions string `field:"actions"` // 一组动作
|
Actions dbs.JSON `field:"actions"` // 一组动作
|
||||||
IgnoreLocal uint8 `field:"ignoreLocal"` // 忽略局域网请求
|
IgnoreLocal uint8 `field:"ignoreLocal"` // 忽略局域网请求
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPFirewallRuleSetOperator struct {
|
type HTTPFirewallRuleSetOperator struct {
|
||||||
|
|||||||
@@ -88,10 +88,10 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPGzipCompressionConfig{}
|
config := &serverconfigs.HTTPGzipCompressionConfig{}
|
||||||
config.Id = int64(gzip.Id)
|
config.Id = int64(gzip.Id)
|
||||||
config.IsOn = gzip.IsOn == 1
|
config.IsOn = gzip.IsOn
|
||||||
if IsNotNull(gzip.MinLength) {
|
if IsNotNull(gzip.MinLength) {
|
||||||
minLengthConfig := &shared.SizeCapacity{}
|
minLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal([]byte(gzip.MinLength), minLengthConfig)
|
err = json.Unmarshal(gzip.MinLength, minLengthConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
|
|||||||
}
|
}
|
||||||
if IsNotNull(gzip.MaxLength) {
|
if IsNotNull(gzip.MaxLength) {
|
||||||
maxLengthConfig := &shared.SizeCapacity{}
|
maxLengthConfig := &shared.SizeCapacity{}
|
||||||
err = json.Unmarshal([]byte(gzip.MaxLength), maxLengthConfig)
|
err = json.Unmarshal(gzip.MaxLength, maxLengthConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(tx *dbs.Tx, gzipId int64) (*servercon
|
|||||||
|
|
||||||
if IsNotNull(gzip.Conds) {
|
if IsNotNull(gzip.Conds) {
|
||||||
condsConfig := &shared.HTTPRequestCondsConfig{}
|
condsConfig := &shared.HTTPRequestCondsConfig{}
|
||||||
err = json.Unmarshal([]byte(gzip.Conds), condsConfig)
|
err = json.Unmarshal(gzip.Conds, condsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// Gzip配置
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
|
// HTTPGzip Gzip配置
|
||||||
type HTTPGzip struct {
|
type HTTPGzip struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Level uint32 `field:"level"` // 压缩级别
|
Level uint32 `field:"level"` // 压缩级别
|
||||||
MinLength string `field:"minLength"` // 可压缩最小值
|
MinLength dbs.JSON `field:"minLength"` // 可压缩最小值
|
||||||
MaxLength string `field:"maxLength"` // 可压缩最大值
|
MaxLength dbs.JSON `field:"maxLength"` // 可压缩最大值
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Conds string `field:"conds"` // 条件
|
Conds dbs.JSON `field:"conds"` // 条件
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPGzipOperator struct {
|
type HTTPGzipOperator struct {
|
||||||
|
|||||||
@@ -5,22 +5,22 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 解析最小长度
|
// DecodeMinLength 解析最小长度
|
||||||
func (this *HTTPGzip) DecodeMinLength() (*shared.SizeCapacity, error) {
|
func (this *HTTPGzip) DecodeMinLength() (*shared.SizeCapacity, error) {
|
||||||
if len(this.MinLength) == 0 {
|
if len(this.MinLength) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
capacity := &shared.SizeCapacity{}
|
capacity := &shared.SizeCapacity{}
|
||||||
err := json.Unmarshal([]byte(this.MinLength), capacity)
|
err := json.Unmarshal(this.MinLength, capacity)
|
||||||
return capacity, err
|
return capacity, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析最大长度
|
// DecodeMaxLength 解析最大长度
|
||||||
func (this *HTTPGzip) DecodeMaxLength() (*shared.SizeCapacity, error) {
|
func (this *HTTPGzip) DecodeMaxLength() (*shared.SizeCapacity, error) {
|
||||||
if len(this.MaxLength) == 0 {
|
if len(this.MaxLength) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
capacity := &shared.SizeCapacity{}
|
capacity := &shared.SizeCapacity{}
|
||||||
err := json.Unmarshal([]byte(this.MaxLength), capacity)
|
err := json.Unmarshal(this.MaxLength, capacity)
|
||||||
return capacity, err
|
return capacity, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
|
|||||||
|
|
||||||
config := &shared.HTTPHeaderConfig{}
|
config := &shared.HTTPHeaderConfig{}
|
||||||
config.Id = int64(header.Id)
|
config.Id = int64(header.Id)
|
||||||
config.IsOn = header.IsOn == 1
|
config.IsOn = header.IsOn
|
||||||
config.Name = header.Name
|
config.Name = header.Name
|
||||||
config.Value = header.Value
|
config.Value = header.Value
|
||||||
config.DisableRedirect = header.DisableRedirect == 1
|
config.DisableRedirect = header.DisableRedirect == 1
|
||||||
@@ -244,9 +244,9 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
|
|||||||
|
|
||||||
// replace
|
// replace
|
||||||
config.ShouldReplace = header.ShouldReplace == 1
|
config.ShouldReplace = header.ShouldReplace == 1
|
||||||
if len(header.ReplaceValues) > 0 {
|
if IsNotNull(header.ReplaceValues) {
|
||||||
var values = []*shared.HTTPHeaderReplaceValue{}
|
var values = []*shared.HTTPHeaderReplaceValue{}
|
||||||
err = json.Unmarshal([]byte(header.ReplaceValues), &values)
|
err = json.Unmarshal(header.ReplaceValues, &values)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -254,9 +254,9 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// status
|
// status
|
||||||
if len(header.Status) > 0 {
|
if IsNotNull(header.Status) {
|
||||||
status := &shared.HTTPStatusConfig{}
|
status := &shared.HTTPStatusConfig{}
|
||||||
err = json.Unmarshal([]byte(header.Status), status)
|
err = json.Unmarshal(header.Status, status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -264,9 +264,9 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
if len(header.Methods) > 0 {
|
if IsNotNull(header.Methods) {
|
||||||
var methods = []string{}
|
var methods = []string{}
|
||||||
err = json.Unmarshal([]byte(header.Methods), &methods)
|
err = json.Unmarshal(header.Methods, &methods)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -274,9 +274,9 @@ func (this *HTTPHeaderDAO) ComposeHeaderConfig(tx *dbs.Tx, headerId int64) (*sha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// domains
|
// domains
|
||||||
if len(header.Domains) > 0 {
|
if IsNotNull(header.Domains) {
|
||||||
var domains = []string{}
|
var domains = []string{}
|
||||||
err = json.Unmarshal([]byte(header.Domains), &domains)
|
err = json.Unmarshal(header.Domains, &domains)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPHeader HTTP Header
|
// HTTPHeader HTTP Header
|
||||||
type HTTPHeader struct {
|
type HTTPHeader struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Value string `field:"value"` // 值
|
Value string `field:"value"` // 值
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
Status string `field:"status"` // 状态码设置
|
Status dbs.JSON `field:"status"` // 状态码设置
|
||||||
DisableRedirect uint8 `field:"disableRedirect"` // 是否不支持跳转
|
DisableRedirect uint8 `field:"disableRedirect"` // 是否不支持跳转
|
||||||
ShouldAppend uint8 `field:"shouldAppend"` // 是否为附加
|
ShouldAppend uint8 `field:"shouldAppend"` // 是否为附加
|
||||||
ShouldReplace uint8 `field:"shouldReplace"` // 是否替换变量
|
ShouldReplace uint8 `field:"shouldReplace"` // 是否替换变量
|
||||||
ReplaceValues string `field:"replaceValues"` // 替换的值
|
ReplaceValues dbs.JSON `field:"replaceValues"` // 替换的值
|
||||||
Methods string `field:"methods"` // 支持的方法
|
Methods dbs.JSON `field:"methods"` // 支持的方法
|
||||||
Domains string `field:"domains"` // 支持的域名
|
Domains dbs.JSON `field:"domains"` // 支持的域名
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPHeaderOperator struct {
|
type HTTPHeaderOperator struct {
|
||||||
|
|||||||
@@ -184,12 +184,12 @@ func (this *HTTPHeaderPolicyDAO) ComposeHeaderPolicyConfig(tx *dbs.Tx, headerPol
|
|||||||
|
|
||||||
config := &shared.HTTPHeaderPolicy{}
|
config := &shared.HTTPHeaderPolicy{}
|
||||||
config.Id = int64(policy.Id)
|
config.Id = int64(policy.Id)
|
||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn
|
||||||
|
|
||||||
// SetHeaders
|
// SetHeaders
|
||||||
if len(policy.SetHeaders) > 0 {
|
if IsNotNull(policy.SetHeaders) {
|
||||||
refs := []*shared.HTTPHeaderRef{}
|
refs := []*shared.HTTPHeaderRef{}
|
||||||
err = json.Unmarshal([]byte(policy.SetHeaders), &refs)
|
err = json.Unmarshal(policy.SetHeaders, &refs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -211,9 +211,9 @@ func (this *HTTPHeaderPolicyDAO) ComposeHeaderPolicyConfig(tx *dbs.Tx, headerPol
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete Headers
|
// Delete Headers
|
||||||
if len(policy.DeleteHeaders) > 0 {
|
if IsNotNull(policy.DeleteHeaders) {
|
||||||
headers := []string{}
|
headers := []string{}
|
||||||
err = json.Unmarshal([]byte(policy.DeleteHeaders), &headers)
|
err = json.Unmarshal(policy.DeleteHeaders, &headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
//
|
//
|
||||||
type HTTPHeaderPolicy struct {
|
type HTTPHeaderPolicy struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
AddHeaders string `field:"addHeaders"` // 添加的Header
|
AddHeaders dbs.JSON `field:"addHeaders"` // 添加的Header
|
||||||
AddTrailers string `field:"addTrailers"` // 添加的Trailers
|
AddTrailers dbs.JSON `field:"addTrailers"` // 添加的Trailers
|
||||||
SetHeaders string `field:"setHeaders"` // 设置Header
|
SetHeaders dbs.JSON `field:"setHeaders"` // 设置Header
|
||||||
ReplaceHeaders string `field:"replaceHeaders"` // 替换Header内容
|
ReplaceHeaders dbs.JSON `field:"replaceHeaders"` // 替换Header内容
|
||||||
Expires string `field:"expires"` // Expires单独设置
|
Expires dbs.JSON `field:"expires"` // Expires单独设置
|
||||||
DeleteHeaders string `field:"deleteHeaders"` // 删除的Headers
|
DeleteHeaders dbs.JSON `field:"deleteHeaders"` // 删除的Headers
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPHeaderPolicyOperator struct {
|
type HTTPHeaderPolicyOperator struct {
|
||||||
|
|||||||
@@ -170,12 +170,12 @@ func (this *HTTPLocationDAO) ComposeLocationConfig(tx *dbs.Tx, locationId int64,
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPLocationConfig{}
|
config := &serverconfigs.HTTPLocationConfig{}
|
||||||
config.Id = int64(location.Id)
|
config.Id = int64(location.Id)
|
||||||
config.IsOn = location.IsOn == 1
|
config.IsOn = location.IsOn
|
||||||
config.Description = location.Description
|
config.Description = location.Description
|
||||||
config.Name = location.Name
|
config.Name = location.Name
|
||||||
config.Pattern = location.Pattern
|
config.Pattern = location.Pattern
|
||||||
config.URLPrefix = location.UrlPrefix
|
config.URLPrefix = location.UrlPrefix
|
||||||
config.IsBreak = location.IsBreak == 1
|
config.IsBreak = location.IsBreak
|
||||||
|
|
||||||
// web
|
// web
|
||||||
if location.WebId > 0 {
|
if location.WebId > 0 {
|
||||||
@@ -189,7 +189,7 @@ func (this *HTTPLocationDAO) ComposeLocationConfig(tx *dbs.Tx, locationId int64,
|
|||||||
// reverse proxy
|
// reverse proxy
|
||||||
if IsNotNull(location.ReverseProxy) {
|
if IsNotNull(location.ReverseProxy) {
|
||||||
ref := &serverconfigs.ReverseProxyRef{}
|
ref := &serverconfigs.ReverseProxyRef{}
|
||||||
err = json.Unmarshal([]byte(location.ReverseProxy), ref)
|
err = json.Unmarshal(location.ReverseProxy, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -204,9 +204,9 @@ func (this *HTTPLocationDAO) ComposeLocationConfig(tx *dbs.Tx, locationId int64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// conds
|
// conds
|
||||||
if len(location.Conds) > 0 {
|
if IsNotNull(location.Conds) {
|
||||||
conds := &shared.HTTPRequestCondsConfig{}
|
conds := &shared.HTTPRequestCondsConfig{}
|
||||||
err = json.Unmarshal([]byte(location.Conds), conds)
|
err = json.Unmarshal(location.Conds, conds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -214,9 +214,9 @@ func (this *HTTPLocationDAO) ComposeLocationConfig(tx *dbs.Tx, locationId int64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// domains
|
// domains
|
||||||
if len(location.Domains) > 0 {
|
if IsNotNull(location.Domains) {
|
||||||
var domains = []string{}
|
var domains = []string{}
|
||||||
err = json.Unmarshal([]byte(location.Domains), &domains)
|
err = json.Unmarshal(location.Domains, &domains)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ func (this *HTTPLocationDAO) FindLocationReverseProxy(tx *dbs.Tx, locationId int
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if IsNotNull(refString) {
|
if IsNotNull([]byte(refString)) {
|
||||||
ref := &serverconfigs.ReverseProxyRef{}
|
ref := &serverconfigs.ReverseProxyRef{}
|
||||||
err = json.Unmarshal([]byte(refString), ref)
|
err = json.Unmarshal([]byte(refString), ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPLocation 路由规则配置
|
// HTTPLocation 路由规则配置
|
||||||
type HTTPLocation struct {
|
type HTTPLocation struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
ParentId uint32 `field:"parentId"` // 父级ID
|
ParentId uint32 `field:"parentId"` // 父级ID
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Pattern string `field:"pattern"` // 匹配规则
|
Pattern string `field:"pattern"` // 匹配规则
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
WebId uint32 `field:"webId"` // Web配置ID
|
WebId uint32 `field:"webId"` // Web配置ID
|
||||||
ReverseProxy string `field:"reverseProxy"` // 反向代理
|
ReverseProxy dbs.JSON `field:"reverseProxy"` // 反向代理
|
||||||
UrlPrefix string `field:"urlPrefix"` // URL前缀
|
UrlPrefix string `field:"urlPrefix"` // URL前缀
|
||||||
IsBreak uint8 `field:"isBreak"` // 是否终止匹配
|
IsBreak bool `field:"isBreak"` // 是否终止匹配
|
||||||
Conds string `field:"conds"` // 匹配条件
|
Conds dbs.JSON `field:"conds"` // 匹配条件
|
||||||
Domains string `field:"domains"` // 专属域名
|
Domains dbs.JSON `field:"domains"` // 专属域名
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPLocationOperator struct {
|
type HTTPLocationOperator struct {
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ func (this *HTTPPageDAO) ComposePageConfig(tx *dbs.Tx, pageId int64, cacheMap *u
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPPageConfig{}
|
config := &serverconfigs.HTTPPageConfig{}
|
||||||
config.Id = int64(page.Id)
|
config.Id = int64(page.Id)
|
||||||
config.IsOn = page.IsOn == 1
|
config.IsOn = page.IsOn
|
||||||
config.NewStatus = int(page.NewStatus)
|
config.NewStatus = int(page.NewStatus)
|
||||||
config.URL = page.Url
|
config.URL = page.Url
|
||||||
config.Body = page.Body
|
config.Body = page.Body
|
||||||
@@ -166,7 +166,7 @@ func (this *HTTPPageDAO) ComposePageConfig(tx *dbs.Tx, pageId int64, cacheMap *u
|
|||||||
|
|
||||||
if len(page.StatusList) > 0 {
|
if len(page.StatusList) > 0 {
|
||||||
statusList := []string{}
|
statusList := []string{}
|
||||||
err = json.Unmarshal([]byte(page.StatusList), &statusList)
|
err = json.Unmarshal(page.StatusList, &statusList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPPage 特殊页面
|
// HTTPPage 特殊页面
|
||||||
type HTTPPage struct {
|
type HTTPPage struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
StatusList string `field:"statusList"` // 状态列表
|
StatusList dbs.JSON `field:"statusList"` // 状态列表
|
||||||
Url string `field:"url"` // 页面URL
|
Url string `field:"url"` // 页面URL
|
||||||
NewStatus int32 `field:"newStatus"` // 新状态码
|
NewStatus int32 `field:"newStatus"` // 新状态码
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Body string `field:"body"` // 页面内容
|
Body string `field:"body"` // 页面内容
|
||||||
BodyType string `field:"bodyType"` // 内容类型
|
BodyType string `field:"bodyType"` // 内容类型
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPPageOperator struct {
|
type HTTPPageOperator struct {
|
||||||
|
|||||||
@@ -97,19 +97,19 @@ func (this *HTTPRewriteRuleDAO) ComposeRewriteRule(tx *dbs.Tx, rewriteRuleId int
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPRewriteRule{}
|
config := &serverconfigs.HTTPRewriteRule{}
|
||||||
config.Id = int64(rule.Id)
|
config.Id = int64(rule.Id)
|
||||||
config.IsOn = rule.IsOn == 1
|
config.IsOn = rule.IsOn
|
||||||
config.Pattern = rule.Pattern
|
config.Pattern = rule.Pattern
|
||||||
config.Replace = rule.Replace
|
config.Replace = rule.Replace
|
||||||
config.Mode = rule.Mode
|
config.Mode = rule.Mode
|
||||||
config.RedirectStatus = types.Int(rule.RedirectStatus)
|
config.RedirectStatus = types.Int(rule.RedirectStatus)
|
||||||
config.ProxyHost = rule.ProxyHost
|
config.ProxyHost = rule.ProxyHost
|
||||||
config.IsBreak = rule.IsBreak == 1
|
config.IsBreak = rule.IsBreak
|
||||||
config.WithQuery = rule.WithQuery == 1
|
config.WithQuery = rule.WithQuery == 1
|
||||||
|
|
||||||
// conds
|
// conds
|
||||||
if len(rule.Conds) > 0 {
|
if len(rule.Conds) > 0 {
|
||||||
conds := &shared.HTTPRequestCondsConfig{}
|
conds := &shared.HTTPRequestCondsConfig{}
|
||||||
err = json.Unmarshal([]byte(rule.Conds), conds)
|
err = json.Unmarshal(rule.Conds, conds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// 重写规则
|
// 重写规则
|
||||||
type HTTPRewriteRule struct {
|
type HTTPRewriteRule struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Pattern string `field:"pattern"` // 匹配规则
|
Pattern string `field:"pattern"` // 匹配规则
|
||||||
Replace string `field:"replace"` // 跳转后的地址
|
Replace string `field:"replace"` // 跳转后的地址
|
||||||
Mode string `field:"mode"` // 替换模式
|
Mode string `field:"mode"` // 替换模式
|
||||||
RedirectStatus uint32 `field:"redirectStatus"` // 跳转的状态码
|
RedirectStatus uint32 `field:"redirectStatus"` // 跳转的状态码
|
||||||
ProxyHost string `field:"proxyHost"` // 代理的主机名
|
ProxyHost string `field:"proxyHost"` // 代理的主机名
|
||||||
IsBreak uint8 `field:"isBreak"` // 是否终止解析
|
IsBreak bool `field:"isBreak"` // 是否终止解析
|
||||||
WithQuery uint8 `field:"withQuery"` // 是否保留URI参数
|
WithQuery uint8 `field:"withQuery"` // 是否保留URI参数
|
||||||
Conds string `field:"conds"` // 匹配条件
|
Conds dbs.JSON `field:"conds"` // 匹配条件
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPRewriteRuleOperator struct {
|
type HTTPRewriteRuleOperator struct {
|
||||||
|
|||||||
@@ -96,12 +96,12 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
|
|
||||||
config := &serverconfigs.HTTPWebConfig{}
|
config := &serverconfigs.HTTPWebConfig{}
|
||||||
config.Id = webId
|
config.Id = webId
|
||||||
config.IsOn = web.IsOn == 1
|
config.IsOn = web.IsOn
|
||||||
|
|
||||||
// root
|
// root
|
||||||
if IsNotNull(web.Root) {
|
if IsNotNull(web.Root) {
|
||||||
rootConfig := &serverconfigs.HTTPRootConfig{}
|
rootConfig := &serverconfigs.HTTPRootConfig{}
|
||||||
err = json.Unmarshal([]byte(web.Root), rootConfig)
|
err = json.Unmarshal(web.Root, rootConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// compression
|
// compression
|
||||||
if IsNotNull(web.Compression) {
|
if IsNotNull(web.Compression) {
|
||||||
compression := &serverconfigs.HTTPCompressionConfig{}
|
compression := &serverconfigs.HTTPCompressionConfig{}
|
||||||
err = json.Unmarshal([]byte(web.Compression), compression)
|
err = json.Unmarshal(web.Compression, compression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// charset
|
// charset
|
||||||
if IsNotNull(web.Charset) {
|
if IsNotNull(web.Charset) {
|
||||||
charsetConfig := &serverconfigs.HTTPCharsetConfig{}
|
charsetConfig := &serverconfigs.HTTPCharsetConfig{}
|
||||||
err = json.Unmarshal([]byte(web.Charset), charsetConfig)
|
err = json.Unmarshal(web.Charset, charsetConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// headers
|
// headers
|
||||||
if IsNotNull(web.RequestHeader) {
|
if IsNotNull(web.RequestHeader) {
|
||||||
ref := &shared.HTTPHeaderPolicyRef{}
|
ref := &shared.HTTPHeaderPolicyRef{}
|
||||||
err = json.Unmarshal([]byte(web.RequestHeader), ref)
|
err = json.Unmarshal(web.RequestHeader, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
|
|
||||||
if IsNotNull(web.ResponseHeader) {
|
if IsNotNull(web.ResponseHeader) {
|
||||||
ref := &shared.HTTPHeaderPolicyRef{}
|
ref := &shared.HTTPHeaderPolicyRef{}
|
||||||
err = json.Unmarshal([]byte(web.ResponseHeader), ref)
|
err = json.Unmarshal(web.ResponseHeader, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// shutdown
|
// shutdown
|
||||||
if IsNotNull(web.Shutdown) {
|
if IsNotNull(web.Shutdown) {
|
||||||
shutdownConfig := &serverconfigs.HTTPShutdownConfig{}
|
shutdownConfig := &serverconfigs.HTTPShutdownConfig{}
|
||||||
err = json.Unmarshal([]byte(web.Shutdown), shutdownConfig)
|
err = json.Unmarshal(web.Shutdown, shutdownConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// pages
|
// pages
|
||||||
if IsNotNull(web.Pages) {
|
if IsNotNull(web.Pages) {
|
||||||
pages := []*serverconfigs.HTTPPageConfig{}
|
pages := []*serverconfigs.HTTPPageConfig{}
|
||||||
err = json.Unmarshal([]byte(web.Pages), &pages)
|
err = json.Unmarshal(web.Pages, &pages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 访问日志
|
// 访问日志
|
||||||
if IsNotNull(web.AccessLog) {
|
if IsNotNull(web.AccessLog) {
|
||||||
accessLogConfig := &serverconfigs.HTTPAccessLogRef{}
|
accessLogConfig := &serverconfigs.HTTPAccessLogRef{}
|
||||||
err = json.Unmarshal([]byte(web.AccessLog), accessLogConfig)
|
err = json.Unmarshal(web.AccessLog, accessLogConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 统计配置
|
// 统计配置
|
||||||
if IsNotNull(web.Stat) {
|
if IsNotNull(web.Stat) {
|
||||||
statRef := &serverconfigs.HTTPStatRef{}
|
statRef := &serverconfigs.HTTPStatRef{}
|
||||||
err = json.Unmarshal([]byte(web.Stat), statRef)
|
err = json.Unmarshal(web.Stat, statRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 缓存配置
|
// 缓存配置
|
||||||
if IsNotNull(web.Cache) {
|
if IsNotNull(web.Cache) {
|
||||||
cacheConfig := &serverconfigs.HTTPCacheConfig{}
|
cacheConfig := &serverconfigs.HTTPCacheConfig{}
|
||||||
err = json.Unmarshal([]byte(web.Cache), &cacheConfig)
|
err = json.Unmarshal(web.Cache, &cacheConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 防火墙配置
|
// 防火墙配置
|
||||||
if IsNotNull(web.Firewall) {
|
if IsNotNull(web.Firewall) {
|
||||||
firewallRef := &firewallconfigs.HTTPFirewallRef{}
|
firewallRef := &firewallconfigs.HTTPFirewallRef{}
|
||||||
err = json.Unmarshal([]byte(web.Firewall), firewallRef)
|
err = json.Unmarshal(web.Firewall, firewallRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 路由规则
|
// 路由规则
|
||||||
if IsNotNull(web.Locations) {
|
if IsNotNull(web.Locations) {
|
||||||
refs := []*serverconfigs.HTTPLocationRef{}
|
refs := []*serverconfigs.HTTPLocationRef{}
|
||||||
err = json.Unmarshal([]byte(web.Locations), &refs)
|
err = json.Unmarshal(web.Locations, &refs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 跳转
|
// 跳转
|
||||||
if IsNotNull(web.RedirectToHttps) {
|
if IsNotNull(web.RedirectToHttps) {
|
||||||
redirectToHTTPSConfig := &serverconfigs.HTTPRedirectToHTTPSConfig{}
|
redirectToHTTPSConfig := &serverconfigs.HTTPRedirectToHTTPSConfig{}
|
||||||
err = json.Unmarshal([]byte(web.RedirectToHttps), redirectToHTTPSConfig)
|
err = json.Unmarshal(web.RedirectToHttps, redirectToHTTPSConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -309,7 +309,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// Websocket
|
// Websocket
|
||||||
if IsNotNull(web.Websocket) {
|
if IsNotNull(web.Websocket) {
|
||||||
ref := &serverconfigs.HTTPWebsocketRef{}
|
ref := &serverconfigs.HTTPWebsocketRef{}
|
||||||
err = json.Unmarshal([]byte(web.Websocket), ref)
|
err = json.Unmarshal(web.Websocket, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -328,7 +328,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 重写规则
|
// 重写规则
|
||||||
if IsNotNull(web.RewriteRules) {
|
if IsNotNull(web.RewriteRules) {
|
||||||
refs := []*serverconfigs.HTTPRewriteRef{}
|
refs := []*serverconfigs.HTTPRewriteRef{}
|
||||||
err = json.Unmarshal([]byte(web.RewriteRules), &refs)
|
err = json.Unmarshal(web.RewriteRules, &refs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 主机跳转
|
// 主机跳转
|
||||||
if IsNotNull(web.HostRedirects) {
|
if IsNotNull(web.HostRedirects) {
|
||||||
redirects := []*serverconfigs.HTTPHostRedirectConfig{}
|
redirects := []*serverconfigs.HTTPHostRedirectConfig{}
|
||||||
err = json.Unmarshal([]byte(web.HostRedirects), &redirects)
|
err = json.Unmarshal(web.HostRedirects, &redirects)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -357,7 +357,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// Fastcgi
|
// Fastcgi
|
||||||
if IsNotNull(web.Fastcgi) {
|
if IsNotNull(web.Fastcgi) {
|
||||||
ref := &serverconfigs.HTTPFastcgiRef{}
|
ref := &serverconfigs.HTTPFastcgiRef{}
|
||||||
err = json.Unmarshal([]byte(web.Fastcgi), ref)
|
err = json.Unmarshal(web.Fastcgi, ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -381,7 +381,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// 认证
|
// 认证
|
||||||
if IsNotNull(web.Auth) {
|
if IsNotNull(web.Auth) {
|
||||||
authConfig := &serverconfigs.HTTPAuthConfig{}
|
authConfig := &serverconfigs.HTTPAuthConfig{}
|
||||||
err = json.Unmarshal([]byte(web.Auth), authConfig)
|
err = json.Unmarshal(web.Auth, authConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -402,7 +402,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// WebP
|
// WebP
|
||||||
if IsNotNull(web.Webp) {
|
if IsNotNull(web.Webp) {
|
||||||
var webpConfig = &serverconfigs.WebPImageConfig{}
|
var webpConfig = &serverconfigs.WebPImageConfig{}
|
||||||
err = json.Unmarshal([]byte(web.Webp), webpConfig)
|
err = json.Unmarshal(web.Webp, webpConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -412,7 +412,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
// RemoteAddr
|
// RemoteAddr
|
||||||
if IsNotNull(web.RemoteAddr) {
|
if IsNotNull(web.RemoteAddr) {
|
||||||
var remoteAddrConfig = &serverconfigs.HTTPRemoteAddrConfig{}
|
var remoteAddrConfig = &serverconfigs.HTTPRemoteAddrConfig{}
|
||||||
err = json.Unmarshal([]byte(web.RemoteAddr), remoteAddrConfig)
|
err = json.Unmarshal(web.RemoteAddr, remoteAddrConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -426,7 +426,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
if len(web.RequestLimit) > 0 {
|
if len(web.RequestLimit) > 0 {
|
||||||
var requestLimitConfig = &serverconfigs.HTTPRequestLimitConfig{}
|
var requestLimitConfig = &serverconfigs.HTTPRequestLimitConfig{}
|
||||||
if len(web.RequestLimit) > 0 {
|
if len(web.RequestLimit) > 0 {
|
||||||
err = json.Unmarshal([]byte(web.RequestLimit), requestLimitConfig)
|
err = json.Unmarshal(web.RequestLimit, requestLimitConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -438,7 +438,7 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *util
|
|||||||
if len(web.RequestScripts) > 0 {
|
if len(web.RequestScripts) > 0 {
|
||||||
var requestScriptsConfig = &serverconfigs.HTTPRequestScriptsConfig{}
|
var requestScriptsConfig = &serverconfigs.HTTPRequestScriptsConfig{}
|
||||||
if len(web.RequestScripts) > 0 {
|
if len(web.RequestScripts) > 0 {
|
||||||
err = json.Unmarshal([]byte(web.RequestScripts), requestScriptsConfig)
|
err = json.Unmarshal(web.RequestScripts, requestScriptsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,42 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// HTTPWeb HTTP Web
|
// HTTPWeb HTTP Web
|
||||||
type HTTPWeb struct {
|
type HTTPWeb struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Root string `field:"root"` // 根目录
|
Root dbs.JSON `field:"root"` // 根目录
|
||||||
Charset string `field:"charset"` // 字符集
|
Charset dbs.JSON `field:"charset"` // 字符集
|
||||||
Shutdown string `field:"shutdown"` // 临时关闭页面配置
|
Shutdown dbs.JSON `field:"shutdown"` // 临时关闭页面配置
|
||||||
Pages string `field:"pages"` // 特殊页面
|
Pages dbs.JSON `field:"pages"` // 特殊页面
|
||||||
RedirectToHttps string `field:"redirectToHttps"` // 跳转到HTTPS设置
|
RedirectToHttps dbs.JSON `field:"redirectToHttps"` // 跳转到HTTPS设置
|
||||||
Indexes string `field:"indexes"` // 首页文件列表
|
Indexes dbs.JSON `field:"indexes"` // 首页文件列表
|
||||||
MaxRequestBodySize string `field:"maxRequestBodySize"` // 最大允许的请求内容尺寸
|
MaxRequestBodySize dbs.JSON `field:"maxRequestBodySize"` // 最大允许的请求内容尺寸
|
||||||
RequestHeader string `field:"requestHeader"` // 请求Header配置
|
RequestHeader dbs.JSON `field:"requestHeader"` // 请求Header配置
|
||||||
ResponseHeader string `field:"responseHeader"` // 响应Header配置
|
ResponseHeader dbs.JSON `field:"responseHeader"` // 响应Header配置
|
||||||
AccessLog string `field:"accessLog"` // 访问日志配置
|
AccessLog dbs.JSON `field:"accessLog"` // 访问日志配置
|
||||||
Stat string `field:"stat"` // 统计配置
|
Stat dbs.JSON `field:"stat"` // 统计配置
|
||||||
Gzip string `field:"gzip"` // Gzip配置(v0.3.2弃用)
|
Gzip dbs.JSON `field:"gzip"` // Gzip配置(v0.3.2弃用)
|
||||||
Compression string `field:"compression"` // 压缩配置
|
Compression dbs.JSON `field:"compression"` // 压缩配置
|
||||||
Cache string `field:"cache"` // 缓存配置
|
Cache dbs.JSON `field:"cache"` // 缓存配置
|
||||||
Firewall string `field:"firewall"` // 防火墙设置
|
Firewall dbs.JSON `field:"firewall"` // 防火墙设置
|
||||||
Locations string `field:"locations"` // 路由规则配置
|
Locations dbs.JSON `field:"locations"` // 路由规则配置
|
||||||
Websocket string `field:"websocket"` // Websocket设置
|
Websocket dbs.JSON `field:"websocket"` // Websocket设置
|
||||||
RewriteRules string `field:"rewriteRules"` // 重写规则配置
|
RewriteRules dbs.JSON `field:"rewriteRules"` // 重写规则配置
|
||||||
HostRedirects string `field:"hostRedirects"` // 域名跳转
|
HostRedirects dbs.JSON `field:"hostRedirects"` // 域名跳转
|
||||||
Fastcgi string `field:"fastcgi"` // Fastcgi配置
|
Fastcgi dbs.JSON `field:"fastcgi"` // Fastcgi配置
|
||||||
Auth string `field:"auth"` // 认证策略配置
|
Auth dbs.JSON `field:"auth"` // 认证策略配置
|
||||||
Webp string `field:"webp"` // WebP配置
|
Webp dbs.JSON `field:"webp"` // WebP配置
|
||||||
RemoteAddr string `field:"remoteAddr"` // 客户端IP配置
|
RemoteAddr dbs.JSON `field:"remoteAddr"` // 客户端IP配置
|
||||||
MergeSlashes uint8 `field:"mergeSlashes"` // 是否合并路径中的斜杠
|
MergeSlashes uint8 `field:"mergeSlashes"` // 是否合并路径中的斜杠
|
||||||
RequestLimit string `field:"requestLimit"` // 请求限制
|
RequestLimit dbs.JSON `field:"requestLimit"` // 请求限制
|
||||||
RequestScripts string `field:"requestScripts"` // 请求脚本
|
RequestScripts dbs.JSON `field:"requestScripts"` // 请求脚本
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPWebOperator struct {
|
type HTTPWebOperator struct {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 启用条目
|
// EnableHTTPWebsocket 启用条目
|
||||||
func (this *HTTPWebsocketDAO) EnableHTTPWebsocket(tx *dbs.Tx, id int64) error {
|
func (this *HTTPWebsocketDAO) EnableHTTPWebsocket(tx *dbs.Tx, id int64) error {
|
||||||
_, err := this.Query(tx).
|
_, err := this.Query(tx).
|
||||||
Pk(id).
|
Pk(id).
|
||||||
@@ -46,7 +46,7 @@ func (this *HTTPWebsocketDAO) EnableHTTPWebsocket(tx *dbs.Tx, id int64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 禁用条目
|
// DisableHTTPWebsocket 禁用条目
|
||||||
func (this *HTTPWebsocketDAO) DisableHTTPWebsocket(tx *dbs.Tx, websocketId int64) error {
|
func (this *HTTPWebsocketDAO) DisableHTTPWebsocket(tx *dbs.Tx, websocketId int64) error {
|
||||||
_, err := this.Query(tx).
|
_, err := this.Query(tx).
|
||||||
Pk(websocketId).
|
Pk(websocketId).
|
||||||
@@ -58,7 +58,7 @@ func (this *HTTPWebsocketDAO) DisableHTTPWebsocket(tx *dbs.Tx, websocketId int64
|
|||||||
return this.NotifyUpdate(tx, websocketId)
|
return this.NotifyUpdate(tx, websocketId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找启用中的条目
|
// FindEnabledHTTPWebsocket 查找启用中的条目
|
||||||
func (this *HTTPWebsocketDAO) FindEnabledHTTPWebsocket(tx *dbs.Tx, id int64) (*HTTPWebsocket, error) {
|
func (this *HTTPWebsocketDAO) FindEnabledHTTPWebsocket(tx *dbs.Tx, id int64) (*HTTPWebsocket, error) {
|
||||||
result, err := this.Query(tx).
|
result, err := this.Query(tx).
|
||||||
Pk(id).
|
Pk(id).
|
||||||
@@ -70,7 +70,7 @@ func (this *HTTPWebsocketDAO) FindEnabledHTTPWebsocket(tx *dbs.Tx, id int64) (*H
|
|||||||
return result.(*HTTPWebsocket), err
|
return result.(*HTTPWebsocket), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 组合配置
|
// ComposeWebsocketConfig 组合配置
|
||||||
func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int64) (*serverconfigs.HTTPWebsocketConfig, error) {
|
func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int64) (*serverconfigs.HTTPWebsocketConfig, error) {
|
||||||
websocket, err := this.FindEnabledHTTPWebsocket(tx, websocketId)
|
websocket, err := this.FindEnabledHTTPWebsocket(tx, websocketId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -81,12 +81,12 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
|
|||||||
}
|
}
|
||||||
config := &serverconfigs.HTTPWebsocketConfig{}
|
config := &serverconfigs.HTTPWebsocketConfig{}
|
||||||
config.Id = int64(websocket.Id)
|
config.Id = int64(websocket.Id)
|
||||||
config.IsOn = websocket.IsOn == 1
|
config.IsOn = websocket.IsOn
|
||||||
config.AllowAllOrigins = websocket.AllowAllOrigins == 1
|
config.AllowAllOrigins = websocket.AllowAllOrigins == 1
|
||||||
|
|
||||||
if IsNotNull(websocket.AllowedOrigins) {
|
if IsNotNull(websocket.AllowedOrigins) {
|
||||||
origins := []string{}
|
origins := []string{}
|
||||||
err = json.Unmarshal([]byte(websocket.AllowedOrigins), &origins)
|
err = json.Unmarshal(websocket.AllowedOrigins, &origins)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
|
|||||||
|
|
||||||
if IsNotNull(websocket.HandshakeTimeout) {
|
if IsNotNull(websocket.HandshakeTimeout) {
|
||||||
duration := &shared.TimeDuration{}
|
duration := &shared.TimeDuration{}
|
||||||
err = json.Unmarshal([]byte(websocket.HandshakeTimeout), duration)
|
err = json.Unmarshal(websocket.HandshakeTimeout, duration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ func (this *HTTPWebsocketDAO) ComposeWebsocketConfig(tx *dbs.Tx, websocketId int
|
|||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建Websocket配置
|
// CreateWebsocket 创建Websocket配置
|
||||||
func (this *HTTPWebsocketDAO) CreateWebsocket(tx *dbs.Tx, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) (websocketId int64, err error) {
|
func (this *HTTPWebsocketDAO) CreateWebsocket(tx *dbs.Tx, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) (websocketId int64, err error) {
|
||||||
op := NewHTTPWebsocketOperator()
|
op := NewHTTPWebsocketOperator()
|
||||||
op.IsOn = true
|
op.IsOn = true
|
||||||
@@ -130,7 +130,7 @@ func (this *HTTPWebsocketDAO) CreateWebsocket(tx *dbs.Tx, handshakeTimeoutJSON [
|
|||||||
return types.Int64(op.Id), err
|
return types.Int64(op.Id), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改Websocket配置
|
// UpdateWebsocket 修改Websocket配置
|
||||||
func (this *HTTPWebsocketDAO) UpdateWebsocket(tx *dbs.Tx, websocketId int64, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) error {
|
func (this *HTTPWebsocketDAO) UpdateWebsocket(tx *dbs.Tx, websocketId int64, handshakeTimeoutJSON []byte, allowAllOrigins bool, allowedOrigins []string, requestSameOrigin bool, requestOrigin string) error {
|
||||||
if websocketId <= 0 {
|
if websocketId <= 0 {
|
||||||
return errors.New("invalid websocketId")
|
return errors.New("invalid websocketId")
|
||||||
@@ -159,7 +159,7 @@ func (this *HTTPWebsocketDAO) UpdateWebsocket(tx *dbs.Tx, websocketId int64, han
|
|||||||
return this.NotifyUpdate(tx, websocketId)
|
return this.NotifyUpdate(tx, websocketId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通知更新
|
// NotifyUpdate 通知更新
|
||||||
func (this *HTTPWebsocketDAO) NotifyUpdate(tx *dbs.Tx, websocketId int64) error {
|
func (this *HTTPWebsocketDAO) NotifyUpdate(tx *dbs.Tx, websocketId int64) error {
|
||||||
webId, err := SharedHTTPWebDAO.FindEnabledWebIdWithWebsocketId(tx, websocketId)
|
webId, err := SharedHTTPWebDAO.FindEnabledWebIdWithWebsocketId(tx, websocketId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// Websocket设置
|
// Websocket设置
|
||||||
type HTTPWebsocket struct {
|
type HTTPWebsocket struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
HandshakeTimeout string `field:"handshakeTimeout"` // 握手超时时间
|
HandshakeTimeout dbs.JSON `field:"handshakeTimeout"` // 握手超时时间
|
||||||
AllowAllOrigins uint8 `field:"allowAllOrigins"` // 是否支持所有源
|
AllowAllOrigins uint8 `field:"allowAllOrigins"` // 是否支持所有源
|
||||||
AllowedOrigins string `field:"allowedOrigins"` // 支持的源域名列表
|
AllowedOrigins dbs.JSON `field:"allowedOrigins"` // 支持的源域名列表
|
||||||
RequestSameOrigin uint8 `field:"requestSameOrigin"` // 是否请求一样的Origin
|
RequestSameOrigin uint8 `field:"requestSameOrigin"` // 是否请求一样的Origin
|
||||||
RequestOrigin string `field:"requestOrigin"` // 请求Origin
|
RequestOrigin string `field:"requestOrigin"` // 请求Origin
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPWebsocketOperator struct {
|
type HTTPWebsocketOperator struct {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type IPItem struct {
|
|||||||
SourceHTTPFirewallPolicyId uint32 `field:"sourceHTTPFirewallPolicyId"` // 来源策略ID
|
SourceHTTPFirewallPolicyId uint32 `field:"sourceHTTPFirewallPolicyId"` // 来源策略ID
|
||||||
SourceHTTPFirewallRuleGroupId uint32 `field:"sourceHTTPFirewallRuleGroupId"` // 来源规则集分组ID
|
SourceHTTPFirewallRuleGroupId uint32 `field:"sourceHTTPFirewallRuleGroupId"` // 来源规则集分组ID
|
||||||
SourceHTTPFirewallRuleSetId uint32 `field:"sourceHTTPFirewallRuleSetId"` // 来源规则集ID
|
SourceHTTPFirewallRuleSetId uint32 `field:"sourceHTTPFirewallRuleSetId"` // 来源规则集ID
|
||||||
IsRead uint8 `field:"isRead"` // 是否已读
|
IsRead bool `field:"isRead"` // 是否已读
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPItemOperator struct {
|
type IPItemOperator struct {
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ var listTypeCacheMap = map[int64]*IPList{} // listId => *IPList
|
|||||||
var DefaultGlobalIPList = &IPList{
|
var DefaultGlobalIPList = &IPList{
|
||||||
Id: uint32(firewallconfigs.GlobalListId),
|
Id: uint32(firewallconfigs.GlobalListId),
|
||||||
Name: "全局封锁名单",
|
Name: "全局封锁名单",
|
||||||
IsPublic: 1,
|
IsPublic: true,
|
||||||
IsGlobal: 1,
|
IsGlobal: true,
|
||||||
Type: "black",
|
Type: "black",
|
||||||
State: IPListStateEnabled,
|
State: IPListStateEnabled,
|
||||||
IsOn: 1,
|
IsOn: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPListDAO dbs.DAO
|
type IPListDAO dbs.DAO
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// IPList IP名单
|
// IPList IP名单
|
||||||
type IPList struct {
|
type IPList struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
AdminId uint32 `field:"adminId"` // 用户ID
|
AdminId uint32 `field:"adminId"` // 用户ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
Name string `field:"name"` // 列表名
|
Name string `field:"name"` // 列表名
|
||||||
Code string `field:"code"` // 代号
|
Code string `field:"code"` // 代号
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Timeout string `field:"timeout"` // 默认超时时间
|
Timeout dbs.JSON `field:"timeout"` // 默认超时时间
|
||||||
Actions string `field:"actions"` // IP触发的动作
|
Actions dbs.JSON `field:"actions"` // IP触发的动作
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
IsPublic uint8 `field:"isPublic"` // 是否公用
|
IsPublic bool `field:"isPublic"` // 是否公用
|
||||||
IsGlobal uint8 `field:"isGlobal"` // 是否全局
|
IsGlobal bool `field:"isGlobal"` // 是否全局
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPListOperator struct {
|
type IPListOperator struct {
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 第三方登录认证
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
|
// Login 第三方登录认证
|
||||||
type Login struct {
|
type Login struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Type string `field:"type"` // 认证方式
|
Type string `field:"type"` // 认证方式
|
||||||
Params string `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type LoginOperator struct {
|
type LoginOperator struct {
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// MessageMediaInstance 消息媒介接收人
|
// MessageMediaInstance 消息媒介接收人
|
||||||
type MessageMediaInstance struct {
|
type MessageMediaInstance struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
MediaType string `field:"mediaType"` // 媒介类型
|
MediaType string `field:"mediaType"` // 媒介类型
|
||||||
Params string `field:"params"` // 媒介参数
|
Params dbs.JSON `field:"params"` // 媒介参数
|
||||||
Description string `field:"description"` // 备注
|
Description string `field:"description"` // 备注
|
||||||
Rate string `field:"rate"` // 发送频率
|
Rate dbs.JSON `field:"rate"` // 发送频率
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
HashLife int32 `field:"hashLife"` // HASH有效期(秒)
|
HashLife int32 `field:"hashLife"` // HASH有效期(秒)
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageMediaInstanceOperator struct {
|
type MessageMediaInstanceOperator struct {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 消息媒介
|
// MessageMedia 消息媒介
|
||||||
type MessageMedia struct {
|
type MessageMedia struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
UserDescription string `field:"userDescription"` // 用户描述
|
UserDescription string `field:"userDescription"` // 用户描述
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// Message 消息通知
|
// Message 消息通知
|
||||||
type Message struct {
|
type Message struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
Role string `field:"role"` // 角色
|
Role string `field:"role"` // 角色
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
NodeId uint32 `field:"nodeId"` // 节点ID
|
NodeId uint32 `field:"nodeId"` // 节点ID
|
||||||
Level string `field:"level"` // 级别
|
Level string `field:"level"` // 级别
|
||||||
Subject string `field:"subject"` // 标题
|
Subject string `field:"subject"` // 标题
|
||||||
Body string `field:"body"` // 内容
|
Body string `field:"body"` // 内容
|
||||||
Type string `field:"type"` // 消息类型
|
Type string `field:"type"` // 消息类型
|
||||||
Params string `field:"params"` // 额外的参数
|
Params dbs.JSON `field:"params"` // 额外的参数
|
||||||
IsRead uint8 `field:"isRead"` // 是否已读
|
IsRead bool `field:"isRead"` // 是否已读
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Day string `field:"day"` // 日期YYYYMMDD
|
Day string `field:"day"` // 日期YYYYMMDD
|
||||||
Hash string `field:"hash"` // 消息内容的Hash
|
Hash string `field:"hash"` // 消息内容的Hash
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageOperator struct {
|
type MessageOperator struct {
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// MessageReceiver 消息通知接收人
|
// MessageReceiver 消息通知接收人
|
||||||
type MessageReceiver struct {
|
type MessageReceiver struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Role string `field:"role"` // 节点角色
|
Role string `field:"role"` // 节点角色
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
NodeId uint32 `field:"nodeId"` // 节点ID
|
NodeId uint32 `field:"nodeId"` // 节点ID
|
||||||
ServerId uint32 `field:"serverId"` // 服务ID
|
ServerId uint32 `field:"serverId"` // 服务ID
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
Params string `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
RecipientId uint32 `field:"recipientId"` // 接收人ID
|
RecipientId uint32 `field:"recipientId"` // 接收人ID
|
||||||
RecipientGroupId uint32 `field:"recipientGroupId"` // 接收人分组ID
|
RecipientGroupId uint32 `field:"recipientGroupId"` // 接收人分组ID
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageReceiverOperator struct {
|
type MessageReceiverOperator struct {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 消息接收人分组
|
// MessageRecipientGroup 消息接收人分组
|
||||||
type MessageRecipientGroup struct {
|
type MessageRecipientGroup struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 分组名
|
Name string `field:"name"` // 分组名
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// MessageRecipient 消息媒介接收人
|
// MessageRecipient 消息媒介接收人
|
||||||
type MessageRecipient struct {
|
type MessageRecipient struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
InstanceId uint32 `field:"instanceId"` // 实例ID
|
InstanceId uint32 `field:"instanceId"` // 实例ID
|
||||||
User string `field:"user"` // 接收人信息
|
User string `field:"user"` // 接收人信息
|
||||||
GroupIds string `field:"groupIds"` // 分组ID
|
GroupIds dbs.JSON `field:"groupIds"` // 分组ID
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
TimeFrom string `field:"timeFrom"` // 开始时间
|
TimeFrom string `field:"timeFrom"` // 开始时间
|
||||||
TimeTo string `field:"timeTo"` // 结束时间
|
TimeTo string `field:"timeTo"` // 结束时间
|
||||||
Description string `field:"description"` // 备注
|
Description string `field:"description"` // 备注
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageRecipientOperator struct {
|
type MessageRecipientOperator struct {
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import (
|
|||||||
"github.com/iwind/TeaGo/logs"
|
"github.com/iwind/TeaGo/logs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 解析分组ID
|
// DecodeGroupIds 解析分组ID
|
||||||
func (this *MessageRecipient) DecodeGroupIds() []int64 {
|
func (this *MessageRecipient) DecodeGroupIds() []int64 {
|
||||||
if len(this.GroupIds) == 0 {
|
if len(this.GroupIds) == 0 {
|
||||||
return []int64{}
|
return []int64{}
|
||||||
}
|
}
|
||||||
result := []int64{}
|
result := []int64{}
|
||||||
err := json.Unmarshal([]byte(this.GroupIds), &result)
|
err := json.Unmarshal(this.GroupIds, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Println("MessageRecipient.DecodeGroupIds(): " + err.Error())
|
logs.Println("MessageRecipient.DecodeGroupIds(): " + err.Error())
|
||||||
// 不阻断执行
|
// 不阻断执行
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ type MessageTaskLog struct {
|
|||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
TaskId uint64 `field:"taskId"` // 任务ID
|
TaskId uint64 `field:"taskId"` // 任务ID
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
IsOk uint8 `field:"isOk"` // 是否成功
|
IsOk bool `field:"isOk"` // 是否成功
|
||||||
Error string `field:"error"` // 错误信息
|
Error string `field:"error"` // 错误信息
|
||||||
Response string `field:"response"` // 响应信息
|
Response string `field:"response"` // 响应信息
|
||||||
Day string `field:"day"` // YYYYMMDD
|
Day string `field:"day"` // YYYYMMDD
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// MessageTask 消息发送相关任务
|
// MessageTask 消息发送相关任务
|
||||||
type MessageTask struct {
|
type MessageTask struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
RecipientId uint32 `field:"recipientId"` // 接收人ID
|
RecipientId uint32 `field:"recipientId"` // 接收人ID
|
||||||
Hash string `field:"hash"` // SUM标识
|
Hash string `field:"hash"` // SUM标识
|
||||||
InstanceId uint32 `field:"instanceId"` // 媒介实例ID
|
InstanceId uint32 `field:"instanceId"` // 媒介实例ID
|
||||||
User string `field:"user"` // 接收用户标识
|
User string `field:"user"` // 接收用户标识
|
||||||
Subject string `field:"subject"` // 标题
|
Subject string `field:"subject"` // 标题
|
||||||
Body string `field:"body"` // 内容
|
Body string `field:"body"` // 内容
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Status uint8 `field:"status"` // 发送状态
|
Status uint8 `field:"status"` // 发送状态
|
||||||
SentAt uint64 `field:"sentAt"` // 最后一次发送时间
|
SentAt uint64 `field:"sentAt"` // 最后一次发送时间
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
Result string `field:"result"` // 结果
|
Result dbs.JSON `field:"result"` // 结果
|
||||||
Day string `field:"day"` // YYYYMMDD
|
Day string `field:"day"` // YYYYMMDD
|
||||||
IsPrimary uint8 `field:"isPrimary"` // 是否优先
|
IsPrimary bool `field:"isPrimary"` // 是否优先
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageTaskOperator struct {
|
type MessageTaskOperator struct {
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// MetricChart 指标图表
|
// MetricChart 指标图表
|
||||||
type MetricChart struct {
|
type MetricChart struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
ItemId uint32 `field:"itemId"` // 指标ID
|
ItemId uint32 `field:"itemId"` // 指标ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Code string `field:"code"` // 代号
|
Code string `field:"code"` // 代号
|
||||||
Type string `field:"type"` // 图形类型
|
Type string `field:"type"` // 图形类型
|
||||||
WidthDiv int32 `field:"widthDiv"` // 宽度划分
|
WidthDiv int32 `field:"widthDiv"` // 宽度划分
|
||||||
Params string `field:"params"` // 图形参数
|
Params dbs.JSON `field:"params"` // 图形参数
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
MaxItems uint32 `field:"maxItems"` // 最多条目
|
MaxItems uint32 `field:"maxItems"` // 最多条目
|
||||||
IgnoreEmptyKeys uint8 `field:"ignoreEmptyKeys"` // 忽略空的键值
|
IgnoreEmptyKeys uint8 `field:"ignoreEmptyKeys"` // 忽略空的键值
|
||||||
IgnoredKeys string `field:"ignoredKeys"` // 忽略键值
|
IgnoredKeys dbs.JSON `field:"ignoredKeys"` // 忽略键值
|
||||||
}
|
}
|
||||||
|
|
||||||
type MetricChartOperator struct {
|
type MetricChartOperator struct {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ func (this *MetricChart) DecodeIgnoredKeys() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var result = []string{}
|
var result = []string{}
|
||||||
err := json.Unmarshal([]byte(this.IgnoredKeys), &result)
|
err := json.Unmarshal(this.IgnoredKeys, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 这里忽略错误
|
// 这里忽略错误
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ func (this *MetricItemDAO) UpdateItem(tx *dbs.Tx, itemId int64, name string, key
|
|||||||
if oldItem == nil {
|
if oldItem == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
oldIsPublic := oldItem.IsPublic == 1
|
oldIsPublic := oldItem.IsPublic
|
||||||
var versionChanged = false
|
var versionChanged = false
|
||||||
if strings.Join(oldItem.DecodeKeys(), "&") != strings.Join(keys, "&") || types.Int32(oldItem.Period) != period || oldItem.PeriodUnit != periodUnit || oldItem.Value != value {
|
if strings.Join(oldItem.DecodeKeys(), "&") != strings.Join(keys, "&") || types.Int32(oldItem.Period) != period || oldItem.PeriodUnit != periodUnit || oldItem.Value != value {
|
||||||
versionChanged = true
|
versionChanged = true
|
||||||
@@ -194,7 +194,7 @@ func (this *MetricItemDAO) UpdateItem(tx *dbs.Tx, itemId int64, name string, key
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 通知更新
|
// 通知更新
|
||||||
if versionChanged || (oldItem.IsOn == 0 && isOn) || (oldItem.IsOn == 1 && !isOn) || oldIsPublic != isPublic {
|
if versionChanged || (!oldItem.IsOn && isOn) || (oldItem.IsOn && !isOn) || oldIsPublic != isPublic {
|
||||||
err := this.NotifyUpdate(tx, itemId, isPublic || oldIsPublic)
|
err := this.NotifyUpdate(tx, itemId, isPublic || oldIsPublic)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -283,7 +283,7 @@ func (this *MetricItemDAO) ComposeItemConfig(tx *dbs.Tx, itemId int64) (*serverc
|
|||||||
var item = one.(*MetricItem)
|
var item = one.(*MetricItem)
|
||||||
var config = &serverconfigs.MetricItemConfig{
|
var config = &serverconfigs.MetricItemConfig{
|
||||||
Id: int64(item.Id),
|
Id: int64(item.Id),
|
||||||
IsOn: item.IsOn == 1,
|
IsOn: item.IsOn,
|
||||||
Period: types.Int(item.Period),
|
Period: types.Int(item.Period),
|
||||||
PeriodUnit: item.PeriodUnit,
|
PeriodUnit: item.PeriodUnit,
|
||||||
Category: item.Category,
|
Category: item.Category,
|
||||||
@@ -302,7 +302,7 @@ func (this *MetricItemDAO) ComposeItemConfigWithItem(item *MetricItem) *serverco
|
|||||||
}
|
}
|
||||||
var config = &serverconfigs.MetricItemConfig{
|
var config = &serverconfigs.MetricItemConfig{
|
||||||
Id: int64(item.Id),
|
Id: int64(item.Id),
|
||||||
IsOn: item.IsOn == 1,
|
IsOn: item.IsOn,
|
||||||
Period: types.Int(item.Period),
|
Period: types.Int(item.Period),
|
||||||
PeriodUnit: item.PeriodUnit,
|
PeriodUnit: item.PeriodUnit,
|
||||||
Category: item.Category,
|
Category: item.Category,
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// MetricItem 指标定义
|
// MetricItem 指标定义
|
||||||
type MetricItem struct {
|
type MetricItem struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Code string `field:"code"` // 代号(用来区分是否内置)
|
Code string `field:"code"` // 代号(用来区分是否内置)
|
||||||
Category string `field:"category"` // 类型,比如http, tcp等
|
Category string `field:"category"` // 类型,比如http, tcp等
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
Name string `field:"name"` // 指标名称
|
Name string `field:"name"` // 指标名称
|
||||||
Keys string `field:"keys"` // 统计的Key
|
Keys dbs.JSON `field:"keys"` // 统计的Key
|
||||||
Period uint32 `field:"period"` // 周期
|
Period uint32 `field:"period"` // 周期
|
||||||
PeriodUnit string `field:"periodUnit"` // 周期单位
|
PeriodUnit string `field:"periodUnit"` // 周期单位
|
||||||
Value string `field:"value"` // 值运算
|
Value string `field:"value"` // 值运算
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
Version uint32 `field:"version"` // 版本号
|
Version uint32 `field:"version"` // 版本号
|
||||||
IsPublic uint8 `field:"isPublic"` // 是否为公用
|
IsPublic bool `field:"isPublic"` // 是否为公用
|
||||||
}
|
}
|
||||||
|
|
||||||
type MetricItemOperator struct {
|
type MetricItemOperator struct {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
func (this *MetricItem) DecodeKeys() []string {
|
func (this *MetricItem) DecodeKeys() []string {
|
||||||
var result []string
|
var result []string
|
||||||
if len(this.Keys) > 0 {
|
if len(this.Keys) > 0 {
|
||||||
_ = json.Unmarshal([]byte(this.Keys), &result)
|
_ = json.Unmarshal(this.Keys, &result)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// MetricStat 指标统计数据
|
// MetricStat 指标统计数据
|
||||||
type MetricStat struct {
|
type MetricStat struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
Hash string `field:"hash"` // Hash值
|
Hash string `field:"hash"` // Hash值
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
NodeId uint32 `field:"nodeId"` // 节点ID
|
NodeId uint32 `field:"nodeId"` // 节点ID
|
||||||
ServerId uint32 `field:"serverId"` // 服务ID
|
ServerId uint32 `field:"serverId"` // 服务ID
|
||||||
ItemId uint64 `field:"itemId"` // 指标
|
ItemId uint64 `field:"itemId"` // 指标
|
||||||
Keys string `field:"keys"` // 键值
|
Keys dbs.JSON `field:"keys"` // 键值
|
||||||
Value float64 `field:"value"` // 数值
|
Value float64 `field:"value"` // 数值
|
||||||
Time string `field:"time"` // 分钟值YYYYMMDDHHII
|
Time string `field:"time"` // 分钟值YYYYMMDDHHII
|
||||||
Version uint32 `field:"version"` // 版本号
|
Version uint32 `field:"version"` // 版本号
|
||||||
CreatedDay string `field:"createdDay"` // YYYYMMDD
|
CreatedDay string `field:"createdDay"` // YYYYMMDD
|
||||||
}
|
}
|
||||||
|
|
||||||
type MetricStatOperator struct {
|
type MetricStatOperator struct {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import "encoding/json"
|
|||||||
func (this *MetricStat) DecodeKeys() []string {
|
func (this *MetricStat) DecodeKeys() []string {
|
||||||
var result []string
|
var result []string
|
||||||
if len(this.Keys) > 0 {
|
if len(this.Keys) > 0 {
|
||||||
_ = json.Unmarshal([]byte(this.Keys), &result)
|
_ = json.Unmarshal(this.Keys, &result)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// 监控节点
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
|
// MonitorNode 监控节点
|
||||||
type MonitorNode struct {
|
type MonitorNode struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||||
Secret string `field:"secret"` // 密钥
|
Secret string `field:"secret"` // 密钥
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Description string `field:"description"` // 描述
|
Description string `field:"description"` // 描述
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
Weight uint32 `field:"weight"` // 权重
|
Weight uint32 `field:"weight"` // 权重
|
||||||
Status string `field:"status"` // 运行状态
|
Status dbs.JSON `field:"status"` // 运行状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type MonitorNodeOperator struct {
|
type MonitorNodeOperator struct {
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
package nameservers
|
package nameservers
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// NSDomain DNS域名
|
// NSDomain DNS域名
|
||||||
type NSDomain struct {
|
type NSDomain struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Name string `field:"name"` // 域名
|
Name string `field:"name"` // 域名
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Version uint64 `field:"version"` // 版本
|
Version uint64 `field:"version"` // 版本
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
Tsig string `field:"tsig"` // TSIG配置
|
Tsig dbs.JSON `field:"tsig"` // TSIG配置
|
||||||
}
|
}
|
||||||
|
|
||||||
type NSDomainOperator struct {
|
type NSDomainOperator struct {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package nameservers
|
|||||||
// NSKey 密钥管理
|
// NSKey 密钥管理
|
||||||
type NSKey struct {
|
type NSKey struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 状态
|
IsOn bool `field:"isOn"` // 状态
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
DomainId uint64 `field:"domainId"` // 域名ID
|
DomainId uint64 `field:"domainId"` // 域名ID
|
||||||
ZoneId uint64 `field:"zoneId"` // 子域ID
|
ZoneId uint64 `field:"zoneId"` // 子域ID
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package nameservers
|
package nameservers
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// NSQuestionOption DNS请求选项
|
// NSQuestionOption DNS请求选项
|
||||||
type NSQuestionOption struct {
|
type NSQuestionOption struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
Name string `field:"name"` // 选项名
|
Name string `field:"name"` // 选项名
|
||||||
Values string `field:"values"` // 选项值
|
Values dbs.JSON `field:"values"` // 选项值
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
}
|
}
|
||||||
|
|
||||||
type NSQuestionOptionOperator struct {
|
type NSQuestionOptionOperator struct {
|
||||||
|
|||||||
@@ -13,17 +13,17 @@ func TestNSRecord_DecodeRouteIds(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
record := &NSRecord{RouteIds: "[]"}
|
record := &NSRecord{RouteIds: []byte("[]")}
|
||||||
t.Log(record.DecodeRouteIds())
|
t.Log(record.DecodeRouteIds())
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
record := &NSRecord{RouteIds: "[1, 2, 3]"}
|
record := &NSRecord{RouteIds: []byte("[1, 2, 3]")}
|
||||||
t.Log(record.DecodeRouteIds())
|
t.Log(record.DecodeRouteIds())
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
record := &NSRecord{RouteIds: `["id:1", "id:2", "isp:liantong"]`}
|
record := &NSRecord{RouteIds: []byte(`["id:1", "id:2", "isp:liantong"]`)}
|
||||||
t.Log(record.DecodeRouteIds())
|
t.Log(record.DecodeRouteIds())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
package nameservers
|
package nameservers
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// NSRecord DNS记录
|
// NSRecord DNS记录
|
||||||
type NSRecord struct {
|
type NSRecord struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
DomainId uint32 `field:"domainId"` // 域名ID
|
DomainId uint32 `field:"domainId"` // 域名ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Description string `field:"description"` // 备注
|
Description string `field:"description"` // 备注
|
||||||
Name string `field:"name"` // 记录名
|
Name string `field:"name"` // 记录名
|
||||||
Type string `field:"type"` // 类型
|
Type string `field:"type"` // 类型
|
||||||
Value string `field:"value"` // 值
|
Value string `field:"value"` // 值
|
||||||
Ttl uint32 `field:"ttl"` // TTL(秒)
|
Ttl uint32 `field:"ttl"` // TTL(秒)
|
||||||
Weight uint32 `field:"weight"` // 权重
|
Weight uint32 `field:"weight"` // 权重
|
||||||
RouteIds string `field:"routeIds"` // 线路
|
RouteIds dbs.JSON `field:"routeIds"` // 线路
|
||||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||||
Version uint64 `field:"version"` //
|
Version uint64 `field:"version"` //
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type NSRecordOperator struct {
|
type NSRecordOperator struct {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import (
|
|||||||
func (this *NSRecord) DecodeRouteIds() []string {
|
func (this *NSRecord) DecodeRouteIds() []string {
|
||||||
var routeIds = []string{}
|
var routeIds = []string{}
|
||||||
if len(this.RouteIds) > 0 {
|
if len(this.RouteIds) > 0 {
|
||||||
err := json.Unmarshal([]byte(this.RouteIds), &routeIds)
|
err := json.Unmarshal(this.RouteIds, &routeIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 检查是否有旧的数据
|
// 检查是否有旧的数据
|
||||||
var oldRouteIds = []int64{}
|
var oldRouteIds = []int64{}
|
||||||
err = json.Unmarshal([]byte(this.RouteIds), &oldRouteIds)
|
err = json.Unmarshal(this.RouteIds, &oldRouteIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ func (this *NSRouteDAO) FindEnabledRouteWithCode(tx *dbs.Tx, code string) (*NSRo
|
|||||||
|
|
||||||
return &NSRoute{
|
return &NSRoute{
|
||||||
Id: 0,
|
Id: 0,
|
||||||
IsOn: 1,
|
IsOn: true,
|
||||||
Name: route.Name,
|
Name: route.Name,
|
||||||
Code: route.Code,
|
Code: route.Code,
|
||||||
State: NSRouteStateEnabled,
|
State: NSRouteStateEnabled,
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package nameservers
|
package nameservers
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// NSRoute DNS线路
|
// NSRoute DNS线路
|
||||||
type NSRoute struct {
|
type NSRoute struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
DomainId uint32 `field:"domainId"` // 域名ID
|
DomainId uint32 `field:"domainId"` // 域名ID
|
||||||
UserId uint32 `field:"userId"` // 用户ID
|
UserId uint32 `field:"userId"` // 用户ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
Ranges string `field:"ranges"` // 范围
|
Ranges dbs.JSON `field:"ranges"` // 范围
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
Version uint64 `field:"version"` // 版本号
|
Version uint64 `field:"version"` // 版本号
|
||||||
Code string `field:"code"` // 代号
|
Code string `field:"code"` // 代号
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type NSRouteOperator struct {
|
type NSRouteOperator struct {
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
package nameservers
|
package nameservers
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// NSZone 域名子域
|
// NSZone 域名子域
|
||||||
type NSZone struct {
|
type NSZone struct {
|
||||||
Id uint64 `field:"id"` // ID
|
Id uint64 `field:"id"` // ID
|
||||||
DomainId uint64 `field:"domainId"` // 域名ID
|
DomainId uint64 `field:"domainId"` // 域名ID
|
||||||
IsOn uint8 `field:"isOn"` // 是否启用
|
IsOn bool `field:"isOn"` // 是否启用
|
||||||
Order uint32 `field:"order"` // 排序
|
Order uint32 `field:"order"` // 排序
|
||||||
Version uint64 `field:"version"` // 版本
|
Version uint64 `field:"version"` // 版本
|
||||||
Tsig string `field:"tsig"` // TSIG配置
|
Tsig dbs.JSON `field:"tsig"` // TSIG配置
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type NSZoneOperator struct {
|
type NSZoneOperator struct {
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ func (this *NodeClusterDAO) FindAllAPINodeAddrsWithCluster(tx *dbs.Tx, clusterId
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, apiNode := range apiNodes {
|
for _, apiNode := range apiNodes {
|
||||||
if apiNode.IsOn != 1 {
|
if !apiNode.IsOn {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
addrs, err := apiNode.DecodeAccessAddrStrings()
|
addrs, err := apiNode.DecodeAccessAddrStrings()
|
||||||
@@ -279,7 +279,7 @@ func (this *NodeClusterDAO) FindAllAPINodeAddrsWithCluster(tx *dbs.Tx, clusterId
|
|||||||
if !IsNotNull(cluster.ApiNodes) {
|
if !IsNotNull(cluster.ApiNodes) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = json.Unmarshal([]byte(cluster.ApiNodes), &apiNodeIds)
|
err = json.Unmarshal(cluster.ApiNodes, &apiNodeIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ func (this *NodeClusterDAO) FindAllAPINodeAddrsWithCluster(tx *dbs.Tx, clusterId
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if apiNode == nil || apiNode.IsOn != 1 {
|
if apiNode == nil || !apiNode.IsOn {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
addrs, err := apiNode.DecodeAccessAddrStrings()
|
addrs, err := apiNode.DecodeAccessAddrStrings()
|
||||||
@@ -526,7 +526,7 @@ func (this *NodeClusterDAO) FindClusterTOAConfig(tx *dbs.Tx, clusterId int64, ca
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !IsNotNull(toa) {
|
if !IsNotNull([]byte(toa)) {
|
||||||
return nodeconfigs.DefaultTOAConfig(), nil
|
return nodeconfigs.DefaultTOAConfig(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,16 +719,16 @@ func (this *NodeClusterDAO) UpdateNodeClusterSystemService(tx *dbs.Tx, clusterId
|
|||||||
if clusterId <= 0 {
|
if clusterId <= 0 {
|
||||||
return errors.New("invalid clusterId")
|
return errors.New("invalid clusterId")
|
||||||
}
|
}
|
||||||
service, err := this.Query(tx).
|
serviceData, err := this.Query(tx).
|
||||||
Pk(clusterId).
|
Pk(clusterId).
|
||||||
Result("systemServices").
|
Result("systemServices").
|
||||||
FindStringCol("")
|
FindBytesCol()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
servicesMap := map[string]maps.Map{}
|
servicesMap := map[string]maps.Map{}
|
||||||
if IsNotNull(service) {
|
if IsNotNull(serviceData) {
|
||||||
err = json.Unmarshal([]byte(service), &servicesMap)
|
err = json.Unmarshal(serviceData, &servicesMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -766,7 +766,7 @@ func (this *NodeClusterDAO) FindNodeClusterSystemServiceParams(tx *dbs.Tx, clust
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
servicesMap := map[string]maps.Map{}
|
servicesMap := map[string]maps.Map{}
|
||||||
if IsNotNull(service) {
|
if IsNotNull([]byte(service)) {
|
||||||
err = json.Unmarshal([]byte(service), &servicesMap)
|
err = json.Unmarshal([]byte(service), &servicesMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -797,7 +797,7 @@ func (this *NodeClusterDAO) FindNodeClusterSystemServices(tx *dbs.Tx, clusterId
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
servicesMap := map[string]maps.Map{}
|
servicesMap := map[string]maps.Map{}
|
||||||
if IsNotNull(service) {
|
if IsNotNull([]byte(service)) {
|
||||||
err = json.Unmarshal([]byte(service), &servicesMap)
|
err = json.Unmarshal([]byte(service), &servicesMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/dbs"
|
||||||
|
|
||||||
// 防火墙动作
|
// 防火墙动作
|
||||||
type NodeClusterFirewallAction struct {
|
type NodeClusterFirewallAction struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
AdminId uint32 `field:"adminId"` // 管理员ID
|
AdminId uint32 `field:"adminId"` // 管理员ID
|
||||||
ClusterId uint32 `field:"clusterId"` // 集群ID
|
ClusterId uint32 `field:"clusterId"` // 集群ID
|
||||||
Name string `field:"name"` // 名称
|
Name string `field:"name"` // 名称
|
||||||
EventLevel string `field:"eventLevel"` // 级别
|
EventLevel string `field:"eventLevel"` // 级别
|
||||||
Type string `field:"type"` // 动作类型
|
Type string `field:"type"` // 动作类型
|
||||||
Params string `field:"params"` // 参数
|
Params dbs.JSON `field:"params"` // 参数
|
||||||
State uint8 `field:"state"` // 状态
|
State uint8 `field:"state"` // 状态
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeClusterFirewallActionOperator struct {
|
type NodeClusterFirewallActionOperator struct {
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 解析参数
|
// DecodeParams 解析参数
|
||||||
func (this *NodeClusterFirewallAction) DecodeParams() (maps.Map, error) {
|
func (this *NodeClusterFirewallAction) DecodeParams() (maps.Map, error) {
|
||||||
if IsNotNull(this.Params) {
|
if IsNotNull(this.Params) {
|
||||||
params := maps.Map{}
|
params := maps.Map{}
|
||||||
err := json.Unmarshal([]byte(this.Params), ¶ms)
|
err := json.Unmarshal(this.Params, ¶ms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user