mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-04 18:58:44 +00:00
XICMP finalmask: Refactor & Speed up; Add multi ips and dgram mode (client) (#6168)
https://github.com/XTLS/Xray-core/pull/5872#issuecomment-4198514120 https://github.com/XTLS/Xray-core/pull/6168#issuecomment-4571606666 https://github.com/XTLS/Xray-core/pull/6168#issuecomment-4573294637 Example: https://github.com/XTLS/Xray-core/pull/6168#issue-4484980927 Closes https://github.com/XTLS/Xray-core/discussions/5879
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"math"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
@@ -1901,18 +1902,20 @@ func (c *Xdns) Build() (proto.Message, error) {
|
||||
}
|
||||
|
||||
type Xicmp struct {
|
||||
ListenIp string `json:"listenIp"`
|
||||
Id uint16 `json:"id"`
|
||||
DGRAM bool `json:"dgram"`
|
||||
IPs []string `json:"ips"`
|
||||
}
|
||||
|
||||
func (c *Xicmp) Build() (proto.Message, error) {
|
||||
config := &xicmp.Config{
|
||||
Ip: c.ListenIp,
|
||||
Id: int32(c.Id),
|
||||
for _, ip := range c.IPs {
|
||||
if _, err := netip.ParseAddr(ip); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if config.Ip == "" {
|
||||
config.Ip = "0.0.0.0"
|
||||
config := &xicmp.Config{
|
||||
DGRAM: c.DGRAM,
|
||||
IPs: c.IPs,
|
||||
}
|
||||
|
||||
return config, nil
|
||||
|
||||
Reference in New Issue
Block a user