softether

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxEthernetFrame = 1600
	MaxKeepAlive     = 512
)
View Source
const (
	ConnectPath = "/vpnsvc/connect.cgi"
	PackPath    = "/vpnsvc/vpn.cgi"
	ContentType = "application/octet-stream"
	MaxPackSize = 65536
	MaxFrames   = 4096
)
View Source
const (
	TypeInt    = 0
	TypeData   = 1
	TypeString = 2
	TypeUTF8   = 3
	TypeInt64  = 4
)
View Source
const (
	AuthAnonymous     uint32 = 0
	AuthPassword      uint32 = 1
	AuthPlainPassword uint32 = 2
	AuthCertificate   uint32 = 3

	ProtocolTCP uint32 = 0
)

Variables

This section is empty.

Functions

func ARPReply

func ARPReply(frame []byte, localMAC [6]byte, localIP netip.Addr) ([]byte, bool)

func ARPRequest

func ARPRequest(localMAC [6]byte, localIP, targetIP netip.Addr) []byte

func AddPolicy

func AddPolicy(pack *Pack, policy Policy)

func DHCPServerReply

func DHCPServerReply(frame []byte, serverMAC [6]byte, serverIP, assigned netip.Addr, prefixBits int, dns []netip.Addr) ([]byte, netip.Addr, [6]byte, bool)

func FrameSource

func FrameSource(frame []byte) (netip.Addr, [6]byte, bool)

func IPDestination

func IPDestination(packet []byte) (netip.Addr, bool)

func PasswordResponse

func PasswordResponse(username, password string, challenge []byte) [20]byte

func ReadSignatureRequest

func ReadSignatureRequest(r *bufio.Reader) error

func ResolveARP

func ResolveARP(stream *FrameStream, localMAC [6]byte, localIP, targetIP netip.Addr) ([6]byte, error)

func SHA0

func SHA0(message []byte) [20]byte

SHA0 implements the original FIPS PUB 180 digest used by SoftEther's password challenge. It differs from SHA-1 only in the message schedule.

func UnwrapIP

func UnwrapIP(frame []byte) ([]byte, bool)

func WrapIPv4

func WrapIPv4(payload []byte, source, destination [6]byte) []byte

func WritePackRequest

func WritePackRequest(w io.Writer, host string, pack *Pack) error

func WritePackResponse

func WritePackResponse(w io.Writer, pack *Pack) error

func WriteSignatureRequest

func WriteSignatureRequest(w io.Writer, host string) error

Types

type DHCPLease

type DHCPLease struct {
	Address   netip.Prefix
	Gateway   netip.Addr
	DNS       []netip.Addr
	ServerMAC [6]byte
}

func AcquireDHCP

func AcquireDHCP(stream *FrameStream, mac [6]byte) (DHCPLease, error)

type FrameStream

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

func NewFrameStream

func NewFrameStream(r io.Reader, w io.Writer, compress ...bool) *FrameStream

func (*FrameStream) ReadFrames

func (s *FrameStream) ReadFrames() ([][]byte, error)

func (*FrameStream) WriteFrames

func (s *FrameStream) WriteFrames(frames ...[]byte) error

func (*FrameStream) WriteKeepAlive

func (s *FrameStream) WriteKeepAlive() error

type Pack

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

func NewPack

func NewPack() *Pack

func ReadPackRequest

func ReadPackRequest(r *bufio.Reader) (*Pack, error)

func ReadPackResponse

func ReadPackResponse(r *bufio.Reader) (*Pack, error)

func UnmarshalPack

func UnmarshalPack(data []byte) (*Pack, error)

func (*Pack) AddBool

func (p *Pack) AddBool(name string, value bool)

func (*Pack) AddData

func (p *Pack) AddData(name string, value []byte)

func (*Pack) AddInt

func (p *Pack) AddInt(name string, value uint32)

func (*Pack) AddInt64

func (p *Pack) AddInt64(name string, value uint64)

func (*Pack) AddString

func (p *Pack) AddString(name, value string)

func (*Pack) AddValues

func (p *Pack) AddValues(name string, values ...Value)

func (*Pack) GetData

func (p *Pack) GetData(name string) []byte

func (*Pack) GetInt

func (p *Pack) GetInt(name string) uint32

func (*Pack) GetInt64

func (p *Pack) GetInt64(name string) uint64

func (*Pack) GetString

func (p *Pack) GetString(name string) string

func (*Pack) Has

func (p *Pack) Has(name string) bool

func (*Pack) MarshalBinary

func (p *Pack) MarshalBinary() ([]byte, error)

func (*Pack) Values

func (p *Pack) Values(name string) []Value

type Policy

type Policy struct {
	Access                          bool
	DHCPFilter                      bool
	DHCPNoServer                    bool
	DHCPForce                       bool
	NoBridge                        bool
	NoRouting                       bool
	PrivacyFilter                   bool
	NoServer                        bool
	CheckMAC                        bool
	CheckIP                         bool
	ARPDHCPOnly                     bool
	MonitorPort                     bool
	NoBroadcastLimiter              bool
	FixPassword                     bool
	NoQoS                           bool
	RSAndRAFilter                   bool
	RAFilter                        bool
	DHCPv6Filter                    bool
	DHCPv6NoServer                  bool
	NoRoutingV6                     bool
	CheckIPv6                       bool
	NoServerV6                      bool
	NoSavePassword                  bool
	FilterIPv4                      bool
	FilterIPv6                      bool
	FilterNonIP                     bool
	NoIPv6DefaultRouterInRA         bool
	NoIPv6DefaultRouterInRAWhenIPv6 bool
	MaxConnection                   uint32
	Timeout                         uint32
	MaxMAC                          uint32
	MaxIP                           uint32
	MaxUpload                       uint32
	MaxDownload                     uint32
	MultiLogins                     uint32
	MaxIPv6                         uint32
	AutoDisconnect                  uint32
	VLANID                          uint32
}

func PolicyFromPack

func PolicyFromPack(pack *Pack) Policy

type SessionParameters

type SessionParameters struct {
	SessionName    string
	ConnectionName string
	MaxConnection  uint32
	UseEncrypt     bool
	UseCompress    bool
	HalfConnection bool
	Timeout        uint32
	QoS            bool
	SessionKey     [20]byte
	SessionKey32   uint32
	VLANID         uint32
	Policy         Policy
}

func ParseSessionParameters

func ParseSessionParameters(pack *Pack) (SessionParameters, error)

type Value

type Value struct {
	Type  byte
	Int   uint32
	Int64 uint64
	Bytes []byte
}

Jump to

Keyboard shortcuts

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