Add socks outbound

This commit is contained in:
世界
2022-07-03 13:14:49 +08:00
parent ef5cfd59d4
commit 70c0812606
10 changed files with 122 additions and 28 deletions

View File

@@ -10,6 +10,7 @@ type _Outbound struct {
Tag string `json:"tag,omitempty"`
Type string `json:"type,omitempty"`
DirectOptions DirectOutboundOptions `json:"-"`
SocksOptions SocksOutboundOptions `json:"-"`
ShadowsocksOptions ShadowsocksOutboundOptions `json:"-"`
}
@@ -20,6 +21,8 @@ func (h Outbound) MarshalJSON() ([]byte, error) {
switch h.Type {
case "direct":
v = h.DirectOptions
case "socks":
v = h.SocksOptions
case "shadowsocks":
v = h.ShadowsocksOptions
default:
@@ -37,6 +40,8 @@ func (h *Outbound) UnmarshalJSON(bytes []byte) error {
switch h.Type {
case "direct":
v = &h.DirectOptions
case "socks":
v = &h.SocksOptions
case "shadowsocks":
v = &h.ShadowsocksOptions
default:
@@ -73,6 +78,14 @@ func (o ServerOptions) Build() M.Socksaddr {
return M.ParseSocksaddrHostPort(o.Server, o.ServerPort)
}
type SocksOutboundOptions struct {
DialerOptions
ServerOptions
Version string `json:"version,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
type ShadowsocksOutboundOptions struct {
DialerOptions
ServerOptions