protocol

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: GPL-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Copyright (C) 2026 by saba <contact me via issue>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

In addition, no derivative work may use the name or imply association with this application without prior consent.

Index

Constants

View Source
const (
	AddrTypeIPv4   = 0x01
	AddrTypeDomain = 0x03
	AddrTypeIPv6   = 0x04
)

Address type bytes of the SOCKS5-style encoding: type | address | port (big-endian u16). A domain address carries a one-byte length (1..255) before the name.

View Source
const MaxEncodedAddrLen = 1 + 1 + 255 + 2

MaxEncodedAddrLen is the longest encoding: type, length, a 255-byte domain and the port.

Variables

This section is empty.

Functions

func AppendAddrPort added in v0.5.2

func AppendAddrPort(dst []byte, ap netip.AddrPort) []byte

AppendAddrPort appends the encoding of an IP destination to dst. IPv4-mapped IPv6 addresses are encoded as IPv4 and zones are dropped.

func AppendAddress added in v0.5.2

func AppendAddress(dst []byte, rawAddr string) ([]byte, error)

AppendAddress appends the encoding of rawAddr ("host:port") to dst; dst is returned unchanged on error. IPv4-mapped IPv6 literals are encoded as IPv4 and IPv6 zones are dropped.

func DecodeAddress added in v0.5.2

func DecodeAddress(b []byte) (string, error)

DecodeAddress parses the address at the start of b and returns it as "host:port". IPv4-mapped IPv6 addresses are returned in dotted IPv4 form; bytes after the address are ignored.

func ReadAddress

func ReadAddress(r io.Reader) (string, byte, net.IP, error)

ReadAddress reads one encoded address from r without consuming bytes beyond it. It returns the "host:port" string, the address type, and the IP for IPv4/IPv6 addresses (nil for domains).

func WriteAddress

func WriteAddress(w io.Writer, rawAddr string) error

WriteAddress writes the encoding of rawAddr ("host:port") to w with a single Write.

Types

This section is empty.

Jump to

Keyboard shortcuts

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