mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-04-03 20:07:36 +03:00
Remove map usage in options
This commit is contained in:
parent
08534c277e
commit
b2f456d6c5
2 changed files with 18 additions and 15 deletions
|
@ -4,17 +4,18 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
"github.com/sagernet/sing/common/json/badjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ShadowTLSInboundOptions struct {
|
type ShadowTLSInboundOptions struct {
|
||||||
ListenOptions
|
ListenOptions
|
||||||
Version int `json:"version,omitempty"`
|
Version int `json:"version,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
Users []ShadowTLSUser `json:"users,omitempty"`
|
Users []ShadowTLSUser `json:"users,omitempty"`
|
||||||
Handshake ShadowTLSHandshakeOptions `json:"handshake,omitempty"`
|
Handshake ShadowTLSHandshakeOptions `json:"handshake,omitempty"`
|
||||||
HandshakeForServerName map[string]ShadowTLSHandshakeOptions `json:"handshake_for_server_name,omitempty"`
|
HandshakeForServerName *badjson.TypedMap[string, ShadowTLSHandshakeOptions] `json:"handshake_for_server_name,omitempty"`
|
||||||
StrictMode bool `json:"strict_mode,omitempty"`
|
StrictMode bool `json:"strict_mode,omitempty"`
|
||||||
WildcardSNI WildcardSNI `json:"wildcard_sni,omitempty"`
|
WildcardSNI WildcardSNI `json:"wildcard_sni,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WildcardSNI int
|
type WildcardSNI int
|
||||||
|
|
|
@ -46,14 +46,16 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
||||||
var handshakeForServerName map[string]shadowtls.HandshakeConfig
|
var handshakeForServerName map[string]shadowtls.HandshakeConfig
|
||||||
if options.Version > 1 {
|
if options.Version > 1 {
|
||||||
handshakeForServerName = make(map[string]shadowtls.HandshakeConfig)
|
handshakeForServerName = make(map[string]shadowtls.HandshakeConfig)
|
||||||
for serverName, serverOptions := range options.HandshakeForServerName {
|
if options.HandshakeForServerName != nil {
|
||||||
handshakeDialer, err := dialer.New(ctx, serverOptions.DialerOptions, serverOptions.ServerIsDomain())
|
for _, entry := range options.HandshakeForServerName.Entries() {
|
||||||
if err != nil {
|
handshakeDialer, err := dialer.New(ctx, entry.Value.DialerOptions, entry.Value.ServerIsDomain())
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
handshakeForServerName[serverName] = shadowtls.HandshakeConfig{
|
}
|
||||||
Server: serverOptions.ServerOptions.Build(),
|
handshakeForServerName[entry.Key] = shadowtls.HandshakeConfig{
|
||||||
Dialer: handshakeDialer,
|
Server: entry.Value.ServerOptions.Build(),
|
||||||
|
Dialer: handshakeDialer,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue