rpn

package
v0.0.0-...-bf8faa0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Net6to4 = []netip.Prefix{
	netip.MustParsePrefix("2a00:1098:2b::/96"),
	netip.MustParsePrefix("2a00:1098:2c:1::/96"),
	netip.MustParsePrefix("2a01:4f8:c2c:123f:64::/96"),
	netip.MustParsePrefix("2a01:4f9:c010:3f02:64::/96"),
	netip.MustParsePrefix("2001:67c:2960:6464::/96"),
	netip.MustParsePrefix("2001:67c:2b0:db32:0:1::/96"),
}

preset 6to4 NATs; from: nat64.xyz

Functions

func Exit64Endpoints

func Exit64Endpoints() (v6 []netip.Addr, errs error)

func WinEndpoints

func WinEndpoints() (v4 []netip.AddrPort, v6 []netip.AddrPort, err error)

Types

type BaseClient

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

func NewExtClient

func NewExtClient(d protect.RDialer) *BaseClient

func (*BaseClient) MakeWsWg

func (w *BaseClient) MakeWsWg(entitlement []byte) (*WsClient, error)

func (*BaseClient) MakeWsWgFrom

func (w *BaseClient) MakeWsWgFrom(entitlementOrWsConfigJson []byte) (*WsClient, error)

type RegionalWgConf

type RegionalWgConf struct {
	// WsServerList.CountryCode (uppercased)
	CC string `json:"CC"`
	// WsServerGroup.City
	City string `json:"City"`
	// City (Nick)
	Name string `json:"Name"`
	// WsServerGroup.Health (0-100, lower is better)
	Load int32 `json:"Load"`
	// WsServerGroup.LinkSpeed (100, 1000, 10000 in mbps)
	Link int32 `json:"Link"`
	// len(WsServerGroup.Nodes) (number of nodes in this group)
	Count int32 `json:"Count"`
	// WsServerList.PremiumOnly == 1
	Premium bool `json:"Premium"`

	ClientAddr4   string `json:"ClientAddr4"`
	ClientAddr6   string `json:"ClientAddr6"`
	ClientPrivKey string `json:"ClientPrivKey"`
	ClientPubKey  string `json:"ClientPubKey"`
	ClientDNS4    string `json:"ClientDNS4"`
	ClientDNS6    string `json:"ClientDNS6"`

	PskKey string `json:"PskKey"`

	ServerPubKey     string   `json:"ServerPubKey"`
	ServerIPPort4    string   `json:"ServerIPPort4"`
	ServerIPPort6    string   `json:"ServerIPPort6"`
	ServerDomainPort string   `json:"ServerDomainPort"`
	AllowedIPs       []string `json:"AllowedIPs"` // csv

	WgConf     string `json:"wgconf"`     // generated
	UapiWgConf string `json:"uapiwgconf"` // generated
}

func (*RegionalWgConf) GenUapiConfig

func (rwg *RegionalWgConf) GenUapiConfig() (didGenerate bool)

func (*RegionalWgConf) String

func (rwg *RegionalWgConf) String() string

type RpnAcc

type RpnAcc interface {
	x.RpnAcc
	ProviderID() string // x.RpnWg, x.RpnPro, x.RpnAmz, x.RpnWin
	MultiCountry() bool
	Conf(key string) (string, error)
}

type RpnCountryless

type RpnCountryless struct{}

func (RpnCountryless) Locations

func (c RpnCountryless) Locations() (x.RpnServers, error)

func (RpnCountryless) MultiCountry

func (c RpnCountryless) MultiCountry() bool

type RpnForever

type RpnForever struct{}

func (RpnForever) Created

func (RpnForever) Created() int64

func (RpnForever) Expires

func (RpnForever) Expires() int64

type RpnMultiCountry

type RpnMultiCountry struct{}

func (RpnMultiCountry) MultiCountry

func (RpnMultiCountry) MultiCountry() bool

type RpnMultiCountryServers

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

func (*RpnMultiCountryServers) Get

func (s *RpnMultiCountryServers) Get(i int) (*x.RpnServer, error)

func (*RpnMultiCountryServers) Json

func (s *RpnMultiCountryServers) Json() (*x.Gobyte, error)

func (*RpnMultiCountryServers) Len

func (s *RpnMultiCountryServers) Len() int

type RpnStateless

type RpnStateless struct {
	RpnUpdateless
}

func (RpnStateless) Conf

func (RpnStateless) Conf(cc string) (string, error)

func (RpnStateless) State

func (RpnStateless) State() (*x.Gobyte, error)

type RpnUpdateless

