Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): forest-cli net reachability #4052

Merged
merged 2 commits into from
Mar 13, 2024
Merged

feat(cli): forest-cli net reachability #4052

merged 2 commits into from
Mar 13, 2024

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Mar 13, 2024

Summary of changes

Follow up of #4039

Changes introduced in this pull request:

  • Add forest-cli net reachability command (compatible with lotus net reachability) that prints information about reachability from the internet.
lotus git:(master) FULLNODE_API_INFO="/ip4/64.226.122.57/tcp/2345/http" lotus net reachability
2024-03-13T14:15:03.689+0800    WARN    cliutil util/apiinfo.go:94      API Token not set and requested, capabilities might be limited.
AutoNAT status:  Public
Public address: [/ip4/64.226.122.57/tcp/12345]forest git:(main) ✗  FULLNODE_API_INFO="/ip4/64.226.122.57/tcp/2345/http" cargo run --bin forest-cli -- net reachability
   Compiling forest-filecoin v0.17.0 (/home/me/git/forest)
    Finished dev [unoptimized] target(s) in 38.39s
     Running `target/debug/forest-cli net reachability`
AutoNAT status:  Public
Public address: [/ip4/64.226.122.57/tcp/12345]lotus git:(master) FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/1234/http" lotus net reachability
2024-03-13T17:13:52.599+0800    WARN    cliutil util/apiinfo.go:94      API Token not set and requested, capabilities might be limited.
AutoNAT status:  Privateforest git:(hm/net-reachability) FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/1234/http" cargo run --bin forest-cli -- net r
eachability
    Finished dev [unoptimized] target(s) in 3.48s
     Running `target/debug/forest-cli net reachability`
AutoNAT status:  Privatelotus git:(master) FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/2345/http" lotus net reachability
2024-03-13T17:16:26.466+0800    WARN    cliutil util/apiinfo.go:94      API Token not set and requested, capabilities might be limited.
AutoNAT status:  Unknownforest git:(hm/net-reachability) FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/2345/http" cargo run --bin forest-cli -- net r
eachability
    Finished dev [unoptimized] target(s) in 4.21s
     Running `target/debug/forest-cli net reachability`
AutoNAT status:  Unknown

Lotus code:

var NetReachability = &cli.Command{
	Name:  "reachability",
	Usage: "Print information about reachability from the internet",
	Action: func(cctx *cli.Context) error {
		api, closer, err := GetAPI(cctx)
		if err != nil {
			return err
		}
		defer closer()

		ctx := ReqContext(cctx)

		i, err := api.NetAutoNatStatus(ctx)
		if err != nil {
			return err
		}

		fmt.Println("AutoNAT status: ", i.Reachability.String())
		if len(i.PublicAddrs) > 0 {
			fmt.Println("Public address:", i.PublicAddrs)
		}
		return nil
	},
}

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@hanabi1224 hanabi1224 marked this pull request as ready for review March 13, 2024 06:32
@hanabi1224 hanabi1224 requested a review from a team as a code owner March 13, 2024 06:32
@hanabi1224 hanabi1224 requested review from ruseinov and lemmih and removed request for a team March 13, 2024 06:32
Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hanabi1224 Out of curiosity, have you checked the output when all interfaces are down?

@hanabi1224
Copy link
Contributor Author

hanabi1224 commented Mar 13, 2024

@LesnyRumcajs Updated the output of a local lotus node behind firewall and a forest node on startup

lotus git:(master) FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/1234/http" lotus net reachability
2024-03-13T17:13:52.599+0800    WARN    cliutil util/apiinfo.go:94      API Token not set and requested, capabilities might be limited.
AutoNAT status:  Privateforest git:(hm/net-reachability) FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/1234/http" cargo run --bin forest-cli -- net r
eachability
    Finished dev [unoptimized] target(s) in 3.48s
     Running `target/debug/forest-cli net reachability`
AutoNAT status:  Privatelotus git:(master) FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/2345/http" lotus net reachability
2024-03-13T17:16:26.466+0800    WARN    cliutil util/apiinfo.go:94      API Token not set and requested, capabilities might be limited.
AutoNAT status:  Unknownforest git:(hm/net-reachability) FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/2345/http" cargo run --bin forest-cli -- net r
eachability
    Finished dev [unoptimized] target(s) in 4.21s
     Running `target/debug/forest-cli net reachability`
AutoNAT status:  Unknown

Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it.

@ruseinov ruseinov added this pull request to the merge queue Mar 13, 2024
Merged via the queue into main with commit 49ca7c2 Mar 13, 2024
30 checks passed
@ruseinov ruseinov deleted the hm/net-reachability branch March 13, 2024 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants