|
7 | 7 | "fmt"
|
8 | 8 | "io"
|
9 | 9 | "math/rand"
|
10 |
| - "net" |
11 |
| - "net/url" |
12 | 10 | "os"
|
13 | 11 | "os/signal"
|
14 | 12 | "path/filepath"
|
@@ -49,18 +47,6 @@ const (
|
49 | 47 | heapProfile = "ipfs.memprof"
|
50 | 48 | )
|
51 | 49 |
|
52 |
| -type cmdInvocation struct { |
53 |
| - req *cmds.Request |
54 |
| - node *core.IpfsNode |
55 |
| - ctx *oldcmds.Context |
56 |
| -} |
57 |
| - |
58 |
| -type exitErr int |
59 |
| - |
60 |
| -func (e exitErr) Error() string { |
61 |
| - return fmt.Sprint("exit code", int(e)) |
62 |
| -} |
63 |
| - |
64 | 50 | // main roadmap:
|
65 | 51 | // - parse the commandline to get a cmdInvocation
|
66 | 52 | // - if user requests help, print it and exit.
|
@@ -171,7 +157,7 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
|
171 | 157 | return nil, err
|
172 | 158 | }
|
173 | 159 |
|
174 |
| - client, err := commandShouldRunOnDaemon(*details, req, Root, env.(*oldcmds.Context)) |
| 160 | + client, err := commandShouldRunOnDaemon(*details, req, env.(*oldcmds.Context)) |
175 | 161 | if err != nil {
|
176 | 162 | return nil, err
|
177 | 163 | }
|
@@ -241,7 +227,7 @@ func commandDetails(path []string, root *cmds.Command) (*cmdDetails, error) {
|
241 | 227 | // It returns a client if the command should be executed on a daemon and nil if
|
242 | 228 | // it should be executed on a client. It returns an error if the command must
|
243 | 229 | // NOT be executed on either.
|
244 |
| -func commandShouldRunOnDaemon(details cmdDetails, req *cmds.Request, root *cmds.Command, cctx *oldcmds.Context) (http.Client, error) { |
| 230 | +func commandShouldRunOnDaemon(details cmdDetails, req *cmds.Request, cctx *oldcmds.Context) (http.Client, error) { |
245 | 231 | path := req.Path
|
246 | 232 | // root command.
|
247 | 233 | if len(path) < 1 {
|
@@ -478,24 +464,3 @@ func apiClientForAddr(addr ma.Multiaddr) (http.Client, error) {
|
478 | 464 |
|
479 | 465 | return http.NewClient(host, http.ClientWithAPIPrefix(corehttp.APIPath)), nil
|
480 | 466 | }
|
481 |
| - |
482 |
| -func isConnRefused(err error) bool { |
483 |
| - // unwrap url errors from http calls |
484 |
| - if urlerr, ok := err.(*url.Error); ok { |
485 |
| - err = urlerr.Err |
486 |
| - } |
487 |
| - |
488 |
| - netoperr, ok := err.(*net.OpError) |
489 |
| - if !ok { |
490 |
| - return false |
491 |
| - } |
492 |
| - |
493 |
| - return netoperr.Op == "dial" |
494 |
| -} |
495 |
| - |
496 |
| -func wrapContextCanceled(err error) error { |
497 |
| - if strings.Contains(err.Error(), "request canceled") { |
498 |
| - err = errRequestCanceled |
499 |
| - } |
500 |
| - return err |
501 |
| -} |
0 commit comments