Naming unify

This commit is contained in:
Iurii Egorov 2024-01-19 15:08:27 +03:00 committed by Iurii Egorov
parent ce9d3866a3
commit e3c9ec8012
36 changed files with 80 additions and 78 deletions

2
.gitignore vendored
View file

@ -1 +1 @@
wireguard-go amneziawg-go

View file

@ -8,13 +8,13 @@ RUN go mod download && \
FROM alpine:3.15 as awg-tools FROM alpine:3.15 as awg-tools
ARG AWGTOOLS_RELEASE="1.0.20231215" ARG AWGTOOLS_RELEASE="1.0.20231215"
RUN apk --no-cache add linux-headers build-base bash && \ RUN apk --no-cache add linux-headers build-base bash && \
wget https://github.com/amnezia-vpn/amnezia-wg-tools/archive/refs/tags/v${AWGTOOLS_RELEASE}.zip && \ wget https://github.com/amnezia-vpn/amneziawg-tools/archive/refs/tags/v${AWGTOOLS_RELEASE}.zip && \
unzip v${AWGTOOLS_RELEASE}.zip && \ unzip v${AWGTOOLS_RELEASE}.zip && \
cd amnezia-wg-tools-${AWGTOOLS_RELEASE}/src && \ cd amneziawg-tools-${AWGTOOLS_RELEASE}/src && \
make -e LDFLAGS=-static && \ make -e LDFLAGS=-static && \
make install make install
FROM alpine:3.15 FROM alpine:3.15
RUN apk --no-cache add iproute2 bash RUN apk --no-cache add iproute2 bash
COPY --from=awg /usr/bin/amnezia-wg /usr/bin/wireguard-go COPY --from=awg /usr/bin/amneziawg-go /usr/bin/amneziawg-go
COPY --from=awg-tools /usr/bin/wg /usr/bin/wg-quick /usr/bin/ COPY --from=awg-tools /usr/bin/awg /usr/bin/awg-quick /usr/bin/

View file

