warp

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const KeyLen = 32 // wgh.KeyLen

KeyLen is the expected key length for a WireGuard key.

Variables

This section is empty.

Functions

func LoadOrCreateIdentity

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

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 RemoveDevice

func RemoveDevice(l *slog.Logger, accountID, accessToken string) error

func WarpPorts

func WarpPorts() []uint16

func WarpPrefixes

func WarpPrefixes() []netip.Prefix

Types

type Dialer

type Dialer struct{}

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

func (*Dialer) TLSDial

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

TLSDial dials a TLS connection.

type Identity added in v1.1.1

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 added in v1.1.1

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

func LoadIdentity added in v1.1.1

func LoadIdentity(path string) (Identity, error)

type IdentityAccount added in v1.1.1

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 added in v1.1.1

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

type IdentityConfigInterface added in v1.1.1

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

type IdentityConfigInterfaceAddresses added in v1.1.1

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

type IdentityConfigPeer added in v1.1.1

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

type IdentityConfigPeerEndpoint added in v1.1.1

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

type IdentityConfigServices added in v1.1.1

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

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 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 SNIExtension

type SNIExtension struct {
	*tls.GenericExtension
	ServerName string // not an array because go crypto/tls doesn't support multiple SNIs
}

SNIExtension implements server_name (0)

func (*SNIExtension) Len

func (e *SNIExtension) Len() int

Len returns the length of the SNIExtension.

func (*SNIExtension) Read

func (e *SNIExtension) Read(b []byte) (int, error)

Read reads the SNIExtension.

Jump to

Keyboard shortcuts

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