Add reserved to WireGuard config

Fixes https://github.com/XTLS/Xray-core/issues/1730
This commit is contained in:
RPRX 2023-03-02 16:55:42 +00:00 committed by GitHub
parent 6526e74d49
commit ccba465590
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 12 deletions

View file

@ -52,6 +52,7 @@ type WireGuardConfig struct {
Peers []*WireGuardPeerConfig `json:"peers"`
MTU int `json:"mtu"`
NumWorkers int `json:"workers"`
Reserved []byte `json:"reserved"`
}
func (c *WireGuardConfig) Build() (proto.Message, error) {
@ -90,6 +91,11 @@ func (c *WireGuardConfig) Build() (proto.Message, error) {
// we don't need to process fallback manually
config.NumWorkers = int32(c.NumWorkers)
if len(c.Reserved) != 0 && len(c.Reserved) != 3 {
return nil, newError(`"reserved" should be empty or 3 bytes`)
}
config.Reserved = c.Reserved
return config, nil
}