mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-08-16 23:27:35 +08:00
Simplify slice to array conversion
This commit is contained in:
parent
e1dbcccab5
commit
76ee64ae50
@ -454,5 +454,5 @@ func parseADGuardIPCIDRLine(ruleLine string) (netip.Prefix, error) {
|
|||||||
for len(ruleParts) < 4 {
|
for len(ruleParts) < 4 {
|
||||||
ruleParts = append(ruleParts, 0)
|
ruleParts = append(ruleParts, 0)
|
||||||
}
|
}
|
||||||
return netip.PrefixFrom(netip.AddrFrom4(*(*[4]byte)(ruleParts)), bitLen), nil
|
return netip.PrefixFrom(netip.AddrFrom4([4]byte(ruleParts)), bitLen), nil
|
||||||
}
|
}
|
||||||
|
@ -96,11 +96,11 @@ func findProcessName(network string, ip netip.Addr, port int) (string, error) {
|
|||||||
switch {
|
switch {
|
||||||
case flag&0x1 > 0 && isIPv4:
|
case flag&0x1 > 0 && isIPv4:
|
||||||
// ipv4
|
// ipv4
|
||||||
srcIP = netip.AddrFrom4(*(*[4]byte)(buf[inp+76 : inp+80]))
|
srcIP = netip.AddrFrom4([4]byte(buf[inp+76 : inp+80]))
|
||||||
srcIsIPv4 = true
|
srcIsIPv4 = true
|
||||||
case flag&0x2 > 0 && !isIPv4:
|
case flag&0x2 > 0 && !isIPv4:
|
||||||
// ipv6
|
// ipv6
|
||||||
srcIP = netip.AddrFrom16(*(*[16]byte)(buf[inp+64 : inp+80]))
|
srcIP = netip.AddrFrom16([16]byte(buf[inp+64 : inp+80]))
|
||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func defaultRouteIP() (netip.Addr, error) {
|
|||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
ip := addr.(*net.IPNet).IP
|
ip := addr.(*net.IPNet).IP
|
||||||
if ip.To4() != nil {
|
if ip.To4() != nil {
|
||||||
return netip.AddrFrom4(*(*[4]byte)(ip)), nil
|
return netip.AddrFrom4([4]byte(ip)), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ func (w *Writer) WriteBuffer(buffer *buf.Buffer) error {
|
|||||||
if !w.isServer {
|
if !w.isServer {
|
||||||
maskKey := rand.Uint32()
|
maskKey := rand.Uint32()
|
||||||
binary.BigEndian.PutUint32(header[1+payloadBitLength:], maskKey)
|
binary.BigEndian.PutUint32(header[1+payloadBitLength:], maskKey)
|
||||||
ws.Cipher(data, *(*[4]byte)(header[1+payloadBitLength:]), 0)
|
ws.Cipher(data, [4]byte(header[1+payloadBitLength:]), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return wrapWsError(w.writer.WriteBuffer(buffer))
|
return wrapWsError(w.writer.WriteBuffer(buffer))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user