Update On Wed Jun 26 20:32:17 CEST 2024

This commit is contained in:
github-action[bot]
2024-06-26 20:32:18 +02:00
parent b4c13ca1fc
commit bfc1931721
223 changed files with 19065 additions and 1052 deletions

View File

@@ -1,13 +1,17 @@
package cli
import cli "github.com/urfave/cli/v2"
import (
"github.com/Ehco1996/ehco/internal/constant"
cli "github.com/urfave/cli/v2"
)
var (
LocalAddr string
ListenType string
ListenType constant.RelayType
TCPRemoteAddr string
UDPRemoteAddr string
TransportType string
TransportType constant.RelayType
ConfigPath string
WebPort int
WebToken string
@@ -30,7 +34,7 @@ var RootFlags = []cli.Flag{
Value: "raw",
Usage: "监听类型,可选项有 raw,ws,wss,mwss",
EnvVars: []string{"EHCO_LISTEN_TYPE"},
Destination: &ListenType,
Destination: (*string)(&ListenType),
Required: false,
},
&cli.StringFlag{
@@ -50,7 +54,7 @@ var RootFlags = []cli.Flag{
Value: "raw",
Usage: "传输类型,可选选有 raw,ws,wss,mwss",
EnvVars: []string{"EHCO_TRANSPORT_TYPE"},
Destination: &TransportType,
Destination: (*string)(&TransportType),
},
&cli.StringFlag{
Name: "c,config",

View File

@@ -2,6 +2,8 @@ package constant
import "time"
type RelayType string
var (
// allow change in test
IdleTimeOut = 10 * time.Second
@@ -30,12 +32,12 @@ const (
// relay type
const (
// tcp relay
RelayTypeRaw = "raw"
RelayTypeMTCP = "mtcp"
RelayTypeRaw RelayType = "raw"
RelayTypeMTCP RelayType = "mtcp"
// ws relay
RelayTypeWS = "ws"
RelayTypeMWS = "mws"
RelayTypeWSS = "wss"
RelayTypeMWSS = "mwss"
RelayTypeWS RelayType = "ws"
RelayTypeMWS RelayType = "mws"
RelayTypeWSS RelayType = "wss"
RelayTypeMWSS RelayType = "mwss"
)

View File

@@ -24,12 +24,12 @@ type WSConfig struct {
}
type Config struct {
Label string `json:"label,omitempty"`
Listen string `json:"listen"`
ListenType string `json:"listen_type"`
TransportType string `json:"transport_type"`
TCPRemotes []string `json:"tcp_remotes"`
UDPRemotes []string `json:"udp_remotes"`
Label string `json:"label,omitempty"`
Listen string `json:"listen"`
ListenType constant.RelayType `json:"listen_type"`
TransportType constant.RelayType `json:"transport_type"`
TCPRemotes []string `json:"tcp_remotes"`
UDPRemotes []string `json:"udp_remotes"`
MaxConnection int `json:"max_connection,omitempty"`
BlockedProtocols []string `json:"blocked_protocols,omitempty"`

View File

@@ -33,7 +33,7 @@ func newRelayClient(cfg *conf.Config) (RelayClient, error) {
case constant.RelayTypeMWSS:
return newMwssClient(cfg)
default:
return nil, fmt.Errorf("unsupported transport type" + cfg.TransportType)
return nil, fmt.Errorf("unsupported transport type: %s", cfg.TransportType)
}
}

View File

@@ -32,7 +32,7 @@ type WsClient struct {
func newWsClient(cfg *conf.Config) (*WsClient, error) {
s := &WsClient{
cfg: cfg,
l: zap.S().Named(cfg.TransportType),
l: zap.S().Named(string(cfg.TransportType)),
dialer: &ws.Dialer{Timeout: constant.DialTimeOut},
}
return s, nil