move metrics module to github.com/go-gost/metrics
This commit is contained in:
parent
749d802a12
commit
a2d62d1753
@ -8,9 +8,9 @@ import (
|
|||||||
"github.com/go-gost/config"
|
"github.com/go-gost/config"
|
||||||
"github.com/go-gost/config/parsing"
|
"github.com/go-gost/config/parsing"
|
||||||
"github.com/go-gost/gost/v3/pkg/logger"
|
"github.com/go-gost/gost/v3/pkg/logger"
|
||||||
metrics "github.com/go-gost/gost/v3/pkg/metrics/service"
|
|
||||||
"github.com/go-gost/gost/v3/pkg/registry"
|
"github.com/go-gost/gost/v3/pkg/registry"
|
||||||
"github.com/go-gost/gost/v3/pkg/service"
|
"github.com/go-gost/gost/v3/pkg/service"
|
||||||
|
metrics "github.com/go-gost/metrics/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildService(cfg *config.Config) (services []service.Service) {
|
func buildService(cfg *config.Config) (services []service.Service) {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-gost/config"
|
"github.com/go-gost/config"
|
||||||
"github.com/go-gost/gost/v3/pkg/logger"
|
"github.com/go-gost/gost/v3/pkg/logger"
|
||||||
"github.com/go-gost/gost/v3/pkg/metrics"
|
"github.com/go-gost/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
15
go.mod
15
go.mod
@ -10,10 +10,10 @@ require (
|
|||||||
github.com/go-gost/config v0.0.0-20220314131548-69ef8eeb9733
|
github.com/go-gost/config v0.0.0-20220314131548-69ef8eeb9733
|
||||||
github.com/go-gost/gosocks4 v0.0.1
|
github.com/go-gost/gosocks4 v0.0.1
|
||||||
github.com/go-gost/gosocks5 v0.3.1-0.20211109033403-d894d75b7f09
|
github.com/go-gost/gosocks5 v0.3.1-0.20211109033403-d894d75b7f09
|
||||||
github.com/go-gost/x v0.0.0-20220314122750-ba23628a0e42
|
github.com/go-gost/metrics v0.0.0-20220314135054-2263ae431a5f
|
||||||
|
github.com/go-gost/x v0.0.0-20220314140325-7915c0401c2e
|
||||||
github.com/gobwas/glob v0.2.3
|
github.com/gobwas/glob v0.2.3
|
||||||
github.com/miekg/dns v1.1.26
|
github.com/miekg/dns v1.1.45
|
||||||
github.com/prometheus/client_golang v1.12.1
|
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
github.com/xtaci/smux v1.5.16
|
github.com/xtaci/smux v1.5.16
|
||||||
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5
|
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5
|
||||||
@ -60,9 +60,10 @@ require (
|
|||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/nxadm/tail v1.4.8 // indirect
|
github.com/nxadm/tail v1.4.8 // indirect
|
||||||
github.com/onsi/ginkgo v1.16.4 // indirect
|
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||||
github.com/pelletier/go-toml v1.9.4 // indirect
|
github.com/pelletier/go-toml v1.9.4 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
|
github.com/prometheus/client_golang v1.12.1 // indirect
|
||||||
github.com/prometheus/client_model v0.2.0 // indirect
|
github.com/prometheus/client_model v0.2.0 // indirect
|
||||||
github.com/prometheus/common v0.32.1 // indirect
|
github.com/prometheus/common v0.32.1 // indirect
|
||||||
github.com/prometheus/procfs v0.7.3 // indirect
|
github.com/prometheus/procfs v0.7.3 // indirect
|
||||||
@ -84,12 +85,12 @@ require (
|
|||||||
github.com/xtaci/kcp-go/v5 v5.6.1 // indirect
|
github.com/xtaci/kcp-go/v5 v5.6.1 // indirect
|
||||||
github.com/xtaci/tcpraw v1.2.25 // indirect
|
github.com/xtaci/tcpraw v1.2.25 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
|
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
|
||||||
golang.org/x/mod v0.4.2 // indirect
|
golang.org/x/mod v0.5.1 // indirect
|
||||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
golang.org/x/tools v0.1.5 // indirect
|
golang.org/x/tools v0.1.9 // indirect
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
|
google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350 // indirect
|
||||||
google.golang.org/grpc v1.45.0 // indirect
|
google.golang.org/grpc v1.45.0 // indirect
|
||||||
google.golang.org/protobuf v1.27.1 // indirect
|
google.golang.org/protobuf v1.27.1 // indirect
|
||||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||||
|
31
go.sum
31
go.sum
@ -128,12 +128,14 @@ github.com/go-gost/gosocks4 v0.0.1 h1:+k1sec8HlELuQV7rWftIkmy8UijzUt2I6t+iMPlGB2
|
|||||||
github.com/go-gost/gosocks4 v0.0.1/go.mod h1:3B6L47HbU/qugDg4JnoFPHgJXE43Inz8Bah1QaN9qCc=
|
github.com/go-gost/gosocks4 v0.0.1/go.mod h1:3B6L47HbU/qugDg4JnoFPHgJXE43Inz8Bah1QaN9qCc=
|
||||||
github.com/go-gost/gosocks5 v0.3.1-0.20211109033403-d894d75b7f09 h1:A95M6UWcfZgOuJkQ7QLfG0Hs5peWIUSysCDNz4pfe04=
|
github.com/go-gost/gosocks5 v0.3.1-0.20211109033403-d894d75b7f09 h1:A95M6UWcfZgOuJkQ7QLfG0Hs5peWIUSysCDNz4pfe04=
|
||||||
github.com/go-gost/gosocks5 v0.3.1-0.20211109033403-d894d75b7f09/go.mod h1:1G6I7HP7VFVxveGkoK8mnprnJqSqJjdcASKsdUn4Pp4=
|
github.com/go-gost/gosocks5 v0.3.1-0.20211109033403-d894d75b7f09/go.mod h1:1G6I7HP7VFVxveGkoK8mnprnJqSqJjdcASKsdUn4Pp4=
|
||||||
|
github.com/go-gost/metrics v0.0.0-20220314135054-2263ae431a5f h1:gNquUvOvPXUpq4Xk7ed7motbVN5t0HMqImf96k+pzlU=
|
||||||
|
github.com/go-gost/metrics v0.0.0-20220314135054-2263ae431a5f/go.mod h1:Ac2Pigx5GMJEznkP9wLdBJ36+rYwWiJPqWk7lrg3FKg=
|
||||||
github.com/go-gost/relay v0.1.1-0.20211123134818-8ef7fd81ffd7 h1:itaaJhQJ19kUXEB4Igb0EbY8m+1Py2AaNNSBds/9gk4=
|
github.com/go-gost/relay v0.1.1-0.20211123134818-8ef7fd81ffd7 h1:itaaJhQJ19kUXEB4Igb0EbY8m+1Py2AaNNSBds/9gk4=
|
||||||
github.com/go-gost/relay v0.1.1-0.20211123134818-8ef7fd81ffd7/go.mod h1:lcX+23LCQ3khIeASBo+tJ/WbwXFO32/N5YN6ucuYTG8=
|
github.com/go-gost/relay v0.1.1-0.20211123134818-8ef7fd81ffd7/go.mod h1:lcX+23LCQ3khIeASBo+tJ/WbwXFO32/N5YN6ucuYTG8=
|
||||||
github.com/go-gost/tls-dissector v0.0.2-0.20211125135007-2b5d5bd9c07e h1:73NGqAs22ey3wJkIYVD/ACEoovuIuOlEzQTEoqrO5+U=
|
github.com/go-gost/tls-dissector v0.0.2-0.20211125135007-2b5d5bd9c07e h1:73NGqAs22ey3wJkIYVD/ACEoovuIuOlEzQTEoqrO5+U=
|
||||||
github.com/go-gost/tls-dissector v0.0.2-0.20211125135007-2b5d5bd9c07e/go.mod h1:/9QfdewqmHdaE362Hv5nDaSWLx3pCmtD870d6GaquXs=
|
github.com/go-gost/tls-dissector v0.0.2-0.20211125135007-2b5d5bd9c07e/go.mod h1:/9QfdewqmHdaE362Hv5nDaSWLx3pCmtD870d6GaquXs=
|
||||||
github.com/go-gost/x v0.0.0-20220314122750-ba23628a0e42 h1:iLGI3Mnxi8L6u2ILakI5PBZO5tk5ojbg2DDt7rYK77E=
|
github.com/go-gost/x v0.0.0-20220314140325-7915c0401c2e h1:sQjjbnEQBgVWYvJREYb7wdVqFabHzaevIUaOjZzSv8U=
|
||||||
github.com/go-gost/x v0.0.0-20220314122750-ba23628a0e42/go.mod h1:5jjp1nnv/79VsrLlFTmyddxkgCnP0ACwmpIpmKHidpE=
|
github.com/go-gost/x v0.0.0-20220314140325-7915c0401c2e/go.mod h1:kA9Ndel1O6xj/Iva5LkhaOYpHmjYpr0HBoZmsnDGKso=
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||||
@ -294,8 +296,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
|
|||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
||||||
github.com/miekg/dns v1.1.26 h1:gPxPSwALAeHJSjarOs00QjVdV9QoBvc1D2ujQUr5BzU=
|
github.com/miekg/dns v1.1.45 h1:g5fRIhm9nx7g8osrAvgb16QJfmyMsyOCb+J7LSv+Qzk=
|
||||||
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
|
github.com/miekg/dns v1.1.45/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
|
||||||
github.com/milosgajdos/tenus v0.0.3 h1:jmaJzwaY1DUyYVD0lM4U+uvP2kkEg1VahDqRFxIkVBE=
|
github.com/milosgajdos/tenus v0.0.3 h1:jmaJzwaY1DUyYVD0lM4U+uvP2kkEg1VahDqRFxIkVBE=
|
||||||
github.com/milosgajdos/tenus v0.0.3/go.mod h1:eIjx29vNeDOYWJuCnaHY2r4fq5egetV26ry3on7p8qY=
|
github.com/milosgajdos/tenus v0.0.3/go.mod h1:eIjx29vNeDOYWJuCnaHY2r4fq5egetV26ry3on7p8qY=
|
||||||
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
||||||
@ -320,8 +322,9 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
|
|||||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||||
github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E=
|
github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E=
|
||||||
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
|
|
||||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||||
|
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||||
|
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||||
github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
|
github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
|
||||||
@ -469,7 +472,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
|||||||
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
@ -514,8 +516,9 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
|
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
|
||||||
|
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
@ -534,7 +537,6 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
@ -558,6 +560,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
|||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
|
||||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
@ -602,8 +605,6 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@ -680,7 +681,6 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw
|
|||||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
@ -719,8 +719,9 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f
|
|||||||
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
|
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8=
|
||||||
|
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
@ -798,8 +799,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D
|
|||||||
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa h1:I0YcKz0I7OAhddo7ya8kMnvprhcWM045PmkBdMO9zN0=
|
google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350 h1:YxHp5zqIcAShDEvRr5/0rVESVS+njYF68PSdazrNLJo=
|
||||||
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||||
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||||
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
||||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||||
|
@ -1,222 +0,0 @@
|
|||||||
package metrics
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/go-gost/gost/v3/pkg/metrics"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
errUnsupport = errors.New("unsupported operation")
|
|
||||||
)
|
|
||||||
|
|
||||||
// ServerConn is a server side Conn with metrics supported.
|
|
||||||
type serverConn struct {
|
|
||||||
net.Conn
|
|
||||||
service string
|
|
||||||
}
|
|
||||||
|
|
||||||
func WrapConn(service string, c net.Conn) net.Conn {
|
|
||||||
return &serverConn{
|
|
||||||
service: service,
|
|
||||||
Conn: c,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *serverConn) Read(b []byte) (n int, err error) {
|
|
||||||
n, err = c.Conn.Read(b)
|
|
||||||
metrics.InputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *serverConn) Write(b []byte) (n int, err error) {
|
|
||||||
n, err = c.Conn.Write(b)
|
|
||||||
metrics.OutputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
type packetConn struct {
|
|
||||||
net.PacketConn
|
|
||||||
service string
|
|
||||||
}
|
|
||||||
|
|
||||||
func WrapPacketConn(service string, pc net.PacketConn) net.PacketConn {
|
|
||||||
return &packetConn{
|
|
||||||
PacketConn: pc,
|
|
||||||
service: service,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *packetConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
|
|
||||||
n, addr, err = c.PacketConn.ReadFrom(p)
|
|
||||||
metrics.InputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *packetConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
|
|
||||||
n, err = c.PacketConn.WriteTo(p, addr)
|
|
||||||
metrics.OutputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
type udpConn struct {
|
|
||||||
net.PacketConn
|
|
||||||
service string
|
|
||||||
}
|
|
||||||
|
|
||||||
func WrapUDPConn(service string, pc net.PacketConn) UDPConn {
|
|
||||||
return &udpConn{
|
|
||||||
PacketConn: pc,
|
|
||||||
service: service,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) RemoteAddr() net.Addr {
|
|
||||||
if nc, ok := c.PacketConn.(remoteAddr); ok {
|
|
||||||
return nc.RemoteAddr()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) SetReadBuffer(n int) error {
|
|
||||||
if nc, ok := c.PacketConn.(setBuffer); ok {
|
|
||||||
return nc.SetReadBuffer(n)
|
|
||||||
}
|
|
||||||
return errUnsupport
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) SetWriteBuffer(n int) error {
|
|
||||||
if nc, ok := c.PacketConn.(setBuffer); ok {
|
|
||||||
return nc.SetWriteBuffer(n)
|
|
||||||
}
|
|
||||||
return errUnsupport
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) Read(b []byte) (n int, err error) {
|
|
||||||
if nc, ok := c.PacketConn.(io.Reader); ok {
|
|
||||||
n, err = nc.Read(b)
|
|
||||||
metrics.InputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = errUnsupport
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
|
|
||||||
n, addr, err = c.PacketConn.ReadFrom(p)
|
|
||||||
metrics.InputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error) {
|
|
||||||
if nc, ok := c.PacketConn.(readUDP); ok {
|
|
||||||
n, addr, err = nc.ReadFromUDP(b)
|
|
||||||
metrics.InputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = errUnsupport
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error) {
|
|
||||||
if nc, ok := c.PacketConn.(readUDP); ok {
|
|
||||||
n, oobn, flags, addr, err = nc.ReadMsgUDP(b, oob)
|
|
||||||
metrics.InputBytes(c.service).Add(float64(n + oobn))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = errUnsupport
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) Write(b []byte) (n int, err error) {
|
|
||||||
if nc, ok := c.PacketConn.(io.Writer); ok {
|
|
||||||
n, err = nc.Write(b)
|
|
||||||
metrics.OutputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = errUnsupport
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
|
|
||||||
n, err = c.PacketConn.WriteTo(p, addr)
|
|
||||||
metrics.OutputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) WriteToUDP(b []byte, addr *net.UDPAddr) (n int, err error) {
|
|
||||||
if nc, ok := c.PacketConn.(writeUDP); ok {
|
|
||||||
n, err = nc.WriteToUDP(b, addr)
|
|
||||||
metrics.OutputBytes(c.service).Add(float64(n))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = errUnsupport
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) WriteMsgUDP(b, oob []byte, addr *net.UDPAddr) (n, oobn int, err error) {
|
|
||||||
if nc, ok := c.PacketConn.(writeUDP); ok {
|
|
||||||
n, oobn, err = nc.WriteMsgUDP(b, oob, addr)
|
|
||||||
metrics.OutputBytes(c.service).Add(float64(n + oobn))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = errUnsupport
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) SyscallConn() (rc syscall.RawConn, err error) {
|
|
||||||
if nc, ok := c.PacketConn.(syscallConn); ok {
|
|
||||||
return nc.SyscallConn()
|
|
||||||
}
|
|
||||||
err = errUnsupport
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *udpConn) SetDSCP(n int) error {
|
|
||||||
if nc, ok := c.PacketConn.(setDSCP); ok {
|
|
||||||
return nc.SetDSCP(n)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type UDPConn interface {
|
|
||||||
net.PacketConn
|
|
||||||
io.Reader
|
|
||||||
io.Writer
|
|
||||||
readUDP
|
|
||||||
writeUDP
|
|
||||||
setBuffer
|
|
||||||
syscallConn
|
|
||||||
remoteAddr
|
|
||||||
}
|
|
||||||
|
|
||||||
type setBuffer interface {
|
|
||||||
SetReadBuffer(bytes int) error
|
|
||||||
SetWriteBuffer(bytes int) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type readUDP interface {
|
|
||||||
ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error)
|
|
||||||
ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type writeUDP interface {
|
|
||||||
WriteToUDP(b []byte, addr *net.UDPAddr) (int, error)
|
|
||||||
WriteMsgUDP(b, oob []byte, addr *net.UDPAddr) (n, oobn int, err error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type syscallConn interface {
|
|
||||||
SyscallConn() (syscall.RawConn, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type remoteAddr interface {
|
|
||||||
RemoteAddr() net.Addr
|
|
||||||
}
|
|
||||||
|
|
||||||
// tcpraw.TCPConn
|
|
||||||
type setDSCP interface {
|
|
||||||
SetDSCP(int) error
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package metrics
|
|
||||||
|
|
||||||
import "net"
|
|
||||||
|
|
||||||
type listener struct {
|
|
||||||
service string
|
|
||||||
net.Listener
|
|
||||||
}
|
|
||||||
|
|
||||||
func WrapListener(service string, ln net.Listener) net.Listener {
|
|
||||||
return &listener{
|
|
||||||
service: service,
|
|
||||||
Listener: ln,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ln *listener) Accept() (net.Conn, error) {
|
|
||||||
c, err := ln.Listener.Accept()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return WrapConn(ln.service, c), nil
|
|
||||||
}
|
|
@ -5,12 +5,12 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/go-gost/gost/v3/pkg/chain"
|
"github.com/go-gost/gost/v3/pkg/chain"
|
||||||
"github.com/go-gost/gost/v3/pkg/common/metrics"
|
|
||||||
"github.com/go-gost/gost/v3/pkg/connector"
|
"github.com/go-gost/gost/v3/pkg/connector"
|
||||||
"github.com/go-gost/gost/v3/pkg/listener"
|
"github.com/go-gost/gost/v3/pkg/listener"
|
||||||
"github.com/go-gost/gost/v3/pkg/logger"
|
"github.com/go-gost/gost/v3/pkg/logger"
|
||||||
md "github.com/go-gost/gost/v3/pkg/metadata"
|
md "github.com/go-gost/gost/v3/pkg/metadata"
|
||||||
"github.com/go-gost/gost/v3/pkg/registry"
|
"github.com/go-gost/gost/v3/pkg/registry"
|
||||||
|
metrics "github.com/go-gost/metrics/wrapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -5,12 +5,12 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/go-gost/gost/v3/pkg/chain"
|
"github.com/go-gost/gost/v3/pkg/chain"
|
||||||
"github.com/go-gost/gost/v3/pkg/common/metrics"
|
|
||||||
"github.com/go-gost/gost/v3/pkg/connector"
|
"github.com/go-gost/gost/v3/pkg/connector"
|
||||||
"github.com/go-gost/gost/v3/pkg/listener"
|
"github.com/go-gost/gost/v3/pkg/listener"
|
||||||
"github.com/go-gost/gost/v3/pkg/logger"
|
"github.com/go-gost/gost/v3/pkg/logger"
|
||||||
md "github.com/go-gost/gost/v3/pkg/metadata"
|
md "github.com/go-gost/gost/v3/pkg/metadata"
|
||||||
"github.com/go-gost/gost/v3/pkg/registry"
|
"github.com/go-gost/gost/v3/pkg/registry"
|
||||||
|
metrics "github.com/go-gost/metrics/wrapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -3,11 +3,11 @@ package tcp
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/go-gost/gost/v3/pkg/common/metrics"
|
|
||||||
"github.com/go-gost/gost/v3/pkg/listener"
|
"github.com/go-gost/gost/v3/pkg/listener"
|
||||||
"github.com/go-gost/gost/v3/pkg/logger"
|
"github.com/go-gost/gost/v3/pkg/logger"
|
||||||
md "github.com/go-gost/gost/v3/pkg/metadata"
|
md "github.com/go-gost/gost/v3/pkg/metadata"
|
||||||
"github.com/go-gost/gost/v3/pkg/registry"
|
"github.com/go-gost/gost/v3/pkg/registry"
|
||||||
|
metrics "github.com/go-gost/metrics/wrapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -5,11 +5,11 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/go-gost/gost/v3/pkg/common/admission"
|
"github.com/go-gost/gost/v3/pkg/common/admission"
|
||||||
"github.com/go-gost/gost/v3/pkg/common/metrics"
|
|
||||||
"github.com/go-gost/gost/v3/pkg/listener"
|
"github.com/go-gost/gost/v3/pkg/listener"
|
||||||
"github.com/go-gost/gost/v3/pkg/logger"
|
"github.com/go-gost/gost/v3/pkg/logger"
|
||||||
md "github.com/go-gost/gost/v3/pkg/metadata"
|
md "github.com/go-gost/gost/v3/pkg/metadata"
|
||||||
"github.com/go-gost/gost/v3/pkg/registry"
|
"github.com/go-gost/gost/v3/pkg/registry"
|
||||||
|
metrics "github.com/go-gost/metrics/wrapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -3,12 +3,12 @@ package udp
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/go-gost/gost/v3/pkg/common/metrics"
|
|
||||||
"github.com/go-gost/gost/v3/pkg/common/util/udp"
|
"github.com/go-gost/gost/v3/pkg/common/util/udp"
|
||||||
"github.com/go-gost/gost/v3/pkg/listener"
|
"github.com/go-gost/gost/v3/pkg/listener"
|
||||||
"github.com/go-gost/gost/v3/pkg/logger"
|
"github.com/go-gost/gost/v3/pkg/logger"
|
||||||
md "github.com/go-gost/gost/v3/pkg/metadata"
|
md "github.com/go-gost/gost/v3/pkg/metadata"
|
||||||
"github.com/go-gost/gost/v3/pkg/registry"
|
"github.com/go-gost/gost/v3/pkg/registry"
|
||||||
|
metrics "github.com/go-gost/metrics/wrapper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -1,182 +0,0 @@
|
|||||||
package metrics
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
metrics *Metrics
|
|
||||||
)
|
|
||||||
|
|
||||||
func SetGlobal(m *Metrics) {
|
|
||||||
metrics = m
|
|
||||||
}
|
|
||||||
|
|
||||||
type Gauge interface {
|
|
||||||
Inc()
|
|
||||||
Dec()
|
|
||||||
Add(float64)
|
|
||||||
Set(float64)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Counter interface {
|
|
||||||
Inc()
|
|
||||||
Add(float64)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Observer interface {
|
|
||||||
Observe(float64)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Metrics struct {
|
|
||||||
host string
|
|
||||||
services *prometheus.GaugeVec
|
|
||||||
requests *prometheus.CounterVec
|
|
||||||
requestsInFlight *prometheus.GaugeVec
|
|
||||||
requestSeconds *prometheus.HistogramVec
|
|
||||||
inputBytes *prometheus.CounterVec
|
|
||||||
outputBytes *prometheus.CounterVec
|
|
||||||
handlerErrors *prometheus.CounterVec
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMetrics() *Metrics {
|
|
||||||
host, _ := os.Hostname()
|
|
||||||
m := &Metrics{
|
|
||||||
host: host,
|
|
||||||
services: prometheus.NewGaugeVec(
|
|
||||||
prometheus.GaugeOpts{
|
|
||||||
Name: "gost_services",
|
|
||||||
Help: "Current number of services",
|
|
||||||
},
|
|
||||||
[]string{"host"}),
|
|
||||||
|
|
||||||
requests: prometheus.NewCounterVec(
|
|
||||||
prometheus.CounterOpts{
|
|
||||||
Name: "gost_service_requests_total",
|
|
||||||
Help: "Total number of requests",
|
|
||||||
},
|
|
||||||
[]string{"host", "service"}),
|
|
||||||
|
|
||||||
requestsInFlight: prometheus.NewGaugeVec(
|
|
||||||
prometheus.GaugeOpts{
|
|
||||||
Name: "gost_service_requests_in_flight",
|
|
||||||
Help: "Current in-flight requests",
|
|
||||||
},
|
|
||||||
[]string{"host", "service"}),
|
|
||||||
|
|
||||||
requestSeconds: prometheus.NewHistogramVec(
|
|
||||||
prometheus.HistogramOpts{
|
|
||||||
Name: "gost_service_request_duration_seconds",
|
|
||||||
Help: "Distribution of request latencies",
|
|
||||||
Buckets: []float64{
|
|
||||||
.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 15, 30, 60,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[]string{"host", "service"}),
|
|
||||||
inputBytes: prometheus.NewCounterVec(
|
|
||||||
prometheus.CounterOpts{
|
|
||||||
Name: "gost_service_transfer_input_bytes_total",
|
|
||||||
Help: "Total service input data transfer size in bytes",
|
|
||||||
},
|
|
||||||
[]string{"host", "service"}),
|
|
||||||
outputBytes: prometheus.NewCounterVec(
|
|
||||||
prometheus.CounterOpts{
|
|
||||||
Name: "gost_service_transfer_output_bytes_total",
|
|
||||||
Help: "Total service output data transfer size in bytes",
|
|
||||||
},
|
|
||||||
[]string{"host", "service"}),
|
|
||||||
handlerErrors: prometheus.NewCounterVec(
|
|
||||||
prometheus.CounterOpts{
|
|
||||||
Name: "gost_service_handler_errors_total",
|
|
||||||
Help: "Total service handler errors",
|
|
||||||
},
|
|
||||||
[]string{"host", "service"}),
|
|
||||||
}
|
|
||||||
prometheus.MustRegister(m.services)
|
|
||||||
prometheus.MustRegister(m.requests)
|
|
||||||
prometheus.MustRegister(m.requestsInFlight)
|
|
||||||
prometheus.MustRegister(m.requestSeconds)
|
|
||||||
prometheus.MustRegister(m.inputBytes)
|
|
||||||
prometheus.MustRegister(m.outputBytes)
|
|
||||||
prometheus.MustRegister(m.handlerErrors)
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
func Services() Gauge {
|
|
||||||
if metrics == nil || metrics.services == nil {
|
|
||||||
return nilGauge
|
|
||||||
}
|
|
||||||
return metrics.services.
|
|
||||||
With(prometheus.Labels{
|
|
||||||
"host": metrics.host,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func Requests(service string) Counter {
|
|
||||||
if metrics == nil || metrics.requests == nil {
|
|
||||||
return nilCounter
|
|
||||||
}
|
|
||||||
|
|
||||||
return metrics.requests.
|
|
||||||
With(prometheus.Labels{
|
|
||||||
"host": metrics.host,
|
|
||||||
"service": service,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func RequestsInFlight(service string) Gauge {
|
|
||||||
if metrics == nil || metrics.requestsInFlight == nil {
|
|
||||||
return nilGauge
|
|
||||||
}
|
|
||||||
return metrics.requestsInFlight.
|
|
||||||
With(prometheus.Labels{
|
|
||||||
"host": metrics.host,
|
|
||||||
"service": service,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func RequestSeconds(service string) Observer {
|
|
||||||
if metrics == nil || metrics.requestSeconds == nil {
|
|
||||||
return nilObserver
|
|
||||||
}
|
|
||||||
return metrics.requestSeconds.
|
|
||||||
With(prometheus.Labels{
|
|
||||||
"host": metrics.host,
|
|
||||||
"service": service,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func InputBytes(service string) Counter {
|
|
||||||
if metrics == nil || metrics.inputBytes == nil {
|
|
||||||
return nilCounter
|
|
||||||
}
|
|
||||||
return metrics.inputBytes.
|
|
||||||
With(prometheus.Labels{
|
|
||||||
"host": metrics.host,
|
|
||||||
"service": service,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func OutputBytes(service string) Counter {
|
|
||||||
if metrics == nil || metrics.outputBytes == nil {
|
|
||||||
return nilCounter
|
|
||||||
}
|
|
||||||
return metrics.outputBytes.
|
|
||||||
With(prometheus.Labels{
|
|
||||||
"host": metrics.host,
|
|
||||||
"service": service,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func HandlerErrors(service string) Counter {
|
|
||||||
if metrics == nil || metrics.handlerErrors == nil {
|
|
||||||
return nilCounter
|
|
||||||
}
|
|
||||||
return metrics.handlerErrors.
|
|
||||||
With(prometheus.Labels{
|
|
||||||
"host": metrics.host,
|
|
||||||
"service": service,
|
|
||||||
})
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package metrics
|
|
||||||
|
|
||||||
var (
|
|
||||||
nilGauge = &nopGauge{}
|
|
||||||
nilCounter = &nopCounter{}
|
|
||||||
nilObserver = &nopObserver{}
|
|
||||||
)
|
|
||||||
|
|
||||||
type nopGauge struct{}
|
|
||||||
|
|
||||||
func (*nopGauge) Inc() {}
|
|
||||||
func (*nopGauge) Dec() {}
|
|
||||||
func (*nopGauge) Add(v float64) {}
|
|
||||||
func (*nopGauge) Set(v float64) {}
|
|
||||||
|
|
||||||
type nopCounter struct{}
|
|
||||||
|
|
||||||
func (*nopCounter) Inc() {}
|
|
||||||
func (*nopCounter) Add(v float64) {}
|
|
||||||
|
|
||||||
type nopObserver struct{}
|
|
||||||
|
|
||||||
func (*nopObserver) Observe(v float64) {}
|
|
@ -1,66 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/go-gost/gost/v3/pkg/service"
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
DefaultPath = "/metrics"
|
|
||||||
)
|
|
||||||
|
|
||||||
type options struct {
|
|
||||||
path string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Option func(*options)
|
|
||||||
|
|
||||||
func PathOption(path string) Option {
|
|
||||||
return func(o *options) {
|
|
||||||
o.path = path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type server struct {
|
|
||||||
s *http.Server
|
|
||||||
ln net.Listener
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewService(addr string, opts ...Option) (service.Service, error) {
|
|
||||||
ln, err := net.Listen("tcp", addr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var options options
|
|
||||||
for _, opt := range opts {
|
|
||||||
opt(&options)
|
|
||||||
}
|
|
||||||
if options.path == "" {
|
|
||||||
options.path = DefaultPath
|
|
||||||
}
|
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
|
||||||
mux.Handle(options.path, promhttp.Handler())
|
|
||||||
return &server{
|
|
||||||
s: &http.Server{
|
|
||||||
Handler: mux,
|
|
||||||
},
|
|
||||||
ln: ln,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) Serve() error {
|
|
||||||
return s.s.Serve(s.ln)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) Addr() net.Addr {
|
|
||||||
return s.ln.Addr()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) Close() error {
|
|
||||||
return s.s.Close()
|
|
||||||
}
|
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/go-gost/gost/v3/pkg/handler"
|
"github.com/go-gost/gost/v3/pkg/handler"
|
||||||
"github.com/go-gost/gost/v3/pkg/listener"
|
"github.com/go-gost/gost/v3/pkg/listener"
|
||||||
"github.com/go-gost/gost/v3/pkg/logger"
|
"github.com/go-gost/gost/v3/pkg/logger"
|
||||||
"github.com/go-gost/gost/v3/pkg/metrics"
|
"github.com/go-gost/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
type options struct {
|
type options struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user