Skip to content

Commit a93513c

Browse files
authored
Merge pull request #9 from dProxSocks/auto-enabling-libp2p-streammounting
auto enabling Libp2p StreamMounting if not already enabled
2 parents eddf4ef + c847705 commit a93513c

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

controllers/ipfs.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ type PingResult struct {
4747
Time int
4848
}
4949

50+
type ConfigResult struct {
51+
Key string
52+
Value bool
53+
}
54+
5055
type P2PStreamsList struct {
5156
Streams []*struct {
5257
HandlerID string
@@ -91,7 +96,6 @@ func ListListeners(c *gin.Context) {
9196
var response *P2PListenerList
9297
s := shell.NewLocalShell()
9398
reqBuilder := s.Request("p2p/ls")
94-
// reqBuilder.Arguments("arg1", "arg2")
9599
err := reqBuilder.Exec(context.Background(), &response)
96100
if err != nil {
97101
log.Fatal(err)
@@ -103,14 +107,25 @@ func ListStreams(c *gin.Context) {
103107
var response *P2PStreamsList
104108
s := shell.NewLocalShell()
105109
reqBuilder := s.Request("p2p/stream/ls")
106-
// reqBuilder.Arguments("arg1", "arg2")
107110
err := reqBuilder.Exec(context.Background(), &response)
108111
if err != nil {
109112
log.Fatal(err)
110113
}
111114
c.IndentedJSON(http.StatusOK, response.Streams)
112115
}
113116

117+
func EnableLibp2pStreaming() {
118+
var response *ConfigResult
119+
s := shell.NewLocalShell()
120+
reqBuilder := s.Request("config")
121+
reqBuilder.Arguments("Experimental.Libp2pStreamMounting", "true")
122+
reqBuilder.Option("bool", true)
123+
err := reqBuilder.Exec(context.Background(), &response)
124+
if err != nil {
125+
log.Fatal(err)
126+
}
127+
}
128+
114129
// Send echo request packets to IPFS hosts.
115130
func Ping(c *gin.Context) {
116131
var response *PingResult

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func main() {
5252
// Enable the Listener by default on the proxy port
5353
protocol := "/x/7proxies/1.0"
5454
target := "/ip4/127.0.0.1/tcp/" + strconv.Itoa(config.SocksPort)
55+
controllers.EnableLibp2pStreaming()
5556
controllers.Listen(protocol, target)
5657

5758
fmt.Println("───────────────────────────────────────────────────")

0 commit comments

Comments
 (0)