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" "golang.org/x/net/ipv6"
) )
var ( var _ Bind = (*StdNetBind)(nil)
_ Bind = (*StdNetBind)(nil)
)
// StdNetBind implements Bind for all platforms. While Windows has its own Bind // StdNetBind implements Bind for all platforms. While Windows has its own Bind
// (see bind_windows.go), it may fall back to StdNetBind. // (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) return s.msgsPool.Get().(*[]ipv6.Message)
} }
var ( // If compilation fails here these are no longer the same underlying type.
// If compilation fails here these are no longer the same underlying type. var _ ipv6.Message = ipv4.Message{}
_ ipv6.Message = ipv4.Message{}
)
type batchReader interface { type batchReader interface {
ReadBatch([]ipv6.Message, int) (int, error) ReadBatch([]ipv6.Message, int) (int, error)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -12,10 +12,10 @@ import (
"sync" "sync"
"time" "time"
"github.com/sagernet/wireguard-go/conn"
"golang.org/x/crypto/chacha20poly1305" "golang.org/x/crypto/chacha20poly1305"
"golang.org/x/net/ipv4" "golang.org/x/net/ipv4"
"golang.org/x/net/ipv6" "golang.org/x/net/ipv6"
"golang.zx2c4.com/wireguard/conn"
) )
type QueueHandshakeElement struct { type QueueHandshakeElement struct {
@ -411,7 +411,6 @@ func (device *Device) RoutineHandshake(id int) {
// derive keypair // derive keypair
err = peer.BeginSymmetricSession() err = peer.BeginSymmetricSession()
if err != nil { if err != nil {
device.log.Errorf("%v - Failed to derive keypair: %v", peer, err) device.log.Errorf("%v - Failed to derive keypair: %v", peer, err)
goto skip goto skip

View file

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

View file

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

View file

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

View file

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

View file

@ -18,7 +18,7 @@ import (
"sync" "sync"
"time" "time"
"golang.zx2c4.com/wireguard/ipc" "github.com/sagernet/wireguard-go/ipc"
) )
type IPCError struct { 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 go 1.23.1

View file

@ -9,8 +9,8 @@ import (
"net" "net"
"os" "os"
"github.com/sagernet/wireguard-go/rwcancel"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"golang.zx2c4.com/wireguard/rwcancel"
) )
type UAPIListener struct { type UAPIListener struct {
@ -84,7 +84,6 @@ func UAPIListen(name string, file *os.File) (net.Listener, error) {
unix.IN_DELETE| unix.IN_DELETE|
unix.IN_DELETE_SELF, unix.IN_DELETE_SELF,
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

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

View file

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

View file

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

View file

@ -17,9 +17,9 @@ import (
"time" "time"
"unsafe" "unsafe"
"github.com/sagernet/wireguard-go/conn"
"github.com/sagernet/wireguard-go/rwcancel"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/rwcancel"
) )
const ( const (
@ -514,9 +514,7 @@ func (tun *NativeTun) initFromFlags(name string) error {
return err return err
} }
if e := sc.Control(func(fd uintptr) { if e := sc.Control(func(fd uintptr) {
var ( var ifr *unix.Ifreq
ifr *unix.Ifreq
)
ifr, err = unix.NewIfreq(name) ifr, err = unix.NewIfreq(name)
if err != nil { if err != nil {
return return