Documentation
¶
Overview ¶
Package config holds all Properties of dfget.
Index ¶
Constants ¶
View Source
const ( // HTTPSuccess represents the http request is success. HTTPSuccess = 200 ResultFail = 500 ResultSuc = 501 ResultInvalid = 502 // ResultSemiSuc represents the result is partial successful. ResultSemiSuc = 503 )
the response code from supernode
View Source
const ( TaskStatusStart = 700 TaskStatusRunning = 701 TaskStatusFinish = 702 )
report status of task to supernode
View Source
const ( TaskCodeFinish = 600 TaskCodeContinue = 601 TaskCodeWait = 602 TaskCodeLimited = 603 TaskCodeNeedAuth = 608 TaskCodeWaitAuth = 609 )
the task code get from supernode
View Source
const ( BackSourceReasonNone = 0 BackSourceReasonRegisterFail = 1 BackSourceReasonMd5NotMatch = 2 BackSourceReasonDownloadError = 3 BackSourceReasonNoSpace = 4 BackSourceReasonInitError = 5 BackSourceReasonWriteError = 6 BackSourceReasonHostSysError = 7 ForceNotBackSourceAddition = 1000 )
the reason of backing to source
View Source
const ( DefaultYamlConfigFile = "/etc/dragonfly.yaml" DefaultIniConfigFile = "/etc/dragonfly.conf" DefaultNode = "127.0.0.1" DefaultLocalLimit = 20 * 1024 * 1024 DefaultClientQueueSize = 6 )
properties
View Source
const ( DefaultTimestampFormat = "2006-01-02 15:04:05" SchemaHTTP = "http" ServerPortLowerLimit = 15000 ServerPortUpperLimit = 65000 RangeNotExistDesc = "range not satisfiable" AddrUsedDesc = "address already in use" PeerHTTPPathPrefix = "/peer/file/" CDNPathPrefix = "/qtdown/" LocalHTTPPathCheck = "/check/" LocalHTTPPathClient = "/client/" LocalHTTPPathRate = "/rate/" )
others
Variables ¶
View Source
var ( // Props is loaded from config file. Props *Properties // Ctx holds all the runtime Context information. Ctx *Context )
Functions ¶
func AssertContext ¶
func AssertContext(ctx *Context)
AssertContext checks the ctx and panic if any error happens.
Types ¶
type Context ¶
type Context struct {
URL string `json:"url"`
Output string `json:"output"`
LocalLimit int `json:"localLimit,omitempty"`
TotalLimit int `json:"totalLimit,omitempty"`
Timeout int `json:"timeout,omitempty"`
Md5 string `json:"md5,omitempty"`
Identifier string `json:"identifier,omitempty"`
CallSystem string `json:"callSystem,omitempty"`
Pattern string `json:"pattern,omitempty"`
Filter []string `json:"filter,omitempty"`
Header []string `json:"header,omitempty"`
Node []string `json:"node,omitempty"`
Notbs bool `json:"notbs,omitempty"`
DFDaemon bool `json:"dfdaemon,omitempty"`
Version bool `json:"version,omitempty"`
ShowBar bool `json:"showBar,omitempty"`
Console bool `json:"console,omitempty"`
Verbose bool `json:"verbose,omitempty"`
Help bool `json:"help,omitempty"`
ClientQueueSize int `json:"clientQueueSize,omitempty"`
StartTime time.Time `json:"startTime"`
Sign string `json:"sign"`
User string `json:"user"`
WorkHome string `json:"workHome"`
ConfigFiles []string `json:"configFile"`
ClientLogger *logrus.Logger `json:"-"`
ServerLogger *logrus.Logger `json:"-"`
}
Context holds all the runtime context information.
type Properties ¶
type Properties struct {
Nodes []string `yaml:"nodes"`
LocalLimit int `yaml:"localLimit"`
TotalLimit int `yaml:"totalLimit"`
ClientQueueSize int `yaml:"clientQueueSize"`
}
Properties holds all configurable Properties. Support INI(or conf) and YAML(since 0.2.0). Before 0.2.0, only support INI config and only have one property(node):
[node] address=127.0.0.1,10.10.10.1
Since 0.2.0, the INI config is just to be compatible with previous versions. The YAML config will have more properties:
nodes:
- 127.0.0.1
- 10.10.10.1
localLimit: 20971520
totalLimit: 20971520
clientQueueSize: 6
func NewProperties ¶
func NewProperties() *Properties
NewProperties create a new properties with default values.
func (*Properties) Load ¶
func (p *Properties) Load(path string) error
Load loads properties from config file.
func (*Properties) String ¶
func (p *Properties) String() string
Click to show internal directories.
Click to hide internal directories.