@@ -9,20 +9,20 @@ import (
9
9
"text/tabwriter"
10
10
11
11
cmds "github.com/ipfs/go-ipfs/commands"
12
- "github.com/ipfs/go-ipfs/core"
13
- cnet "github.com/ipfs/go-ipfs/corenet /net"
12
+ core "github.com/ipfs/go-ipfs/core"
13
+ ptpnet "github.com/ipfs/go-ipfs/ptp /net"
14
14
15
15
ma "gx/ipfs/QmcyqRMCAXVtYPS4DiBrA7sezL9rRGfW8Ctx7cywL4TXJj/go-multiaddr"
16
16
)
17
17
18
- // CorenetAppInfoOutput is output type of ls command
19
- type CorenetAppInfoOutput struct {
18
+ // PTPAppInfoOutput is output type of ls command
19
+ type PTPAppInfoOutput struct {
20
20
Protocol string
21
21
Address string
22
22
}
23
23
24
- // CorenetStreamInfoOutput is output type of streams command
25
- type CorenetStreamInfoOutput struct {
24
+ // PTPStreamInfoOutput is output type of streams command
25
+ type PTPStreamInfoOutput struct {
26
26
HandlerID string
27
27
Protocol string
28
28
LocalPeer string
@@ -31,38 +31,38 @@ type CorenetStreamInfoOutput struct {
31
31
RemoteAddress string
32
32
}
33
33
34
- // CorenetLsOutput is output type of ls command
35
- type CorenetLsOutput struct {
36
- Apps []CorenetAppInfoOutput
34
+ // PTPLsOutput is output type of ls command
35
+ type PTPLsOutput struct {
36
+ Apps []PTPAppInfoOutput
37
37
}
38
38
39
- // CorenetStreamsOutput is output type of streams command
40
- type CorenetStreamsOutput struct {
41
- Streams []CorenetStreamInfoOutput
39
+ // PTPStreamsOutput is output type of streams command
40
+ type PTPStreamsOutput struct {
41
+ Streams []PTPStreamInfoOutput
42
42
}
43
43
44
- // CorenetCmd is the 'ipfs corenet ' command
45
- var CorenetCmd = & cmds.Command {
44
+ // PTPCmd is the 'ipfs ptp ' command
45
+ var PTPCmd = & cmds.Command {
46
46
Helptext : cmds.HelpText {
47
47
Tagline : "Libp2p stream mounting." ,
48
48
ShortDescription : `
49
- Expose a local application to remote peers over libp2p
49
+ Create and use tunnels to remote peers over libp2p
50
50
51
51
Note: this command is experimental and subject to change as usecases and APIs are refined` ,
52
52
},
53
53
54
54
Subcommands : map [string ]* cmds.Command {
55
- "ls" : corenetLsCmd ,
56
- "streams" : corenetStreamsCmd ,
57
- "dial" : corenetDialCmd ,
58
- "listen" : corenetListenCmd ,
59
- "close" : corenetCloseCmd ,
55
+ "ls" : ptpLsCmd ,
56
+ "streams" : ptpStreamsCmd ,
57
+ "dial" : ptpDialCmd ,
58
+ "listen" : ptpListenCmd ,
59
+ "close" : ptpCloseCmd ,
60
60
},
61
61
}
62
62
63
- var corenetLsCmd = & cmds.Command {
63
+ var ptpLsCmd = & cmds.Command {
64
64
Helptext : cmds.HelpText {
65
- Tagline : "List active application protocol listeners." ,
65
+ Tagline : "List active p2p listeners." ,
66
66
},
67
67
Options : []cmds.Option {
68
68
cmds .BoolOption ("headers" , "v" , "Print table headers (HandlerID, Protocol, Local, Remote)." ).Default (false ),
@@ -85,22 +85,22 @@ var corenetLsCmd = &cmds.Command{
85
85
return
86
86
}
87
87
88
- output := & CorenetLsOutput {}
88
+ output := & PTPLsOutput {}
89
89
90
- for _ , app := range n .Corenet .Apps .Apps {
91
- output .Apps = append (output .Apps , CorenetAppInfoOutput {
90
+ for _ , app := range n .PTP .Apps .Apps {
91
+ output .Apps = append (output .Apps , PTPAppInfoOutput {
92
92
Protocol : app .Protocol ,
93
93
Address : app .Address .String (),
94
94
})
95
95
}
96
96
97
97
res .SetOutput (output )
98
98
},
99
- Type : CorenetLsOutput {},
99
+ Type : PTPLsOutput {},
100
100
Marshalers : cmds.MarshalerMap {
101
101
cmds .Text : func (res cmds.Response ) (io.Reader , error ) {
102
102
headers , _ , _ := res .Request ().Option ("headers" ).Bool ()
103
- list , _ := res .Output ().(* CorenetLsOutput )
103
+ list , _ := res .Output ().(* PTPLsOutput )
104
104
buf := new (bytes.Buffer )
105
105
w := tabwriter .NewWriter (buf , 1 , 2 , 1 , ' ' , 0 )
106
106
for _ , app := range list .Apps {
@@ -117,12 +117,12 @@ var corenetLsCmd = &cmds.Command{
117
117
},
118
118
}
119
119
120
- var corenetStreamsCmd = & cmds.Command {
120
+ var ptpStreamsCmd = & cmds.Command {
121
121
Helptext : cmds.HelpText {
122
- Tagline : "List active application protocol streams." ,
122
+ Tagline : "List active p2p streams." ,
123
123
},
124
124
Options : []cmds.Option {
125
- cmds .BoolOption ("headers" , "v" , "Print table headers (HandlerID , Protocol, Local, Remote)." ).Default (false ),
125
+ cmds .BoolOption ("headers" , "v" , "Print table headers (HagndlerID , Protocol, Local, Remote)." ).Default (false ),
126
126
},
127
127
Run : func (req cmds.Request , res cmds.Response ) {
128
128
n , err := req .InvocContext ().GetNode ()
@@ -142,10 +142,10 @@ var corenetStreamsCmd = &cmds.Command{
142
142
return
143
143
}
144
144
145
- output := & CorenetStreamsOutput {}
145
+ output := & PTPStreamsOutput {}
146
146
147
- for _ , s := range n .Corenet .Streams .Streams {
148
- output .Streams = append (output .Streams , CorenetStreamInfoOutput {
147
+ for _ , s := range n .PTP .Streams .Streams {
148
+ output .Streams = append (output .Streams , PTPStreamInfoOutput {
149
149
HandlerID : strconv .FormatUint (s .HandlerID , 10 ),
150
150
151
151
Protocol : s .Protocol ,
@@ -160,11 +160,11 @@ var corenetStreamsCmd = &cmds.Command{
160
160
161
161
res .SetOutput (output )
162
162
},
163
- Type : CorenetStreamsOutput {},
163
+ Type : PTPStreamsOutput {},
164
164
Marshalers : cmds.MarshalerMap {
165
165
cmds .Text : func (res cmds.Response ) (io.Reader , error ) {
166
166
headers , _ , _ := res .Request ().Option ("headers" ).Bool ()
167
- list , _ := res .Output ().(* CorenetStreamsOutput )
167
+ list , _ := res .Output ().(* PTPStreamsOutput )
168
168
buf := new (bytes.Buffer )
169
169
w := tabwriter .NewWriter (buf , 1 , 2 , 1 , ' ' , 0 )
170
170
for _ , stream := range list .Streams {
@@ -181,12 +181,11 @@ var corenetStreamsCmd = &cmds.Command{
181
181
},
182
182
}
183
183
184
- var corenetListenCmd = & cmds.Command {
184
+ var ptpListenCmd = & cmds.Command {
185
185
Helptext : cmds.HelpText {
186
186
Tagline : "Create application protocol listener and proxy to network multiaddr." ,
187
187
ShortDescription : `
188
- Register a p2p connection handler and proxies the connections to a specified
189
- address.
188
+ Register a p2p connection handler and proxies the connections to a specified address.
190
189
191
190
Note that the connections originate from the ipfs daemon process.
192
191
` ,
@@ -214,7 +213,7 @@ Note that the connections originate from the ipfs daemon process.
214
213
}
215
214
216
215
proto := "/app/" + req .Arguments ()[0 ]
217
- if cnet .CheckProtoExists (n , proto ) {
216
+ if ptpnet .CheckProtoExists (n , proto ) {
218
217
res .SetError (errors .New ("protocol handler already registered" ), cmds .ErrNormal )
219
218
return
220
219
}
@@ -225,30 +224,30 @@ Note that the connections originate from the ipfs daemon process.
225
224
return
226
225
}
227
226
228
- _ , err = cnet .NewListener (n , proto , addr )
227
+ _ , err = ptpnet .NewListener (n , proto , addr )
229
228
if err != nil {
230
229
res .SetError (err , cmds .ErrNormal )
231
230
return
232
231
}
233
232
234
233
// Successful response.
235
- res .SetOutput (& CorenetAppInfoOutput {
234
+ res .SetOutput (& PTPAppInfoOutput {
236
235
Protocol : proto ,
237
236
Address : addr .String (),
238
237
})
239
238
},
240
239
}
241
240
242
- var corenetDialCmd = & cmds.Command {
241
+ var ptpDialCmd = & cmds.Command {
243
242
Helptext : cmds.HelpText {
244
- Tagline : "Dial to an application service ." ,
243
+ Tagline : "Dial to a p2p listener ." ,
245
244
246
245
ShortDescription : `
247
246
Establish a new connection to a peer service.
248
247
249
248
When a connection is made to a peer service the ipfs daemon will setup one time
250
249
TCP listener and return it's bind port, this way a dialing application can
251
- transparently connect to a corenet service.
250
+ transparently connect to a p2p service.
252
251
` ,
253
252
},
254
253
Arguments : []cmds.Argument {
@@ -291,13 +290,13 @@ transparently connect to a corenet service.
291
290
}
292
291
}
293
292
294
- app , err := cnet .Dial (n , addr , peer , proto , bindAddr )
293
+ app , err := ptpnet .Dial (n , addr , peer , proto , bindAddr )
295
294
if err != nil {
296
295
res .SetError (err , cmds .ErrNormal )
297
296
return
298
297
}
299
298
300
- output := CorenetAppInfoOutput {
299
+ output := PTPAppInfoOutput {
301
300
Protocol : app .Protocol ,
302
301
Address : app .Address .String (),
303
302
}
@@ -306,13 +305,12 @@ transparently connect to a corenet service.
306
305
},
307
306
}
308
307
309
- var corenetCloseCmd = & cmds.Command {
308
+ var ptpCloseCmd = & cmds.Command {
310
309
Helptext : cmds.HelpText {
311
- Tagline : "Closes an active stream listener or client ." ,
310
+ Tagline : "Closes an active p2p stream or listener ." ,
312
311
},
313
312
Arguments : []cmds.Argument {
314
- cmds .StringArg ("HandlerID" , false , false , "Application listener or client HandlerID" ),
315
- cmds .StringArg ("Protocol" , false , false , "Application listener or client HandlerID" ),
313
+ cmds .StringArg ("Identifier" , false , false , "Stream HandlerID or p2p listener protocol" ),
316
314
},
317
315
Options : []cmds.Option {
318
316
cmds .BoolOption ("all" , "a" , "Close all streams and listeners." ).Default (false ),
@@ -344,7 +342,7 @@ var corenetCloseCmd = &cmds.Command{
344
342
345
343
if ! closeAll {
346
344
if len (req .Arguments ()) == 0 {
347
- res .SetError (errors .New ("no handlerID nor stream protocol specified" ), cmds .ErrNormal )
345
+ res .SetError (errors .New ("no handlerID nor listener protocol specified" ), cmds .ErrNormal )
348
346
return
349
347
}
350
348
@@ -357,7 +355,7 @@ var corenetCloseCmd = &cmds.Command{
357
355
}
358
356
359
357
if closeAll || useHandlerID {
360
- for _ , stream := range n .Corenet .Streams .Streams {
358
+ for _ , stream := range n .PTP .Streams .Streams {
361
359
if ! closeAll && handlerID != stream .HandlerID {
362
360
continue
363
361
}
@@ -369,7 +367,7 @@ var corenetCloseCmd = &cmds.Command{
369
367
}
370
368
371
369
if closeAll || ! useHandlerID {
372
- for _ , app := range n .Corenet .Apps .Apps {
370
+ for _ , app := range n .PTP .Apps .Apps {
373
371
if ! closeAll && app .Protocol != proto {
374
372
continue
375
373
}
0 commit comments