Rename module

This commit is contained in:
世界 2026-05-17 20:08:42 +08:00
parent f853bfc5c5
commit 75d0f348d5
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
20 changed files with 33 additions and 46 deletions

View file

@ -20,9 +20,7 @@ import (
"golang.org/x/net/ipv6"
)
var (
_ Bind = (*StdNetBind)(nil)
)
var _ Bind = (*StdNetBind)(nil)
// StdNetBind implements Bind for all platforms. While Windows has its own Bind
// (see bind_windows.go), it may fall back to StdNetBind.
@ -210,10 +208,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"
"github.com/sagernet/wireguard-go/conn/winrio"
"golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/conn/winrio"
)
const (

View file

@ -11,10 +11,10 @@ import (
"sync/atomic"
"time"
"golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/ratelimiter"
"golang.zx2c4.com/wireguard/rwcancel"
"golang.zx2c4.com/wireguard/tun"
"github.com/sagernet/wireguard-go/conn"
"github.com/sagernet/wireguard-go/ratelimiter"
"github.com/sagernet/wireguard-go/rwcancel"
"github.com/sagernet/wireguard-go/tun"
)
type Device struct {

View file

@ -11,7 +11,7 @@ import (
"sync/atomic"
"time"
"golang.zx2c4.com/wireguard/replay"
"github.com/sagernet/wireguard-go/replay"
)
/* Due to limitations in Go and /x/crypto there is currently

View file

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

View file

@ -12,7 +12,7 @@ import (
"sync/atomic"
"time"
"golang.zx2c4.com/wireguard/conn"
"github.com/sagernet/wireguard-go/conn"
)
type Peer struct {

View file

@ -5,7 +5,7 @@
package device
import "golang.zx2c4.com/wireguard/conn"
import "github.com/sagernet/wireguard-go/conn"
/* Reduce memory consumption for Android */

View file

@ -7,7 +7,7 @@
package device
import "golang.zx2c4.com/wireguard/conn"
import "github.com/sagernet/wireguard-go/conn"
const (
QueueStagedSize = conn.IdealBatchSize

View file

@ -12,10 +12,10 @@ import (
"sync"
"time"
"github.com/sagernet/wireguard-go/conn"
"golang.org/x/crypto/chacha20poly1305"
"golang.org/x/net/ipv4"
"golang.org/x/net/ipv6"
"golang.zx2c4.com/wireguard/conn"
)
type QueueHandshakeElement struct {
@ -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

@ -13,11 +13,11 @@ import (
"sync"
"time"
"github.com/sagernet/wireguard-go/conn"
"github.com/sagernet/wireguard-go/tun"
"golang.org/x/crypto/chacha20poly1305"
"golang.org/x/net/ipv4"
"golang.org/x/net/ipv6"
"golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/tun"
)
/* Outbound flow

View file

@ -3,8 +3,8 @@
package device
import (
"golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/rwcancel"
"github.com/sagernet/wireguard-go/conn"
"github.com/sagernet/wireguard-go/rwcancel"
)
func (device *Device) startRouteListener(_ conn.Bind) (*rwcancel.RWCancel, error) {

View file

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

View file

@ -8,7 +8,7 @@ package device
import (
"fmt"
"golang.zx2c4.com/wireguard/tun"
"github.com/sagernet/wireguard-go/tun"
)
const DefaultMTU = 1420

View file

@ -18,7 +18,7 @@ import (
"sync"
"time"
"golang.zx2c4.com/wireguard/ipc"
"github.com/sagernet/wireguard-go/ipc"
)
type IPCError struct {

2
go.mod
View file

@ -1,4 +1,4 @@
module golang.zx2c4.com/wireguard
module github.com/sagernet/wireguard-go
go 1.23.1

View file

@ -9,8 +9,8 @@ import (
"net"
"os"
"github.com/sagernet/wireguard-go/rwcancel"
"golang.org/x/sys/unix"
"golang.zx2c4.com/wireguard/rwcancel"
)
type UAPIListener struct {
@ -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

@ -8,8 +8,8 @@ package ipc
import (
"net"
"github.com/sagernet/wireguard-go/ipc/namedpipe"
"golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/ipc/namedpipe"
)
// TODO: replace these with actual standard windows error numbers from the win package

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

@ -12,8 +12,8 @@ import (
"io"
"unsafe"
"github.com/sagernet/wireguard-go/conn"
"golang.org/x/sys/unix"
"golang.zx2c4.com/wireguard/conn"
)
const tcpFlagsOffset = 13

View file

@ -17,9 +17,9 @@ import (
"time"
"unsafe"
"github.com/sagernet/wireguard-go/conn"
"github.com/sagernet/wireguard-go/rwcancel"
"golang.org/x/sys/unix"
"golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/rwcancel"
)
const (
@ -514,9 +514,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