@ -14,18 +14,18 @@ generate-version-and-build:
[ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \ [ "$$(cat version.go 2>/dev/null)" != "$$ver" ] && \
echo "$$ver" > version.go && \ echo "$$ver" > version.go && \
git update-index --assume-unchanged version.go || true git update-index --assume-unchanged version.go || true
@$(MAKE) wireguard-go @$(MAKE) amneziawg-go
wireguard-go: $(wildcard *.go) $(wildcard */*.go) amneziawg-go: $(wildcard *.go) $(wildcard */*.go)
go build -v -o "$@" go build -v -o "$@"
install: wireguard-go install: amneziawg-go
@install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 "$<" "$(DESTDIR)$(BINDIR)/wireguard-go" @install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 "$<" "$(DESTDIR)$(BINDIR)/amneziawg-go"
test: test:
go test ./... go test ./...
clean: clean:
rm -f wireguard-go rm -f amneziawg-go
.PHONY: all clean test install generate-version-and-build .PHONY: all clean test install generate-version-and-build

View file

@ -11,17 +11,17 @@ As a result, AmneziaWG maintains high performance while adding an extra layer of
Simply run: Simply run:
``` ```
$ amnezia-wg wg0 $ amneziawg-go wg0
``` ```
This will create an interface and fork into the background. To remove the interface, use the usual `ip link del wg0`, or if your system does not support removing interfaces directly, you may instead remove the control socket via `rm -f /var/run/wireguard/wg0.sock`, which will result in wireguard-go shutting down. This will create an interface and fork into the background. To remove the interface, use the usual `ip link del wg0`, or if your system does not support removing interfaces directly, you may instead remove the control socket via `rm -f /var/run/amneziawg/wg0.sock`, which will result in amneziawg-go shutting down.
To run amnezia-wg without forking to the background, pass `-f` or `--foreground`: To run amneziawg-go without forking to the background, pass `-f` or `--foreground`:
``` ```
$ amnezia-wg -f wg0 $ amneziawg-go -f wg0
``` ```
When an interface is running, you may use [`amnezia-wg-tools `](https://github.com/amnezia-vpn/amnezia-wg-tools) to configure it, as well as the usual `ip(8)` and `ifconfig(8)` commands. When an interface is running, you may use [`amnezia-wg-tools `](https://github.com/amnezia-vpn/amneziawg-go-tools) to configure it, as well as the usual `ip(8)` and `ifconfig(8)` commands.
To run with more logging you may set the environment variable `LOG_LEVEL=debug`. To run with more logging you may set the environment variable `LOG_LEVEL=debug`.
@ -46,7 +46,7 @@ This runs on Windows, you should use it from [awg-windows](https://github.com/am
This requires an installation of the latest version of [Go](https://go.dev/). This requires an installation of the latest version of [Go](https://go.dev/).
``` ```
$ git clone https://github.com/amnezia-vpn/amnezia-wg $ git clone https://github.com/amnezia-vpn/amneziawg-go
$ cd amnezia-wg $ cd amneziawg-go
$ make $ make
``` ```

View file

@ -17,7 +17,7 @@ import (
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"github.com/amnezia-vpn/amnezia-wg/conn/winrio" "github.com/amnezia-vpn/amneziawg-go/conn/winrio"
) )
const ( const (

View file

@ -12,7 +12,7 @@ import (
"net/netip" "net/netip"
"os" "os"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
) )
type ChannelBind struct { type ChannelBind struct {

View file

@ -8,7 +8,7 @@ package device
import ( import (
"errors" "errors"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
) )
type DummyDatagram struct { type DummyDatagram struct {

View file

@ -11,11 +11,11 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/ipc" "github.com/amnezia-vpn/amneziawg-go/ipc"
"github.com/amnezia-vpn/amnezia-wg/ratelimiter" "github.com/amnezia-vpn/amneziawg-go/ratelimiter"
"github.com/amnezia-vpn/amnezia-wg/rwcancel" "github.com/amnezia-vpn/amneziawg-go/rwcancel"
"github.com/amnezia-vpn/amnezia-wg/tun" "github.com/amnezia-vpn/amneziawg-go/tun"
"github.com/tevino/abool/v2" "github.com/tevino/abool/v2"
) )

View file

@ -20,10 +20,10 @@ import (
"testing" "testing"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/conn/bindtest" "github.com/amnezia-vpn/amneziawg-go/conn/bindtest"
"github.com/amnezia-vpn/amnezia-wg/tun" "github.com/amnezia-vpn/amneziawg-go/tun"
"github.com/amnezia-vpn/amnezia-wg/tun/tuntest" "github.com/amnezia-vpn/amneziawg-go/tun/tuntest"
) )
// uapiCfg returns a string that contains cfg formatted use with IpcSet. // uapiCfg returns a string that contains cfg formatted use with IpcSet.
@ -237,7 +237,7 @@ func genTestPair(
if _, ok := tb.(*testing.B); ok && !testing.Verbose() { if _, ok := tb.(*testing.B); ok && !testing.Verbose() {
level = LogLevelError level = LogLevelError
} }
p.dev = NewDevice(p.tun.TUN(),binds[i],NewLogger(level, fmt.Sprintf("dev%d: ", i))) p.dev = NewDevice(p.tun.TUN(), binds[i], NewLogger(level, fmt.Sprintf("dev%d: ", i)))
if err := p.dev.IpcSet(cfg[i]); err != nil { if err := p.dev.IpcSet(cfg[i]); err != nil {
tb.Errorf("failed to configure device %d: %v", i, err) tb.Errorf("failed to configure device %d: %v", i, err)
p.dev.Close() p.dev.Close()
@ -294,7 +294,7 @@ func TestUpDown(t *testing.T) {
pair := genTestPair(t, false, false) pair := genTestPair(t, false, false)
for i := range pair { for i := range pair {
for k := range pair[i].dev.peers.keyMap { for k := range pair[i].dev.peers.keyMap {
pair[i].dev.IpcSet(fmt.Sprintf("public_key=%s\npersistent_keepalive_interval=1\n",hex.EncodeToString(k[:]))) pair[i].dev.IpcSet(fmt.Sprintf("public_key=%s\npersistent_keepalive_interval=1\n", hex.EncodeToString(k[:])))
} }
} }
var wg sync.WaitGroup var wg sync.WaitGroup
@ -513,7 +513,7 @@ func (b *fakeBindSized) Open(
func (b *fakeBindSized) Close() error { return nil } func (b *fakeBindSized) Close() error { return nil }
func (b *fakeBindSized) SetMark(mark uint32) error {return nil } func (b *fakeBindSized) SetMark(mark uint32) error { return nil }
func (b *fakeBindSized) Send(bufs [][]byte, ep conn.Endpoint) error { return nil } func (b *fakeBindSized) Send(bufs [][]byte, ep conn.Endpoint) error { return nil }
@ -527,7 +527,9 @@ type fakeTUNDeviceSized struct {
func (t *fakeTUNDeviceSized) File() *os.File { return nil } func (t *fakeTUNDeviceSized) File() *os.File { return nil }
func (t *fakeTUNDeviceSized) Read(bufs [][]byte, sizes []int, offset int) (n int, err error) { return 0, nil } func (t *fakeTUNDeviceSized) Read(bufs [][]byte, sizes []int, offset int) (n int, err error) {
return 0, nil
}
func (t *fakeTUNDeviceSized) Write(bufs [][]byte, offset int) (int, error) { return 0, nil } func (t *fakeTUNDeviceSized) Write(bufs [][]byte, offset int) (int, error) { return 0, nil }

View file

@ -11,7 +11,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/replay" "github.com/amnezia-vpn/amneziawg-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

@ -15,7 +15,7 @@ import (
"golang.org/x/crypto/chacha20poly1305" "golang.org/x/crypto/chacha20poly1305"
"golang.org/x/crypto/poly1305" "golang.org/x/crypto/poly1305"
"github.com/amnezia-vpn/amnezia-wg/tai64n" "github.com/amnezia-vpn/amneziawg-go/tai64n"
) )
type handshakeState int type handshakeState int

View file

@ -10,8 +10,8 @@ import (
"encoding/binary" "encoding/binary"
"testing" "testing"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/tun/tuntest" "github.com/amnezia-vpn/amneziawg-go/tun/tuntest"
) )
func TestCurveWrappers(t *testing.T) { func TestCurveWrappers(t *testing.T) {

View file

@ -12,7 +12,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
) )
type Peer struct { type Peer struct {

View file

@ -5,7 +5,7 @@
package device package device
import "github.com/amnezia-vpn/amnezia-wg/conn" import "github.com/amnezia-vpn/amneziawg-go/conn"
/* Reduce memory consumption for Android */ /* Reduce memory consumption for Android */

View file

@ -7,7 +7,7 @@
package device package device
import "github.com/amnezia-vpn/amnezia-wg/conn" import "github.com/amnezia-vpn/amneziawg-go/conn"
const ( const (
QueueStagedSize = conn.IdealBatchSize QueueStagedSize = conn.IdealBatchSize

View file

@ -13,7 +13,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-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"
@ -145,7 +145,7 @@ func (device *Device) RoutineReceiveIncoming(
junkSize := msgTypeToJunkSize[assumedMsgType] junkSize := msgTypeToJunkSize[assumedMsgType]
// transport size can align with other header types; // transport size can align with other header types;
// making sure we have the right msgType // making sure we have the right msgType
msgType = binary.LittleEndian.Uint32(packet[junkSize:junkSize+4]) msgType = binary.LittleEndian.Uint32(packet[junkSize : junkSize+4])
if msgType == assumedMsgType { if msgType == assumedMsgType {
packet = packet[junkSize:] packet = packet[junkSize:]
} else { } else {

View file

@ -15,8 +15,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/tun" "github.com/amnezia-vpn/amneziawg-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"

View file

@ -3,8 +3,8 @@
package device package device
import ( import (
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/rwcancel" "github.com/amnezia-vpn/amneziawg-go/rwcancel"
) )
func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) { func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) {

View file

@ -20,8 +20,8 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/rwcancel" "github.com/amnezia-vpn/amneziawg-go/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"
"github.com/amnezia-vpn/amnezia-wg/tun" "github.com/amnezia-vpn/amneziawg-go/tun"
) )
const DefaultMTU = 1420 const DefaultMTU = 1420

View file

@ -18,7 +18,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/ipc" "github.com/amnezia-vpn/amneziawg-go/ipc"
) )
type IPCError struct { type IPCError struct {

2
go.mod
View file

@ -1,4 +1,4 @@
module github.com/amnezia-vpn/amnezia-wg module github.com/amnezia-vpn/amneziawg-go
go 1.20 go 1.20

View file

@ -20,7 +20,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/ipc/namedpipe" "github.com/amnezia-vpn/amneziawg-go/ipc/namedpipe"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )

View file

@ -9,7 +9,7 @@ import (
"net" "net"
"os" "os"
"github.com/amnezia-vpn/amnezia-wg/rwcancel" "github.com/amnezia-vpn/amneziawg-go/rwcancel"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View file

@ -26,7 +26,7 @@ const (
// socketDirectory is variable because it is modified by a linker // socketDirectory is variable because it is modified by a linker
// flag in wireguard-android. // flag in wireguard-android.
var socketDirectory = "/var/run/wireguard" var socketDirectory = "/var/run/amneziawg"
func sockPath(iface string) string { func sockPath(iface string) string {
return fmt.Sprintf("%s/%s.sock", socketDirectory, iface) return fmt.Sprintf("%s/%s.sock", socketDirectory, iface)

View file

@ -8,7 +8,7 @@ package ipc
import ( import (
"net" "net"
"github.com/amnezia-vpn/amnezia-wg/ipc/namedpipe" "github.com/amnezia-vpn/amneziawg-go/ipc/namedpipe"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )

View file

@ -14,10 +14,10 @@ import (
"runtime" "runtime"
"strconv" "strconv"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/device" "github.com/amnezia-vpn/amneziawg-go/device"
"github.com/amnezia-vpn/amnezia-wg/ipc" "github.com/amnezia-vpn/amneziawg-go/ipc"
"github.com/amnezia-vpn/amnezia-wg/tun" "github.com/amnezia-vpn/amneziawg-go/tun"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View file

@ -12,11 +12,11 @@ import (
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/device" "github.com/amnezia-vpn/amneziawg-go/device"
"github.com/amnezia-vpn/amnezia-wg/ipc" "github.com/amnezia-vpn/amneziawg-go/ipc"
"github.com/amnezia-vpn/amnezia-wg/tun" "github.com/amnezia-vpn/amneziawg-go/tun"
) )
const ( const (

View file

@ -13,9 +13,9 @@ import (
"net/http" "net/http"
"net/netip" "net/netip"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/device" "github.com/amnezia-vpn/amneziawg-go/device"
"github.com/amnezia-vpn/amnezia-wg/tun/netstack" "github.com/amnezia-vpn/amneziawg-go/tun/netstack"
) )
func main() { func main() {

View file

@ -14,9 +14,9 @@ import (
"net/http" "net/http"
"net/netip" "net/netip"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/device" "github.com/amnezia-vpn/amneziawg-go/device"
"github.com/amnezia-vpn/amnezia-wg/tun/netstack" "github.com/amnezia-vpn/amneziawg-go/tun/netstack"
) )
func main() { func main() {

View file

@ -17,9 +17,9 @@ import (
"golang.org/x/net/icmp" "golang.org/x/net/icmp"
"golang.org/x/net/ipv4" "golang.org/x/net/ipv4"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/device" "github.com/amnezia-vpn/amneziawg-go/device"
"github.com/amnezia-vpn/amnezia-wg/tun/netstack" "github.com/amnezia-vpn/amneziawg-go/tun/netstack"
) )
func main() { func main() {

View file

@ -22,7 +22,7 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/amnezia-vpn/amnezia-wg/tun" "github.com/amnezia-vpn/amneziawg-go/tun"
"golang.org/x/net/dns/dnsmessage" "golang.org/x/net/dns/dnsmessage"
"gvisor.dev/gvisor/pkg/buffer" "gvisor.dev/gvisor/pkg/buffer"

View file

@ -12,7 +12,7 @@ import (
"io" "io"
"unsafe" "unsafe"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View file

@ -9,7 +9,7 @@ import (
"net/netip" "net/netip"
"testing" "testing"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip"
"gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/header"

View file

@ -17,8 +17,8 @@ import (
"time" "time"
"unsafe" "unsafe"
"github.com/amnezia-vpn/amnezia-wg/conn" "github.com/amnezia-vpn/amneziawg-go/conn"
"github.com/amnezia-vpn/amnezia-wg/rwcancel" "github.com/amnezia-vpn/amneziawg-go/rwcancel"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View file

@ -11,7 +11,7 @@ import (
"net/netip" "net/netip"
"os" "os"
"github.com/amnezia-vpn/amnezia-wg/tun" "github.com/amnezia-vpn/amneziawg-go/tun"
) )
func Ping(dst, src netip.Addr) []byte { func Ping(dst, src netip.Addr) []byte {