Add resolver for inbound

This commit is contained in:
世界 2022-07-07 23:36:32 +08:00
parent 538a1f5909
commit 9c256afc1a
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
22 changed files with 261 additions and 173 deletions

View file

@ -79,12 +79,13 @@ func (h *Inbound) UnmarshalJSON(bytes []byte) error {
}
type ListenOptions struct {
Listen ListenAddress `json:"listen"`
Port uint16 `json:"listen_port"`
TCPFastOpen bool `json:"tcp_fast_open,omitempty"`
UDPTimeout int64 `json:"udp_timeout,omitempty"`
SniffEnabled bool `json:"sniff,omitempty"`
SniffOverrideDestination bool `json:"sniff_override_destination,omitempty"`
Listen ListenAddress `json:"listen"`
Port uint16 `json:"listen_port"`
TCPFastOpen bool `json:"tcp_fast_open,omitempty"`
UDPTimeout int64 `json:"udp_timeout,omitempty"`
SniffEnabled bool `json:"sniff,omitempty"`
SniffOverrideDestination bool `json:"sniff_override_destination,omitempty"`
DomainStrategy DomainStrategy `json:"domain_strategy,omitempty"`
}
type SimpleInboundOptions struct {

View file

@ -67,13 +67,17 @@ func (h *Outbound) UnmarshalJSON(bytes []byte) error {
}
type DialerOptions struct {
Detour string `json:"detour,omitempty"`
BindInterface string `json:"bind_interface,omitempty"`
ProtectPath string `json:"protect_path,omitempty"`
RoutingMark int `json:"routing_mark,omitempty"`
ReuseAddr bool `json:"reuse_addr,omitempty"`
ConnectTimeout int `json:"connect_timeout,omitempty"`
TCPFastOpen bool `json:"tcp_fast_open,omitempty"`
Detour string `json:"detour,omitempty"`
BindInterface string `json:"bind_interface,omitempty"`
ProtectPath string `json:"protect_path,omitempty"`
RoutingMark int `json:"routing_mark,omitempty"`
ReuseAddr bool `json:"reuse_addr,omitempty"`
ConnectTimeout int `json:"connect_timeout,omitempty"`
TCPFastOpen bool `json:"tcp_fast_open,omitempty"`
}
type OutboundDialerOptions struct {
DialerOptions
OverrideOptions *OverrideStreamOptions `json:"override,omitempty"`
DomainStrategy DomainStrategy `json:"domain_strategy,omitempty"`
}
@ -99,13 +103,13 @@ func (o ServerOptions) Build() M.Socksaddr {
}
type DirectOutboundOptions struct {
DialerOptions
OutboundDialerOptions
OverrideAddress string `json:"override_address,omitempty"`
OverridePort uint16 `json:"override_port,omitempty"`
}
type SocksOutboundOptions struct {
DialerOptions
OutboundDialerOptions
ServerOptions
Version string `json:"version,omitempty"`
Username string `json:"username,omitempty"`
@ -114,14 +118,14 @@ type SocksOutboundOptions struct {
}
type HTTPOutboundOptions struct {
DialerOptions
OutboundDialerOptions
ServerOptions
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
type ShadowsocksOutboundOptions struct {
DialerOptions
OutboundDialerOptions
ServerOptions
Method string `json:"method"`
Password string `json:"password"`

View file

@ -100,13 +100,13 @@ func (s DomainStrategy) MarshalJSON() ([]byte, error) {
value = ""
// value = "AsIS"
case C.DomainStrategyPreferIPv4:
value = "PreferIPv4"
value = "prefer_ipv4"
case C.DomainStrategyPreferIPv6:
value = "PreferIPv6"
value = "prefer_ipv6"
case C.DomainStrategyUseIPv4:
value = "UseIPv4"
value = "ipv4_only"
case C.DomainStrategyUseIPv6:
value = "UseIPv6"
value = "ipv6_only"
default:
return nil, E.New("unknown domain strategy: ", s)
}
@ -122,13 +122,13 @@ func (s *DomainStrategy) UnmarshalJSON(bytes []byte) error {
switch value {
case "", "AsIS":
*s = DomainStrategy(C.DomainStrategyAsIS)
case "PreferIPv4":
case "prefer_ipv4":
*s = DomainStrategy(C.DomainStrategyPreferIPv4)
case "PreferIPv6":
case "prefer_ipv6":
*s = DomainStrategy(C.DomainStrategyPreferIPv6)
case "UseIPv4":
case "ipv4_only":
*s = DomainStrategy(C.DomainStrategyUseIPv4)
case "UseIPv6":
case "ipv6_only":
*s = DomainStrategy(C.DomainStrategyUseIPv6)
default:
return E.New("unknown domain strategy: ", value)