Version: v6.2.5 Latest Latest

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

Go to latest
Published: Nov 13, 2019 License: Apache-2.0 Imports: 3 Imported by: 0



Package xfer is transfer filter set.

Copyright 2017 HenryLee. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.



This section is empty.


View Source
var ErrXferPipeTooLong = errors.New("The length of transfer pipe cannot be bigger than 255")

ErrXferPipeTooLong error


func Reg

func Reg(xferFilter XferFilter)

Reg registers transfer filter.


type XferFilter

type XferFilter interface {
	// ID returns transfer filter id.
	ID() byte
	// Name returns transfer filter name.
	Name() string
	// OnPack performs filtering on packing.
	OnPack([]byte) ([]byte, error)
	// OnUnpack performs filtering on unpacking.
	OnUnpack([]byte) ([]byte, error)

XferFilter handles byte stream of message when transfer.

func Get

func Get(id byte) (XferFilter, error)

Get returns transfer filter by id.

func GetByName

func GetByName(name string) (XferFilter, error)

GetByName returns transfer filter by name.

type XferPipe

type XferPipe struct {
	// contains filtered or unexported fields

XferPipe transfer filter pipe, handlers from outer-most to inner-most. NOTE: the length can not be bigger than 255!

func NewXferPipe

func NewXferPipe() *XferPipe

NewXferPipe creates a new transfer filter pipe.

func (*XferPipe) Append

func (x *XferPipe) Append(filterID ...byte) error

Append appends transfer filter by id.

func (*XferPipe) AppendFrom

func (x *XferPipe) AppendFrom(src *XferPipe)

AppendFrom appends transfer filters from a *XferPipe.

func (*XferPipe) IDs

func (x *XferPipe) IDs() []byte

IDs returns the id list of transfer filters.

func (*XferPipe) Len

func (x *XferPipe) Len() int

Len returns the length of transfer pipe.

func (*XferPipe) Names

func (x *XferPipe) Names() []string

Names returns the name list of transfer filters.

func (*XferPipe) OnPack

func (x *XferPipe) OnPack(data []byte) ([]byte, error)

OnPack packs transfer byte stream, from inner-most to outer-most.

func (*XferPipe) OnUnpack

func (x *XferPipe) OnUnpack(data []byte) ([]byte, error)

OnUnpack unpacks transfer byte stream, from outer-most to inner-most.

func (*XferPipe) Range

func (x *XferPipe) Range(callback func(idx int, filter XferFilter) bool)

Range calls f sequentially for each XferFilter present in the XferPipe. If f returns false, range stops the iteration.

func (*XferPipe) Reset

func (x *XferPipe) Reset()

Reset resets transfer filter pipe.

Source Files


Path Synopsis
Package md5 provides a integrity check transfer filter
Package md5 provides a integrity check transfer filter

Jump to

Keyboard shortcuts

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