warp

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const KeyLen = 32 // wgh.KeyLen

KeyLen is the expected key length for a WireGuard key.

View Source
const SNICurveSize = 1200

Variables

View Source
var APILoadOrCreateIdentity = LoadOrCreateIdentity

Functions

func APIGetWarpPorts

func APIGetWarpPorts() []uint16

func APIRandomWarpEndpoint

func APIRandomWarpEndpoint(v4, v6 bool) (netip.AddrPort, error)

func APIRandomWarpPrefix

func APIRandomWarpPrefix(v4, v6 bool) netip.Prefix

func APIWarpPrefixes

func APIWarpPrefixes() []netip.Prefix

func RandomWarpEndpoint

func RandomWarpEndpoint(v4, v6 bool) (netip.AddrPort, error)

func RandomWarpPort

func RandomWarpPort() uint16

func RandomWarpPrefix

func RandomWarpPrefix(v4, v6 bool) netip.Prefix

func WarpPorts

func WarpPorts() []uint16

func WarpPrefixes

func WarpPrefixes() []netip.Prefix

Types

type APIIdentity

type APIIdentity = Identity

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

Dialer is a struct that holds various options for custom dialing.

func (*Dialer) TLSDial

func (d *Dialer) TLSDial(network, addr string) (net.Conn, error)

TLSDial dials a TLS connection.

type Identity

type Identity struct {
	PrivateKey      string          `json:"private_key"`
	Key             string          `json:"key"`
	Account         IdentityAccount `json:"account"`
	Place           int64           `json:"place"`
	FCMToken        string          `json:"fcm_token"`
	Name            string          `json:"name"`
	TOS             string          `json:"tos"`
	Locale          string          `json:"locale"`
	InstallID       string          `json:"install_id"`
	WarpEnabled     bool            `json:"warp_enabled"`
	Type            string          `json:"type"`
	Model           string          `json:"model"`
	Config          IdentityConfig  `json:"config"`
	Token           string          `json:"token"`
	Enabled         bool            `json:"enabled"`
	ID              string          `json:"id"`
	Created         string          `json:"created"`
	Updated         string          `json:"updated"`
	WaitlistEnabled bool            `json:"waitlist_enabled"`
}

func CreateIdentity

func CreateIdentity(l *slog.Logger, warpAPI *WarpAPI, license string) (Identity, error)

func LoadIdentity

func LoadIdentity(path string) (Identity, error)

func LoadOrCreateIdentity

func LoadOrCreateIdentity(l *slog.Logger, path, license string) (*Identity, error)

type IdentityAccount

type IdentityAccount struct {
	Created                  string `json:"created"`
	Updated                  string `json:"updated"`
	License                  string `json:"license"`
	PremiumData              int64  `json:"premium_data"`
	WarpPlus                 bool   `json:"warp_plus"`
	AccountType              string `json:"account_type"`
	ReferralRenewalCountdown int64  `json:"referral_renewal_countdown"`
	Role                     string `json:"role"`
	ID                       string `json:"id"`
	Quota                    int64  `json:"quota"`
	Usage                    int64  `json:"usage"`
	ReferralCount            int64  `json:"referral_count"`
	TTL                      string `json:"ttl"`
}

type IdentityConfig

type IdentityConfig struct {
	Peers     []IdentityConfigPeer    `json:"peers"`
	Interface IdentityConfigInterface `json:"interface"`
	Services  IdentityConfigServices  `json:"services"`
	ClientID  string                  `json:"client_id"`
}

type IdentityConfigInterface

type IdentityConfigInterface struct {
	Addresses IdentityConfigInterfaceAddresses `json:"addresses"`
}

type IdentityConfigInterfaceAddresses

type IdentityConfigInterfaceAddresses struct {
	V4 string `json:"v4"`
	V6 string `json:"v6"`
}

type IdentityConfigPeer

type IdentityConfigPeer struct {
	PublicKey string                     `json:"public_key"`
	Endpoint  IdentityConfigPeerEndpoint `json:"endpoint"`
}

type IdentityConfigPeerEndpoint

type IdentityConfigPeerEndpoint struct {
	V4    string   `json:"v4"`
	V6    string   `json:"v6"`
	Host  string   `json:"host"`
	Ports []uint16 `json:"ports"`
}

type IdentityConfigServices

type IdentityConfigServices struct {
	HTTPProxy string `json:"http_proxy"`
}

type IdentityDevice

type IdentityDevice struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	Model     string `json:"model"`
	Created   string `json:"created"`
	Activated string `json:"updated"`
	Active    bool   `json:"active"`
	Role      string `json:"role"`
}

type Key

type Key [KeyLen]byte

A Key is a public, private, or pre-shared secret key. The Key constructor functions in this package can be used to create Keys suitable for each of these applications.

func GenerateKey

func GenerateKey() (Key, error)

GenerateKey generates a Key suitable for use as a pre-shared secret key from a cryptographically safe source.

The output Key should not be used as a private key; use GeneratePrivateKey instead.

func GeneratePrivateKey

func GeneratePrivateKey() (Key, error)

GeneratePrivateKey generates a Key suitable for use as a private key from a cryptographically safe source.

func NewKey

func NewKey(b []byte) (Key, error)

NewKey creates a Key from an existing byte slice. The byte slice must be exactly 32 bytes in length.

func (Key) PublicKey

func (k Key) PublicKey() Key

PublicKey computes a public key from the private key k.

PublicKey should only be called when k is a private key.

func (Key) String

func (k Key) String() string

String returns the base64-encoded string representation of a Key.

ParseKey can be used to produce a new Key from this string.

type License

type License struct {
	License string `json:"license"`
}

type SNICurveExtension

type SNICurveExtension struct {
	*tls.GenericExtension
	SNICurveLen int
	WillPad     bool // set false to disable extension
}

SNICurveExtension implements SNICurve (0x15) extension

func (*SNICurveExtension) Len

func (e *SNICurveExtension) Len() int

Len returns the length of the SNICurveExtension.

func (*SNICurveExtension) Read

func (e *SNICurveExtension) Read(b []byte) (n int, err error)

Read reads the SNICurveExtension.

type WarpAPI

type WarpAPI struct {
	// contains filtered or unexported fields
}

func NewWarpAPI

func NewWarpAPI(l *slog.Logger) *WarpAPI

func (*WarpAPI) DeleteDevice

func (w *WarpAPI) DeleteDevice(authToken, deviceID string) error

func (*WarpAPI) GetAccount

func (w *WarpAPI) GetAccount(authToken, deviceID string) (IdentityAccount, error)

func (*WarpAPI) GetBoundDevices

func (w *WarpAPI) GetBoundDevices(authToken, deviceID string) ([]IdentityDevice, error)

func (*WarpAPI) GetSourceDevice

func (w *WarpAPI) GetSourceDevice(authToken, deviceID string) (Identity, error)

func (*WarpAPI) Register

func (w *WarpAPI) Register(publicKey string) (Identity, error)

func (*WarpAPI) ResetAccountLicense

func (w *WarpAPI) ResetAccountLicense(authToken, deviceID string) (License, error)

func (*WarpAPI) UpdateAccount

func (w *WarpAPI) UpdateAccount(authToken, deviceID, license string) (IdentityAccount, error)

func (*WarpAPI) UpdateBoundDevice

func (w *WarpAPI) UpdateBoundDevice(authToken, deviceID, otherDeviceID, name string, active bool) (IdentityDevice, error)

func (*WarpAPI) UpdateSourceDevice

func (w *WarpAPI) UpdateSourceDevice(authToken, deviceID, publicKey string) (Identity, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL