mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-05 19:28:45 +00:00
feat: add root browserDialers tags for dialerProxy integration
Agent-Logs-Url: https://github.com/XTLS/Xray-core/sessions/808be5b1-7ed2-4309-87f1-18a808d6aba4 Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
97ad6cef43
commit
ca3cd5fb88
@@ -33,6 +33,7 @@ type task struct {
|
||||
|
||||
var sockoptDialers map[string]*dialerInstance
|
||||
var dialerServers map[string]*dialerServer
|
||||
var dialerTags map[string]string
|
||||
var mu sync.RWMutex
|
||||
|
||||
const browserDialerSubprotocol = "browser-dialer"
|
||||
@@ -51,6 +52,37 @@ func HasBrowserDialerWithAddress(addr string) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func GetAddressByTag(tag string) (string, bool) {
|
||||
if tag == "" {
|
||||
return "", false
|
||||
}
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
addr, ok := dialerTags[tag]
|
||||
return addr, ok
|
||||
}
|
||||
|
||||
func ConfigureDialerTags(tags map[string]string) error {
|
||||
next := make(map[string]string, len(tags))
|
||||
for tag, addr := range tags {
|
||||
if tag == "" {
|
||||
return errors.New("browserDialers tag cannot be empty")
|
||||
}
|
||||
if addr == "" {
|
||||
return errors.New("browserDialers url cannot be empty for tag: ", tag)
|
||||
}
|
||||
if err := EnsureDialerWithAddress(addr); err != nil {
|
||||
return errors.New("invalid browserDialers entry for tag ", tag).Base(err)
|
||||
}
|
||||
next[tag] = addr
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
dialerTags = next
|
||||
mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
type webSocketExtra struct {
|
||||
Protocol string `json:"protocol,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user