diff --git a/FAQ.md b/FAQ.md index 137c46e03..a1c02650c 100644 --- a/FAQ.md +++ b/FAQ.md @@ -41,7 +41,7 @@ After finishing distributing file from other peers, `dfget` should do two kinds - second, backup the unioned file(s) in a configured directory, by default "$HOME/.small-dragonfly/data" with a suffix of ".server"; - third, move the original unioned file(s) to the destination path. -**NOTE**: The supernode cannot manage the cached file which is already distributed to peer nodes at all. For what will happen if the cached file on a peer is deleted, please refer to [What if you kill the dfget server process or delete the source files](#what-if-you-kill-the-dfget-server-process-or-delete-the-source-files) +**NOTE**: The supernode cannot manage the cached file which is already distributed to peer nodes at all. For what will happen if the cached file on a peer is deleted, please refer to [What if you kill the dfget server process or delete the source files](#what-will-happen-if-you-kill-the-dfget-server-process-or-delete-the-source-files) ## What is the sequence of supernode's CDN functionality @@ -61,7 +61,7 @@ If the requested file has already been cached in supernode, supernode will send In addition, supernode does not have to wait for all the piece downloading finished, so it can concurrently start pieces downloading once one piece has been downloaded. -## What will happen if you kill the dfget server process or delete the source files +## What will happen if you kill the dfget server process or delete the source files If a file on a peer is deleted manually or by GC, the supernode won't know that. And in the subsequent scheduling, if multiple download tasks fail from this peer, the scheduler will add it to a blacklist. So do with that if the server process is killed or other abnormal conditions. @@ -323,4 +323,4 @@ Please check the [CONTRIBUTING.md](CONTRIBUTING.md#join-dragonfly-as-a-member) If supernodes are set in multiple-supernode mode, dfget will connect to one of these supernodes randomly. Because dfget will randomize the order of all supernodes it knows and store them in a slice. If dfget connects to the first supernode unsuccessfully, it will connect to the second supernode in the slice. -And so on until all the known supernodes fail to access twice, the dfget will exit with download failure. \ No newline at end of file +And so on until all the known supernodes fail to access twice, the dfget will exit with download failure. diff --git a/pkg/netutils/netutils.go b/pkg/netutils/netutils.go index 098935225..fc14085cb 100644 --- a/pkg/netutils/netutils.go +++ b/pkg/netutils/netutils.go @@ -124,6 +124,10 @@ func NetLimit() *rate.Rate { // ExtractHost extracts host ip from the giving string. func ExtractHost(hostAndPort string) string { + if stringutils.IsEmptyStr(hostAndPort) { + return "" + } + fields := strings.Split(strings.TrimSpace(hostAndPort), ":") return fields[0] }