Reformat code

This commit is contained in:
世界 2025-09-15 18:12:47 +08:00
parent 558e1e0493
commit d79d3c88fd
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
8 changed files with 11 additions and 22 deletions

View file

@ -213,10 +213,8 @@ func (s *StdNetBind) getMessages() *[]ipv6.Message {
return s.msgsPool.Get().(*[]ipv6.Message)
}
var (
// If compilation fails here these are no longer the same underlying type.
_ ipv6.Message = ipv4.Message{}
)
// If compilation fails here these are no longer the same underlying type.
var _ ipv6.Message = ipv4.Message{}
type batchReader interface {
ReadBatch([]ipv6.Message, int) (int, error)

View file

@ -15,9 +15,8 @@ import (
"sync/atomic"
"unsafe"
"golang.org/x/sys/windows"
"github.com/sagernet/wireguard-go/conn/winrio"
"golang.org/x/sys/windows"
)
const (

View file

@ -12,12 +12,11 @@ import (
"sync"
"time"
"github.com/sagernet/wireguard-go/conn"
"github.com/sagernet/wireguard-go/tai64n"
"golang.org/x/crypto/blake2s"
"golang.org/x/crypto/chacha20poly1305"
"golang.org/x/crypto/poly1305"
"github.com/sagernet/wireguard-go/conn"
"github.com/sagernet/wireguard-go/tai64n"
)
type handshakeState int

View file

@ -411,7 +411,6 @@ func (device *Device) RoutineHandshake(id int) {
// derive keypair
err = peer.BeginSymmetricSession()
if err != nil {
device.log.Errorf("%v - Failed to derive keypair: %v", peer, err)
goto skip

View file

@ -18,10 +18,9 @@ import (
"sync"
"unsafe"
"golang.org/x/sys/unix"
"github.com/sagernet/wireguard-go/conn"
"github.com/sagernet/wireguard-go/rwcancel"
"golang.org/x/sys/unix"
)
func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) {

View file

@ -84,7 +84,6 @@ func UAPIListen(name string, file *os.File) (net.Listener, error) {
unix.IN_DELETE|
unix.IN_DELETE_SELF,
)
if err != nil {
return nil, err
}

View file

@ -4,9 +4,7 @@ import (
"errors"
)
var (
// ErrTooManySegments is returned by Device.Read() when segmentation
// overflows the length of supplied buffers. This error should not cause
// reads to cease.
ErrTooManySegments = errors.New("too many segments")
)
// ErrTooManySegments is returned by Device.Read() when segmentation
// overflows the length of supplied buffers. This error should not cause
// reads to cease.
var ErrTooManySegments = errors.New("too many segments")

View file

@ -506,9 +506,7 @@ func (tun *NativeTun) initFromFlags(name string) error {
return err
}
if e := sc.Control(func(fd uintptr) {
var (
ifr *unix.Ifreq
)
var ifr *unix.Ifreq
ifr, err = unix.NewIfreq(name)
if err != nil {
return