Files
Go_I2p/lib/tunnel/README.md
2025-02-26 20:58:20 -05:00

5.8 KiB

tunnel

-- import "github.com/go-i2p/go-i2p/lib/tunnel"

tunnel.svg

i2p garlic tunnel implementation

Usage

const (
	DT_LOCAL = iota
	DT_TUNNEL
	DT_ROUTER
	DT_UNUSED
)
const (
	FIRST_FRAGMENT = iota
	FOLLOW_ON_FRAGMENT
)
const (
	FLAG_SIZE                 = 1
	TUNNEL_ID_SIZE            = 4
	HASH_SIZE                 = 32
	DELAY_SIZE                = 1
	MESSAGE_ID_SIZE           = 4
	EXTENDED_OPTIONS_MIN_SIZE = 2
	SIZE_FIELD_SIZE           = 2
)

type DecryptedTunnelMessage

type DecryptedTunnelMessage [1028]byte

func (DecryptedTunnelMessage) Checksum

func (decrypted_tunnel_message DecryptedTunnelMessage) Checksum() crypto.TunnelIV

func (DecryptedTunnelMessage) DeliveryInstructionsWithFragments

func (decrypted_tunnel_message DecryptedTunnelMessage) DeliveryInstructionsWithFragments() []DeliveryInstructionsWithFragment

Returns a slice of DeliveryInstructionWithFragment structures, which all of the Delivery Instructions in the tunnel message and their corresponding MessageFragment structures.

func (DecryptedTunnelMessage) ID

func (decrypted_tunnel_message DecryptedTunnelMessage) ID() TunnelID

func (DecryptedTunnelMessage) IV

func (decrypted_tunnel_message DecryptedTunnelMessage) IV() crypto.TunnelIV

type DelayFactor

type DelayFactor byte

type DeliveryInstructions

type DeliveryInstructions []byte

func (DeliveryInstructions) Delay

func (delivery_instructions DeliveryInstructions) Delay() (delay_factor DelayFactor, err error)

Return the DelayFactor if present and any errors encountered parsing the DeliveryInstructions.

func (DeliveryInstructions) DeliveryType

func (delivery_instructions DeliveryInstructions) DeliveryType() (byte, error)

Return the delivery type for these DeliveryInstructions, can be of type DT_LOCAL, DT_TUNNEL, DT_ROUTER, or DT_UNUSED.

func (DeliveryInstructions) ExtendedOptions

func (delivery_instructions DeliveryInstructions) ExtendedOptions() (data []byte, err error)

Return the Extended Options data if present, or an error if not present. Extended Options in unimplemented in the Java router and the presence of extended options will generate a warning.

func (DeliveryInstructions) FragmentNumber

func (delivery_instructions DeliveryInstructions) FragmentNumber() (int, error)

Read the integer stored in the 6-1 bits of a FOLLOW_ON_FRAGMENT's flag, indicating the fragment number.

func (DeliveryInstructions) FragmentSize

func (delivery_instructions DeliveryInstructions) FragmentSize() (frag_size uint16, err error)

Return the size of the associated I2NP fragment and an error if the data is unavailable.

func (DeliveryInstructions) Fragmented

func (delivery_instructions DeliveryInstructions) Fragmented() (bool, error)

Returns true if the Delivery Instructions are fragmented or false if the following data contains the entire message

func (DeliveryInstructions) HasDelay

func (delivery_instructions DeliveryInstructions) HasDelay() (bool, error)

Check if the delay bit is set. This feature in unimplemented in the Java router.

func (DeliveryInstructions) HasExtendedOptions

func (delivery_instructions DeliveryInstructions) HasExtendedOptions() (bool, error)

Check if the extended options bit is set. This feature in unimplemented in the Java router.

func (DeliveryInstructions) HasHash

func (delivery_instructions DeliveryInstructions) HasHash() (bool, error)

func (DeliveryInstructions) HasTunnelID

func (delivery_instructions DeliveryInstructions) HasTunnelID() (bool, error)

Check if the DeliveryInstructions is of type DT_TUNNEL.

func (DeliveryInstructions) Hash

func (delivery_instructions DeliveryInstructions) Hash() (hash common.Hash, err error)

Return the hash for these DeliveryInstructions, which varies by hash type.

If the type is DT_TUNNEL, hash is the SHA256 of the gateway router, if
the type is DT_ROUTER it is the SHA256 of the router.

func (DeliveryInstructions) LastFollowOnFragment

func (delivery_instructions DeliveryInstructions) LastFollowOnFragment() (bool, error)

Read the value of the 0 bit of a FOLLOW_ON_FRAGMENT, which is set to 1 to indicate the last fragment.

func (DeliveryInstructions) MessageID

func (delivery_instructions DeliveryInstructions) MessageID() (msgid uint32, err error)

Return the I2NP Message ID or 0 and an error if the data is not available for this DeliveryInstructions.

func (DeliveryInstructions) TunnelID

func (delivery_instructions DeliveryInstructions) TunnelID() (tunnel_id uint32, err error)

Return the tunnel ID in this DeliveryInstructions or 0 and an error if the DeliveryInstructions are not of type DT_TUNNEL.

func (DeliveryInstructions) Type

func (delivery_instructions DeliveryInstructions) Type() (int, error)

Return if the DeliveryInstructions are of type FIRST_FRAGMENT or FOLLOW_ON_FRAGMENT.

type DeliveryInstructionsWithFragment

type DeliveryInstructionsWithFragment struct {
	DeliveryInstructions DeliveryInstructions
	MessageFragment      []byte
}

type EncryptedTunnelMessage

type EncryptedTunnelMessage crypto.TunnelData

func (EncryptedTunnelMessage) Data

func (tm EncryptedTunnelMessage) Data() crypto.TunnelIV

func (EncryptedTunnelMessage) ID

func (tm EncryptedTunnelMessage) ID() (tid TunnelID)

func (EncryptedTunnelMessage) IV

func (tm EncryptedTunnelMessage) IV() crypto.TunnelIV

type Participant

type Participant struct {
}

type Pool

type Pool struct{}

a pool of tunnels which we have created

type TunnelID

type TunnelID uint32

tunnel

github.com/go-i2p/go-i2p/lib/tunnel