golang中的持久隐藏服务

golang中的持久隐藏服务

php小编新一带你一起探索golang中的持久隐藏服务。Golang是一种高效的编程语言,以其卓越的性能和并发性而闻名。在这个快节奏的互联网时代,隐藏服务成为了许多应用程序的重要组成部分。它们提供了一种安全且可靠的方式,使应用程序能够长时间运行,同时隐藏其内部细节。本文将介绍golang中如何实现持久隐藏服务,并探讨其在实际应用中的应用场景和优势。无论您是初学者还是有经验的开发者,都能从中获得有益的知识和实践经验。让我们一起来探索这个有趣的话题吧!

问题内容

我正在尝试使用 github.com/cretz/bine/tor 在 golang 中托管一个隐藏服务。 但每次我启动程序时,都会启动一个新的隐藏服务(带有新的 .onion 地址),而不是之前的隐藏服务。

这是我使用的代码

package main import ( "context" "fmt" "github.com/cretz/bine/tor" "log" "net/http" "time" ) func main() { // Start tor with default config fmt.Println("Starting and registering onion service, please wait a couple of minutes...") t, err := tor.Start(nil, nil) if err != nil { log.Panicf("Unable to start Tor: %v", err) } defer t.Close() // Wait at most a few minutes to publish the service listenCtx, listenCancel := context.WithTimeout(context.Background(), 3*time.Minute) defer listenCancel() // Create a v3 onion service onion, err := t.Listen(listenCtx, &tor.ListenConf{Version3: true, RemotePorts: []int{80}}) if err != nil { log.Panicf("Unable to create onion service: %v", err) } defer onion.Close() fmt.Printf("Open Tor browser and navigate to http://%v.onionn", onion.ID) fmt.Println("Press enter to exit") // Serve the current folder from HTTP errCh := make(chan error, 1) go func() { errCh 登录后复制