mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-07-16 21:09:44 +03:00
Integrate AmneziaWG
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/sagernet/sing/common"
|
||||
@@ -179,6 +180,17 @@ func (e *Endpoint) Start(resolve bool) error {
|
||||
wgDevice := device.NewDevice(e.options.Context, e.tunDevice, bind, logger, e.options.Workers)
|
||||
e.tunDevice.SetDevice(wgDevice)
|
||||
ipcConf := e.ipcConf
|
||||
if e.options.Amnezia != nil {
|
||||
ipcConf += "\njc=" + strconv.Itoa(e.options.Amnezia.JC) + "\n"
|
||||
ipcConf += "jmin=" + strconv.Itoa(e.options.Amnezia.JMin) + "\n"
|
||||
ipcConf += "jmax=" + strconv.Itoa(e.options.Amnezia.JMax) + "\n"
|
||||
ipcConf += "s1=" + strconv.Itoa(e.options.Amnezia.S1) + "\n"
|
||||
ipcConf += "s2=" + strconv.Itoa(e.options.Amnezia.S2) + "\n"
|
||||
ipcConf += "h1=" + strconv.FormatUint(uint64(e.options.Amnezia.H1), 10) + "\n"
|
||||
ipcConf += "h2=" + strconv.FormatUint(uint64(e.options.Amnezia.H2), 10) + "\n"
|
||||
ipcConf += "h3=" + strconv.FormatUint(uint64(e.options.Amnezia.H3), 10) + "\n"
|
||||
ipcConf += "h4=" + strconv.FormatUint(uint64(e.options.Amnezia.H4), 10)
|
||||
}
|
||||
for _, peer := range e.peers {
|
||||
ipcConf += peer.GenerateIpcLines()
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ type EndpointOptions struct {
|
||||
ResolvePeer func(domain string) (netip.Addr, error)
|
||||
Peers []PeerOptions
|
||||
Workers int
|
||||
Amnezia *AmneziaOptions
|
||||
}
|
||||
|
||||
type PeerOptions struct {
|
||||
@@ -37,3 +38,15 @@ type PeerOptions struct {
|
||||
PersistentKeepaliveInterval uint16
|
||||
Reserved []uint8
|
||||
}
|
||||
|
||||
type AmneziaOptions struct {
|
||||
JC int
|
||||
JMin int
|
||||
JMax int
|
||||
S1 int
|
||||
S2 int
|
||||
H1 uint32
|
||||
H2 uint32
|
||||
H3 uint32
|
||||
H4 uint32
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user