filetransfer

package
v0.0.131 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var (
	Ft_LoadBalanceMode_name = map[int32]string{
		0: "load_balance_mode_first",
		1: "load_balance_mode_random",
	}
	Ft_LoadBalanceMode_value = map[string]int32{
		"load_balance_mode_first":  0,
		"load_balance_mode_random": 1,
	}
)

Enum value maps for Ft_LoadBalanceMode.

View Source
var File_pkg_file_transfer_ft_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type CompletedConfig

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

func (CompletedConfig) New

func (c CompletedConfig) New(ctx context.Context) (*FileTransfer, error)

type Config

type Config struct {
	Proto Ft
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(options ...ConfigOption) *Config

func (*Config) ApplyOptions

func (o *Config) ApplyOptions(options ...ConfigOption) *Config

func (*Config) Complete

func (c *Config) Complete() CompletedConfig

Complete set default ServerRunOptions.

type ConfigOption

type ConfigOption interface {
	// contains filtered or unexported methods
}

A ConfigOption sets options.

func WithViper

func WithViper(v *viper.Viper) ConfigOption

type ConfigOptionFunc

type ConfigOptionFunc func(*Config)

ConfigOptionFunc wraps a function that modifies Client into an implementation of the ConfigOption interface.

type EmptyConfigOption

type EmptyConfigOption struct{}

EmptyConfigOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type EmptyFileTransferOption

type EmptyFileTransferOption struct{}

EmptyFileTransferUrlOption does not alter the FileTransferuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type FileTransfer

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

func NewFileTransfer

func NewFileTransfer(opts ...FileTransferOption) *FileTransfer

func (*FileTransfer) ApplyOptions

func (o *FileTransfer) ApplyOptions(options ...FileTransferOption) *FileTransfer

func (*FileTransfer) Download

func (f *FileTransfer) Download(ctx context.Context, downloadUrl string) (data []byte, err error)

short connection

func (*FileTransfer) Upload added in v0.0.103

func (f *FileTransfer) Upload(ctx context.Context, uploadUrl string, body []byte) (data []byte, err error)

short connection

type FileTransferOption

type FileTransferOption interface {
	// contains filtered or unexported methods
}

A FileTransferOption sets options.

func WithDownloadTimeout

func WithDownloadTimeout(downloadTimeout time.Duration) FileTransferOption

func WithLoadBalanceMode added in v0.0.103

func WithLoadBalanceMode(mode Ft_LoadBalanceMode) FileTransferOption

func WithProxies added in v0.0.103

func WithProxies(proxies []*Ft_Proxy) FileTransferOption

func WithRetryInterval added in v0.0.103

func WithRetryInterval(retryInterval time.Duration) FileTransferOption

func WithRetryTimes added in v0.0.103

func WithRetryTimes(retryTimes int) FileTransferOption

type FileTransferOptionFunc

type FileTransferOptionFunc func(*FileTransfer)

FileTransferOptionFunc wraps a function that modifies FileTransfer into an implementation of the FileTransferOption interface.

type FileTransferOptions

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

type Ft

type Ft struct {
	Enabled         bool               `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
	DownloadTimeout *duration.Duration `protobuf:"bytes,2,opt,name=download_timeout,json=downloadTimeout,proto3" json:"download_timeout,omitempty"`
	UploadTimeout   *duration.Duration `protobuf:"bytes,3,opt,name=upload_timeout,json=uploadTimeout,proto3" json:"upload_timeout,omitempty"`
	RetryTimes      uint32             `protobuf:"varint,4,opt,name=retry_times,json=retryTimes,proto3" json:"retry_times,omitempty"`
	RetryInterval   *duration.Duration `protobuf:"bytes,5,opt,name=retry_interval,json=retryInterval,proto3" json:"retry_interval,omitempty"`
	// 当有多个代理地址时,代理模式, use proxy mode
	LoadBalanceMode Ft_LoadBalanceMode `` /* 154-byte string literal not displayed */
	Proxies         []*Ft_Proxy        `protobuf:"bytes,11,rep,name=proxies,proto3" json:"proxies,omitempty"`
	// contains filtered or unexported fields
}

func (*Ft) Descriptor deprecated

func (*Ft) Descriptor() ([]byte, []int)

Deprecated: Use Ft.ProtoReflect.Descriptor instead.

func (*Ft) GetDownloadTimeout

func (x *Ft) GetDownloadTimeout() *duration.Duration

func (*Ft) GetEnabled

func (x *Ft) GetEnabled() bool

func (*Ft) GetLoadBalanceMode added in v0.0.103

func (x *Ft) GetLoadBalanceMode() Ft_LoadBalanceMode

func (*Ft) GetProxies

func (x *Ft) GetProxies() []*Ft_Proxy

func (*Ft) GetRetryInterval added in v0.0.103

func (x *Ft) GetRetryInterval() *duration.Duration

func (*Ft) GetRetryTimes added in v0.0.103

func (x *Ft) GetRetryTimes() uint32

func (*Ft) GetUploadTimeout

func (x *Ft) GetUploadTimeout() *duration.Duration

func (*Ft) ProtoMessage

func (*Ft) ProtoMessage()

func (*Ft) ProtoReflect

func (x *Ft) ProtoReflect() protoreflect.Message

func (*Ft) Reset

func (x *Ft) Reset()

func (*Ft) String

func (x *Ft) String() string

type Ft_LoadBalanceMode added in v0.0.103

type Ft_LoadBalanceMode int32
const (
	Ft_load_balance_mode_first  Ft_LoadBalanceMode = 0
	Ft_load_balance_mode_random Ft_LoadBalanceMode = 1
)

func (Ft_LoadBalanceMode) Descriptor added in v0.0.103

func (Ft_LoadBalanceMode) Enum added in v0.0.103

func (Ft_LoadBalanceMode) EnumDescriptor deprecated added in v0.0.103

func (Ft_LoadBalanceMode) EnumDescriptor() ([]byte, []int)

Deprecated: Use Ft_LoadBalanceMode.Descriptor instead.

func (Ft_LoadBalanceMode) Number added in v0.0.103

func (Ft_LoadBalanceMode) String added in v0.0.103

func (x Ft_LoadBalanceMode) String() string

func (Ft_LoadBalanceMode) Type added in v0.0.103

type Ft_Proxy

type Ft_Proxy struct {

	// target_addr和target_url都设置值的情况下,优先使用target_addr
	// reset dns to target_addr in url,
	TargetHost string `protobuf:"bytes,1,opt,name=target_host,json=targetHost,proto3" json:"target_host,omitempty"`
	// reset url to target url
	ProxyUrl  string `protobuf:"bytes,2,opt,name=proxy_url,json=proxyUrl,proto3" json:"proxy_url,omitempty"`
	ProxyHost string `protobuf:"bytes,3,opt,name=proxy_host,json=proxyHost,proto3" json:"proxy_host,omitempty"`
	// contains filtered or unexported fields
}

func (*Ft_Proxy) Descriptor deprecated

func (*Ft_Proxy) Descriptor() ([]byte, []int)

Deprecated: Use Ft_Proxy.ProtoReflect.Descriptor instead.

func (*Ft_Proxy) GetProxyHost added in v0.0.117

func (x *Ft_Proxy) GetProxyHost() string

func (*Ft_Proxy) GetProxyUrl added in v0.0.117

func (x *Ft_Proxy) GetProxyUrl() string

func (*Ft_Proxy) GetTargetHost added in v0.0.117

func (x *Ft_Proxy) GetTargetHost() string

func (*Ft_Proxy) ProtoMessage

func (*Ft_Proxy) ProtoMessage()

func (*Ft_Proxy) ProtoReflect

func (x *Ft_Proxy) ProtoReflect() protoreflect.Message

func (*Ft_Proxy) Reset

func (x *Ft_Proxy) Reset()

func (*Ft_Proxy) String

func (x *Ft_Proxy) String() string

Directories

Path Synopsis
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software.

Jump to

Keyboard shortcuts

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