mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-08-07 14:25:17 +03:00
Add call protocol, Rmux. Update AmneziaWG. Fixes and improvements
This commit is contained in:
78
option/call.go
Normal file
78
option/call.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package option
|
||||
|
||||
import "strings"
|
||||
|
||||
// CallCookie is a single cookie entry provided inline in the configuration as
|
||||
// JSON, matching the browser-exported {name, value} format.
|
||||
type CallCookie struct {
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// CallCookieList is the list of cookies provided in the configuration.
|
||||
type CallCookieList []CallCookie
|
||||
|
||||
// Header renders the cookie list into a single "name=value; name=value"
|
||||
// header string. Entries with an empty name are skipped.
|
||||
func (l CallCookieList) Header() string {
|
||||
if len(l) == 0 {
|
||||
return ""
|
||||
}
|
||||
parts := make([]string, 0, len(l))
|
||||
for _, c := range l {
|
||||
if c.Name == "" {
|
||||
continue
|
||||
}
|
||||
parts = append(parts, c.Name+"="+c.Value)
|
||||
}
|
||||
return strings.Join(parts, "; ")
|
||||
}
|
||||
|
||||
// ParseCookieHeader parses a "name=value; name=value" cookie header string into
|
||||
// a CallCookieList.
|
||||
func ParseCookieHeader(header string) CallCookieList {
|
||||
header = strings.TrimSpace(header)
|
||||
if header == "" {
|
||||
return nil
|
||||
}
|
||||
var list CallCookieList
|
||||
for _, part := range strings.Split(header, ";") {
|
||||
part = strings.TrimSpace(part)
|
||||
if part == "" {
|
||||
continue
|
||||
}
|
||||
name, value, _ := strings.Cut(part, "=")
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
list = append(list, CallCookie{Name: name, Value: strings.TrimSpace(value)})
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
type CallCommonOptions struct {
|
||||
Platform string `json:"platform,omitempty"`
|
||||
Mode string `json:"mode,omitempty"`
|
||||
ReadBuffer int `json:"read_buffer,omitempty"`
|
||||
MaxBufferedAmount int `json:"max_buffered_amount,omitempty"`
|
||||
MemoryLimit int64 `json:"memory_limit,omitempty"`
|
||||
}
|
||||
|
||||
type CallInboundOptions struct {
|
||||
DialerOptions
|
||||
CallCommonOptions
|
||||
Cookies CallCookieList `json:"cookies,omitempty"`
|
||||
JoinLink string `json:"join_link,omitempty"`
|
||||
// Email and Password are used to re-authenticate with the dion.vc
|
||||
// platform when the refresh cookie is missing or rejected.
|
||||
Email string `json:"email,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
type CallOutboundOptions struct {
|
||||
DialerOptions
|
||||
CallCommonOptions
|
||||
JoinLink string `json:"join_link"`
|
||||
Cookies CallCookieList `json:"cookies,omitempty"`
|
||||
}
|
||||
@@ -7,16 +7,22 @@ import (
|
||||
)
|
||||
|
||||
type VPNClientEndpointOptions struct {
|
||||
Address netip.Addr `json:"address"`
|
||||
Key string `json:"key"`
|
||||
Outbound Outbound `json:"outbound"`
|
||||
Address netip.Addr `json:"address"`
|
||||
Key string `json:"key"`
|
||||
Outbound Outbound `json:"outbound"`
|
||||
PoolSize uint8 `json:"pool_size,omitempty"`
|
||||
ReconnectDelay badoption.Duration `json:"reconnect_delay,omitempty"`
|
||||
RejectDelay badoption.Duration `json:"reject_delay,omitempty"`
|
||||
DefaultGateway netip.Addr `json:"default_gateway,omitempty"`
|
||||
}
|
||||
|
||||
type VPNServerEndpointOptions struct {
|
||||
Address netip.Addr `json:"address"`
|
||||
Users []VPNUser `json:"users"`
|
||||
Inbounds []Inbound `json:"inbounds"`
|
||||
PoolSize uint8 `json:"pool_size,omitempty"`
|
||||
ConnectTimeout badoption.Duration `json:"connect_timeout,omitempty"`
|
||||
DefaultGateway netip.Addr `json:"default_gateway,omitempty"`
|
||||
}
|
||||
|
||||
type VPNUser struct {
|
||||
|
||||
Reference in New Issue
Block a user