type RpnUpdateless struct{}

func (RpnUpdateless) Update

func (RpnUpdateless) Update() (*x.Gobyte, error)

type WsClient

type WsClient struct {
	RpnMultiCountry
	// contains filtered or unexported fields
}

func (*WsClient) Conf

func (a *WsClient) Conf(cc string) (string, error)

Conf implements RpnAcc.

func (*WsClient) Created

func (a *WsClient) Created() int64

Created implements x.RpnAcc.

func (*WsClient) Expires

func (a *WsClient) Expires() int64

Expires implements x.RpnAcc.

func (*WsClient) Locations

func (a *WsClient) Locations() (x.RpnServers, error)

func (*WsClient) ProviderID

func (*WsClient) ProviderID() string

ProviderID implements RpnAcc.

func (*WsClient) State

func (a *WsClient) State() (*x.Gobyte, error)

State implements x.RpnAcc.

func (*WsClient) Update

func (a *WsClient) Update() (newstate *x.Gobyte, err error)

Update implements x.RpnAcc.

func (*WsClient) Who

func (a *WsClient) Who() *x.Gostr

Who implements x.RpnAcc.

type WsEntitlement

type WsEntitlement struct {
	Kind         string `json:"kind"`          // e.g. "ws#v1"
	Cid          string `json:"cid"`           // Client ID
	Sid          string `json:"pid,omitempty"` // Share ID
	SessionToken string `json:"sessiontoken"`  // Encrypted session token
	// Expiry date of the entitlement; go.dev/play/p/d2gshytEF61
	Expiry time.Time `json:"expiry"`
	Status string    `json:"status"` // "valid" | "invalid" | "banned" | "expired" | "unknown"
	Test   bool      `json:"test"`   // true if this is a test entitlement
}

