From af9130480fb30371f7f43894d44889ac493c1e5f Mon Sep 17 00:00:00 2001 From: charles Date: Sun, 5 Dec 2021 18:55:04 +0800 Subject: [PATCH] extract relay type --- cmd/config.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index 04cdbd7..5d88dbc 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -3,6 +3,7 @@ package main import ( "errors" "fmt" + "github.com/yosuke-furukawa/json5/encoding/json5" ) @@ -70,6 +71,12 @@ func (c *serverConfig) String() string { return fmt.Sprintf("%+v", *c) } +type Relay struct { + Listen string `json:"listen"` + Remote string `json:"remote"` + Timeout int `json:"timeout"` +} + type clientConfig struct { Server string `json:"server"` UpMbps int `json:"up_mbps"` @@ -99,16 +106,10 @@ type clientConfig struct { DNS []string `json:"dns"` Persist bool `json:"persist"` } `json:"tun"` - TCPRelay struct { - Listen string `json:"listen"` - Remote string `json:"remote"` - Timeout int `json:"timeout"` - } `json:"relay_tcp"` - UDPRelay struct { - Listen string `json:"listen"` - Remote string `json:"remote"` - Timeout int `json:"timeout"` - } `json:"relay_udp"` + TCPRelays []Relay `json:"relay_tcps"` + TCPRelay Relay `json:"relay_tcp"` + UDPRelays []Relay `json:"relay_udps"` + UDPRelay Relay `json:"relay_udp"` TCPTProxy struct { Listen string `json:"listen"` Timeout int `json:"timeout"`