mv non-core components to extended repo

This commit is contained in:
ginuerzh
2022-03-14 17:43:37 +08:00
parent bfc1f8472c
commit 5c5af49b0e
279 changed files with 608 additions and 14301 deletions

View File

@ -9,10 +9,10 @@ import (
"strings"
"time"
"github.com/go-gost/gost/pkg/config"
"github.com/go-gost/gost/pkg/metadata"
metrics "github.com/go-gost/gost/pkg/metrics/service"
"github.com/go-gost/gost/pkg/registry"
"github.com/go-gost/gost/v3/pkg/config"
"github.com/go-gost/gost/v3/pkg/metadata"
metrics "github.com/go-gost/gost/v3/pkg/metrics/service"
"github.com/go-gost/gost/v3/pkg/registry"
)
var (
@ -41,8 +41,9 @@ func buildConfigFromCmd(services, nodes stringList) (*config.Config, error) {
}
if v := os.Getenv("GOST_METRICS"); v != "" {
cfg.Metrics = &config.MetricsConfig{
Addr: v,
Path: metrics.DefaultPath,
Enable: true,
Addr: v,
Path: metrics.DefaultPath,
}
}

View File

@ -4,13 +4,13 @@ import (
"io"
"os"
"github.com/go-gost/gost/pkg/api"
"github.com/go-gost/gost/pkg/config"
"github.com/go-gost/gost/pkg/config/parsing"
"github.com/go-gost/gost/pkg/logger"
metrics "github.com/go-gost/gost/pkg/metrics/service"
"github.com/go-gost/gost/pkg/registry"
"github.com/go-gost/gost/pkg/service"
"github.com/go-gost/gost/v3/pkg/api"
"github.com/go-gost/gost/v3/pkg/config"
"github.com/go-gost/gost/v3/pkg/config/parsing"
"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/service"
)
func buildService(cfg *config.Config) (services []service.Service) {

View File

@ -8,9 +8,9 @@ import (
"os"
"runtime"
"github.com/go-gost/gost/pkg/config"
"github.com/go-gost/gost/pkg/logger"
metrics "github.com/go-gost/gost/pkg/metrics/service"
"github.com/go-gost/gost/v3/pkg/config"
"github.com/go-gost/gost/v3/pkg/logger"
"github.com/go-gost/gost/v3/pkg/metrics"
)
var (
@ -63,8 +63,8 @@ func main() {
}
if metricsAddr != "" {
cfg.Metrics = &config.MetricsConfig{
Addr: metricsAddr,
Path: metrics.DefaultPath,
Enable: true,
Addr: metricsAddr,
}
}
} else {
@ -113,17 +113,19 @@ func main() {
}()
}
if cfg.Metrics != nil {
s, err := buildMetricsService(cfg.Metrics)
if err != nil {
log.Fatal(err)
if cfg.Metrics != nil && cfg.Metrics.Enable {
metrics.SetGlobal(metrics.NewMetrics())
if cfg.Metrics.Addr != "" {
s, err := buildMetricsService(cfg.Metrics)
if err != nil {
log.Fatal(err)
}
go func() {
defer s.Close()
log.Info("metrics service on ", s.Addr())
log.Fatal(s.Serve())
}()
}
defer s.Close()
go func() {
log.Info("metrics service on ", s.Addr())
log.Fatal(s.Serve())
}()
}
buildDefaultTLSConfig(cfg.TLS)

View File

@ -1,81 +1,86 @@
package main
import (
// Register connectors
_ "github.com/go-gost/gost/pkg/connector/forward"
_ "github.com/go-gost/gost/pkg/connector/http"
_ "github.com/go-gost/gost/pkg/connector/http2"
_ "github.com/go-gost/gost/pkg/connector/relay"
_ "github.com/go-gost/gost/pkg/connector/sni"
_ "github.com/go-gost/gost/pkg/connector/socks/v4"
_ "github.com/go-gost/gost/pkg/connector/socks/v5"
_ "github.com/go-gost/gost/pkg/connector/ss"
_ "github.com/go-gost/gost/pkg/connector/ss/udp"
_ "github.com/go-gost/gost/pkg/connector/sshd"
// core components
_ "github.com/go-gost/gost/v3/pkg/connector/forward"
_ "github.com/go-gost/gost/v3/pkg/connector/http"
_ "github.com/go-gost/gost/v3/pkg/connector/http2"
_ "github.com/go-gost/gost/v3/pkg/connector/socks/v4"
_ "github.com/go-gost/gost/v3/pkg/connector/socks/v5"
// Register dialers
_ "github.com/go-gost/gost/pkg/dialer/ftcp"
_ "github.com/go-gost/gost/pkg/dialer/grpc"
_ "github.com/go-gost/gost/pkg/dialer/http2"
_ "github.com/go-gost/gost/pkg/dialer/http2/h2"
_ "github.com/go-gost/gost/pkg/dialer/http3"
_ "github.com/go-gost/gost/pkg/dialer/icmp"
_ "github.com/go-gost/gost/pkg/dialer/kcp"
_ "github.com/go-gost/gost/pkg/dialer/obfs/http"
_ "github.com/go-gost/gost/pkg/dialer/obfs/tls"
_ "github.com/go-gost/gost/pkg/dialer/pht"
_ "github.com/go-gost/gost/pkg/dialer/quic"
_ "github.com/go-gost/gost/pkg/dialer/ssh"
_ "github.com/go-gost/gost/pkg/dialer/sshd"
_ "github.com/go-gost/gost/pkg/dialer/tcp"
_ "github.com/go-gost/gost/pkg/dialer/tls"
_ "github.com/go-gost/gost/pkg/dialer/tls/mux"
_ "github.com/go-gost/gost/pkg/dialer/udp"
_ "github.com/go-gost/gost/pkg/dialer/ws"
_ "github.com/go-gost/gost/pkg/dialer/ws/mux"
_ "github.com/go-gost/gost/v3/pkg/dialer/http2"
_ "github.com/go-gost/gost/v3/pkg/dialer/http2/h2"
_ "github.com/go-gost/gost/v3/pkg/dialer/tcp"
_ "github.com/go-gost/gost/v3/pkg/dialer/tls"
_ "github.com/go-gost/gost/v3/pkg/dialer/udp"
// Register handlers
_ "github.com/go-gost/gost/pkg/handler/auto"
_ "github.com/go-gost/gost/pkg/handler/dns"
_ "github.com/go-gost/gost/pkg/handler/forward/local"
_ "github.com/go-gost/gost/pkg/handler/forward/remote"
_ "github.com/go-gost/gost/pkg/handler/http"
_ "github.com/go-gost/gost/pkg/handler/http2"
_ "github.com/go-gost/gost/pkg/handler/redirect"
_ "github.com/go-gost/gost/pkg/handler/relay"
_ "github.com/go-gost/gost/pkg/handler/sni"
_ "github.com/go-gost/gost/pkg/handler/socks/v4"
_ "github.com/go-gost/gost/pkg/handler/socks/v5"
_ "github.com/go-gost/gost/pkg/handler/ss"
_ "github.com/go-gost/gost/pkg/handler/ss/udp"
_ "github.com/go-gost/gost/pkg/handler/sshd"
_ "github.com/go-gost/gost/pkg/handler/tap"
_ "github.com/go-gost/gost/pkg/handler/tun"
_ "github.com/go-gost/gost/v3/pkg/handler/auto"
_ "github.com/go-gost/gost/v3/pkg/handler/forward/local"
_ "github.com/go-gost/gost/v3/pkg/handler/forward/remote"
_ "github.com/go-gost/gost/v3/pkg/handler/http"
_ "github.com/go-gost/gost/v3/pkg/handler/http2"
_ "github.com/go-gost/gost/v3/pkg/handler/socks/v4"
_ "github.com/go-gost/gost/v3/pkg/handler/socks/v5"
// Register listeners
_ "github.com/go-gost/gost/pkg/listener/dns"
_ "github.com/go-gost/gost/pkg/listener/ftcp"
_ "github.com/go-gost/gost/pkg/listener/grpc"
_ "github.com/go-gost/gost/pkg/listener/http2"
_ "github.com/go-gost/gost/pkg/listener/http2/h2"
_ "github.com/go-gost/gost/pkg/listener/http3"
_ "github.com/go-gost/gost/pkg/listener/icmp"
_ "github.com/go-gost/gost/pkg/listener/kcp"
_ "github.com/go-gost/gost/pkg/listener/obfs/http"
_ "github.com/go-gost/gost/pkg/listener/obfs/tls"
_ "github.com/go-gost/gost/pkg/listener/pht"
_ "github.com/go-gost/gost/pkg/listener/quic"
_ "github.com/go-gost/gost/pkg/listener/redirect/udp"
_ "github.com/go-gost/gost/pkg/listener/rtcp"
_ "github.com/go-gost/gost/pkg/listener/rudp"
_ "github.com/go-gost/gost/pkg/listener/ssh"
_ "github.com/go-gost/gost/pkg/listener/sshd"
_ "github.com/go-gost/gost/pkg/listener/tap"
_ "github.com/go-gost/gost/pkg/listener/tcp"
_ "github.com/go-gost/gost/pkg/listener/tls"
_ "github.com/go-gost/gost/pkg/listener/tls/mux"
_ "github.com/go-gost/gost/pkg/listener/tun"
_ "github.com/go-gost/gost/pkg/listener/udp"
_ "github.com/go-gost/gost/pkg/listener/ws"
_ "github.com/go-gost/gost/pkg/listener/ws/mux"
)
_ "github.com/go-gost/gost/v3/pkg/listener/http2"
_ "github.com/go-gost/gost/v3/pkg/listener/http2/h2"
_ "github.com/go-gost/gost/v3/pkg/listener/rtcp"
_ "github.com/go-gost/gost/v3/pkg/listener/rudp"
_ "github.com/go-gost/gost/v3/pkg/listener/tcp"
_ "github.com/go-gost/gost/v3/pkg/listener/tls"
/*
// extended components
_ "github.com/go-gost/gost/pkg/connector/relay"
_ "github.com/go-gost/gost/pkg/connector/sni"
_ "github.com/go-gost/gost/pkg/connector/ss"
_ "github.com/go-gost/gost/pkg/connector/ss/udp"
_ "github.com/go-gost/gost/pkg/connector/sshd"
// Register dialers
_ "github.com/go-gost/gost/pkg/dialer/ftcp"
_ "github.com/go-gost/gost/pkg/dialer/grpc"
_ "github.com/go-gost/gost/pkg/dialer/http3"
_ "github.com/go-gost/gost/pkg/dialer/icmp"
_ "github.com/go-gost/gost/pkg/dialer/kcp"
_ "github.com/go-gost/gost/pkg/dialer/obfs/http"
_ "github.com/go-gost/gost/pkg/dialer/obfs/tls"
_ "github.com/go-gost/gost/pkg/dialer/pht"
_ "github.com/go-gost/gost/pkg/dialer/quic"
_ "github.com/go-gost/gost/pkg/dialer/ssh"
_ "github.com/go-gost/gost/pkg/dialer/sshd"
_ "github.com/go-gost/gost/pkg/dialer/tls/mux"
_ "github.com/go-gost/gost/pkg/dialer/ws"
_ "github.com/go-gost/gost/pkg/dialer/ws/mux"
// Register handlers
_ "github.com/go-gost/gost/pkg/handler/dns"
_ "github.com/go-gost/gost/pkg/handler/redirect"
_ "github.com/go-gost/gost/pkg/handler/relay"
_ "github.com/go-gost/gost/pkg/handler/sni"
_ "github.com/go-gost/gost/pkg/handler/ss"
_ "github.com/go-gost/gost/pkg/handler/ss/udp"
_ "github.com/go-gost/gost/pkg/handler/sshd"
_ "github.com/go-gost/gost/pkg/handler/tap"
_ "github.com/go-gost/gost/pkg/handler/tun"
// Register listeners
_ "github.com/go-gost/gost/pkg/listener/dns"
_ "github.com/go-gost/gost/pkg/listener/ftcp"
_ "github.com/go-gost/gost/pkg/listener/grpc"
_ "github.com/go-gost/gost/pkg/listener/http3"
_ "github.com/go-gost/gost/pkg/listener/icmp"
_ "github.com/go-gost/gost/pkg/listener/kcp"
_ "github.com/go-gost/gost/pkg/listener/obfs/http"
_ "github.com/go-gost/gost/pkg/listener/obfs/tls"
_ "github.com/go-gost/gost/pkg/listener/pht"
_ "github.com/go-gost/gost/pkg/listener/quic"
_ "github.com/go-gost/gost/pkg/listener/redirect/udp"
_ "github.com/go-gost/gost/pkg/listener/ssh"
_ "github.com/go-gost/gost/pkg/listener/sshd"
_ "github.com/go-gost/gost/pkg/listener/tap"
_ "github.com/go-gost/gost/pkg/listener/tls/mux"
_ "github.com/go-gost/gost/pkg/listener/tun"
_ "github.com/go-gost/gost/pkg/listener/udp"
_ "github.com/go-gost/gost/pkg/listener/ws"
_ "github.com/go-gost/gost/pkg/listener/ws/mux"
*/)

View File

@ -10,8 +10,8 @@ import (
"math/big"
"time"
tls_util "github.com/go-gost/gost/pkg/common/util/tls"
"github.com/go-gost/gost/pkg/config"
tls_util "github.com/go-gost/gost/v3/pkg/common/util/tls"
"github.com/go-gost/gost/v3/pkg/config"
)
func buildDefaultTLSConfig(cfg *config.TLSConfig) {