{ "kind": "ws#v1", "cid": "hex", // Identifier "sid": "id:epochsec:parentcidsig", // profile identifier, if any "sessiontoken": enc("id:typ:epochsec:sig1:sig2"), "expiry": "2025-07-15T00:00:00Z", // Expiry date of the entitlement "status": "valid" // "valid" | "invalid" | "banned" | "expired" | "unknown" "test": false // true if this is a test entitlement }

type WsErrorResponse

type WsErrorResponse struct {
	Code      int            `json:"errorCode"`
	Msg       string         `json:"errorMessage"`
	Desc      string         `json:"errorDescription"`
	LogStatus string         `json:"logStatus"`
	Failures  map[string]any `json:"validationFailuresArray"`
}
{
    "errorCode": 502,
    "errorMessage": "1 arguments had validation errors",
    "errorDescription": "Argument did not validate",
    "logStatus": null,
    "validationFailuresArray": {
        "0": {
            "wg_pubkey": {
                "lengthMin": {
                    "validationValue": "44"
                }
            }
        },
        "validationErrorMessageArray": [
            "wg pubkey is too short. Minimum value is 44 characters"
        ]
    }
}

type WsInfo

type WsInfo struct {
	Revision      int    `json:"revision"`
	RevisionHash  string `json:"revision_hash"`
	Changed       int    `json:"changed"`
	FeatureConfig int    `json:"fc"`
}
{
        "revision": 2672,
        "revision_hash": "6ad01549d6643292d8021f19a14b82310ff44c90",
        "changed": 1,
        "fc": 1
}

type WsMetadata

type WsMetadata struct {
	ServiceRequestId string `json:"serviceRequestId"`
	HostName         string `json:"hostName"`
	Duration         string `json:"duration"`
	LogStatus        string `json:"logStatus"`
	MD5              string `json:"md5"`
}
	{
        "serviceRequestId": "1752328061104032696",
        "hostName": "staging",
        "duration": "0.00278ms",
        "logStatus": null,
        "md5": "f90552b29b73b6899f7f00dc0c9fe5f4"
    }

type WsPortMap

type WsPortMap struct {
	Protocol    string   `json:"protocol"`
	Heading     string   `json:"heading"`
	Use         string   `json:"use"`
	Ports       []string `json:"ports"`
	LegacyPorts []string `json:"legacy_ports,omitempty"`
}
{
        "portmap": [
            {
                "protocol": "wg",
                "heading": "WireGuard",
                "use": "ip3",
                "ports": [
                    "443",
                    "80",
                    "53",
                    "123",
                    "1194",
                    "65142"
                ]
            },
            {
                "protocol": "ikev2",
                "heading": "IKEv2",
                "use": "hostname",
                "ports": [
                    "500"
                ],
                "legacy_ports": [
                    "500"
                ]
            },
            {
                "protocol": "udp",
                "heading": "UDP",
                "use": "ip2",
                "ports": [
                    "443",
                    "80",
                ],
                "legacy_ports": [
                    "443"
                ]
            },
            {
                "protocol": "tcp",
                "heading": "TCP",
                "use": "ip2",
                "ports": [
                    "443",
                    "587",
                    "21",
                    "1194"
                ],
                "legacy_ports": [
                    "1194"
                ]
            },
            {
                "protocol": "stunnel",
                "heading": "Stealth",
                "use": "ip3",
                "ports": [
                    "443",
                    "587",
                    "21",
                    "22",
                    "80",
                    "123",
                    "8443"
                ],
                "legacy_ports": [
                    "8443"
                ]
            },
            {
                "protocol": "wstunnel",
                "heading": "WStunnel",
                "use": "hostname",
                "ports": [
                    "443"
                ],
                "legacy_ports": [
                    "443"
                ]
            }
        ]
}

type WsPortMapResponse

type WsPortMapResponse struct {
	Data struct {
		PortMap []WsPortMap `json:"portmap"`
	} `json:"data"`
	Metadata WsMetadata `json:"metadata"`
}
{
    "data": {
        "portmap": [
		{...}, {...}
		],
	}
	"metadata": { ... }

type WsProxyCreds

type WsProxyCreds struct {
	Username string `json:"username"`
	Password string `json:"password"`
}
{
        "username": "string",
        "password": "string"
}

type WsProxyCredsResponse

type WsProxyCredsResponse struct {
	Data     WsProxyCreds `json:"data"`
	Metadata WsMetadata   `json:"metadata"`
}
{
    "data": WsProxyCreds,
	metadata: { ... }
}

type WsServerGroup

type WsServerGroup struct {
	ID   int    `json:"id"`
	City string `json:"city"`
	Nick string `json:"nick"`
	Pro  int    `json:"pro"`
	GPS  string `json:"gps"`
	TZ   string `json:"tz"`
	// public key for all servers in this datacenter / building
	WgPubKey string `json:"wg_pubkey"`
	// WireGuard hostname to connect to, which will connect to a
	// random WireGuard server in this datacenter: Its A/AAAA records
	// contains all "ip3" (WireGuard-only) IPs for individual Nodes
	// (all hosts in this datacenter).
	WgEndpoint string `json:"wg_endpoint"`
	OvpnX509   string `json:"ovpn_x509"`
	PingIP     string `json:"ping_ip"`
	// GET <ping-host>
	// {"rtt": "5775"}  = 5.7ms
	PingHost string `json:"ping_host"`
	// 100, 1000, 10000 (in mbps) etc;
	LinkSpeed string `json:"link_speed"`
	// Nodes are online servers that can be connected to in a datacneter.
	// If empty, the datacenter is offline.
	Nodes []WsServerNode `json:"nodes"`
	// Health is a measure of load, between 0 and 100. Lower is better.
	Health int `json:"health"`
}
				{
                    "id": 87,
                    "city": "Boston",
                    "nick": "The Wahlberg",
                    "pro": 1,
                    "gps": "42.36,-71.06",
                    "tz": "EST",
                    "wg_pubkey": "M/kVfITvFaz8i8msJi7C3jsgk45vnbnYLJIOl/zBsVk=",
                    "wg_endpoint": "bos-87-wg.whiskergalaxy.dev",
                    "ovpn_x509": "bos-87.windscribe.dev",
                    "ping_ip": "181.215.52.122",
                    "ping_host": "http://us-014.whiskergalaxy.dev:6464/latency",
                    "link_speed": "1000",
                    "nodes": [
                        { ... }
                    ],
                    "health": 0
                }

type WsServerList

type WsServerList struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	CountryCode string `json:"country_code"`
	// Status is for country level location record,
	// flips to a value thats not 1 only if all servers
	// in the whole country are unavailable.
	Status      int    `json:"status"`
	PremiumOnly int    `json:"premium_only"`
	ShortName   string `json:"short_name"`
	// p2p is 0 as a signal that common torrent trackers are null routed
	// on these machines and torrenting is discouraged. Nothing prevents
	// users from still doing so, especially on private trackers.
	// This flag has no impact on port forwarding.
	P2P         int             `json:"p2p"`
	TZ          string          `json:"tz"`
	TZOffset    string          `json:"tz_offset"`
	LocType     string          `json:"loc_type"`
	DNSHostname string          `json:"dns_hostname,omitempty"`
	Groups      []WsServerGroup `json:"groups"`
}
{
            "id": 90,
            "name": "Guatemala",
            "country_code": "gt",
            "status": 1,
            "premium_only": 1,
            "short_name": "GT",
            "p2p": 1,
            "tz": "America/Toronto",
            "tz_offset": "-4,EST",
            "loc_type": "normal",
            "dns_hostname": "gt.windscribe.dev",
            "groups": [
                {
                    "id": 110,
                    "city": "San Marcos",
                    "nick": "Trafficker",
                    "pro": 1,
                    "gps": "14.97,-91.80",
                    "tz": "America/Guatemala",
                    "wg_pubkey": "NXPIQ0kD2ww9VkgFqMWvJs7ZLthd5PS259/yJPyDyz0=",
                    "wg_endpoint": "gua-110-wg.whiskergalaxy.dev",
                    "ovpn_x509": "gua-110.windscribe.dev",
                    "ping_ip": "66.66.66.70",
                    "ping_host": "http://gt-stg-001.whiskergalaxy.dev:6464/latency",
                    "link_speed": "100",
                    "nodes": [
                        {
                            "ip": "66.66.66.70",
                            "ip2": "66.66.66.71",
                            "ip3": "66.66.66.72",
                            "hostname": "gt-stg-001.whiskergalaxy.dev",
                            "weight": 1,
                            "health": 0
                        }
                    ],
                    "health": 0
                }
            ]
        },
        {
            "id": 38,
            "name": "Canada East",
            "country_code": "CA",
            "status": 1,
            "premium_only": 0,
            "short_name": "CA",
            "p2p": 0,
            "tz": "America/Toronto",
            "tz_offset": "-4,EST",
            "loc_type": "normal",
            "dns_hostname": "ca.windscribe.dev",
            "groups": [
                { ... }
            ]
        },
        {
            "id": 52,
            "name": "United States",
            "country_code": "US",
            "status": 1,
            "premium_only": 0,
            "short_name": "US",
            "p2p": 0,
            "tz": "America/Chicago",
            "tz_offset": "-6,CET",
            "loc_type": "normal",
            "dns_hostname": "us.windscribe.dev",
            "groups": [
                { ... }
            ]
        },
        {
            "id": 84,
            "name": "The Best Korea",
            "country_code": "KP",
            "status": 2,
            "premium_only": 1,
            "short_name": "KP",
            "p2p": 1,
            "tz": "Asia/Pyongyang",
            "tz_offset": "9,PYT",
            "loc_type": "normal",
            "groups": [
                { ... }
            ]
        }

type WsServerListResponse

type WsServerListResponse struct {
	Data     []WsServerList `json:"data"`
	Info     WsInfo         `json:"info"`
	Metadata WsMetadata     `json:"metadata"`
}
{
    "data": [
		{ ... }, { ... },
    ],
    "info": { ... },
    "metadata": { ... }
}

type WsServerNode

type WsServerNode struct {
	IP  string `json:"ip"`
	IP2 string `json:"ip2,omitempty"`
	// Init direct connections to "ip3" + port to connect to
	// a specific node (host) skipping DNS.
	IP3      string `json:"ip3,omitempty"`
	Hostname string `json:"hostname"`
	Weight   int    `json:"weight"`
	Health   int    `json:"health"`
}
						{
                            "ip": "181.215.52.122",
                            "ip2": "181.215.52.123",
                            "ip3": "181.215.52.124",
                            "hostname": "us-014.whiskergalaxy.dev",
                            "weight": 1,
                            "health": 0
                        },
                        {
                            "ip": "181.215.52.2",
                            "ip2": "181.215.52.3",
                            "ip3": "181.215.52.4",
                            "hostname": "us-004.whiskergalaxy.dev",
                            "weight": 1,
                            "health": 0
                        }

type WsSession

type WsSession struct {
	UserID string `json:"user_id"`
	// Encrypted account session token authenticates this user with the API to get
	// and set any state, incl WG configuration which are unique and bound
	// to each session token. Session token is the "bearer token".
	// Unencrypted session/bearer token is of shape, id:type:timestamp:sig1:sig2.
	// However it could change to a new format in the future.
	SessionToken string `json:"session_auth_hash"`
	Username     string `json:"username"`
	// TrafficUsed shows byte count of data used since LastReset date?
	TrafficUsed int64 `json:"traffic_used"`
	TrafficMax  int64 `json:"traffic_max"`
	// Status is 1 under normal circumstances. Any other state means
	// this user is banned (or a free account has expired).
	// Bans are extremely rare, and there is no appeal process.
	// Bans are issued on repeated abuse, never right away.
	// This user is permanently disabled if banned.
	Status        int    `json:"status"`
	Email         string `json:"email"`
	EmailStatus   int    `json:"email_status"`
	BillingPlanID int    `json:"billing_plan_id"`
	IsPremium     int    `json:"is_premium"`
	Rebill        int    `json:"rebill"`
	// This will downgrade on this date, unless its renewed.
	// ex: "2025-07-22" go.dev/play/p/IoeH1Ee6cZ3
	ExpiryDate string `json:"premium_expiry_date"`
	RegDate    int64  `json:"reg_date"`
	LastReset  string `json:"last_reset"` // can be null
	LocRev     int    `json:"loc_rev"`
	// Latest revision hash of the server list.
	LocHash string `json:"loc_hash"`
}
{
        "user_id": "l7xfy9c1",
        "session_auth_hash": "id:typ:epochsec:sig1:sig2",
        "username": "celz_l7xfy9c1",
        "traffic_used": 0,
        "traffic_max": -1,
        "status": 1,
        "email": null,
        "email_status": 0,
        "billing_plan_id": 120,
        "is_premium": 1,
        "rebill": 0,
        "premium_expiry_date": "2025-07-15",
        "reg_date": 1749999508,
        "last_reset": "2025-07-12", // or null
        "loc_rev": 2672,
        "loc_hash": "6ad01549d66..."
}

type WsSessionResponse

type WsSessionResponse struct {
	Data     WsSession  `json:"data"`
	Metadata WsMetadata `json:"metadata"`
}
{
    "data": WsSession ,
    "metadata": { ... }
}

type WsWgConfig

type WsWgConfig struct {
	Entitlement *WsEntitlement    `json:"entitlement"` // entitlement info
	Session     *WsSession        `json:"session"`
	Configs     []*RegionalWgConf `json:"configs"`
	Servers     []WsServerList    `json:"servers"` // all servers in the server list
	Creds       *WsWgCreds        `json:"creds"`   // base64 encoded private key
}

func (*WsWgConfig) Json

func (a *WsWgConfig) Json() ([]byte, error)

type WsWgConnectData

type WsWgConnectData struct {
	Config  WsWgInterface     `json:"config"`
	Debug   map[string]string `json:"debug,omitempty"` // optional
	Success int               `json:"success"`
}
{
        "config": WsWgInterface,
        "debug": {
            "pub_key": "supplied: tsoZzRelDNFe/xF6eQz+xxzjmgS0xKfxEmlqsZKPNgs=",
            "interface": "generated + attached: 100.65.61.145"
        },
        "success": 1
    }

type WsWgConnectResponse

type WsWgConnectResponse struct {
	Data     WsWgConnectData `json:"data"`
	Metadata WsMetadata      `json:"metadata"`
}
{
    "data": WsWgConnectData,
    "metadata": { ... }
}

type WsWgCreds

type WsWgCreds struct {
	PrivateKey   string `json:"PrivateKey,omitempty"` // base64, always empty as remote does not generate for us
	PublicKey    string `json:"PublicKey"`            // base64, generated locally
	PresharedKey string `json:"PresharedKey"`         // base64, only the latest key is valid (generated by remote)
	AllowedIPs   string `json:"AllowedIPs"`           // for now, it is "0.0.0.0/0"
}
{
            "PrivateKey": "stdbase64",
            "PublicKey": "tsoZzRelDNFe/xF6eQz+xxzjmgS0xKfxEmlqsZKPNgs=",
            "PresharedKey": "stdbase64",
            "AllowedIPs": "0.0.0.0/0"
}

type WsWgCredsData

type WsWgCredsData struct {
	Config  WsWgCreds         `json:"config"`
	Debug   map[string]string `json:"debug,omitempty"`
	Success int               `json:"success"`
}
{
        "config": WsWgCfg,
        "debug": {
            "init": "generated: tsoZzRelDNFe/xF6eQz+xxzjmgS0xKfxEmlqsZKPNgs="
        },
        "success": 1
}

type WsWgCredsResponse

type WsWgCredsResponse struct {
	Data     WsWgCredsData `json:"data"`
	Metadata WsMetadata    `json:"metadata"`
}
{
    "data": WsWgCredsData,
    "metadata": { ... }
}

type WsWgInterface

type WsWgInterface struct {
	Address string `json:"Address"` // cidr notation
	DNS     string `json:"DNS"`     // ip address
}
{
            "Address": "100.65.61.145/32",
            "DNS": "10.255.255.2"
}

Jump to

Keyboard shortcuts

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