anchor

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: GPL-2.0 Imports: 6 Imported by: 2

README

Anchor

Go Reference

A protocol that allow switching proxy info in Lan.

Forked from SagerNet/SagerConnect

Warn

I know nothing about L4 proxies and transparent proxies, and this is my first time to something about them. So this software is for educational and research purposes only. Please do not use it for illegal activities or in production environments.

Developing

Build

CGO_ENABLED=0 make

Format

make fmt

Protocol

  • All use Big Endian.

  • Target port is 45947, which generated randomly.

Query:
Version Device Name Length Device Name
1 1 0 to 128
  • Version: always constant 0x02
Response:
Version Dns Port Device Name Length Device Name Socks Port
1 2 1 0 to 128 2
  • Version: always constant 0x02
  • Dns Port: can be zero, which means server not providing dns port.

Credits

Inspired by: SagerNet/SagerConnect

Documentation

Overview

Package anchor provides an API that allow switching the proxy info.

Index

Constants

View Source
const (
	Version = 0x02
	Port    = 45947

	MaxDeviceName   = 128
	MinQuerySize    = 1 + 1 + 0                     // 2
	MaxQuerySize    = 1 + 1 + 128                   // 130
	MinResponseSize = 1 + 2 + 1 + 0 + 2             // 6
	MaxResponseSize = 1 + 2 + 1 + MaxDeviceName + 2 // 134
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Query

type Query struct {
	Version    uint8
	DeviceName string
}

func ParseQuery

func ParseQuery(reader io.Reader) (*Query, error)

func (Query) Length

func (q Query) Length() (length int)

func (Query) MarshalBinary

func (q Query) MarshalBinary() ([]byte, error)

type Response

type Response struct {
	Version    uint8
	DnsPort    uint16
	DeviceName string
	SocksPort  uint16
}

func ParseResponse

func ParseResponse(reader io.Reader) (*Response, error)

func (Response) Length

func (r Response) Length() (length int)

func (Response) MarshalBinary

func (r Response) MarshalBinary() ([]byte, error)

Directories

Path Synopsis
Package anchorservice implements a service that provides anchor protocol.
Package anchorservice implements a service that provides anchor protocol.
cmd
Package dialers provides implementations for N.Dialer.
Package dialers provides implementations for N.Dialer.
Package log implements custom log for logger.ContextLogger.
Package log implements custom log for logger.ContextLogger.
Package tun2dialer provides Tun2Dialer to handle Tun.
Package tun2dialer provides Tun2Dialer to handle Tun.

Jump to

Keyboard shortcuts

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